wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2002 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | #include <common.h> |
Jean-Christophe PLAGNIOL-VILLARD | 2a7a031 | 2009-05-16 12:14:54 +0200 | [diff] [blame] | 25 | #include <stdio_dev.h> |
wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 26 | #include <watchdog.h> |
| 27 | #include <post.h> |
| 28 | |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 29 | #ifdef CONFIG_LOGBUFFER |
| 30 | #include <logbuff.h> |
| 31 | #endif |
| 32 | |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 33 | DECLARE_GLOBAL_DATA_PTR; |
| 34 | |
wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 35 | #define POST_MAX_NUMBER 32 |
| 36 | |
| 37 | #define BOOTMODE_MAGIC 0xDEAD0000 |
| 38 | |
wdenk | c08f158 | 2003-04-27 22:52:51 +0000 | [diff] [blame] | 39 | int post_init_f (void) |
| 40 | { |
wdenk | c08f158 | 2003-04-27 22:52:51 +0000 | [diff] [blame] | 41 | int res = 0; |
| 42 | unsigned int i; |
| 43 | |
| 44 | for (i = 0; i < post_list_size; i++) { |
| 45 | struct post_test *test = post_list + i; |
| 46 | |
| 47 | if (test->init_f && test->init_f()) { |
| 48 | res = -1; |
| 49 | } |
| 50 | } |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 51 | |
wdenk | c08f158 | 2003-04-27 22:52:51 +0000 | [diff] [blame] | 52 | gd->post_init_f_time = post_time_ms(0); |
| 53 | if (!gd->post_init_f_time) |
| 54 | { |
| 55 | printf("post/post.c: post_time_ms seems not to be implemented\n"); |
| 56 | } |
| 57 | |
| 58 | return res; |
| 59 | } |
| 60 | |
Stefan Roese | f0a15c5 | 2009-12-03 06:24:30 +0100 | [diff] [blame] | 61 | /* |
| 62 | * Supply a default implementation for post_hotkeys_pressed() for boards |
| 63 | * without hotkey support. We always return 0 here, so that the |
| 64 | * long-running tests won't be started. |
| 65 | * |
| 66 | * Boards with hotkey support can override this weak default function |
| 67 | * by defining one in their board specific code. |
| 68 | */ |
| 69 | int __post_hotkeys_pressed(void) |
| 70 | { |
| 71 | return 0; /* No hotkeys supported */ |
| 72 | } |
| 73 | int post_hotkeys_pressed(void) |
| 74 | __attribute__((weak, alias("__post_hotkeys_pressed"))); |
| 75 | |
| 76 | |
wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 77 | void post_bootmode_init (void) |
| 78 | { |
| 79 | int bootmode = post_bootmode_get (0); |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 80 | int newword; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 81 | |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 82 | if (post_hotkeys_pressed() && !(bootmode & POST_POWERTEST)) { |
| 83 | newword = BOOTMODE_MAGIC | POST_SLOWTEST; |
wdenk | ca9bc76 | 2003-07-15 07:45:49 +0000 | [diff] [blame] | 84 | } else if (bootmode == 0) { |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 85 | newword = BOOTMODE_MAGIC | POST_POWERON; |
wdenk | ca9bc76 | 2003-07-15 07:45:49 +0000 | [diff] [blame] | 86 | } else if (bootmode == POST_POWERON || bootmode == POST_SLOWTEST) { |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 87 | newword = BOOTMODE_MAGIC | POST_NORMAL; |
wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 88 | } else { |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 89 | /* Use old value */ |
| 90 | newword = post_word_load () & ~POST_COLDBOOT; |
| 91 | } |
| 92 | |
| 93 | if (bootmode == 0) |
| 94 | { |
| 95 | /* We are booting after power-on */ |
| 96 | newword |= POST_COLDBOOT; |
wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 97 | } |
| 98 | |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 99 | post_word_store (newword); |
| 100 | |
wdenk | 9dfa8d1 | 2002-12-08 09:53:23 +0000 | [diff] [blame] | 101 | /* Reset activity record */ |
| 102 | gd->post_log_word = 0; |
wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | int post_bootmode_get (unsigned int *last_test) |
| 106 | { |
| 107 | unsigned long word = post_word_load (); |
| 108 | int bootmode; |
| 109 | |
| 110 | if ((word & 0xFFFF0000) != BOOTMODE_MAGIC) { |
| 111 | return 0; |
| 112 | } |
| 113 | |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 114 | bootmode = word & 0x7F; |
wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 115 | |
| 116 | if (last_test && (bootmode & POST_POWERTEST)) { |
| 117 | *last_test = (word >> 8) & 0xFF; |
| 118 | } |
| 119 | |
| 120 | return bootmode; |
| 121 | } |
| 122 | |
wdenk | 9dfa8d1 | 2002-12-08 09:53:23 +0000 | [diff] [blame] | 123 | /* POST tests run before relocation only mark status bits .... */ |
| 124 | static void post_log_mark_start ( unsigned long testid ) |
| 125 | { |
wdenk | 9dfa8d1 | 2002-12-08 09:53:23 +0000 | [diff] [blame] | 126 | gd->post_log_word |= (testid)<<16; |
| 127 | } |
| 128 | |
| 129 | static void post_log_mark_succ ( unsigned long testid ) |
| 130 | { |
wdenk | 9dfa8d1 | 2002-12-08 09:53:23 +0000 | [diff] [blame] | 131 | gd->post_log_word |= testid; |
| 132 | } |
| 133 | |
| 134 | /* ... and the messages are output once we are relocated */ |
| 135 | void post_output_backlog ( void ) |
| 136 | { |
wdenk | 9dfa8d1 | 2002-12-08 09:53:23 +0000 | [diff] [blame] | 137 | int j; |
| 138 | |
| 139 | for (j = 0; j < post_list_size; j++) { |
| 140 | if (gd->post_log_word & (post_list[j].testid<<16)) { |
| 141 | post_log ("POST %s ", post_list[j].cmd); |
| 142 | if (gd->post_log_word & post_list[j].testid) |
| 143 | post_log ("PASSED\n"); |
wdenk | e97d3d9 | 2004-02-23 22:22:28 +0000 | [diff] [blame] | 144 | else { |
wdenk | 9dfa8d1 | 2002-12-08 09:53:23 +0000 | [diff] [blame] | 145 | post_log ("FAILED\n"); |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 146 | show_boot_progress (-31); |
wdenk | e97d3d9 | 2004-02-23 22:22:28 +0000 | [diff] [blame] | 147 | } |
wdenk | 9dfa8d1 | 2002-12-08 09:53:23 +0000 | [diff] [blame] | 148 | } |
| 149 | } |
| 150 | } |
| 151 | |
wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 152 | static void post_bootmode_test_on (unsigned int last_test) |
| 153 | { |
| 154 | unsigned long word = post_word_load (); |
| 155 | |
| 156 | word |= POST_POWERTEST; |
| 157 | |
| 158 | word |= (last_test & 0xFF) << 8; |
| 159 | |
| 160 | post_word_store (word); |
| 161 | } |
| 162 | |
| 163 | static void post_bootmode_test_off (void) |
| 164 | { |
| 165 | unsigned long word = post_word_load (); |
| 166 | |
| 167 | word &= ~POST_POWERTEST; |
| 168 | |
| 169 | post_word_store (word); |
| 170 | } |
| 171 | |
| 172 | static void post_get_flags (int *test_flags) |
| 173 | { |
Yuri Tikhonov | 6a068a1 | 2008-02-04 14:11:03 +0100 | [diff] [blame] | 174 | int flag[] = { POST_POWERON, POST_NORMAL, POST_SLOWTEST, |
| 175 | POST_CRITICAL }; |
| 176 | char *var[] = { "post_poweron", "post_normal", "post_slowtest", |
| 177 | "post_critical" }; |
wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 178 | int varnum = sizeof (var) / sizeof (var[0]); |
| 179 | char list[128]; /* long enough for POST list */ |
| 180 | char *name; |
| 181 | char *s; |
| 182 | int last; |
| 183 | int i, j; |
| 184 | |
| 185 | for (j = 0; j < post_list_size; j++) { |
| 186 | test_flags[j] = post_list[j].flags; |
| 187 | } |
| 188 | |
| 189 | for (i = 0; i < varnum; i++) { |
Wolfgang Denk | 76af278 | 2010-07-24 21:55:43 +0200 | [diff] [blame] | 190 | if (getenv_f(var[i], list, sizeof (list)) <= 0) |
wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 191 | continue; |
| 192 | |
| 193 | for (j = 0; j < post_list_size; j++) { |
| 194 | test_flags[j] &= ~flag[i]; |
| 195 | } |
| 196 | |
| 197 | last = 0; |
| 198 | name = list; |
| 199 | while (!last) { |
| 200 | while (*name && *name == ' ') |
| 201 | name++; |
| 202 | if (*name == 0) |
| 203 | break; |
| 204 | s = name + 1; |
| 205 | while (*s && *s != ' ') |
| 206 | s++; |
| 207 | if (*s == 0) |
| 208 | last = 1; |
| 209 | else |
| 210 | *s = 0; |
| 211 | |
| 212 | for (j = 0; j < post_list_size; j++) { |
| 213 | if (strcmp (post_list[j].cmd, name) == 0) { |
| 214 | test_flags[j] |= flag[i]; |
| 215 | break; |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | if (j == post_list_size) { |
| 220 | printf ("No such test: %s\n", name); |
| 221 | } |
| 222 | |
| 223 | name = s + 1; |
| 224 | } |
| 225 | } |
wdenk | ca9bc76 | 2003-07-15 07:45:49 +0000 | [diff] [blame] | 226 | |
| 227 | for (j = 0; j < post_list_size; j++) { |
| 228 | if (test_flags[j] & POST_POWERON) { |
| 229 | test_flags[j] |= POST_SLOWTEST; |
| 230 | } |
| 231 | } |
wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 232 | } |
| 233 | |
Michael Zaidman | e3ac2b9 | 2010-03-01 11:47:36 +0200 | [diff] [blame] | 234 | void __show_post_progress (unsigned int test_num, int before, int result) |
| 235 | { |
| 236 | } |
| 237 | void show_post_progress (unsigned int, int, int) |
| 238 | __attribute__((weak, alias("__show_post_progress"))); |
| 239 | |
wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 240 | static int post_run_single (struct post_test *test, |
| 241 | int test_flags, int flags, unsigned int i) |
| 242 | { |
| 243 | if ((flags & test_flags & POST_ALWAYS) && |
| 244 | (flags & test_flags & POST_MEM)) { |
| 245 | WATCHDOG_RESET (); |
| 246 | |
| 247 | if (!(flags & POST_REBOOT)) { |
| 248 | if ((test_flags & POST_REBOOT) && !(flags & POST_MANUAL)) { |
Yuri Tikhonov | 6a068a1 | 2008-02-04 14:11:03 +0100 | [diff] [blame] | 249 | post_bootmode_test_on ( |
| 250 | (gd->flags & GD_FLG_POSTFAIL) ? |
| 251 | POST_FAIL_SAVE | i : i); |
wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 252 | } |
| 253 | |
wdenk | 9dfa8d1 | 2002-12-08 09:53:23 +0000 | [diff] [blame] | 254 | if (test_flags & POST_PREREL) |
| 255 | post_log_mark_start ( test->testid ); |
| 256 | else |
Michael Zaidman | e3ac2b9 | 2010-03-01 11:47:36 +0200 | [diff] [blame] | 257 | post_log ("POST %s ", test->cmd); |
wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 258 | } |
| 259 | |
Michael Zaidman | e3ac2b9 | 2010-03-01 11:47:36 +0200 | [diff] [blame] | 260 | show_post_progress(i, POST_BEFORE, POST_FAILED); |
| 261 | |
wdenk | 9dfa8d1 | 2002-12-08 09:53:23 +0000 | [diff] [blame] | 262 | if (test_flags & POST_PREREL) { |
Michael Zaidman | e3ac2b9 | 2010-03-01 11:47:36 +0200 | [diff] [blame] | 263 | if ((*test->test) (flags) == 0) { |
wdenk | 9dfa8d1 | 2002-12-08 09:53:23 +0000 | [diff] [blame] | 264 | post_log_mark_succ ( test->testid ); |
Michael Zaidman | e3ac2b9 | 2010-03-01 11:47:36 +0200 | [diff] [blame] | 265 | show_post_progress(i, POST_AFTER, POST_PASSED); |
| 266 | } |
Yuri Tikhonov | bc439b0 | 2008-05-08 15:45:26 +0200 | [diff] [blame] | 267 | else { |
Michael Zaidman | e3ac2b9 | 2010-03-01 11:47:36 +0200 | [diff] [blame] | 268 | show_post_progress(i, POST_AFTER, POST_FAILED); |
Yuri Tikhonov | bc439b0 | 2008-05-08 15:45:26 +0200 | [diff] [blame] | 269 | if (test_flags & POST_CRITICAL) |
| 270 | gd->flags |= GD_FLG_POSTFAIL; |
| 271 | if (test_flags & POST_STOP) |
| 272 | gd->flags |= GD_FLG_POSTSTOP; |
| 273 | } |
wdenk | 9dfa8d1 | 2002-12-08 09:53:23 +0000 | [diff] [blame] | 274 | } else { |
wdenk | e97d3d9 | 2004-02-23 22:22:28 +0000 | [diff] [blame] | 275 | if ((*test->test) (flags) != 0) { |
wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 276 | post_log ("FAILED\n"); |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 277 | show_boot_progress (-32); |
Michael Zaidman | e3ac2b9 | 2010-03-01 11:47:36 +0200 | [diff] [blame] | 278 | show_post_progress(i, POST_AFTER, POST_FAILED); |
Yuri Tikhonov | 6a068a1 | 2008-02-04 14:11:03 +0100 | [diff] [blame] | 279 | if (test_flags & POST_CRITICAL) |
| 280 | gd->flags |= GD_FLG_POSTFAIL; |
Yuri Tikhonov | bc439b0 | 2008-05-08 15:45:26 +0200 | [diff] [blame] | 281 | if (test_flags & POST_STOP) |
| 282 | gd->flags |= GD_FLG_POSTSTOP; |
wdenk | e97d3d9 | 2004-02-23 22:22:28 +0000 | [diff] [blame] | 283 | } |
wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 284 | else |
| 285 | post_log ("PASSED\n"); |
Michael Zaidman | e3ac2b9 | 2010-03-01 11:47:36 +0200 | [diff] [blame] | 286 | show_post_progress(i, POST_AFTER, POST_PASSED); |
wdenk | 9dfa8d1 | 2002-12-08 09:53:23 +0000 | [diff] [blame] | 287 | } |
wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 288 | |
| 289 | if ((test_flags & POST_REBOOT) && !(flags & POST_MANUAL)) { |
| 290 | post_bootmode_test_off (); |
| 291 | } |
| 292 | |
| 293 | return 0; |
| 294 | } else { |
| 295 | return -1; |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | int post_run (char *name, int flags) |
| 300 | { |
| 301 | unsigned int i; |
| 302 | int test_flags[POST_MAX_NUMBER]; |
| 303 | |
| 304 | post_get_flags (test_flags); |
| 305 | |
| 306 | if (name == NULL) { |
| 307 | unsigned int last; |
| 308 | |
Yuri Tikhonov | bc439b0 | 2008-05-08 15:45:26 +0200 | [diff] [blame] | 309 | if (gd->flags & GD_FLG_POSTSTOP) |
| 310 | return 0; |
| 311 | |
wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 312 | if (post_bootmode_get (&last) & POST_POWERTEST) { |
Yuri Tikhonov | 6a068a1 | 2008-02-04 14:11:03 +0100 | [diff] [blame] | 313 | if (last & POST_FAIL_SAVE) { |
| 314 | last &= ~POST_FAIL_SAVE; |
| 315 | gd->flags |= GD_FLG_POSTFAIL; |
| 316 | } |
wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 317 | if (last < post_list_size && |
| 318 | (flags & test_flags[last] & POST_ALWAYS) && |
| 319 | (flags & test_flags[last] & POST_MEM)) { |
| 320 | |
wdenk | 2029f4d | 2002-11-21 23:11:29 +0000 | [diff] [blame] | 321 | post_run_single (post_list + last, |
| 322 | test_flags[last], |
| 323 | flags | POST_REBOOT, last); |
wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 324 | |
| 325 | for (i = last + 1; i < post_list_size; i++) { |
Yuri Tikhonov | bc439b0 | 2008-05-08 15:45:26 +0200 | [diff] [blame] | 326 | if (gd->flags & GD_FLG_POSTSTOP) |
| 327 | break; |
wdenk | 2029f4d | 2002-11-21 23:11:29 +0000 | [diff] [blame] | 328 | post_run_single (post_list + i, |
| 329 | test_flags[i], |
| 330 | flags, i); |
wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 331 | } |
| 332 | } |
| 333 | } else { |
| 334 | for (i = 0; i < post_list_size; i++) { |
Yuri Tikhonov | bc439b0 | 2008-05-08 15:45:26 +0200 | [diff] [blame] | 335 | if (gd->flags & GD_FLG_POSTSTOP) |
| 336 | break; |
wdenk | 2029f4d | 2002-11-21 23:11:29 +0000 | [diff] [blame] | 337 | post_run_single (post_list + i, |
| 338 | test_flags[i], |
| 339 | flags, i); |
wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 340 | } |
| 341 | } |
| 342 | |
| 343 | return 0; |
| 344 | } else { |
| 345 | for (i = 0; i < post_list_size; i++) { |
| 346 | if (strcmp (post_list[i].cmd, name) == 0) |
| 347 | break; |
| 348 | } |
| 349 | |
| 350 | if (i < post_list_size) { |
Sascha Laue | 0015053 | 2008-05-30 09:48:14 +0200 | [diff] [blame] | 351 | WATCHDOG_RESET(); |
wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 352 | return post_run_single (post_list + i, |
| 353 | test_flags[i], |
| 354 | flags, i); |
| 355 | } else { |
| 356 | return -1; |
| 357 | } |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | static int post_info_single (struct post_test *test, int full) |
| 362 | { |
| 363 | if (test->flags & POST_MANUAL) { |
| 364 | if (full) |
| 365 | printf ("%s - %s\n" |
| 366 | " %s\n", test->cmd, test->name, test->desc); |
| 367 | else |
| 368 | printf (" %-15s - %s\n", test->cmd, test->name); |
| 369 | |
| 370 | return 0; |
| 371 | } else { |
| 372 | return -1; |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | int post_info (char *name) |
| 377 | { |
| 378 | unsigned int i; |
| 379 | |
| 380 | if (name == NULL) { |
| 381 | for (i = 0; i < post_list_size; i++) { |
| 382 | post_info_single (post_list + i, 0); |
| 383 | } |
| 384 | |
| 385 | return 0; |
| 386 | } else { |
| 387 | for (i = 0; i < post_list_size; i++) { |
| 388 | if (strcmp (post_list[i].cmd, name) == 0) |
| 389 | break; |
| 390 | } |
| 391 | |
| 392 | if (i < post_list_size) { |
| 393 | return post_info_single (post_list + i, 1); |
| 394 | } else { |
| 395 | return -1; |
| 396 | } |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | int post_log (char *format, ...) |
| 401 | { |
| 402 | va_list args; |
| 403 | uint i; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 404 | char printbuffer[CONFIG_SYS_PBSIZE]; |
wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 405 | |
| 406 | va_start (args, format); |
| 407 | |
| 408 | /* For this to work, printbuffer must be larger than |
| 409 | * anything we ever want to print. |
| 410 | */ |
| 411 | i = vsprintf (printbuffer, format, args); |
| 412 | va_end (args); |
| 413 | |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 414 | #ifdef CONFIG_LOGBUFFER |
wdenk | 9dfa8d1 | 2002-12-08 09:53:23 +0000 | [diff] [blame] | 415 | /* Send to the logbuffer */ |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 416 | logbuff_log (printbuffer); |
| 417 | #else |
wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 418 | /* Send to the stdout file */ |
| 419 | puts (printbuffer); |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 420 | #endif |
wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 421 | |
| 422 | return 0; |
| 423 | } |
| 424 | |
Wolfgang Denk | d0813e5 | 2010-10-28 20:00:11 +0200 | [diff] [blame] | 425 | #ifdef CONFIG_NEEDS_MANUAL_RELOC |
wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 426 | void post_reloc (void) |
| 427 | { |
wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 428 | unsigned int i; |
| 429 | |
| 430 | /* |
| 431 | * We have to relocate the test table manually |
| 432 | */ |
| 433 | for (i = 0; i < post_list_size; i++) { |
| 434 | ulong addr; |
| 435 | struct post_test *test = post_list + i; |
| 436 | |
| 437 | if (test->name) { |
| 438 | addr = (ulong) (test->name) + gd->reloc_off; |
| 439 | test->name = (char *) addr; |
| 440 | } |
| 441 | |
| 442 | if (test->cmd) { |
| 443 | addr = (ulong) (test->cmd) + gd->reloc_off; |
| 444 | test->cmd = (char *) addr; |
| 445 | } |
| 446 | |
| 447 | if (test->desc) { |
| 448 | addr = (ulong) (test->desc) + gd->reloc_off; |
| 449 | test->desc = (char *) addr; |
| 450 | } |
| 451 | |
| 452 | if (test->test) { |
| 453 | addr = (ulong) (test->test) + gd->reloc_off; |
| 454 | test->test = (int (*)(int flags)) addr; |
| 455 | } |
wdenk | c08f158 | 2003-04-27 22:52:51 +0000 | [diff] [blame] | 456 | |
| 457 | if (test->init_f) { |
| 458 | addr = (ulong) (test->init_f) + gd->reloc_off; |
| 459 | test->init_f = (int (*)(void)) addr; |
| 460 | } |
| 461 | |
| 462 | if (test->reloc) { |
| 463 | addr = (ulong) (test->reloc) + gd->reloc_off; |
| 464 | test->reloc = (void (*)(void)) addr; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 465 | |
wdenk | c08f158 | 2003-04-27 22:52:51 +0000 | [diff] [blame] | 466 | test->reloc(); |
| 467 | } |
wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 468 | } |
| 469 | } |
Peter Tyser | 9057cbf | 2009-09-21 11:20:36 -0500 | [diff] [blame] | 470 | #endif |
wdenk | a042ac8 | 2002-09-12 22:36:57 +0000 | [diff] [blame] | 471 | |
wdenk | c08f158 | 2003-04-27 22:52:51 +0000 | [diff] [blame] | 472 | |
| 473 | /* |
| 474 | * Some tests (e.g. SYSMON) need the time when post_init_f started, |
| 475 | * but we cannot use get_timer() at this point. |
| 476 | * |
| 477 | * On PowerPC we implement it using the timebase register. |
| 478 | */ |
| 479 | unsigned long post_time_ms (unsigned long base) |
| 480 | { |
| 481 | #ifdef CONFIG_PPC |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 482 | return (unsigned long)(get_ticks () / (get_tbclk () / CONFIG_SYS_HZ)) - base; |
wdenk | c08f158 | 2003-04-27 22:52:51 +0000 | [diff] [blame] | 483 | #else |
Wolfgang Denk | b38e0df | 2007-03-06 18:08:43 +0100 | [diff] [blame] | 484 | #warning "Not implemented yet" |
wdenk | c08f158 | 2003-04-27 22:52:51 +0000 | [diff] [blame] | 485 | return 0; /* Not implemented yet */ |
| 486 | #endif |
| 487 | } |