blob: 946d9094d451fab9116fbc4d93061988fd985273 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
wdenka042ac82002-09-12 22:36:57 +00002/*
3 * (C) Copyright 2002
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
wdenka042ac82002-09-12 22:36:57 +00005 */
6
7#include <common.h>
Simon Glass52f24232020-05-10 11:40:00 -06008#include <bootstage.h>
Simon Glass3a7d5572019-08-01 09:46:42 -06009#include <env.h>
Simon Glassf7ae49f2020-05-10 11:40:05 -060010#include <log.h>
Simon Glass336d4612020-02-03 07:36:16 -070011#include <malloc.h>
Jean-Christophe PLAGNIOL-VILLARD52cb4d42009-05-16 12:14:54 +020012#include <stdio_dev.h>
Simon Glass10453152019-11-14 12:57:30 -070013#include <time.h>
wdenka042ac82002-09-12 22:36:57 +000014#include <watchdog.h>
Christian Rieschc90a4dd2011-12-09 16:54:02 +010015#include <div64.h>
wdenka042ac82002-09-12 22:36:57 +000016#include <post.h>
Simon Glass401d1c42020-10-30 21:38:53 -060017#include <asm/global_data.h>
wdenka042ac82002-09-12 22:36:57 +000018
Tom Rini1e019502022-12-04 10:14:17 -050019#ifdef CFG_SYS_POST_HOTKEYS_GPIO
Mike Frysinger9146d132011-05-10 07:01:21 +000020#include <asm/gpio.h>
21#endif
22
Wolfgang Denkd87080b2006-03-31 18:32:53 +020023DECLARE_GLOBAL_DATA_PTR;
24
wdenka042ac82002-09-12 22:36:57 +000025#define POST_MAX_NUMBER 32
26
27#define BOOTMODE_MAGIC 0xDEAD0000
28
Heiko Schochere92372c2011-10-12 01:18:05 +000029int post_init_f(void)
wdenk4532cb62003-04-27 22:52:51 +000030{
wdenk4532cb62003-04-27 22:52:51 +000031 int res = 0;
32 unsigned int i;
33
34 for (i = 0; i < post_list_size; i++) {
35 struct post_test *test = post_list + i;
36
Wolfgang Denk50da8372011-10-29 09:42:22 +000037 if (test->init_f && test->init_f())
wdenk4532cb62003-04-27 22:52:51 +000038 res = -1;
wdenk4532cb62003-04-27 22:52:51 +000039 }
wdenk8bde7f72003-06-27 21:31:46 +000040
wdenk4532cb62003-04-27 22:52:51 +000041 gd->post_init_f_time = post_time_ms(0);
42 if (!gd->post_init_f_time)
Heiko Schochere92372c2011-10-12 01:18:05 +000043 printf("%s: post_time_ms not implemented\n", __FILE__);
wdenk4532cb62003-04-27 22:52:51 +000044
45 return res;
46}
47
Stefan Roese39ff7d52009-12-03 06:24:30 +010048/*
49 * Supply a default implementation for post_hotkeys_pressed() for boards
50 * without hotkey support. We always return 0 here, so that the
51 * long-running tests won't be started.
52 *
53 * Boards with hotkey support can override this weak default function
54 * by defining one in their board specific code.
55 */
Jeroen Hofstee002ad7b2014-10-08 22:57:25 +020056__weak int post_hotkeys_pressed(void)
Stefan Roese39ff7d52009-12-03 06:24:30 +010057{
Tom Rini1e019502022-12-04 10:14:17 -050058#ifdef CFG_SYS_POST_HOTKEYS_GPIO
Mike Frysinger9146d132011-05-10 07:01:21 +000059 int ret;
Tom Rini1e019502022-12-04 10:14:17 -050060 unsigned gpio = CFG_SYS_POST_HOTKEYS_GPIO;
Mike Frysinger9146d132011-05-10 07:01:21 +000061
62 ret = gpio_request(gpio, "hotkeys");
63 if (ret) {
64 printf("POST: gpio hotkey request failed\n");
65 return 0;
66 }
67
68 gpio_direction_input(gpio);
69 ret = gpio_get_value(gpio);
70 gpio_free(gpio);
71
72 return ret;
73#endif
74
Stefan Roese39ff7d52009-12-03 06:24:30 +010075 return 0; /* No hotkeys supported */
76}
Stefan Roese39ff7d52009-12-03 06:24:30 +010077
Heiko Schochere92372c2011-10-12 01:18:05 +000078void post_bootmode_init(void)
wdenka042ac82002-09-12 22:36:57 +000079{
Heiko Schochere92372c2011-10-12 01:18:05 +000080 int bootmode = post_bootmode_get(0);
wdenk27b207f2003-07-24 23:38:38 +000081 int newword;
wdenk42d1f032003-10-15 23:53:47 +000082
Heiko Schochere92372c2011-10-12 01:18:05 +000083 if (post_hotkeys_pressed() && !(bootmode & POST_POWERTEST))
wdenk27b207f2003-07-24 23:38:38 +000084 newword = BOOTMODE_MAGIC | POST_SLOWTEST;
Heiko Schochere92372c2011-10-12 01:18:05 +000085 else if (bootmode == 0)
wdenk27b207f2003-07-24 23:38:38 +000086 newword = BOOTMODE_MAGIC | POST_POWERON;
Heiko Schochere92372c2011-10-12 01:18:05 +000087 else if (bootmode == POST_POWERON || bootmode == POST_SLOWTEST)
wdenk27b207f2003-07-24 23:38:38 +000088 newword = BOOTMODE_MAGIC | POST_NORMAL;
Heiko Schochere92372c2011-10-12 01:18:05 +000089 else
wdenk27b207f2003-07-24 23:38:38 +000090 /* Use old value */
Wolfgang Denk50da8372011-10-29 09:42:22 +000091 newword = post_word_load() & ~POST_COLDBOOT;
wdenka042ac82002-09-12 22:36:57 +000092
wdenk27b207f2003-07-24 23:38:38 +000093 if (bootmode == 0)
wdenk27b207f2003-07-24 23:38:38 +000094 /* We are booting after power-on */
95 newword |= POST_COLDBOOT;
wdenk27b207f2003-07-24 23:38:38 +000096
Heiko Schochere92372c2011-10-12 01:18:05 +000097 post_word_store(newword);
wdenk27b207f2003-07-24 23:38:38 +000098
wdenk228f29a2002-12-08 09:53:23 +000099 /* Reset activity record */
100 gd->post_log_word = 0;
Valentin Longchamp79843952011-08-03 02:37:01 +0000101 gd->post_log_res = 0;
wdenka042ac82002-09-12 22:36:57 +0000102}
103
Heiko Schochere92372c2011-10-12 01:18:05 +0000104int post_bootmode_get(unsigned int *last_test)
wdenka042ac82002-09-12 22:36:57 +0000105{
Heiko Schochere92372c2011-10-12 01:18:05 +0000106 unsigned long word = post_word_load();
wdenka042ac82002-09-12 22:36:57 +0000107 int bootmode;
108
Heiko Schochere92372c2011-10-12 01:18:05 +0000109 if ((word & 0xFFFF0000) != BOOTMODE_MAGIC)
wdenka042ac82002-09-12 22:36:57 +0000110 return 0;
wdenka042ac82002-09-12 22:36:57 +0000111
wdenk27b207f2003-07-24 23:38:38 +0000112 bootmode = word & 0x7F;
wdenka042ac82002-09-12 22:36:57 +0000113
Heiko Schochere92372c2011-10-12 01:18:05 +0000114 if (last_test && (bootmode & POST_POWERTEST))
wdenka042ac82002-09-12 22:36:57 +0000115 *last_test = (word >> 8) & 0xFF;
wdenka042ac82002-09-12 22:36:57 +0000116
117 return bootmode;
118}
119
wdenk228f29a2002-12-08 09:53:23 +0000120/* POST tests run before relocation only mark status bits .... */
Heiko Schochere92372c2011-10-12 01:18:05 +0000121static void post_log_mark_start(unsigned long testid)
wdenk228f29a2002-12-08 09:53:23 +0000122{
Valentin Longchamp79843952011-08-03 02:37:01 +0000123 gd->post_log_word |= testid;
wdenk228f29a2002-12-08 09:53:23 +0000124}
125
Heiko Schochere92372c2011-10-12 01:18:05 +0000126static void post_log_mark_succ(unsigned long testid)
wdenk228f29a2002-12-08 09:53:23 +0000127{
Valentin Longchamp79843952011-08-03 02:37:01 +0000128 gd->post_log_res |= testid;
wdenk228f29a2002-12-08 09:53:23 +0000129}
130
131/* ... and the messages are output once we are relocated */
Ovidiu Panait7addd3c2020-11-28 10:43:10 +0200132int post_output_backlog(void)
wdenk228f29a2002-12-08 09:53:23 +0000133{
wdenk228f29a2002-12-08 09:53:23 +0000134 int j;
135
136 for (j = 0; j < post_list_size; j++) {
Valentin Longchamp79843952011-08-03 02:37:01 +0000137 if (gd->post_log_word & (post_list[j].testid)) {
Wolfgang Denk50da8372011-10-29 09:42:22 +0000138 post_log("POST %s ", post_list[j].cmd);
Valentin Longchamp79843952011-08-03 02:37:01 +0000139 if (gd->post_log_res & post_list[j].testid)
Wolfgang Denk50da8372011-10-29 09:42:22 +0000140 post_log("PASSED\n");
wdenk63e73c92004-02-23 22:22:28 +0000141 else {
Heiko Schochere92372c2011-10-12 01:18:05 +0000142 post_log("FAILED\n");
Simon Glass770605e2012-02-13 13:51:18 +0000143 bootstage_error(BOOTSTAGE_ID_POST_FAIL_R);
wdenk63e73c92004-02-23 22:22:28 +0000144 }
wdenk228f29a2002-12-08 09:53:23 +0000145 }
146 }
Ovidiu Panait7addd3c2020-11-28 10:43:10 +0200147
148 return 0;
wdenk228f29a2002-12-08 09:53:23 +0000149}
150
Heiko Schochere92372c2011-10-12 01:18:05 +0000151static void post_bootmode_test_on(unsigned int last_test)
wdenka042ac82002-09-12 22:36:57 +0000152{
Heiko Schochere92372c2011-10-12 01:18:05 +0000153 unsigned long word = post_word_load();
wdenka042ac82002-09-12 22:36:57 +0000154
155 word |= POST_POWERTEST;
156
157 word |= (last_test & 0xFF) << 8;
158
Heiko Schochere92372c2011-10-12 01:18:05 +0000159 post_word_store(word);
wdenka042ac82002-09-12 22:36:57 +0000160}
161
Heiko Schochere92372c2011-10-12 01:18:05 +0000162static void post_bootmode_test_off(void)
wdenka042ac82002-09-12 22:36:57 +0000163{
Heiko Schochere92372c2011-10-12 01:18:05 +0000164 unsigned long word = post_word_load();
wdenka042ac82002-09-12 22:36:57 +0000165
166 word &= ~POST_POWERTEST;
167
Heiko Schochere92372c2011-10-12 01:18:05 +0000168 post_word_store(word);
wdenka042ac82002-09-12 22:36:57 +0000169}
170
Tom Rini9cebc4a2022-11-19 18:45:44 -0500171#ifndef CFG_POST_SKIP_ENV_FLAGS
Valentin Longchamp212a0ca2011-08-03 02:37:02 +0000172static void post_get_env_flags(int *test_flags)
wdenka042ac82002-09-12 22:36:57 +0000173{
Yuri Tikhonove262efe2008-02-04 14:11:03 +0100174 int flag[] = { POST_POWERON, POST_NORMAL, POST_SLOWTEST,
175 POST_CRITICAL };
176 char *var[] = { "post_poweron", "post_normal", "post_slowtest",
177 "post_critical" };
Mike Frysingerd2397812011-05-10 07:28:35 +0000178 int varnum = ARRAY_SIZE(var);
wdenka042ac82002-09-12 22:36:57 +0000179 char list[128]; /* long enough for POST list */
180 char *name;
181 char *s;
182 int last;
183 int i, j;
184
wdenka042ac82002-09-12 22:36:57 +0000185 for (i = 0; i < varnum; i++) {
Simon Glass00caae62017-08-03 12:22:12 -0600186 if (env_get_f(var[i], list, sizeof(list)) <= 0)
wdenka042ac82002-09-12 22:36:57 +0000187 continue;
188
Wolfgang Denk50da8372011-10-29 09:42:22 +0000189 for (j = 0; j < post_list_size; j++)
wdenka042ac82002-09-12 22:36:57 +0000190 test_flags[j] &= ~flag[i];
wdenka042ac82002-09-12 22:36:57 +0000191
192 last = 0;
193 name = list;
194 while (!last) {
Heinrich Schuchardt86eeac72020-08-03 22:12:13 +0200195 while (*name == ' ')
wdenka042ac82002-09-12 22:36:57 +0000196 name++;
197 if (*name == 0)
198 break;
199 s = name + 1;
200 while (*s && *s != ' ')
201 s++;
202 if (*s == 0)
203 last = 1;
204 else
205 *s = 0;
206
207 for (j = 0; j < post_list_size; j++) {
Wolfgang Denk50da8372011-10-29 09:42:22 +0000208 if (strcmp(post_list[j].cmd, name) == 0) {
wdenka042ac82002-09-12 22:36:57 +0000209 test_flags[j] |= flag[i];
210 break;
211 }
212 }
213
Heiko Schochere92372c2011-10-12 01:18:05 +0000214 if (j == post_list_size)
Wolfgang Denk50da8372011-10-29 09:42:22 +0000215 printf("No such test: %s\n", name);
wdenka042ac82002-09-12 22:36:57 +0000216
217 name = s + 1;
218 }
219 }
Valentin Longchamp212a0ca2011-08-03 02:37:02 +0000220}
221#endif
222
223static void post_get_flags(int *test_flags)
224{
225 int j;
226
227 for (j = 0; j < post_list_size; j++)
228 test_flags[j] = post_list[j].flags;
229
Tom Rini9cebc4a2022-11-19 18:45:44 -0500230#ifndef CFG_POST_SKIP_ENV_FLAGS
Valentin Longchamp212a0ca2011-08-03 02:37:02 +0000231 post_get_env_flags(test_flags);
232#endif
wdenk6dff5522003-07-15 07:45:49 +0000233
Heiko Schochere92372c2011-10-12 01:18:05 +0000234 for (j = 0; j < post_list_size; j++)
235 if (test_flags[j] & POST_POWERON)
wdenk6dff5522003-07-15 07:45:49 +0000236 test_flags[j] |= POST_SLOWTEST;
wdenka042ac82002-09-12 22:36:57 +0000237}
238
Jeroen Hofstee002ad7b2014-10-08 22:57:25 +0200239__weak void show_post_progress(unsigned int test_num, int before, int result)
Michael Zaidmane070a562010-03-01 11:47:36 +0200240{
241}
Michael Zaidmane070a562010-03-01 11:47:36 +0200242
Heiko Schochere92372c2011-10-12 01:18:05 +0000243static int post_run_single(struct post_test *test,
wdenka042ac82002-09-12 22:36:57 +0000244 int test_flags, int flags, unsigned int i)
245{
246 if ((flags & test_flags & POST_ALWAYS) &&
247 (flags & test_flags & POST_MEM)) {
Stefan Roese29caf932022-09-02 14:10:46 +0200248 schedule();
wdenka042ac82002-09-12 22:36:57 +0000249
250 if (!(flags & POST_REBOOT)) {
Heiko Schochere92372c2011-10-12 01:18:05 +0000251 if ((test_flags & POST_REBOOT) &&
252 !(flags & POST_MANUAL)) {
253 post_bootmode_test_on(
Yuri Tikhonove262efe2008-02-04 14:11:03 +0100254 (gd->flags & GD_FLG_POSTFAIL) ?
255 POST_FAIL_SAVE | i : i);
wdenka042ac82002-09-12 22:36:57 +0000256 }
257
wdenk228f29a2002-12-08 09:53:23 +0000258 if (test_flags & POST_PREREL)
Heiko Schochere92372c2011-10-12 01:18:05 +0000259 post_log_mark_start(test->testid);
wdenk228f29a2002-12-08 09:53:23 +0000260 else
Heiko Schochere92372c2011-10-12 01:18:05 +0000261 post_log("POST %s ", test->cmd);
wdenka042ac82002-09-12 22:36:57 +0000262 }
263
Michael Zaidmane070a562010-03-01 11:47:36 +0200264 show_post_progress(i, POST_BEFORE, POST_FAILED);
265
wdenk228f29a2002-12-08 09:53:23 +0000266 if (test_flags & POST_PREREL) {
Wolfgang Denk50da8372011-10-29 09:42:22 +0000267 if ((*test->test)(flags) == 0) {
Heiko Schochere92372c2011-10-12 01:18:05 +0000268 post_log_mark_succ(test->testid);
Michael Zaidmane070a562010-03-01 11:47:36 +0200269 show_post_progress(i, POST_AFTER, POST_PASSED);
Wolfgang Denk50da8372011-10-29 09:42:22 +0000270 } else {
Michael Zaidmane070a562010-03-01 11:47:36 +0200271 show_post_progress(i, POST_AFTER, POST_FAILED);
Yuri Tikhonov28a38502008-05-08 15:45:26 +0200272 if (test_flags & POST_CRITICAL)
273 gd->flags |= GD_FLG_POSTFAIL;
274 if (test_flags & POST_STOP)
275 gd->flags |= GD_FLG_POSTSTOP;
276 }
wdenk228f29a2002-12-08 09:53:23 +0000277 } else {
James Kosin975afc32011-07-14 08:15:06 +0000278 if ((*test->test)(flags) != 0) {
279 post_log("FAILED\n");
Simon Glass770605e2012-02-13 13:51:18 +0000280 bootstage_error(BOOTSTAGE_ID_POST_FAIL_R);
James Kosin975afc32011-07-14 08:15:06 +0000281 show_post_progress(i, POST_AFTER, POST_FAILED);
282 if (test_flags & POST_CRITICAL)
283 gd->flags |= GD_FLG_POSTFAIL;
284 if (test_flags & POST_STOP)
285 gd->flags |= GD_FLG_POSTSTOP;
286 } else {
287 post_log("PASSED\n");
288 show_post_progress(i, POST_AFTER, POST_PASSED);
289 }
wdenk228f29a2002-12-08 09:53:23 +0000290 }
wdenka042ac82002-09-12 22:36:57 +0000291
Wolfgang Denk50da8372011-10-29 09:42:22 +0000292 if ((test_flags & POST_REBOOT) && !(flags & POST_MANUAL))
Heiko Schochere92372c2011-10-12 01:18:05 +0000293 post_bootmode_test_off();
wdenka042ac82002-09-12 22:36:57 +0000294
295 return 0;
296 } else {
297 return -1;
298 }
299}
300
Wolfgang Denk50da8372011-10-29 09:42:22 +0000301int post_run(char *name, int flags)
wdenka042ac82002-09-12 22:36:57 +0000302{
303 unsigned int i;
304 int test_flags[POST_MAX_NUMBER];
305
Heiko Schochere92372c2011-10-12 01:18:05 +0000306 post_get_flags(test_flags);
wdenka042ac82002-09-12 22:36:57 +0000307
308 if (name == NULL) {
309 unsigned int last;
310
Yuri Tikhonov28a38502008-05-08 15:45:26 +0200311 if (gd->flags & GD_FLG_POSTSTOP)
312 return 0;
313
Heiko Schochere92372c2011-10-12 01:18:05 +0000314 if (post_bootmode_get(&last) & POST_POWERTEST) {
Yuri Tikhonove262efe2008-02-04 14:11:03 +0100315 if (last & POST_FAIL_SAVE) {
316 last &= ~POST_FAIL_SAVE;
317 gd->flags |= GD_FLG_POSTFAIL;
318 }
wdenka042ac82002-09-12 22:36:57 +0000319 if (last < post_list_size &&
320 (flags & test_flags[last] & POST_ALWAYS) &&
321 (flags & test_flags[last] & POST_MEM)) {
322
Heiko Schochere92372c2011-10-12 01:18:05 +0000323 post_run_single(post_list + last,
wdenkea909b72002-11-21 23:11:29 +0000324 test_flags[last],
325 flags | POST_REBOOT, last);
wdenka042ac82002-09-12 22:36:57 +0000326
327 for (i = last + 1; i < post_list_size; i++) {
Yuri Tikhonov28a38502008-05-08 15:45:26 +0200328 if (gd->flags & GD_FLG_POSTSTOP)
329 break;
Heiko Schochere92372c2011-10-12 01:18:05 +0000330 post_run_single(post_list + i,
wdenkea909b72002-11-21 23:11:29 +0000331 test_flags[i],
332 flags, i);
wdenka042ac82002-09-12 22:36:57 +0000333 }
334 }
335 } else {
336 for (i = 0; i < post_list_size; i++) {
Yuri Tikhonov28a38502008-05-08 15:45:26 +0200337 if (gd->flags & GD_FLG_POSTSTOP)
338 break;
Heiko Schochere92372c2011-10-12 01:18:05 +0000339 post_run_single(post_list + i,
wdenkea909b72002-11-21 23:11:29 +0000340 test_flags[i],
341 flags, i);
wdenka042ac82002-09-12 22:36:57 +0000342 }
343 }
344
345 return 0;
346 } else {
347 for (i = 0; i < post_list_size; i++) {
Wolfgang Denk50da8372011-10-29 09:42:22 +0000348 if (strcmp(post_list[i].cmd, name) == 0)
wdenka042ac82002-09-12 22:36:57 +0000349 break;
350 }
351
352 if (i < post_list_size) {
Stefan Roese29caf932022-09-02 14:10:46 +0200353 schedule();
Heiko Schochere92372c2011-10-12 01:18:05 +0000354 return post_run_single(post_list + i,
wdenka042ac82002-09-12 22:36:57 +0000355 test_flags[i],
356 flags, i);
357 } else {
358 return -1;
359 }
360 }
361}
362
Heiko Schochere92372c2011-10-12 01:18:05 +0000363static int post_info_single(struct post_test *test, int full)
wdenka042ac82002-09-12 22:36:57 +0000364{
365 if (test->flags & POST_MANUAL) {
366 if (full)
Heiko Schochere92372c2011-10-12 01:18:05 +0000367 printf("%s - %s\n"
wdenka042ac82002-09-12 22:36:57 +0000368 " %s\n", test->cmd, test->name, test->desc);
369 else
Heiko Schochere92372c2011-10-12 01:18:05 +0000370 printf(" %-15s - %s\n", test->cmd, test->name);
wdenka042ac82002-09-12 22:36:57 +0000371
372 return 0;
373 } else {
374 return -1;
375 }
376}
377
Wolfgang Denk50da8372011-10-29 09:42:22 +0000378int post_info(char *name)
wdenka042ac82002-09-12 22:36:57 +0000379{
380 unsigned int i;
381
382 if (name == NULL) {
Heiko Schochere92372c2011-10-12 01:18:05 +0000383 for (i = 0; i < post_list_size; i++)
384 post_info_single(post_list + i, 0);
wdenka042ac82002-09-12 22:36:57 +0000385
386 return 0;
387 } else {
388 for (i = 0; i < post_list_size; i++) {
Wolfgang Denk50da8372011-10-29 09:42:22 +0000389 if (strcmp(post_list[i].cmd, name) == 0)
wdenka042ac82002-09-12 22:36:57 +0000390 break;
391 }
392
Wolfgang Denk50da8372011-10-29 09:42:22 +0000393 if (i < post_list_size)
Heiko Schochere92372c2011-10-12 01:18:05 +0000394 return post_info_single(post_list + i, 1);
Wolfgang Denk50da8372011-10-29 09:42:22 +0000395 else
wdenka042ac82002-09-12 22:36:57 +0000396 return -1;
wdenka042ac82002-09-12 22:36:57 +0000397 }
398}
399
Heiko Schochere92372c2011-10-12 01:18:05 +0000400int post_log(char *format, ...)
wdenka042ac82002-09-12 22:36:57 +0000401{
402 va_list args;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200403 char printbuffer[CONFIG_SYS_PBSIZE];
wdenka042ac82002-09-12 22:36:57 +0000404
Wolfgang Denk50da8372011-10-29 09:42:22 +0000405 va_start(args, format);
wdenka042ac82002-09-12 22:36:57 +0000406
407 /* For this to work, printbuffer must be larger than
408 * anything we ever want to print.
409 */
Wolfgang Denk4d6402b2011-10-29 09:42:23 +0000410 vsprintf(printbuffer, format, args);
Wolfgang Denk50da8372011-10-29 09:42:22 +0000411 va_end(args);
wdenka042ac82002-09-12 22:36:57 +0000412
413 /* Send to the stdout file */
Heiko Schochere92372c2011-10-12 01:18:05 +0000414 puts(printbuffer);
wdenka042ac82002-09-12 22:36:57 +0000415
416 return 0;
417}
418
wdenk4532cb62003-04-27 22:52:51 +0000419/*
420 * Some tests (e.g. SYSMON) need the time when post_init_f started,
421 * but we cannot use get_timer() at this point.
422 *
423 * On PowerPC we implement it using the timebase register.
424 */
Heiko Schochere92372c2011-10-12 01:18:05 +0000425unsigned long post_time_ms(unsigned long base)
wdenk4532cb62003-04-27 22:52:51 +0000426{
Tom Riniea3310e2017-03-14 11:08:10 -0400427#if defined(CONFIG_PPC) || defined(CONFIG_ARM)
Christian Rieschc90a4dd2011-12-09 16:54:02 +0100428 return (unsigned long)lldiv(get_ticks(), get_tbclk() / CONFIG_SYS_HZ)
Heiko Schochere92372c2011-10-12 01:18:05 +0000429 - base;
wdenk4532cb62003-04-27 22:52:51 +0000430#else
Wolfgang Denkad5bb452007-03-06 18:08:43 +0100431#warning "Not implemented yet"
wdenk4532cb62003-04-27 22:52:51 +0000432 return 0; /* Not implemented yet */
433#endif
434}