2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2002-09-12 22:36:57 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2002
|
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2020-05-10 17:40:00 +00:00
|
|
|
#include <bootstage.h>
|
2019-08-01 15:46:42 +00:00
|
|
|
#include <env.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2020-02-03 14:36:16 +00:00
|
|
|
#include <malloc.h>
|
2009-05-16 10:14:54 +00:00
|
|
|
#include <stdio_dev.h>
|
2019-11-14 19:57:30 +00:00
|
|
|
#include <time.h>
|
2002-09-12 22:36:57 +00:00
|
|
|
#include <watchdog.h>
|
2011-12-09 15:54:02 +00:00
|
|
|
#include <div64.h>
|
2002-09-12 22:36:57 +00:00
|
|
|
#include <post.h>
|
|
|
|
|
2011-05-10 07:01:21 +00:00
|
|
|
#ifdef CONFIG_SYS_POST_HOTKEYS_GPIO
|
|
|
|
#include <asm/gpio.h>
|
|
|
|
#endif
|
|
|
|
|
2006-03-31 16:32:53 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2002-09-12 22:36:57 +00:00
|
|
|
#define POST_MAX_NUMBER 32
|
|
|
|
|
|
|
|
#define BOOTMODE_MAGIC 0xDEAD0000
|
|
|
|
|
2011-10-12 01:18:05 +00:00
|
|
|
int post_init_f(void)
|
2003-04-27 22:52:51 +00:00
|
|
|
{
|
|
|
|
int res = 0;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < post_list_size; i++) {
|
|
|
|
struct post_test *test = post_list + i;
|
|
|
|
|
2011-10-29 09:42:22 +00:00
|
|
|
if (test->init_f && test->init_f())
|
2003-04-27 22:52:51 +00:00
|
|
|
res = -1;
|
|
|
|
}
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2003-04-27 22:52:51 +00:00
|
|
|
gd->post_init_f_time = post_time_ms(0);
|
|
|
|
if (!gd->post_init_f_time)
|
2011-10-12 01:18:05 +00:00
|
|
|
printf("%s: post_time_ms not implemented\n", __FILE__);
|
2003-04-27 22:52:51 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2009-12-03 05:24:30 +00:00
|
|
|
/*
|
|
|
|
* Supply a default implementation for post_hotkeys_pressed() for boards
|
|
|
|
* without hotkey support. We always return 0 here, so that the
|
|
|
|
* long-running tests won't be started.
|
|
|
|
*
|
|
|
|
* Boards with hotkey support can override this weak default function
|
|
|
|
* by defining one in their board specific code.
|
|
|
|
*/
|
2014-10-08 20:57:25 +00:00
|
|
|
__weak int post_hotkeys_pressed(void)
|
2009-12-03 05:24:30 +00:00
|
|
|
{
|
2011-05-10 07:01:21 +00:00
|
|
|
#ifdef CONFIG_SYS_POST_HOTKEYS_GPIO
|
|
|
|
int ret;
|
|
|
|
unsigned gpio = CONFIG_SYS_POST_HOTKEYS_GPIO;
|
|
|
|
|
|
|
|
ret = gpio_request(gpio, "hotkeys");
|
|
|
|
if (ret) {
|
|
|
|
printf("POST: gpio hotkey request failed\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
gpio_direction_input(gpio);
|
|
|
|
ret = gpio_get_value(gpio);
|
|
|
|
gpio_free(gpio);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
#endif
|
|
|
|
|
2009-12-03 05:24:30 +00:00
|
|
|
return 0; /* No hotkeys supported */
|
|
|
|
}
|
|
|
|
|
2011-10-12 01:18:05 +00:00
|
|
|
void post_bootmode_init(void)
|
2002-09-12 22:36:57 +00:00
|
|
|
{
|
2011-10-12 01:18:05 +00:00
|
|
|
int bootmode = post_bootmode_get(0);
|
2003-07-24 23:38:38 +00:00
|
|
|
int newword;
|
2003-10-15 23:53:47 +00:00
|
|
|
|
2011-10-12 01:18:05 +00:00
|
|
|
if (post_hotkeys_pressed() && !(bootmode & POST_POWERTEST))
|
2003-07-24 23:38:38 +00:00
|
|
|
newword = BOOTMODE_MAGIC | POST_SLOWTEST;
|
2011-10-12 01:18:05 +00:00
|
|
|
else if (bootmode == 0)
|
2003-07-24 23:38:38 +00:00
|
|
|
newword = BOOTMODE_MAGIC | POST_POWERON;
|
2011-10-12 01:18:05 +00:00
|
|
|
else if (bootmode == POST_POWERON || bootmode == POST_SLOWTEST)
|
2003-07-24 23:38:38 +00:00
|
|
|
newword = BOOTMODE_MAGIC | POST_NORMAL;
|
2011-10-12 01:18:05 +00:00
|
|
|
else
|
2003-07-24 23:38:38 +00:00
|
|
|
/* Use old value */
|
2011-10-29 09:42:22 +00:00
|
|
|
newword = post_word_load() & ~POST_COLDBOOT;
|
2002-09-12 22:36:57 +00:00
|
|
|
|
2003-07-24 23:38:38 +00:00
|
|
|
if (bootmode == 0)
|
|
|
|
/* We are booting after power-on */
|
|
|
|
newword |= POST_COLDBOOT;
|
|
|
|
|
2011-10-12 01:18:05 +00:00
|
|
|
post_word_store(newword);
|
2003-07-24 23:38:38 +00:00
|
|
|
|
2002-12-08 09:53:23 +00:00
|
|
|
/* Reset activity record */
|
|
|
|
gd->post_log_word = 0;
|
2011-08-03 02:37:01 +00:00
|
|
|
gd->post_log_res = 0;
|
2002-09-12 22:36:57 +00:00
|
|
|
}
|
|
|
|
|
2011-10-12 01:18:05 +00:00
|
|
|
int post_bootmode_get(unsigned int *last_test)
|
2002-09-12 22:36:57 +00:00
|
|
|
{
|
2011-10-12 01:18:05 +00:00
|
|
|
unsigned long word = post_word_load();
|
2002-09-12 22:36:57 +00:00
|
|
|
int bootmode;
|
|
|
|
|
2011-10-12 01:18:05 +00:00
|
|
|
if ((word & 0xFFFF0000) != BOOTMODE_MAGIC)
|
2002-09-12 22:36:57 +00:00
|
|
|
return 0;
|
|
|
|
|
2003-07-24 23:38:38 +00:00
|
|
|
bootmode = word & 0x7F;
|
2002-09-12 22:36:57 +00:00
|
|
|
|
2011-10-12 01:18:05 +00:00
|
|
|
if (last_test && (bootmode & POST_POWERTEST))
|
2002-09-12 22:36:57 +00:00
|
|
|
*last_test = (word >> 8) & 0xFF;
|
|
|
|
|
|
|
|
return bootmode;
|
|
|
|
}
|
|
|
|
|
2002-12-08 09:53:23 +00:00
|
|
|
/* POST tests run before relocation only mark status bits .... */
|
2011-10-12 01:18:05 +00:00
|
|
|
static void post_log_mark_start(unsigned long testid)
|
2002-12-08 09:53:23 +00:00
|
|
|
{
|
2011-08-03 02:37:01 +00:00
|
|
|
gd->post_log_word |= testid;
|
2002-12-08 09:53:23 +00:00
|
|
|
}
|
|
|
|
|
2011-10-12 01:18:05 +00:00
|
|
|
static void post_log_mark_succ(unsigned long testid)
|
2002-12-08 09:53:23 +00:00
|
|
|
{
|
2011-08-03 02:37:01 +00:00
|
|
|
gd->post_log_res |= testid;
|
2002-12-08 09:53:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ... and the messages are output once we are relocated */
|
2020-11-28 08:43:10 +00:00
|
|
|
int post_output_backlog(void)
|
2002-12-08 09:53:23 +00:00
|
|
|
{
|
|
|
|
int j;
|
|
|
|
|
|
|
|
for (j = 0; j < post_list_size; j++) {
|
2011-08-03 02:37:01 +00:00
|
|
|
if (gd->post_log_word & (post_list[j].testid)) {
|
2011-10-29 09:42:22 +00:00
|
|
|
post_log("POST %s ", post_list[j].cmd);
|
2011-08-03 02:37:01 +00:00
|
|
|
if (gd->post_log_res & post_list[j].testid)
|
2011-10-29 09:42:22 +00:00
|
|
|
post_log("PASSED\n");
|
2004-02-23 22:22:28 +00:00
|
|
|
else {
|
2011-10-12 01:18:05 +00:00
|
|
|
post_log("FAILED\n");
|
2012-02-13 13:51:18 +00:00
|
|
|
bootstage_error(BOOTSTAGE_ID_POST_FAIL_R);
|
2004-02-23 22:22:28 +00:00
|
|
|
}
|
2002-12-08 09:53:23 +00:00
|
|
|
}
|
|
|
|
}
|
2020-11-28 08:43:10 +00:00
|
|
|
|
|
|
|
return 0;
|
2002-12-08 09:53:23 +00:00
|
|
|
}
|
|
|
|
|
2011-10-12 01:18:05 +00:00
|
|
|
static void post_bootmode_test_on(unsigned int last_test)
|
2002-09-12 22:36:57 +00:00
|
|
|
{
|
2011-10-12 01:18:05 +00:00
|
|
|
unsigned long word = post_word_load();
|
2002-09-12 22:36:57 +00:00
|
|
|
|
|
|
|
word |= POST_POWERTEST;
|
|
|
|
|
|
|
|
word |= (last_test & 0xFF) << 8;
|
|
|
|
|
2011-10-12 01:18:05 +00:00
|
|
|
post_word_store(word);
|
2002-09-12 22:36:57 +00:00
|
|
|
}
|
|
|
|
|
2011-10-12 01:18:05 +00:00
|
|
|
static void post_bootmode_test_off(void)
|
2002-09-12 22:36:57 +00:00
|
|
|
{
|
2011-10-12 01:18:05 +00:00
|
|
|
unsigned long word = post_word_load();
|
2002-09-12 22:36:57 +00:00
|
|
|
|
|
|
|
word &= ~POST_POWERTEST;
|
|
|
|
|
2011-10-12 01:18:05 +00:00
|
|
|
post_word_store(word);
|
2002-09-12 22:36:57 +00:00
|
|
|
}
|
|
|
|
|
2011-08-03 02:37:02 +00:00
|
|
|
#ifndef CONFIG_POST_SKIP_ENV_FLAGS
|
|
|
|
static void post_get_env_flags(int *test_flags)
|
2002-09-12 22:36:57 +00:00
|
|
|
{
|
2008-02-04 13:11:03 +00:00
|
|
|
int flag[] = { POST_POWERON, POST_NORMAL, POST_SLOWTEST,
|
|
|
|
POST_CRITICAL };
|
|
|
|
char *var[] = { "post_poweron", "post_normal", "post_slowtest",
|
|
|
|
"post_critical" };
|
2011-05-10 07:28:35 +00:00
|
|
|
int varnum = ARRAY_SIZE(var);
|
2002-09-12 22:36:57 +00:00
|
|
|
char list[128]; /* long enough for POST list */
|
|
|
|
char *name;
|
|
|
|
char *s;
|
|
|
|
int last;
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
for (i = 0; i < varnum; i++) {
|
2017-08-03 18:22:12 +00:00
|
|
|
if (env_get_f(var[i], list, sizeof(list)) <= 0)
|
2002-09-12 22:36:57 +00:00
|
|
|
continue;
|
|
|
|
|
2011-10-29 09:42:22 +00:00
|
|
|
for (j = 0; j < post_list_size; j++)
|
2002-09-12 22:36:57 +00:00
|
|
|
test_flags[j] &= ~flag[i];
|
|
|
|
|
|
|
|
last = 0;
|
|
|
|
name = list;
|
|
|
|
while (!last) {
|
2020-08-03 20:12:13 +00:00
|
|
|
while (*name == ' ')
|
2002-09-12 22:36:57 +00:00
|
|
|
name++;
|
|
|
|
if (*name == 0)
|
|
|
|
break;
|
|
|
|
s = name + 1;
|
|
|
|
while (*s && *s != ' ')
|
|
|
|
s++;
|
|
|
|
if (*s == 0)
|
|
|
|
last = 1;
|
|
|
|
else
|
|
|
|
*s = 0;
|
|
|
|
|
|
|
|
for (j = 0; j < post_list_size; j++) {
|
2011-10-29 09:42:22 +00:00
|
|
|
if (strcmp(post_list[j].cmd, name) == 0) {
|
2002-09-12 22:36:57 +00:00
|
|
|
test_flags[j] |= flag[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-12 01:18:05 +00:00
|
|
|
if (j == post_list_size)
|
2011-10-29 09:42:22 +00:00
|
|
|
printf("No such test: %s\n", name);
|
2002-09-12 22:36:57 +00:00
|
|
|
|
|
|
|
name = s + 1;
|
|
|
|
}
|
|
|
|
}
|
2011-08-03 02:37:02 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void post_get_flags(int *test_flags)
|
|
|
|
{
|
|
|
|
int j;
|
|
|
|
|
|
|
|
for (j = 0; j < post_list_size; j++)
|
|
|
|
test_flags[j] = post_list[j].flags;
|
|
|
|
|
|
|
|
#ifndef CONFIG_POST_SKIP_ENV_FLAGS
|
|
|
|
post_get_env_flags(test_flags);
|
|
|
|
#endif
|
2003-07-15 07:45:49 +00:00
|
|
|
|
2011-10-12 01:18:05 +00:00
|
|
|
for (j = 0; j < post_list_size; j++)
|
|
|
|
if (test_flags[j] & POST_POWERON)
|
2003-07-15 07:45:49 +00:00
|
|
|
test_flags[j] |= POST_SLOWTEST;
|
2002-09-12 22:36:57 +00:00
|
|
|
}
|
|
|
|
|
2014-10-08 20:57:25 +00:00
|
|
|
__weak void show_post_progress(unsigned int test_num, int before, int result)
|
2010-03-01 09:47:36 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-10-12 01:18:05 +00:00
|
|
|
static int post_run_single(struct post_test *test,
|
2002-09-12 22:36:57 +00:00
|
|
|
int test_flags, int flags, unsigned int i)
|
|
|
|
{
|
|
|
|
if ((flags & test_flags & POST_ALWAYS) &&
|
|
|
|
(flags & test_flags & POST_MEM)) {
|
2011-10-29 09:42:22 +00:00
|
|
|
WATCHDOG_RESET();
|
2002-09-12 22:36:57 +00:00
|
|
|
|
|
|
|
if (!(flags & POST_REBOOT)) {
|
2011-10-12 01:18:05 +00:00
|
|
|
if ((test_flags & POST_REBOOT) &&
|
|
|
|
!(flags & POST_MANUAL)) {
|
|
|
|
post_bootmode_test_on(
|
2008-02-04 13:11:03 +00:00
|
|
|
(gd->flags & GD_FLG_POSTFAIL) ?
|
|
|
|
POST_FAIL_SAVE | i : i);
|
2002-09-12 22:36:57 +00:00
|
|
|
}
|
|
|
|
|
2002-12-08 09:53:23 +00:00
|
|
|
if (test_flags & POST_PREREL)
|
2011-10-12 01:18:05 +00:00
|
|
|
post_log_mark_start(test->testid);
|
2002-12-08 09:53:23 +00:00
|
|
|
else
|
2011-10-12 01:18:05 +00:00
|
|
|
post_log("POST %s ", test->cmd);
|
2002-09-12 22:36:57 +00:00
|
|
|
}
|
|
|
|
|
2010-03-01 09:47:36 +00:00
|
|
|
show_post_progress(i, POST_BEFORE, POST_FAILED);
|
|
|
|
|
2002-12-08 09:53:23 +00:00
|
|
|
if (test_flags & POST_PREREL) {
|
2011-10-29 09:42:22 +00:00
|
|
|
if ((*test->test)(flags) == 0) {
|
2011-10-12 01:18:05 +00:00
|
|
|
post_log_mark_succ(test->testid);
|
2010-03-01 09:47:36 +00:00
|
|
|
show_post_progress(i, POST_AFTER, POST_PASSED);
|
2011-10-29 09:42:22 +00:00
|
|
|
} else {
|
2010-03-01 09:47:36 +00:00
|
|
|
show_post_progress(i, POST_AFTER, POST_FAILED);
|
2008-05-08 13:45:26 +00:00
|
|
|
if (test_flags & POST_CRITICAL)
|
|
|
|
gd->flags |= GD_FLG_POSTFAIL;
|
|
|
|
if (test_flags & POST_STOP)
|
|
|
|
gd->flags |= GD_FLG_POSTSTOP;
|
|
|
|
}
|
2002-12-08 09:53:23 +00:00
|
|
|
} else {
|
2011-07-14 08:15:06 +00:00
|
|
|
if ((*test->test)(flags) != 0) {
|
|
|
|
post_log("FAILED\n");
|
2012-02-13 13:51:18 +00:00
|
|
|
bootstage_error(BOOTSTAGE_ID_POST_FAIL_R);
|
2011-07-14 08:15:06 +00:00
|
|
|
show_post_progress(i, POST_AFTER, POST_FAILED);
|
|
|
|
if (test_flags & POST_CRITICAL)
|
|
|
|
gd->flags |= GD_FLG_POSTFAIL;
|
|
|
|
if (test_flags & POST_STOP)
|
|
|
|
gd->flags |= GD_FLG_POSTSTOP;
|
|
|
|
} else {
|
|
|
|
post_log("PASSED\n");
|
|
|
|
show_post_progress(i, POST_AFTER, POST_PASSED);
|
|
|
|
}
|
2002-12-08 09:53:23 +00:00
|
|
|
}
|
2002-09-12 22:36:57 +00:00
|
|
|
|
2011-10-29 09:42:22 +00:00
|
|
|
if ((test_flags & POST_REBOOT) && !(flags & POST_MANUAL))
|
2011-10-12 01:18:05 +00:00
|
|
|
post_bootmode_test_off();
|
2002-09-12 22:36:57 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-29 09:42:22 +00:00
|
|
|
int post_run(char *name, int flags)
|
2002-09-12 22:36:57 +00:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
int test_flags[POST_MAX_NUMBER];
|
|
|
|
|
2011-10-12 01:18:05 +00:00
|
|
|
post_get_flags(test_flags);
|
2002-09-12 22:36:57 +00:00
|
|
|
|
|
|
|
if (name == NULL) {
|
|
|
|
unsigned int last;
|
|
|
|
|
2008-05-08 13:45:26 +00:00
|
|
|
if (gd->flags & GD_FLG_POSTSTOP)
|
|
|
|
return 0;
|
|
|
|
|
2011-10-12 01:18:05 +00:00
|
|
|
if (post_bootmode_get(&last) & POST_POWERTEST) {
|
2008-02-04 13:11:03 +00:00
|
|
|
if (last & POST_FAIL_SAVE) {
|
|
|
|
last &= ~POST_FAIL_SAVE;
|
|
|
|
gd->flags |= GD_FLG_POSTFAIL;
|
|
|
|
}
|
2002-09-12 22:36:57 +00:00
|
|
|
if (last < post_list_size &&
|
|
|
|
(flags & test_flags[last] & POST_ALWAYS) &&
|
|
|
|
(flags & test_flags[last] & POST_MEM)) {
|
|
|
|
|
2011-10-12 01:18:05 +00:00
|
|
|
post_run_single(post_list + last,
|
2002-11-21 23:11:29 +00:00
|
|
|
test_flags[last],
|
|
|
|
flags | POST_REBOOT, last);
|
2002-09-12 22:36:57 +00:00
|
|
|
|
|
|
|
for (i = last + 1; i < post_list_size; i++) {
|
2008-05-08 13:45:26 +00:00
|
|
|
if (gd->flags & GD_FLG_POSTSTOP)
|
|
|
|
break;
|
2011-10-12 01:18:05 +00:00
|
|
|
post_run_single(post_list + i,
|
2002-11-21 23:11:29 +00:00
|
|
|
test_flags[i],
|
|
|
|
flags, i);
|
2002-09-12 22:36:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < post_list_size; i++) {
|
2008-05-08 13:45:26 +00:00
|
|
|
if (gd->flags & GD_FLG_POSTSTOP)
|
|
|
|
break;
|
2011-10-12 01:18:05 +00:00
|
|
|
post_run_single(post_list + i,
|
2002-11-21 23:11:29 +00:00
|
|
|
test_flags[i],
|
|
|
|
flags, i);
|
2002-09-12 22:36:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < post_list_size; i++) {
|
2011-10-29 09:42:22 +00:00
|
|
|
if (strcmp(post_list[i].cmd, name) == 0)
|
2002-09-12 22:36:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i < post_list_size) {
|
2008-05-30 07:48:14 +00:00
|
|
|
WATCHDOG_RESET();
|
2011-10-12 01:18:05 +00:00
|
|
|
return post_run_single(post_list + i,
|
2002-09-12 22:36:57 +00:00
|
|
|
test_flags[i],
|
|
|
|
flags, i);
|
|
|
|
} else {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-12 01:18:05 +00:00
|
|
|
static int post_info_single(struct post_test *test, int full)
|
2002-09-12 22:36:57 +00:00
|
|
|
{
|
|
|
|
if (test->flags & POST_MANUAL) {
|
|
|
|
if (full)
|
2011-10-12 01:18:05 +00:00
|
|
|
printf("%s - %s\n"
|
2002-09-12 22:36:57 +00:00
|
|
|
" %s\n", test->cmd, test->name, test->desc);
|
|
|
|
else
|
2011-10-12 01:18:05 +00:00
|
|
|
printf(" %-15s - %s\n", test->cmd, test->name);
|
2002-09-12 22:36:57 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-29 09:42:22 +00:00
|
|
|
int post_info(char *name)
|
2002-09-12 22:36:57 +00:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (name == NULL) {
|
2011-10-12 01:18:05 +00:00
|
|
|
for (i = 0; i < post_list_size; i++)
|
|
|
|
post_info_single(post_list + i, 0);
|
2002-09-12 22:36:57 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < post_list_size; i++) {
|
2011-10-29 09:42:22 +00:00
|
|
|
if (strcmp(post_list[i].cmd, name) == 0)
|
2002-09-12 22:36:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-10-29 09:42:22 +00:00
|
|
|
if (i < post_list_size)
|
2011-10-12 01:18:05 +00:00
|
|
|
return post_info_single(post_list + i, 1);
|
2011-10-29 09:42:22 +00:00
|
|
|
else
|
2002-09-12 22:36:57 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-12 01:18:05 +00:00
|
|
|
int post_log(char *format, ...)
|
2002-09-12 22:36:57 +00:00
|
|
|
{
|
|
|
|
va_list args;
|
2008-10-16 13:01:15 +00:00
|
|
|
char printbuffer[CONFIG_SYS_PBSIZE];
|
2002-09-12 22:36:57 +00:00
|
|
|
|
2011-10-29 09:42:22 +00:00
|
|
|
va_start(args, format);
|
2002-09-12 22:36:57 +00:00
|
|
|
|
|
|
|
/* For this to work, printbuffer must be larger than
|
|
|
|
* anything we ever want to print.
|
|
|
|
*/
|
2011-10-29 09:42:23 +00:00
|
|
|
vsprintf(printbuffer, format, args);
|
2011-10-29 09:42:22 +00:00
|
|
|
va_end(args);
|
2002-09-12 22:36:57 +00:00
|
|
|
|
|
|
|
/* Send to the stdout file */
|
2011-10-12 01:18:05 +00:00
|
|
|
puts(printbuffer);
|
2002-09-12 22:36:57 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-10-28 18:00:11 +00:00
|
|
|
#ifdef CONFIG_NEEDS_MANUAL_RELOC
|
2011-10-12 01:18:05 +00:00
|
|
|
void post_reloc(void)
|
2002-09-12 22:36:57 +00:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We have to relocate the test table manually
|
|
|
|
*/
|
|
|
|
for (i = 0; i < post_list_size; i++) {
|
|
|
|
ulong addr;
|
|
|
|
struct post_test *test = post_list + i;
|
|
|
|
|
|
|
|
if (test->name) {
|
2011-10-29 09:42:22 +00:00
|
|
|
addr = (ulong)(test->name) + gd->reloc_off;
|
2011-10-12 01:18:05 +00:00
|
|
|
test->name = (char *)addr;
|
2002-09-12 22:36:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (test->cmd) {
|
2011-10-29 09:42:22 +00:00
|
|
|
addr = (ulong)(test->cmd) + gd->reloc_off;
|
2011-10-12 01:18:05 +00:00
|
|
|
test->cmd = (char *)addr;
|
2002-09-12 22:36:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (test->desc) {
|
2011-10-29 09:42:22 +00:00
|
|
|
addr = (ulong)(test->desc) + gd->reloc_off;
|
2011-10-12 01:18:05 +00:00
|
|
|
test->desc = (char *)addr;
|
2002-09-12 22:36:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (test->test) {
|
2011-10-29 09:42:22 +00:00
|
|
|
addr = (ulong)(test->test) + gd->reloc_off;
|
2002-09-12 22:36:57 +00:00
|
|
|
test->test = (int (*)(int flags)) addr;
|
|
|
|
}
|
2003-04-27 22:52:51 +00:00
|
|
|
|
|
|
|
if (test->init_f) {
|
2011-10-29 09:42:22 +00:00
|
|
|
addr = (ulong)(test->init_f) + gd->reloc_off;
|
2003-04-27 22:52:51 +00:00
|
|
|
test->init_f = (int (*)(void)) addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (test->reloc) {
|
2011-10-29 09:42:22 +00:00
|
|
|
addr = (ulong)(test->reloc) + gd->reloc_off;
|
2003-04-27 22:52:51 +00:00
|
|
|
test->reloc = (void (*)(void)) addr;
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2003-04-27 22:52:51 +00:00
|
|
|
test->reloc();
|
|
|
|
}
|
2002-09-12 22:36:57 +00:00
|
|
|
}
|
|
|
|
}
|
2009-09-21 16:20:36 +00:00
|
|
|
#endif
|
2002-09-12 22:36:57 +00:00
|
|
|
|
2003-04-27 22:52:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Some tests (e.g. SYSMON) need the time when post_init_f started,
|
|
|
|
* but we cannot use get_timer() at this point.
|
|
|
|
*
|
|
|
|
* On PowerPC we implement it using the timebase register.
|
|
|
|
*/
|
2011-10-12 01:18:05 +00:00
|
|
|
unsigned long post_time_ms(unsigned long base)
|
2003-04-27 22:52:51 +00:00
|
|
|
{
|
2017-03-14 15:08:10 +00:00
|
|
|
#if defined(CONFIG_PPC) || defined(CONFIG_ARM)
|
2011-12-09 15:54:02 +00:00
|
|
|
return (unsigned long)lldiv(get_ticks(), get_tbclk() / CONFIG_SYS_HZ)
|
2011-10-12 01:18:05 +00:00
|
|
|
- base;
|
2003-04-27 22:52:51 +00:00
|
|
|
#else
|
2007-03-06 17:08:43 +00:00
|
|
|
#warning "Not implemented yet"
|
2003-04-27 22:52:51 +00:00
|
|
|
return 0; /* Not implemented yet */
|
|
|
|
#endif
|
|
|
|
}
|