Commit 25edd694 authored by David S. Miller's avatar David S. Miller

sparc64: Get rid of indirect p1275 PROM call buffer.

This is based upon a report by Meelis Roos showing that it's possible
that we'll try to fetch a property that is 32K in size with some
devices.  With the current fixed 3K buffer we use for moving data in
and out of the firmware during PROM calls, that simply won't work.

In fact, it will scramble random kernel data during bootup.

The reasoning behind the temporary buffer is entirely historical.  It
used to be the case that we had problems referencing dynamic kernel
memory (including the stack) early in the boot process before we
explicitly told the firwmare to switch us over to the kernel trap
table.

So what we did was always give the firmware buffers that were locked
into the main kernel image.

But we no longer have problems like that, so get rid of all of this
indirect bounce buffering.

Besides fixing Meelis's bug, this also makes the kernel data about 3K
smaller.

It was also discovered during these conversions that the
implementation of prom_retain() was completely wrong, so that was
fixed here as well.  Currently that interface is not in use.
Reported-by: default avatarMeelis Roos <mroos@linux.ee>
Tested-by: default avatarMeelis Roos <mroos@linux.ee>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 019408f9
...@@ -185,9 +185,8 @@ extern int prom_getunumber(int syndrome_code, ...@@ -185,9 +185,8 @@ extern int prom_getunumber(int syndrome_code,
char *buf, int buflen); char *buf, int buflen);
/* Retain physical memory to the caller across soft resets. */ /* Retain physical memory to the caller across soft resets. */
extern unsigned long prom_retain(const char *name, extern int prom_retain(const char *name, unsigned long size,
unsigned long pa_low, unsigned long pa_high, unsigned long align, unsigned long *paddr);
long size, long align);
/* Load explicit I/D TLB entries into the calling processor. */ /* Load explicit I/D TLB entries into the calling processor. */
extern long prom_itlb_load(unsigned long index, extern long prom_itlb_load(unsigned long index,
...@@ -287,26 +286,6 @@ extern void prom_sun4v_guest_soft_state(void); ...@@ -287,26 +286,6 @@ extern void prom_sun4v_guest_soft_state(void);
extern int prom_ihandle2path(int handle, char *buffer, int bufsize); extern int prom_ihandle2path(int handle, char *buffer, int bufsize);
/* Client interface level routines. */ /* Client interface level routines. */
extern long p1275_cmd(const char *, long, ...); extern void p1275_cmd_direct(unsigned long *);
#if 0
#define P1275_SIZE(x) ((((long)((x) / 32)) << 32) | (x))
#else
#define P1275_SIZE(x) x
#endif
/* We support at most 16 input and 1 output argument */
#define P1275_ARG_NUMBER 0
#define P1275_ARG_IN_STRING 1
#define P1275_ARG_OUT_BUF 2
#define P1275_ARG_OUT_32B 3
#define P1275_ARG_IN_FUNCTION 4
#define P1275_ARG_IN_BUF 5
#define P1275_ARG_IN_64B 6
#define P1275_IN(x) ((x) & 0xf)
#define P1275_OUT(x) (((x) << 4) & 0xf0)
#define P1275_INOUT(i,o) (P1275_IN(i)|P1275_OUT(o))
#define P1275_ARG(n,x) ((x) << ((n)*3 + 8))
#endif /* !(__SPARC64_OPLIB_H) */ #endif /* !(__SPARC64_OPLIB_H) */
...@@ -9,18 +9,18 @@ ...@@ -9,18 +9,18 @@
#include <asm/thread_info.h> #include <asm/thread_info.h>
.text .text
.globl prom_cif_interface .globl prom_cif_direct
prom_cif_interface: prom_cif_direct:
sethi %hi(p1275buf), %o0 sethi %hi(p1275buf), %o1
or %o0, %lo(p1275buf), %o0 or %o1, %lo(p1275buf), %o1
ldx [%o0 + 0x010], %o1 ! prom_cif_stack ldx [%o1 + 0x0010], %o2 ! prom_cif_stack
save %o1, -192, %sp save %o2, -192, %sp
ldx [%i0 + 0x008], %l2 ! prom_cif_handler ldx [%i1 + 0x0008], %l2 ! prom_cif_handler
mov %g4, %l0 mov %g4, %l0
mov %g5, %l1 mov %g5, %l1
mov %g6, %l3 mov %g6, %l3
call %l2 call %l2
add %i0, 0x018, %o0 ! prom_args mov %i0, %o0 ! prom_args
mov %l0, %g4 mov %l0, %g4
mov %l1, %g5 mov %l1, %g5
mov %l3, %g6 mov %l3, %g6
......
...@@ -21,13 +21,21 @@ extern int prom_stdin, prom_stdout; ...@@ -21,13 +21,21 @@ extern int prom_stdin, prom_stdout;
inline int inline int
prom_nbgetchar(void) prom_nbgetchar(void)
{ {
unsigned long args[7];
char inc; char inc;
if (p1275_cmd("read", P1275_ARG(1,P1275_ARG_OUT_BUF)| args[0] = (unsigned long) "read";
P1275_INOUT(3,1), args[1] = 3;
prom_stdin, &inc, P1275_SIZE(1)) == 1) args[2] = 1;
args[3] = (unsigned int) prom_stdin;
args[4] = (unsigned long) &inc;
args[5] = 1;
args[6] = (unsigned long) -1;
p1275_cmd_direct(args);
if (args[6] == 1)
return inc; return inc;
else
return -1; return -1;
} }
...@@ -37,12 +45,22 @@ prom_nbgetchar(void) ...@@ -37,12 +45,22 @@ prom_nbgetchar(void)
inline int inline int
prom_nbputchar(char c) prom_nbputchar(char c)
{ {
unsigned long args[7];
char outc; char outc;
outc = c; outc = c;
if (p1275_cmd("write", P1275_ARG(1,P1275_ARG_IN_BUF)|
P1275_INOUT(3,1), args[0] = (unsigned long) "write";
prom_stdout, &outc, P1275_SIZE(1)) == 1) args[1] = 3;
args[2] = 1;
args[3] = (unsigned int) prom_stdout;
args[4] = (unsigned long) &outc;
args[5] = 1;
args[6] = (unsigned long) -1;
p1275_cmd_direct(args);
if (args[6] == 1)
return 0; return 0;
else else
return -1; return -1;
...@@ -67,7 +85,15 @@ prom_putchar(char c) ...@@ -67,7 +85,15 @@ prom_putchar(char c)
void void
prom_puts(const char *s, int len) prom_puts(const char *s, int len)
{ {
p1275_cmd("write", P1275_ARG(1,P1275_ARG_IN_BUF)| unsigned long args[7];
P1275_INOUT(3,1),
prom_stdout, s, P1275_SIZE(len)); args[0] = (unsigned long) "write";
args[1] = 3;
args[2] = 1;
args[3] = (unsigned int) prom_stdout;
args[4] = (unsigned long) s;
args[5] = len;
args[6] = (unsigned long) -1;
p1275_cmd_direct(args);
} }
...@@ -18,16 +18,32 @@ ...@@ -18,16 +18,32 @@
int int
prom_devopen(const char *dstr) prom_devopen(const char *dstr)
{ {
return p1275_cmd ("open", P1275_ARG(0,P1275_ARG_IN_STRING)| unsigned long args[5];
P1275_INOUT(1,1),
dstr); args[0] = (unsigned long) "open";
args[1] = 1;
args[2] = 1;
args[3] = (unsigned long) dstr;
args[4] = (unsigned long) -1;
p1275_cmd_direct(args);
return (int) args[4];
} }
/* Close the device described by device handle 'dhandle'. */ /* Close the device described by device handle 'dhandle'. */
int int
prom_devclose(int dhandle) prom_devclose(int dhandle)
{ {
p1275_cmd ("close", P1275_INOUT(1,0), dhandle); unsigned long args[4];
args[0] = (unsigned long) "close";
args[1] = 1;
args[2] = 0;
args[3] = (unsigned int) dhandle;
p1275_cmd_direct(args);
return 0; return 0;
} }
...@@ -37,5 +53,15 @@ prom_devclose(int dhandle) ...@@ -37,5 +53,15 @@ prom_devclose(int dhandle)
void void
prom_seek(int dhandle, unsigned int seekhi, unsigned int seeklo) prom_seek(int dhandle, unsigned int seekhi, unsigned int seeklo)
{ {
p1275_cmd ("seek", P1275_INOUT(3,1), dhandle, seekhi, seeklo); unsigned long args[7];
args[0] = (unsigned long) "seek";
args[1] = 3;
args[2] = 1;
args[3] = (unsigned int) dhandle;
args[4] = seekhi;
args[5] = seeklo;
args[6] = (unsigned long) -1;
p1275_cmd_direct(args);
} }
This diff is collapsed.
...@@ -22,13 +22,11 @@ struct { ...@@ -22,13 +22,11 @@ struct {
long prom_callback; /* 0x00 */ long prom_callback; /* 0x00 */
void (*prom_cif_handler)(long *); /* 0x08 */ void (*prom_cif_handler)(long *); /* 0x08 */
unsigned long prom_cif_stack; /* 0x10 */ unsigned long prom_cif_stack; /* 0x10 */
unsigned long prom_args [23]; /* 0x18 */
char prom_buffer [3000];
} p1275buf; } p1275buf;
extern void prom_world(int); extern void prom_world(int);
extern void prom_cif_interface(void); extern void prom_cif_direct(unsigned long *args);
extern void prom_cif_callback(void); extern void prom_cif_callback(void);
/* /*
...@@ -36,114 +34,20 @@ extern void prom_cif_callback(void); ...@@ -36,114 +34,20 @@ extern void prom_cif_callback(void);
*/ */
DEFINE_RAW_SPINLOCK(prom_entry_lock); DEFINE_RAW_SPINLOCK(prom_entry_lock);
long p1275_cmd(const char *service, long fmt, ...) void p1275_cmd_direct(unsigned long *args)
{ {
char *p, *q;
unsigned long flags; unsigned long flags;
int nargs, nrets, i;
va_list list;
long attrs, x;
p = p1275buf.prom_buffer;
raw_local_save_flags(flags); raw_local_save_flags(flags);
raw_local_irq_restore(PIL_NMI); raw_local_irq_restore(PIL_NMI);
raw_spin_lock(&prom_entry_lock); raw_spin_lock(&prom_entry_lock);
p1275buf.prom_args[0] = (unsigned long)p; /* service */
strcpy (p, service);
p = (char *)(((long)(strchr (p, 0) + 8)) & ~7);
p1275buf.prom_args[1] = nargs = (fmt & 0x0f); /* nargs */
p1275buf.prom_args[2] = nrets = ((fmt & 0xf0) >> 4); /* nrets */
attrs = fmt >> 8;
va_start(list, fmt);
for (i = 0; i < nargs; i++, attrs >>= 3) {
switch (attrs & 0x7) {
case P1275_ARG_NUMBER:
p1275buf.prom_args[i + 3] =
(unsigned)va_arg(list, long);
break;
case P1275_ARG_IN_64B:
p1275buf.prom_args[i + 3] =
va_arg(list, unsigned long);
break;
case P1275_ARG_IN_STRING:
strcpy (p, va_arg(list, char *));
p1275buf.prom_args[i + 3] = (unsigned long)p;
p = (char *)(((long)(strchr (p, 0) + 8)) & ~7);
break;
case P1275_ARG_OUT_BUF:
(void) va_arg(list, char *);
p1275buf.prom_args[i + 3] = (unsigned long)p;
x = va_arg(list, long);
i++; attrs >>= 3;
p = (char *)(((long)(p + (int)x + 7)) & ~7);
p1275buf.prom_args[i + 3] = x;
break;
case P1275_ARG_IN_BUF:
q = va_arg(list, char *);
p1275buf.prom_args[i + 3] = (unsigned long)p;
x = va_arg(list, long);
i++; attrs >>= 3;
memcpy (p, q, (int)x);
p = (char *)(((long)(p + (int)x + 7)) & ~7);
p1275buf.prom_args[i + 3] = x;
break;
case P1275_ARG_OUT_32B:
(void) va_arg(list, char *);
p1275buf.prom_args[i + 3] = (unsigned long)p;
p += 32;
break;
case P1275_ARG_IN_FUNCTION:
p1275buf.prom_args[i + 3] =
(unsigned long)prom_cif_callback;
p1275buf.prom_callback = va_arg(list, long);
break;
}
}
va_end(list);
prom_world(1); prom_world(1);
prom_cif_interface(); prom_cif_direct(args);
prom_world(0); prom_world(0);
attrs = fmt >> 8;
va_start(list, fmt);
for (i = 0; i < nargs; i++, attrs >>= 3) {
switch (attrs & 0x7) {
case P1275_ARG_NUMBER:
(void) va_arg(list, long);
break;
case P1275_ARG_IN_STRING:
(void) va_arg(list, char *);
break;
case P1275_ARG_IN_FUNCTION:
(void) va_arg(list, long);
break;
case P1275_ARG_IN_BUF:
(void) va_arg(list, char *);
(void) va_arg(list, long);
i++; attrs >>= 3;
break;
case P1275_ARG_OUT_BUF:
p = va_arg(list, char *);
x = va_arg(list, long);
memcpy (p, (char *)(p1275buf.prom_args[i + 3]), (int)x);
i++; attrs >>= 3;
break;
case P1275_ARG_OUT_32B:
p = va_arg(list, char *);
memcpy (p, (char *)(p1275buf.prom_args[i + 3]), 32);
break;
}
}
va_end(list);
x = p1275buf.prom_args [nargs + 3];
raw_spin_unlock(&prom_entry_lock); raw_spin_unlock(&prom_entry_lock);
raw_local_irq_restore(flags); raw_local_irq_restore(flags);
return x;
} }
void prom_cif_init(void *cif_handler, void *cif_stack) void prom_cif_init(void *cif_handler, void *cif_stack)
......
...@@ -16,22 +16,39 @@ ...@@ -16,22 +16,39 @@
#include <asm/oplib.h> #include <asm/oplib.h>
#include <asm/ldc.h> #include <asm/ldc.h>
static int prom_node_to_node(const char *type, int node)
{
unsigned long args[5];
args[0] = (unsigned long) type;
args[1] = 1;
args[2] = 1;
args[3] = (unsigned int) node;
args[4] = (unsigned long) -1;
p1275_cmd_direct(args);
return (int) args[4];
}
/* Return the child of node 'node' or zero if no this node has no /* Return the child of node 'node' or zero if no this node has no
* direct descendent. * direct descendent.
*/ */
inline int __prom_getchild(int node) inline int __prom_getchild(int node)
{ {
return p1275_cmd ("child", P1275_INOUT(1, 1), node); return prom_node_to_node("child", node);
} }
inline int prom_getchild(int node) inline int prom_getchild(int node)
{ {
int cnode; int cnode;
if(node == -1) return 0; if (node == -1)
return 0;
cnode = __prom_getchild(node); cnode = __prom_getchild(node);
if(cnode == -1) return 0; if (cnode == -1)
return (int)cnode; return 0;
return cnode;
} }
EXPORT_SYMBOL(prom_getchild); EXPORT_SYMBOL(prom_getchild);
...@@ -39,10 +56,12 @@ inline int prom_getparent(int node) ...@@ -39,10 +56,12 @@ inline int prom_getparent(int node)
{ {
int cnode; int cnode;
if(node == -1) return 0; if (node == -1)
cnode = p1275_cmd ("parent", P1275_INOUT(1, 1), node); return 0;
if(cnode == -1) return 0; cnode = prom_node_to_node("parent", node);
return (int)cnode; if (cnode == -1)
return 0;
return cnode;
} }
/* Return the next sibling of node 'node' or zero if no more siblings /* Return the next sibling of node 'node' or zero if no more siblings
...@@ -50,7 +69,7 @@ inline int prom_getparent(int node) ...@@ -50,7 +69,7 @@ inline int prom_getparent(int node)
*/ */
inline int __prom_getsibling(int node) inline int __prom_getsibling(int node)
{ {
return p1275_cmd(prom_peer_name, P1275_INOUT(1, 1), node); return prom_node_to_node(prom_peer_name, node);
} }
inline int prom_getsibling(int node) inline int prom_getsibling(int node)
...@@ -72,11 +91,21 @@ EXPORT_SYMBOL(prom_getsibling); ...@@ -72,11 +91,21 @@ EXPORT_SYMBOL(prom_getsibling);
*/ */
inline int prom_getproplen(int node, const char *prop) inline int prom_getproplen(int node, const char *prop)
{ {
if((!node) || (!prop)) return -1; unsigned long args[6];
return p1275_cmd ("getproplen",
P1275_ARG(1,P1275_ARG_IN_STRING)| if (!node || !prop)
P1275_INOUT(2, 1), return -1;
node, prop);
args[0] = (unsigned long) "getproplen";
args[1] = 2;
args[2] = 1;
args[3] = (unsigned int) node;
args[4] = (unsigned long) prop;
args[5] = (unsigned long) -1;
p1275_cmd_direct(args);
return (int) args[5];
} }
EXPORT_SYMBOL(prom_getproplen); EXPORT_SYMBOL(prom_getproplen);
...@@ -87,19 +116,25 @@ EXPORT_SYMBOL(prom_getproplen); ...@@ -87,19 +116,25 @@ EXPORT_SYMBOL(prom_getproplen);
inline int prom_getproperty(int node, const char *prop, inline int prom_getproperty(int node, const char *prop,
char *buffer, int bufsize) char *buffer, int bufsize)
{ {
unsigned long args[8];
int plen; int plen;
plen = prom_getproplen(node, prop); plen = prom_getproplen(node, prop);
if ((plen > bufsize) || (plen == 0) || (plen == -1)) { if ((plen > bufsize) || (plen == 0) || (plen == -1))
return -1; return -1;
} else {
/* Ok, things seem all right. */ args[0] = (unsigned long) prom_getprop_name;
return p1275_cmd(prom_getprop_name, args[1] = 4;
P1275_ARG(1,P1275_ARG_IN_STRING)| args[2] = 1;
P1275_ARG(2,P1275_ARG_OUT_BUF)| args[3] = (unsigned int) node;
P1275_INOUT(4, 1), args[4] = (unsigned long) prop;
node, prop, buffer, P1275_SIZE(plen)); args[5] = (unsigned long) buffer;
} args[6] = bufsize;
args[7] = (unsigned long) -1;
p1275_cmd_direct(args);
return (int) args[7];
} }
EXPORT_SYMBOL(prom_getproperty); EXPORT_SYMBOL(prom_getproperty);
...@@ -110,7 +145,7 @@ inline int prom_getint(int node, const char *prop) ...@@ -110,7 +145,7 @@ inline int prom_getint(int node, const char *prop)
{ {
int intprop; int intprop;
if(prom_getproperty(node, prop, (char *) &intprop, sizeof(int)) != -1) if (prom_getproperty(node, prop, (char *) &intprop, sizeof(int)) != -1)
return intprop; return intprop;
return -1; return -1;
...@@ -126,7 +161,8 @@ int prom_getintdefault(int node, const char *property, int deflt) ...@@ -126,7 +161,8 @@ int prom_getintdefault(int node, const char *property, int deflt)
int retval; int retval;
retval = prom_getint(node, property); retval = prom_getint(node, property);
if(retval == -1) return deflt; if (retval == -1)
return deflt;
return retval; return retval;
} }
...@@ -138,7 +174,8 @@ int prom_getbool(int node, const char *prop) ...@@ -138,7 +174,8 @@ int prom_getbool(int node, const char *prop)
int retval; int retval;
retval = prom_getproplen(node, prop); retval = prom_getproplen(node, prop);
if(retval == -1) return 0; if (retval == -1)
return 0;
return 1; return 1;
} }
EXPORT_SYMBOL(prom_getbool); EXPORT_SYMBOL(prom_getbool);
...@@ -152,7 +189,8 @@ void prom_getstring(int node, const char *prop, char *user_buf, int ubuf_size) ...@@ -152,7 +189,8 @@ void prom_getstring(int node, const char *prop, char *user_buf, int ubuf_size)
int len; int len;
len = prom_getproperty(node, prop, user_buf, ubuf_size); len = prom_getproperty(node, prop, user_buf, ubuf_size);
if(len != -1) return; if (len != -1)
return;
user_buf[0] = 0; user_buf[0] = 0;
} }
EXPORT_SYMBOL(prom_getstring); EXPORT_SYMBOL(prom_getstring);
...@@ -164,7 +202,8 @@ int prom_nodematch(int node, const char *name) ...@@ -164,7 +202,8 @@ int prom_nodematch(int node, const char *name)
{ {
char namebuf[128]; char namebuf[128];
prom_getproperty(node, "name", namebuf, sizeof(namebuf)); prom_getproperty(node, "name", namebuf, sizeof(namebuf));
if(strcmp(namebuf, name) == 0) return 1; if (strcmp(namebuf, name) == 0)
return 1;
return 0; return 0;
} }
...@@ -190,16 +229,29 @@ int prom_searchsiblings(int node_start, const char *nodename) ...@@ -190,16 +229,29 @@ int prom_searchsiblings(int node_start, const char *nodename)
} }
EXPORT_SYMBOL(prom_searchsiblings); EXPORT_SYMBOL(prom_searchsiblings);
static const char *prom_nextprop_name = "nextprop";
/* Return the first property type for node 'node'. /* Return the first property type for node 'node'.
* buffer should be at least 32B in length * buffer should be at least 32B in length
*/ */
inline char *prom_firstprop(int node, char *buffer) inline char *prom_firstprop(int node, char *buffer)
{ {
unsigned long args[7];
*buffer = 0; *buffer = 0;
if(node == -1) return buffer; if (node == -1)
p1275_cmd ("nextprop", P1275_ARG(2,P1275_ARG_OUT_32B)| return buffer;
P1275_INOUT(3, 0),
node, (char *) 0x0, buffer); args[0] = (unsigned long) prom_nextprop_name;
args[1] = 3;
args[2] = 1;
args[3] = (unsigned int) node;
args[4] = 0;
args[5] = (unsigned long) buffer;
args[6] = (unsigned long) -1;
p1275_cmd_direct(args);
return buffer; return buffer;
} }
EXPORT_SYMBOL(prom_firstprop); EXPORT_SYMBOL(prom_firstprop);
...@@ -210,9 +262,10 @@ EXPORT_SYMBOL(prom_firstprop); ...@@ -210,9 +262,10 @@ EXPORT_SYMBOL(prom_firstprop);
*/ */
inline char *prom_nextprop(int node, const char *oprop, char *buffer) inline char *prom_nextprop(int node, const char *oprop, char *buffer)
{ {
unsigned long args[7];
char buf[32]; char buf[32];
if(node == -1) { if (node == -1) {
*buffer = 0; *buffer = 0;
return buffer; return buffer;
} }
...@@ -220,10 +273,17 @@ inline char *prom_nextprop(int node, const char *oprop, char *buffer) ...@@ -220,10 +273,17 @@ inline char *prom_nextprop(int node, const char *oprop, char *buffer)
strcpy (buf, oprop); strcpy (buf, oprop);
oprop = buf; oprop = buf;
} }
p1275_cmd ("nextprop", P1275_ARG(1,P1275_ARG_IN_STRING)|
P1275_ARG(2,P1275_ARG_OUT_32B)| args[0] = (unsigned long) prom_nextprop_name;
P1275_INOUT(3, 0), args[1] = 3;
node, oprop, buffer); args[2] = 1;
args[3] = (unsigned int) node;
args[4] = (unsigned long) oprop;
args[5] = (unsigned long) buffer;
args[6] = (unsigned long) -1;
p1275_cmd_direct(args);
return buffer; return buffer;
} }
EXPORT_SYMBOL(prom_nextprop); EXPORT_SYMBOL(prom_nextprop);
...@@ -231,12 +291,19 @@ EXPORT_SYMBOL(prom_nextprop); ...@@ -231,12 +291,19 @@ EXPORT_SYMBOL(prom_nextprop);
int int
prom_finddevice(const char *name) prom_finddevice(const char *name)
{ {
unsigned long args[5];
if (!name) if (!name)
return 0; return 0;
return p1275_cmd(prom_finddev_name, args[0] = (unsigned long) "finddevice";
P1275_ARG(0,P1275_ARG_IN_STRING)| args[1] = 1;
P1275_INOUT(1, 1), args[2] = 1;
name); args[3] = (unsigned long) name;
args[4] = (unsigned long) -1;
p1275_cmd_direct(args);
return (int) args[4];
} }
EXPORT_SYMBOL(prom_finddevice); EXPORT_SYMBOL(prom_finddevice);
...@@ -247,7 +314,7 @@ int prom_node_has_property(int node, const char *prop) ...@@ -247,7 +314,7 @@ int prom_node_has_property(int node, const char *prop)
*buf = 0; *buf = 0;
do { do {
prom_nextprop(node, buf, buf); prom_nextprop(node, buf, buf);
if(!strcmp(buf, prop)) if (!strcmp(buf, prop))
return 1; return 1;
} while (*buf); } while (*buf);
return 0; return 0;
...@@ -260,6 +327,8 @@ EXPORT_SYMBOL(prom_node_has_property); ...@@ -260,6 +327,8 @@ EXPORT_SYMBOL(prom_node_has_property);
int int
prom_setprop(int node, const char *pname, char *value, int size) prom_setprop(int node, const char *pname, char *value, int size)
{ {
unsigned long args[8];
if (size == 0) if (size == 0)
return 0; return 0;
if ((pname == 0) || (value == 0)) if ((pname == 0) || (value == 0))
...@@ -271,19 +340,37 @@ prom_setprop(int node, const char *pname, char *value, int size) ...@@ -271,19 +340,37 @@ prom_setprop(int node, const char *pname, char *value, int size)
return 0; return 0;
} }
#endif #endif
return p1275_cmd ("setprop", P1275_ARG(1,P1275_ARG_IN_STRING)| args[0] = (unsigned long) "setprop";
P1275_ARG(2,P1275_ARG_IN_BUF)| args[1] = 4;
P1275_INOUT(4, 1), args[2] = 1;
node, pname, value, P1275_SIZE(size)); args[3] = (unsigned int) node;
args[4] = (unsigned long) pname;
args[5] = (unsigned long) value;
args[6] = size;
args[7] = (unsigned long) -1;
p1275_cmd_direct(args);
return (int) args[7];
} }
EXPORT_SYMBOL(prom_setprop); EXPORT_SYMBOL(prom_setprop);
inline int prom_inst2pkg(int inst) inline int prom_inst2pkg(int inst)
{ {
unsigned long args[5];
int node; int node;
node = p1275_cmd ("instance-to-package", P1275_INOUT(1, 1), inst); args[0] = (unsigned long) "instance-to-package";
if (node == -1) return 0; args[1] = 1;
args[2] = 1;
args[3] = (unsigned int) inst;
args[4] = (unsigned long) -1;
p1275_cmd_direct(args);
node = (int) args[4];
if (node == -1)
return 0;
return node; return node;
} }
...@@ -296,17 +383,28 @@ prom_pathtoinode(const char *path) ...@@ -296,17 +383,28 @@ prom_pathtoinode(const char *path)
int node, inst; int node, inst;
inst = prom_devopen (path); inst = prom_devopen (path);
if (inst == 0) return 0; if (inst == 0)
node = prom_inst2pkg (inst); return 0;
prom_devclose (inst); node = prom_inst2pkg(inst);
if (node == -1) return 0; prom_devclose(inst);
if (node == -1)
return 0;
return node; return node;
} }
int prom_ihandle2path(int handle, char *buffer, int bufsize) int prom_ihandle2path(int handle, char *buffer, int bufsize)
{ {
return p1275_cmd("instance-to-path", unsigned long args[7];
P1275_ARG(1,P1275_ARG_OUT_BUF)|
P1275_INOUT(3, 1), args[0] = (unsigned long) "instance-to-path";
handle, buffer, P1275_SIZE(bufsize)); args[1] = 3;
args[2] = 1;
args[3] = (unsigned int) handle;
args[4] = (unsigned long) buffer;
args[5] = bufsize;
args[6] = (unsigned long) -1;
p1275_cmd_direct(args);
return (int) args[6];
} }
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