aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/powerpc/kernel/prom_init.c558
1 files changed, 267 insertions, 291 deletions
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index c78ac5698b99..7f7fb7fd991b 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -79,7 +79,6 @@
79 * On ppc64, 64 bit values are truncated to 32 bits (and 79 * On ppc64, 64 bit values are truncated to 32 bits (and
80 * fortunately don't get interpreted as two arguments). 80 * fortunately don't get interpreted as two arguments).
81 */ 81 */
82#define RELOC(x) (x)
83#define ADDR(x) (u32)(unsigned long)(x) 82#define ADDR(x) (u32)(unsigned long)(x)
84 83
85#ifdef CONFIG_PPC64 84#ifdef CONFIG_PPC64
@@ -94,7 +93,7 @@ int of_workarounds;
94 93
95#define PROM_BUG() do { \ 94#define PROM_BUG() do { \
96 prom_printf("kernel BUG at %s line 0x%x!\n", \ 95 prom_printf("kernel BUG at %s line 0x%x!\n", \
97 RELOC(__FILE__), __LINE__); \ 96 __FILE__, __LINE__); \
98 __asm__ __volatile__(".long " BUG_ILLEGAL_INSTR); \ 97 __asm__ __volatile__(".long " BUG_ILLEGAL_INSTR); \
99} while (0) 98} while (0)
100 99
@@ -232,7 +231,7 @@ static int __init call_prom(const char *service, int nargs, int nret, ...)
232 for (i = 0; i < nret; i++) 231 for (i = 0; i < nret; i++)
233 args.args[nargs+i] = 0; 232 args.args[nargs+i] = 0;
234 233
235 if (enter_prom(&args, RELOC(prom_entry)) < 0) 234 if (enter_prom(&args, prom_entry) < 0)
236 return PROM_ERROR; 235 return PROM_ERROR;
237 236
238 return (nret > 0) ? args.args[nargs] : 0; 237 return (nret > 0) ? args.args[nargs] : 0;
@@ -257,7 +256,7 @@ static int __init call_prom_ret(const char *service, int nargs, int nret,
257 for (i = 0; i < nret; i++) 256 for (i = 0; i < nret; i++)
258 args.args[nargs+i] = 0; 257 args.args[nargs+i] = 0;
259 258
260 if (enter_prom(&args, RELOC(prom_entry)) < 0) 259 if (enter_prom(&args, prom_entry) < 0)
261 return PROM_ERROR; 260 return PROM_ERROR;
262 261
263 if (rets != NULL) 262 if (rets != NULL)
@@ -271,20 +270,19 @@ static int __init call_prom_ret(const char *service, int nargs, int nret,
271static void __init prom_print(const char *msg) 270static void __init prom_print(const char *msg)
272{ 271{
273 const char *p, *q; 272 const char *p, *q;
274 struct prom_t *_prom = &RELOC(prom);
275 273
276 if (_prom->stdout == 0) 274 if (prom.stdout == 0)
277 return; 275 return;
278 276
279 for (p = msg; *p != 0; p = q) { 277 for (p = msg; *p != 0; p = q) {
280 for (q = p; *q != 0 && *q != '\n'; ++q) 278 for (q = p; *q != 0 && *q != '\n'; ++q)
281 ; 279 ;
282 if (q > p) 280 if (q > p)
283 call_prom("write", 3, 1, _prom->stdout, p, q - p); 281 call_prom("write", 3, 1, prom.stdout, p, q - p);
284 if (*q == 0) 282 if (*q == 0)
285 break; 283 break;
286 ++q; 284 ++q;
287 call_prom("write", 3, 1, _prom->stdout, ADDR("\r\n"), 2); 285 call_prom("write", 3, 1, prom.stdout, ADDR("\r\n"), 2);
288 } 286 }
289} 287}
290 288
@@ -293,7 +291,6 @@ static void __init prom_print_hex(unsigned long val)
293{ 291{
294 int i, nibbles = sizeof(val)*2; 292 int i, nibbles = sizeof(val)*2;
295 char buf[sizeof(val)*2+1]; 293 char buf[sizeof(val)*2+1];
296 struct prom_t *_prom = &RELOC(prom);
297 294
298 for (i = nibbles-1; i >= 0; i--) { 295 for (i = nibbles-1; i >= 0; i--) {
299 buf[i] = (val & 0xf) + '0'; 296 buf[i] = (val & 0xf) + '0';
@@ -302,7 +299,7 @@ static void __init prom_print_hex(unsigned long val)
302 val >>= 4; 299 val >>= 4;
303 } 300 }
304 buf[nibbles] = '\0'; 301 buf[nibbles] = '\0';
305 call_prom("write", 3, 1, _prom->stdout, buf, nibbles); 302 call_prom("write", 3, 1, prom.stdout, buf, nibbles);
306} 303}
307 304
308/* max number of decimal digits in an unsigned long */ 305/* max number of decimal digits in an unsigned long */
@@ -311,7 +308,6 @@ static void __init prom_print_dec(unsigned long val)
311{ 308{
312 int i, size; 309 int i, size;
313 char buf[UL_DIGITS+1]; 310 char buf[UL_DIGITS+1];
314 struct prom_t *_prom = &RELOC(prom);
315 311
316 for (i = UL_DIGITS-1; i >= 0; i--) { 312 for (i = UL_DIGITS-1; i >= 0; i--) {
317 buf[i] = (val % 10) + '0'; 313 buf[i] = (val % 10) + '0';
@@ -321,7 +317,7 @@ static void __init prom_print_dec(unsigned long val)
321 } 317 }
322 /* shift stuff down */ 318 /* shift stuff down */
323 size = UL_DIGITS - i; 319 size = UL_DIGITS - i;
324 call_prom("write", 3, 1, _prom->stdout, buf+i, size); 320 call_prom("write", 3, 1, prom.stdout, buf+i, size);
325} 321}
326 322
327static void __init prom_printf(const char *format, ...) 323static void __init prom_printf(const char *format, ...)
@@ -330,19 +326,18 @@ static void __init prom_printf(const char *format, ...)
330 va_list args; 326 va_list args;
331 unsigned long v; 327 unsigned long v;
332 long vs; 328 long vs;
333 struct prom_t *_prom = &RELOC(prom);
334 329
335 va_start(args, format); 330 va_start(args, format);
336 for (p = format; *p != 0; p = q) { 331 for (p = format; *p != 0; p = q) {
337 for (q = p; *q != 0 && *q != '\n' && *q != '%'; ++q) 332 for (q = p; *q != 0 && *q != '\n' && *q != '%'; ++q)
338 ; 333 ;
339 if (q > p) 334 if (q > p)
340 call_prom("write", 3, 1, _prom->stdout, p, q - p); 335 call_prom("write", 3, 1, prom.stdout, p, q - p);
341 if (*q == 0) 336 if (*q == 0)
342 break; 337 break;
343 if (*q == '\n') { 338 if (*q == '\n') {
344 ++q; 339 ++q;
345 call_prom("write", 3, 1, _prom->stdout, 340 call_prom("write", 3, 1, prom.stdout,
346 ADDR("\r\n"), 2); 341 ADDR("\r\n"), 2);
347 continue; 342 continue;
348 } 343 }
@@ -364,7 +359,7 @@ static void __init prom_printf(const char *format, ...)
364 ++q; 359 ++q;
365 vs = va_arg(args, int); 360 vs = va_arg(args, int);
366 if (vs < 0) { 361 if (vs < 0) {
367 prom_print(RELOC("-")); 362 prom_print("-");
368 vs = -vs; 363 vs = -vs;
369 } 364 }
370 prom_print_dec(vs); 365 prom_print_dec(vs);
@@ -385,7 +380,7 @@ static void __init prom_printf(const char *format, ...)
385 ++q; 380 ++q;
386 vs = va_arg(args, long); 381 vs = va_arg(args, long);
387 if (vs < 0) { 382 if (vs < 0) {
388 prom_print(RELOC("-")); 383 prom_print("-");
389 vs = -vs; 384 vs = -vs;
390 } 385 }
391 prom_print_dec(vs); 386 prom_print_dec(vs);
@@ -399,7 +394,6 @@ static void __init prom_printf(const char *format, ...)
399static unsigned int __init prom_claim(unsigned long virt, unsigned long size, 394static unsigned int __init prom_claim(unsigned long virt, unsigned long size,
400 unsigned long align) 395 unsigned long align)
401{ 396{
402 struct prom_t *_prom = &RELOC(prom);
403 397
404 if (align == 0 && (OF_WORKAROUNDS & OF_WA_CLAIM)) { 398 if (align == 0 && (OF_WORKAROUNDS & OF_WA_CLAIM)) {
405 /* 399 /*
@@ -410,21 +404,21 @@ static unsigned int __init prom_claim(unsigned long virt, unsigned long size,
410 prom_arg_t result; 404 prom_arg_t result;
411 405
412 ret = call_prom_ret("call-method", 5, 2, &result, 406 ret = call_prom_ret("call-method", 5, 2, &result,
413 ADDR("claim"), _prom->memory, 407 ADDR("claim"), prom.memory,
414 align, size, virt); 408 align, size, virt);
415 if (ret != 0 || result == -1) 409 if (ret != 0 || result == -1)
416 return -1; 410 return -1;
417 ret = call_prom_ret("call-method", 5, 2, &result, 411 ret = call_prom_ret("call-method", 5, 2, &result,
418 ADDR("claim"), _prom->mmumap, 412 ADDR("claim"), prom.mmumap,
419 align, size, virt); 413 align, size, virt);
420 if (ret != 0) { 414 if (ret != 0) {
421 call_prom("call-method", 4, 1, ADDR("release"), 415 call_prom("call-method", 4, 1, ADDR("release"),
422 _prom->memory, size, virt); 416 prom.memory, size, virt);
423 return -1; 417 return -1;
424 } 418 }
425 /* the 0x12 is M (coherence) + PP == read/write */ 419 /* the 0x12 is M (coherence) + PP == read/write */
426 call_prom("call-method", 6, 1, 420 call_prom("call-method", 6, 1,
427 ADDR("map"), _prom->mmumap, 0x12, size, virt, virt); 421 ADDR("map"), prom.mmumap, 0x12, size, virt, virt);
428 return virt; 422 return virt;
429 } 423 }
430 return call_prom("claim", 3, 1, (prom_arg_t)virt, (prom_arg_t)size, 424 return call_prom("claim", 3, 1, (prom_arg_t)virt, (prom_arg_t)size,
@@ -436,7 +430,7 @@ static void __init __attribute__((noreturn)) prom_panic(const char *reason)
436 prom_print(reason); 430 prom_print(reason);
437 /* Do not call exit because it clears the screen on pmac 431 /* Do not call exit because it clears the screen on pmac
438 * it also causes some sort of double-fault on early pmacs */ 432 * it also causes some sort of double-fault on early pmacs */
439 if (RELOC(of_platform) == PLATFORM_POWERMAC) 433 if (of_platform == PLATFORM_POWERMAC)
440 asm("trap\n"); 434 asm("trap\n");
441 435
442 /* ToDo: should put up an SRC here on pSeries */ 436 /* ToDo: should put up an SRC here on pSeries */
@@ -518,13 +512,13 @@ static int __init prom_setprop(phandle node, const char *nodename,
518 add_string(&p, tohex((u32)(unsigned long) value)); 512 add_string(&p, tohex((u32)(unsigned long) value));
519 add_string(&p, tohex(valuelen)); 513 add_string(&p, tohex(valuelen));
520 add_string(&p, tohex(ADDR(pname))); 514 add_string(&p, tohex(ADDR(pname)));
521 add_string(&p, tohex(strlen(RELOC(pname)))); 515 add_string(&p, tohex(strlen(pname)));
522 add_string(&p, "property"); 516 add_string(&p, "property");
523 *p = 0; 517 *p = 0;
524 return call_prom("interpret", 1, 1, (u32)(unsigned long) cmd); 518 return call_prom("interpret", 1, 1, (u32)(unsigned long) cmd);
525} 519}
526 520
527/* We can't use the standard versions because of RELOC headaches. */ 521/* We can't use the standard versions because of relocation headaches. */
528#define isxdigit(c) (('0' <= (c) && (c) <= '9') \ 522#define isxdigit(c) (('0' <= (c) && (c) <= '9') \
529 || ('a' <= (c) && (c) <= 'f') \ 523 || ('a' <= (c) && (c) <= 'f') \
530 || ('A' <= (c) && (c) <= 'F')) 524 || ('A' <= (c) && (c) <= 'F'))
@@ -591,43 +585,42 @@ unsigned long prom_memparse(const char *ptr, const char **retptr)
591 */ 585 */
592static void __init early_cmdline_parse(void) 586static void __init early_cmdline_parse(void)
593{ 587{
594 struct prom_t *_prom = &RELOC(prom);
595 const char *opt; 588 const char *opt;
596 589
597 char *p; 590 char *p;
598 int l = 0; 591 int l = 0;
599 592
600 RELOC(prom_cmd_line[0]) = 0; 593 prom_cmd_line[0] = 0;
601 p = RELOC(prom_cmd_line); 594 p = prom_cmd_line;
602 if ((long)_prom->chosen > 0) 595 if ((long)prom.chosen > 0)
603 l = prom_getprop(_prom->chosen, "bootargs", p, COMMAND_LINE_SIZE-1); 596 l = prom_getprop(prom.chosen, "bootargs", p, COMMAND_LINE_SIZE-1);
604#ifdef CONFIG_CMDLINE 597#ifdef CONFIG_CMDLINE
605 if (l <= 0 || p[0] == '\0') /* dbl check */ 598 if (l <= 0 || p[0] == '\0') /* dbl check */
606 strlcpy(RELOC(prom_cmd_line), 599 strlcpy(prom_cmd_line,
607 RELOC(CONFIG_CMDLINE), sizeof(prom_cmd_line)); 600 CONFIG_CMDLINE, sizeof(prom_cmd_line));
608#endif /* CONFIG_CMDLINE */ 601#endif /* CONFIG_CMDLINE */
609 prom_printf("command line: %s\n", RELOC(prom_cmd_line)); 602 prom_printf("command line: %s\n", prom_cmd_line);
610 603
611#ifdef CONFIG_PPC64 604#ifdef CONFIG_PPC64
612 opt = strstr(RELOC(prom_cmd_line), RELOC("iommu=")); 605 opt = strstr(prom_cmd_line, "iommu=");
613 if (opt) { 606 if (opt) {
614 prom_printf("iommu opt is: %s\n", opt); 607 prom_printf("iommu opt is: %s\n", opt);
615 opt += 6; 608 opt += 6;
616 while (*opt && *opt == ' ') 609 while (*opt && *opt == ' ')
617 opt++; 610 opt++;
618 if (!strncmp(opt, RELOC("off"), 3)) 611 if (!strncmp(opt, "off", 3))
619 RELOC(prom_iommu_off) = 1; 612 prom_iommu_off = 1;
620 else if (!strncmp(opt, RELOC("force"), 5)) 613 else if (!strncmp(opt, "force", 5))
621 RELOC(prom_iommu_force_on) = 1; 614 prom_iommu_force_on = 1;
622 } 615 }
623#endif 616#endif
624 opt = strstr(RELOC(prom_cmd_line), RELOC("mem=")); 617 opt = strstr(prom_cmd_line, "mem=");
625 if (opt) { 618 if (opt) {
626 opt += 4; 619 opt += 4;
627 RELOC(prom_memory_limit) = prom_memparse(opt, (const char **)&opt); 620 prom_memory_limit = prom_memparse(opt, (const char **)&opt);
628#ifdef CONFIG_PPC64 621#ifdef CONFIG_PPC64
629 /* Align to 16 MB == size of ppc64 large page */ 622 /* Align to 16 MB == size of ppc64 large page */
630 RELOC(prom_memory_limit) = ALIGN(RELOC(prom_memory_limit), 0x1000000); 623 prom_memory_limit = ALIGN(prom_memory_limit, 0x1000000);
631#endif 624#endif
632 } 625 }
633} 626}
@@ -880,7 +873,7 @@ static int __init prom_count_smt_threads(void)
880 type[0] = 0; 873 type[0] = 0;
881 prom_getprop(node, "device_type", type, sizeof(type)); 874 prom_getprop(node, "device_type", type, sizeof(type));
882 875
883 if (strcmp(type, RELOC("cpu"))) 876 if (strcmp(type, "cpu"))
884 continue; 877 continue;
885 /* 878 /*
886 * There is an entry for each smt thread, each entry being 879 * There is an entry for each smt thread, each entry being
@@ -998,21 +991,21 @@ static void __init prom_send_capabilities(void)
998 */ 991 */
999static unsigned long __init alloc_up(unsigned long size, unsigned long align) 992static unsigned long __init alloc_up(unsigned long size, unsigned long align)
1000{ 993{
1001 unsigned long base = RELOC(alloc_bottom); 994 unsigned long base = alloc_bottom;
1002 unsigned long addr = 0; 995 unsigned long addr = 0;
1003 996
1004 if (align) 997 if (align)
1005 base = _ALIGN_UP(base, align); 998 base = _ALIGN_UP(base, align);
1006 prom_debug("alloc_up(%x, %x)\n", size, align); 999 prom_debug("alloc_up(%x, %x)\n", size, align);
1007 if (RELOC(ram_top) == 0) 1000 if (ram_top == 0)
1008 prom_panic("alloc_up() called with mem not initialized\n"); 1001 prom_panic("alloc_up() called with mem not initialized\n");
1009 1002
1010 if (align) 1003 if (align)
1011 base = _ALIGN_UP(RELOC(alloc_bottom), align); 1004 base = _ALIGN_UP(alloc_bottom, align);
1012 else 1005 else
1013 base = RELOC(alloc_bottom); 1006 base = alloc_bottom;
1014 1007
1015 for(; (base + size) <= RELOC(alloc_top); 1008 for(; (base + size) <= alloc_top;
1016 base = _ALIGN_UP(base + 0x100000, align)) { 1009 base = _ALIGN_UP(base + 0x100000, align)) {
1017 prom_debug(" trying: 0x%x\n\r", base); 1010 prom_debug(" trying: 0x%x\n\r", base);
1018 addr = (unsigned long)prom_claim(base, size, 0); 1011 addr = (unsigned long)prom_claim(base, size, 0);
@@ -1024,14 +1017,14 @@ static unsigned long __init alloc_up(unsigned long size, unsigned long align)
1024 } 1017 }
1025 if (addr == 0) 1018 if (addr == 0)
1026 return 0; 1019 return 0;
1027 RELOC(alloc_bottom) = addr + size; 1020 alloc_bottom = addr + size;
1028 1021
1029 prom_debug(" -> %x\n", addr); 1022 prom_debug(" -> %x\n", addr);
1030 prom_debug(" alloc_bottom : %x\n", RELOC(alloc_bottom)); 1023 prom_debug(" alloc_bottom : %x\n", alloc_bottom);
1031 prom_debug(" alloc_top : %x\n", RELOC(alloc_top)); 1024 prom_debug(" alloc_top : %x\n", alloc_top);
1032 prom_debug(" alloc_top_hi : %x\n", RELOC(alloc_top_high)); 1025 prom_debug(" alloc_top_hi : %x\n", alloc_top_high);
1033 prom_debug(" rmo_top : %x\n", RELOC(rmo_top)); 1026 prom_debug(" rmo_top : %x\n", rmo_top);
1034 prom_debug(" ram_top : %x\n", RELOC(ram_top)); 1027 prom_debug(" ram_top : %x\n", ram_top);
1035 1028
1036 return addr; 1029 return addr;
1037} 1030}
@@ -1047,32 +1040,32 @@ static unsigned long __init alloc_down(unsigned long size, unsigned long align,
1047 unsigned long base, addr = 0; 1040 unsigned long base, addr = 0;
1048 1041
1049 prom_debug("alloc_down(%x, %x, %s)\n", size, align, 1042 prom_debug("alloc_down(%x, %x, %s)\n", size, align,
1050 highmem ? RELOC("(high)") : RELOC("(low)")); 1043 highmem ? "(high)" : "(low)");
1051 if (RELOC(ram_top) == 0) 1044 if (ram_top == 0)
1052 prom_panic("alloc_down() called with mem not initialized\n"); 1045 prom_panic("alloc_down() called with mem not initialized\n");
1053 1046
1054 if (highmem) { 1047 if (highmem) {
1055 /* Carve out storage for the TCE table. */ 1048 /* Carve out storage for the TCE table. */
1056 addr = _ALIGN_DOWN(RELOC(alloc_top_high) - size, align); 1049 addr = _ALIGN_DOWN(alloc_top_high - size, align);
1057 if (addr <= RELOC(alloc_bottom)) 1050 if (addr <= alloc_bottom)
1058 return 0; 1051 return 0;
1059 /* Will we bump into the RMO ? If yes, check out that we 1052 /* Will we bump into the RMO ? If yes, check out that we
1060 * didn't overlap existing allocations there, if we did, 1053 * didn't overlap existing allocations there, if we did,
1061 * we are dead, we must be the first in town ! 1054 * we are dead, we must be the first in town !
1062 */ 1055 */
1063 if (addr < RELOC(rmo_top)) { 1056 if (addr < rmo_top) {
1064 /* Good, we are first */ 1057 /* Good, we are first */
1065 if (RELOC(alloc_top) == RELOC(rmo_top)) 1058 if (alloc_top == rmo_top)
1066 RELOC(alloc_top) = RELOC(rmo_top) = addr; 1059 alloc_top = rmo_top = addr;
1067 else 1060 else
1068 return 0; 1061 return 0;
1069 } 1062 }
1070 RELOC(alloc_top_high) = addr; 1063 alloc_top_high = addr;
1071 goto bail; 1064 goto bail;
1072 } 1065 }
1073 1066
1074 base = _ALIGN_DOWN(RELOC(alloc_top) - size, align); 1067 base = _ALIGN_DOWN(alloc_top - size, align);
1075 for (; base > RELOC(alloc_bottom); 1068 for (; base > alloc_bottom;
1076 base = _ALIGN_DOWN(base - 0x100000, align)) { 1069 base = _ALIGN_DOWN(base - 0x100000, align)) {
1077 prom_debug(" trying: 0x%x\n\r", base); 1070 prom_debug(" trying: 0x%x\n\r", base);
1078 addr = (unsigned long)prom_claim(base, size, 0); 1071 addr = (unsigned long)prom_claim(base, size, 0);
@@ -1082,15 +1075,15 @@ static unsigned long __init alloc_down(unsigned long size, unsigned long align,
1082 } 1075 }
1083 if (addr == 0) 1076 if (addr == 0)
1084 return 0; 1077 return 0;
1085 RELOC(alloc_top) = addr; 1078 alloc_top = addr;
1086 1079
1087 bail: 1080 bail:
1088 prom_debug(" -> %x\n", addr); 1081 prom_debug(" -> %x\n", addr);
1089 prom_debug(" alloc_bottom : %x\n", RELOC(alloc_bottom)); 1082 prom_debug(" alloc_bottom : %x\n", alloc_bottom);
1090 prom_debug(" alloc_top : %x\n", RELOC(alloc_top)); 1083 prom_debug(" alloc_top : %x\n", alloc_top);
1091 prom_debug(" alloc_top_hi : %x\n", RELOC(alloc_top_high)); 1084 prom_debug(" alloc_top_hi : %x\n", alloc_top_high);
1092 prom_debug(" rmo_top : %x\n", RELOC(rmo_top)); 1085 prom_debug(" rmo_top : %x\n", rmo_top);
1093 prom_debug(" ram_top : %x\n", RELOC(ram_top)); 1086 prom_debug(" ram_top : %x\n", ram_top);
1094 1087
1095 return addr; 1088 return addr;
1096} 1089}
@@ -1130,7 +1123,7 @@ static unsigned long __init prom_next_cell(int s, cell_t **cellp)
1130static void __init reserve_mem(u64 base, u64 size) 1123static void __init reserve_mem(u64 base, u64 size)
1131{ 1124{
1132 u64 top = base + size; 1125 u64 top = base + size;
1133 unsigned long cnt = RELOC(mem_reserve_cnt); 1126 unsigned long cnt = mem_reserve_cnt;
1134 1127
1135 if (size == 0) 1128 if (size == 0)
1136 return; 1129 return;
@@ -1145,9 +1138,9 @@ static void __init reserve_mem(u64 base, u64 size)
1145 1138
1146 if (cnt >= (MEM_RESERVE_MAP_SIZE - 1)) 1139 if (cnt >= (MEM_RESERVE_MAP_SIZE - 1))
1147 prom_panic("Memory reserve map exhausted !\n"); 1140 prom_panic("Memory reserve map exhausted !\n");
1148 RELOC(mem_reserve_map)[cnt].base = base; 1141 mem_reserve_map[cnt].base = base;
1149 RELOC(mem_reserve_map)[cnt].size = size; 1142 mem_reserve_map[cnt].size = size;
1150 RELOC(mem_reserve_cnt) = cnt + 1; 1143 mem_reserve_cnt = cnt + 1;
1151} 1144}
1152 1145
1153/* 1146/*
@@ -1160,7 +1153,6 @@ static void __init prom_init_mem(void)
1160 char *path, type[64]; 1153 char *path, type[64];
1161 unsigned int plen; 1154 unsigned int plen;
1162 cell_t *p, *endp; 1155 cell_t *p, *endp;
1163 struct prom_t *_prom = &RELOC(prom);
1164 u32 rac, rsc; 1156 u32 rac, rsc;
1165 1157
1166 /* 1158 /*
@@ -1169,14 +1161,14 @@ static void __init prom_init_mem(void)
1169 * 2) top of memory 1161 * 2) top of memory
1170 */ 1162 */
1171 rac = 2; 1163 rac = 2;
1172 prom_getprop(_prom->root, "#address-cells", &rac, sizeof(rac)); 1164 prom_getprop(prom.root, "#address-cells", &rac, sizeof(rac));
1173 rsc = 1; 1165 rsc = 1;
1174 prom_getprop(_prom->root, "#size-cells", &rsc, sizeof(rsc)); 1166 prom_getprop(prom.root, "#size-cells", &rsc, sizeof(rsc));
1175 prom_debug("root_addr_cells: %x\n", (unsigned long) rac); 1167 prom_debug("root_addr_cells: %x\n", (unsigned long) rac);
1176 prom_debug("root_size_cells: %x\n", (unsigned long) rsc); 1168 prom_debug("root_size_cells: %x\n", (unsigned long) rsc);
1177 1169
1178 prom_debug("scanning memory:\n"); 1170 prom_debug("scanning memory:\n");
1179 path = RELOC(prom_scratch); 1171 path = prom_scratch;
1180 1172
1181 for (node = 0; prom_next_node(&node); ) { 1173 for (node = 0; prom_next_node(&node); ) {
1182 type[0] = 0; 1174 type[0] = 0;
@@ -1189,15 +1181,15 @@ static void __init prom_init_mem(void)
1189 */ 1181 */
1190 prom_getprop(node, "name", type, sizeof(type)); 1182 prom_getprop(node, "name", type, sizeof(type));
1191 } 1183 }
1192 if (strcmp(type, RELOC("memory"))) 1184 if (strcmp(type, "memory"))
1193 continue; 1185 continue;
1194 1186
1195 plen = prom_getprop(node, "reg", RELOC(regbuf), sizeof(regbuf)); 1187 plen = prom_getprop(node, "reg", regbuf, sizeof(regbuf));
1196 if (plen > sizeof(regbuf)) { 1188 if (plen > sizeof(regbuf)) {
1197 prom_printf("memory node too large for buffer !\n"); 1189 prom_printf("memory node too large for buffer !\n");
1198 plen = sizeof(regbuf); 1190 plen = sizeof(regbuf);
1199 } 1191 }
1200 p = RELOC(regbuf); 1192 p = regbuf;
1201 endp = p + (plen / sizeof(cell_t)); 1193 endp = p + (plen / sizeof(cell_t));
1202 1194
1203#ifdef DEBUG_PROM 1195#ifdef DEBUG_PROM
@@ -1215,14 +1207,14 @@ static void __init prom_init_mem(void)
1215 if (size == 0) 1207 if (size == 0)
1216 continue; 1208 continue;
1217 prom_debug(" %x %x\n", base, size); 1209 prom_debug(" %x %x\n", base, size);
1218 if (base == 0 && (RELOC(of_platform) & PLATFORM_LPAR)) 1210 if (base == 0 && (of_platform & PLATFORM_LPAR))
1219 RELOC(rmo_top) = size; 1211 rmo_top = size;
1220 if ((base + size) > RELOC(ram_top)) 1212 if ((base + size) > ram_top)
1221 RELOC(ram_top) = base + size; 1213 ram_top = base + size;
1222 } 1214 }
1223 } 1215 }
1224 1216
1225 RELOC(alloc_bottom) = PAGE_ALIGN((unsigned long)&RELOC(_end) + 0x4000); 1217 alloc_bottom = PAGE_ALIGN((unsigned long)&_end + 0x4000);
1226 1218
1227 /* 1219 /*
1228 * If prom_memory_limit is set we reduce the upper limits *except* for 1220 * If prom_memory_limit is set we reduce the upper limits *except* for
@@ -1230,20 +1222,20 @@ static void __init prom_init_mem(void)
1230 * TCE's up there. 1222 * TCE's up there.
1231 */ 1223 */
1232 1224
1233 RELOC(alloc_top_high) = RELOC(ram_top); 1225 alloc_top_high = ram_top;
1234 1226
1235 if (RELOC(prom_memory_limit)) { 1227 if (prom_memory_limit) {
1236 if (RELOC(prom_memory_limit) <= RELOC(alloc_bottom)) { 1228 if (prom_memory_limit <= alloc_bottom) {
1237 prom_printf("Ignoring mem=%x <= alloc_bottom.\n", 1229 prom_printf("Ignoring mem=%x <= alloc_bottom.\n",
1238 RELOC(prom_memory_limit)); 1230 prom_memory_limit);
1239 RELOC(prom_memory_limit) = 0; 1231 prom_memory_limit = 0;
1240 } else if (RELOC(prom_memory_limit) >= RELOC(ram_top)) { 1232 } else if (prom_memory_limit >= ram_top) {
1241 prom_printf("Ignoring mem=%x >= ram_top.\n", 1233 prom_printf("Ignoring mem=%x >= ram_top.\n",
1242 RELOC(prom_memory_limit)); 1234 prom_memory_limit);
1243 RELOC(prom_memory_limit) = 0; 1235 prom_memory_limit = 0;
1244 } else { 1236 } else {
1245 RELOC(ram_top) = RELOC(prom_memory_limit); 1237 ram_top = prom_memory_limit;
1246 RELOC(rmo_top) = min(RELOC(rmo_top), RELOC(prom_memory_limit)); 1238 rmo_top = min(rmo_top, prom_memory_limit);
1247 } 1239 }
1248 } 1240 }
1249 1241
@@ -1255,36 +1247,35 @@ static void __init prom_init_mem(void)
1255 * Since 768MB is plenty of room, and we need to cap to something 1247 * Since 768MB is plenty of room, and we need to cap to something
1256 * reasonable on 32-bit, cap at 768MB on all machines. 1248 * reasonable on 32-bit, cap at 768MB on all machines.
1257 */ 1249 */
1258 if (!RELOC(rmo_top)) 1250 if (!rmo_top)
1259 RELOC(rmo_top) = RELOC(ram_top); 1251 rmo_top = ram_top;
1260 RELOC(rmo_top) = min(0x30000000ul, RELOC(rmo_top)); 1252 rmo_top = min(0x30000000ul, rmo_top);
1261 RELOC(alloc_top) = RELOC(rmo_top); 1253 alloc_top = rmo_top;
1262 RELOC(alloc_top_high) = RELOC(ram_top); 1254 alloc_top_high = ram_top;
1263 1255
1264 /* 1256 /*
1265 * Check if we have an initrd after the kernel but still inside 1257 * Check if we have an initrd after the kernel but still inside
1266 * the RMO. If we do move our bottom point to after it. 1258 * the RMO. If we do move our bottom point to after it.
1267 */ 1259 */
1268 if (RELOC(prom_initrd_start) && 1260 if (prom_initrd_start &&
1269 RELOC(prom_initrd_start) < RELOC(rmo_top) && 1261 prom_initrd_start < rmo_top &&
1270 RELOC(prom_initrd_end) > RELOC(alloc_bottom)) 1262 prom_initrd_end > alloc_bottom)
1271 RELOC(alloc_bottom) = PAGE_ALIGN(RELOC(prom_initrd_end)); 1263 alloc_bottom = PAGE_ALIGN(prom_initrd_end);
1272 1264
1273 prom_printf("memory layout at init:\n"); 1265 prom_printf("memory layout at init:\n");
1274 prom_printf(" memory_limit : %x (16 MB aligned)\n", RELOC(prom_memory_limit)); 1266 prom_printf(" memory_limit : %x (16 MB aligned)\n", prom_memory_limit);
1275 prom_printf(" alloc_bottom : %x\n", RELOC(alloc_bottom)); 1267 prom_printf(" alloc_bottom : %x\n", alloc_bottom);
1276 prom_printf(" alloc_top : %x\n", RELOC(alloc_top)); 1268 prom_printf(" alloc_top : %x\n", alloc_top);
1277 prom_printf(" alloc_top_hi : %x\n", RELOC(alloc_top_high)); 1269 prom_printf(" alloc_top_hi : %x\n", alloc_top_high);
1278 prom_printf(" rmo_top : %x\n", RELOC(rmo_top)); 1270 prom_printf(" rmo_top : %x\n", rmo_top);
1279 prom_printf(" ram_top : %x\n", RELOC(ram_top)); 1271 prom_printf(" ram_top : %x\n", ram_top);
1280} 1272}
1281 1273
1282static void __init prom_close_stdin(void) 1274static void __init prom_close_stdin(void)
1283{ 1275{
1284 struct prom_t *_prom = &RELOC(prom);
1285 ihandle val; 1276 ihandle val;
1286 1277
1287 if (prom_getprop(_prom->chosen, "stdin", &val, sizeof(val)) > 0) 1278 if (prom_getprop(prom.chosen, "stdin", &val, sizeof(val)) > 0)
1288 call_prom("close", 1, 0, val); 1279 call_prom("close", 1, 0, val);
1289} 1280}
1290 1281
@@ -1325,19 +1316,19 @@ static void __init prom_query_opal(void)
1325 } 1316 }
1326 1317
1327 prom_printf("Querying for OPAL presence... "); 1318 prom_printf("Querying for OPAL presence... ");
1328 rc = opal_query_takeover(&RELOC(prom_opal_size), 1319 rc = opal_query_takeover(&prom_opal_size,
1329 &RELOC(prom_opal_align)); 1320 &prom_opal_align);
1330 prom_debug("(rc = %ld) ", rc); 1321 prom_debug("(rc = %ld) ", rc);
1331 if (rc != 0) { 1322 if (rc != 0) {
1332 prom_printf("not there.\n"); 1323 prom_printf("not there.\n");
1333 return; 1324 return;
1334 } 1325 }
1335 RELOC(of_platform) = PLATFORM_OPAL; 1326 of_platform = PLATFORM_OPAL;
1336 prom_printf(" there !\n"); 1327 prom_printf(" there !\n");
1337 prom_debug(" opal_size = 0x%lx\n", RELOC(prom_opal_size)); 1328 prom_debug(" opal_size = 0x%lx\n", prom_opal_size);
1338 prom_debug(" opal_align = 0x%lx\n", RELOC(prom_opal_align)); 1329 prom_debug(" opal_align = 0x%lx\n", prom_opal_align);
1339 if (RELOC(prom_opal_align) < 0x10000) 1330 if (prom_opal_align < 0x10000)
1340 RELOC(prom_opal_align) = 0x10000; 1331 prom_opal_align = 0x10000;
1341} 1332}
1342 1333
1343static int prom_rtas_call(int token, int nargs, int nret, int *outputs, ...) 1334static int prom_rtas_call(int token, int nargs, int nret, int *outputs, ...)
@@ -1358,8 +1349,8 @@ static int prom_rtas_call(int token, int nargs, int nret, int *outputs, ...)
1358 for (i = 0; i < nret; ++i) 1349 for (i = 0; i < nret; ++i)
1359 rtas_args.rets[i] = 0; 1350 rtas_args.rets[i] = 0;
1360 1351
1361 opal_enter_rtas(&rtas_args, RELOC(prom_rtas_data), 1352 opal_enter_rtas(&rtas_args, prom_rtas_data,
1362 RELOC(prom_rtas_entry)); 1353 prom_rtas_entry);
1363 1354
1364 if (nret > 1 && outputs != NULL) 1355 if (nret > 1 && outputs != NULL)
1365 for (i = 0; i < nret-1; ++i) 1356 for (i = 0; i < nret-1; ++i)
@@ -1374,9 +1365,8 @@ static void __init prom_opal_hold_cpus(void)
1374 phandle node; 1365 phandle node;
1375 char type[64]; 1366 char type[64];
1376 u32 servers[8]; 1367 u32 servers[8];
1377 struct prom_t *_prom = &RELOC(prom); 1368 void *entry = (unsigned long *)&opal_secondary_entry;
1378 void *entry = (unsigned long *)&RELOC(opal_secondary_entry); 1369 struct opal_secondary_data *data = &opal_secondary_data;
1379 struct opal_secondary_data *data = &RELOC(opal_secondary_data);
1380 1370
1381 prom_debug("prom_opal_hold_cpus: start...\n"); 1371 prom_debug("prom_opal_hold_cpus: start...\n");
1382 prom_debug(" - entry = 0x%x\n", entry); 1372 prom_debug(" - entry = 0x%x\n", entry);
@@ -1389,12 +1379,12 @@ static void __init prom_opal_hold_cpus(void)
1389 for (node = 0; prom_next_node(&node); ) { 1379 for (node = 0; prom_next_node(&node); ) {
1390 type[0] = 0; 1380 type[0] = 0;
1391 prom_getprop(node, "device_type", type, sizeof(type)); 1381 prom_getprop(node, "device_type", type, sizeof(type));
1392 if (strcmp(type, RELOC("cpu")) != 0) 1382 if (strcmp(type, "cpu") != 0)
1393 continue; 1383 continue;
1394 1384
1395 /* Skip non-configured cpus. */ 1385 /* Skip non-configured cpus. */
1396 if (prom_getprop(node, "status", type, sizeof(type)) > 0) 1386 if (prom_getprop(node, "status", type, sizeof(type)) > 0)
1397 if (strcmp(type, RELOC("okay")) != 0) 1387 if (strcmp(type, "okay") != 0)
1398 continue; 1388 continue;
1399 1389
1400 cnt = prom_getprop(node, "ibm,ppc-interrupt-server#s", servers, 1390 cnt = prom_getprop(node, "ibm,ppc-interrupt-server#s", servers,
@@ -1405,7 +1395,7 @@ static void __init prom_opal_hold_cpus(void)
1405 for (i = 0; i < cnt; i++) { 1395 for (i = 0; i < cnt; i++) {
1406 cpu = servers[i]; 1396 cpu = servers[i];
1407 prom_debug("CPU %d ... ", cpu); 1397 prom_debug("CPU %d ... ", cpu);
1408 if (cpu == _prom->cpu) { 1398 if (cpu == prom.cpu) {
1409 prom_debug("booted !\n"); 1399 prom_debug("booted !\n");
1410 continue; 1400 continue;
1411 } 1401 }
@@ -1416,7 +1406,7 @@ static void __init prom_opal_hold_cpus(void)
1416 * spinloop. 1406 * spinloop.
1417 */ 1407 */
1418 data->ack = -1; 1408 data->ack = -1;
1419 rc = prom_rtas_call(RELOC(prom_rtas_start_cpu), 3, 1, 1409 rc = prom_rtas_call(prom_rtas_start_cpu, 3, 1,
1420 NULL, cpu, entry, data); 1410 NULL, cpu, entry, data);
1421 prom_debug("rtas rc=%d ...", rc); 1411 prom_debug("rtas rc=%d ...", rc);
1422 1412
@@ -1436,21 +1426,21 @@ static void __init prom_opal_hold_cpus(void)
1436 1426
1437static void __init prom_opal_takeover(void) 1427static void __init prom_opal_takeover(void)
1438{ 1428{
1439 struct opal_secondary_data *data = &RELOC(opal_secondary_data); 1429 struct opal_secondary_data *data = &opal_secondary_data;
1440 struct opal_takeover_args *args = &data->args; 1430 struct opal_takeover_args *args = &data->args;
1441 u64 align = RELOC(prom_opal_align); 1431 u64 align = prom_opal_align;
1442 u64 top_addr, opal_addr; 1432 u64 top_addr, opal_addr;
1443 1433
1444 args->k_image = (u64)RELOC(_stext); 1434 args->k_image = (u64)_stext;
1445 args->k_size = _end - _stext; 1435 args->k_size = _end - _stext;
1446 args->k_entry = 0; 1436 args->k_entry = 0;
1447 args->k_entry2 = 0x60; 1437 args->k_entry2 = 0x60;
1448 1438
1449 top_addr = _ALIGN_UP(args->k_size, align); 1439 top_addr = _ALIGN_UP(args->k_size, align);
1450 1440
1451 if (RELOC(prom_initrd_start) != 0) { 1441 if (prom_initrd_start != 0) {
1452 args->rd_image = RELOC(prom_initrd_start); 1442 args->rd_image = prom_initrd_start;
1453 args->rd_size = RELOC(prom_initrd_end) - args->rd_image; 1443 args->rd_size = prom_initrd_end - args->rd_image;
1454 args->rd_loc = top_addr; 1444 args->rd_loc = top_addr;
1455 top_addr = _ALIGN_UP(args->rd_loc + args->rd_size, align); 1445 top_addr = _ALIGN_UP(args->rd_loc + args->rd_size, align);
1456 } 1446 }
@@ -1462,13 +1452,13 @@ static void __init prom_opal_takeover(void)
1462 * has plenty of memory, and we ask for the HAL for now to 1452 * has plenty of memory, and we ask for the HAL for now to
1463 * be just below the 1G point, or above the initrd 1453 * be just below the 1G point, or above the initrd
1464 */ 1454 */
1465 opal_addr = _ALIGN_DOWN(0x40000000 - RELOC(prom_opal_size), align); 1455 opal_addr = _ALIGN_DOWN(0x40000000 - prom_opal_size, align);
1466 if (opal_addr < top_addr) 1456 if (opal_addr < top_addr)
1467 opal_addr = top_addr; 1457 opal_addr = top_addr;
1468 args->hal_addr = opal_addr; 1458 args->hal_addr = opal_addr;
1469 1459
1470 /* Copy the command line to the kernel image */ 1460 /* Copy the command line to the kernel image */
1471 strlcpy(RELOC(boot_command_line), RELOC(prom_cmd_line), 1461 strlcpy(boot_command_line, prom_cmd_line,
1472 COMMAND_LINE_SIZE); 1462 COMMAND_LINE_SIZE);
1473 1463
1474 prom_debug(" k_image = 0x%lx\n", args->k_image); 1464 prom_debug(" k_image = 0x%lx\n", args->k_image);
@@ -1550,8 +1540,8 @@ static void __init prom_instantiate_opal(void)
1550 &entry, sizeof(entry)); 1540 &entry, sizeof(entry));
1551 1541
1552#ifdef CONFIG_PPC_EARLY_DEBUG_OPAL 1542#ifdef CONFIG_PPC_EARLY_DEBUG_OPAL
1553 RELOC(prom_opal_base) = base; 1543 prom_opal_base = base;
1554 RELOC(prom_opal_entry) = entry; 1544 prom_opal_entry = entry;
1555#endif 1545#endif
1556 prom_debug("prom_instantiate_opal: end...\n"); 1546 prom_debug("prom_instantiate_opal: end...\n");
1557} 1547}
@@ -1609,9 +1599,9 @@ static void __init prom_instantiate_rtas(void)
1609 1599
1610#ifdef CONFIG_PPC_POWERNV 1600#ifdef CONFIG_PPC_POWERNV
1611 /* PowerVN takeover hack */ 1601 /* PowerVN takeover hack */
1612 RELOC(prom_rtas_data) = base; 1602 prom_rtas_data = base;
1613 RELOC(prom_rtas_entry) = entry; 1603 prom_rtas_entry = entry;
1614 prom_getprop(rtas_node, "start-cpu", &RELOC(prom_rtas_start_cpu), 4); 1604 prom_getprop(rtas_node, "start-cpu", &prom_rtas_start_cpu, 4);
1615#endif 1605#endif
1616 prom_debug("rtas base = 0x%x\n", base); 1606 prom_debug("rtas base = 0x%x\n", base);
1617 prom_debug("rtas entry = 0x%x\n", entry); 1607 prom_debug("rtas entry = 0x%x\n", entry);
@@ -1686,20 +1676,20 @@ static void __init prom_initialize_tce_table(void)
1686 phandle node; 1676 phandle node;
1687 ihandle phb_node; 1677 ihandle phb_node;
1688 char compatible[64], type[64], model[64]; 1678 char compatible[64], type[64], model[64];
1689 char *path = RELOC(prom_scratch); 1679 char *path = prom_scratch;
1690 u64 base, align; 1680 u64 base, align;
1691 u32 minalign, minsize; 1681 u32 minalign, minsize;
1692 u64 tce_entry, *tce_entryp; 1682 u64 tce_entry, *tce_entryp;
1693 u64 local_alloc_top, local_alloc_bottom; 1683 u64 local_alloc_top, local_alloc_bottom;
1694 u64 i; 1684 u64 i;
1695 1685
1696 if (RELOC(prom_iommu_off)) 1686 if (prom_iommu_off)
1697 return; 1687 return;
1698 1688
1699 prom_debug("starting prom_initialize_tce_table\n"); 1689 prom_debug("starting prom_initialize_tce_table\n");
1700 1690
1701 /* Cache current top of allocs so we reserve a single block */ 1691 /* Cache current top of allocs so we reserve a single block */
1702 local_alloc_top = RELOC(alloc_top_high); 1692 local_alloc_top = alloc_top_high;
1703 local_alloc_bottom = local_alloc_top; 1693 local_alloc_bottom = local_alloc_top;
1704 1694
1705 /* Search all nodes looking for PHBs. */ 1695 /* Search all nodes looking for PHBs. */
@@ -1712,19 +1702,19 @@ static void __init prom_initialize_tce_table(void)
1712 prom_getprop(node, "device_type", type, sizeof(type)); 1702 prom_getprop(node, "device_type", type, sizeof(type));
1713 prom_getprop(node, "model", model, sizeof(model)); 1703 prom_getprop(node, "model", model, sizeof(model));
1714 1704
1715 if ((type[0] == 0) || (strstr(type, RELOC("pci")) == NULL)) 1705 if ((type[0] == 0) || (strstr(type, "pci") == NULL))
1716 continue; 1706 continue;
1717 1707
1718 /* Keep the old logic intact to avoid regression. */ 1708 /* Keep the old logic intact to avoid regression. */
1719 if (compatible[0] != 0) { 1709 if (compatible[0] != 0) {
1720 if ((strstr(compatible, RELOC("python")) == NULL) && 1710 if ((strstr(compatible, "python") == NULL) &&
1721 (strstr(compatible, RELOC("Speedwagon")) == NULL) && 1711 (strstr(compatible, "Speedwagon") == NULL) &&
1722 (strstr(compatible, RELOC("Winnipeg")) == NULL)) 1712 (strstr(compatible, "Winnipeg") == NULL))
1723 continue; 1713 continue;
1724 } else if (model[0] != 0) { 1714 } else if (model[0] != 0) {
1725 if ((strstr(model, RELOC("ython")) == NULL) && 1715 if ((strstr(model, "ython") == NULL) &&
1726 (strstr(model, RELOC("peedwagon")) == NULL) && 1716 (strstr(model, "peedwagon") == NULL) &&
1727 (strstr(model, RELOC("innipeg")) == NULL)) 1717 (strstr(model, "innipeg") == NULL))
1728 continue; 1718 continue;
1729 } 1719 }
1730 1720
@@ -1803,8 +1793,8 @@ static void __init prom_initialize_tce_table(void)
1803 1793
1804 /* These are only really needed if there is a memory limit in 1794 /* These are only really needed if there is a memory limit in
1805 * effect, but we don't know so export them always. */ 1795 * effect, but we don't know so export them always. */
1806 RELOC(prom_tce_alloc_start) = local_alloc_bottom; 1796 prom_tce_alloc_start = local_alloc_bottom;
1807 RELOC(prom_tce_alloc_end) = local_alloc_top; 1797 prom_tce_alloc_end = local_alloc_top;
1808 1798
1809 /* Flag the first invalid entry */ 1799 /* Flag the first invalid entry */
1810 prom_debug("ending prom_initialize_tce_table\n"); 1800 prom_debug("ending prom_initialize_tce_table\n");
@@ -1841,7 +1831,6 @@ static void __init prom_hold_cpus(void)
1841 unsigned int reg; 1831 unsigned int reg;
1842 phandle node; 1832 phandle node;
1843 char type[64]; 1833 char type[64];
1844 struct prom_t *_prom = &RELOC(prom);
1845 unsigned long *spinloop 1834 unsigned long *spinloop
1846 = (void *) LOW_ADDR(__secondary_hold_spinloop); 1835 = (void *) LOW_ADDR(__secondary_hold_spinloop);
1847 unsigned long *acknowledge 1836 unsigned long *acknowledge
@@ -1867,12 +1856,12 @@ static void __init prom_hold_cpus(void)
1867 for (node = 0; prom_next_node(&node); ) { 1856 for (node = 0; prom_next_node(&node); ) {
1868 type[0] = 0; 1857 type[0] = 0;
1869 prom_getprop(node, "device_type", type, sizeof(type)); 1858 prom_getprop(node, "device_type", type, sizeof(type));
1870 if (strcmp(type, RELOC("cpu")) != 0) 1859 if (strcmp(type, "cpu") != 0)
1871 continue; 1860 continue;
1872 1861
1873 /* Skip non-configured cpus. */ 1862 /* Skip non-configured cpus. */
1874 if (prom_getprop(node, "status", type, sizeof(type)) > 0) 1863 if (prom_getprop(node, "status", type, sizeof(type)) > 0)
1875 if (strcmp(type, RELOC("okay")) != 0) 1864 if (strcmp(type, "okay") != 0)
1876 continue; 1865 continue;
1877 1866
1878 reg = -1; 1867 reg = -1;
@@ -1886,7 +1875,7 @@ static void __init prom_hold_cpus(void)
1886 */ 1875 */
1887 *acknowledge = (unsigned long)-1; 1876 *acknowledge = (unsigned long)-1;
1888 1877
1889 if (reg != _prom->cpu) { 1878 if (reg != prom.cpu) {
1890 /* Primary Thread of non-boot cpu or any thread */ 1879 /* Primary Thread of non-boot cpu or any thread */
1891 prom_printf("starting cpu hw idx %lu... ", reg); 1880 prom_printf("starting cpu hw idx %lu... ", reg);
1892 call_prom("start-cpu", 3, 0, node, 1881 call_prom("start-cpu", 3, 0, node,
@@ -1913,22 +1902,20 @@ static void __init prom_hold_cpus(void)
1913 1902
1914static void __init prom_init_client_services(unsigned long pp) 1903static void __init prom_init_client_services(unsigned long pp)
1915{ 1904{
1916 struct prom_t *_prom = &RELOC(prom);
1917
1918 /* Get a handle to the prom entry point before anything else */ 1905 /* Get a handle to the prom entry point before anything else */
1919 RELOC(prom_entry) = pp; 1906 prom_entry = pp;
1920 1907
1921 /* get a handle for the stdout device */ 1908 /* get a handle for the stdout device */
1922 _prom->chosen = call_prom("finddevice", 1, 1, ADDR("/chosen")); 1909 prom.chosen = call_prom("finddevice", 1, 1, ADDR("/chosen"));
1923 if (!PHANDLE_VALID(_prom->chosen)) 1910 if (!PHANDLE_VALID(prom.chosen))
1924 prom_panic("cannot find chosen"); /* msg won't be printed :( */ 1911 prom_panic("cannot find chosen"); /* msg won't be printed :( */
1925 1912
1926 /* get device tree root */ 1913 /* get device tree root */
1927 _prom->root = call_prom("finddevice", 1, 1, ADDR("/")); 1914 prom.root = call_prom("finddevice", 1, 1, ADDR("/"));
1928 if (!PHANDLE_VALID(_prom->root)) 1915 if (!PHANDLE_VALID(prom.root))
1929 prom_panic("cannot find device tree root"); /* msg won't be printed :( */ 1916 prom_panic("cannot find device tree root"); /* msg won't be printed :( */
1930 1917
1931 _prom->mmumap = 0; 1918 prom.mmumap = 0;
1932} 1919}
1933 1920
1934#ifdef CONFIG_PPC32 1921#ifdef CONFIG_PPC32
@@ -1939,7 +1926,6 @@ static void __init prom_init_client_services(unsigned long pp)
1939 */ 1926 */
1940static void __init prom_find_mmu(void) 1927static void __init prom_find_mmu(void)
1941{ 1928{
1942 struct prom_t *_prom = &RELOC(prom);
1943 phandle oprom; 1929 phandle oprom;
1944 char version[64]; 1930 char version[64];
1945 1931
@@ -1957,10 +1943,10 @@ static void __init prom_find_mmu(void)
1957 call_prom("interpret", 1, 1, "dev /memory 0 to allow-reclaim"); 1943 call_prom("interpret", 1, 1, "dev /memory 0 to allow-reclaim");
1958 } else 1944 } else
1959 return; 1945 return;
1960 _prom->memory = call_prom("open", 1, 1, ADDR("/memory")); 1946 prom.memory = call_prom("open", 1, 1, ADDR("/memory"));
1961 prom_getprop(_prom->chosen, "mmu", &_prom->mmumap, 1947 prom_getprop(prom.chosen, "mmu", &prom.mmumap,
1962 sizeof(_prom->mmumap)); 1948 sizeof(prom.mmumap));
1963 if (!IHANDLE_VALID(_prom->memory) || !IHANDLE_VALID(_prom->mmumap)) 1949 if (!IHANDLE_VALID(prom.memory) || !IHANDLE_VALID(prom.mmumap))
1964 of_workarounds &= ~OF_WA_CLAIM; /* hmmm */ 1950 of_workarounds &= ~OF_WA_CLAIM; /* hmmm */
1965} 1951}
1966#else 1952#else
@@ -1969,36 +1955,34 @@ static void __init prom_find_mmu(void)
1969 1955
1970static void __init prom_init_stdout(void) 1956static void __init prom_init_stdout(void)
1971{ 1957{
1972 struct prom_t *_prom = &RELOC(prom); 1958 char *path = of_stdout_device;
1973 char *path = RELOC(of_stdout_device);
1974 char type[16]; 1959 char type[16];
1975 u32 val; 1960 u32 val;
1976 1961
1977 if (prom_getprop(_prom->chosen, "stdout", &val, sizeof(val)) <= 0) 1962 if (prom_getprop(prom.chosen, "stdout", &val, sizeof(val)) <= 0)
1978 prom_panic("cannot find stdout"); 1963 prom_panic("cannot find stdout");
1979 1964
1980 _prom->stdout = val; 1965 prom.stdout = val;
1981 1966
1982 /* Get the full OF pathname of the stdout device */ 1967 /* Get the full OF pathname of the stdout device */
1983 memset(path, 0, 256); 1968 memset(path, 0, 256);
1984 call_prom("instance-to-path", 3, 1, _prom->stdout, path, 255); 1969 call_prom("instance-to-path", 3, 1, prom.stdout, path, 255);
1985 val = call_prom("instance-to-package", 1, 1, _prom->stdout); 1970 val = call_prom("instance-to-package", 1, 1, prom.stdout);
1986 prom_setprop(_prom->chosen, "/chosen", "linux,stdout-package", 1971 prom_setprop(prom.chosen, "/chosen", "linux,stdout-package",
1987 &val, sizeof(val)); 1972 &val, sizeof(val));
1988 prom_printf("OF stdout device is: %s\n", RELOC(of_stdout_device)); 1973 prom_printf("OF stdout device is: %s\n", of_stdout_device);
1989 prom_setprop(_prom->chosen, "/chosen", "linux,stdout-path", 1974 prom_setprop(prom.chosen, "/chosen", "linux,stdout-path",
1990 path, strlen(path) + 1); 1975 path, strlen(path) + 1);
1991 1976
1992 /* If it's a display, note it */ 1977 /* If it's a display, note it */
1993 memset(type, 0, sizeof(type)); 1978 memset(type, 0, sizeof(type));
1994 prom_getprop(val, "device_type", type, sizeof(type)); 1979 prom_getprop(val, "device_type", type, sizeof(type));
1995 if (strcmp(type, RELOC("display")) == 0) 1980 if (strcmp(type, "display") == 0)
1996 prom_setprop(val, path, "linux,boot-display", NULL, 0); 1981 prom_setprop(val, path, "linux,boot-display", NULL, 0);
1997} 1982}
1998 1983
1999static int __init prom_find_machine_type(void) 1984static int __init prom_find_machine_type(void)
2000{ 1985{
2001 struct prom_t *_prom = &RELOC(prom);
2002 char compat[256]; 1986 char compat[256];
2003 int len, i = 0; 1987 int len, i = 0;
2004#ifdef CONFIG_PPC64 1988#ifdef CONFIG_PPC64
@@ -2007,7 +1991,7 @@ static int __init prom_find_machine_type(void)
2007#endif 1991#endif
2008 1992
2009 /* Look for a PowerMac or a Cell */ 1993 /* Look for a PowerMac or a Cell */
2010 len = prom_getprop(_prom->root, "compatible", 1994 len = prom_getprop(prom.root, "compatible",
2011 compat, sizeof(compat)-1); 1995 compat, sizeof(compat)-1);
2012 if (len > 0) { 1996 if (len > 0) {
2013 compat[len] = 0; 1997 compat[len] = 0;
@@ -2016,16 +2000,16 @@ static int __init prom_find_machine_type(void)
2016 int sl = strlen(p); 2000 int sl = strlen(p);
2017 if (sl == 0) 2001 if (sl == 0)
2018 break; 2002 break;
2019 if (strstr(p, RELOC("Power Macintosh")) || 2003 if (strstr(p, "Power Macintosh") ||
2020 strstr(p, RELOC("MacRISC"))) 2004 strstr(p, "MacRISC"))
2021 return PLATFORM_POWERMAC; 2005 return PLATFORM_POWERMAC;
2022#ifdef CONFIG_PPC64 2006#ifdef CONFIG_PPC64
2023 /* We must make sure we don't detect the IBM Cell 2007 /* We must make sure we don't detect the IBM Cell
2024 * blades as pSeries due to some firmware issues, 2008 * blades as pSeries due to some firmware issues,
2025 * so we do it here. 2009 * so we do it here.
2026 */ 2010 */
2027 if (strstr(p, RELOC("IBM,CBEA")) || 2011 if (strstr(p, "IBM,CBEA") ||
2028 strstr(p, RELOC("IBM,CPBW-1.0"))) 2012 strstr(p, "IBM,CPBW-1.0"))
2029 return PLATFORM_GENERIC; 2013 return PLATFORM_GENERIC;
2030#endif /* CONFIG_PPC64 */ 2014#endif /* CONFIG_PPC64 */
2031 i += sl + 1; 2015 i += sl + 1;
@@ -2042,11 +2026,11 @@ static int __init prom_find_machine_type(void)
2042 * non-IBM designs ! 2026 * non-IBM designs !
2043 * - it has /rtas 2027 * - it has /rtas
2044 */ 2028 */
2045 len = prom_getprop(_prom->root, "device_type", 2029 len = prom_getprop(prom.root, "device_type",
2046 compat, sizeof(compat)-1); 2030 compat, sizeof(compat)-1);
2047 if (len <= 0) 2031 if (len <= 0)
2048 return PLATFORM_GENERIC; 2032 return PLATFORM_GENERIC;
2049 if (strcmp(compat, RELOC("chrp"))) 2033 if (strcmp(compat, "chrp"))
2050 return PLATFORM_GENERIC; 2034 return PLATFORM_GENERIC;
2051 2035
2052 /* Default to pSeries. We need to know if we are running LPAR */ 2036 /* Default to pSeries. We need to know if we are running LPAR */
@@ -2108,11 +2092,11 @@ static void __init prom_check_displays(void)
2108 for (node = 0; prom_next_node(&node); ) { 2092 for (node = 0; prom_next_node(&node); ) {
2109 memset(type, 0, sizeof(type)); 2093 memset(type, 0, sizeof(type));
2110 prom_getprop(node, "device_type", type, sizeof(type)); 2094 prom_getprop(node, "device_type", type, sizeof(type));
2111 if (strcmp(type, RELOC("display")) != 0) 2095 if (strcmp(type, "display") != 0)
2112 continue; 2096 continue;
2113 2097
2114 /* It seems OF doesn't null-terminate the path :-( */ 2098 /* It seems OF doesn't null-terminate the path :-( */
2115 path = RELOC(prom_scratch); 2099 path = prom_scratch;
2116 memset(path, 0, PROM_SCRATCH_SIZE); 2100 memset(path, 0, PROM_SCRATCH_SIZE);
2117 2101
2118 /* 2102 /*
@@ -2136,15 +2120,15 @@ static void __init prom_check_displays(void)
2136 2120
2137 /* Setup a usable color table when the appropriate 2121 /* Setup a usable color table when the appropriate
2138 * method is available. Should update this to set-colors */ 2122 * method is available. Should update this to set-colors */
2139 clut = RELOC(default_colors); 2123 clut = default_colors;
2140 for (i = 0; i < 16; i++, clut += 3) 2124 for (i = 0; i < 16; i++, clut += 3)
2141 if (prom_set_color(ih, i, clut[0], clut[1], 2125 if (prom_set_color(ih, i, clut[0], clut[1],
2142 clut[2]) != 0) 2126 clut[2]) != 0)
2143 break; 2127 break;
2144 2128
2145#ifdef CONFIG_LOGO_LINUX_CLUT224 2129#ifdef CONFIG_LOGO_LINUX_CLUT224
2146 clut = PTRRELOC(RELOC(logo_linux_clut224.clut)); 2130 clut = PTRRELOC(logo_linux_clut224.clut);
2147 for (i = 0; i < RELOC(logo_linux_clut224.clutsize); i++, clut += 3) 2131 for (i = 0; i < logo_linux_clut224.clutsize; i++, clut += 3)
2148 if (prom_set_color(ih, i + 32, clut[0], clut[1], 2132 if (prom_set_color(ih, i + 32, clut[0], clut[1],
2149 clut[2]) != 0) 2133 clut[2]) != 0)
2150 break; 2134 break;
@@ -2164,8 +2148,8 @@ static void __init *make_room(unsigned long *mem_start, unsigned long *mem_end,
2164 unsigned long room, chunk; 2148 unsigned long room, chunk;
2165 2149
2166 prom_debug("Chunk exhausted, claiming more at %x...\n", 2150 prom_debug("Chunk exhausted, claiming more at %x...\n",
2167 RELOC(alloc_bottom)); 2151 alloc_bottom);
2168 room = RELOC(alloc_top) - RELOC(alloc_bottom); 2152 room = alloc_top - alloc_bottom;
2169 if (room > DEVTREE_CHUNK_SIZE) 2153 if (room > DEVTREE_CHUNK_SIZE)
2170 room = DEVTREE_CHUNK_SIZE; 2154 room = DEVTREE_CHUNK_SIZE;
2171 if (room < PAGE_SIZE) 2155 if (room < PAGE_SIZE)
@@ -2191,9 +2175,9 @@ static unsigned long __init dt_find_string(char *str)
2191{ 2175{
2192 char *s, *os; 2176 char *s, *os;
2193 2177
2194 s = os = (char *)RELOC(dt_string_start); 2178 s = os = (char *)dt_string_start;
2195 s += 4; 2179 s += 4;
2196 while (s < (char *)RELOC(dt_string_end)) { 2180 while (s < (char *)dt_string_end) {
2197 if (strcmp(s, str) == 0) 2181 if (strcmp(s, str) == 0)
2198 return s - os; 2182 return s - os;
2199 s += strlen(s) + 1; 2183 s += strlen(s) + 1;
@@ -2215,10 +2199,10 @@ static void __init scan_dt_build_strings(phandle node,
2215 unsigned long soff; 2199 unsigned long soff;
2216 phandle child; 2200 phandle child;
2217 2201
2218 sstart = (char *)RELOC(dt_string_start); 2202 sstart = (char *)dt_string_start;
2219 2203
2220 /* get and store all property names */ 2204 /* get and store all property names */
2221 prev_name = RELOC(""); 2205 prev_name = "";
2222 for (;;) { 2206 for (;;) {
2223 /* 64 is max len of name including nul. */ 2207 /* 64 is max len of name including nul. */
2224 namep = make_room(mem_start, mem_end, MAX_PROPERTY_NAME, 1); 2208 namep = make_room(mem_start, mem_end, MAX_PROPERTY_NAME, 1);
@@ -2229,9 +2213,9 @@ static void __init scan_dt_build_strings(phandle node,
2229 } 2213 }
2230 2214
2231 /* skip "name" */ 2215 /* skip "name" */
2232 if (strcmp(namep, RELOC("name")) == 0) { 2216 if (strcmp(namep, "name") == 0) {
2233 *mem_start = (unsigned long)namep; 2217 *mem_start = (unsigned long)namep;
2234 prev_name = RELOC("name"); 2218 prev_name = "name";
2235 continue; 2219 continue;
2236 } 2220 }
2237 /* get/create string entry */ 2221 /* get/create string entry */
@@ -2242,7 +2226,7 @@ static void __init scan_dt_build_strings(phandle node,
2242 } else { 2226 } else {
2243 /* Trim off some if we can */ 2227 /* Trim off some if we can */
2244 *mem_start = (unsigned long)namep + strlen(namep) + 1; 2228 *mem_start = (unsigned long)namep + strlen(namep) + 1;
2245 RELOC(dt_string_end) = *mem_start; 2229 dt_string_end = *mem_start;
2246 } 2230 }
2247 prev_name = namep; 2231 prev_name = namep;
2248 } 2232 }
@@ -2297,35 +2281,35 @@ static void __init scan_dt_build_struct(phandle node, unsigned long *mem_start,
2297 } 2281 }
2298 2282
2299 /* get it again for debugging */ 2283 /* get it again for debugging */
2300 path = RELOC(prom_scratch); 2284 path = prom_scratch;
2301 memset(path, 0, PROM_SCRATCH_SIZE); 2285 memset(path, 0, PROM_SCRATCH_SIZE);
2302 call_prom("package-to-path", 3, 1, node, path, PROM_SCRATCH_SIZE-1); 2286 call_prom("package-to-path", 3, 1, node, path, PROM_SCRATCH_SIZE-1);
2303 2287
2304 /* get and store all properties */ 2288 /* get and store all properties */
2305 prev_name = RELOC(""); 2289 prev_name = "";
2306 sstart = (char *)RELOC(dt_string_start); 2290 sstart = (char *)dt_string_start;
2307 for (;;) { 2291 for (;;) {
2308 if (call_prom("nextprop", 3, 1, node, prev_name, 2292 if (call_prom("nextprop", 3, 1, node, prev_name,
2309 RELOC(pname)) != 1) 2293 pname) != 1)
2310 break; 2294 break;
2311 2295
2312 /* skip "name" */ 2296 /* skip "name" */
2313 if (strcmp(RELOC(pname), RELOC("name")) == 0) { 2297 if (strcmp(pname, "name") == 0) {
2314 prev_name = RELOC("name"); 2298 prev_name = "name";
2315 continue; 2299 continue;
2316 } 2300 }
2317 2301
2318 /* find string offset */ 2302 /* find string offset */
2319 soff = dt_find_string(RELOC(pname)); 2303 soff = dt_find_string(pname);
2320 if (soff == 0) { 2304 if (soff == 0) {
2321 prom_printf("WARNING: Can't find string index for" 2305 prom_printf("WARNING: Can't find string index for"
2322 " <%s>, node %s\n", RELOC(pname), path); 2306 " <%s>, node %s\n", pname, path);
2323 break; 2307 break;
2324 } 2308 }
2325 prev_name = sstart + soff; 2309 prev_name = sstart + soff;
2326 2310
2327 /* get length */ 2311 /* get length */
2328 l = call_prom("getproplen", 2, 1, node, RELOC(pname)); 2312 l = call_prom("getproplen", 2, 1, node, pname);
2329 2313
2330 /* sanity checks */ 2314 /* sanity checks */
2331 if (l == PROM_ERROR) 2315 if (l == PROM_ERROR)
@@ -2338,10 +2322,10 @@ static void __init scan_dt_build_struct(phandle node, unsigned long *mem_start,
2338 2322
2339 /* push property content */ 2323 /* push property content */
2340 valp = make_room(mem_start, mem_end, l, 4); 2324 valp = make_room(mem_start, mem_end, l, 4);
2341 call_prom("getprop", 4, 1, node, RELOC(pname), valp, l); 2325 call_prom("getprop", 4, 1, node, pname, valp, l);
2342 *mem_start = _ALIGN(*mem_start, 4); 2326 *mem_start = _ALIGN(*mem_start, 4);
2343 2327
2344 if (!strcmp(RELOC(pname), RELOC("phandle"))) 2328 if (!strcmp(pname, "phandle"))
2345 has_phandle = 1; 2329 has_phandle = 1;
2346 } 2330 }
2347 2331
@@ -2349,7 +2333,7 @@ static void __init scan_dt_build_struct(phandle node, unsigned long *mem_start,
2349 * existed (can happen with OPAL) 2333 * existed (can happen with OPAL)
2350 */ 2334 */
2351 if (!has_phandle) { 2335 if (!has_phandle) {
2352 soff = dt_find_string(RELOC("linux,phandle")); 2336 soff = dt_find_string("linux,phandle");
2353 if (soff == 0) 2337 if (soff == 0)
2354 prom_printf("WARNING: Can't find string index for" 2338 prom_printf("WARNING: Can't find string index for"
2355 " <linux-phandle> node %s\n", path); 2339 " <linux-phandle> node %s\n", path);
@@ -2377,7 +2361,6 @@ static void __init flatten_device_tree(void)
2377 phandle root; 2361 phandle root;
2378 unsigned long mem_start, mem_end, room; 2362 unsigned long mem_start, mem_end, room;
2379 struct boot_param_header *hdr; 2363 struct boot_param_header *hdr;
2380 struct prom_t *_prom = &RELOC(prom);
2381 char *namep; 2364 char *namep;
2382 u64 *rsvmap; 2365 u64 *rsvmap;
2383 2366
@@ -2385,10 +2368,10 @@ static void __init flatten_device_tree(void)
2385 * Check how much room we have between alloc top & bottom (+/- a 2368 * Check how much room we have between alloc top & bottom (+/- a
2386 * few pages), crop to 1MB, as this is our "chunk" size 2369 * few pages), crop to 1MB, as this is our "chunk" size
2387 */ 2370 */
2388 room = RELOC(alloc_top) - RELOC(alloc_bottom) - 0x4000; 2371 room = alloc_top - alloc_bottom - 0x4000;
2389 if (room > DEVTREE_CHUNK_SIZE) 2372 if (room > DEVTREE_CHUNK_SIZE)
2390 room = DEVTREE_CHUNK_SIZE; 2373 room = DEVTREE_CHUNK_SIZE;
2391 prom_debug("starting device tree allocs at %x\n", RELOC(alloc_bottom)); 2374 prom_debug("starting device tree allocs at %x\n", alloc_bottom);
2392 2375
2393 /* Now try to claim that */ 2376 /* Now try to claim that */
2394 mem_start = (unsigned long)alloc_up(room, PAGE_SIZE); 2377 mem_start = (unsigned long)alloc_up(room, PAGE_SIZE);
@@ -2405,66 +2388,66 @@ static void __init flatten_device_tree(void)
2405 mem_start = _ALIGN(mem_start, 4); 2388 mem_start = _ALIGN(mem_start, 4);
2406 hdr = make_room(&mem_start, &mem_end, 2389 hdr = make_room(&mem_start, &mem_end,
2407 sizeof(struct boot_param_header), 4); 2390 sizeof(struct boot_param_header), 4);
2408 RELOC(dt_header_start) = (unsigned long)hdr; 2391 dt_header_start = (unsigned long)hdr;
2409 rsvmap = make_room(&mem_start, &mem_end, sizeof(mem_reserve_map), 8); 2392 rsvmap = make_room(&mem_start, &mem_end, sizeof(mem_reserve_map), 8);
2410 2393
2411 /* Start of strings */ 2394 /* Start of strings */
2412 mem_start = PAGE_ALIGN(mem_start); 2395 mem_start = PAGE_ALIGN(mem_start);
2413 RELOC(dt_string_start) = mem_start; 2396 dt_string_start = mem_start;
2414 mem_start += 4; /* hole */ 2397 mem_start += 4; /* hole */
2415 2398
2416 /* Add "linux,phandle" in there, we'll need it */ 2399 /* Add "linux,phandle" in there, we'll need it */
2417 namep = make_room(&mem_start, &mem_end, 16, 1); 2400 namep = make_room(&mem_start, &mem_end, 16, 1);
2418 strcpy(namep, RELOC("linux,phandle")); 2401 strcpy(namep, "linux,phandle");
2419 mem_start = (unsigned long)namep + strlen(namep) + 1; 2402 mem_start = (unsigned long)namep + strlen(namep) + 1;
2420 2403
2421 /* Build string array */ 2404 /* Build string array */
2422 prom_printf("Building dt strings...\n"); 2405 prom_printf("Building dt strings...\n");
2423 scan_dt_build_strings(root, &mem_start, &mem_end); 2406 scan_dt_build_strings(root, &mem_start, &mem_end);
2424 RELOC(dt_string_end) = mem_start; 2407 dt_string_end = mem_start;
2425 2408
2426 /* Build structure */ 2409 /* Build structure */
2427 mem_start = PAGE_ALIGN(mem_start); 2410 mem_start = PAGE_ALIGN(mem_start);
2428 RELOC(dt_struct_start) = mem_start; 2411 dt_struct_start = mem_start;
2429 prom_printf("Building dt structure...\n"); 2412 prom_printf("Building dt structure...\n");
2430 scan_dt_build_struct(root, &mem_start, &mem_end); 2413 scan_dt_build_struct(root, &mem_start, &mem_end);
2431 dt_push_token(OF_DT_END, &mem_start, &mem_end); 2414 dt_push_token(OF_DT_END, &mem_start, &mem_end);
2432 RELOC(dt_struct_end) = PAGE_ALIGN(mem_start); 2415 dt_struct_end = PAGE_ALIGN(mem_start);
2433 2416
2434 /* Finish header */ 2417 /* Finish header */
2435 hdr->boot_cpuid_phys = _prom->cpu; 2418 hdr->boot_cpuid_phys = prom.cpu;
2436 hdr->magic = OF_DT_HEADER; 2419 hdr->magic = OF_DT_HEADER;
2437 hdr->totalsize = RELOC(dt_struct_end) - RELOC(dt_header_start); 2420 hdr->totalsize = dt_struct_end - dt_header_start;
2438 hdr->off_dt_struct = RELOC(dt_struct_start) - RELOC(dt_header_start); 2421 hdr->off_dt_struct = dt_struct_start - dt_header_start;
2439 hdr->off_dt_strings = RELOC(dt_string_start) - RELOC(dt_header_start); 2422 hdr->off_dt_strings = dt_string_start - dt_header_start;
2440 hdr->dt_strings_size = RELOC(dt_string_end) - RELOC(dt_string_start); 2423 hdr->dt_strings_size = dt_string_end - dt_string_start;
2441 hdr->off_mem_rsvmap = ((unsigned long)rsvmap) - RELOC(dt_header_start); 2424 hdr->off_mem_rsvmap = ((unsigned long)rsvmap) - dt_header_start;
2442 hdr->version = OF_DT_VERSION; 2425 hdr->version = OF_DT_VERSION;
2443 /* Version 16 is not backward compatible */ 2426 /* Version 16 is not backward compatible */
2444 hdr->last_comp_version = 0x10; 2427 hdr->last_comp_version = 0x10;
2445 2428
2446 /* Copy the reserve map in */ 2429 /* Copy the reserve map in */
2447 memcpy(rsvmap, RELOC(mem_reserve_map), sizeof(mem_reserve_map)); 2430 memcpy(rsvmap, mem_reserve_map, sizeof(mem_reserve_map));
2448 2431
2449#ifdef DEBUG_PROM 2432#ifdef DEBUG_PROM
2450 { 2433 {
2451 int i; 2434 int i;
2452 prom_printf("reserved memory map:\n"); 2435 prom_printf("reserved memory map:\n");
2453 for (i = 0; i < RELOC(mem_reserve_cnt); i++) 2436 for (i = 0; i < mem_reserve_cnt; i++)
2454 prom_printf(" %x - %x\n", 2437 prom_printf(" %x - %x\n",
2455 RELOC(mem_reserve_map)[i].base, 2438 mem_reserve_map[i].base,
2456 RELOC(mem_reserve_map)[i].size); 2439 mem_reserve_map[i].size);
2457 } 2440 }
2458#endif 2441#endif
2459 /* Bump mem_reserve_cnt to cause further reservations to fail 2442 /* Bump mem_reserve_cnt to cause further reservations to fail
2460 * since it's too late. 2443 * since it's too late.
2461 */ 2444 */
2462 RELOC(mem_reserve_cnt) = MEM_RESERVE_MAP_SIZE; 2445 mem_reserve_cnt = MEM_RESERVE_MAP_SIZE;
2463 2446
2464 prom_printf("Device tree strings 0x%x -> 0x%x\n", 2447 prom_printf("Device tree strings 0x%x -> 0x%x\n",
2465 RELOC(dt_string_start), RELOC(dt_string_end)); 2448 dt_string_start, dt_string_end);
2466 prom_printf("Device tree struct 0x%x -> 0x%x\n", 2449 prom_printf("Device tree struct 0x%x -> 0x%x\n",
2467 RELOC(dt_struct_start), RELOC(dt_struct_end)); 2450 dt_struct_start, dt_struct_end);
2468 2451
2469} 2452}
2470 2453
@@ -2519,7 +2502,6 @@ static void __init fixup_device_tree_maple_memory_controller(void)
2519 phandle mc; 2502 phandle mc;
2520 u32 mc_reg[4]; 2503 u32 mc_reg[4];
2521 char *name = "/hostbridge@f8000000"; 2504 char *name = "/hostbridge@f8000000";
2522 struct prom_t *_prom = &RELOC(prom);
2523 u32 ac, sc; 2505 u32 ac, sc;
2524 2506
2525 mc = call_prom("finddevice", 1, 1, ADDR(name)); 2507 mc = call_prom("finddevice", 1, 1, ADDR(name));
@@ -2529,8 +2511,8 @@ static void __init fixup_device_tree_maple_memory_controller(void)
2529 if (prom_getproplen(mc, "reg") != 8) 2511 if (prom_getproplen(mc, "reg") != 8)
2530 return; 2512 return;
2531 2513
2532 prom_getprop(_prom->root, "#address-cells", &ac, sizeof(ac)); 2514 prom_getprop(prom.root, "#address-cells", &ac, sizeof(ac));
2533 prom_getprop(_prom->root, "#size-cells", &sc, sizeof(sc)); 2515 prom_getprop(prom.root, "#size-cells", &sc, sizeof(sc));
2534 if ((ac != 2) || (sc != 2)) 2516 if ((ac != 2) || (sc != 2))
2535 return; 2517 return;
2536 2518
@@ -2799,46 +2781,43 @@ static void __init fixup_device_tree(void)
2799 2781
2800static void __init prom_find_boot_cpu(void) 2782static void __init prom_find_boot_cpu(void)
2801{ 2783{
2802 struct prom_t *_prom = &RELOC(prom);
2803 u32 getprop_rval; 2784 u32 getprop_rval;
2804 ihandle prom_cpu; 2785 ihandle prom_cpu;
2805 phandle cpu_pkg; 2786 phandle cpu_pkg;
2806 2787
2807 _prom->cpu = 0; 2788 prom.cpu = 0;
2808 if (prom_getprop(_prom->chosen, "cpu", &prom_cpu, sizeof(prom_cpu)) <= 0) 2789 if (prom_getprop(prom.chosen, "cpu", &prom_cpu, sizeof(prom_cpu)) <= 0)
2809 return; 2790 return;
2810 2791
2811 cpu_pkg = call_prom("instance-to-package", 1, 1, prom_cpu); 2792 cpu_pkg = call_prom("instance-to-package", 1, 1, prom_cpu);
2812 2793
2813 prom_getprop(cpu_pkg, "reg", &getprop_rval, sizeof(getprop_rval)); 2794 prom_getprop(cpu_pkg, "reg", &getprop_rval, sizeof(getprop_rval));
2814 _prom->cpu = getprop_rval; 2795 prom.cpu = getprop_rval;
2815 2796
2816 prom_debug("Booting CPU hw index = %lu\n", _prom->cpu); 2797 prom_debug("Booting CPU hw index = %lu\n", prom.cpu);
2817} 2798}
2818 2799
2819static void __init prom_check_initrd(unsigned long r3, unsigned long r4) 2800static void __init prom_check_initrd(unsigned long r3, unsigned long r4)
2820{ 2801{
2821#ifdef CONFIG_BLK_DEV_INITRD 2802#ifdef CONFIG_BLK_DEV_INITRD
2822 struct prom_t *_prom = &RELOC(prom);
2823
2824 if (r3 && r4 && r4 != 0xdeadbeef) { 2803 if (r3 && r4 && r4 != 0xdeadbeef) {
2825 unsigned long val; 2804 unsigned long val;
2826 2805
2827 RELOC(prom_initrd_start) = is_kernel_addr(r3) ? __pa(r3) : r3; 2806 prom_initrd_start = is_kernel_addr(r3) ? __pa(r3) : r3;
2828 RELOC(prom_initrd_end) = RELOC(prom_initrd_start) + r4; 2807 prom_initrd_end = prom_initrd_start + r4;
2829 2808
2830 val = RELOC(prom_initrd_start); 2809 val = prom_initrd_start;
2831 prom_setprop(_prom->chosen, "/chosen", "linux,initrd-start", 2810 prom_setprop(prom.chosen, "/chosen", "linux,initrd-start",
2832 &val, sizeof(val)); 2811 &val, sizeof(val));
2833 val = RELOC(prom_initrd_end); 2812 val = prom_initrd_end;
2834 prom_setprop(_prom->chosen, "/chosen", "linux,initrd-end", 2813 prom_setprop(prom.chosen, "/chosen", "linux,initrd-end",
2835 &val, sizeof(val)); 2814 &val, sizeof(val));
2836 2815
2837 reserve_mem(RELOC(prom_initrd_start), 2816 reserve_mem(prom_initrd_start,
2838 RELOC(prom_initrd_end) - RELOC(prom_initrd_start)); 2817 prom_initrd_end - prom_initrd_start);
2839 2818
2840 prom_debug("initrd_start=0x%x\n", RELOC(prom_initrd_start)); 2819 prom_debug("initrd_start=0x%x\n", prom_initrd_start);
2841 prom_debug("initrd_end=0x%x\n", RELOC(prom_initrd_end)); 2820 prom_debug("initrd_end=0x%x\n", prom_initrd_end);
2842 } 2821 }
2843#endif /* CONFIG_BLK_DEV_INITRD */ 2822#endif /* CONFIG_BLK_DEV_INITRD */
2844} 2823}
@@ -2901,7 +2880,6 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,
2901 unsigned long r6, unsigned long r7, 2880 unsigned long r6, unsigned long r7,
2902 unsigned long kbase) 2881 unsigned long kbase)
2903{ 2882{
2904 struct prom_t *_prom;
2905 unsigned long hdr; 2883 unsigned long hdr;
2906 2884
2907#ifdef CONFIG_PPC32 2885#ifdef CONFIG_PPC32
@@ -2911,12 +2889,10 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,
2911 reloc_toc(); 2889 reloc_toc();
2912#endif 2890#endif
2913 2891
2914 _prom = &RELOC(prom);
2915
2916 /* 2892 /*
2917 * First zero the BSS 2893 * First zero the BSS
2918 */ 2894 */
2919 memset(&RELOC(__bss_start), 0, __bss_stop - __bss_start); 2895 memset(&__bss_start, 0, __bss_stop - __bss_start);
2920 2896
2921 /* 2897 /*
2922 * Init interface to Open Firmware, get some node references, 2898 * Init interface to Open Firmware, get some node references,
@@ -2935,14 +2911,14 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,
2935 */ 2911 */
2936 prom_init_stdout(); 2912 prom_init_stdout();
2937 2913
2938 prom_printf("Preparing to boot %s", RELOC(linux_banner)); 2914 prom_printf("Preparing to boot %s", linux_banner);
2939 2915
2940 /* 2916 /*
2941 * Get default machine type. At this point, we do not differentiate 2917 * Get default machine type. At this point, we do not differentiate
2942 * between pSeries SMP and pSeries LPAR 2918 * between pSeries SMP and pSeries LPAR
2943 */ 2919 */
2944 RELOC(of_platform) = prom_find_machine_type(); 2920 of_platform = prom_find_machine_type();
2945 prom_printf("Detected machine type: %x\n", RELOC(of_platform)); 2921 prom_printf("Detected machine type: %x\n", of_platform);
2946 2922
2947#ifndef CONFIG_NONSTATIC_KERNEL 2923#ifndef CONFIG_NONSTATIC_KERNEL
2948 /* Bail if this is a kdump kernel. */ 2924 /* Bail if this is a kdump kernel. */
@@ -2959,15 +2935,15 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,
2959 /* 2935 /*
2960 * On pSeries, inform the firmware about our capabilities 2936 * On pSeries, inform the firmware about our capabilities
2961 */ 2937 */
2962 if (RELOC(of_platform) == PLATFORM_PSERIES || 2938 if (of_platform == PLATFORM_PSERIES ||
2963 RELOC(of_platform) == PLATFORM_PSERIES_LPAR) 2939 of_platform == PLATFORM_PSERIES_LPAR)
2964 prom_send_capabilities(); 2940 prom_send_capabilities();
2965#endif 2941#endif
2966 2942
2967 /* 2943 /*
2968 * Copy the CPU hold code 2944 * Copy the CPU hold code
2969 */ 2945 */
2970 if (RELOC(of_platform) != PLATFORM_POWERMAC) 2946 if (of_platform != PLATFORM_POWERMAC)
2971 copy_and_flush(0, kbase, 0x100, 0); 2947 copy_and_flush(0, kbase, 0x100, 0);
2972 2948
2973 /* 2949 /*
@@ -2996,7 +2972,7 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,
2996 * that uses the allocator, we need to make sure we get the top of memory 2972 * that uses the allocator, we need to make sure we get the top of memory
2997 * available for us here... 2973 * available for us here...
2998 */ 2974 */
2999 if (RELOC(of_platform) == PLATFORM_PSERIES) 2975 if (of_platform == PLATFORM_PSERIES)
3000 prom_initialize_tce_table(); 2976 prom_initialize_tce_table();
3001#endif 2977#endif
3002 2978
@@ -3004,19 +2980,19 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,
3004 * On non-powermacs, try to instantiate RTAS. PowerMacs don't 2980 * On non-powermacs, try to instantiate RTAS. PowerMacs don't
3005 * have a usable RTAS implementation. 2981 * have a usable RTAS implementation.
3006 */ 2982 */
3007 if (RELOC(of_platform) != PLATFORM_POWERMAC && 2983 if (of_platform != PLATFORM_POWERMAC &&
3008 RELOC(of_platform) != PLATFORM_OPAL) 2984 of_platform != PLATFORM_OPAL)
3009 prom_instantiate_rtas(); 2985 prom_instantiate_rtas();
3010 2986
3011#ifdef CONFIG_PPC_POWERNV 2987#ifdef CONFIG_PPC_POWERNV
3012 /* Detect HAL and try instanciating it & doing takeover */ 2988 /* Detect HAL and try instanciating it & doing takeover */
3013 if (RELOC(of_platform) == PLATFORM_PSERIES_LPAR) { 2989 if (of_platform == PLATFORM_PSERIES_LPAR) {
3014 prom_query_opal(); 2990 prom_query_opal();
3015 if (RELOC(of_platform) == PLATFORM_OPAL) { 2991 if (of_platform == PLATFORM_OPAL) {
3016 prom_opal_hold_cpus(); 2992 prom_opal_hold_cpus();
3017 prom_opal_takeover(); 2993 prom_opal_takeover();
3018 } 2994 }
3019 } else if (RELOC(of_platform) == PLATFORM_OPAL) 2995 } else if (of_platform == PLATFORM_OPAL)
3020 prom_instantiate_opal(); 2996 prom_instantiate_opal();
3021#endif 2997#endif
3022 2998
@@ -3030,32 +3006,32 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,
3030 * 3006 *
3031 * PowerMacs use a different mechanism to spin CPUs 3007 * PowerMacs use a different mechanism to spin CPUs
3032 */ 3008 */
3033 if (RELOC(of_platform) != PLATFORM_POWERMAC && 3009 if (of_platform != PLATFORM_POWERMAC &&
3034 RELOC(of_platform) != PLATFORM_OPAL) 3010 of_platform != PLATFORM_OPAL)
3035 prom_hold_cpus(); 3011 prom_hold_cpus();
3036 3012
3037 /* 3013 /*
3038 * Fill in some infos for use by the kernel later on 3014 * Fill in some infos for use by the kernel later on
3039 */ 3015 */
3040 if (RELOC(prom_memory_limit)) 3016 if (prom_memory_limit)
3041 prom_setprop(_prom->chosen, "/chosen", "linux,memory-limit", 3017 prom_setprop(prom.chosen, "/chosen", "linux,memory-limit",
3042 &RELOC(prom_memory_limit), 3018 &prom_memory_limit,
3043 sizeof(prom_memory_limit)); 3019 sizeof(prom_memory_limit));
3044#ifdef CONFIG_PPC64 3020#ifdef CONFIG_PPC64
3045 if (RELOC(prom_iommu_off)) 3021 if (prom_iommu_off)
3046 prom_setprop(_prom->chosen, "/chosen", "linux,iommu-off", 3022 prom_setprop(prom.chosen, "/chosen", "linux,iommu-off",
3047 NULL, 0); 3023 NULL, 0);
3048 3024
3049 if (RELOC(prom_iommu_force_on)) 3025 if (prom_iommu_force_on)
3050 prom_setprop(_prom->chosen, "/chosen", "linux,iommu-force-on", 3026 prom_setprop(prom.chosen, "/chosen", "linux,iommu-force-on",
3051 NULL, 0); 3027 NULL, 0);
3052 3028
3053 if (RELOC(prom_tce_alloc_start)) { 3029 if (prom_tce_alloc_start) {
3054 prom_setprop(_prom->chosen, "/chosen", "linux,tce-alloc-start", 3030 prom_setprop(prom.chosen, "/chosen", "linux,tce-alloc-start",
3055 &RELOC(prom_tce_alloc_start), 3031 &prom_tce_alloc_start,
3056 sizeof(prom_tce_alloc_start)); 3032 sizeof(prom_tce_alloc_start));
3057 prom_setprop(_prom->chosen, "/chosen", "linux,tce-alloc-end", 3033 prom_setprop(prom.chosen, "/chosen", "linux,tce-alloc-end",
3058 &RELOC(prom_tce_alloc_end), 3034 &prom_tce_alloc_end,
3059 sizeof(prom_tce_alloc_end)); 3035 sizeof(prom_tce_alloc_end));
3060 } 3036 }
3061#endif 3037#endif
@@ -3077,8 +3053,8 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,
3077 * closed stdin already (in particular the powerbook 101). It 3053 * closed stdin already (in particular the powerbook 101). It
3078 * appears that the OPAL version of OFW doesn't like it either. 3054 * appears that the OPAL version of OFW doesn't like it either.
3079 */ 3055 */
3080 if (RELOC(of_platform) != PLATFORM_POWERMAC && 3056 if (of_platform != PLATFORM_POWERMAC &&
3081 RELOC(of_platform) != PLATFORM_OPAL) 3057 of_platform != PLATFORM_OPAL)
3082 prom_close_stdin(); 3058 prom_close_stdin();
3083 3059
3084 /* 3060 /*
@@ -3093,10 +3069,10 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,
3093 * tree and NULL as r5, thus triggering the new entry point which 3069 * tree and NULL as r5, thus triggering the new entry point which
3094 * is common to us and kexec 3070 * is common to us and kexec
3095 */ 3071 */
3096 hdr = RELOC(dt_header_start); 3072 hdr = dt_header_start;
3097 3073
3098 /* Don't print anything after quiesce under OPAL, it crashes OFW */ 3074 /* Don't print anything after quiesce under OPAL, it crashes OFW */
3099 if (RELOC(of_platform) != PLATFORM_OPAL) { 3075 if (of_platform != PLATFORM_OPAL) {
3100 prom_printf("returning from prom_init\n"); 3076 prom_printf("returning from prom_init\n");
3101 prom_debug("->dt_header_start=0x%x\n", hdr); 3077 prom_debug("->dt_header_start=0x%x\n", hdr);
3102 } 3078 }
@@ -3110,7 +3086,7 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,
3110#ifdef CONFIG_PPC_EARLY_DEBUG_OPAL 3086#ifdef CONFIG_PPC_EARLY_DEBUG_OPAL
3111 /* OPAL early debug gets the OPAL base & entry in r8 and r9 */ 3087 /* OPAL early debug gets the OPAL base & entry in r8 and r9 */
3112 __start(hdr, kbase, 0, 0, 0, 3088 __start(hdr, kbase, 0, 0, 0,
3113 RELOC(prom_opal_base), RELOC(prom_opal_entry)); 3089 prom_opal_base, prom_opal_entry);
3114#else 3090#else
3115 __start(hdr, kbase, 0, 0, 0, 0, 0); 3091 __start(hdr, kbase, 0, 0, 0, 0, 0);
3116#endif 3092#endif