Blame view

post/post.c 9.58 KB
83d290c56   Tom Rini   SPDX: Convert all...
1
  // SPDX-License-Identifier: GPL-2.0+
a042ac843   wdenk   Initial revision
2
3
4
  /*
   * (C) Copyright 2002
   * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
a042ac843   wdenk   Initial revision
5
6
7
   */
  
  #include <common.h>
52cb4d4fb   Jean-Christophe PLAGNIOL-VILLARD   stdio/device: rew...
8
  #include <stdio_dev.h>
a042ac843   wdenk   Initial revision
9
  #include <watchdog.h>
c90a4dd79   Christian Riesch   post/post.c: Use ...
10
  #include <div64.h>
a042ac843   wdenk   Initial revision
11
  #include <post.h>
9146d1382   Mike Frysinger   post: add gpio ho...
12
13
14
  #ifdef CONFIG_SYS_POST_HOTKEYS_GPIO
  #include <asm/gpio.h>
  #endif
d87080b72   Wolfgang Denk   GCC-4.x fixes: cl...
15
  DECLARE_GLOBAL_DATA_PTR;
a042ac843   wdenk   Initial revision
16
17
18
  #define POST_MAX_NUMBER		32
  
  #define BOOTMODE_MAGIC	0xDEAD0000
e92372c8a   Heiko Schocher   cosmetic, post: C...
19
  int post_init_f(void)
4532cb696   wdenk   * LWMON extensions:
20
  {
4532cb696   wdenk   * LWMON extensions:
21
22
23
24
25
  	int res = 0;
  	unsigned int i;
  
  	for (i = 0; i < post_list_size; i++) {
  		struct post_test *test = post_list + i;
50da83766   Wolfgang Denk   post/post.c: Codi...
26
  		if (test->init_f && test->init_f())
4532cb696   wdenk   * LWMON extensions:
27
  			res = -1;
4532cb696   wdenk   * LWMON extensions:
28
  	}
8bde7f776   wdenk   * Code cleanup:
29

4532cb696   wdenk   * LWMON extensions:
30
31
  	gd->post_init_f_time = post_time_ms(0);
  	if (!gd->post_init_f_time)
e92372c8a   Heiko Schocher   cosmetic, post: C...
32
33
  		printf("%s: post_time_ms not implemented
  ", __FILE__);
4532cb696   wdenk   * LWMON extensions:
34
35
36
  
  	return res;
  }
39ff7d5f4   Stefan Roese   POST: Remove dupl...
37
38
39
40
41
42
43
44
  /*
   * 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.
   */
002ad7b87   Jeroen Hofstee   misc: use __weak
45
  __weak int post_hotkeys_pressed(void)
39ff7d5f4   Stefan Roese   POST: Remove dupl...
46
  {
9146d1382   Mike Frysinger   post: add gpio ho...
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
  #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
  ");
  		return 0;
  	}
  
  	gpio_direction_input(gpio);
  	ret = gpio_get_value(gpio);
  	gpio_free(gpio);
  
  	return ret;
  #endif
39ff7d5f4   Stefan Roese   POST: Remove dupl...
64
65
  	return 0;	/* No hotkeys supported */
  }
39ff7d5f4   Stefan Roese   POST: Remove dupl...
66

e92372c8a   Heiko Schocher   cosmetic, post: C...
67
  void post_bootmode_init(void)
