X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=arch%2Fppc64%2Fkernel%2Fprom.c;h=a5f8f241895a3f80dbfb3b48555c115a461ac1f3;hb=f9296eb00ed30209424102d3c920e69617eea853;hp=bdf5e3a476dcb9d01ae619757bd495c7bb146e69;hpb=a91482bdcc2e0f6035702e46f1b99043a0893346;p=linux-2.6.git diff --git a/arch/ppc64/kernel/prom.c b/arch/ppc64/kernel/prom.c index bdf5e3a47..a5f8f2418 100644 --- a/arch/ppc64/kernel/prom.c +++ b/arch/ppc64/kernel/prom.c @@ -15,7 +15,9 @@ * 2 of the License, or (at your option) any later version. */ -#undef DEBUG_PROM +#if 0 +#define DEBUG_PROM +#endif #include #include @@ -89,17 +91,15 @@ extern const struct linux_logo logo_linux_clut224; */ -#define PROM_BUG() do { \ - prom_printf("kernel BUG at %s line 0x%x!\n", \ - RELOC(__FILE__), __LINE__); \ - __asm__ __volatile__(".long " BUG_ILLEGAL_INSTR); \ +#define PROM_BUG() do { \ + prom_print(RELOC("kernel BUG at ")); \ + prom_print(RELOC(__FILE__)); \ + prom_print(RELOC(":")); \ + prom_print_hex(__LINE__); \ + prom_print(RELOC("!\n")); \ + __asm__ __volatile__(".long " BUG_ILLEGAL_INSTR); \ } while (0) -#ifdef DEBUG_PROM -#define prom_debug(x...) prom_printf(x) -#else -#define prom_debug(x...) -#endif struct pci_reg_property { @@ -133,10 +133,10 @@ typedef unsigned long interpret_func(struct device_node *, unsigned long, /* prom structure */ struct prom_t prom; -char *prom_display_paths[FB_MAX] __initdata = { NULL, }; +char *prom_display_paths[FB_MAX] __initdata = { 0, }; phandle prom_display_nodes[FB_MAX] __initdata; unsigned int prom_num_displays = 0; -char *of_stdout_device = NULL; +char *of_stdout_device = 0; static int iommu_force_on; int ppc64_iommu_off; @@ -148,13 +148,13 @@ extern struct lmb lmb; #define MAX_PHB (32 * 6) /* 32 drawers * 6 PHBs/drawer */ struct of_tce_table of_tce_table[MAX_PHB + 1]; -char *bootpath = NULL; -char *bootdevice = NULL; +char *bootpath = 0; +char *bootdevice = 0; int boot_cpuid = 0; #define MAX_CPU_THREADS 2 -struct device_node *allnodes = NULL; +struct device_node *allnodes = 0; /* use when traversing tree through the allnext, child, sibling, * or parent members of struct device_node. */ @@ -178,44 +178,37 @@ struct { char testString[] = "LINUX\n"; -/* - * This are used in calls to call_prom. The 4th and following - * arguments to call_prom should be 32-bit values. 64 bit values - * are truncated to 32 bits (and fortunately don't get interpreted - * as two arguments). - */ -#define ADDR(x) (u32) ((unsigned long)(x) - offset) /* This is the one and *ONLY* place where we actually call open * firmware from, since we need to make sure we're running in 32b * mode when we do. We switch back to 64b mode upon return. */ -#define PROM_ERROR (-1) +#define PROM_ERROR (0x00000000fffffffful) -static int __init call_prom(const char *service, int nargs, int nret, ...) +static unsigned long __init call_prom(const char *service, int nargs, int nret, ...) { int i; unsigned long offset = reloc_offset(); struct prom_t *_prom = PTRRELOC(&prom); va_list list; - - _prom->args.service = ADDR(service); + + _prom->args.service = (u32)LONG_LSW(service); _prom->args.nargs = nargs; _prom->args.nret = nret; - _prom->args.rets = (prom_arg_t *)&(_prom->args.args[nargs]); + _prom->args.rets = (prom_arg_t *)&(_prom->args.args[nargs]); - va_start(list, nret); - for (i=0; i < nargs; i++) - _prom->args.args[i] = va_arg(list, prom_arg_t); - va_end(list); + va_start(list, nret); + for (i=0; i < nargs ;i++) + _prom->args.args[i] = (prom_arg_t)LONG_LSW(va_arg(list, unsigned long)); + va_end(list); for (i=0; i < nret ;i++) _prom->args.rets[i] = 0; enter_prom(&_prom->args); - return (nret > 0)? _prom->args.rets[0]: 0; + return (unsigned long)((nret > 0) ? _prom->args.rets[0] : 0); } @@ -232,81 +225,47 @@ static void __init prom_print(const char *msg) for (q = p; *q != 0 && *q != '\n'; ++q) ; if (q > p) - call_prom("write", 3, 1, _prom->stdout, p, q - p); - if (*q == 0) - break; - ++q; - call_prom("write", 3, 1, _prom->stdout, ADDR("\r\n"), 2); + call_prom(RELOC("write"), 3, 1, _prom->stdout, + p, q - p); + if (*q != 0) { + ++q; + call_prom(RELOC("write"), 3, 1, _prom->stdout, + RELOC("\r\n"), 2); + } } } static void __init prom_print_hex(unsigned long val) { - unsigned long offset = reloc_offset(); - int i, nibbles = sizeof(val)*2; - char buf[sizeof(val)*2+1]; - struct prom_t *_prom = PTRRELOC(&prom); + int i, nibbles = sizeof(val)*2; + char buf[sizeof(val)*2+1]; - for (i = nibbles-1; i >= 0; i--) { - buf[i] = (val & 0xf) + '0'; - if (buf[i] > '9') - buf[i] += ('a'-'0'-10); - val >>= 4; - } - buf[nibbles] = '\0'; - call_prom("write", 3, 1, _prom->stdout, buf, nibbles); + for (i = nibbles-1; i >= 0; i--) { + buf[i] = (val & 0xf) + '0'; + if (buf[i] > '9') + buf[i] += ('a'-'0'-10); + val >>= 4; + } + buf[nibbles] = '\0'; + prom_print(buf); } -static void __init prom_printf(const char *format, ...) +static void __init prom_print_nl(void) { unsigned long offset = reloc_offset(); - const char *p, *q, *s; - va_list args; - unsigned long v; - struct prom_t *_prom = PTRRELOC(&prom); - - va_start(args, format); - for (p = PTRRELOC(format); *p != 0; p = q) { - for (q = p; *q != 0 && *q != '\n' && *q != '%'; ++q) - ; - if (q > p) - call_prom("write", 3, 1, _prom->stdout, p, q - p); - if (*q == 0) - break; - if (*q == '\n') { - ++q; - call_prom("write", 3, 1, _prom->stdout, - ADDR("\r\n"), 2); - continue; - } - ++q; - if (*q == 0) - break; - switch (*q) { - case 's': - ++q; - s = va_arg(args, const char *); - prom_print(s); - break; - case 'x': - ++q; - v = va_arg(args, unsigned long); - prom_print_hex(v); - break; - } - } + prom_print(RELOC("\n")); } -static void __init __attribute__((noreturn)) prom_panic(const char *reason) +static void __init prom_panic(const char *reason) { unsigned long offset = reloc_offset(); - prom_print(PTRRELOC(reason)); + prom_print(reason); /* ToDo: should put up an SRC here */ - call_prom("exit", 0, 0); + call_prom(RELOC("exit"), 0, 0); for (;;) /* should never get here */ ; @@ -316,49 +275,45 @@ static void __init __attribute__((noreturn)) prom_panic(const char *reason) static int __init prom_next_node(phandle *nodep) { phandle node; + unsigned long offset = reloc_offset(); if ((node = *nodep) != 0 - && (*nodep = call_prom("child", 1, 1, node)) != 0) + && (*nodep = call_prom(RELOC("child"), 1, 1, node)) != 0) return 1; - if ((*nodep = call_prom("peer", 1, 1, node)) != 0) + if ((*nodep = call_prom(RELOC("peer"), 1, 1, node)) != 0) return 1; for (;;) { - if ((node = call_prom("parent", 1, 1, node)) == 0) + if ((node = call_prom(RELOC("parent"), 1, 1, node)) == 0) return 0; - if ((*nodep = call_prom("peer", 1, 1, node)) != 0) + if ((*nodep = call_prom(RELOC("peer"), 1, 1, node)) != 0) return 1; } } -static int __init prom_getprop(phandle node, const char *pname, - void *value, size_t valuelen) -{ - unsigned long offset = reloc_offset(); - - return call_prom("getprop", 4, 1, node, ADDR(pname), - (u32)(unsigned long) value, (u32) valuelen); -} static void __init prom_initialize_naca(void) { phandle node; char type[64]; - unsigned long num_cpus = 0; - unsigned long offset = reloc_offset(); + unsigned long num_cpus = 0; + unsigned long offset = reloc_offset(); struct prom_t *_prom = PTRRELOC(&prom); - struct naca_struct *_naca = RELOC(naca); - struct systemcfg *_systemcfg = RELOC(systemcfg); + struct naca_struct *_naca = RELOC(naca); + struct systemcfg *_systemcfg = RELOC(systemcfg); /* NOTE: _naca->debug_switch is already initialized. */ - prom_debug("prom_initialize_naca: start...\n"); +#ifdef DEBUG_PROM + prom_print(RELOC("prom_initialize_naca: start...\n")); +#endif _naca->pftSize = 0; /* ilog2 of htab size. computed below. */ - for (node = 0; prom_next_node(&node); ) { - type[0] = 0; - prom_getprop(node, "device_type", type, sizeof(type)); + for (node = 0; prom_next_node(&node); ) { + type[0] = 0; + call_prom(RELOC("getprop"), 4, 1, node, RELOC("device_type"), + type, sizeof(type)); - if (!strcmp(type, RELOC("cpu"))) { + if (!strcmp(type, RELOC("cpu"))) { num_cpus += 1; /* We're assuming *all* of the CPUs have the same @@ -366,30 +321,37 @@ static void __init prom_initialize_naca(void) */ if ( num_cpus == 1 ) { u32 size, lsize; - const char *dc, *ic; - - if (_systemcfg->platform == PLATFORM_POWERMAC){ - dc = "d-cache-block-size"; - ic = "i-cache-block-size"; - } else { - dc = "d-cache-line-size"; - ic = "i-cache-line-size"; - } - prom_getprop(node, "d-cache-size", - &size, sizeof(size)); + call_prom(RELOC("getprop"), 4, 1, node, + RELOC("d-cache-size"), + &size, sizeof(size)); - prom_getprop(node, dc, &lsize, sizeof(lsize)); + if (_systemcfg->platform == PLATFORM_POWERMAC) + call_prom(RELOC("getprop"), 4, 1, node, + RELOC("d-cache-block-size"), + &lsize, sizeof(lsize)); + else + call_prom(RELOC("getprop"), 4, 1, node, + RELOC("d-cache-line-size"), + &lsize, sizeof(lsize)); _systemcfg->dCacheL1Size = size; _systemcfg->dCacheL1LineSize = lsize; _naca->dCacheL1LogLineSize = __ilog2(lsize); _naca->dCacheL1LinesPerPage = PAGE_SIZE/lsize; - prom_getprop(node, "i-cache-size", - &size, sizeof(size)); + call_prom(RELOC("getprop"), 4, 1, node, + RELOC("i-cache-size"), + &size, sizeof(size)); - prom_getprop(node, ic, &lsize, sizeof(lsize)); + if (_systemcfg->platform == PLATFORM_POWERMAC) + call_prom(RELOC("getprop"), 4, 1, node, + RELOC("i-cache-block-size"), + &lsize, sizeof(lsize)); + else + call_prom(RELOC("getprop"), 4, 1, node, + RELOC("i-cache-line-size"), + &lsize, sizeof(lsize)); _systemcfg->iCacheL1Size = size; _systemcfg->iCacheL1LineSize = lsize; @@ -398,13 +360,14 @@ static void __init prom_initialize_naca(void) if (_systemcfg->platform == PLATFORM_PSERIES_LPAR) { u32 pft_size[2]; - prom_getprop(node, "ibm,pft-size", - &pft_size, sizeof(pft_size)); + call_prom(RELOC("getprop"), 4, 1, node, + RELOC("ibm,pft-size"), + &pft_size, sizeof(pft_size)); /* pft_size[0] is the NUMA CEC cookie */ _naca->pftSize = pft_size[1]; } } - } else if (!strcmp(type, RELOC("serial"))) { + } else if (!strcmp(type, RELOC("serial"))) { phandle isa, pci; struct isa_reg_property reg; union pci_range ranges; @@ -412,21 +375,24 @@ static void __init prom_initialize_naca(void) if (_systemcfg->platform == PLATFORM_POWERMAC) continue; type[0] = 0; - prom_getprop(node, "ibm,aix-loc", type, sizeof(type)); + call_prom(RELOC("getprop"), 4, 1, node, + RELOC("ibm,aix-loc"), type, sizeof(type)); if (strcmp(type, RELOC("S1"))) continue; - prom_getprop(node, "reg", ®, sizeof(reg)); + call_prom(RELOC("getprop"), 4, 1, node, RELOC("reg"), + ®, sizeof(reg)); - isa = call_prom("parent", 1, 1, node); + isa = call_prom(RELOC("parent"), 1, 1, node); if (!isa) PROM_BUG(); - pci = call_prom("parent", 1, 1, isa); + pci = call_prom(RELOC("parent"), 1, 1, isa); if (!pci) PROM_BUG(); - prom_getprop(pci, "ranges", &ranges, sizeof(ranges)); + call_prom(RELOC("getprop"), 4, 1, pci, RELOC("ranges"), + &ranges, sizeof(ranges)); if ( _prom->encode_phys_size == 32 ) _naca->serialPortAddr = ranges.pci32.phys+reg.address; @@ -435,7 +401,7 @@ static void __init prom_initialize_naca(void) ((((unsigned long)ranges.pci64.phys_hi) << 32) | (ranges.pci64.phys_lo)) + reg.address; } - } + } } if (_systemcfg->platform == PLATFORM_POWERMAC) @@ -444,29 +410,31 @@ static void __init prom_initialize_naca(void) _naca->interrupt_controller = IC_INVALID; for (node = 0; prom_next_node(&node); ) { type[0] = 0; - prom_getprop(node, "name", type, sizeof(type)); + call_prom(RELOC("getprop"), 4, 1, node, RELOC("name"), + type, sizeof(type)); if (strcmp(type, RELOC("interrupt-controller"))) continue; - prom_getprop(node, "compatible", type, sizeof(type)); + call_prom(RELOC("getprop"), 4, 1, node, RELOC("compatible"), + type, sizeof(type)); if (strstr(type, RELOC("open-pic"))) _naca->interrupt_controller = IC_OPEN_PIC; else if (strstr(type, RELOC("ppc-xicp"))) _naca->interrupt_controller = IC_PPC_XIC; else - prom_printf("prom: failed to recognize" - " interrupt-controller\n"); + prom_print(RELOC("prom: failed to recognize" + " interrupt-controller\n")); break; } } if (_naca->interrupt_controller == IC_INVALID) { - prom_printf("prom: failed to find interrupt-controller\n"); + prom_print(RELOC("prom: failed to find interrupt-controller\n")); PROM_BUG(); } /* We gotta have at least 1 cpu... */ - if ( (_systemcfg->processorCount = num_cpus) < 1 ) - PROM_BUG(); + if ( (_systemcfg->processorCount = num_cpus) < 1 ) + PROM_BUG(); _systemcfg->physicalMemorySize = lmb_phys_mem_size(); @@ -486,7 +454,7 @@ static void __init prom_initialize_naca(void) } if (_naca->pftSize == 0) { - prom_printf("prom: failed to compute pftSize!\n"); + prom_print(RELOC("prom: failed to compute pftSize!\n")); PROM_BUG(); } @@ -496,23 +464,41 @@ static void __init prom_initialize_naca(void) _systemcfg->version.minor = SYSTEMCFG_MINOR; _systemcfg->processor = _get_PVR(); - prom_debug("systemcfg->processorCount = 0x%x\n", - _systemcfg->processorCount); - prom_debug("systemcfg->physicalMemorySize = 0x%x\n", - _systemcfg->physicalMemorySize); - prom_debug("naca->pftSize = 0x%x\n", - _naca->pftSize); - prom_debug("systemcfg->dCacheL1LineSize = 0x%x\n", - _systemcfg->dCacheL1LineSize); - prom_debug("systemcfg->iCacheL1LineSize = 0x%x\n", - _systemcfg->iCacheL1LineSize); - prom_debug("naca->serialPortAddr = 0x%x\n", - _naca->serialPortAddr); - prom_debug("naca->interrupt_controller = 0x%x\n", - _naca->interrupt_controller); - prom_debug("systemcfg->platform = 0x%x\n", - _systemcfg->platform); - prom_debug("prom_initialize_naca: end...\n"); +#ifdef DEBUG_PROM + prom_print(RELOC("systemcfg->processorCount = 0x")); + prom_print_hex(_systemcfg->processorCount); + prom_print_nl(); + + prom_print(RELOC("systemcfg->physicalMemorySize = 0x")); + prom_print_hex(_systemcfg->physicalMemorySize); + prom_print_nl(); + + prom_print(RELOC("naca->pftSize = 0x")); + prom_print_hex(_naca->pftSize); + prom_print_nl(); + + prom_print(RELOC("systemcfg->dCacheL1LineSize = 0x")); + prom_print_hex(_systemcfg->dCacheL1LineSize); + prom_print_nl(); + + prom_print(RELOC("systemcfg->iCacheL1LineSize = 0x")); + prom_print_hex(_systemcfg->iCacheL1LineSize); + prom_print_nl(); + + prom_print(RELOC("naca->serialPortAddr = 0x")); + prom_print_hex(_naca->serialPortAddr); + prom_print_nl(); + + prom_print(RELOC("naca->interrupt_controller = 0x")); + prom_print_hex(_naca->interrupt_controller); + prom_print_nl(); + + prom_print(RELOC("systemcfg->platform = 0x")); + prom_print_hex(_systemcfg->platform); + prom_print_nl(); + + prom_print(RELOC("prom_initialize_naca: end...\n")); +#endif } @@ -526,7 +512,9 @@ static void __init early_cmdline_parse(void) opt = strstr(RELOC(cmd_line), RELOC("iommu=")); if (opt) { - prom_printf("opt is:%s\n", opt); + prom_print(RELOC("opt is:")); + prom_print(opt); + prom_print(RELOC("\n")); opt += 6; while (*opt && *opt == ' ') opt++; @@ -539,7 +527,7 @@ static void __init early_cmdline_parse(void) #ifndef CONFIG_PMAC_DART if (_systemcfg->platform == PLATFORM_POWERMAC) { RELOC(ppc64_iommu_off) = 1; - prom_printf("DART disabled on PowerMac !\n"); + prom_print(RELOC("DART disabled on PowerMac !\n")); } #endif } @@ -547,36 +535,51 @@ static void __init early_cmdline_parse(void) #ifdef DEBUG_PROM void prom_dump_lmb(void) { - unsigned long i; - unsigned long offset = reloc_offset(); + unsigned long i; + unsigned long offset = reloc_offset(); struct lmb *_lmb = PTRRELOC(&lmb); - prom_printf("\nprom_dump_lmb:\n"); - prom_printf(" memory.cnt = 0x%x\n", - _lmb->memory.cnt); - prom_printf(" memory.size = 0x%x\n", - _lmb->memory.size); - for (i=0; i < _lmb->memory.cnt ;i++) { - prom_printf(" memory.region[0x%x].base = 0x%x\n", - i, _lmb->memory.region[i].base); - prom_printf(" .physbase = 0x%x\n", - _lmb->memory.region[i].physbase); - prom_printf(" .size = 0x%x\n", - _lmb->memory.region[i].size); - } - - prom_printf("\n reserved.cnt = 0x%x\n", - _lmb->reserved.cnt); - prom_printf(" reserved.size = 0x%x\n", - _lmb->reserved.size); - for (i=0; i < _lmb->reserved.cnt ;i++) { - prom_printf(" reserved.region[0x%x\n].base = 0x%x\n", - i, _lmb->reserved.region[i].base); - prom_printf(" .physbase = 0x%x\n", - _lmb->reserved.region[i].physbase); - prom_printf(" .size = 0x%x\n", - _lmb->reserved.region[i].size); - } + prom_print(RELOC("\nprom_dump_lmb:\n")); + prom_print(RELOC(" memory.cnt = 0x")); + prom_print_hex(_lmb->memory.cnt); + prom_print_nl(); + prom_print(RELOC(" memory.size = 0x")); + prom_print_hex(_lmb->memory.size); + prom_print_nl(); + for (i=0; i < _lmb->memory.cnt ;i++) { + prom_print(RELOC(" memory.region[0x")); + prom_print_hex(i); + prom_print(RELOC("].base = 0x")); + prom_print_hex(_lmb->memory.region[i].base); + prom_print_nl(); + prom_print(RELOC(" .physbase = 0x")); + prom_print_hex(_lmb->memory.region[i].physbase); + prom_print_nl(); + prom_print(RELOC(" .size = 0x")); + prom_print_hex(_lmb->memory.region[i].size); + prom_print_nl(); + } + + prom_print_nl(); + prom_print(RELOC(" reserved.cnt = 0x")); + prom_print_hex(_lmb->reserved.cnt); + prom_print_nl(); + prom_print(RELOC(" reserved.size = 0x")); + prom_print_hex(_lmb->reserved.size); + prom_print_nl(); + for (i=0; i < _lmb->reserved.cnt ;i++) { + prom_print(RELOC(" reserved.region[0x")); + prom_print_hex(i); + prom_print(RELOC("].base = 0x")); + prom_print_hex(_lmb->reserved.region[i].base); + prom_print_nl(); + prom_print(RELOC(" .physbase = 0x")); + prom_print_hex(_lmb->reserved.region[i].physbase); + prom_print_nl(); + prom_print(RELOC(" .size = 0x")); + prom_print_hex(_lmb->reserved.region[i].size); + prom_print_nl(); + } } #endif /* DEBUG_PROM */ @@ -584,9 +587,9 @@ static void __init prom_initialize_lmb(void) { phandle node; char type[64]; - unsigned long i, offset = reloc_offset(); + unsigned long i, offset = reloc_offset(); struct prom_t *_prom = PTRRELOC(&prom); - struct systemcfg *_systemcfg = RELOC(systemcfg); + struct systemcfg *_systemcfg = RELOC(systemcfg); union lmb_reg_property reg; unsigned long lmb_base, lmb_size; unsigned long num_regs, bytes_per_reg = (_prom->encode_phys_size*2)/8; @@ -599,15 +602,16 @@ static void __init prom_initialize_lmb(void) if (_systemcfg->platform == PLATFORM_POWERMAC) bytes_per_reg = 12; - for (node = 0; prom_next_node(&node); ) { - type[0] = 0; - prom_getprop(node, "device_type", type, sizeof(type)); + for (node = 0; prom_next_node(&node); ) { + type[0] = 0; + call_prom(RELOC("getprop"), 4, 1, node, RELOC("device_type"), + type, sizeof(type)); - if (strcmp(type, RELOC("memory"))) + if (strcmp(type, RELOC("memory"))) continue; - num_regs = prom_getprop(node, "reg", ®, sizeof(reg)) - / bytes_per_reg; + num_regs = call_prom(RELOC("getprop"), 4, 1, node, RELOC("reg"), + ®, sizeof(reg)) / bytes_per_reg; for (i=0; i < num_regs ;i++) { if (_systemcfg->platform == PLATFORM_POWERMAC) { @@ -632,7 +636,7 @@ static void __init prom_initialize_lmb(void) } if (lmb_add(lmb_base, lmb_size) < 0) - prom_printf("Too many LMB's, discarding this one...\n"); + prom_print(RELOC("Too many LMB's, discarding this one...\n")); } } @@ -651,26 +655,33 @@ prom_instantiate_rtas(void) struct rtas_t *_rtas = PTRRELOC(&rtas); struct systemcfg *_systemcfg = RELOC(systemcfg); ihandle prom_rtas; - u32 getprop_rval; + u32 getprop_rval; char hypertas_funcs[4]; - prom_debug("prom_instantiate_rtas: start...\n"); - - prom_rtas = call_prom("finddevice", 1, 1, ADDR("/rtas")); +#ifdef DEBUG_PROM + prom_print(RELOC("prom_instantiate_rtas: start...\n")); +#endif + prom_rtas = (ihandle)call_prom(RELOC("finddevice"), 1, 1, RELOC("/rtas")); if (prom_rtas != (ihandle) -1) { unsigned long x; - x = prom_getprop(prom_rtas, "ibm,hypertas-functions", - hypertas_funcs, sizeof(hypertas_funcs)); + x = call_prom(RELOC("getprop"), + 4, 1, prom_rtas, + RELOC("ibm,hypertas-functions"), + hypertas_funcs, + sizeof(hypertas_funcs)); if (x != PROM_ERROR) { - prom_printf("Hypertas detected, assuming LPAR !\n"); + prom_print(RELOC("Hypertas detected, assuming LPAR !\n")); _systemcfg->platform = PLATFORM_PSERIES_LPAR; } - prom_getprop(prom_rtas, "rtas-size", - &getprop_rval, sizeof(getprop_rval)); - _rtas->size = getprop_rval; - prom_printf("instantiating rtas"); + call_prom(RELOC("getprop"), + 4, 1, prom_rtas, + RELOC("rtas-size"), + &getprop_rval, + sizeof(getprop_rval)); + _rtas->size = getprop_rval; + prom_print(RELOC("instantiating rtas")); if (_rtas->size != 0) { unsigned long rtas_region = RTAS_INSTANTIATE_MAX; @@ -685,15 +696,17 @@ prom_instantiate_rtas(void) _rtas->base = lmb_alloc_base(_rtas->size, PAGE_SIZE, rtas_region); - prom_printf(" at 0x%x", _rtas->base); + prom_print(RELOC(" at 0x")); + prom_print_hex(_rtas->base); - prom_rtas = call_prom("open", 1, 1, ADDR("/rtas")); - prom_printf("..."); + prom_rtas = (ihandle)call_prom(RELOC("open"), + 1, 1, RELOC("/rtas")); + prom_print(RELOC("...")); - if (call_prom("call-method", 3, 2, - ADDR("instantiate-rtas"), - prom_rtas, - _rtas->base) != PROM_ERROR) { + if (call_prom(RELOC("call-method"), 3, 2, + RELOC("instantiate-rtas"), + prom_rtas, + _rtas->base) != PROM_ERROR) { _rtas->entry = (long)_prom->args.rets[1]; } RELOC(rtas_rmo_buf) @@ -702,16 +715,26 @@ prom_instantiate_rtas(void) } if (_rtas->entry <= 0) { - prom_printf(" failed\n"); + prom_print(RELOC(" failed\n")); } else { - prom_printf(" done\n"); + prom_print(RELOC(" done\n")); } - prom_debug("rtas->base = 0x%x\n", _rtas->base); - prom_debug("rtas->entry = 0x%x\n", _rtas->entry); - prom_debug("rtas->size = 0x%x\n", _rtas->size); +#ifdef DEBUG_PROM + prom_print(RELOC("rtas->base = 0x")); + prom_print_hex(_rtas->base); + prom_print_nl(); + prom_print(RELOC("rtas->entry = 0x")); + prom_print_hex(_rtas->entry); + prom_print_nl(); + prom_print(RELOC("rtas->size = 0x")); + prom_print_hex(_rtas->size); + prom_print_nl(); +#endif } - prom_debug("prom_instantiate_rtas: end...\n"); +#ifdef DEBUG_PROM + prom_print(RELOC("prom_instantiate_rtas: end...\n")); +#endif } @@ -736,7 +759,9 @@ static void __init prom_initialize_dart_table(void) RELOC(dart_tablebase) = (unsigned long) abs_to_virt(lmb_alloc_base(1UL<<24, 1UL<<24, 0x80000000L)); - prom_printf("Dart at: %x\n", RELOC(dart_tablebase)); + prom_print(RELOC("Dart at: ")); + prom_print_hex(RELOC(dart_tablebase)); + prom_print(RELOC("\n")); } #endif /* CONFIG_PMAC_DART */ @@ -744,7 +769,7 @@ static void __init prom_initialize_tce_table(void) { phandle node; ihandle phb_node; - unsigned long offset = reloc_offset(); + unsigned long offset = reloc_offset(); char compatible[64], path[64], type[64], model[64]; unsigned long i, table = 0; unsigned long base, vbase, align; @@ -755,29 +780,33 @@ static void __init prom_initialize_tce_table(void) if (RELOC(ppc64_iommu_off)) return; - prom_debug("starting prom_initialize_tce_table\n"); +#ifdef DEBUG_PROM + prom_print(RELOC("starting prom_initialize_tce_table\n")); +#endif /* Search all nodes looking for PHBs. */ for (node = 0; prom_next_node(&node); ) { if (table == MAX_PHB) { - prom_printf("WARNING: PCI host bridge ignored, " - "need to increase MAX_PHB\n"); + prom_print(RELOC("WARNING: PCI host bridge ignored, " + "need to increase MAX_PHB\n")); continue; } compatible[0] = 0; type[0] = 0; model[0] = 0; - prom_getprop(node, "compatible", - compatible, sizeof(compatible)); - prom_getprop(node, "device_type", type, sizeof(type)); - prom_getprop(node, "model", model, sizeof(model)); + call_prom(RELOC("getprop"), 4, 1, node, RELOC("compatible"), + compatible, sizeof(compatible)); + call_prom(RELOC("getprop"), 4, 1, node, RELOC("device_type"), + type, sizeof(type)); + call_prom(RELOC("getprop"), 4, 1, node, RELOC("model"), + model, sizeof(model)); /* Keep the old logic in tack to avoid regression. */ if (compatible[0] != 0) { - if ((strstr(compatible, RELOC("python")) == NULL) && - (strstr(compatible, RELOC("Speedwagon")) == NULL) && - (strstr(compatible, RELOC("Winnipeg")) == NULL)) + if((strstr(compatible, RELOC("python")) == NULL) && + (strstr(compatible, RELOC("Speedwagon")) == NULL) && + (strstr(compatible, RELOC("Winnipeg")) == NULL)) continue; } else if (model[0] != 0) { if ((strstr(model, RELOC("ython")) == NULL) && @@ -790,13 +819,15 @@ static void __init prom_initialize_tce_table(void) continue; } - if (prom_getprop(node, "tce-table-minalign", &minalign, - sizeof(minalign)) == PROM_ERROR) { + if (call_prom(RELOC("getprop"), 4, 1, node, + RELOC("tce-table-minalign"), &minalign, + sizeof(minalign)) == PROM_ERROR) { minalign = 0; } - if (prom_getprop(node, "tce-table-minsize", &minsize, - sizeof(minsize)) == PROM_ERROR) { + if (call_prom(RELOC("getprop"), 4, 1, node, + RELOC("tce-table-minsize"), &minsize, + sizeof(minsize)) == PROM_ERROR) { minsize = 4UL << 20; } @@ -823,7 +854,7 @@ static void __init prom_initialize_tce_table(void) base = lmb_alloc(minsize, align); if ( !base ) { - prom_panic("ERROR, cannot find space for TCE table.\n"); + prom_panic(RELOC("ERROR, cannot find space for TCE table.\n")); } vbase = (unsigned long)abs_to_virt(base); @@ -833,10 +864,23 @@ static void __init prom_initialize_tce_table(void) prom_tce_table[table].base = vbase; prom_tce_table[table].size = minsize; - prom_debug("TCE table: 0x%x\n", table); - prom_debug("\tnode = 0x%x\n", node); - prom_debug("\tbase = 0x%x\n", vbase); - prom_debug("\tsize = 0x%x\n", minsize); +#ifdef DEBUG_PROM + prom_print(RELOC("TCE table: 0x")); + prom_print_hex(table); + prom_print_nl(); + + prom_print(RELOC("\tnode = 0x")); + prom_print_hex(node); + prom_print_nl(); + + prom_print(RELOC("\tbase = 0x")); + prom_print_hex(vbase); + prom_print_nl(); + + prom_print(RELOC("\tsize = 0x")); + prom_print_hex(minsize); + prom_print_nl(); +#endif /* Initialize the table to have a one-to-one mapping * over the allocated size. @@ -851,30 +895,37 @@ static void __init prom_initialize_tce_table(void) /* It seems OF doesn't null-terminate the path :-( */ memset(path, 0, sizeof(path)); /* Call OF to setup the TCE hardware */ - if (call_prom("package-to-path", 3, 1, node, - path, sizeof(path)-1) == PROM_ERROR) { - prom_printf("package-to-path failed\n"); - } else { - prom_printf("opening PHB %s", path); - } - - phb_node = call_prom("open", 1, 1, path); - if ( (long)phb_node <= 0) { - prom_printf("... failed\n"); - } else { - prom_printf("... done\n"); - } - call_prom("call-method", 6, 0, ADDR("set-64-bit-addressing"), - phb_node, -1, minsize, - (u32) base, (u32) (base >> 32)); - call_prom("close", 1, 0, phb_node); + if (call_prom(RELOC("package-to-path"), 3, 1, node, + path, sizeof(path)-1) == PROM_ERROR) { + prom_print(RELOC("package-to-path failed\n")); + } else { + prom_print(RELOC("opening PHB ")); + prom_print(path); + } + + phb_node = (ihandle)call_prom(RELOC("open"), 1, 1, path); + if ( (long)phb_node <= 0) { + prom_print(RELOC("... failed\n")); + } else { + prom_print(RELOC("... done\n")); + } + call_prom(RELOC("call-method"), 6, 0, + RELOC("set-64-bit-addressing"), + phb_node, + -1, + minsize, + base & 0xffffffff, + (base >> 32) & 0xffffffff); + call_prom(RELOC("close"), 1, 0, phb_node); table++; } /* Flag the first invalid entry */ prom_tce_table[table].node = 0; - prom_debug("ending prom_initialize_tce_table\n"); +#ifdef DEBUG_PROM + prom_print(RELOC("ending prom_initialize_tce_table\n")); +#endif } /* @@ -910,16 +961,16 @@ static void __init prom_hold_cpus(unsigned long mem) unsigned int cpu_threads, hw_cpu_num; int propsize; extern void __secondary_hold(void); - extern unsigned long __secondary_hold_spinloop; - extern unsigned long __secondary_hold_acknowledge; - unsigned long *spinloop + extern unsigned long __secondary_hold_spinloop; + extern unsigned long __secondary_hold_acknowledge; + unsigned long *spinloop = (void *)virt_to_abs(&__secondary_hold_spinloop); - unsigned long *acknowledge + unsigned long *acknowledge = (void *)virt_to_abs(&__secondary_hold_acknowledge); - unsigned long secondary_hold + unsigned long secondary_hold = virt_to_abs(*PTRRELOC((unsigned long *)__secondary_hold)); - struct systemcfg *_systemcfg = RELOC(systemcfg); - struct paca_struct *lpaca = PTRRELOC(&paca[0]); + struct systemcfg *_systemcfg = RELOC(systemcfg); + struct paca_struct *_xPaca = PTRRELOC(&paca[0]); struct prom_t *_prom = PTRRELOC(&prom); #ifdef CONFIG_SMP struct naca_struct *_naca = RELOC(naca); @@ -932,12 +983,14 @@ static void __init prom_hold_cpus(unsigned long mem) if (_systemcfg->platform == PLATFORM_POWERMAC) { for (node = 0; prom_next_node(&node); ) { type[0] = 0; - prom_getprop(node, "device_type", type, sizeof(type)); + call_prom(RELOC("getprop"), 4, 1, node, RELOC("device_type"), + type, sizeof(type)); if (strcmp(type, RELOC("cpu")) != 0) continue; reg = -1; - prom_getprop(node, "reg", ®, sizeof(reg)); - lpaca[cpuid].hw_cpu_id = reg; + call_prom(RELOC("getprop"), 4, 1, node, RELOC("reg"), + ®, sizeof(reg)); + _xPaca[cpuid].xHwProcNum = reg; #ifdef CONFIG_SMP cpu_set(cpuid, RELOC(cpu_available_map)); @@ -954,20 +1007,31 @@ static void __init prom_hold_cpus(unsigned long mem) /* Initially, we must have one active CPU. */ _systemcfg->processorCount = 1; - prom_debug("prom_hold_cpus: start...\n"); - prom_debug(" 1) spinloop = 0x%x\n", (unsigned long)spinloop); - prom_debug(" 1) *spinloop = 0x%x\n", *spinloop); - prom_debug(" 1) acknowledge = 0x%x\n", - (unsigned long)acknowledge); - prom_debug(" 1) *acknowledge = 0x%x\n", *acknowledge); - prom_debug(" 1) secondary_hold = 0x%x\n", secondary_hold); +#ifdef DEBUG_PROM + prom_print(RELOC("prom_hold_cpus: start...\n")); + prom_print(RELOC(" 1) spinloop = 0x")); + prom_print_hex((unsigned long)spinloop); + prom_print_nl(); + prom_print(RELOC(" 1) *spinloop = 0x")); + prom_print_hex(*spinloop); + prom_print_nl(); + prom_print(RELOC(" 1) acknowledge = 0x")); + prom_print_hex((unsigned long)acknowledge); + prom_print_nl(); + prom_print(RELOC(" 1) *acknowledge = 0x")); + prom_print_hex(*acknowledge); + prom_print_nl(); + prom_print(RELOC(" 1) secondary_hold = 0x")); + prom_print_hex(secondary_hold); + prom_print_nl(); +#endif - /* Set the common spinloop variable, so all of the secondary cpus + /* Set the common spinloop variable, so all of the secondary cpus * will block when they are awakened from their OF spinloop. * This must occur for both SMP and non SMP kernels, since OF will * be trashed when we move the kernel. - */ - *spinloop = 0; + */ + *spinloop = 0; #ifdef CONFIG_HMT for (i=0; i < NR_CPUS; i++) { @@ -977,27 +1041,37 @@ static void __init prom_hold_cpus(unsigned long mem) /* look for cpus */ for (node = 0; prom_next_node(&node); ) { type[0] = 0; - prom_getprop(node, "device_type", type, sizeof(type)); + call_prom(RELOC("getprop"), 4, 1, node, RELOC("device_type"), + type, sizeof(type)); if (strcmp(type, RELOC("cpu")) != 0) continue; /* Skip non-configured cpus. */ - prom_getprop(node, "status", type, sizeof(type)); + call_prom(RELOC("getprop"), 4, 1, node, RELOC("status"), + type, sizeof(type)); if (strcmp(type, RELOC("okay")) != 0) continue; - reg = -1; - prom_getprop(node, "reg", ®, sizeof(reg)); + reg = -1; + call_prom(RELOC("getprop"), 4, 1, node, RELOC("reg"), + ®, sizeof(reg)); path = (char *) mem; memset(path, 0, 256); - if (call_prom("package-to-path", 3, 1, - node, path, 255) == PROM_ERROR) + if ((long) call_prom(RELOC("package-to-path"), 3, 1, + node, path, 255) == PROM_ERROR) continue; - prom_debug("\ncpuid = 0x%x\n", cpuid); - prom_debug("cpu hw idx = 0x%x\n", reg); - lpaca[cpuid].hw_cpu_id = reg; +#ifdef DEBUG_PROM + prom_print_nl(); + prom_print(RELOC("cpuid = 0x")); + prom_print_hex(cpuid); + prom_print_nl(); + prom_print(RELOC("cpu hw idx = 0x")); + prom_print_hex(reg); + prom_print_nl(); +#endif + _xPaca[cpuid].xHwProcNum = reg; /* Init the acknowledge var which will be reset by * the secondary cpu when it awakens from its OF @@ -1005,9 +1079,10 @@ static void __init prom_hold_cpus(unsigned long mem) */ *acknowledge = (unsigned long)-1; - propsize = prom_getprop(node, "ibm,ppc-interrupt-server#s", - &interrupt_server, - sizeof(interrupt_server)); + propsize = call_prom(RELOC("getprop"), 4, 1, node, + RELOC("ibm,ppc-interrupt-server#s"), + &interrupt_server, + sizeof(interrupt_server)); if (propsize < 0) { /* no property. old hardware has no SMT */ cpu_threads = 1; @@ -1016,9 +1091,11 @@ static void __init prom_hold_cpus(unsigned long mem) /* We have a threaded processor */ cpu_threads = propsize / sizeof(u32); if (cpu_threads > MAX_CPU_THREADS) { - prom_printf("SMT: too many threads!\n" - "SMT: found %x, max is %x\n", - cpu_threads, MAX_CPU_THREADS); + prom_print(RELOC("SMT: too many threads!\nSMT: found ")); + prom_print_hex(cpu_threads); + prom_print(RELOC(", max is ")); + prom_print_hex(MAX_CPU_THREADS); + prom_print_nl(); cpu_threads = 1; /* ToDo: panic? */ } } @@ -1026,15 +1103,18 @@ static void __init prom_hold_cpus(unsigned long mem) hw_cpu_num = interrupt_server[0]; if (hw_cpu_num != _prom->cpu) { /* Primary Thread of non-boot cpu */ - prom_printf("%x : starting cpu %s... ", cpuid, path); - call_prom("start-cpu", 3, 0, node, + prom_print_hex(cpuid); + prom_print(RELOC(" : starting cpu ")); + prom_print(path); + prom_print(RELOC("... ")); + call_prom(RELOC("start-cpu"), 3, 0, node, secondary_hold, cpuid); for ( i = 0 ; (i < 100000000) && (*acknowledge == ((unsigned long)-1)); i++ ) ; if (*acknowledge == cpuid) { - prom_printf("... done\n"); + prom_print(RELOC("... done\n")); /* We have to get every CPU out of OF, * even if we never start it. */ if (cpuid >= NR_CPUS) @@ -1047,12 +1127,17 @@ static void __init prom_hold_cpus(unsigned long mem) cpu_set(cpuid, RELOC(cpu_present_at_boot)); #endif } else { - prom_printf("... failed: %x\n", *acknowledge); + prom_print(RELOC("... failed: ")); + prom_print_hex(*acknowledge); + prom_print_nl(); } } #ifdef CONFIG_SMP else { - prom_printf("%x : booting cpu %s\n", cpuid, path); + prom_print_hex(cpuid); + prom_print(RELOC(" : booting cpu ")); + prom_print(path); + prom_print_nl(); cpu_set(cpuid, RELOC(cpu_available_map)); cpu_set(cpuid, RELOC(cpu_possible_map)); cpu_set(cpuid, RELOC(cpu_online_map)); @@ -1066,16 +1151,17 @@ next: cpuid++; if (cpuid >= NR_CPUS) continue; - lpaca[cpuid].hw_cpu_id = interrupt_server[i]; - prom_printf("%x : preparing thread ... ", - interrupt_server[i]); + _xPaca[cpuid].xHwProcNum = interrupt_server[i]; + prom_print_hex(interrupt_server[i]); + prom_print(RELOC(" : preparing thread ... ")); if (_naca->smt_state) { cpu_set(cpuid, RELOC(cpu_available_map)); cpu_set(cpuid, RELOC(cpu_present_at_boot)); - prom_printf("available\n"); + prom_print(RELOC("available")); } else { - prom_printf("not available\n"); + prom_print(RELOC("not available")); } + prom_print_nl(); } #endif cpuid++; @@ -1085,7 +1171,7 @@ next: if (__is_processor(PV_PULSAR) || __is_processor(PV_ICESTAR) || __is_processor(PV_SSTAR)) { - prom_printf(" starting secondary threads\n"); + prom_print(RELOC(" starting secondary threads\n")); for (i = 0; i < NR_CPUS; i += 2) { if (!cpu_online(i)) @@ -1106,25 +1192,27 @@ next: } _systemcfg->processorCount *= 2; } else { - prom_printf("Processor is not HMT capable\n"); + prom_print(RELOC("Processor is not HMT capable\n")); } #endif - if (cpuid > NR_CPUS) - prom_printf("WARNING: maximum CPUs (" __stringify(NR_CPUS) - ") exceeded: ignoring extras\n"); + if (cpuid >= NR_CPUS) + prom_print(RELOC("WARNING: maximum CPUs (" __stringify(NR_CPUS) + ") exceeded: ignoring extras\n")); - prom_debug("prom_hold_cpus: end...\n"); +#ifdef DEBUG_PROM + prom_print(RELOC("prom_hold_cpus: end...\n")); +#endif } static void __init smt_setup(void) { char *p, *q; char my_smt_enabled = SMT_DYNAMIC; - ihandle prom_options = 0; + ihandle prom_options = NULL; char option[9]; unsigned long offset = reloc_offset(); - struct naca_struct *_naca = RELOC(naca); + struct naca_struct *_naca = RELOC(naca); char found = 0; if (strstr(RELOC(cmd_line), RELOC("smt-enabled="))) { @@ -1145,10 +1233,13 @@ static void __init smt_setup(void) } } if (!found) { - prom_options = call_prom("finddevice", 1, 1, ADDR("/options")); + prom_options = (ihandle)call_prom(RELOC("finddevice"), 1, 1, RELOC("/options")); if (prom_options != (ihandle) -1) { - prom_getprop(prom_options, "ibm,smt-enabled", - option, sizeof(option)); + call_prom(RELOC("getprop"), + 4, 1, prom_options, + RELOC("ibm,smt-enabled"), + option, + sizeof(option)); if (option[0] != 0) { found = 1; if (!strcmp(option, RELOC("off"))) @@ -1181,29 +1272,43 @@ static void __init setup_disp_fake_bi(ihandle dp) int i, naddrs; char name[64]; unsigned long offset = reloc_offset(); + char *getprop = RELOC("getprop"); + + prom_print(RELOC("Initializing fake screen: ")); memset(name, 0, sizeof(name)); - prom_getprop(dp, "name", name, sizeof(name)); + call_prom(getprop, 4, 1, dp, RELOC("name"), name, sizeof(name)); name[sizeof(name)-1] = 0; - prom_printf("Initializing fake screen: %s\n", name); - - prom_getprop(dp, "width", &width, sizeof(width)); - prom_getprop(dp, "height", &height, sizeof(height)); - prom_getprop(dp, "depth", &depth, sizeof(depth)); + prom_print(name); + prom_print(RELOC("\n")); + call_prom(getprop, 4, 1, dp, RELOC("width"), &width, sizeof(width)); + call_prom(getprop, 4, 1, dp, RELOC("height"), &height, sizeof(height)); + call_prom(getprop, 4, 1, dp, RELOC("depth"), &depth, sizeof(depth)); pitch = width * ((depth + 7) / 8); - prom_getprop(dp, "linebytes", &pitch, sizeof(pitch)); + call_prom(getprop, 4, 1, dp, RELOC("linebytes"), + &pitch, sizeof(pitch)); if (pitch == 1) pitch = 0x1000; /* for strange IBM display */ address = 0; - prom_printf("width %x height %x depth %x linebytes %x\n", - width, height, depth, depth); + prom_print(RELOC("width ")); + prom_print_hex(width); + prom_print(RELOC(" height ")); + prom_print_hex(height); + prom_print(RELOC(" depth ")); + prom_print_hex(depth); + prom_print(RELOC(" linebytes ")); + prom_print_hex(pitch); + prom_print(RELOC("\n")); + - prom_getprop(dp, "address", &address, sizeof(address)); + call_prom(getprop, 4, 1, dp, RELOC("address"), + &address, sizeof(address)); if (address == 0) { /* look for an assigned address with a size of >= 1MB */ - naddrs = prom_getprop(dp, "assigned-addresses", - addrs, sizeof(addrs)); + naddrs = (int) call_prom(getprop, 4, 1, dp, + RELOC("assigned-addresses"), + addrs, sizeof(addrs)); naddrs /= sizeof(struct pci_reg_property); for (i = 0; i < naddrs; ++i) { if (addrs[i].size_lo >= (1 << 20)) { @@ -1215,12 +1320,14 @@ static void __init setup_disp_fake_bi(ihandle dp) } } if (address == 0) { - prom_printf("Failed to get address of frame buffer\n"); + prom_print(RELOC("Failed to get address of frame buffer\n")); return; } } btext_setup_display(width, height, depth, pitch, address); - prom_printf("Addr of fb: %x\n", address); + prom_print(RELOC("Addr of fb: ")); + prom_print_hex(address); + prom_print_nl(); RELOC(boot_text_mapped) = 0; } #endif /* CONFIG_BOOTX_TEXT */ @@ -1237,14 +1344,15 @@ static void __init prom_init_client_services(unsigned long pp) _prom->encode_phys_size = 32; /* get a handle for the stdout device */ - _prom->chosen = call_prom("finddevice", 1, 1, ADDR("/chosen")); + _prom->chosen = (ihandle)call_prom(RELOC("finddevice"), 1, 1, + RELOC("/chosen")); if ((long)_prom->chosen <= 0) - prom_panic("cannot find chosen"); /* msg won't be printed :( */ + prom_panic(RELOC("cannot find chosen")); /* msg won't be printed :( */ /* get device tree root */ - _prom->root = call_prom("finddevice", 1, 1, ADDR("/")); + _prom->root = (ihandle)call_prom(RELOC("finddevice"), 1, 1, RELOC("/")); if ((long)_prom->root <= 0) - prom_panic("cannot find device tree root"); /* msg won't be printed :( */ + prom_panic(RELOC("cannot find device tree root")); /* msg won't be printed :( */ } static void __init prom_init_stdout(void) @@ -1253,10 +1361,12 @@ static void __init prom_init_stdout(void) struct prom_t *_prom = PTRRELOC(&prom); u32 val; - if (prom_getprop(_prom->chosen, "stdout", &val, sizeof(val)) <= 0) - prom_panic("cannot find stdout"); + if ((long)call_prom(RELOC("getprop"), 4, 1, _prom->chosen, + RELOC("stdout"), &val, + sizeof(val)) <= 0) + prom_panic(RELOC("cannot find stdout")); - _prom->stdout = val; + _prom->stdout = (ihandle)(unsigned long)val; } static int __init prom_find_machine_type(void) @@ -1266,8 +1376,9 @@ static int __init prom_find_machine_type(void) char compat[256]; int len, i = 0; - len = prom_getprop(_prom->root, "compatible", - compat, sizeof(compat)-1); + len = (int)(long)call_prom(RELOC("getprop"), 4, 1, _prom->root, + RELOC("compatible"), + compat, sizeof(compat)-1); if (len > 0) { compat[len] = 0; while (i < len) { @@ -1289,7 +1400,13 @@ static int __init prom_set_color(ihandle ih, int i, int r, int g, int b) { unsigned long offset = reloc_offset(); - return call_prom("call-method", 6, 1, ADDR("color!"), ih, i, b, g, r); + return (int)(long)call_prom(RELOC("call-method"), 6, 1, + RELOC("color!"), + ih, + (void *)(long) i, + (void *)(long) b, + (void *)(long) g, + (void *)(long) r ); } /* @@ -1306,7 +1423,7 @@ static unsigned long __init check_display(unsigned long mem) ihandle ih; int i, j; unsigned long offset = reloc_offset(); - struct prom_t *_prom = PTRRELOC(&prom); + struct prom_t *_prom = PTRRELOC(&prom); char type[16], *path; static unsigned char default_colors[] = { 0x00, 0x00, 0x00, @@ -1330,13 +1447,16 @@ static unsigned long __init check_display(unsigned long mem) _prom->disp_node = 0; - prom_printf("Looking for displays\n"); - if (RELOC(of_stdout_device) != 0) - prom_printf("OF stdout is : %s\n", - PTRRELOC(RELOC(of_stdout_device))); + prom_print(RELOC("Looking for displays\n")); + if (RELOC(of_stdout_device) != 0) { + prom_print(RELOC("OF stdout is : ")); + prom_print(PTRRELOC(RELOC(of_stdout_device))); + prom_print(RELOC("\n")); + } for (node = 0; prom_next_node(&node); ) { type[0] = 0; - prom_getprop(node, "device_type", type, sizeof(type)); + call_prom(RELOC("getprop"), 4, 1, node, RELOC("device_type"), + type, sizeof(type)); if (strcmp(type, RELOC("display")) != 0) continue; /* It seems OF doesn't null-terminate the path :-( */ @@ -1347,9 +1467,12 @@ static unsigned long __init check_display(unsigned long mem) * leave some room at the end of the path for appending extra * arguments */ - if (call_prom("package-to-path", 3, 1, node, path, 250) < 0) + if ((long) call_prom(RELOC("package-to-path"), 3, 1, + node, path, 250) < 0) continue; - prom_printf("found display : %s\n", path); + prom_print(RELOC("found display : ")); + prom_print(path); + prom_print(RELOC("\n")); /* * If this display is the device that OF is using for stdout, @@ -1366,26 +1489,27 @@ static unsigned long __init check_display(unsigned long mem) RELOC(prom_display_nodes[i]) = RELOC(prom_display_nodes[i-1]); } - _prom->disp_node = node; + _prom->disp_node = (ihandle)(unsigned long)node; } RELOC(prom_display_paths[i]) = PTRUNRELOC(path); RELOC(prom_display_nodes[i]) = node; if (_prom->disp_node == 0) - _prom->disp_node = node; + _prom->disp_node = (ihandle)(unsigned long)node; if (RELOC(prom_num_displays) >= FB_MAX) break; } - prom_printf("Opening displays...\n"); + prom_print(RELOC("Opening displays...\n")); for (j = RELOC(prom_num_displays) - 1; j >= 0; j--) { path = PTRRELOC(RELOC(prom_display_paths[j])); - prom_printf("opening display : %s", path); - ih = call_prom("open", 1, 1, path); + prom_print(RELOC("opening display : ")); + prom_print(path); + ih = (ihandle)call_prom(RELOC("open"), 1, 1, path); if (ih == (ihandle)0 || ih == (ihandle)-1) { - prom_printf("... failed\n"); + prom_print(RELOC("... failed\n")); continue; } - prom_printf("... done\n"); + prom_print(RELOC("... done\n")); /* Setup a useable color table when the appropriate * method is available. Should update this to set-colors */ @@ -1403,7 +1527,7 @@ static unsigned long __init check_display(unsigned long mem) break; #endif /* CONFIG_LOGO_LINUX_CLUT224 */ } - + return DOUBLEWORD_ALIGN(mem); } @@ -1412,19 +1536,19 @@ static void __init *__make_room(unsigned long *mem_start, unsigned long *mem_end unsigned long needed, unsigned long align) { void *ret; + unsigned long offset = reloc_offset(); *mem_start = ALIGN(*mem_start, align); if (*mem_start + needed > *mem_end) { #ifdef CONFIG_BLK_DEV_INITRD - unsigned long offset = reloc_offset(); /* FIXME: Apple OF doesn't map unclaimed mem. If this * ever happened on G5, we'd need to fix. */ unsigned long initrd_len; if (*mem_end != RELOC(initrd_start)) - prom_panic("No memory for copy_device_tree"); + prom_panic(RELOC("No memory for copy_device_tree")); - prom_printf("Huge device_tree: moving initrd\n"); + prom_print(RELOC("Huge device_tree: moving initrd\n")); /* Move by 4M. */ initrd_len = RELOC(initrd_end) - RELOC(initrd_start); *mem_end = RELOC(initrd_start) + 4 * 1024 * 1024; @@ -1433,7 +1557,7 @@ static void __init *__make_room(unsigned long *mem_start, unsigned long *mem_end RELOC(initrd_start) = *mem_end; RELOC(initrd_end) = RELOC(initrd_start) + initrd_len; #else - prom_panic("No memory for copy_device_tree"); + prom_panic(RELOC("No memory for copy_device_tree")); #endif } @@ -1482,7 +1606,8 @@ inspect_node(phandle node, struct device_node *dad, for (;;) { /* 32 is max len of name including nul. */ namep = make_room(mem_start, mem_end, char[32]); - if (call_prom("nextprop", 3, 1, node, prev_name, namep) <= 0) { + if ((long) call_prom(RELOC("nextprop"), 3, 1, node, prev_name, + namep) <= 0) { /* No more nodes: unwind alloc */ *mem_start = (unsigned long)namep; break; @@ -1494,24 +1619,28 @@ inspect_node(phandle node, struct device_node *dad, pp->name = PTRUNRELOC(namep); prev_name = namep; - pp->length = call_prom("getproplen", 2, 1, node, namep); + pp->length = call_prom(RELOC("getproplen"), 2, 1, node, namep); if (pp->length < 0) continue; if (pp->length > MAX_PROPERTY_LENGTH) { char path[128]; - prom_printf("WARNING: ignoring large property "); + prom_print(RELOC("WARNING: ignoring large property ")); /* It seems OF doesn't null-terminate the path :-( */ memset(path, 0, sizeof(path)); - if (call_prom("package-to-path", 3, 1, node, - path, sizeof(path)-1) > 0) - prom_printf("[%s] ", path); - prom_printf("%s length 0x%x\n", namep, pp->length); + if (call_prom(RELOC("package-to-path"), 3, 1, node, + path, sizeof(path)-1) > 0) + prom_print(path); + prom_print(namep); + prom_print(RELOC(" length 0x")); + prom_print_hex(pp->length); + prom_print_nl(); + continue; } valp = __make_room(mem_start, mem_end, pp->length, 1); pp->value = PTRUNRELOC(valp); - call_prom("getprop", 4, 1, node, namep, valp, pp->length); + call_prom(RELOC("getprop"), 4, 1, node, namep,valp,pp->length); *prev_propp = PTRUNRELOC(pp); prev_propp = &pp->next; } @@ -1531,19 +1660,19 @@ inspect_node(phandle node, struct device_node *dad, /* Set np->linux_phandle to the value of the ibm,phandle property if it exists, otherwise to the phandle for this node. */ np->linux_phandle = node; - if (prom_getprop(node, "ibm,phandle", - &ibm_phandle, sizeof(ibm_phandle)) > 0) + if ((int)call_prom(RELOC("getprop"), 4, 1, node, RELOC("ibm,phandle"), + &ibm_phandle, sizeof(ibm_phandle)) > 0) np->linux_phandle = ibm_phandle; /* get the node's full name */ namep = (char *)*mem_start; - l = call_prom("package-to-path", 3, 1, node, - namep, *mem_end - *mem_start); + l = (long) call_prom(RELOC("package-to-path"), 3, 1, node, + namep, *mem_end - *mem_start); if (l >= 0) { /* Didn't fit? Get more room. */ if (l+1 > *mem_end - *mem_start) { namep = __make_room(mem_start, mem_end, l+1, 1); - call_prom("package-to-path", 3, 1, node, namep, l); + call_prom(RELOC("package-to-path"),3,1,node,namep,l); } np->full_name = PTRUNRELOC(namep); namep[l] = '\0'; @@ -1551,11 +1680,11 @@ inspect_node(phandle node, struct device_node *dad, } /* do all our children */ - child = call_prom("child", 1, 1, node); + child = call_prom(RELOC("child"), 1, 1, node); while (child != (phandle)0) { inspect_node(child, np, mem_start, mem_end, allnextpp); - child = call_prom("peer", 1, 1, child); + child = call_prom(RELOC("peer"), 1, 1, child); } } @@ -1577,13 +1706,13 @@ copy_device_tree(unsigned long mem_start) mem_end = RELOC(initrd_start); #endif /* CONFIG_BLK_DEV_INITRD */ - root = call_prom("peer", 1, 1, (phandle)0); + root = call_prom(RELOC("peer"), 1, 1, (phandle)0); if (root == (phandle)0) { - prom_panic("couldn't get device tree root\n"); + prom_panic(RELOC("couldn't get device tree root\n")); } allnextp = &RELOC(allnodes); - inspect_node(root, NULL, &mem_start, &mem_end, &allnextp); - *allnextp = NULL; + inspect_node(root, 0, &mem_start, &mem_end, &allnextp); + *allnextp = 0; return mem_start; } @@ -1591,25 +1720,44 @@ copy_device_tree(unsigned long mem_start) static struct bi_record * __init prom_bi_rec_verify(struct bi_record *bi_recs) { struct bi_record *first, *last; +#ifdef DEBUG_PROM + unsigned long offset = reloc_offset(); - prom_debug("birec_verify: r6=0x%x\n", (unsigned long)bi_recs); - if (bi_recs != NULL) - prom_debug(" tag=0x%x\n", bi_recs->tag); + prom_print(RELOC("birec_verify: r6=0x")); + prom_print_hex((unsigned long)bi_recs); + prom_print_nl(); + if (bi_recs != NULL) { + prom_print(RELOC(" tag=0x")); + prom_print_hex(bi_recs->tag); + prom_print_nl(); + } +#endif /* DEBUG_PROM */ if ( bi_recs == NULL || bi_recs->tag != BI_FIRST ) return NULL; last = (struct bi_record *)(long)bi_recs->data[0]; - prom_debug(" last=0x%x\n", (unsigned long)last); - if (last != NULL) - prom_debug(" last_tag=0x%x\n", last->tag); +#ifdef DEBUG_PROM + prom_print(RELOC(" last=0x")); + prom_print_hex((unsigned long)last); + prom_print_nl(); + if (last != NULL) { + prom_print(RELOC(" last_tag=0x")); + prom_print_hex(last->tag); + prom_print_nl(); + } +#endif /* DEBUG_PROM */ if ( last == NULL || last->tag != BI_LAST ) return NULL; first = (struct bi_record *)(long)last->data[0]; - prom_debug(" first=0x%x\n", (unsigned long)first); +#ifdef DEBUG_PROM + prom_print(RELOC(" first=0x")); + prom_print_hex((unsigned long)first); + prom_print_nl(); +#endif /* DEBUG_PROM */ if ( first == NULL || first != bi_recs ) return NULL; @@ -1628,7 +1776,11 @@ static void __init prom_bi_rec_reserve(void) for ( rec=_prom->bi_recs; rec->tag != BI_LAST; rec=bi_rec_next(rec) ) { - prom_debug("bi: 0x%x\n", rec->tag); +#ifdef DEBUG_PROM + prom_print(RELOC("bi: 0x")); + prom_print_hex(rec->tag); + prom_print_nl(); +#endif /* DEBUG_PROM */ switch (rec->tag) { #ifdef CONFIG_BLK_DEV_INITRD case BI_INITRD: @@ -1664,7 +1816,7 @@ prom_init(unsigned long r3, unsigned long r4, unsigned long pp, unsigned long phys; u32 getprop_rval; struct systemcfg *_systemcfg; - struct paca_struct *lpaca = PTRRELOC(&paca[0]); + struct paca_struct *_xPaca = PTRRELOC(&paca[0]); struct prom_t *_prom = PTRRELOC(&prom); /* First zero the BSS -- use memset, some arches don't have @@ -1681,17 +1833,31 @@ prom_init(unsigned long r3, unsigned long r4, unsigned long pp, /* Init prom stdout device */ prom_init_stdout(); - prom_debug("klimit=0x%x\n", RELOC(klimit)); - prom_debug("offset=0x%x\n", offset); - prom_debug("->mem=0x%x\n", RELOC(klimit) - offset); +#ifdef DEBUG_PROM + prom_print(RELOC("klimit=0x")); + prom_print_hex(RELOC(klimit)); + prom_print_nl(); + prom_print(RELOC("offset=0x")); + prom_print_hex(offset); + prom_print_nl(); + prom_print(RELOC("->mem=0x")); + prom_print_hex(RELOC(klimit) - offset); + prom_print_nl(); +#endif /* DEBUG_PROM */ /* check out if we have bi_recs */ _prom->bi_recs = prom_bi_rec_verify((struct bi_record *)r6); if ( _prom->bi_recs != NULL ) { RELOC(klimit) = PTRUNRELOC((unsigned long)_prom->bi_recs + _prom->bi_recs->data[1]); - prom_debug("bi_recs=0x%x\n", (unsigned long)_prom->bi_recs); - prom_debug("new mem=0x%x\n", RELOC(klimit) - offset); +#ifdef DEBUG_PROM + prom_print(RELOC("bi_recs=0x")); + prom_print_hex((unsigned long)_prom->bi_recs); + prom_print_nl(); + prom_print(RELOC("new mem=0x")); + prom_print_hex(RELOC(klimit) - offset); + prom_print_nl(); +#endif /* DEBUG_PROM */ } /* If we don't have birec's or didn't find them, check for an initrd @@ -1713,51 +1879,62 @@ prom_init(unsigned long r3, unsigned long r4, unsigned long pp, copy_and_flush(0, KERNELBASE - offset, 0x100, 0); /* Start storing things at klimit */ - mem = RELOC(klimit) - offset; + mem = RELOC(klimit) - offset; /* Get the full OF pathname of the stdout device */ p = (char *) mem; memset(p, 0, 256); - call_prom("instance-to-path", 3, 1, _prom->stdout, p, 255); + call_prom(RELOC("instance-to-path"), 3, 1, _prom->stdout, p, 255); RELOC(of_stdout_device) = PTRUNRELOC(p); mem += strlen(p) + 1; getprop_rval = 1; - prom_getprop(_prom->root, "#size-cells", - &getprop_rval, sizeof(getprop_rval)); + call_prom(RELOC("getprop"), 4, 1, + _prom->root, RELOC("#size-cells"), + &getprop_rval, sizeof(getprop_rval)); _prom->encode_phys_size = (getprop_rval == 1) ? 32 : 64; /* Determine which cpu is actually running right _now_ */ - if (prom_getprop(_prom->chosen, "cpu", - &prom_cpu, sizeof(prom_cpu)) <= 0) - prom_panic("cannot find boot cpu"); - - cpu_pkg = call_prom("instance-to-package", 1, 1, prom_cpu); - prom_getprop(cpu_pkg, "reg", &getprop_rval, sizeof(getprop_rval)); - _prom->cpu = getprop_rval; - lpaca[0].hw_cpu_id = _prom->cpu; + if ((long)call_prom(RELOC("getprop"), 4, 1, _prom->chosen, + RELOC("cpu"), &getprop_rval, + sizeof(getprop_rval)) <= 0) + prom_panic(RELOC("cannot find boot cpu")); + + prom_cpu = (ihandle)(unsigned long)getprop_rval; + cpu_pkg = call_prom(RELOC("instance-to-package"), 1, 1, prom_cpu); + call_prom(RELOC("getprop"), 4, 1, + cpu_pkg, RELOC("reg"), + &getprop_rval, sizeof(getprop_rval)); + _prom->cpu = (int)(unsigned long)getprop_rval; + _xPaca[0].xHwProcNum = _prom->cpu; RELOC(boot_cpuid) = 0; - prom_debug("Booting CPU hw index = 0x%x\n", _prom->cpu); +#ifdef DEBUG_PROM + prom_print(RELOC("Booting CPU hw index = 0x")); + prom_print_hex(_prom->cpu); + prom_print_nl(); +#endif /* Get the boot device and translate it to a full OF pathname. */ p = (char *) mem; - l = prom_getprop(_prom->chosen, "bootpath", p, 1<<20); + l = (long) call_prom(RELOC("getprop"), 4, 1, _prom->chosen, + RELOC("bootpath"), p, 1<<20); if (l > 0) { p[l] = 0; /* should already be null-terminated */ RELOC(bootpath) = PTRUNRELOC(p); mem += l + 1; d = (char *) mem; *d = 0; - call_prom("canon", 3, 1, p, d, 1<<20); + call_prom(RELOC("canon"), 3, 1, p, d, 1<<20); RELOC(bootdevice) = PTRUNRELOC(d); mem = DOUBLEWORD_ALIGN(mem + strlen(d) + 1); } RELOC(cmd_line[0]) = 0; if ((long)_prom->chosen > 0) { - prom_getprop(_prom->chosen, "bootargs", p, sizeof(cmd_line)); + call_prom(RELOC("getprop"), 4, 1, _prom->chosen, + RELOC("bootargs"), p, sizeof(cmd_line)); if (p != NULL && p[0] != 0) strlcpy(RELOC(cmd_line), p, sizeof(cmd_line)); } @@ -1773,31 +1950,44 @@ prom_init(unsigned long r3, unsigned long r4, unsigned long pp, if (_systemcfg->platform != PLATFORM_POWERMAC) prom_instantiate_rtas(); - /* Initialize some system info into the Naca early... */ - prom_initialize_naca(); + /* Initialize some system info into the Naca early... */ + prom_initialize_naca(); smt_setup(); - /* If we are on an SMP machine, then we *MUST* do the - * following, regardless of whether we have an SMP - * kernel or not. - */ + /* If we are on an SMP machine, then we *MUST* do the + * following, regardless of whether we have an SMP + * kernel or not. + */ prom_hold_cpus(mem); - prom_debug("after basic inits, mem=0x%x\n", mem); +#ifdef DEBUG_PROM + prom_print(RELOC("after basic inits, mem=0x")); + prom_print_hex(mem); + prom_print_nl(); #ifdef CONFIG_BLK_DEV_INITRD - prom_debug("initrd_start=0x%x\n", RELOC(initrd_start)); - prom_debug("initrd_end=0x%x\n", RELOC(initrd_end)); + prom_print(RELOC("initrd_start=0x")); + prom_print_hex(RELOC(initrd_start)); + prom_print_nl(); + prom_print(RELOC("initrd_end=0x")); + prom_print_hex(RELOC(initrd_end)); + prom_print_nl(); #endif /* CONFIG_BLK_DEV_INITRD */ - prom_debug("copying OF device tree...\n"); - + prom_print(RELOC("copying OF device tree...\n")); +#endif /* DEBUG_PROM */ mem = copy_device_tree(mem); RELOC(klimit) = mem + offset; - prom_debug("new klimit is\n"); - prom_debug("klimit=0x%x\n", RELOC(klimit)); - prom_debug(" ->mem=0x%x\n", mem); +#ifdef DEBUG_PROM + prom_print(RELOC("new klimit is\n")); + prom_print(RELOC("klimit=0x")); + prom_print_hex(RELOC(klimit)); + prom_print(RELOC(" ->mem=0x\n")); + prom_print(RELOC("klimit=0x")); + prom_print_hex(mem); + prom_print_nl(); +#endif /* DEBUG_PROM */ lmb_reserve(0, __pa(RELOC(klimit))); @@ -1827,14 +2017,14 @@ prom_init(unsigned long r3, unsigned long r4, unsigned long pp, #endif #ifdef CONFIG_BOOTX_TEXT - if (_prom->disp_node) { - prom_printf("Setting up bi display...\n"); + if(_prom->disp_node) { + prom_print(RELOC("Setting up bi display...\n")); setup_disp_fake_bi(_prom->disp_node); } #endif /* CONFIG_BOOTX_TEXT */ - prom_printf("Calling quiesce ...\n"); - call_prom("quiesce", 0, 0); + prom_print(RELOC("Calling quiesce ...\n")); + call_prom(RELOC("quiesce"), 0, 0); phys = KERNELBASE - offset; #ifdef CONFIG_BLK_DEV_INITRD @@ -1845,7 +2035,7 @@ prom_init(unsigned long r3, unsigned long r4, unsigned long pp, } #endif /* CONFIG_BLK_DEV_INITRD */ - prom_printf("returning from prom_init\n"); + prom_print(RELOC("returning from prom_init\n")); return phys; } @@ -1881,7 +2071,8 @@ intr_parent(struct device_node *p) * Find out the size of each entry of the interrupts property * for a node. */ -int __devinit prom_n_intr_cells(struct device_node *np) +static int __devinit +prom_n_intr_cells(struct device_node *np) { struct device_node *p; unsigned int *icp; @@ -1895,7 +2086,7 @@ int __devinit prom_n_intr_cells(struct device_node *np) || get_property(p, "interrupt-map", NULL) != NULL) { printk("oops, node %s doesn't have #interrupt-cells\n", p->full_name); - return 1; + return 1; } } #ifdef DEBUG_IRQ @@ -2081,7 +2272,7 @@ interpret_pci_props(struct device_node *np, unsigned long mem_start, i = 0; adr = (struct address_range *) mem_start; while ((l -= sizeof(struct pci_reg_property)) >= 0) { - if (!measure_only) { + if (!measure_only) { adr[i].space = pci_addrs[i].addr.a_hi; adr[i].address = pci_addrs[i].addr.a_lo; adr[i].size = pci_addrs[i].size_lo; @@ -2120,7 +2311,7 @@ interpret_dbdma_props(struct device_node *np, unsigned long mem_start, i = 0; adr = (struct address_range *) mem_start; while ((l -= sizeof(struct reg_property32)) >= 0) { - if (!measure_only) { + if (!measure_only) { adr[i].space = 2; adr[i].address = rp[i].address + base_address; adr[i].size = rp[i].size; @@ -2160,7 +2351,7 @@ interpret_macio_props(struct device_node *np, unsigned long mem_start, i = 0; adr = (struct address_range *) mem_start; while ((l -= sizeof(struct reg_property32)) >= 0) { - if (!measure_only) { + if (!measure_only) { adr[i].space = 2; adr[i].address = rp[i].address + base_address; adr[i].size = rp[i].size; @@ -2188,7 +2379,7 @@ interpret_isa_props(struct device_node *np, unsigned long mem_start, i = 0; adr = (struct address_range *) mem_start; while ((l -= sizeof(struct reg_property)) >= 0) { - if (!measure_only) { + if (!measure_only) { adr[i].space = rp[i].space; adr[i].address = rp[i].address; adr[i].size = rp[i].size; @@ -2217,7 +2408,7 @@ interpret_root_props(struct device_node *np, unsigned long mem_start, i = 0; adr = (struct address_range *) mem_start; while ((l -= rpsize) >= 0) { - if (!measure_only) { + if (!measure_only) { adr[i].space = 0; adr[i].address = rp[naddrc - 1]; adr[i].size = rp[naddrc + nsizec - 1]; @@ -2240,8 +2431,8 @@ finish_node(struct device_node *np, unsigned long mem_start, struct device_node *child; int *ip; - np->name = get_property(np, "name", NULL); - np->type = get_property(np, "device_type", NULL); + np->name = get_property(np, "name", 0); + np->type = get_property(np, "device_type", 0); if (!np->name) np->name = ""; @@ -2255,10 +2446,10 @@ finish_node(struct device_node *np, unsigned long mem_start, mem_start = finish_node_interrupts(np, mem_start, measure_only); /* Look for #address-cells and #size-cells properties. */ - ip = (int *) get_property(np, "#address-cells", NULL); + ip = (int *) get_property(np, "#address-cells", 0); if (ip != NULL) naddrc = *ip; - ip = (int *) get_property(np, "#size-cells", NULL); + ip = (int *) get_property(np, "#size-cells", 0); if (ip != NULL) nsizec = *ip; @@ -2266,7 +2457,7 @@ finish_node(struct device_node *np, unsigned long mem_start, * expect for the name -- Cort */ if (!strcmp(np->name, "display")) - np->name = get_property(np, "compatible", NULL); + np->name = get_property(np, "compatible", 0); if (!strcmp(np->name, "device-tree") || np->parent == NULL) ifunc = interpret_root_props; @@ -2295,7 +2486,7 @@ finish_node(struct device_node *np, unsigned long mem_start, return mem_start; } -/** +/* * finish_device_tree is called once things are running normally * (i.e. with text and data mapped to the address they were linked at). * It traverses the device tree and fills in the name, type, @@ -2323,7 +2514,7 @@ prom_n_addr_cells(struct device_node* np) do { if (np->parent) np = np->parent; - ip = (int *) get_property(np, "#address-cells", NULL); + ip = (int *) get_property(np, "#address-cells", 0); if (ip != NULL) return *ip; } while (np->parent); @@ -2338,7 +2529,7 @@ prom_n_size_cells(struct device_node* np) do { if (np->parent) np = np->parent; - ip = (int *) get_property(np, "#size-cells", NULL); + ip = (int *) get_property(np, "#size-cells", 0); if (ip != NULL) return *ip; } while (np->parent); @@ -2346,7 +2537,7 @@ prom_n_size_cells(struct device_node* np) return 1; } -/** +/* * Work out the sense (active-low level / active-high edge) * of each interrupt from the device tree. */ @@ -2368,7 +2559,7 @@ prom_get_irq_senses(unsigned char *senses, int off, int max) } } -/** +/* * Construct and return a list of the device_nodes with a given name. */ struct device_node * @@ -2383,11 +2574,11 @@ find_devices(const char *name) prevp = &np->next; } } - *prevp = NULL; + *prevp = 0; return head; } -/** +/* * Construct and return a list of the device_nodes with a given type. */ struct device_node * @@ -2402,11 +2593,11 @@ find_type_devices(const char *type) prevp = &np->next; } } - *prevp = NULL; + *prevp = 0; return head; } -/** +/* * Returns all nodes linked together */ struct device_node * @@ -2419,11 +2610,11 @@ find_all_nodes(void) *prevp = np; prevp = &np->next; } - *prevp = NULL; + *prevp = 0; return head; } -/** Checks if the given "compat" string matches one of the strings in +/* Checks if the given "compat" string matches one of the strings in * the device's "compatible" property */ int @@ -2447,7 +2638,7 @@ device_is_compatible(struct device_node *device, const char *compat) } -/** +/* * Indicates whether the root node has a given value in its * compatible property. */ @@ -2456,7 +2647,7 @@ machine_is_compatible(const char *compat) { struct device_node *root; int rc = 0; - + root = of_find_node_by_path("/"); if (root) { rc = device_is_compatible(root, compat); @@ -2465,7 +2656,7 @@ machine_is_compatible(const char *compat) return rc; } -/** +/* * Construct and return a list of the device_nodes with a given type * and compatible property. */ @@ -2484,11 +2675,11 @@ find_compatible_devices(const char *type, const char *compat) prevp = &np->next; } } - *prevp = NULL; + *prevp = 0; return head; } -/** +/* * Find the device_node with a given full_name. */ struct device_node * @@ -2903,9 +3094,9 @@ static int of_finish_dynamic_node(struct device_node *node) u32 *regs; int err = 0; phandle *ibm_phandle; - - node->name = get_property(node, "name", NULL); - node->type = get_property(node, "device_type", NULL); + + node->name = get_property(node, "name", 0); + node->type = get_property(node, "device_type", 0); if (!parent) { err = -ENODEV; @@ -2951,31 +3142,32 @@ static int of_finish_dynamic_node(struct device_node *node) } /* now do the work of finish_node_interrupts */ - if (get_property(node, "interrupts", NULL)) { + if (get_property(node, "interrupts", 0)) { err = of_finish_dynamic_node_interrupts(node); if (err) goto out; } - /* now do the rough equivalent of update_dn_pci_info, this - * probably is not correct for phb's, but should work for - * IOAs and slots. - */ + /* now do the rough equivalent of update_dn_pci_info, this + * probably is not correct for phb's, but should work for + * IOAs and slots. + */ - node->phb = parent->phb; + node->phb = parent->phb; - regs = (u32 *)get_property(node, "reg", NULL); - if (regs) { - node->busno = (regs[0] >> 16) & 0xff; - node->devfn = (regs[0] >> 8) & 0xff; - } + regs = (u32 *)get_property(node, "reg", 0); + if (regs) { + node->busno = (regs[0] >> 16) & 0xff; + node->devfn = (regs[0] >> 8) & 0xff; + } /* fixing up iommu_table */ - if (strcmp(node->name, "pci") == 0 && - get_property(node, "ibm,dma-window", NULL)) { - node->bussubno = node->busno; - iommu_devnode_init(node); - } else + if(strcmp(node->name, "pci") == 0 && + get_property(node, "ibm,dma-window", NULL)) { + node->bussubno = node->busno; + iommu_devnode_init(node); + } + else node->iommu_table = parent->iommu_table; out: @@ -3095,7 +3287,7 @@ get_property(struct device_node *np, const char *name, int *lenp) *lenp = pp->length; return pp->value; } - return NULL; + return 0; } /*