X-Git-Url: https://git.librecmc.org/?p=oweals%2Fu-boot.git;a=blobdiff_plain;f=post%2Fpost.c;h=6687e0b75cac897decf160dc41309dd773dc45a6;hp=dc9c0f2cf89068b386645b3b9fb22242f287238d;hb=1099b2abef35c3c887f6afac1a8ef18c7924d5d2;hpb=87a5d601031652293ec4b729fdb7ee01bbd940a8 diff --git a/post/post.c b/post/post.c index dc9c0f2cf8..6687e0b75c 100644 --- a/post/post.c +++ b/post/post.c @@ -1,39 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * (C) Copyright 2002 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. - * - * See file CREDITS for list of people who contributed to this - * project. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA */ #include +#include +#include +#include +#include #include +#include #include +#include #include #ifdef CONFIG_SYS_POST_HOTKEYS_GPIO #include #endif -#ifdef CONFIG_LOGBUFFER -#include -#endif - DECLARE_GLOBAL_DATA_PTR; #define POST_MAX_NUMBER 32 @@ -48,9 +33,8 @@ int post_init_f(void) for (i = 0; i < post_list_size; i++) { struct post_test *test = post_list + i; - if (test->init_f && test->init_f()) { + if (test->init_f && test->init_f()) res = -1; - } } gd->post_init_f_time = post_time_ms(0); @@ -68,7 +52,7 @@ int post_init_f(void) * Boards with hotkey support can override this weak default function * by defining one in their board specific code. */ -int __post_hotkeys_pressed(void) +__weak int post_hotkeys_pressed(void) { #ifdef CONFIG_SYS_POST_HOTKEYS_GPIO int ret; @@ -89,9 +73,6 @@ int __post_hotkeys_pressed(void) return 0; /* No hotkeys supported */ } -int post_hotkeys_pressed(void) - __attribute__((weak, alias("__post_hotkeys_pressed"))); - void post_bootmode_init(void) { @@ -106,7 +87,7 @@ void post_bootmode_init(void) newword = BOOTMODE_MAGIC | POST_NORMAL; else /* Use old value */ - newword = post_word_load () & ~POST_COLDBOOT; + newword = post_word_load() & ~POST_COLDBOOT; if (bootmode == 0) /* We are booting after power-on */ @@ -153,12 +134,12 @@ void post_output_backlog(void) for (j = 0; j < post_list_size; j++) { if (gd->post_log_word & (post_list[j].testid)) { - post_log ("POST %s ", post_list[j].cmd); + post_log("POST %s ", post_list[j].cmd); if (gd->post_log_res & post_list[j].testid) - post_log ("PASSED\n"); + post_log("PASSED\n"); else { post_log("FAILED\n"); - show_boot_progress(-31); + bootstage_error(BOOTSTAGE_ID_POST_FAIL_R); } } } @@ -199,12 +180,11 @@ static void post_get_env_flags(int *test_flags) int i, j; for (i = 0; i < varnum; i++) { - if (getenv_f(var[i], list, sizeof (list)) <= 0) + if (env_get_f(var[i], list, sizeof(list)) <= 0) continue; - for (j = 0; j < post_list_size; j++) { + for (j = 0; j < post_list_size; j++) test_flags[j] &= ~flag[i]; - } last = 0; name = list; @@ -222,14 +202,14 @@ static void post_get_env_flags(int *test_flags) *s = 0; for (j = 0; j < post_list_size; j++) { - if (strcmp (post_list[j].cmd, name) == 0) { + if (strcmp(post_list[j].cmd, name) == 0) { test_flags[j] |= flag[i]; break; } } if (j == post_list_size) - printf ("No such test: %s\n", name); + printf("No such test: %s\n", name); name = s + 1; } @@ -253,18 +233,16 @@ static void post_get_flags(int *test_flags) test_flags[j] |= POST_SLOWTEST; } -void __show_post_progress(unsigned int test_num, int before, int result) +__weak void show_post_progress(unsigned int test_num, int before, int result) { } -void show_post_progress(unsigned int, int, int) - __attribute__((weak, alias("__show_post_progress"))); static int post_run_single(struct post_test *test, int test_flags, int flags, unsigned int i) { if ((flags & test_flags & POST_ALWAYS) && (flags & test_flags & POST_MEM)) { - WATCHDOG_RESET (); + WATCHDOG_RESET(); if (!(flags & POST_REBOOT)) { if ((test_flags & POST_REBOOT) && @@ -283,11 +261,10 @@ static int post_run_single(struct post_test *test, show_post_progress(i, POST_BEFORE, POST_FAILED); if (test_flags & POST_PREREL) { - if ((*test->test) (flags) == 0) { + if ((*test->test)(flags) == 0) { post_log_mark_succ(test->testid); show_post_progress(i, POST_AFTER, POST_PASSED); - } - else { + } else { show_post_progress(i, POST_AFTER, POST_FAILED); if (test_flags & POST_CRITICAL) gd->flags |= GD_FLG_POSTFAIL; @@ -297,7 +274,7 @@ static int post_run_single(struct post_test *test, } else { if ((*test->test)(flags) != 0) { post_log("FAILED\n"); - show_boot_progress(-32); + bootstage_error(BOOTSTAGE_ID_POST_FAIL_R); show_post_progress(i, POST_AFTER, POST_FAILED); if (test_flags & POST_CRITICAL) gd->flags |= GD_FLG_POSTFAIL; @@ -309,9 +286,8 @@ static int post_run_single(struct post_test *test, } } - if ((test_flags & POST_REBOOT) && !(flags & POST_MANUAL)) { + if ((test_flags & POST_REBOOT) && !(flags & POST_MANUAL)) post_bootmode_test_off(); - } return 0; } else { @@ -319,7 +295,7 @@ static int post_run_single(struct post_test *test, } } -int post_run (char *name, int flags) +int post_run(char *name, int flags) { unsigned int i; int test_flags[POST_MAX_NUMBER]; @@ -366,7 +342,7 @@ int post_run (char *name, int flags) return 0; } else { for (i = 0; i < post_list_size; i++) { - if (strcmp (post_list[i].cmd, name) == 0) + if (strcmp(post_list[i].cmd, name) == 0) break; } @@ -396,7 +372,7 @@ static int post_info_single(struct post_test *test, int full) } } -int post_info (char *name) +int post_info(char *name) { unsigned int i; @@ -407,39 +383,32 @@ int post_info (char *name) return 0; } else { for (i = 0; i < post_list_size; i++) { - if (strcmp (post_list[i].cmd, name) == 0) + if (strcmp(post_list[i].cmd, name) == 0) break; } - if (i < post_list_size) { + if (i < post_list_size) return post_info_single(post_list + i, 1); - } else { + else return -1; - } } } int post_log(char *format, ...) { va_list args; - uint i; char printbuffer[CONFIG_SYS_PBSIZE]; - va_start (args, format); + va_start(args, format); /* For this to work, printbuffer must be larger than * anything we ever want to print. */ - i = vsprintf (printbuffer, format, args); - va_end (args); + vsprintf(printbuffer, format, args); + va_end(args); -#ifdef CONFIG_LOGBUFFER - /* Send to the logbuffer */ - logbuff_log(printbuffer); -#else /* Send to the stdout file */ puts(printbuffer); -#endif return 0; } @@ -457,32 +426,32 @@ void post_reloc(void) struct post_test *test = post_list + i; if (test->name) { - addr = (ulong) (test->name) + gd->reloc_off; + addr = (ulong)(test->name) + gd->reloc_off; test->name = (char *)addr; } if (test->cmd) { - addr = (ulong) (test->cmd) + gd->reloc_off; + addr = (ulong)(test->cmd) + gd->reloc_off; test->cmd = (char *)addr; } if (test->desc) { - addr = (ulong) (test->desc) + gd->reloc_off; + addr = (ulong)(test->desc) + gd->reloc_off; test->desc = (char *)addr; } if (test->test) { - addr = (ulong) (test->test) + gd->reloc_off; + addr = (ulong)(test->test) + gd->reloc_off; test->test = (int (*)(int flags)) addr; } if (test->init_f) { - addr = (ulong) (test->init_f) + gd->reloc_off; + addr = (ulong)(test->init_f) + gd->reloc_off; test->init_f = (int (*)(void)) addr; } if (test->reloc) { - addr = (ulong) (test->reloc) + gd->reloc_off; + addr = (ulong)(test->reloc) + gd->reloc_off; test->reloc = (void (*)(void)) addr; test->reloc(); @@ -501,7 +470,7 @@ void post_reloc(void) unsigned long post_time_ms(unsigned long base) { #if defined(CONFIG_PPC) || defined(CONFIG_ARM) - return (unsigned long)(get_ticks() / (get_tbclk() / CONFIG_SYS_HZ)) + return (unsigned long)lldiv(get_ticks(), get_tbclk() / CONFIG_SYS_HZ) - base; #else #warning "Not implemented yet"