a042ac843   wdenk   Initial revision
68
  {
e92372c8a   Heiko Schocher   cosmetic, post: C...
69
  	int bootmode = post_bootmode_get(0);
27b207fd0   wdenk   * Implement new m...
70
  	int newword;
42d1f0394   wdenk   * Patches by Xian...
71

e92372c8a   Heiko Schocher   cosmetic, post: C...
72
  	if (post_hotkeys_pressed() && !(bootmode & POST_POWERTEST))
27b207fd0   wdenk   * Implement new m...
73
  		newword = BOOTMODE_MAGIC | POST_SLOWTEST;
e92372c8a   Heiko Schocher   cosmetic, post: C...
74
  	else if (bootmode == 0)
27b207fd0   wdenk   * Implement new m...
75
  		newword = BOOTMODE_MAGIC | POST_POWERON;
e92372c8a   Heiko Schocher   cosmetic, post: C...
76
  	else if (bootmode == POST_POWERON || bootmode == POST_SLOWTEST)
27b207fd0   wdenk   * Implement new m...
77
  		newword = BOOTMODE_MAGIC | POST_NORMAL;
e92372c8a   Heiko Schocher   cosmetic, post: C...
78
  	else
27b207fd0   wdenk   * Implement new m...
79
  		/* Use old value */
50da83766   Wolfgang Denk   post/post.c: Codi...
80
  		newword = post_word_load() & ~POST_COLDBOOT;
a042ac843   wdenk   Initial revision
81

27b207fd0   wdenk   * Implement new m...
82
  	if (bootmode == 0)
27b207fd0   wdenk   * Implement new m...
83
84
  		/* We are booting after power-on */
  		newword |= POST_COLDBOOT;
27b207fd0   wdenk   * Implement new m...
85

e92372c8a   Heiko Schocher   cosmetic, post: C...
86
  	post_word_store(newword);
27b207fd0   wdenk   * Implement new m...
87

228f29ac6   wdenk   * Improve log buf...
88
89
  	/* Reset activity record */
  	gd->post_log_word = 0;
79843950b   Valentin Longchamp   POST: add post_lo...
90
  	gd->post_log_res = 0;
a042ac843   wdenk   Initial revision
91
  }
e92372c8a   Heiko Schocher   cosmetic, post: C...
92
  int post_bootmode_get(unsigned int *last_test)
a042ac843   wdenk   Initial revision
93
  {
e92372c8a   Heiko Schocher   cosmetic, post: C...
94
  	unsigned long word = post_word_load();
a042ac843   wdenk   Initial revision
95
  	int bootmode;
e92372c8a   Heiko Schocher   cosmetic, post: C...
96
  	if ((word & 0xFFFF0000) != BOOTMODE_MAGIC)
a042ac843   wdenk   Initial revision
97
  		return 0;
a042ac843   wdenk   Initial revision
98

27b207fd0   wdenk   * Implement new m...
99
  	bootmode = word & 0x7F;
a042ac843   wdenk   Initial revision
100

e92372c8a   Heiko Schocher   cosmetic, post: C...
101
  	if (last_test && (bootmode & POST_POWERTEST))
a042ac843   wdenk   Initial revision
102
  		*last_test = (word >> 8) & 0xFF;
a042ac843   wdenk   Initial revision
103
104
105
  
  	return bootmode;
  }
228f29ac6   wdenk   * Improve log buf...
106
  /* POST tests run before relocation only mark status bits .... */
e92372c8a   Heiko Schocher   cosmetic, post: C...
107
  static void post_log_mark_start(unsigned long testid)
228f29ac6   wdenk   * Improve log buf...
108
  {
79843950b   Valentin Longchamp   POST: add post_lo...
109
  	gd->post_log_word |= testid;
228f29ac6   wdenk   * Improve log buf...
110
  }
e92372c8a   Heiko Schocher   cosmetic, post: C...
111
  static void post_log_mark_succ(unsigned long testid)
228f29ac6   wdenk   * Improve log buf...
112
  {
79843950b   Valentin Longchamp   POST: add post_lo...
113
  	gd->post_log_res |= testid;
228f29ac6   wdenk   * Improve log buf...
114
115
116
  }
  
  /* ... and the messages are output once we are relocated */
e92372c8a   Heiko Schocher   cosmetic, post: C...
117
  void post_output_backlog(void)
