Commit fe3a3a65 authored by Paul Mackerras's avatar Paul Mackerras Committed by Linus Torvalds

[PATCH] ppc64: clean up prom.c and related files

Somebody back in the mists of time decided that call_prom and rtas_call
should return longs even though both of those bits of firmware run in
32-bit mode and produce a 32-bit result.  To make life more interesting,
the 32-bit result gets zero-extended to 64 bits, which makes checking
for a -1 return value more complicated than it should be.

This patch changes call_prom and rtas_call to return an int, and makes
the corresponding changes to use ints for the variables used to hold
those return values. 

While I was doing this I finally got annoyed enough with the strings of
prom_print() and prom_print_hex() calls that we do to write a simple
prom_printf.  I deliberately didn't use snprintf because the execution
environment is weird at this point - we aren't running at the address we
are linked at just yet - and I didn't want to inflict that on any code
outside this file.  I also did a prom_debug() macro, which eliminated a
few ifdefs. 

There are also a bunch of other minor cleanups.  This patch makes very
few algorithmic changes but does get rid of a lot of casts.  :)

I have been running with this patch for a couple of weeks, and Anton has
tested it too.
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 91bc6523
...@@ -365,7 +365,8 @@ unsigned long eeh_check_failure(void *token, unsigned long val) ...@@ -365,7 +365,8 @@ unsigned long eeh_check_failure(void *token, unsigned long val)
unsigned long addr; unsigned long addr;
struct pci_dev *dev; struct pci_dev *dev;
struct device_node *dn; struct device_node *dn;
unsigned long ret, rets[2]; unsigned long ret;
int rets[2];
static spinlock_t lock = SPIN_LOCK_UNLOCKED; static spinlock_t lock = SPIN_LOCK_UNLOCKED;
/* dont want this on the stack */ /* dont want this on the stack */
static unsigned char slot_err_buf[RTAS_ERROR_LOG_MAX]; static unsigned char slot_err_buf[RTAS_ERROR_LOG_MAX];
...@@ -444,11 +445,11 @@ unsigned long eeh_check_failure(void *token, unsigned long val) ...@@ -444,11 +445,11 @@ unsigned long eeh_check_failure(void *token, unsigned long val)
* can use it here. * can use it here.
*/ */
if (panic_on_oops) { if (panic_on_oops) {
panic("EEH: MMIO failure (%ld) on device:%s %s\n", panic("EEH: MMIO failure (%d) on device:%s %s\n",
rets[0], pci_name(dev), pci_pretty_name(dev)); rets[0], pci_name(dev), pci_pretty_name(dev));
} else { } else {
__get_cpu_var(ignored_failures)++; __get_cpu_var(ignored_failures)++;
printk(KERN_INFO "EEH: MMIO failure (%ld) on device:%s %s\n", printk(KERN_INFO "EEH: MMIO failure (%d) on device:%s %s\n",
rets[0], pci_name(dev), pci_pretty_name(dev)); rets[0], pci_name(dev), pci_pretty_name(dev));
} }
} else { } else {
......
...@@ -37,7 +37,8 @@ static spinlock_t nvram_lock = SPIN_LOCK_UNLOCKED; ...@@ -37,7 +37,8 @@ static spinlock_t nvram_lock = SPIN_LOCK_UNLOCKED;
static ssize_t pSeries_nvram_read(char *buf, size_t count, loff_t *index) static ssize_t pSeries_nvram_read(char *buf, size_t count, loff_t *index)
{ {
unsigned int i; unsigned int i;
unsigned long len, done; unsigned long len;
int done;
unsigned long flags; unsigned long flags;
char *p = buf; char *p = buf;
...@@ -80,7 +81,8 @@ static ssize_t pSeries_nvram_read(char *buf, size_t count, loff_t *index) ...@@ -80,7 +81,8 @@ static ssize_t pSeries_nvram_read(char *buf, size_t count, loff_t *index)
static ssize_t pSeries_nvram_write(char *buf, size_t count, loff_t *index) static ssize_t pSeries_nvram_write(char *buf, size_t count, loff_t *index)
{ {
unsigned int i; unsigned int i;
unsigned long len, done; unsigned long len;
int done;
unsigned long flags; unsigned long flags;
const char *p = buf; const char *p = buf;
......
...@@ -62,7 +62,7 @@ extern unsigned long pci_probe_only; ...@@ -62,7 +62,7 @@ extern unsigned long pci_probe_only;
static int rtas_read_config(struct device_node *dn, int where, int size, u32 *val) static int rtas_read_config(struct device_node *dn, int where, int size, u32 *val)
{ {
unsigned long returnval = ~0L; int returnval = -1;
unsigned long buid, addr; unsigned long buid, addr;
int ret; int ret;
...@@ -72,7 +72,8 @@ static int rtas_read_config(struct device_node *dn, int where, int size, u32 *va ...@@ -72,7 +72,8 @@ static int rtas_read_config(struct device_node *dn, int where, int size, u32 *va
addr = (dn->busno << 16) | (dn->devfn << 8) | where; addr = (dn->busno << 16) | (dn->devfn << 8) | where;
buid = dn->phb->buid; buid = dn->phb->buid;
if (buid) { if (buid) {
ret = rtas_call(ibm_read_pci_config, 4, 2, &returnval, addr, buid >> 32, buid & 0xffffffff, size); ret = rtas_call(ibm_read_pci_config, 4, 2, &returnval,
addr, buid >> 32, buid & 0xffffffff, size);
} else { } else {
ret = rtas_call(read_pci_config, 2, 2, &returnval, addr, size); ret = rtas_call(read_pci_config, 2, 2, &returnval, addr, size);
} }
......
...@@ -15,9 +15,7 @@ ...@@ -15,9 +15,7 @@
* 2 of the License, or (at your option) any later version. * 2 of the License, or (at your option) any later version.
*/ */
#if 0 #undef DEBUG_PROM
#define DEBUG_PROM
#endif
#include <stdarg.h> #include <stdarg.h>
#include <linux/config.h> #include <linux/config.h>
...@@ -91,15 +89,17 @@ extern const struct linux_logo logo_linux_clut224; ...@@ -91,15 +89,17 @@ extern const struct linux_logo logo_linux_clut224;
*/ */
#define PROM_BUG() do { \ #define PROM_BUG() do { \
prom_print(RELOC("kernel BUG at ")); \ prom_printf("kernel BUG at %s line 0x%x!\n", \
prom_print(RELOC(__FILE__)); \ RELOC(__FILE__), __LINE__); \
prom_print(RELOC(":")); \ __asm__ __volatile__(".long " BUG_ILLEGAL_INSTR); \
prom_print_hex(__LINE__); \
prom_print(RELOC("!\n")); \
__asm__ __volatile__(".long " BUG_ILLEGAL_INSTR); \
} while (0) } while (0)
#ifdef DEBUG_PROM
#define prom_debug(x...) prom_printf(x)
#else
#define prom_debug(x...)
#endif
struct pci_reg_property { struct pci_reg_property {
...@@ -178,29 +178,36 @@ struct { ...@@ -178,29 +178,36 @@ struct {
char testString[] = "LINUX\n"; 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 /* 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 * 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. * mode when we do. We switch back to 64b mode upon return.
*/ */
#define PROM_ERROR (0x00000000fffffffful) #define PROM_ERROR (-1)
static unsigned long __init call_prom(const char *service, int nargs, int nret, ...) static int __init call_prom(const char *service, int nargs, int nret, ...)
{ {
int i; int i;
unsigned long offset = reloc_offset(); unsigned long offset = reloc_offset();
struct prom_t *_prom = PTRRELOC(&prom); struct prom_t *_prom = PTRRELOC(&prom);
va_list list; va_list list;
_prom->args.service = (u32)LONG_LSW(service); _prom->args.service = ADDR(service);
_prom->args.nargs = nargs; _prom->args.nargs = nargs;
_prom->args.nret = nret; _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); va_start(list, nret);
for (i=0; i < nargs ;i++) for (i=0; i < nargs; i++)
_prom->args.args[i] = (prom_arg_t)LONG_LSW(va_arg(list, unsigned long)); _prom->args.args[i] = va_arg(list, prom_arg_t);
va_end(list); va_end(list);
for (i=0; i < nret ;i++) for (i=0; i < nret ;i++)
...@@ -208,7 +215,7 @@ static unsigned long __init call_prom(const char *service, int nargs, int nret, ...@@ -208,7 +215,7 @@ static unsigned long __init call_prom(const char *service, int nargs, int nret,
enter_prom(&_prom->args); enter_prom(&_prom->args);
return (unsigned long)((nret > 0) ? _prom->args.rets[0] : 0); return (nret > 0)? _prom->args.rets[0]: 0;
} }
...@@ -225,21 +232,21 @@ static void __init prom_print(const char *msg) ...@@ -225,21 +232,21 @@ static void __init prom_print(const char *msg)
for (q = p; *q != 0 && *q != '\n'; ++q) for (q = p; *q != 0 && *q != '\n'; ++q)
; ;
if (q > p) if (q > p)
call_prom(RELOC("write"), 3, 1, _prom->stdout, call_prom("write", 3, 1, _prom->stdout, p, q - p);
p, q - p); if (*q == 0)
if (*q != 0) { break;
++q; ++q;
call_prom(RELOC("write"), 3, 1, _prom->stdout, call_prom("write", 3, 1, _prom->stdout, ADDR("\r\n"), 2);
RELOC("\r\n"), 2);
}
} }
} }
static void __init prom_print_hex(unsigned long val) static void __init prom_print_hex(unsigned long val)
{ {
unsigned long offset = reloc_offset();
int i, nibbles = sizeof(val)*2; int i, nibbles = sizeof(val)*2;
char buf[sizeof(val)*2+1]; char buf[sizeof(val)*2+1];
struct prom_t *_prom = PTRRELOC(&prom);
for (i = nibbles-1; i >= 0; i--) { for (i = nibbles-1; i >= 0; i--) {
buf[i] = (val & 0xf) + '0'; buf[i] = (val & 0xf) + '0';
...@@ -248,24 +255,58 @@ static void __init prom_print_hex(unsigned long val) ...@@ -248,24 +255,58 @@ static void __init prom_print_hex(unsigned long val)
val >>= 4; val >>= 4;
} }
buf[nibbles] = '\0'; buf[nibbles] = '\0';
prom_print(buf); call_prom("write", 3, 1, _prom->stdout, buf, nibbles);
} }
static void __init prom_print_nl(void) static void __init prom_printf(const char *format, ...)
{ {
unsigned long offset = reloc_offset(); unsigned long offset = reloc_offset();
prom_print(RELOC("\n")); 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;
}
}
} }
static void __init prom_panic(const char *reason) static void __init __attribute__((noreturn)) prom_panic(const char *reason)
{ {
unsigned long offset = reloc_offset(); unsigned long offset = reloc_offset();
prom_print(reason); prom_print(PTRRELOC(reason));
/* ToDo: should put up an SRC here */ /* ToDo: should put up an SRC here */
call_prom(RELOC("exit"), 0, 0); call_prom("exit", 0, 0);
for (;;) /* should never get here */ for (;;) /* should never get here */
; ;
...@@ -275,21 +316,28 @@ static void __init prom_panic(const char *reason) ...@@ -275,21 +316,28 @@ static void __init prom_panic(const char *reason)
static int __init prom_next_node(phandle *nodep) static int __init prom_next_node(phandle *nodep)
{ {
phandle node; phandle node;
unsigned long offset = reloc_offset();
if ((node = *nodep) != 0 if ((node = *nodep) != 0
&& (*nodep = call_prom(RELOC("child"), 1, 1, node)) != 0) && (*nodep = call_prom("child", 1, 1, node)) != 0)
return 1; return 1;
if ((*nodep = call_prom(RELOC("peer"), 1, 1, node)) != 0) if ((*nodep = call_prom("peer", 1, 1, node)) != 0)
return 1; return 1;
for (;;) { for (;;) {
if ((node = call_prom(RELOC("parent"), 1, 1, node)) == 0) if ((node = call_prom("parent", 1, 1, node)) == 0)
return 0; return 0;
if ((*nodep = call_prom(RELOC("peer"), 1, 1, node)) != 0) if ((*nodep = call_prom("peer", 1, 1, node)) != 0)
return 1; 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) static void __init prom_initialize_naca(void)
{ {
...@@ -302,16 +350,13 @@ static void __init prom_initialize_naca(void) ...@@ -302,16 +350,13 @@ static void __init prom_initialize_naca(void)
struct systemcfg *_systemcfg = RELOC(systemcfg); struct systemcfg *_systemcfg = RELOC(systemcfg);
/* NOTE: _naca->debug_switch is already initialized. */ /* NOTE: _naca->debug_switch is already initialized. */
#ifdef DEBUG_PROM prom_debug("prom_initialize_naca: start...\n");
prom_print(RELOC("prom_initialize_naca: start...\n"));
#endif
_naca->pftSize = 0; /* ilog2 of htab size. computed below. */ _naca->pftSize = 0; /* ilog2 of htab size. computed below. */
for (node = 0; prom_next_node(&node); ) { for (node = 0; prom_next_node(&node); ) {
type[0] = 0; type[0] = 0;
call_prom(RELOC("getprop"), 4, 1, node, RELOC("device_type"), prom_getprop(node, "device_type", type, sizeof(type));
type, sizeof(type));
if (!strcmp(type, RELOC("cpu"))) { if (!strcmp(type, RELOC("cpu"))) {
num_cpus += 1; num_cpus += 1;
...@@ -321,37 +366,30 @@ static void __init prom_initialize_naca(void) ...@@ -321,37 +366,30 @@ static void __init prom_initialize_naca(void)
*/ */
if ( num_cpus == 1 ) { if ( num_cpus == 1 ) {
u32 size, lsize; 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";
}
call_prom(RELOC("getprop"), 4, 1, node, prom_getprop(node, "d-cache-size",
RELOC("d-cache-size"), &size, sizeof(size));
&size, sizeof(size));
if (_systemcfg->platform == PLATFORM_POWERMAC) prom_getprop(node, dc, &lsize, sizeof(lsize));
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->dCacheL1Size = size;
_systemcfg->dCacheL1LineSize = lsize; _systemcfg->dCacheL1LineSize = lsize;
_naca->dCacheL1LogLineSize = __ilog2(lsize); _naca->dCacheL1LogLineSize = __ilog2(lsize);
_naca->dCacheL1LinesPerPage = PAGE_SIZE/lsize; _naca->dCacheL1LinesPerPage = PAGE_SIZE/lsize;
call_prom(RELOC("getprop"), 4, 1, node, prom_getprop(node, "i-cache-size",
RELOC("i-cache-size"), &size, sizeof(size));
&size, sizeof(size));
if (_systemcfg->platform == PLATFORM_POWERMAC) prom_getprop(node, ic, &lsize, sizeof(lsize));
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->iCacheL1Size = size;
_systemcfg->iCacheL1LineSize = lsize; _systemcfg->iCacheL1LineSize = lsize;
...@@ -360,9 +398,8 @@ static void __init prom_initialize_naca(void) ...@@ -360,9 +398,8 @@ static void __init prom_initialize_naca(void)
if (_systemcfg->platform == PLATFORM_PSERIES_LPAR) { if (_systemcfg->platform == PLATFORM_PSERIES_LPAR) {
u32 pft_size[2]; u32 pft_size[2];
call_prom(RELOC("getprop"), 4, 1, node, prom_getprop(node, "ibm,pft-size",
RELOC("ibm,pft-size"), &pft_size, sizeof(pft_size));
&pft_size, sizeof(pft_size));
/* pft_size[0] is the NUMA CEC cookie */ /* pft_size[0] is the NUMA CEC cookie */
_naca->pftSize = pft_size[1]; _naca->pftSize = pft_size[1];
} }
...@@ -375,24 +412,21 @@ static void __init prom_initialize_naca(void) ...@@ -375,24 +412,21 @@ static void __init prom_initialize_naca(void)
if (_systemcfg->platform == PLATFORM_POWERMAC) if (_systemcfg->platform == PLATFORM_POWERMAC)
continue; continue;
type[0] = 0; type[0] = 0;
call_prom(RELOC("getprop"), 4, 1, node, prom_getprop(node, "ibm,aix-loc", type, sizeof(type));
RELOC("ibm,aix-loc"), type, sizeof(type));
if (strcmp(type, RELOC("S1"))) if (strcmp(type, RELOC("S1")))
continue; continue;
call_prom(RELOC("getprop"), 4, 1, node, RELOC("reg"), prom_getprop(node, "reg", &reg, sizeof(reg));
&reg, sizeof(reg));
isa = call_prom(RELOC("parent"), 1, 1, node); isa = call_prom("parent", 1, 1, node);
if (!isa) if (!isa)
PROM_BUG(); PROM_BUG();
pci = call_prom(RELOC("parent"), 1, 1, isa); pci = call_prom("parent", 1, 1, isa);
if (!pci) if (!pci)
PROM_BUG(); PROM_BUG();
call_prom(RELOC("getprop"), 4, 1, pci, RELOC("ranges"), prom_getprop(pci, "ranges", &ranges, sizeof(ranges));
&ranges, sizeof(ranges));
if ( _prom->encode_phys_size == 32 ) if ( _prom->encode_phys_size == 32 )
_naca->serialPortAddr = ranges.pci32.phys+reg.address; _naca->serialPortAddr = ranges.pci32.phys+reg.address;
...@@ -410,25 +444,23 @@ static void __init prom_initialize_naca(void) ...@@ -410,25 +444,23 @@ static void __init prom_initialize_naca(void)
_naca->interrupt_controller = IC_INVALID; _naca->interrupt_controller = IC_INVALID;
for (node = 0; prom_next_node(&node); ) { for (node = 0; prom_next_node(&node); ) {
type[0] = 0; type[0] = 0;
call_prom(RELOC("getprop"), 4, 1, node, RELOC("name"), prom_getprop(node, "name", type, sizeof(type));
type, sizeof(type));
if (strcmp(type, RELOC("interrupt-controller"))) if (strcmp(type, RELOC("interrupt-controller")))
continue; continue;
call_prom(RELOC("getprop"), 4, 1, node, RELOC("compatible"), prom_getprop(node, "compatible", type, sizeof(type));
type, sizeof(type));
if (strstr(type, RELOC("open-pic"))) if (strstr(type, RELOC("open-pic")))
_naca->interrupt_controller = IC_OPEN_PIC; _naca->interrupt_controller = IC_OPEN_PIC;
else if (strstr(type, RELOC("ppc-xicp"))) else if (strstr(type, RELOC("ppc-xicp")))
_naca->interrupt_controller = IC_PPC_XIC; _naca->interrupt_controller = IC_PPC_XIC;
else else
prom_print(RELOC("prom: failed to recognize" prom_printf("prom: failed to recognize"
" interrupt-controller\n")); " interrupt-controller\n");
break; break;
} }
} }
if (_naca->interrupt_controller == IC_INVALID) { if (_naca->interrupt_controller == IC_INVALID) {
prom_print(RELOC("prom: failed to find interrupt-controller\n")); prom_printf("prom: failed to find interrupt-controller\n");
PROM_BUG(); PROM_BUG();
} }
...@@ -454,7 +486,7 @@ static void __init prom_initialize_naca(void) ...@@ -454,7 +486,7 @@ static void __init prom_initialize_naca(void)
} }
if (_naca->pftSize == 0) { if (_naca->pftSize == 0) {
prom_print(RELOC("prom: failed to compute pftSize!\n")); prom_printf("prom: failed to compute pftSize!\n");
PROM_BUG(); PROM_BUG();
} }
...@@ -464,41 +496,23 @@ static void __init prom_initialize_naca(void) ...@@ -464,41 +496,23 @@ static void __init prom_initialize_naca(void)
_systemcfg->version.minor = SYSTEMCFG_MINOR; _systemcfg->version.minor = SYSTEMCFG_MINOR;
_systemcfg->processor = _get_PVR(); _systemcfg->processor = _get_PVR();
#ifdef DEBUG_PROM prom_debug("systemcfg->processorCount = 0x%x\n",
prom_print(RELOC("systemcfg->processorCount = 0x")); _systemcfg->processorCount);
prom_print_hex(_systemcfg->processorCount); prom_debug("systemcfg->physicalMemorySize = 0x%x\n",
prom_print_nl(); _systemcfg->physicalMemorySize);
prom_debug("naca->pftSize = 0x%x\n",
prom_print(RELOC("systemcfg->physicalMemorySize = 0x")); _naca->pftSize);
prom_print_hex(_systemcfg->physicalMemorySize); prom_debug("systemcfg->dCacheL1LineSize = 0x%x\n",
prom_print_nl(); _systemcfg->dCacheL1LineSize);
prom_debug("systemcfg->iCacheL1LineSize = 0x%x\n",
prom_print(RELOC("naca->pftSize = 0x")); _systemcfg->iCacheL1LineSize);
prom_print_hex(_naca->pftSize); prom_debug("naca->serialPortAddr = 0x%x\n",
prom_print_nl(); _naca->serialPortAddr);
prom_debug("naca->interrupt_controller = 0x%x\n",
prom_print(RELOC("systemcfg->dCacheL1LineSize = 0x")); _naca->interrupt_controller);
prom_print_hex(_systemcfg->dCacheL1LineSize); prom_debug("systemcfg->platform = 0x%x\n",
prom_print_nl(); _systemcfg->platform);
prom_debug("prom_initialize_naca: end...\n");
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
} }
...@@ -512,9 +526,7 @@ static void __init early_cmdline_parse(void) ...@@ -512,9 +526,7 @@ static void __init early_cmdline_parse(void)
opt = strstr(RELOC(cmd_line), RELOC("iommu=")); opt = strstr(RELOC(cmd_line), RELOC("iommu="));
if (opt) { if (opt) {
prom_print(RELOC("opt is:")); prom_printf("opt is:%s\n", opt);
prom_print(opt);
prom_print(RELOC("\n"));
opt += 6; opt += 6;
while (*opt && *opt == ' ') while (*opt && *opt == ' ')
opt++; opt++;
...@@ -527,7 +539,7 @@ static void __init early_cmdline_parse(void) ...@@ -527,7 +539,7 @@ static void __init early_cmdline_parse(void)
#ifndef CONFIG_PMAC_DART #ifndef CONFIG_PMAC_DART
if (_systemcfg->platform == PLATFORM_POWERMAC) { if (_systemcfg->platform == PLATFORM_POWERMAC) {
RELOC(ppc64_iommu_off) = 1; RELOC(ppc64_iommu_off) = 1;
prom_print(RELOC("DART disabled on PowerMac !\n")); prom_printf("DART disabled on PowerMac !\n");
} }
#endif #endif
} }
...@@ -539,46 +551,31 @@ void prom_dump_lmb(void) ...@@ -539,46 +551,31 @@ void prom_dump_lmb(void)
unsigned long offset = reloc_offset(); unsigned long offset = reloc_offset();
struct lmb *_lmb = PTRRELOC(&lmb); struct lmb *_lmb = PTRRELOC(&lmb);
prom_print(RELOC("\nprom_dump_lmb:\n")); prom_printf("\nprom_dump_lmb:\n");
prom_print(RELOC(" memory.cnt = 0x")); prom_printf(" memory.cnt = 0x%x\n",
prom_print_hex(_lmb->memory.cnt); _lmb->memory.cnt);
prom_print_nl(); prom_printf(" memory.size = 0x%x\n",
prom_print(RELOC(" memory.size = 0x")); _lmb->memory.size);
prom_print_hex(_lmb->memory.size);
prom_print_nl();
for (i=0; i < _lmb->memory.cnt ;i++) { for (i=0; i < _lmb->memory.cnt ;i++) {
prom_print(RELOC(" memory.region[0x")); prom_printf(" memory.region[0x%x].base = 0x%x\n",
prom_print_hex(i); i, _lmb->memory.region[i].base);
prom_print(RELOC("].base = 0x")); prom_printf(" .physbase = 0x%x\n",
prom_print_hex(_lmb->memory.region[i].base); _lmb->memory.region[i].physbase);
prom_print_nl(); prom_printf(" .size = 0x%x\n",
prom_print(RELOC(" .physbase = 0x")); _lmb->memory.region[i].size);
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_printf("\n reserved.cnt = 0x%x\n",
prom_print(RELOC(" reserved.cnt = 0x")); _lmb->reserved.cnt);
prom_print_hex(_lmb->reserved.cnt); prom_printf(" reserved.size = 0x%x\n",
prom_print_nl(); _lmb->reserved.size);
prom_print(RELOC(" reserved.size = 0x"));
prom_print_hex(_lmb->reserved.size);
prom_print_nl();
for (i=0; i < _lmb->reserved.cnt ;i++) { for (i=0; i < _lmb->reserved.cnt ;i++) {
prom_print(RELOC(" reserved.region[0x")); prom_printf(" reserved.region[0x%x\n].base = 0x%x\n",
prom_print_hex(i); i, _lmb->reserved.region[i].base);
prom_print(RELOC("].base = 0x")); prom_printf(" .physbase = 0x%x\n",
prom_print_hex(_lmb->reserved.region[i].base); _lmb->reserved.region[i].physbase);
prom_print_nl(); prom_printf(" .size = 0x%x\n",
prom_print(RELOC(" .physbase = 0x")); _lmb->reserved.region[i].size);
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 */ #endif /* DEBUG_PROM */
...@@ -604,14 +601,13 @@ static void __init prom_initialize_lmb(void) ...@@ -604,14 +601,13 @@ static void __init prom_initialize_lmb(void)
for (node = 0; prom_next_node(&node); ) { for (node = 0; prom_next_node(&node); ) {
type[0] = 0; type[0] = 0;
call_prom(RELOC("getprop"), 4, 1, node, RELOC("device_type"), prom_getprop(node, "device_type", type, sizeof(type));
type, sizeof(type));
if (strcmp(type, RELOC("memory"))) if (strcmp(type, RELOC("memory")))
continue; continue;
num_regs = call_prom(RELOC("getprop"), 4, 1, node, RELOC("reg"), num_regs = prom_getprop(node, "reg", &reg, sizeof(reg))
&reg, sizeof(reg)) / bytes_per_reg; / bytes_per_reg;
for (i=0; i < num_regs ;i++) { for (i=0; i < num_regs ;i++) {
if (_systemcfg->platform == PLATFORM_POWERMAC) { if (_systemcfg->platform == PLATFORM_POWERMAC) {
...@@ -636,7 +632,7 @@ static void __init prom_initialize_lmb(void) ...@@ -636,7 +632,7 @@ static void __init prom_initialize_lmb(void)
} }
if (lmb_add(lmb_base, lmb_size) < 0) if (lmb_add(lmb_base, lmb_size) < 0)
prom_print(RELOC("Too many LMB's, discarding this one...\n")); prom_printf("Too many LMB's, discarding this one...\n");
} }
} }
...@@ -658,30 +654,23 @@ prom_instantiate_rtas(void) ...@@ -658,30 +654,23 @@ prom_instantiate_rtas(void)
u32 getprop_rval; u32 getprop_rval;
char hypertas_funcs[4]; char hypertas_funcs[4];
#ifdef DEBUG_PROM prom_debug("prom_instantiate_rtas: start...\n");
prom_print(RELOC("prom_instantiate_rtas: start...\n"));
#endif prom_rtas = call_prom("finddevice", 1, 1, ADDR("/rtas"));
prom_rtas = (ihandle)call_prom(RELOC("finddevice"), 1, 1, RELOC("/rtas"));
if (prom_rtas != (ihandle) -1) { if (prom_rtas != (ihandle) -1) {
unsigned long x; unsigned long x;
x = call_prom(RELOC("getprop"), x = prom_getprop(prom_rtas, "ibm,hypertas-functions",
4, 1, prom_rtas, hypertas_funcs, sizeof(hypertas_funcs));
RELOC("ibm,hypertas-functions"),
hypertas_funcs,
sizeof(hypertas_funcs));
if (x != PROM_ERROR) { if (x != PROM_ERROR) {
prom_print(RELOC("Hypertas detected, assuming LPAR !\n")); prom_printf("Hypertas detected, assuming LPAR !\n");
_systemcfg->platform = PLATFORM_PSERIES_LPAR; _systemcfg->platform = PLATFORM_PSERIES_LPAR;
} }
call_prom(RELOC("getprop"), prom_getprop(prom_rtas, "rtas-size",
4, 1, prom_rtas, &getprop_rval, sizeof(getprop_rval));
RELOC("rtas-size"),
&getprop_rval,
sizeof(getprop_rval));
_rtas->size = getprop_rval; _rtas->size = getprop_rval;
prom_print(RELOC("instantiating rtas")); prom_printf("instantiating rtas");
if (_rtas->size != 0) { if (_rtas->size != 0) {
unsigned long rtas_region = RTAS_INSTANTIATE_MAX; unsigned long rtas_region = RTAS_INSTANTIATE_MAX;
...@@ -696,17 +685,15 @@ prom_instantiate_rtas(void) ...@@ -696,17 +685,15 @@ prom_instantiate_rtas(void)
_rtas->base = lmb_alloc_base(_rtas->size, PAGE_SIZE, rtas_region); _rtas->base = lmb_alloc_base(_rtas->size, PAGE_SIZE, rtas_region);
prom_print(RELOC(" at 0x")); prom_printf(" at 0x%x", _rtas->base);
prom_print_hex(_rtas->base);
prom_rtas = (ihandle)call_prom(RELOC("open"), prom_rtas = call_prom("open", 1, 1, ADDR("/rtas"));
1, 1, RELOC("/rtas")); prom_printf("...");
prom_print(RELOC("..."));
if (call_prom(RELOC("call-method"), 3, 2, if (call_prom("call-method", 3, 2,
RELOC("instantiate-rtas"), ADDR("instantiate-rtas"),
prom_rtas, prom_rtas,
_rtas->base) != PROM_ERROR) { _rtas->base) != PROM_ERROR) {
_rtas->entry = (long)_prom->args.rets[1]; _rtas->entry = (long)_prom->args.rets[1];
} }
RELOC(rtas_rmo_buf) RELOC(rtas_rmo_buf)
...@@ -715,26 +702,16 @@ prom_instantiate_rtas(void) ...@@ -715,26 +702,16 @@ prom_instantiate_rtas(void)
} }
if (_rtas->entry <= 0) { if (_rtas->entry <= 0) {
prom_print(RELOC(" failed\n")); prom_printf(" failed\n");
} else { } else {
prom_print(RELOC(" done\n")); prom_printf(" done\n");
} }
#ifdef DEBUG_PROM prom_debug("rtas->base = 0x%x\n", _rtas->base);
prom_print(RELOC("rtas->base = 0x")); prom_debug("rtas->entry = 0x%x\n", _rtas->entry);
prom_print_hex(_rtas->base); prom_debug("rtas->size = 0x%x\n", _rtas->size);
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
} }
#ifdef DEBUG_PROM prom_debug("prom_instantiate_rtas: end...\n");
prom_print(RELOC("prom_instantiate_rtas: end...\n"));
#endif
} }
...@@ -759,9 +736,7 @@ static void __init prom_initialize_dart_table(void) ...@@ -759,9 +736,7 @@ static void __init prom_initialize_dart_table(void)
RELOC(dart_tablebase) = (unsigned long) RELOC(dart_tablebase) = (unsigned long)
abs_to_virt(lmb_alloc_base(1UL<<24, 1UL<<24, 0x80000000L)); abs_to_virt(lmb_alloc_base(1UL<<24, 1UL<<24, 0x80000000L));
prom_print(RELOC("Dart at: ")); prom_printf("Dart at: %x\n", RELOC(dart_tablebase));
prom_print_hex(RELOC(dart_tablebase));
prom_print(RELOC("\n"));
} }
#endif /* CONFIG_PMAC_DART */ #endif /* CONFIG_PMAC_DART */
...@@ -780,27 +755,23 @@ static void __init prom_initialize_tce_table(void) ...@@ -780,27 +755,23 @@ static void __init prom_initialize_tce_table(void)
if (RELOC(ppc64_iommu_off)) if (RELOC(ppc64_iommu_off))
return; return;
#ifdef DEBUG_PROM prom_debug("starting prom_initialize_tce_table\n");
prom_print(RELOC("starting prom_initialize_tce_table\n"));
#endif
/* Search all nodes looking for PHBs. */ /* Search all nodes looking for PHBs. */
for (node = 0; prom_next_node(&node); ) { for (node = 0; prom_next_node(&node); ) {
if (table == MAX_PHB) { if (table == MAX_PHB) {
prom_print(RELOC("WARNING: PCI host bridge ignored, " prom_printf("WARNING: PCI host bridge ignored, "
"need to increase MAX_PHB\n")); "need to increase MAX_PHB\n");
continue; continue;
} }
compatible[0] = 0; compatible[0] = 0;
type[0] = 0; type[0] = 0;
model[0] = 0; model[0] = 0;
call_prom(RELOC("getprop"), 4, 1, node, RELOC("compatible"), prom_getprop(node, "compatible",
compatible, sizeof(compatible)); compatible, sizeof(compatible));
call_prom(RELOC("getprop"), 4, 1, node, RELOC("device_type"), prom_getprop(node, "device_type", type, sizeof(type));
type, sizeof(type)); prom_getprop(node, "model", model, sizeof(model));
call_prom(RELOC("getprop"), 4, 1, node, RELOC("model"),
model, sizeof(model));
/* Keep the old logic in tack to avoid regression. */ /* Keep the old logic in tack to avoid regression. */
if (compatible[0] != 0) { if (compatible[0] != 0) {
...@@ -819,15 +790,13 @@ static void __init prom_initialize_tce_table(void) ...@@ -819,15 +790,13 @@ static void __init prom_initialize_tce_table(void)
continue; continue;
} }
if (call_prom(RELOC("getprop"), 4, 1, node, if (prom_getprop(node, "tce-table-minalign", &minalign,
RELOC("tce-table-minalign"), &minalign, sizeof(minalign)) == PROM_ERROR) {
sizeof(minalign)) == PROM_ERROR) {
minalign = 0; minalign = 0;
} }
if (call_prom(RELOC("getprop"), 4, 1, node, if (prom_getprop(node, "tce-table-minsize", &minsize,
RELOC("tce-table-minsize"), &minsize, sizeof(minsize)) == PROM_ERROR) {
sizeof(minsize)) == PROM_ERROR) {
minsize = 4UL << 20; minsize = 4UL << 20;
} }
...@@ -854,7 +823,7 @@ static void __init prom_initialize_tce_table(void) ...@@ -854,7 +823,7 @@ static void __init prom_initialize_tce_table(void)
base = lmb_alloc(minsize, align); base = lmb_alloc(minsize, align);
if ( !base ) { if ( !base ) {
prom_panic(RELOC("ERROR, cannot find space for TCE table.\n")); prom_panic("ERROR, cannot find space for TCE table.\n");
} }
vbase = (unsigned long)abs_to_virt(base); vbase = (unsigned long)abs_to_virt(base);
...@@ -864,23 +833,10 @@ static void __init prom_initialize_tce_table(void) ...@@ -864,23 +833,10 @@ static void __init prom_initialize_tce_table(void)
prom_tce_table[table].base = vbase; prom_tce_table[table].base = vbase;
prom_tce_table[table].size = minsize; prom_tce_table[table].size = minsize;
#ifdef DEBUG_PROM prom_debug("TCE table: 0x%x\n", table);
prom_print(RELOC("TCE table: 0x")); prom_debug("\tnode = 0x%x\n", node);
prom_print_hex(table); prom_debug("\tbase = 0x%x\n", vbase);
prom_print_nl(); prom_debug("\tsize = 0x%x\n", minsize);
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 /* Initialize the table to have a one-to-one mapping
* over the allocated size. * over the allocated size.
...@@ -895,37 +851,30 @@ static void __init prom_initialize_tce_table(void) ...@@ -895,37 +851,30 @@ static void __init prom_initialize_tce_table(void)
/* It seems OF doesn't null-terminate the path :-( */ /* It seems OF doesn't null-terminate the path :-( */
memset(path, 0, sizeof(path)); memset(path, 0, sizeof(path));
/* Call OF to setup the TCE hardware */ /* Call OF to setup the TCE hardware */
if (call_prom(RELOC("package-to-path"), 3, 1, node, if (call_prom("package-to-path", 3, 1, node,
path, sizeof(path)-1) == PROM_ERROR) { path, sizeof(path)-1) == PROM_ERROR) {
prom_print(RELOC("package-to-path failed\n")); prom_printf("package-to-path failed\n");
} else { } else {
prom_print(RELOC("opening PHB ")); prom_printf("opening PHB %s", path);
prom_print(path);
} }
phb_node = (ihandle)call_prom(RELOC("open"), 1, 1, path); phb_node = call_prom("open", 1, 1, path);
if ( (long)phb_node <= 0) { if ( (long)phb_node <= 0) {
prom_print(RELOC("... failed\n")); prom_printf("... failed\n");
} else { } else {
prom_print(RELOC("... done\n")); prom_printf("... done\n");
} }
call_prom(RELOC("call-method"), 6, 0, call_prom("call-method", 6, 0, ADDR("set-64-bit-addressing"),
RELOC("set-64-bit-addressing"), phb_node, -1, minsize,
phb_node, (u32) base, (u32) (base >> 32));
-1, call_prom("close", 1, 0, phb_node);
minsize,
base & 0xffffffff,
(base >> 32) & 0xffffffff);
call_prom(RELOC("close"), 1, 0, phb_node);
table++; table++;
} }
/* Flag the first invalid entry */ /* Flag the first invalid entry */
prom_tce_table[table].node = 0; prom_tce_table[table].node = 0;
#ifdef DEBUG_PROM prom_debug("ending prom_initialize_tce_table\n");
prom_print(RELOC("ending prom_initialize_tce_table\n"));
#endif
} }
/* /*
...@@ -983,13 +932,11 @@ static void __init prom_hold_cpus(unsigned long mem) ...@@ -983,13 +932,11 @@ static void __init prom_hold_cpus(unsigned long mem)
if (_systemcfg->platform == PLATFORM_POWERMAC) { if (_systemcfg->platform == PLATFORM_POWERMAC) {
for (node = 0; prom_next_node(&node); ) { for (node = 0; prom_next_node(&node); ) {
type[0] = 0; type[0] = 0;
call_prom(RELOC("getprop"), 4, 1, node, RELOC("device_type"), prom_getprop(node, "device_type", type, sizeof(type));
type, sizeof(type));
if (strcmp(type, RELOC("cpu")) != 0) if (strcmp(type, RELOC("cpu")) != 0)
continue; continue;
reg = -1; reg = -1;
call_prom(RELOC("getprop"), 4, 1, node, RELOC("reg"), prom_getprop(node, "reg", &reg, sizeof(reg));
&reg, sizeof(reg));
_xPaca[cpuid].xHwProcNum = reg; _xPaca[cpuid].xHwProcNum = reg;
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
...@@ -1007,24 +954,13 @@ static void __init prom_hold_cpus(unsigned long mem) ...@@ -1007,24 +954,13 @@ static void __init prom_hold_cpus(unsigned long mem)
/* Initially, we must have one active CPU. */ /* Initially, we must have one active CPU. */
_systemcfg->processorCount = 1; _systemcfg->processorCount = 1;
#ifdef DEBUG_PROM prom_debug("prom_hold_cpus: start...\n");
prom_print(RELOC("prom_hold_cpus: start...\n")); prom_debug(" 1) spinloop = 0x%x\n", (unsigned long)spinloop);
prom_print(RELOC(" 1) spinloop = 0x")); prom_debug(" 1) *spinloop = 0x%x\n", *spinloop);
prom_print_hex((unsigned long)spinloop); prom_debug(" 1) acknowledge = 0x%x\n",
prom_print_nl(); (unsigned long)acknowledge);
prom_print(RELOC(" 1) *spinloop = 0x")); prom_debug(" 1) *acknowledge = 0x%x\n", *acknowledge);
prom_print_hex(*spinloop); prom_debug(" 1) secondary_hold = 0x%x\n", secondary_hold);
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. * will block when they are awakened from their OF spinloop.
...@@ -1041,36 +977,26 @@ static void __init prom_hold_cpus(unsigned long mem) ...@@ -1041,36 +977,26 @@ static void __init prom_hold_cpus(unsigned long mem)
/* look for cpus */ /* look for cpus */
for (node = 0; prom_next_node(&node); ) { for (node = 0; prom_next_node(&node); ) {
type[0] = 0; type[0] = 0;
call_prom(RELOC("getprop"), 4, 1, node, RELOC("device_type"), prom_getprop(node, "device_type", type, sizeof(type));
type, sizeof(type));
if (strcmp(type, RELOC("cpu")) != 0) if (strcmp(type, RELOC("cpu")) != 0)
continue; continue;
/* Skip non-configured cpus. */ /* Skip non-configured cpus. */
call_prom(RELOC("getprop"), 4, 1, node, RELOC("status"), prom_getprop(node, "status", type, sizeof(type));
type, sizeof(type));
if (strcmp(type, RELOC("okay")) != 0) if (strcmp(type, RELOC("okay")) != 0)
continue; continue;
reg = -1; reg = -1;
call_prom(RELOC("getprop"), 4, 1, node, RELOC("reg"), prom_getprop(node, "reg", &reg, sizeof(reg));
&reg, sizeof(reg));
path = (char *) mem; path = (char *) mem;
memset(path, 0, 256); memset(path, 0, 256);
if ((long) call_prom(RELOC("package-to-path"), 3, 1, if (call_prom("package-to-path", 3, 1,
node, path, 255) == PROM_ERROR) node, path, 255) == PROM_ERROR)
continue; continue;
#ifdef DEBUG_PROM prom_debug("\ncpuid = 0x%x\n", cpuid);
prom_print_nl(); prom_debug("cpu hw idx = 0x%x\n", reg);
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; _xPaca[cpuid].xHwProcNum = reg;
/* Init the acknowledge var which will be reset by /* Init the acknowledge var which will be reset by
...@@ -1079,10 +1005,9 @@ static void __init prom_hold_cpus(unsigned long mem) ...@@ -1079,10 +1005,9 @@ static void __init prom_hold_cpus(unsigned long mem)
*/ */
*acknowledge = (unsigned long)-1; *acknowledge = (unsigned long)-1;
propsize = call_prom(RELOC("getprop"), 4, 1, node, propsize = prom_getprop(node, "ibm,ppc-interrupt-server#s",
RELOC("ibm,ppc-interrupt-server#s"), &interrupt_server,
&interrupt_server, sizeof(interrupt_server));
sizeof(interrupt_server));
if (propsize < 0) { if (propsize < 0) {
/* no property. old hardware has no SMT */ /* no property. old hardware has no SMT */
cpu_threads = 1; cpu_threads = 1;
...@@ -1091,11 +1016,9 @@ static void __init prom_hold_cpus(unsigned long mem) ...@@ -1091,11 +1016,9 @@ static void __init prom_hold_cpus(unsigned long mem)
/* We have a threaded processor */ /* We have a threaded processor */
cpu_threads = propsize / sizeof(u32); cpu_threads = propsize / sizeof(u32);
if (cpu_threads > MAX_CPU_THREADS) { if (cpu_threads > MAX_CPU_THREADS) {
prom_print(RELOC("SMT: too many threads!\nSMT: found ")); prom_printf("SMT: too many threads!\n"
prom_print_hex(cpu_threads); "SMT: found %x, max is %x\n",
prom_print(RELOC(", max is ")); cpu_threads, MAX_CPU_THREADS);
prom_print_hex(MAX_CPU_THREADS);
prom_print_nl();
cpu_threads = 1; /* ToDo: panic? */ cpu_threads = 1; /* ToDo: panic? */
} }
} }
...@@ -1103,18 +1026,15 @@ static void __init prom_hold_cpus(unsigned long mem) ...@@ -1103,18 +1026,15 @@ static void __init prom_hold_cpus(unsigned long mem)
hw_cpu_num = interrupt_server[0]; hw_cpu_num = interrupt_server[0];
if (hw_cpu_num != _prom->cpu) { if (hw_cpu_num != _prom->cpu) {
/* Primary Thread of non-boot cpu */ /* Primary Thread of non-boot cpu */
prom_print_hex(cpuid); prom_printf("%x : starting cpu %s... ", cpuid, path);
prom_print(RELOC(" : starting cpu ")); call_prom("start-cpu", 3, 0, node,
prom_print(path);
prom_print(RELOC("... "));
call_prom(RELOC("start-cpu"), 3, 0, node,
secondary_hold, cpuid); secondary_hold, cpuid);
for ( i = 0 ; (i < 100000000) && for ( i = 0 ; (i < 100000000) &&
(*acknowledge == ((unsigned long)-1)); i++ ) ; (*acknowledge == ((unsigned long)-1)); i++ ) ;
if (*acknowledge == cpuid) { if (*acknowledge == cpuid) {
prom_print(RELOC("... done\n")); prom_printf("... done\n");
/* We have to get every CPU out of OF, /* We have to get every CPU out of OF,
* even if we never start it. */ * even if we never start it. */
if (cpuid >= NR_CPUS) if (cpuid >= NR_CPUS)
...@@ -1127,17 +1047,12 @@ static void __init prom_hold_cpus(unsigned long mem) ...@@ -1127,17 +1047,12 @@ static void __init prom_hold_cpus(unsigned long mem)
cpu_set(cpuid, RELOC(cpu_present_at_boot)); cpu_set(cpuid, RELOC(cpu_present_at_boot));
#endif #endif
} else { } else {
prom_print(RELOC("... failed: ")); prom_printf("... failed: %x\n", *acknowledge);
prom_print_hex(*acknowledge);
prom_print_nl();
} }
} }
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
else { else {
prom_print_hex(cpuid); prom_printf("%x : booting cpu %s\n", cpuid, path);
prom_print(RELOC(" : booting cpu "));
prom_print(path);
prom_print_nl();
cpu_set(cpuid, RELOC(cpu_available_map)); cpu_set(cpuid, RELOC(cpu_available_map));
cpu_set(cpuid, RELOC(cpu_possible_map)); cpu_set(cpuid, RELOC(cpu_possible_map));
cpu_set(cpuid, RELOC(cpu_online_map)); cpu_set(cpuid, RELOC(cpu_online_map));
...@@ -1152,16 +1067,15 @@ static void __init prom_hold_cpus(unsigned long mem) ...@@ -1152,16 +1067,15 @@ static void __init prom_hold_cpus(unsigned long mem)
if (cpuid >= NR_CPUS) if (cpuid >= NR_CPUS)
continue; continue;
_xPaca[cpuid].xHwProcNum = interrupt_server[i]; _xPaca[cpuid].xHwProcNum = interrupt_server[i];
prom_print_hex(interrupt_server[i]); prom_printf("%x : preparing thread ... ",
prom_print(RELOC(" : preparing thread ... ")); interrupt_server[i]);
if (_naca->smt_state) { if (_naca->smt_state) {
cpu_set(cpuid, RELOC(cpu_available_map)); cpu_set(cpuid, RELOC(cpu_available_map));
cpu_set(cpuid, RELOC(cpu_present_at_boot)); cpu_set(cpuid, RELOC(cpu_present_at_boot));
prom_print(RELOC("available")); prom_printf("available\n");
} else { } else {
prom_print(RELOC("not available")); prom_printf("not available\n");
} }
prom_print_nl();
} }
#endif #endif
cpuid++; cpuid++;
...@@ -1171,7 +1085,7 @@ static void __init prom_hold_cpus(unsigned long mem) ...@@ -1171,7 +1085,7 @@ static void __init prom_hold_cpus(unsigned long mem)
if (__is_processor(PV_PULSAR) || if (__is_processor(PV_PULSAR) ||
__is_processor(PV_ICESTAR) || __is_processor(PV_ICESTAR) ||
__is_processor(PV_SSTAR)) { __is_processor(PV_SSTAR)) {
prom_print(RELOC(" starting secondary threads\n")); prom_printf(" starting secondary threads\n");
for (i = 0; i < NR_CPUS; i += 2) { for (i = 0; i < NR_CPUS; i += 2) {
if (!cpu_online(i)) if (!cpu_online(i))
...@@ -1192,24 +1106,22 @@ static void __init prom_hold_cpus(unsigned long mem) ...@@ -1192,24 +1106,22 @@ static void __init prom_hold_cpus(unsigned long mem)
} }
_systemcfg->processorCount *= 2; _systemcfg->processorCount *= 2;
} else { } else {
prom_print(RELOC("Processor is not HMT capable\n")); prom_printf("Processor is not HMT capable\n");
} }
#endif #endif
if (cpuid >= NR_CPUS) if (cpuid > NR_CPUS)
prom_print(RELOC("WARNING: maximum CPUs (" __stringify(NR_CPUS) prom_printf("WARNING: maximum CPUs (" __stringify(NR_CPUS)
") exceeded: ignoring extras\n")); ") exceeded: ignoring extras\n");
#ifdef DEBUG_PROM prom_debug("prom_hold_cpus: end...\n");
prom_print(RELOC("prom_hold_cpus: end...\n"));
#endif
} }
static void __init smt_setup(void) static void __init smt_setup(void)
{ {
char *p, *q; char *p, *q;
char my_smt_enabled = SMT_DYNAMIC; char my_smt_enabled = SMT_DYNAMIC;
ihandle prom_options = NULL; ihandle prom_options = 0;
char option[9]; char option[9];
unsigned long offset = reloc_offset(); unsigned long offset = reloc_offset();
struct naca_struct *_naca = RELOC(naca); struct naca_struct *_naca = RELOC(naca);
...@@ -1233,13 +1145,10 @@ static void __init smt_setup(void) ...@@ -1233,13 +1145,10 @@ static void __init smt_setup(void)
} }
} }
if (!found) { if (!found) {
prom_options = (ihandle)call_prom(RELOC("finddevice"), 1, 1, RELOC("/options")); prom_options = call_prom("finddevice", 1, 1, ADDR("/options"));
if (prom_options != (ihandle) -1) { if (prom_options != (ihandle) -1) {
call_prom(RELOC("getprop"), prom_getprop(prom_options, "ibm,smt-enabled",
4, 1, prom_options, option, sizeof(option));
RELOC("ibm,smt-enabled"),
option,
sizeof(option));
if (option[0] != 0) { if (option[0] != 0) {
found = 1; found = 1;
if (!strcmp(option, RELOC("off"))) if (!strcmp(option, RELOC("off")))
...@@ -1272,43 +1181,29 @@ static void __init setup_disp_fake_bi(ihandle dp) ...@@ -1272,43 +1181,29 @@ static void __init setup_disp_fake_bi(ihandle dp)
int i, naddrs; int i, naddrs;
char name[64]; char name[64];
unsigned long offset = reloc_offset(); unsigned long offset = reloc_offset();
char *getprop = RELOC("getprop");
prom_print(RELOC("Initializing fake screen: "));
memset(name, 0, sizeof(name)); memset(name, 0, sizeof(name));
call_prom(getprop, 4, 1, dp, RELOC("name"), name, sizeof(name)); prom_getprop(dp, "name", name, sizeof(name));
name[sizeof(name)-1] = 0; name[sizeof(name)-1] = 0;
prom_print(name); prom_printf("Initializing fake screen: %s\n", name);
prom_print(RELOC("\n"));
call_prom(getprop, 4, 1, dp, RELOC("width"), &width, sizeof(width)); prom_getprop(dp, "width", &width, sizeof(width));
call_prom(getprop, 4, 1, dp, RELOC("height"), &height, sizeof(height)); prom_getprop(dp, "height", &height, sizeof(height));
call_prom(getprop, 4, 1, dp, RELOC("depth"), &depth, sizeof(depth)); prom_getprop(dp, "depth", &depth, sizeof(depth));
pitch = width * ((depth + 7) / 8); pitch = width * ((depth + 7) / 8);
call_prom(getprop, 4, 1, dp, RELOC("linebytes"), prom_getprop(dp, "linebytes", &pitch, sizeof(pitch));
&pitch, sizeof(pitch));
if (pitch == 1) if (pitch == 1)
pitch = 0x1000; /* for strange IBM display */ pitch = 0x1000; /* for strange IBM display */
address = 0; address = 0;
prom_print(RELOC("width ")); prom_printf("width %x height %x depth %x linebytes %x\n",
prom_print_hex(width); width, height, depth, depth);
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"));
call_prom(getprop, 4, 1, dp, RELOC("address"), prom_getprop(dp, "address", &address, sizeof(address));
&address, sizeof(address));
if (address == 0) { if (address == 0) {
/* look for an assigned address with a size of >= 1MB */ /* look for an assigned address with a size of >= 1MB */
naddrs = (int) call_prom(getprop, 4, 1, dp, naddrs = prom_getprop(dp, "assigned-addresses",
RELOC("assigned-addresses"), addrs, sizeof(addrs));
addrs, sizeof(addrs));
naddrs /= sizeof(struct pci_reg_property); naddrs /= sizeof(struct pci_reg_property);
for (i = 0; i < naddrs; ++i) { for (i = 0; i < naddrs; ++i) {
if (addrs[i].size_lo >= (1 << 20)) { if (addrs[i].size_lo >= (1 << 20)) {
...@@ -1320,14 +1215,12 @@ static void __init setup_disp_fake_bi(ihandle dp) ...@@ -1320,14 +1215,12 @@ static void __init setup_disp_fake_bi(ihandle dp)
} }
} }
if (address == 0) { if (address == 0) {
prom_print(RELOC("Failed to get address of frame buffer\n")); prom_printf("Failed to get address of frame buffer\n");
return; return;
} }
} }
btext_setup_display(width, height, depth, pitch, address); btext_setup_display(width, height, depth, pitch, address);
prom_print(RELOC("Addr of fb: ")); prom_printf("Addr of fb: %x\n", address);
prom_print_hex(address);
prom_print_nl();
RELOC(boot_text_mapped) = 0; RELOC(boot_text_mapped) = 0;
} }
#endif /* CONFIG_BOOTX_TEXT */ #endif /* CONFIG_BOOTX_TEXT */
...@@ -1344,15 +1237,14 @@ static void __init prom_init_client_services(unsigned long pp) ...@@ -1344,15 +1237,14 @@ static void __init prom_init_client_services(unsigned long pp)
_prom->encode_phys_size = 32; _prom->encode_phys_size = 32;
/* get a handle for the stdout device */ /* get a handle for the stdout device */
_prom->chosen = (ihandle)call_prom(RELOC("finddevice"), 1, 1, _prom->chosen = call_prom("finddevice", 1, 1, ADDR("/chosen"));
RELOC("/chosen"));
if ((long)_prom->chosen <= 0) if ((long)_prom->chosen <= 0)
prom_panic(RELOC("cannot find chosen")); /* msg won't be printed :( */ prom_panic("cannot find chosen"); /* msg won't be printed :( */
/* get device tree root */ /* get device tree root */
_prom->root = (ihandle)call_prom(RELOC("finddevice"), 1, 1, RELOC("/")); _prom->root = call_prom("finddevice", 1, 1, ADDR("/"));
if ((long)_prom->root <= 0) if ((long)_prom->root <= 0)
prom_panic(RELOC("cannot find device tree root")); /* msg won't be printed :( */ prom_panic("cannot find device tree root"); /* msg won't be printed :( */
} }
static void __init prom_init_stdout(void) static void __init prom_init_stdout(void)
...@@ -1361,12 +1253,10 @@ static void __init prom_init_stdout(void) ...@@ -1361,12 +1253,10 @@ static void __init prom_init_stdout(void)
struct prom_t *_prom = PTRRELOC(&prom); struct prom_t *_prom = PTRRELOC(&prom);
u32 val; u32 val;
if ((long)call_prom(RELOC("getprop"), 4, 1, _prom->chosen, if (prom_getprop(_prom->chosen, "stdout", &val, sizeof(val)) <= 0)
RELOC("stdout"), &val, prom_panic("cannot find stdout");
sizeof(val)) <= 0)
prom_panic(RELOC("cannot find stdout"));
_prom->stdout = (ihandle)(unsigned long)val; _prom->stdout = val;
} }
static int __init prom_find_machine_type(void) static int __init prom_find_machine_type(void)
...@@ -1376,9 +1266,8 @@ static int __init prom_find_machine_type(void) ...@@ -1376,9 +1266,8 @@ static int __init prom_find_machine_type(void)
char compat[256]; char compat[256];
int len, i = 0; int len, i = 0;
len = (int)(long)call_prom(RELOC("getprop"), 4, 1, _prom->root, len = prom_getprop(_prom->root, "compatible",
RELOC("compatible"), compat, sizeof(compat)-1);
compat, sizeof(compat)-1);
if (len > 0) { if (len > 0) {
compat[len] = 0; compat[len] = 0;
while (i < len) { while (i < len) {
...@@ -1400,13 +1289,7 @@ static int __init prom_set_color(ihandle ih, int i, int r, int g, int b) ...@@ -1400,13 +1289,7 @@ static int __init prom_set_color(ihandle ih, int i, int r, int g, int b)
{ {
unsigned long offset = reloc_offset(); unsigned long offset = reloc_offset();
return (int)(long)call_prom(RELOC("call-method"), 6, 1, return call_prom("call-method", 6, 1, ADDR("color!"), ih, i, b, g, r);
RELOC("color!"),
ih,
(void *)(long) i,
(void *)(long) b,
(void *)(long) g,
(void *)(long) r );
} }
/* /*
...@@ -1447,16 +1330,13 @@ static unsigned long __init check_display(unsigned long mem) ...@@ -1447,16 +1330,13 @@ static unsigned long __init check_display(unsigned long mem)
_prom->disp_node = 0; _prom->disp_node = 0;
prom_print(RELOC("Looking for displays\n")); prom_printf("Looking for displays\n");
if (RELOC(of_stdout_device) != 0) { if (RELOC(of_stdout_device) != 0)
prom_print(RELOC("OF stdout is : ")); prom_printf("OF stdout is : %s\n",
prom_print(PTRRELOC(RELOC(of_stdout_device))); PTRRELOC(RELOC(of_stdout_device)));
prom_print(RELOC("\n"));
}
for (node = 0; prom_next_node(&node); ) { for (node = 0; prom_next_node(&node); ) {
type[0] = 0; type[0] = 0;
call_prom(RELOC("getprop"), 4, 1, node, RELOC("device_type"), prom_getprop(node, "device_type", type, sizeof(type));
type, sizeof(type));
if (strcmp(type, RELOC("display")) != 0) if (strcmp(type, RELOC("display")) != 0)
continue; continue;
/* It seems OF doesn't null-terminate the path :-( */ /* It seems OF doesn't null-terminate the path :-( */
...@@ -1467,12 +1347,9 @@ static unsigned long __init check_display(unsigned long mem) ...@@ -1467,12 +1347,9 @@ static unsigned long __init check_display(unsigned long mem)
* leave some room at the end of the path for appending extra * leave some room at the end of the path for appending extra
* arguments * arguments
*/ */
if ((long) call_prom(RELOC("package-to-path"), 3, 1, if (call_prom("package-to-path", 3, 1, node, path, 250) < 0)
node, path, 250) < 0)
continue; continue;
prom_print(RELOC("found display : ")); prom_printf("found display : %s\n", path);
prom_print(path);
prom_print(RELOC("\n"));
/* /*
* If this display is the device that OF is using for stdout, * If this display is the device that OF is using for stdout,
...@@ -1489,27 +1366,26 @@ static unsigned long __init check_display(unsigned long mem) ...@@ -1489,27 +1366,26 @@ static unsigned long __init check_display(unsigned long mem)
RELOC(prom_display_nodes[i]) RELOC(prom_display_nodes[i])
= RELOC(prom_display_nodes[i-1]); = RELOC(prom_display_nodes[i-1]);
} }
_prom->disp_node = (ihandle)(unsigned long)node; _prom->disp_node = node;
} }
RELOC(prom_display_paths[i]) = PTRUNRELOC(path); RELOC(prom_display_paths[i]) = PTRUNRELOC(path);
RELOC(prom_display_nodes[i]) = node; RELOC(prom_display_nodes[i]) = node;
if (_prom->disp_node == 0) if (_prom->disp_node == 0)
_prom->disp_node = (ihandle)(unsigned long)node; _prom->disp_node = node;
if (RELOC(prom_num_displays) >= FB_MAX) if (RELOC(prom_num_displays) >= FB_MAX)
break; break;
} }
prom_print(RELOC("Opening displays...\n")); prom_printf("Opening displays...\n");
for (j = RELOC(prom_num_displays) - 1; j >= 0; j--) { for (j = RELOC(prom_num_displays) - 1; j >= 0; j--) {
path = PTRRELOC(RELOC(prom_display_paths[j])); path = PTRRELOC(RELOC(prom_display_paths[j]));
prom_print(RELOC("opening display : ")); prom_printf("opening display : %s", path);
prom_print(path); ih = call_prom("open", 1, 1, path);
ih = (ihandle)call_prom(RELOC("open"), 1, 1, path);
if (ih == (ihandle)0 || ih == (ihandle)-1) { if (ih == (ihandle)0 || ih == (ihandle)-1) {
prom_print(RELOC("... failed\n")); prom_printf("... failed\n");
continue; continue;
} }
prom_print(RELOC("... done\n")); prom_printf("... done\n");
/* Setup a useable color table when the appropriate /* Setup a useable color table when the appropriate
* method is available. Should update this to set-colors */ * method is available. Should update this to set-colors */
...@@ -1546,9 +1422,9 @@ static void __init *__make_room(unsigned long *mem_start, unsigned long *mem_end ...@@ -1546,9 +1422,9 @@ static void __init *__make_room(unsigned long *mem_start, unsigned long *mem_end
unsigned long initrd_len; unsigned long initrd_len;
if (*mem_end != RELOC(initrd_start)) if (*mem_end != RELOC(initrd_start))
prom_panic(RELOC("No memory for copy_device_tree")); prom_panic("No memory for copy_device_tree");
prom_print(RELOC("Huge device_tree: moving initrd\n")); prom_printf("Huge device_tree: moving initrd\n");
/* Move by 4M. */ /* Move by 4M. */
initrd_len = RELOC(initrd_end) - RELOC(initrd_start); initrd_len = RELOC(initrd_end) - RELOC(initrd_start);
*mem_end = RELOC(initrd_start) + 4 * 1024 * 1024; *mem_end = RELOC(initrd_start) + 4 * 1024 * 1024;
...@@ -1557,7 +1433,7 @@ static void __init *__make_room(unsigned long *mem_start, unsigned long *mem_end ...@@ -1557,7 +1433,7 @@ static void __init *__make_room(unsigned long *mem_start, unsigned long *mem_end
RELOC(initrd_start) = *mem_end; RELOC(initrd_start) = *mem_end;
RELOC(initrd_end) = RELOC(initrd_start) + initrd_len; RELOC(initrd_end) = RELOC(initrd_start) + initrd_len;
#else #else
prom_panic(RELOC("No memory for copy_device_tree")); prom_panic("No memory for copy_device_tree");
#endif #endif
} }
...@@ -1606,8 +1482,7 @@ inspect_node(phandle node, struct device_node *dad, ...@@ -1606,8 +1482,7 @@ inspect_node(phandle node, struct device_node *dad,
for (;;) { for (;;) {
/* 32 is max len of name including nul. */ /* 32 is max len of name including nul. */
namep = make_room(mem_start, mem_end, char[32]); namep = make_room(mem_start, mem_end, char[32]);
if ((long) call_prom(RELOC("nextprop"), 3, 1, node, prev_name, if (call_prom("nextprop", 3, 1, node, prev_name, namep) <= 0) {
namep) <= 0) {
/* No more nodes: unwind alloc */ /* No more nodes: unwind alloc */
*mem_start = (unsigned long)namep; *mem_start = (unsigned long)namep;
break; break;
...@@ -1619,28 +1494,24 @@ inspect_node(phandle node, struct device_node *dad, ...@@ -1619,28 +1494,24 @@ inspect_node(phandle node, struct device_node *dad,
pp->name = PTRUNRELOC(namep); pp->name = PTRUNRELOC(namep);
prev_name = namep; prev_name = namep;
pp->length = call_prom(RELOC("getproplen"), 2, 1, node, namep); pp->length = call_prom("getproplen", 2, 1, node, namep);
if (pp->length < 0) if (pp->length < 0)
continue; continue;
if (pp->length > MAX_PROPERTY_LENGTH) { if (pp->length > MAX_PROPERTY_LENGTH) {
char path[128]; char path[128];
prom_print(RELOC("WARNING: ignoring large property ")); prom_printf("WARNING: ignoring large property ");
/* It seems OF doesn't null-terminate the path :-( */ /* It seems OF doesn't null-terminate the path :-( */
memset(path, 0, sizeof(path)); memset(path, 0, sizeof(path));
if (call_prom(RELOC("package-to-path"), 3, 1, node, if (call_prom("package-to-path", 3, 1, node,
path, sizeof(path)-1) > 0) path, sizeof(path)-1) > 0)
prom_print(path); prom_printf("[%s] ", path);
prom_print(namep); prom_printf("%s length 0x%x\n", namep, pp->length);
prom_print(RELOC(" length 0x"));
prom_print_hex(pp->length);
prom_print_nl();
continue; continue;
} }
valp = __make_room(mem_start, mem_end, pp->length, 1); valp = __make_room(mem_start, mem_end, pp->length, 1);
pp->value = PTRUNRELOC(valp); pp->value = PTRUNRELOC(valp);
call_prom(RELOC("getprop"), 4, 1, node, namep,valp,pp->length); call_prom("getprop", 4, 1, node, namep, valp, pp->length);
*prev_propp = PTRUNRELOC(pp); *prev_propp = PTRUNRELOC(pp);
prev_propp = &pp->next; prev_propp = &pp->next;
} }
...@@ -1660,19 +1531,19 @@ inspect_node(phandle node, struct device_node *dad, ...@@ -1660,19 +1531,19 @@ inspect_node(phandle node, struct device_node *dad,
/* Set np->linux_phandle to the value of the ibm,phandle property /* Set np->linux_phandle to the value of the ibm,phandle property
if it exists, otherwise to the phandle for this node. */ if it exists, otherwise to the phandle for this node. */
np->linux_phandle = node; np->linux_phandle = node;
if ((int)call_prom(RELOC("getprop"), 4, 1, node, RELOC("ibm,phandle"), if (prom_getprop(node, "ibm,phandle",
&ibm_phandle, sizeof(ibm_phandle)) > 0) &ibm_phandle, sizeof(ibm_phandle)) > 0)
np->linux_phandle = ibm_phandle; np->linux_phandle = ibm_phandle;
/* get the node's full name */ /* get the node's full name */
namep = (char *)*mem_start; namep = (char *)*mem_start;
l = (long) call_prom(RELOC("package-to-path"), 3, 1, node, l = call_prom("package-to-path", 3, 1, node,
namep, *mem_end - *mem_start); namep, *mem_end - *mem_start);
if (l >= 0) { if (l >= 0) {
/* Didn't fit? Get more room. */ /* Didn't fit? Get more room. */
if (l+1 > *mem_end - *mem_start) { if (l+1 > *mem_end - *mem_start) {
namep = __make_room(mem_start, mem_end, l+1, 1); namep = __make_room(mem_start, mem_end, l+1, 1);
call_prom(RELOC("package-to-path"),3,1,node,namep,l); call_prom("package-to-path", 3, 1, node, namep, l);
} }
np->full_name = PTRUNRELOC(namep); np->full_name = PTRUNRELOC(namep);
namep[l] = '\0'; namep[l] = '\0';
...@@ -1680,11 +1551,11 @@ inspect_node(phandle node, struct device_node *dad, ...@@ -1680,11 +1551,11 @@ inspect_node(phandle node, struct device_node *dad,
} }
/* do all our children */ /* do all our children */
child = call_prom(RELOC("child"), 1, 1, node); child = call_prom("child", 1, 1, node);
while (child != (phandle)0) { while (child != (phandle)0) {
inspect_node(child, np, mem_start, mem_end, inspect_node(child, np, mem_start, mem_end,
allnextpp); allnextpp);
child = call_prom(RELOC("peer"), 1, 1, child); child = call_prom("peer", 1, 1, child);
} }
} }
...@@ -1706,9 +1577,9 @@ copy_device_tree(unsigned long mem_start) ...@@ -1706,9 +1577,9 @@ copy_device_tree(unsigned long mem_start)
mem_end = RELOC(initrd_start); mem_end = RELOC(initrd_start);
#endif /* CONFIG_BLK_DEV_INITRD */ #endif /* CONFIG_BLK_DEV_INITRD */
root = call_prom(RELOC("peer"), 1, 1, (phandle)0); root = call_prom("peer", 1, 1, (phandle)0);
if (root == (phandle)0) { if (root == (phandle)0) {
prom_panic(RELOC("couldn't get device tree root\n")); prom_panic("couldn't get device tree root\n");
} }
allnextp = &RELOC(allnodes); allnextp = &RELOC(allnodes);
inspect_node(root, 0, &mem_start, &mem_end, &allnextp); inspect_node(root, 0, &mem_start, &mem_end, &allnextp);
...@@ -1720,44 +1591,25 @@ copy_device_tree(unsigned long mem_start) ...@@ -1720,44 +1591,25 @@ copy_device_tree(unsigned long mem_start)
static struct bi_record * __init prom_bi_rec_verify(struct bi_record *bi_recs) static struct bi_record * __init prom_bi_rec_verify(struct bi_record *bi_recs)
{ {
struct bi_record *first, *last; struct bi_record *first, *last;
#ifdef DEBUG_PROM
unsigned long offset = reloc_offset();
prom_print(RELOC("birec_verify: r6=0x")); prom_debug("birec_verify: r6=0x%x\n", (unsigned long)bi_recs);
prom_print_hex((unsigned long)bi_recs); if (bi_recs != NULL)
prom_print_nl(); prom_debug(" tag=0x%x\n", bi_recs->tag);
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 ) if ( bi_recs == NULL || bi_recs->tag != BI_FIRST )
return NULL; return NULL;
last = (struct bi_record *)(long)bi_recs->data[0]; last = (struct bi_record *)(long)bi_recs->data[0];
#ifdef DEBUG_PROM prom_debug(" last=0x%x\n", (unsigned long)last);
prom_print(RELOC(" last=0x")); if (last != NULL)
prom_print_hex((unsigned long)last); prom_debug(" last_tag=0x%x\n", last->tag);
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 ) if ( last == NULL || last->tag != BI_LAST )
return NULL; return NULL;
first = (struct bi_record *)(long)last->data[0]; first = (struct bi_record *)(long)last->data[0];
#ifdef DEBUG_PROM prom_debug(" first=0x%x\n", (unsigned long)first);
prom_print(RELOC(" first=0x"));
prom_print_hex((unsigned long)first);
prom_print_nl();
#endif /* DEBUG_PROM */
if ( first == NULL || first != bi_recs ) if ( first == NULL || first != bi_recs )
return NULL; return NULL;
...@@ -1776,11 +1628,7 @@ static void __init prom_bi_rec_reserve(void) ...@@ -1776,11 +1628,7 @@ static void __init prom_bi_rec_reserve(void)
for ( rec=_prom->bi_recs; for ( rec=_prom->bi_recs;
rec->tag != BI_LAST; rec->tag != BI_LAST;
rec=bi_rec_next(rec) ) { rec=bi_rec_next(rec) ) {
#ifdef DEBUG_PROM prom_debug("bi: 0x%x\n", rec->tag);
prom_print(RELOC("bi: 0x"));
prom_print_hex(rec->tag);
prom_print_nl();
#endif /* DEBUG_PROM */
switch (rec->tag) { switch (rec->tag) {
#ifdef CONFIG_BLK_DEV_INITRD #ifdef CONFIG_BLK_DEV_INITRD
case BI_INITRD: case BI_INITRD:
...@@ -1833,31 +1681,17 @@ prom_init(unsigned long r3, unsigned long r4, unsigned long pp, ...@@ -1833,31 +1681,17 @@ prom_init(unsigned long r3, unsigned long r4, unsigned long pp,
/* Init prom stdout device */ /* Init prom stdout device */
prom_init_stdout(); prom_init_stdout();
#ifdef DEBUG_PROM prom_debug("klimit=0x%x\n", RELOC(klimit));
prom_print(RELOC("klimit=0x")); prom_debug("offset=0x%x\n", offset);
prom_print_hex(RELOC(klimit)); prom_debug("->mem=0x%x\n", RELOC(klimit) - offset);
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 */ /* check out if we have bi_recs */
_prom->bi_recs = prom_bi_rec_verify((struct bi_record *)r6); _prom->bi_recs = prom_bi_rec_verify((struct bi_record *)r6);
if ( _prom->bi_recs != NULL ) { if ( _prom->bi_recs != NULL ) {
RELOC(klimit) = PTRUNRELOC((unsigned long)_prom->bi_recs + RELOC(klimit) = PTRUNRELOC((unsigned long)_prom->bi_recs +
_prom->bi_recs->data[1]); _prom->bi_recs->data[1]);
#ifdef DEBUG_PROM prom_debug("bi_recs=0x%x\n", (unsigned long)_prom->bi_recs);
prom_print(RELOC("bi_recs=0x")); prom_debug("new mem=0x%x\n", RELOC(klimit) - offset);
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 /* If we don't have birec's or didn't find them, check for an initrd
...@@ -1884,57 +1718,46 @@ prom_init(unsigned long r3, unsigned long r4, unsigned long pp, ...@@ -1884,57 +1718,46 @@ prom_init(unsigned long r3, unsigned long r4, unsigned long pp,
/* Get the full OF pathname of the stdout device */ /* Get the full OF pathname of the stdout device */
p = (char *) mem; p = (char *) mem;
memset(p, 0, 256); memset(p, 0, 256);
call_prom(RELOC("instance-to-path"), 3, 1, _prom->stdout, p, 255); call_prom("instance-to-path", 3, 1, _prom->stdout, p, 255);
RELOC(of_stdout_device) = PTRUNRELOC(p); RELOC(of_stdout_device) = PTRUNRELOC(p);
mem += strlen(p) + 1; mem += strlen(p) + 1;
getprop_rval = 1; getprop_rval = 1;
call_prom(RELOC("getprop"), 4, 1, prom_getprop(_prom->root, "#size-cells",
_prom->root, RELOC("#size-cells"), &getprop_rval, sizeof(getprop_rval));
&getprop_rval, sizeof(getprop_rval));
_prom->encode_phys_size = (getprop_rval == 1) ? 32 : 64; _prom->encode_phys_size = (getprop_rval == 1) ? 32 : 64;
/* Determine which cpu is actually running right _now_ */ /* Determine which cpu is actually running right _now_ */
if ((long)call_prom(RELOC("getprop"), 4, 1, _prom->chosen, if (prom_getprop(_prom->chosen, "cpu",
RELOC("cpu"), &getprop_rval, &prom_cpu, sizeof(prom_cpu)) <= 0)
sizeof(getprop_rval)) <= 0) prom_panic("cannot find boot cpu");
prom_panic(RELOC("cannot find boot cpu"));
cpu_pkg = call_prom("instance-to-package", 1, 1, prom_cpu);
prom_cpu = (ihandle)(unsigned long)getprop_rval; prom_getprop(cpu_pkg, "reg", &getprop_rval, sizeof(getprop_rval));
cpu_pkg = call_prom(RELOC("instance-to-package"), 1, 1, prom_cpu); _prom->cpu = getprop_rval;
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; _xPaca[0].xHwProcNum = _prom->cpu;
RELOC(boot_cpuid) = 0; RELOC(boot_cpuid) = 0;
#ifdef DEBUG_PROM prom_debug("Booting CPU hw index = 0x%x\n", _prom->cpu);
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. */ /* Get the boot device and translate it to a full OF pathname. */
p = (char *) mem; p = (char *) mem;
l = (long) call_prom(RELOC("getprop"), 4, 1, _prom->chosen, l = prom_getprop(_prom->chosen, "bootpath", p, 1<<20);
RELOC("bootpath"), p, 1<<20);
if (l > 0) { if (l > 0) {
p[l] = 0; /* should already be null-terminated */ p[l] = 0; /* should already be null-terminated */
RELOC(bootpath) = PTRUNRELOC(p); RELOC(bootpath) = PTRUNRELOC(p);
mem += l + 1; mem += l + 1;
d = (char *) mem; d = (char *) mem;
*d = 0; *d = 0;
call_prom(RELOC("canon"), 3, 1, p, d, 1<<20); call_prom("canon", 3, 1, p, d, 1<<20);
RELOC(bootdevice) = PTRUNRELOC(d); RELOC(bootdevice) = PTRUNRELOC(d);
mem = DOUBLEWORD_ALIGN(mem + strlen(d) + 1); mem = DOUBLEWORD_ALIGN(mem + strlen(d) + 1);
} }
RELOC(cmd_line[0]) = 0; RELOC(cmd_line[0]) = 0;
if ((long)_prom->chosen > 0) { if ((long)_prom->chosen > 0) {
call_prom(RELOC("getprop"), 4, 1, _prom->chosen, prom_getprop(_prom->chosen, "bootargs", p, sizeof(cmd_line));
RELOC("bootargs"), p, sizeof(cmd_line));
if (p != NULL && p[0] != 0) if (p != NULL && p[0] != 0)
strlcpy(RELOC(cmd_line), p, sizeof(cmd_line)); strlcpy(RELOC(cmd_line), p, sizeof(cmd_line));
} }
...@@ -1961,33 +1784,20 @@ prom_init(unsigned long r3, unsigned long r4, unsigned long pp, ...@@ -1961,33 +1784,20 @@ prom_init(unsigned long r3, unsigned long r4, unsigned long pp,
*/ */
prom_hold_cpus(mem); prom_hold_cpus(mem);
#ifdef DEBUG_PROM prom_debug("after basic inits, mem=0x%x\n", mem);
prom_print(RELOC("after basic inits, mem=0x"));
prom_print_hex(mem);
prom_print_nl();
#ifdef CONFIG_BLK_DEV_INITRD #ifdef CONFIG_BLK_DEV_INITRD
prom_print(RELOC("initrd_start=0x")); prom_debug("initrd_start=0x%x\n", RELOC(initrd_start));
prom_print_hex(RELOC(initrd_start)); prom_debug("initrd_end=0x%x\n", RELOC(initrd_end));
prom_print_nl();
prom_print(RELOC("initrd_end=0x"));
prom_print_hex(RELOC(initrd_end));
prom_print_nl();
#endif /* CONFIG_BLK_DEV_INITRD */ #endif /* CONFIG_BLK_DEV_INITRD */
prom_print(RELOC("copying OF device tree...\n")); prom_debug("copying OF device tree...\n");
#endif /* DEBUG_PROM */
mem = copy_device_tree(mem); mem = copy_device_tree(mem);
RELOC(klimit) = mem + offset; RELOC(klimit) = mem + offset;
#ifdef DEBUG_PROM prom_debug("new klimit is\n");
prom_print(RELOC("new klimit is\n")); prom_debug("klimit=0x%x\n", RELOC(klimit));
prom_print(RELOC("klimit=0x")); prom_debug(" ->mem=0x%x\n", mem);
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))); lmb_reserve(0, __pa(RELOC(klimit)));
...@@ -2017,14 +1827,14 @@ prom_init(unsigned long r3, unsigned long r4, unsigned long pp, ...@@ -2017,14 +1827,14 @@ prom_init(unsigned long r3, unsigned long r4, unsigned long pp,
#endif #endif
#ifdef CONFIG_BOOTX_TEXT #ifdef CONFIG_BOOTX_TEXT
if(_prom->disp_node) { if (_prom->disp_node) {
prom_print(RELOC("Setting up bi display...\n")); prom_printf("Setting up bi display...\n");
setup_disp_fake_bi(_prom->disp_node); setup_disp_fake_bi(_prom->disp_node);
} }
#endif /* CONFIG_BOOTX_TEXT */ #endif /* CONFIG_BOOTX_TEXT */
prom_print(RELOC("Calling quiesce ...\n")); prom_printf("Calling quiesce ...\n");
call_prom(RELOC("quiesce"), 0, 0); call_prom("quiesce", 0, 0);
phys = KERNELBASE - offset; phys = KERNELBASE - offset;
#ifdef CONFIG_BLK_DEV_INITRD #ifdef CONFIG_BLK_DEV_INITRD
...@@ -2035,7 +1845,7 @@ prom_init(unsigned long r3, unsigned long r4, unsigned long pp, ...@@ -2035,7 +1845,7 @@ prom_init(unsigned long r3, unsigned long r4, unsigned long pp,
} }
#endif /* CONFIG_BLK_DEV_INITRD */ #endif /* CONFIG_BLK_DEV_INITRD */
prom_print(RELOC("returning from prom_init\n")); prom_printf("returning from prom_init\n");
return phys; return phys;
} }
......
...@@ -394,7 +394,7 @@ static ssize_t ppc_rtas_clock_read(struct file * file, char * buf, ...@@ -394,7 +394,7 @@ static ssize_t ppc_rtas_clock_read(struct file * file, char * buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
unsigned int year, mon, day, hour, min, sec; unsigned int year, mon, day, hour, min, sec;
unsigned long *ret = kmalloc(4*8, GFP_KERNEL); int ret[8];
int n, sn, error; int n, sn, error;
char stkbuf[40]; /* its small, its on stack */ char stkbuf[40]; /* its small, its on stack */
...@@ -411,7 +411,6 @@ static ssize_t ppc_rtas_clock_read(struct file * file, char * buf, ...@@ -411,7 +411,6 @@ static ssize_t ppc_rtas_clock_read(struct file * file, char * buf,
n = scnprintf (stkbuf, sizeof(stkbuf), "%lu\n", n = scnprintf (stkbuf, sizeof(stkbuf), "%lu\n",
mktime(year, mon, day, hour, min, sec)); mktime(year, mon, day, hour, min, sec));
} }
kfree(ret);
sn = strlen (stkbuf) +1; sn = strlen (stkbuf) +1;
if (*ppos >= sn) if (*ppos >= sn)
...@@ -434,7 +433,6 @@ static int ppc_rtas_sensor_read(char * buf, char ** start, off_t off, ...@@ -434,7 +433,6 @@ static int ppc_rtas_sensor_read(char * buf, char ** start, off_t off,
int count, int *eof, void *data) int count, int *eof, void *data)
{ {
int i,j,n; int i,j,n;
unsigned long ret;
int state, error; int state, error;
char *buffer; char *buffer;
int get_sensor_state = rtas_token("get-sensor-state"); int get_sensor_state = rtas_token("get-sensor-state");
...@@ -464,11 +462,10 @@ static int ppc_rtas_sensor_read(char * buf, char ** start, off_t off, ...@@ -464,11 +462,10 @@ static int ppc_rtas_sensor_read(char * buf, char ** start, off_t off,
/* A sensor may have multiple instances */ /* A sensor may have multiple instances */
while (j >= 0) { while (j >= 0) {
error = rtas_call(get_sensor_state, 2, 2, &ret, error = rtas_call(get_sensor_state, 2, 2, &state,
sensors.sensor[i].token, sensors.sensor[i].token,
sensors.sensor[i].quant - j); sensors.sensor[i].quant - j);
state = (int) ret;
n += ppc_rtas_process_sensor(sensors.sensor[i], state, n += ppc_rtas_process_sensor(sensors.sensor[i], state,
error, buffer+n ); error, buffer+n );
n += sprintf (buffer+n, "\n"); n += sprintf (buffer+n, "\n");
......
...@@ -139,15 +139,13 @@ log_rtas_error(struct rtas_args *rtas_args) ...@@ -139,15 +139,13 @@ log_rtas_error(struct rtas_args *rtas_args)
log_error(rtas_err_buf, ERR_TYPE_RTAS_LOG, 0); log_error(rtas_err_buf, ERR_TYPE_RTAS_LOG, 0);
} }
long int rtas_call(int token, int nargs, int nret, int *outputs, ...)
rtas_call(int token, int nargs, int nret,
unsigned long *outputs, ...)
{ {
va_list list; va_list list;
int i, logit = 0; int i, logit = 0;
unsigned long s; unsigned long s;
struct rtas_args *rtas_args; struct rtas_args *rtas_args;
long ret; int ret;
PPCDBG(PPCDBG_RTAS, "Entering rtas_call\n"); PPCDBG(PPCDBG_RTAS, "Entering rtas_call\n");
PPCDBG(PPCDBG_RTAS, "\ttoken = 0x%x\n", token); PPCDBG(PPCDBG_RTAS, "\ttoken = 0x%x\n", token);
...@@ -167,8 +165,8 @@ rtas_call(int token, int nargs, int nret, ...@@ -167,8 +165,8 @@ rtas_call(int token, int nargs, int nret,
rtas_args->rets = (rtas_arg_t *)&(rtas_args->args[nargs]); rtas_args->rets = (rtas_arg_t *)&(rtas_args->args[nargs]);
va_start(list, outputs); va_start(list, outputs);
for (i = 0; i < nargs; ++i) { for (i = 0; i < nargs; ++i) {
rtas_args->args[i] = (rtas_arg_t)LONG_LSW(va_arg(list, ulong)); rtas_args->args[i] = va_arg(list, rtas_arg_t);
PPCDBG(PPCDBG_RTAS, "\tnarg[%d] = 0x%lx\n", i, rtas_args->args[i]); PPCDBG(PPCDBG_RTAS, "\tnarg[%d] = 0x%x\n", i, rtas_args->args[i]);
} }
va_end(list); va_end(list);
...@@ -191,7 +189,7 @@ rtas_call(int token, int nargs, int nret, ...@@ -191,7 +189,7 @@ rtas_call(int token, int nargs, int nret,
if (nret > 1 && outputs != NULL) if (nret > 1 && outputs != NULL)
for (i = 0; i < nret-1; ++i) for (i = 0; i < nret-1; ++i)
outputs[i] = rtas_args->rets[i+1]; outputs[i] = rtas_args->rets[i+1];
ret = (ulong)((nret > 0) ? rtas_args->rets[0] : 0); ret = (nret > 0)? rtas_args->rets[0]: 0;
/* Gotta do something different here, use global lock for now... */ /* Gotta do something different here, use global lock for now... */
spin_unlock_irqrestore(&rtas.lock, s); spin_unlock_irqrestore(&rtas.lock, s);
...@@ -227,20 +225,13 @@ int ...@@ -227,20 +225,13 @@ int
rtas_get_power_level(int powerdomain, int *level) rtas_get_power_level(int powerdomain, int *level)
{ {
int token = rtas_token("get-power-level"); int token = rtas_token("get-power-level");
long powerlevel;
int rc; int rc;
if (token == RTAS_UNKNOWN_SERVICE) if (token == RTAS_UNKNOWN_SERVICE)
return RTAS_UNKNOWN_OP; return RTAS_UNKNOWN_OP;
while(1) { while ((rc = rtas_call(token, 1, 2, level, powerdomain)) == RTAS_BUSY)
rc = (int) rtas_call(token, 1, 2, &powerlevel, powerdomain); udelay(1);
if (rc == RTAS_BUSY)
udelay(1);
else
break;
}
*level = (int) powerlevel;
return rc; return rc;
} }
...@@ -249,25 +240,21 @@ rtas_set_power_level(int powerdomain, int level, int *setlevel) ...@@ -249,25 +240,21 @@ rtas_set_power_level(int powerdomain, int level, int *setlevel)
{ {
int token = rtas_token("set-power-level"); int token = rtas_token("set-power-level");
unsigned int wait_time; unsigned int wait_time;
long returned_level;
int rc; int rc;
if (token == RTAS_UNKNOWN_SERVICE) if (token == RTAS_UNKNOWN_SERVICE)
return RTAS_UNKNOWN_OP; return RTAS_UNKNOWN_OP;
while (1) { while (1) {
rc = (int) rtas_call(token, 2, 2, &returned_level, powerdomain, rc = rtas_call(token, 2, 2, setlevel, powerdomain, level);
level);
if (rc == RTAS_BUSY) if (rc == RTAS_BUSY)
udelay(1); udelay(1);
else if (rtas_is_extended_busy(rc)) { else if (rtas_is_extended_busy(rc)) {
wait_time = rtas_extended_busy_delay_time(rc); wait_time = rtas_extended_busy_delay_time(rc);
udelay(wait_time * 1000); udelay(wait_time * 1000);
} } else
else
break; break;
} }
*setlevel = (int) returned_level;
return rc; return rc;
} }
...@@ -276,25 +263,21 @@ rtas_get_sensor(int sensor, int index, int *state) ...@@ -276,25 +263,21 @@ rtas_get_sensor(int sensor, int index, int *state)
{ {
int token = rtas_token("get-sensor-state"); int token = rtas_token("get-sensor-state");
unsigned int wait_time; unsigned int wait_time;
long returned_state;
int rc; int rc;
if (token == RTAS_UNKNOWN_SERVICE) if (token == RTAS_UNKNOWN_SERVICE)
return RTAS_UNKNOWN_OP; return RTAS_UNKNOWN_OP;
while (1) { while (1) {
rc = (int) rtas_call(token, 2, 2, &returned_state, sensor, rc = rtas_call(token, 2, 2, state, sensor, index);
index);
if (rc == RTAS_BUSY) if (rc == RTAS_BUSY)
udelay(1); udelay(1);
else if (rtas_is_extended_busy(rc)) { else if (rtas_is_extended_busy(rc)) {
wait_time = rtas_extended_busy_delay_time(rc); wait_time = rtas_extended_busy_delay_time(rc);
udelay(wait_time * 1000); udelay(wait_time * 1000);
} } else
else
break; break;
} }
*state = (int) returned_state;
return rc; return rc;
} }
...@@ -309,8 +292,7 @@ rtas_set_indicator(int indicator, int index, int new_value) ...@@ -309,8 +292,7 @@ rtas_set_indicator(int indicator, int index, int new_value)
return RTAS_UNKNOWN_OP; return RTAS_UNKNOWN_OP;
while (1) { while (1) {
rc = (int) rtas_call(token, 3, 1, NULL, indicator, index, rc = rtas_call(token, 3, 1, NULL, indicator, index, new_value);
new_value);
if (rc == RTAS_BUSY) if (rc == RTAS_BUSY)
udelay(1); udelay(1);
else if (rtas_is_extended_busy(rc)) { else if (rtas_is_extended_busy(rc)) {
...@@ -409,7 +391,7 @@ rtas_restart(char *cmd) ...@@ -409,7 +391,7 @@ rtas_restart(char *cmd)
if (rtas_firmware_flash_list.next) if (rtas_firmware_flash_list.next)
rtas_flash_firmware(); rtas_flash_firmware();
printk("RTAS system-reboot returned %ld\n", printk("RTAS system-reboot returned %d\n",
rtas_call(rtas_token("system-reboot"), 0, 1, NULL)); rtas_call(rtas_token("system-reboot"), 0, 1, NULL));
for (;;); for (;;);
} }
...@@ -420,8 +402,8 @@ rtas_power_off(void) ...@@ -420,8 +402,8 @@ rtas_power_off(void)
if (rtas_firmware_flash_list.next) if (rtas_firmware_flash_list.next)
rtas_flash_bypass_warning(); rtas_flash_bypass_warning();
/* allow power on only with power button press */ /* allow power on only with power button press */
printk("RTAS power-off returned %ld\n", printk("RTAS power-off returned %d\n",
rtas_call(rtas_token("power-off"), 2, 1, NULL,0xffffffff,0xffffffff)); rtas_call(rtas_token("power-off"), 2, 1, NULL, -1, -1));
for (;;); for (;;);
} }
...@@ -438,7 +420,7 @@ static char rtas_os_term_buf[2048]; ...@@ -438,7 +420,7 @@ static char rtas_os_term_buf[2048];
void rtas_os_term(char *str) void rtas_os_term(char *str)
{ {
long status; int status;
snprintf(rtas_os_term_buf, 2048, "OS panic: %s", str); snprintf(rtas_os_term_buf, 2048, "OS panic: %s", str);
...@@ -449,7 +431,7 @@ void rtas_os_term(char *str) ...@@ -449,7 +431,7 @@ void rtas_os_term(char *str)
if (status == RTAS_BUSY) if (status == RTAS_BUSY)
udelay(1); udelay(1);
else if (status != 0) else if (status != 0)
printk(KERN_EMERG "ibm,os-term call failed %ld\n", printk(KERN_EMERG "ibm,os-term call failed %d\n",
status); status);
} while (status == RTAS_BUSY); } while (status == RTAS_BUSY);
} }
......
...@@ -344,8 +344,8 @@ static void manage_flash(struct rtas_manage_flash_t *args_buf) ...@@ -344,8 +344,8 @@ static void manage_flash(struct rtas_manage_flash_t *args_buf)
s32 rc; s32 rc;
while (1) { while (1) {
rc = (s32) rtas_call(rtas_token("ibm,manage-flash-image"), 1, rc = rtas_call(rtas_token("ibm,manage-flash-image"), 1,
1, NULL, (long) args_buf->op); 1, NULL, args_buf->op);
if (rc == RTAS_RC_BUSY) if (rc == RTAS_RC_BUSY)
udelay(1); udelay(1);
else if (rtas_is_extended_busy(rc)) { else if (rtas_is_extended_busy(rc)) {
...@@ -429,15 +429,15 @@ static void validate_flash(struct rtas_validate_flash_t *args_buf) ...@@ -429,15 +429,15 @@ static void validate_flash(struct rtas_validate_flash_t *args_buf)
{ {
int token = rtas_token("ibm,validate-flash-image"); int token = rtas_token("ibm,validate-flash-image");
unsigned int wait_time; unsigned int wait_time;
long update_results; int update_results;
s32 rc; s32 rc;
rc = 0; rc = 0;
while(1) { while(1) {
spin_lock(&rtas_data_buf_lock); spin_lock(&rtas_data_buf_lock);
memcpy(rtas_data_buf, args_buf->buf, VALIDATE_BUF_SIZE); memcpy(rtas_data_buf, args_buf->buf, VALIDATE_BUF_SIZE);
rc = (s32) rtas_call(token, 2, 2, &update_results, rc = rtas_call(token, 2, 2, &update_results,
__pa(rtas_data_buf), args_buf->buf_size); (u32) __pa(rtas_data_buf), args_buf->buf_size);
memcpy(args_buf->buf, rtas_data_buf, VALIDATE_BUF_SIZE); memcpy(args_buf->buf, rtas_data_buf, VALIDATE_BUF_SIZE);
spin_unlock(&rtas_data_buf_lock); spin_unlock(&rtas_data_buf_lock);
...@@ -451,7 +451,7 @@ static void validate_flash(struct rtas_validate_flash_t *args_buf) ...@@ -451,7 +451,7 @@ static void validate_flash(struct rtas_validate_flash_t *args_buf)
} }
args_buf->status = rc; args_buf->status = rc;
args_buf->update_results = (u32) update_results; args_buf->update_results = update_results;
} }
static int get_validate_flash_msg(struct rtas_validate_flash_t *args_buf, static int get_validate_flash_msg(struct rtas_validate_flash_t *args_buf,
......
...@@ -346,13 +346,13 @@ void iSeries_get_boot_time(struct rtc_time *tm) ...@@ -346,13 +346,13 @@ void iSeries_get_boot_time(struct rtc_time *tm)
#define RTAS_CLOCK_BUSY (-2) #define RTAS_CLOCK_BUSY (-2)
void pSeries_get_boot_time(struct rtc_time *rtc_tm) void pSeries_get_boot_time(struct rtc_time *rtc_tm)
{ {
unsigned long ret[8]; int ret[8];
int error, wait_time; int error, wait_time;
unsigned long max_wait_tb; unsigned long max_wait_tb;
max_wait_tb = __get_tb() + tb_ticks_per_usec * 1000 * MAX_RTC_WAIT; max_wait_tb = __get_tb() + tb_ticks_per_usec * 1000 * MAX_RTC_WAIT;
do { do {
error = rtas_call(rtas_token("get-time-of-day"), 0, 8, (void *)&ret); error = rtas_call(rtas_token("get-time-of-day"), 0, 8, ret);
if (error == RTAS_CLOCK_BUSY || rtas_is_extended_busy(error)) { if (error == RTAS_CLOCK_BUSY || rtas_is_extended_busy(error)) {
wait_time = rtas_extended_busy_delay_time(error); wait_time = rtas_extended_busy_delay_time(error);
/* This is boot time so we spin. */ /* This is boot time so we spin. */
...@@ -381,13 +381,13 @@ void pSeries_get_boot_time(struct rtc_time *rtc_tm) ...@@ -381,13 +381,13 @@ void pSeries_get_boot_time(struct rtc_time *rtc_tm)
*/ */
void pSeries_get_rtc_time(struct rtc_time *rtc_tm) void pSeries_get_rtc_time(struct rtc_time *rtc_tm)
{ {
unsigned long ret[8]; int ret[8];
int error, wait_time; int error, wait_time;
unsigned long max_wait_tb; unsigned long max_wait_tb;
max_wait_tb = __get_tb() + tb_ticks_per_usec * 1000 * MAX_RTC_WAIT; max_wait_tb = __get_tb() + tb_ticks_per_usec * 1000 * MAX_RTC_WAIT;
do { do {
error = rtas_call(rtas_token("get-time-of-day"), 0, 8, (void *)&ret); error = rtas_call(rtas_token("get-time-of-day"), 0, 8, ret);
if (error == RTAS_CLOCK_BUSY || rtas_is_extended_busy(error)) { if (error == RTAS_CLOCK_BUSY || rtas_is_extended_busy(error)) {
if (in_interrupt()) { if (in_interrupt()) {
printk(KERN_WARNING "error: reading clock would delay interrupt\n"); printk(KERN_WARNING "error: reading clock would delay interrupt\n");
......
...@@ -49,7 +49,7 @@ static ssize_t scanlog_read(struct file *file, char *buf, ...@@ -49,7 +49,7 @@ static ssize_t scanlog_read(struct file *file, char *buf,
struct inode * inode = file->f_dentry->d_inode; struct inode * inode = file->f_dentry->d_inode;
struct proc_dir_entry *dp; struct proc_dir_entry *dp;
unsigned int *data; unsigned int *data;
unsigned long status; int status;
unsigned long len, off; unsigned long len, off;
unsigned int wait_time; unsigned int wait_time;
...@@ -81,11 +81,11 @@ static ssize_t scanlog_read(struct file *file, char *buf, ...@@ -81,11 +81,11 @@ static ssize_t scanlog_read(struct file *file, char *buf,
spin_lock(&rtas_data_buf_lock); spin_lock(&rtas_data_buf_lock);
memcpy(rtas_data_buf, data, RTAS_DATA_BUF_SIZE); memcpy(rtas_data_buf, data, RTAS_DATA_BUF_SIZE);
status = rtas_call(ibm_scan_log_dump, 2, 1, NULL, status = rtas_call(ibm_scan_log_dump, 2, 1, NULL,
__pa(rtas_data_buf), count); (u32) __pa(rtas_data_buf), (u32) count);
memcpy(data, rtas_data_buf, RTAS_DATA_BUF_SIZE); memcpy(data, rtas_data_buf, RTAS_DATA_BUF_SIZE);
spin_unlock(&rtas_data_buf_lock); spin_unlock(&rtas_data_buf_lock);
DEBUG("status=%ld, data[0]=%x, data[1]=%x, data[2]=%x\n", DEBUG("status=%d, data[0]=%x, data[1]=%x, data[2]=%x\n",
status, data[0], data[1], data[2]); status, data[0], data[1], data[2]);
switch (status) { switch (status) {
case SCANLOG_COMPLETE: case SCANLOG_COMPLETE:
...@@ -133,7 +133,7 @@ static ssize_t scanlog_write(struct file * file, const char * buf, ...@@ -133,7 +133,7 @@ static ssize_t scanlog_write(struct file * file, const char * buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
char stkbuf[20]; char stkbuf[20];
unsigned long status; int status;
if (count > 19) count = 19; if (count > 19) count = 19;
if (copy_from_user (stkbuf, buf, count)) { if (copy_from_user (stkbuf, buf, count)) {
...@@ -144,8 +144,8 @@ static ssize_t scanlog_write(struct file * file, const char * buf, ...@@ -144,8 +144,8 @@ static ssize_t scanlog_write(struct file * file, const char * buf,
if (buf) { if (buf) {
if (strncmp(stkbuf, "reset", 5) == 0) { if (strncmp(stkbuf, "reset", 5) == 0) {
DEBUG("reset scanlog\n"); DEBUG("reset scanlog\n");
status = rtas_call(ibm_scan_log_dump, 2, 1, NULL, NULL, 0); status = rtas_call(ibm_scan_log_dump, 2, 1, NULL, 0, 0);
DEBUG("rtas returns %ld\n", status); DEBUG("rtas returns %d\n", status);
} else if (strncmp(stkbuf, "debugon", 7) == 0) { } else if (strncmp(stkbuf, "debugon", 7) == 0) {
printk(KERN_ERR "scanlog: debug on\n"); printk(KERN_ERR "scanlog: debug on\n");
scanlog_debug = 1; scanlog_debug = 1;
......
...@@ -164,7 +164,7 @@ void setup_system(unsigned long r3, unsigned long r4, unsigned long r5, ...@@ -164,7 +164,7 @@ void setup_system(unsigned long r3, unsigned long r4, unsigned long r5,
unsigned long r6, unsigned long r7) unsigned long r6, unsigned long r7)
{ {
#if defined(CONFIG_SMP) && defined(CONFIG_PPC_PSERIES) #if defined(CONFIG_SMP) && defined(CONFIG_PPC_PSERIES)
unsigned int ret, i; int ret, i;
#endif #endif
#ifdef CONFIG_XMON_DEFAULT #ifdef CONFIG_XMON_DEFAULT
...@@ -232,12 +232,11 @@ void setup_system(unsigned long r3, unsigned long r4, unsigned long r5, ...@@ -232,12 +232,11 @@ void setup_system(unsigned long r3, unsigned long r4, unsigned long r5,
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
/* Start secondary threads on SMT systems */ /* Start secondary threads on SMT systems */
for (i = 0; i < NR_CPUS; i++) { for (i = 0; i < NR_CPUS; i++) {
if(cpu_available(i) && !cpu_possible(i)) { if (cpu_available(i) && !cpu_possible(i)) {
printk("%16.16x : starting thread\n", i); printk("%16.16x : starting thread\n", i);
rtas_call(rtas_token("start-cpu"), 3, 1, rtas_call(rtas_token("start-cpu"), 3, 1, &ret,
(void *)&ret,
get_hard_smp_processor_id(i), get_hard_smp_processor_id(i),
*((unsigned long *)pseries_secondary_smp_init), (u32)*((unsigned long *)pseries_secondary_smp_init),
i); i);
cpu_set(i, cpu_possible_map); cpu_set(i, cpu_possible_map);
systemcfg->processorCount++; systemcfg->processorCount++;
......
...@@ -241,7 +241,7 @@ static void __devinit smp_openpic_setup_cpu(int cpu) ...@@ -241,7 +241,7 @@ static void __devinit smp_openpic_setup_cpu(int cpu)
*/ */
static int query_cpu_stopped(unsigned int pcpu) static int query_cpu_stopped(unsigned int pcpu)
{ {
long cpu_status; int cpu_status;
int status, qcss_tok; int status, qcss_tok;
qcss_tok = rtas_token("query-cpu-stopped-state"); qcss_tok = rtas_token("query-cpu-stopped-state");
......
...@@ -172,9 +172,9 @@ static struct rtas_error_log *FWNMI_get_errinfo(struct pt_regs *regs) ...@@ -172,9 +172,9 @@ static struct rtas_error_log *FWNMI_get_errinfo(struct pt_regs *regs)
*/ */
static void FWNMI_release_errinfo(void) static void FWNMI_release_errinfo(void)
{ {
unsigned long ret = rtas_call(rtas_token("ibm,nmi-interlock"), 0, 1, NULL); int ret = rtas_call(rtas_token("ibm,nmi-interlock"), 0, 1, NULL);
if (ret != 0) if (ret != 0)
printk("FWNMI: nmi-interlock failed: %ld\n", ret); printk("FWNMI: nmi-interlock failed: %d\n", ret);
} }
#endif #endif
......
...@@ -275,7 +275,7 @@ static int get_irq_server(unsigned int irq) ...@@ -275,7 +275,7 @@ static int get_irq_server(unsigned int irq)
static void xics_enable_irq(unsigned int virq) static void xics_enable_irq(unsigned int virq)
{ {
unsigned int irq; unsigned int irq;
long call_status; int call_status;
unsigned int server; unsigned int server;
irq = virt_irq_to_real(irq_offset_down(virq)); irq = virt_irq_to_real(irq_offset_down(virq));
...@@ -287,7 +287,7 @@ static void xics_enable_irq(unsigned int virq) ...@@ -287,7 +287,7 @@ static void xics_enable_irq(unsigned int virq)
DEFAULT_PRIORITY); DEFAULT_PRIORITY);
if (call_status != 0) { if (call_status != 0) {
printk(KERN_ERR "xics_enable_irq: irq=%x: ibm_set_xive " printk(KERN_ERR "xics_enable_irq: irq=%x: ibm_set_xive "
"returned %lx\n", irq, call_status); "returned %x\n", irq, call_status);
return; return;
} }
...@@ -295,14 +295,14 @@ static void xics_enable_irq(unsigned int virq) ...@@ -295,14 +295,14 @@ static void xics_enable_irq(unsigned int virq)
call_status = rtas_call(ibm_int_on, 1, 1, NULL, irq); call_status = rtas_call(ibm_int_on, 1, 1, NULL, irq);
if (call_status != 0) { if (call_status != 0) {
printk(KERN_ERR "xics_enable_irq: irq=%x: ibm_int_on " printk(KERN_ERR "xics_enable_irq: irq=%x: ibm_int_on "
"returned %lx\n", irq, call_status); "returned %x\n", irq, call_status);
return; return;
} }
} }
static void xics_disable_real_irq(unsigned int irq) static void xics_disable_real_irq(unsigned int irq)
{ {
long call_status; int call_status;
unsigned int server; unsigned int server;
if (irq == XICS_IPI) if (irq == XICS_IPI)
...@@ -311,7 +311,7 @@ static void xics_disable_real_irq(unsigned int irq) ...@@ -311,7 +311,7 @@ static void xics_disable_real_irq(unsigned int irq)
call_status = rtas_call(ibm_int_off, 1, 1, NULL, irq); call_status = rtas_call(ibm_int_off, 1, 1, NULL, irq);
if (call_status != 0) { if (call_status != 0) {
printk(KERN_ERR "xics_disable_real_irq: irq=%x: " printk(KERN_ERR "xics_disable_real_irq: irq=%x: "
"ibm_int_off returned %lx\n", irq, call_status); "ibm_int_off returned %x\n", irq, call_status);
return; return;
} }
...@@ -320,7 +320,7 @@ static void xics_disable_real_irq(unsigned int irq) ...@@ -320,7 +320,7 @@ static void xics_disable_real_irq(unsigned int irq)
call_status = rtas_call(ibm_set_xive, 3, 1, NULL, irq, server, 0xff); call_status = rtas_call(ibm_set_xive, 3, 1, NULL, irq, server, 0xff);
if (call_status != 0) { if (call_status != 0) {
printk(KERN_ERR "xics_disable_irq: irq=%x: ibm_set_xive(0xff)" printk(KERN_ERR "xics_disable_irq: irq=%x: ibm_set_xive(0xff)"
" returned %lx\n", irq, call_status); " returned %x\n", irq, call_status);
return; return;
} }
} }
...@@ -612,8 +612,8 @@ void xics_request_IPIs(void) ...@@ -612,8 +612,8 @@ void xics_request_IPIs(void)
static void xics_set_affinity(unsigned int virq, cpumask_t cpumask) static void xics_set_affinity(unsigned int virq, cpumask_t cpumask)
{ {
unsigned int irq; unsigned int irq;
long status; int status;
unsigned long xics_status[2]; int xics_status[2];
unsigned long newmask; unsigned long newmask;
cpumask_t tmp = CPU_MASK_NONE; cpumask_t tmp = CPU_MASK_NONE;
...@@ -621,11 +621,11 @@ static void xics_set_affinity(unsigned int virq, cpumask_t cpumask) ...@@ -621,11 +621,11 @@ static void xics_set_affinity(unsigned int virq, cpumask_t cpumask)
if (irq == XICS_IPI || irq == NO_IRQ) if (irq == XICS_IPI || irq == NO_IRQ)
return; return;
status = rtas_call(ibm_get_xive, 1, 3, (void *)&xics_status, irq); status = rtas_call(ibm_get_xive, 1, 3, xics_status, irq);
if (status) { if (status) {
printk(KERN_ERR "xics_set_affinity: irq=%d ibm,get-xive " printk(KERN_ERR "xics_set_affinity: irq=%d ibm,get-xive "
"returns %ld\n", irq, status); "returns %d\n", irq, status);
return; return;
} }
...@@ -644,7 +644,7 @@ static void xics_set_affinity(unsigned int virq, cpumask_t cpumask) ...@@ -644,7 +644,7 @@ static void xics_set_affinity(unsigned int virq, cpumask_t cpumask)
if (status) { if (status) {
printk(KERN_ERR "xics_set_affinity irq=%d ibm,set-xive " printk(KERN_ERR "xics_set_affinity irq=%d ibm,set-xive "
"returns %ld\n", irq, status); "returns %d\n", irq, status);
return; return;
} }
} }
...@@ -655,10 +655,10 @@ static void xics_set_affinity(unsigned int virq, cpumask_t cpumask) ...@@ -655,10 +655,10 @@ static void xics_set_affinity(unsigned int virq, cpumask_t cpumask)
void xics_migrate_irqs_away(void) void xics_migrate_irqs_away(void)
{ {
int set_indicator = rtas_token("set-indicator"); int set_indicator = rtas_token("set-indicator");
const unsigned long giqs = 9005UL; /* Global Interrupt Queue Server */ const unsigned int giqs = 9005UL; /* Global Interrupt Queue Server */
unsigned long status = 0; int status = 0;
unsigned int irq, cpu = smp_processor_id(); unsigned int irq, cpu = smp_processor_id();
unsigned long xics_status[2]; int xics_status[2];
unsigned long flags; unsigned long flags;
BUG_ON(set_indicator == RTAS_UNKNOWN_SERVICE); BUG_ON(set_indicator == RTAS_UNKNOWN_SERVICE);
...@@ -669,7 +669,7 @@ void xics_migrate_irqs_away(void) ...@@ -669,7 +669,7 @@ void xics_migrate_irqs_away(void)
/* Refuse any new interrupts... */ /* Refuse any new interrupts... */
rtas_call(set_indicator, 3, 1, &status, giqs, rtas_call(set_indicator, 3, 1, &status, giqs,
hard_smp_processor_id(), 0UL); hard_smp_processor_id(), 0);
WARN_ON(status != 0); WARN_ON(status != 0);
/* Allow IPIs again... */ /* Allow IPIs again... */
...@@ -692,11 +692,10 @@ void xics_migrate_irqs_away(void) ...@@ -692,11 +692,10 @@ void xics_migrate_irqs_away(void)
spin_lock_irqsave(&desc->lock, flags); spin_lock_irqsave(&desc->lock, flags);
status = rtas_call(ibm_get_xive, 1, 3, (void *)&xics_status, status = rtas_call(ibm_get_xive, 1, 3, xics_status, irq);
irq);
if (status) { if (status) {
printk(KERN_ERR "migrate_irqs_away: irq=%d " printk(KERN_ERR "migrate_irqs_away: irq=%d "
"ibm,get-xive returns %ld\n", "ibm,get-xive returns %d\n",
irq, status); irq, status);
goto unlock; goto unlock;
} }
...@@ -719,7 +718,7 @@ void xics_migrate_irqs_away(void) ...@@ -719,7 +718,7 @@ void xics_migrate_irqs_away(void)
irq, xics_status[0], xics_status[1]); irq, xics_status[0], xics_status[1]);
if (status) if (status)
printk(KERN_ERR "migrate_irqs_away irq=%d " printk(KERN_ERR "migrate_irqs_away irq=%d "
"ibm,set-xive returns %ld\n", "ibm,set-xive returns %d\n",
irq, status); irq, status);
unlock: unlock:
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#define LONG_MSW(X) (((unsigned long)X) >> 32) #define LONG_MSW(X) (((unsigned long)X) >> 32)
typedef u32 phandle; typedef u32 phandle;
typedef void *ihandle; typedef u32 ihandle;
typedef u32 phandle32; typedef u32 phandle32;
typedef u32 ihandle32; typedef u32 ihandle32;
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
* Where n_in is the number of input parameters and * Where n_in is the number of input parameters and
* n_out is the number of output parameters * n_out is the number of output parameters
* *
* If the "string" is invalid on this system, RTAS_UNKOWN_SERVICE * If the "string" is invalid on this system, RTAS_UNKNOWN_SERVICE
* will be returned as a token. rtas_call() does look for this * will be returned as a token. rtas_call() does look for this
* token and error out gracefully so rtas_call(rtas_token("str"), ...) * token and error out gracefully so rtas_call(rtas_token("str"), ...)
* may be safely used for one-shot calls to RTAS. * may be safely used for one-shot calls to RTAS.
...@@ -168,7 +168,7 @@ extern struct rtas_t rtas; ...@@ -168,7 +168,7 @@ extern struct rtas_t rtas;
extern void enter_rtas(unsigned long); extern void enter_rtas(unsigned long);
extern int rtas_token(const char *service); extern int rtas_token(const char *service);
extern long rtas_call(int token, int, int, unsigned long *, ...); extern int rtas_call(int token, int, int, int *, ...);
extern void call_rtas_display_status(char); extern void call_rtas_display_status(char);
extern void rtas_restart(char *cmd); extern void rtas_restart(char *cmd);
extern void rtas_power_off(void); extern void rtas_power_off(void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment