mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-20 22:21:41 +00:00
cosmetic, post: Codingstyle cleanup
Signed-off-by: Heiko Schocher <hs@denx.de>
This commit is contained in:
parent
ee4014b005
commit
e92372c8a7
1 changed files with 59 additions and 68 deletions
127
post/post.c
127
post/post.c
|
@ -40,7 +40,7 @@ DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
||||||
#define BOOTMODE_MAGIC 0xDEAD0000
|
#define BOOTMODE_MAGIC 0xDEAD0000
|
||||||
|
|
||||||
int post_init_f (void)
|
int post_init_f(void)
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
@ -55,9 +55,7 @@ int post_init_f (void)
|
||||||
|
|
||||||
gd->post_init_f_time = post_time_ms(0);
|
gd->post_init_f_time = post_time_ms(0);
|
||||||
if (!gd->post_init_f_time)
|
if (!gd->post_init_f_time)
|
||||||
{
|
printf("%s: post_time_ms not implemented\n", __FILE__);
|
||||||
printf("post/post.c: post_time_ms seems not to be implemented\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -95,66 +93,61 @@ int post_hotkeys_pressed(void)
|
||||||
__attribute__((weak, alias("__post_hotkeys_pressed")));
|
__attribute__((weak, alias("__post_hotkeys_pressed")));
|
||||||
|
|
||||||
|
|
||||||
void post_bootmode_init (void)
|
void post_bootmode_init(void)
|
||||||
{
|
{
|
||||||
int bootmode = post_bootmode_get (0);
|
int bootmode = post_bootmode_get(0);
|
||||||
int newword;
|
int newword;
|
||||||
|
|
||||||
if (post_hotkeys_pressed() && !(bootmode & POST_POWERTEST)) {
|
if (post_hotkeys_pressed() && !(bootmode & POST_POWERTEST))
|
||||||
newword = BOOTMODE_MAGIC | POST_SLOWTEST;
|
newword = BOOTMODE_MAGIC | POST_SLOWTEST;
|
||||||
} else if (bootmode == 0) {
|
else if (bootmode == 0)
|
||||||
newword = BOOTMODE_MAGIC | POST_POWERON;
|
newword = BOOTMODE_MAGIC | POST_POWERON;
|
||||||
} else if (bootmode == POST_POWERON || bootmode == POST_SLOWTEST) {
|
else if (bootmode == POST_POWERON || bootmode == POST_SLOWTEST)
|
||||||
newword = BOOTMODE_MAGIC | POST_NORMAL;
|
newword = BOOTMODE_MAGIC | POST_NORMAL;
|
||||||
} else {
|
else
|
||||||
/* Use old value */
|
/* Use old value */
|
||||||
newword = post_word_load () & ~POST_COLDBOOT;
|
newword = post_word_load () & ~POST_COLDBOOT;
|
||||||
}
|
|
||||||
|
|
||||||
if (bootmode == 0)
|
if (bootmode == 0)
|
||||||
{
|
|
||||||
/* We are booting after power-on */
|
/* We are booting after power-on */
|
||||||
newword |= POST_COLDBOOT;
|
newword |= POST_COLDBOOT;
|
||||||
}
|
|
||||||
|
|
||||||
post_word_store (newword);
|
post_word_store(newword);
|
||||||
|
|
||||||
/* Reset activity record */
|
/* Reset activity record */
|
||||||
gd->post_log_word = 0;
|
gd->post_log_word = 0;
|
||||||
gd->post_log_res = 0;
|
gd->post_log_res = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int post_bootmode_get (unsigned int *last_test)
|
int post_bootmode_get(unsigned int *last_test)
|
||||||
{
|
{
|
||||||
unsigned long word = post_word_load ();
|
unsigned long word = post_word_load();
|
||||||
int bootmode;
|
int bootmode;
|
||||||
|
|
||||||
if ((word & 0xFFFF0000) != BOOTMODE_MAGIC) {
|
if ((word & 0xFFFF0000) != BOOTMODE_MAGIC)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
bootmode = word & 0x7F;
|
bootmode = word & 0x7F;
|
||||||
|
|
||||||
if (last_test && (bootmode & POST_POWERTEST)) {
|
if (last_test && (bootmode & POST_POWERTEST))
|
||||||
*last_test = (word >> 8) & 0xFF;
|
*last_test = (word >> 8) & 0xFF;
|
||||||
}
|
|
||||||
|
|
||||||
return bootmode;
|
return bootmode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* POST tests run before relocation only mark status bits .... */
|
/* POST tests run before relocation only mark status bits .... */
|
||||||
static void post_log_mark_start ( unsigned long testid )
|
static void post_log_mark_start(unsigned long testid)
|
||||||
{
|
{
|
||||||
gd->post_log_word |= testid;
|
gd->post_log_word |= testid;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void post_log_mark_succ ( unsigned long testid )
|
static void post_log_mark_succ(unsigned long testid)
|
||||||
{
|
{
|
||||||
gd->post_log_res |= testid;
|
gd->post_log_res |= testid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ... and the messages are output once we are relocated */
|
/* ... and the messages are output once we are relocated */
|
||||||
void post_output_backlog ( void )
|
void post_output_backlog(void)
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
|
@ -164,31 +157,31 @@ void post_output_backlog ( void )
|
||||||
if (gd->post_log_res & post_list[j].testid)
|
if (gd->post_log_res & post_list[j].testid)
|
||||||
post_log ("PASSED\n");
|
post_log ("PASSED\n");
|
||||||
else {
|
else {
|
||||||
post_log ("FAILED\n");
|
post_log("FAILED\n");
|
||||||
show_boot_progress (-31);
|
show_boot_progress(-31);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void post_bootmode_test_on (unsigned int last_test)
|
static void post_bootmode_test_on(unsigned int last_test)
|
||||||
{
|
{
|
||||||
unsigned long word = post_word_load ();
|
unsigned long word = post_word_load();
|
||||||
|
|
||||||
word |= POST_POWERTEST;
|
word |= POST_POWERTEST;
|
||||||
|
|
||||||
word |= (last_test & 0xFF) << 8;
|
word |= (last_test & 0xFF) << 8;
|
||||||
|
|
||||||
post_word_store (word);
|
post_word_store(word);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void post_bootmode_test_off (void)
|
static void post_bootmode_test_off(void)
|
||||||
{
|
{
|
||||||
unsigned long word = post_word_load ();
|
unsigned long word = post_word_load();
|
||||||
|
|
||||||
word &= ~POST_POWERTEST;
|
word &= ~POST_POWERTEST;
|
||||||
|
|
||||||
post_word_store (word);
|
post_word_store(word);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef CONFIG_POST_SKIP_ENV_FLAGS
|
#ifndef CONFIG_POST_SKIP_ENV_FLAGS
|
||||||
|
@ -235,9 +228,8 @@ static void post_get_env_flags(int *test_flags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (j == post_list_size) {
|
if (j == post_list_size)
|
||||||
printf ("No such test: %s\n", name);
|
printf ("No such test: %s\n", name);
|
||||||
}
|
|
||||||
|
|
||||||
name = s + 1;
|
name = s + 1;
|
||||||
}
|
}
|
||||||
|
@ -256,20 +248,18 @@ static void post_get_flags(int *test_flags)
|
||||||
post_get_env_flags(test_flags);
|
post_get_env_flags(test_flags);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (j = 0; j < post_list_size; j++) {
|
for (j = 0; j < post_list_size; j++)
|
||||||
if (test_flags[j] & POST_POWERON) {
|
if (test_flags[j] & POST_POWERON)
|
||||||
test_flags[j] |= POST_SLOWTEST;
|
test_flags[j] |= POST_SLOWTEST;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void __show_post_progress (unsigned int test_num, int before, int result)
|
void __show_post_progress(unsigned int test_num, int before, int result)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
void show_post_progress (unsigned int, int, int)
|
void show_post_progress(unsigned int, int, int)
|
||||||
__attribute__((weak, alias("__show_post_progress")));
|
__attribute__((weak, alias("__show_post_progress")));
|
||||||
|
|
||||||
static int post_run_single (struct post_test *test,
|
static int post_run_single(struct post_test *test,
|
||||||
int test_flags, int flags, unsigned int i)
|
int test_flags, int flags, unsigned int i)
|
||||||
{
|
{
|
||||||
if ((flags & test_flags & POST_ALWAYS) &&
|
if ((flags & test_flags & POST_ALWAYS) &&
|
||||||
|
@ -277,23 +267,24 @@ static int post_run_single (struct post_test *test,
|
||||||
WATCHDOG_RESET ();
|
WATCHDOG_RESET ();
|
||||||
|
|
||||||
if (!(flags & POST_REBOOT)) {
|
if (!(flags & POST_REBOOT)) {
|
||||||
if ((test_flags & POST_REBOOT) && !(flags & POST_MANUAL)) {
|
if ((test_flags & POST_REBOOT) &&
|
||||||
post_bootmode_test_on (
|
!(flags & POST_MANUAL)) {
|
||||||
|
post_bootmode_test_on(
|
||||||
(gd->flags & GD_FLG_POSTFAIL) ?
|
(gd->flags & GD_FLG_POSTFAIL) ?
|
||||||
POST_FAIL_SAVE | i : i);
|
POST_FAIL_SAVE | i : i);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test_flags & POST_PREREL)
|
if (test_flags & POST_PREREL)
|
||||||
post_log_mark_start ( test->testid );
|
post_log_mark_start(test->testid);
|
||||||
else
|
else
|
||||||
post_log ("POST %s ", test->cmd);
|
post_log("POST %s ", test->cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
show_post_progress(i, POST_BEFORE, POST_FAILED);
|
show_post_progress(i, POST_BEFORE, POST_FAILED);
|
||||||
|
|
||||||
if (test_flags & POST_PREREL) {
|
if (test_flags & POST_PREREL) {
|
||||||
if ((*test->test) (flags) == 0) {
|
if ((*test->test) (flags) == 0) {
|
||||||
post_log_mark_succ ( test->testid );
|
post_log_mark_succ(test->testid);
|
||||||
show_post_progress(i, POST_AFTER, POST_PASSED);
|
show_post_progress(i, POST_AFTER, POST_PASSED);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -319,7 +310,7 @@ 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 ();
|
post_bootmode_test_off();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -333,7 +324,7 @@ int post_run (char *name, int flags)
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int test_flags[POST_MAX_NUMBER];
|
int test_flags[POST_MAX_NUMBER];
|
||||||
|
|
||||||
post_get_flags (test_flags);
|
post_get_flags(test_flags);
|
||||||
|
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
unsigned int last;
|
unsigned int last;
|
||||||
|
@ -341,7 +332,7 @@ int post_run (char *name, int flags)
|
||||||
if (gd->flags & GD_FLG_POSTSTOP)
|
if (gd->flags & GD_FLG_POSTSTOP)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (post_bootmode_get (&last) & POST_POWERTEST) {
|
if (post_bootmode_get(&last) & POST_POWERTEST) {
|
||||||
if (last & POST_FAIL_SAVE) {
|
if (last & POST_FAIL_SAVE) {
|
||||||
last &= ~POST_FAIL_SAVE;
|
last &= ~POST_FAIL_SAVE;
|
||||||
gd->flags |= GD_FLG_POSTFAIL;
|
gd->flags |= GD_FLG_POSTFAIL;
|
||||||
|
@ -350,14 +341,14 @@ int post_run (char *name, int flags)
|
||||||
(flags & test_flags[last] & POST_ALWAYS) &&
|
(flags & test_flags[last] & POST_ALWAYS) &&
|
||||||
(flags & test_flags[last] & POST_MEM)) {
|
(flags & test_flags[last] & POST_MEM)) {
|
||||||
|
|
||||||
post_run_single (post_list + last,
|
post_run_single(post_list + last,
|
||||||
test_flags[last],
|
test_flags[last],
|
||||||
flags | POST_REBOOT, last);
|
flags | POST_REBOOT, last);
|
||||||
|
|
||||||
for (i = last + 1; i < post_list_size; i++) {
|
for (i = last + 1; i < post_list_size; i++) {
|
||||||
if (gd->flags & GD_FLG_POSTSTOP)
|
if (gd->flags & GD_FLG_POSTSTOP)
|
||||||
break;
|
break;
|
||||||
post_run_single (post_list + i,
|
post_run_single(post_list + i,
|
||||||
test_flags[i],
|
test_flags[i],
|
||||||
flags, i);
|
flags, i);
|
||||||
}
|
}
|
||||||
|
@ -366,7 +357,7 @@ int post_run (char *name, int flags)
|
||||||
for (i = 0; i < post_list_size; i++) {
|
for (i = 0; i < post_list_size; i++) {
|
||||||
if (gd->flags & GD_FLG_POSTSTOP)
|
if (gd->flags & GD_FLG_POSTSTOP)
|
||||||
break;
|
break;
|
||||||
post_run_single (post_list + i,
|
post_run_single(post_list + i,
|
||||||
test_flags[i],
|
test_flags[i],
|
||||||
flags, i);
|
flags, i);
|
||||||
}
|
}
|
||||||
|
@ -381,7 +372,7 @@ int post_run (char *name, int flags)
|
||||||
|
|
||||||
if (i < post_list_size) {
|
if (i < post_list_size) {
|
||||||
WATCHDOG_RESET();
|
WATCHDOG_RESET();
|
||||||
return post_run_single (post_list + i,
|
return post_run_single(post_list + i,
|
||||||
test_flags[i],
|
test_flags[i],
|
||||||
flags, i);
|
flags, i);
|
||||||
} else {
|
} else {
|
||||||
|
@ -390,14 +381,14 @@ int post_run (char *name, int flags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int post_info_single (struct post_test *test, int full)
|
static int post_info_single(struct post_test *test, int full)
|
||||||
{
|
{
|
||||||
if (test->flags & POST_MANUAL) {
|
if (test->flags & POST_MANUAL) {
|
||||||
if (full)
|
if (full)
|
||||||
printf ("%s - %s\n"
|
printf("%s - %s\n"
|
||||||
" %s\n", test->cmd, test->name, test->desc);
|
" %s\n", test->cmd, test->name, test->desc);
|
||||||
else
|
else
|
||||||
printf (" %-15s - %s\n", test->cmd, test->name);
|
printf(" %-15s - %s\n", test->cmd, test->name);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -410,9 +401,8 @@ int post_info (char *name)
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
for (i = 0; i < post_list_size; i++) {
|
for (i = 0; i < post_list_size; i++)
|
||||||
post_info_single (post_list + i, 0);
|
post_info_single(post_list + i, 0);
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -422,14 +412,14 @@ int post_info (char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < post_list_size) {
|
if (i < post_list_size) {
|
||||||
return post_info_single (post_list + i, 1);
|
return post_info_single(post_list + i, 1);
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int post_log (char *format, ...)
|
int post_log(char *format, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
uint i;
|
uint i;
|
||||||
|
@ -445,17 +435,17 @@ int post_log (char *format, ...)
|
||||||
|
|
||||||
#ifdef CONFIG_LOGBUFFER
|
#ifdef CONFIG_LOGBUFFER
|
||||||
/* Send to the logbuffer */
|
/* Send to the logbuffer */
|
||||||
logbuff_log (printbuffer);
|
logbuff_log(printbuffer);
|
||||||
#else
|
#else
|
||||||
/* Send to the stdout file */
|
/* Send to the stdout file */
|
||||||
puts (printbuffer);
|
puts(printbuffer);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_NEEDS_MANUAL_RELOC
|
#ifdef CONFIG_NEEDS_MANUAL_RELOC
|
||||||
void post_reloc (void)
|
void post_reloc(void)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
|
@ -468,17 +458,17 @@ void post_reloc (void)
|
||||||
|
|
||||||
if (test->name) {
|
if (test->name) {
|
||||||
addr = (ulong) (test->name) + gd->reloc_off;
|
addr = (ulong) (test->name) + gd->reloc_off;
|
||||||
test->name = (char *) addr;
|
test->name = (char *)addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test->cmd) {
|
if (test->cmd) {
|
||||||
addr = (ulong) (test->cmd) + gd->reloc_off;
|
addr = (ulong) (test->cmd) + gd->reloc_off;
|
||||||
test->cmd = (char *) addr;
|
test->cmd = (char *)addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test->desc) {
|
if (test->desc) {
|
||||||
addr = (ulong) (test->desc) + gd->reloc_off;
|
addr = (ulong) (test->desc) + gd->reloc_off;
|
||||||
test->desc = (char *) addr;
|
test->desc = (char *)addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test->test) {
|
if (test->test) {
|
||||||
|
@ -508,10 +498,11 @@ void post_reloc (void)
|
||||||
*
|
*
|
||||||
* On PowerPC we implement it using the timebase register.
|
* On PowerPC we implement it using the timebase register.
|
||||||
*/
|
*/
|
||||||
unsigned long post_time_ms (unsigned long base)
|
unsigned long post_time_ms(unsigned long base)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_PPC
|
#ifdef CONFIG_PPC
|
||||||
return (unsigned long)(get_ticks () / (get_tbclk () / CONFIG_SYS_HZ)) - base;
|
return (unsigned long)(get_ticks() / (get_tbclk() / CONFIG_SYS_HZ))
|
||||||
|
- base;
|
||||||
#else
|
#else
|
||||||
#warning "Not implemented yet"
|
#warning "Not implemented yet"
|
||||||
return 0; /* Not implemented yet */
|
return 0; /* Not implemented yet */
|
||||||
|
|
Loading…
Add table
Reference in a new issue