228f29ac6   wdenk   * Improve log buf...
118
  {
228f29ac6   wdenk   * Improve log buf...
119
120
121
  	int j;
  
  	for (j = 0; j < post_list_size; j++) {
79843950b   Valentin Longchamp   POST: add post_lo...
122
  		if (gd->post_log_word & (post_list[j].testid)) {
50da83766   Wolfgang Denk   post/post.c: Codi...
123
  			post_log("POST %s ", post_list[j].cmd);
79843950b   Valentin Longchamp   POST: add post_lo...
124
  			if (gd->post_log_res & post_list[j].testid)
50da83766   Wolfgang Denk   post/post.c: Codi...
125
126
  				post_log("PASSED
  ");
63e73c9a8   wdenk   * Patches by Rein...
127
  			else {
e92372c8a   Heiko Schocher   cosmetic, post: C...
128
129
  				post_log("FAILED
  ");
770605e4f   Simon Glass   bootstage: Replac...
130
  				bootstage_error(BOOTSTAGE_ID_POST_FAIL_R);
63e73c9a8   wdenk   * Patches by Rein...
131
  			}
228f29ac6   wdenk   * Improve log buf...
132
133
134
  		}
  	}
  }
e92372c8a   Heiko Schocher   cosmetic, post: C...
135
  static void post_bootmode_test_on(unsigned int last_test)
a042ac843   wdenk   Initial revision
136
  {
e92372c8a   Heiko Schocher   cosmetic, post: C...
137
  	unsigned long word = post_word_load();
a042ac843   wdenk   Initial revision
138
139
140
141
  
  	word |= POST_POWERTEST;
  
  	word |= (last_test & 0xFF) << 8;
e92372c8a   Heiko Schocher   cosmetic, post: C...
142
  	post_word_store(word);
a042ac843   wdenk   Initial revision
143
  }
e92372c8a   Heiko Schocher   cosmetic, post: C...
144
  static void post_bootmode_test_off(void)
a042ac843   wdenk   Initial revision
145
  {
e92372c8a   Heiko Schocher   cosmetic, post: C...
146
  	unsigned long word = post_word_load();
a042ac843   wdenk   Initial revision
147
148
  
  	word &= ~POST_POWERTEST;
e92372c8a   Heiko Schocher   cosmetic, post: C...
149
  	post_word_store(word);
a042ac843   wdenk   Initial revision
150
  }
212a0cafa   Valentin Longchamp   POST: make env te...
151
152
  #ifndef CONFIG_POST_SKIP_ENV_FLAGS
  static void post_get_env_flags(int *test_flags)
a042ac843   wdenk   Initial revision
153
  {
e262efe35   Yuri Tikhonov   The patch introdu...
154
155
156
157
  	int  flag[] = {  POST_POWERON,   POST_NORMAL,   POST_SLOWTEST,
  			 POST_CRITICAL };
  	char *var[] = { "post_poweron", "post_normal", "post_slowtest",
  			"post_critical" };
d2397817f   Mike Frysinger   post: use ARRAY_SIZE
158
  	int varnum = ARRAY_SIZE(var);
a042ac843   wdenk   Initial revision
159
160
161
162
163
  	char list[128];			/* long enough for POST list */
  	char *name;
  	char *s;
  	int last;
  	int i, j;
a042ac843   wdenk   Initial revision
164
  	for (i = 0; i < varnum; i++) {
00caae6d4   Simon Glass   env: Rename geten...
165
  		if (env_get_f(var[i], list, sizeof(list)) <= 0)
a042ac843   wdenk   Initial revision
166
  			continue;
50da83766   Wolfgang Denk   post/post.c: Codi...
167
  		for (j = 0; j < post_list_size; j++)
a042ac843   wdenk   Initial revision
168
  			test_flags[j] &= ~flag[i];
a042ac843   wdenk   Initial revision
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
  
  		last = 0;
  		name = list;
  		while (!last) {
  			while (*name && *name == ' ')
  				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++) {
50da83766   Wolfgang Denk   post/post.c: Codi...
186
  				if (strcmp(post_list[j].cmd, name) == 0) {
a042ac843   wdenk   Initial revision
187
188
189
190
  					test_flags[j] |= flag[i];
  					break;
  				}
  			}
e92372c8a   Heiko Schocher   cosmetic, post: C...
191
  			if (j == post_list_size)
50da83766   Wolfgang Denk   post/post.c: Codi...
192
193
  				printf("No such test: %s
  ", name);
a042ac843   wdenk   Initial revision
194
195
196
197
  
  			name = s + 1;
  		}
  	}
212a0cafa   Valentin Longchamp   POST: make env te...
198
199
200
201
202
203
204
205
206
207
208
209
210
  }
  #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
6dff55297   wdenk   * Patches by Mart...
211

e92372c8a   Heiko Schocher   cosmetic, post: C...
212
213
  	for (j = 0; j < post_list_size; j++)
  		if (test_flags[j] & POST_POWERON)
6dff55297   wdenk   * Patches by Mart...
214
  			test_flags[j] |= POST_SLOWTEST;
a042ac843   wdenk   Initial revision
215
  }
002ad7b87   Jeroen Hofstee   misc: use __weak
216
  __weak void show_post_progress(unsigned int test_num, int before, int result)
e070a56c7   Michael Zaidman   POST: add progres...
217
218
  {
  }
e070a56c7   Michael Zaidman   POST: add progres...
219

e92372c8a   Heiko Schocher   cosmetic, post: C...
220
  static int post_run_single(struct post_test *test,
a042ac843   wdenk   Initial revision
221
222
223
224
  				int test_flags, int flags, unsigned int i)
  {
  	if ((flags & test_flags & POST_ALWAYS) &&
  		(flags & test_flags & POST_MEM)) {
50da83766   Wolfgang Denk   post/post.c: Codi...
225
  		WATCHDOG_RESET();
a042ac843   wdenk   Initial revision
226
227
  
  		if (!(flags & POST_REBOOT)) {
e92372c8a   Heiko Schocher   cosmetic, post: C...
228
229
230
  			if ((test_flags & POST_REBOOT) &&
  				!(flags & POST_MANUAL)) {
  				post_bootmode_test_on(
e262efe35   Yuri Tikhonov   The patch introdu...
231
232
  					(gd->flags & GD_FLG_POSTFAIL) ?
  						POST_FAIL_SAVE | i : i);
a042ac843   wdenk   Initial revision
233
  			}
228f29ac6   wdenk   * Improve log buf...
234
  			if (test_flags & POST_PREREL)
e92372c8a   Heiko Schocher   cosmetic, post: C...
235
  				post_log_mark_start(test->testid);
228f29ac6   wdenk   * Improve log buf...
236
  			else
e92372c8a   Heiko Schocher   cosmetic, post: C...
237
  				post_log("POST %s ", test->cmd);
a042ac843   wdenk   Initial revision
238
  		}
e070a56c7   Michael Zaidman   POST: add progres...
239
  		show_post_progress(i, POST_BEFORE, POST_FAILED);
228f29ac6   wdenk   * Improve log buf...
240
  		if (test_flags & POST_PREREL) {
50da83766   Wolfgang Denk   post/post.c: Codi...
241
  			if ((*test->test)(flags) == 0) {
e92372c8a   Heiko Schocher   cosmetic, post: C...
242
  				post_log_mark_succ(test->testid);
e070a56c7   Michael Zaidman   POST: add progres...
243
  				show_post_progress(i, POST_AFTER, POST_PASSED);
50da83766   Wolfgang Denk   post/post.c: Codi...
244
  			} else {
e070a56c7   Michael Zaidman   POST: add progres...
245
  				show_post_progress(i, POST_AFTER, POST_FAILED);
28a385065   Yuri Tikhonov   POST: add POST_ST...
246
247
248
249
250
  				if (test_flags & POST_CRITICAL)
  					gd->flags |= GD_FLG_POSTFAIL;
  				if (test_flags & POST_STOP)
  					gd->flags |= GD_FLG_POSTSTOP;
  			}
228f29ac6   wdenk   * Improve log buf...
251
  		} else {
975afc34d   James Kosin   post: fix indenda...
252
253
254
  			if ((*test->test)(flags) != 0) {
  				post_log("FAILED
  ");
770605e4f   Simon Glass   bootstage: Replac...
255
  				bootstage_error(BOOTSTAGE_ID_POST_FAIL_R);
975afc34d   James Kosin   post: fix indenda...
256
257
258
259
260
261
262
263
264
265
  				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
  ");
  				show_post_progress(i, POST_AFTER, POST_PASSED);
  			}
228f29ac6   wdenk   * Improve log buf...
266
  		}
a042ac843   wdenk   Initial revision
267

50da83766   Wolfgang Denk   post/post.c: Codi...
268
  		if ((test_flags & POST_REBOOT) && !(flags & POST_MANUAL))
e92372c8a   Heiko Schocher   cosmetic, post: C...
269
  			post_bootmode_test_off();
a042ac843   wdenk   Initial revision
270
271
272
273
274
275
  
  		return 0;
  	} else {
  		return -1;
  	}
  }
50da83766   Wolfgang Denk   post/post.c: Codi...
276
  int post_run(char *name, int flags)
a042ac843   wdenk   Initial revision
277
278
279
  {
  	unsigned int i;
  	int test_flags[POST_MAX_NUMBER];
e92372c8a   Heiko Schocher   cosmetic, post: C...
280
  	post_get_flags(test_flags);
a042ac843   wdenk   Initial revision
281
282
283
  
  	if (name == NULL) {
  		unsigned int last;
28a385065   Yuri Tikhonov   POST: add POST_ST...
284
285
  		if (gd->flags & GD_FLG_POSTSTOP)
  			return 0;
e92372c8a   Heiko Schocher   cosmetic, post: C...
286
  		if (post_bootmode_get(&last) & POST_POWERTEST) {
e262efe35   Yuri Tikhonov   The patch introdu...
287
288
289
290
  			if (last & POST_FAIL_SAVE) {
  				last &= ~POST_FAIL_SAVE;
  				gd->flags |= GD_FLG_POSTFAIL;
  			}
a042ac843   wdenk   Initial revision
291
292
293
  			if (last < post_list_size &&
  				(flags & test_flags[last] & POST_ALWAYS) &&
  				(flags & test_flags[last] & POST_MEM)) {
e92372c8a   Heiko Schocher   cosmetic, post: C...
294
  				post_run_single(post_list + last,
ea909b760   wdenk   * Added support f...
295
296
  						 test_flags[last],
  						 flags | POST_REBOOT, last);
a042ac843   wdenk   Initial revision
297
298
  
  				for (i = last + 1; i < post_list_size; i++) {
28a385065   Yuri Tikhonov   POST: add POST_ST...
299
300
  					if (gd->flags & GD_FLG_POSTSTOP)
  						break;
e92372c8a   Heiko Schocher   cosmetic, post: C...
301
  					post_run_single(post_list + i,
ea909b760   wdenk   * Added support f...
302
303
  							 test_flags[i],
  							 flags, i);
a042ac843   wdenk   Initial revision
304
305
306
307
  				}
  			}
  		} else {
  			for (i = 0; i < post_list_size; i++) {
28a385065   Yuri Tikhonov   POST: add POST_ST...
308
309
  				if (gd->flags & GD_FLG_POSTSTOP)
  					break;
e92372c8a   Heiko Schocher   cosmetic, post: C...
310
  				post_run_single(post_list + i,
ea909b760   wdenk   * Added support f...
311
312
  						 test_flags[i],
  						 flags, i);
a042ac843   wdenk   Initial revision
313
314
315
316
317
318
  			}
  		}
  
  		return 0;
  	} else {
  		for (i = 0; i < post_list_size; i++) {
50da83766   Wolfgang Denk   post/post.c: Codi...
319
  			if (strcmp(post_list[i].cmd, name) == 0)
a042ac843   wdenk   Initial revision
320
321
322
323
  				break;
  		}
  
  		if (i < post_list_size) {
5744ddc66   Sascha Laue   Configure DSP POS...
324
  			WATCHDOG_RESET();
e92372c8a   Heiko Schocher   cosmetic, post: C...
325
  			return post_run_single(post_list + i,
a042ac843   wdenk   Initial revision
326
327
328
329
330
331
332
  						test_flags[i],
  						flags, i);
  		} else {
  			return -1;
  		}
  	}
  }
e92372c8a   Heiko Schocher   cosmetic, post: C...
333
  static int post_info_single(struct post_test *test, int full)
a042ac843   wdenk   Initial revision
334
335
336
  {
  	if (test->flags & POST_MANUAL) {
  		if (full)
e92372c8a   Heiko Schocher   cosmetic, post: C...
337
338
  			printf("%s - %s
  "
a042ac843   wdenk   Initial revision
339
340
341
  				"  %s
  ", test->cmd, test->name, test->desc);
  		else
e92372c8a   Heiko Schocher   cosmetic, post: C...
342
343
  			printf("  %-15s - %s
  ", test->cmd, test->name);
a042ac843   wdenk   Initial revision
344
345
346
347
348
349
  
  		return 0;
  	} else {
  		return -1;
  	}
  }
50da83766   Wolfgang Denk   post/post.c: Codi...
350
  int post_info(char *name)
a042ac843   wdenk   Initial revision
351
352
353
354
  {
  	unsigned int i;
  
  	if (name == NULL) {
e92372c8a   Heiko Schocher   cosmetic, post: C...
355
356
  		for (i = 0; i < post_list_size; i++)
  			post_info_single(post_list + i, 0);
a042ac843   wdenk   Initial revision
357
358
359
360
  
  		return 0;
  	} else {
  		for (i = 0; i < post_list_size; i++) {
50da83766   Wolfgang Denk   post/post.c: Codi...
361
  			if (strcmp(post_list[i].cmd, name) == 0)
a042ac843   wdenk   Initial revision
362
363
  				break;
  		}
50da83766   Wolfgang Denk   post/post.c: Codi...
364
  		if (i < post_list_size)
e92372c8a   Heiko Schocher   cosmetic, post: C...
365
  			return post_info_single(post_list + i, 1);
50da83766   Wolfgang Denk   post/post.c: Codi...
366
  		else
a042ac843   wdenk   Initial revision
367
  			return -1;
a042ac843   wdenk   Initial revision
368
369
  	}
  }
e92372c8a   Heiko Schocher   cosmetic, post: C...
370
  int post_log(char *format, ...)
a042ac843   wdenk   Initial revision
371
372
  {
  	va_list args;
6d0f6bcf3   Jean-Christophe PLAGNIOL-VILLARD   rename CFG_ macro...
373
  	char printbuffer[CONFIG_SYS_PBSIZE];
a042ac843   wdenk   Initial revision
374

50da83766   Wolfgang Denk   post/post.c: Codi...
375
  	va_start(args, format);
a042ac843   wdenk   Initial revision
376
377
378
379
  
  	/* For this to work, printbuffer must be larger than
  	 * anything we ever want to print.
  	 */
4d6402b01   Wolfgang Denk   post/post.c: fix ...
380
  	vsprintf(printbuffer, format, args);
50da83766   Wolfgang Denk   post/post.c: Codi...
381
  	va_end(args);
a042ac843   wdenk   Initial revision
382
383
  
  	/* Send to the stdout file */
e92372c8a   Heiko Schocher   cosmetic, post: C...
384
  	puts(printbuffer);
a042ac843   wdenk   Initial revision
385
386
387
  
  	return 0;
  }
2e5167cca   Wolfgang Denk   Replace CONFIG_RE...
388
  #ifdef CONFIG_NEEDS_MANUAL_RELOC
e92372c8a   Heiko Schocher   cosmetic, post: C...
389
  void post_reloc(void)
a042ac843   wdenk   Initial revision
390
  {
a042ac843   wdenk   Initial revision
391
392
393
394
395
396
397
398
399
400
  	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) {
50da83766   Wolfgang Denk   post/post.c: Codi...
401
  			addr = (ulong)(test->name) + gd->reloc_off;
e92372c8a   Heiko Schocher   cosmetic, post: C...
402
  			test->name = (char *)addr;
a042ac843   wdenk   Initial revision
403
404
405
  		}
  
  		if (test->cmd) {
50da83766   Wolfgang Denk   post/post.c: Codi...
406
  			addr = (ulong)(test->cmd) + gd->reloc_off;
e92372c8a   Heiko Schocher   cosmetic, post: C...
407
  			test->cmd = (char *)addr;
a042ac843   wdenk   Initial revision
408
409
410
  		}
  
  		if (test->desc) {
50da83766   Wolfgang Denk   post/post.c: Codi...
411
  			addr = (ulong)(test->desc) + gd->reloc_off;
e92372c8a   Heiko Schocher   cosmetic, post: C...
412
  			test->desc = (char *)addr;
a042ac843   wdenk   Initial revision
413
414
415
  		}
  
  		if (test->test) {
50da83766   Wolfgang Denk   post/post.c: Codi...
416
  			addr = (ulong)(test->test) + gd->reloc_off;
a042ac843   wdenk   Initial revision
417
418
  			test->test = (int (*)(int flags)) addr;
  		}
4532cb696   wdenk   * LWMON extensions:
419
420
  
  		if (test->init_f) {
50da83766   Wolfgang Denk   post/post.c: Codi...
421
  			addr = (ulong)(test->init_f) + gd->reloc_off;
4532cb696   wdenk   * LWMON extensions:
422
423
424
425
  			test->init_f = (int (*)(void)) addr;
  		}
  
  		if (test->reloc) {
50da83766   Wolfgang Denk   post/post.c: Codi...
426
  			addr = (ulong)(test->reloc) + gd->reloc_off;
4532cb696   wdenk   * LWMON extensions:
427
  			test->reloc = (void (*)(void)) addr;
8bde7f776   wdenk   * Code cleanup:
428

4532cb696   wdenk   * LWMON extensions:
429
430
  			test->reloc();
  		}
a042ac843   wdenk   Initial revision
431
432
  	}
  }
521af04d8   Peter Tyser   Conditionally per...
433
  #endif
a042ac843   wdenk   Initial revision
434

4532cb696   wdenk   * LWMON extensions:
435
436
437
438
439
440
441
  
  /*
   * 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.
   */
e92372c8a   Heiko Schocher   cosmetic, post: C...
442
  unsigned long post_time_ms(unsigned long base)
4532cb696   wdenk   * LWMON extensions:
443
  {
ea3310e8a   Tom Rini   Blackfin: Remove
444
  #if defined(CONFIG_PPC) || defined(CONFIG_ARM)
c90a4dd79   Christian Riesch   post/post.c: Use ...
445
  	return (unsigned long)lldiv(get_ticks(), get_tbclk() / CONFIG_SYS_HZ)
e92372c8a   Heiko Schocher   cosmetic, post: C...
446
  		- base;
4532cb696   wdenk   * LWMON extensions:
447
  #else
ad5bb451a   Wolfgang Denk   Restructure POST ...
448
  #warning "Not implemented yet"
4532cb696   wdenk   * LWMON extensions:
449
450
451
  	return 0; /* Not implemented yet */
  #endif
  }