summaryrefslogtreecommitdiff
path: root/sys/arch/sparc64
diff options
context:
space:
mode:
authorMarc Aurele La France <tsi@cvs.openbsd.org>2007-01-16 14:39:58 +0000
committerMarc Aurele La France <tsi@cvs.openbsd.org>2007-01-16 14:39:58 +0000
commitd4226eeee8eec4e6c6ceddb5ce6e3facf2525cff (patch)
tree79a1ef71d3f41c97cf95e1f4e014c10e3069096e /sys/arch/sparc64
parent941d007d4480e3ea6e71b62f7674add69abb9b49 (diff)
Remove unnecessary ampersands in ADR2CELL macro invocations;
Change OF_printf references to printf, given the former doesn't exist; Clean up formatting, whitespace, unused code, etc. ok miod@, kettenis@
Diffstat (limited to 'sys/arch/sparc64')
-rw-r--r--sys/arch/sparc64/sparc64/ofw_machdep.c62
-rw-r--r--sys/arch/sparc64/sparc64/openfirm.c62
-rw-r--r--sys/arch/sparc64/stand/ofwboot/Locore.c191
3 files changed, 123 insertions, 192 deletions
diff --git a/sys/arch/sparc64/sparc64/ofw_machdep.c b/sys/arch/sparc64/sparc64/ofw_machdep.c
index 2120ebca593..a078b257f4e 100644
--- a/sys/arch/sparc64/sparc64/ofw_machdep.c
+++ b/sys/arch/sparc64/sparc64/ofw_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ofw_machdep.c,v 1.15 2006/08/31 21:28:35 kettenis Exp $ */
+/* $OpenBSD: ofw_machdep.c,v 1.16 2007/01/16 14:39:57 tsi Exp $ */
/* $NetBSD: ofw_machdep.c,v 1.16 2001/07/20 00:07:14 eeh Exp $ */
/*
@@ -115,7 +115,7 @@ prom_set_trap_table(tba)
cell_t tba;
} args;
- args.name = ADR2CELL(&"SUNW,set-trap-table");
+ args.name = ADR2CELL("SUNW,set-trap-table");
args.nargs = 1;
args.nreturns = 0;
args.tba = ADR2CELL(tba);
@@ -149,18 +149,26 @@ prom_vtop(vaddr)
prom_printf("prom_vtop: cannot get mmuh\r\n");
return 0;
}
- args.name = ADR2CELL(&"call-method");
+ args.name = ADR2CELL("call-method");
args.nargs = 3;
args.nreturns = 5;
- args.method = ADR2CELL(&"translate");
+ args.method = ADR2CELL("translate");
args.ihandle = HDL2CELL(mmuh);
args.vaddr = ADR2CELL(vaddr);
if(openfirmware(&args) == -1)
return -1;
#if 0
- prom_printf("Called \"translate\", mmuh=%x, vaddr=%x, status=%x %x,\r\n retaddr=%x %x, mode=%x %x, phys_hi=%x %x, phys_lo=%x %x\r\n",
- mmuh, vaddr, (int)(args.status>>32), (int)args.status, (int)(args.retaddr>>32), (int)args.retaddr,
- (int)(args.mode>>32), (int)args.mode, (int)(args.phys_hi>>32), (int)args.phys_hi,
+ prom_printf("Called \"translate\", mmuh=%x, vaddr=%x, "
+ "status=%x %x,\r\n "
+ "retaddr=%x %x, "
+ "mode=%x %x, "
+ "phys_hi=%x %x, "
+ "phys_lo=%x %x\r\n",
+ mmuh, vaddr,
+ (int)(args.status>>32), (int)args.status,
+ (int)(args.retaddr>>32), (int)args.retaddr,
+ (int)(args.mode>>32), (int)args.mode,
+ (int)(args.phys_hi>>32), (int)args.phys_hi,
(int)(args.phys_lo>>32), (int)args.phys_lo);
#endif
return (paddr_t)CELL2HDQ(args.phys_hi, args.phys_lo);
@@ -193,10 +201,10 @@ prom_claim_virt(vaddr, len)
prom_printf("prom_claim_virt: cannot get mmuh\r\n");
return 0;
}
- args.name = ADR2CELL(&"call-method");
+ args.name = ADR2CELL("call-method");
args.nargs = 5;
args.nreturns = 2;
- args.method = ADR2CELL(&"claim");
+ args.method = ADR2CELL("claim");
args.ihandle = HDL2CELL(mmuh);
args.align = 0;
args.len = len;
@@ -232,10 +240,10 @@ prom_alloc_virt(len, align)
prom_printf("prom_alloc_virt: cannot get mmuh\r\n");
return -1LL;
}
- args.name = ADR2CELL(&"call-method");
+ args.name = ADR2CELL("call-method");
args.nargs = 4;
args.nreturns = 2;
- args.method = ADR2CELL(&"claim");
+ args.method = ADR2CELL("claim");
args.ihandle = HDL2CELL(mmuh);
args.align = align;
args.len = len;
@@ -268,10 +276,10 @@ prom_free_virt(vaddr, len)
prom_printf("prom_free_virt: cannot get mmuh\r\n");
return -1;
}
- args.name = ADR2CELL(&"call-method");
+ args.name = ADR2CELL("call-method");
args.nargs = 4;
args.nreturns = 0;
- args.method = ADR2CELL(&"release");
+ args.method = ADR2CELL("release");
args.ihandle = HDL2CELL(mmuh);
args.vaddr = ADR2CELL(vaddr);
args.len = len;
@@ -303,10 +311,10 @@ prom_unmap_virt(vaddr, len)
prom_printf("prom_unmap_virt: cannot get mmuh\r\n");
return -1;
}
- args.name = ADR2CELL(&"call-method");
+ args.name = ADR2CELL("call-method");
args.nargs = 4;
args.nreturns = 0;
- args.method = ADR2CELL(&"unmap");
+ args.method = ADR2CELL("unmap");
args.ihandle = HDL2CELL(mmuh);
args.vaddr = ADR2CELL(vaddr);
args.len = len;
@@ -344,15 +352,15 @@ prom_map_phys(paddr, size, vaddr, mode)
prom_printf("prom_map_phys: cannot get mmuh\r\n");
return 0;
}
- args.name = ADR2CELL(&"call-method");
+ args.name = ADR2CELL("call-method");
args.nargs = 7;
args.nreturns = 1;
- args.method = ADR2CELL(&"map");
+ args.method = ADR2CELL("map");
args.ihandle = HDL2CELL(mmuh);
args.mode = mode;
args.size = size;
args.vaddr = ADR2CELL(vaddr);
- args.phys_hi = HDQ2CELL_HI(paddr);
+ args.phys_hi = HDQ2CELL_HI(paddr);
args.phys_lo = HDQ2CELL_LO(paddr);
if (openfirmware(&args) == -1)
@@ -390,10 +398,10 @@ prom_alloc_phys(len, align)
prom_printf("prom_alloc_phys: cannot get memh\r\n");
return -1;
}
- args.name = ADR2CELL(&"call-method");
+ args.name = ADR2CELL("call-method");
args.nargs = 4;
args.nreturns = 3;
- args.method = ADR2CELL(&"claim");
+ args.method = ADR2CELL("claim");
args.ihandle = HDL2CELL(memh);
args.align = align;
args.len = len;
@@ -431,10 +439,10 @@ prom_claim_phys(phys, len)
prom_printf("prom_claim_phys: cannot get memh\r\n");
return -1;
}
- args.name = ADR2CELL(&"call-method");
+ args.name = ADR2CELL("call-method");
args.nargs = 6;
args.nreturns = 3;
- args.method = ADR2CELL(&"claim");
+ args.method = ADR2CELL("claim");
args.ihandle = HDL2CELL(memh);
args.align = 0;
args.len = len;
@@ -470,10 +478,10 @@ prom_free_phys(phys, len)
prom_printf("prom_free_phys: cannot get memh\r\n");
return -1;
}
- args.name = ADR2CELL(&"call-method");
+ args.name = ADR2CELL("call-method");
args.nargs = 5;
args.nreturns = 0;
- args.method = ADR2CELL(&"release");
+ args.method = ADR2CELL("release");
args.ihandle = HDL2CELL(memh);
args.len = len;
args.phys_hi = HDQ2CELL_HI(phys);
@@ -526,11 +534,11 @@ prom_get_msgbuf(len, align)
prom_printf("prom_get_msgbuf: Cannot recover msgbuf on E250/450\r\n");
} else if (OF_test("test-method") == 0) {
if (OF_test_method(memh, "SUNW,retain") != 0) {
- args.name = ADR2CELL(&"call-method");
+ args.name = ADR2CELL("call-method");
args.nargs = 5;
args.nreturns = 3;
- args.method = ADR2CELL(&"SUNW,retain");
- args.id = ADR2CELL(&"msgbuf");
+ args.method = ADR2CELL("SUNW,retain");
+ args.id = ADR2CELL("msgbuf");
args.ihandle = HDL2CELL(memh);
args.len = len;
args.align = align;
diff --git a/sys/arch/sparc64/sparc64/openfirm.c b/sys/arch/sparc64/sparc64/openfirm.c
index a81dc23dc1c..a005a9b7e1b 100644
--- a/sys/arch/sparc64/sparc64/openfirm.c
+++ b/sys/arch/sparc64/sparc64/openfirm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: openfirm.c,v 1.11 2005/03/13 17:33:12 deraadt Exp $ */
+/* $OpenBSD: openfirm.c,v 1.12 2007/01/16 14:39:57 tsi Exp $ */
/* $NetBSD: openfirm.c,v 1.13 2001/06/21 00:08:02 eeh Exp $ */
/*
@@ -52,7 +52,7 @@ OF_peer(phandle)
cell_t sibling;
} args;
- args.name = ADR2CELL(&"peer");
+ args.name = ADR2CELL("peer");
args.nargs = 1;
args.nreturns = 1;
args.phandle = HDL2CELL(phandle);
@@ -73,7 +73,7 @@ OF_child(phandle)
cell_t child;
} args;
- args.name = ADR2CELL(&"child");
+ args.name = ADR2CELL("child");
args.nargs = 1;
args.nreturns = 1;
args.phandle = HDL2CELL(phandle);
@@ -94,7 +94,7 @@ OF_parent(phandle)
cell_t parent;
} args;
- args.name = ADR2CELL(&"parent");
+ args.name = ADR2CELL("parent");
args.nargs = 1;
args.nreturns = 1;
args.phandle = HDL2CELL(phandle);
@@ -115,7 +115,7 @@ OF_instance_to_package(ihandle)
cell_t phandle;
} args;
- args.name = ADR2CELL(&"instance-to-package");
+ args.name = ADR2CELL("instance-to-package");
args.nargs = 1;
args.nreturns = 1;
args.ihandle = HDL2CELL(ihandle);
@@ -139,7 +139,7 @@ OF_getproplen(handle, prop)
cell_t size;
} args;
- args.name = ADR2CELL(&"getproplen");
+ args.name = ADR2CELL("getproplen");
args.nargs = 2;
args.nreturns = 1;
args.phandle = HDL2CELL(handle);
@@ -169,7 +169,7 @@ OF_getprop(handle, prop, buf, buflen)
if (buflen > NBPG)
return -1;
- args.name = ADR2CELL(&"getprop");
+ args.name = ADR2CELL("getprop");
args.nargs = 4;
args.nreturns = 1;
args.phandle = HDL2CELL(handle);
@@ -201,7 +201,7 @@ OF_setprop(handle, prop, buf, buflen)
if (buflen > NBPG)
return -1;
- args.name = ADR2CELL(&"setprop");
+ args.name = ADR2CELL("setprop");
args.nargs = 4;
args.nreturns = 1;
args.phandle = HDL2CELL(handle);
@@ -229,7 +229,7 @@ OF_nextprop(handle, prop, buf)
cell_t next;
} args;
- args.name = ADR2CELL(&"nextprop");
+ args.name = ADR2CELL("nextprop");
args.nargs = 3;
args.nreturns = 1;
args.phandle = HDL2CELL(handle);
@@ -252,7 +252,7 @@ char *name;
cell_t phandle;
} args;
- args.name = ADR2CELL(&"finddevice");
+ args.name = ADR2CELL("finddevice");
args.nargs = 1;
args.nreturns = 1;
args.device = ADR2CELL(name);
@@ -279,7 +279,7 @@ OF_instance_to_path(ihandle, buf, buflen)
if (buflen > NBPG)
return -1;
- args.name = ADR2CELL(&"instance-to-path");
+ args.name = ADR2CELL("instance-to-path");
args.nargs = 3;
args.nreturns = 1;
args.ihandle = HDL2CELL(ihandle);
@@ -308,7 +308,7 @@ OF_package_to_path(phandle, buf, buflen)
if (buflen > NBPG)
return -1;
- args.name = ADR2CELL(&"package-to-path");
+ args.name = ADR2CELL("package-to-path");
args.nargs = 3;
args.nreturns = 1;
args.phandle = HDL2CELL(phandle);
@@ -338,7 +338,7 @@ OF_call_method(char *method, int ihandle, int nargs, int nreturns, ...)
if (nargs > 6)
return -1;
- args.name = ADR2CELL(&"call-method");
+ args.name = ADR2CELL("call-method");
args.nargs = nargs + 2;
args.nreturns = nreturns + 1;
args.method = ADR2CELL(method);
@@ -376,7 +376,7 @@ OF_call_method_1(char *method, int ihandle, int nargs, ...)
if (nargs > 6)
return -1;
- args.name = ADR2CELL(&"call-method");
+ args.name = ADR2CELL("call-method");
args.nargs = nargs + 2;
args.nreturns = 1;
args.method = ADR2CELL(method);
@@ -407,7 +407,7 @@ OF_open(dname)
if ((l = strlen(dname)) >= NBPG)
return -1;
- args.name = ADR2CELL(&"open");
+ args.name = ADR2CELL("open");
args.nargs = 1;
args.nreturns = 1;
args.dname = ADR2CELL(dname);
@@ -427,7 +427,7 @@ OF_close(handle)
cell_t handle;
} args;
- args.name = ADR2CELL(&"close");
+ args.name = ADR2CELL("close");
args.nargs = 1;
args.nreturns = 0;
args.handle = HDL2CELL(handle);
@@ -446,7 +446,7 @@ OF_test(service)
cell_t status;
} args;
- args.name = ADR2CELL(&"test");
+ args.name = ADR2CELL("test");
args.nargs = 1;
args.nreturns = 1;
args.service = ADR2CELL(service);
@@ -469,7 +469,7 @@ OF_test_method(service, method)
cell_t status;
} args;
- args.name = ADR2CELL(&"test-method");
+ args.name = ADR2CELL("test-method");
args.nargs = 2;
args.nreturns = 1;
args.service = HDL2CELL(service);
@@ -500,7 +500,7 @@ OF_read(handle, addr, len)
} args;
int l, act = 0;
- args.name = ADR2CELL(&"read");
+ args.name = ADR2CELL("read");
args.nargs = 3;
args.nreturns = 1;
args.ihandle = HDL2CELL(handle);
@@ -542,7 +542,7 @@ OF_write(handle, addr, len)
} args;
int l, act = 0;
- args.name = ADR2CELL(&"write");
+ args.name = ADR2CELL("write");
args.nargs = 3;
args.nreturns = 1;
args.ihandle = HDL2CELL(handle);
@@ -581,12 +581,12 @@ OF_seek(handle, pos)
cell_t status;
} args;
- args.name = ADR2CELL(&"seek");
+ args.name = ADR2CELL("seek");
args.nargs = 3;
args.nreturns = 1;
args.handle = HDL2CELL(handle);
- args.poshi = HDL2CELL(pos >> 32);
- args.poslo = HDL2CELL(pos);
+ args.poshi = HDQ2CELL_HI(pos);
+ args.poslo = HDQ2CELL_LO(pos);
if (openfirmware(&args) == -1)
return -1;
return args.status;
@@ -606,7 +606,7 @@ OF_boot(bootspec)
if ((l = strlen(bootspec)) >= NBPG)
panic("OF_boot");
- args.name = ADR2CELL(&"boot");
+ args.name = ADR2CELL("boot");
args.nargs = 1;
args.nreturns = 0;
args.bootspec = ADR2CELL(bootspec);
@@ -623,7 +623,7 @@ OF_enter()
cell_t nreturns;
} args;
- args.name = ADR2CELL(&"enter");
+ args.name = ADR2CELL("enter");
args.nargs = 0;
args.nreturns = 0;
openfirmware(&args);
@@ -638,7 +638,7 @@ OF_exit()
cell_t nreturns;
} args;
- args.name = ADR2CELL(&"exit");
+ args.name = ADR2CELL("exit");
args.nargs = 0;
args.nreturns = 0;
openfirmware(&args);
@@ -654,7 +654,7 @@ OF_poweroff()
cell_t nreturns;
} args;
- args.name = ADR2CELL(&"SUNW,power-off");
+ args.name = ADR2CELL("SUNW,power-off");
args.nargs = 0;
args.nreturns = 0;
openfirmware(&args);
@@ -672,7 +672,7 @@ void
cell_t oldfunc;
} args;
- args.name = ADR2CELL(&"set-callback");
+ args.name = ADR2CELL("set-callback");
args.nargs = 1;
args.nreturns = 1;
args.newfunc = ADR2CELL(newfunc);
@@ -694,7 +694,7 @@ OF_set_symbol_lookup(s2v, v2s)
cell_t val2sym;
} args;
- args.name = ADR2CELL(&"set-symbol-lookup");
+ args.name = ADR2CELL("set-symbol-lookup");
args.nargs = 2;
args.nreturns = 0;
args.sym2val = ADR2CELL(s2v);
@@ -716,7 +716,7 @@ OF_interpret(char *cmd, int nreturns, ...)
cell_t status;
int i = 0;
- args.name = ADR2CELL(&"interpret");
+ args.name = ADR2CELL("interpret");
args.nargs = 1;
args.nreturns = ++nreturns;
args.slot[i++] = ADR2CELL(cmd);
@@ -744,7 +744,7 @@ OF_milliseconds()
cell_t ticks;
} args;
- args.name = ADR2CELL(&"milliseconds");
+ args.name = ADR2CELL("milliseconds");
args.nargs = 0;
args.nreturns = 1;
if (openfirmware(&args) == -1)
diff --git a/sys/arch/sparc64/stand/ofwboot/Locore.c b/sys/arch/sparc64/stand/ofwboot/Locore.c
index ed259c11045..23917e4db9e 100644
--- a/sys/arch/sparc64/stand/ofwboot/Locore.c
+++ b/sys/arch/sparc64/stand/ofwboot/Locore.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: Locore.c,v 1.6 2006/08/31 21:28:35 kettenis Exp $ */
+/* $OpenBSD: Locore.c,v 1.7 2007/01/16 14:39:57 tsi Exp $ */
/* $NetBSD: Locore.c,v 1.1 2000/08/20 14:58:36 mrg Exp $ */
/*
@@ -37,14 +37,12 @@
#include <machine/cpu.h>
-vaddr_t OF_claim_virt(vaddr_t vaddr, int len);
-vaddr_t OF_alloc_virt(int len, int align);
-int OF_free_virt(vaddr_t vaddr, int len);
-int OF_unmap_virt(vaddr_t vaddr, int len);
-vaddr_t OF_map_phys(paddr_t paddr, off_t size, vaddr_t vaddr, int mode);
-paddr_t OF_alloc_phys(int len, int align);
-paddr_t OF_claim_phys(paddr_t phys, int len);
-int OF_free_phys(paddr_t paddr, int len);
+static vaddr_t OF_claim_virt(vaddr_t vaddr, int len);
+static vaddr_t OF_alloc_virt(int len, int align);
+static int OF_free_virt(vaddr_t vaddr, int len);
+static vaddr_t OF_map_phys(paddr_t paddr, off_t size, vaddr_t vaddr, int mode);
+static paddr_t OF_alloc_phys(int len, int align);
+static int OF_free_phys(paddr_t paddr, int len);
extern int openfirmware(void *);
@@ -117,7 +115,7 @@ OF_finddevice(name)
cell_t device;
cell_t phandle;
} args;
-
+
args.name = ADR2CELL("finddevice");
args.nargs = 1;
args.nreturns = 1;
@@ -138,7 +136,7 @@ OF_instance_to_package(ihandle)
cell_t ihandle;
cell_t phandle;
} args;
-
+
args.name = ADR2CELL("instance-to-package");
args.nargs = 1;
args.nreturns = 1;
@@ -165,7 +163,7 @@ OF_getprop(handle, prop, buf, buflen)
cell_t buflen;
cell_t size;
} args;
-
+
args.name = ADR2CELL("getprop");
args.nargs = 4;
args.nreturns = 1;
@@ -196,7 +194,7 @@ OF_setprop(handle, prop, buf, len)
cell_t len;
cell_t size;
} args;
-
+
args.name = ADR2CELL("setprop");
args.nargs = 4;
args.nreturns = 1;
@@ -221,7 +219,7 @@ OF_open(dname)
cell_t dname;
cell_t handle;
} args;
-
+
args.name = ADR2CELL("open");
args.nargs = 1;
args.nreturns = 1;
@@ -242,7 +240,7 @@ OF_close(handle)
cell_t nreturns;
cell_t handle;
} args;
-
+
args.name = ADR2CELL("close");
args.nargs = 1;
args.nreturns = 1;
@@ -319,7 +317,7 @@ OF_seek(handle, pos)
cell_t poslo;
cell_t status;
} args;
-
+
args.name = ADR2CELL("seek");
args.nargs = 3;
args.nreturns = 1;
@@ -344,7 +342,7 @@ OF_release(virt, size)
cell_t virt;
cell_t size;
} args;
-
+
args.name = ADR2CELL("release");
args.nargs = 2;
args.nreturns = 0;
@@ -362,7 +360,7 @@ OF_milliseconds()
cell_t nreturns;
cell_t ms;
} args;
-
+
args.name = ADR2CELL("milliseconds");
args.nargs = 0;
args.nreturns = 1;
@@ -421,7 +419,7 @@ void
setup()
{
u_int chosen;
-
+
if ((chosen = OF_finddevice("/chosen")) == -1)
_rtt();
if (OF_getprop(chosen, "stdin", &stdin, sizeof(stdin)) != sizeof(stdin)
@@ -435,12 +433,12 @@ setup()
* The following need either the handle to memory or the handle to the MMU.
*/
-/*
+/*
* Grab some address space from the prom
*
* Only works while the prom is actively mapping us.
*/
-vaddr_t
+static vaddr_t
OF_claim_virt(vaddr, len)
vaddr_t vaddr;
int len;
@@ -460,7 +458,7 @@ int len;
#ifdef __notyet
if (mmuh == -1 && ((mmuh = get_mmu_handle()) == -1)) {
- OF_printf("OF_claim_virt: cannot get mmuh\r\n");
+ printf("OF_claim_virt: cannot get mmuh\r\n");
return -1LL;
}
#endif
@@ -472,17 +470,17 @@ int len;
args.align = 0;
args.len = len;
args.vaddr = ADR2CELL(vaddr);
- if(openfirmware(&args) != 0)
+ if (openfirmware(&args) != 0)
return -1LL;
- return args.retaddr;
+ return (vaddr_t)args.retaddr;
}
-/*
+/*
* Request some address space from the prom
*
* Only works while the prom is actively mapping us.
*/
-vaddr_t
+static vaddr_t
OF_alloc_virt(len, align)
int len;
int align;
@@ -502,7 +500,7 @@ int align;
#ifdef __notyet
if (mmuh == -1 && ((mmuh = get_mmu_handle()) == -1)) {
- OF_printf("OF_alloc_virt: cannot get mmuh\r\n");
+ printf("OF_alloc_virt: cannot get mmuh\r\n");
return -1LL;
}
#endif
@@ -514,17 +512,17 @@ int align;
args.align = align;
args.len = len;
args.retaddr = ADR2CELL(&retaddr);
- if(openfirmware(&args) != 0)
+ if (openfirmware(&args) != 0)
return -1LL;
return (vaddr_t)args.retaddr;
}
-/*
+/*
* Release some address space to the prom
*
* Only works while the prom is actively mapping us.
*/
-int
+static int
OF_free_virt(vaddr, len)
vaddr_t vaddr;
int len;
@@ -541,7 +539,7 @@ int len;
#ifdef __notyet
if (mmuh == -1 && ((mmuh = get_mmu_handle()) == -1)) {
- OF_printf("OF_claim_virt: cannot get mmuh\r\n");
+ printf("OF_free_virt: cannot get mmuh\r\n");
return -1;
}
#endif
@@ -556,48 +554,12 @@ int len;
}
-/*
- * Unmap some address space
- *
- * Only works while the prom is actively mapping us.
- */
-int
-OF_unmap_virt(vaddr, len)
-vaddr_t vaddr;
-int len;
-{
- struct {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- cell_t method;
- cell_t ihandle;
- cell_t len;
- cell_t vaddr;
- } args;
-
-#ifdef __notyet
- if (mmuh == -1 && ((mmuh = get_mmu_handle()) == -1)) {
- OF_printf("OF_claim_virt: cannot get mmuh\r\n");
- return -1;
- }
-#endif
- args.name = ADR2CELL("call-method");
- args.nargs = 4;
- args.nreturns = 0;
- args.method = ADR2CELL("unmap");
- args.ihandle = HDL2CELL(mmuh);
- args.vaddr = ADR2CELL(vaddr);
- args.len = len;
- return openfirmware(&args);
-}
-
-/*
+/*
* Have prom map in some memory
*
* Only works while the prom is actively mapping us.
*/
-vaddr_t
+static vaddr_t
OF_map_phys(paddr, size, vaddr, mode)
paddr_t paddr;
off_t size;
@@ -621,7 +583,7 @@ int mode;
#ifdef __notyet
if (mmuh == -1 && ((mmuh = get_mmu_handle()) == -1)) {
- OF_printf("OF_map_phys: cannot get mmuh\r\n");
+ printf("OF_map_phys: cannot get mmuh\r\n");
return 0LL;
}
#endif
@@ -644,12 +606,12 @@ int mode;
}
-/*
+/*
* Request some RAM from the prom
*
* Only works while the prom is actively mapping us.
*/
-paddr_t
+static paddr_t
OF_alloc_phys(len, align)
int len;
int align;
@@ -669,7 +631,7 @@ int align;
#ifdef __notyet
if (memh == -1 && ((memh = get_memory_handle()) == -1)) {
- OF_printf("OF_alloc_phys: cannot get memh\r\n");
+ printf("OF_alloc_phys: cannot get memh\r\n");
return -1LL;
}
#endif
@@ -680,63 +642,18 @@ int align;
args.ihandle = HDL2CELL(memh);
args.align = align;
args.len = len;
- if(openfirmware(&args) != 0)
+ if (openfirmware(&args) != 0)
return -1LL;
return (paddr_t)CELL2HDQ(args.phys_hi, args.phys_lo);
}
-/*
- * Request some specific RAM from the prom
- *
- * Only works while the prom is actively mapping us.
- */
-paddr_t
-OF_claim_phys(phys, len)
-paddr_t phys;
-int len;
-{
- struct {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- cell_t method;
- cell_t ihandle;
- cell_t align;
- cell_t len;
- cell_t phys_hi;
- cell_t phys_lo;
- cell_t status;
- cell_t res;
- cell_t rphys_hi;
- cell_t rphys_lo;
- } args;
-#ifdef __notyet
- if (memh == -1 && ((memh = get_memory_handle()) == -1)) {
- OF_printf("OF_alloc_phys: cannot get memh\r\n");
- return 0LL;
- }
-#endif
- args.name = ADR2CELL("call-method");
- args.nargs = 6;
- args.nreturns = 4;
- args.method = ADR2CELL("claim");
- args.ihandle = HDL2CELL(memh);
- args.align = 0;
- args.len = len;
- args.phys_hi = HDQ2CELL_HI(phys);
- args.phys_lo = HDQ2CELL_LO(phys);
- if(openfirmware(&args) != 0)
- return 0LL;
- return (paddr_t)CELL2HDQ(args.phys_hi, args.phys_lo);
-}
-
-/*
+/*
* Free some RAM to prom
*
* Only works while the prom is actively mapping us.
*/
-int
+static int
OF_free_phys(phys, len)
paddr_t phys;
int len;
@@ -754,7 +671,7 @@ int len;
#ifdef __notyet
if (memh == -1 && ((memh = get_memory_handle()) == -1)) {
- OF_printf("OF_free_phys: cannot get memh\r\n");
+ printf("OF_free_phys: cannot get memh\r\n");
return -1;
}
#endif
@@ -801,7 +718,7 @@ OF_claim(virt, size, align)
args.align = align;
if (openfirmware(&args) == -1)
return (void *)-1;
- return args.baseaddr;
+ return (void *)args.baseaddr;
#else
/*
* Sun Ultra machines run the firmware with VM enabled,
@@ -813,28 +730,34 @@ OF_claim(virt, size, align)
void * newvirt = NULL;
if (virt == NULL) {
- if ((virt = (void *)OF_alloc_virt(size, align)) == (void *)-1) {
- printf("OF_alloc_virt(%d,%d) failed w/%x\n", size, align, virt);
- return (void *)-1;
+ virt = (void *)OF_alloc_virt(size, align);
+ if (virt == (void *)-1LL) {
+ printf("OF_alloc_virt(%d,%d) failed w/%x\n",
+ size, align, virt);
+ return virt;
}
} else {
- if ((newvirt = (void *)OF_claim_virt((vaddr_t)virt, size)) == (void *)-1) {
- printf("OF_claim_virt(%x,%d) failed w/%x\n", virt, size, newvirt);
- return (void *)-1;
+ newvirt = (void *)OF_claim_virt((vaddr_t)virt, size);
+ if (newvirt == (void *)-1LL) {
+ printf("OF_claim_virt(%x,%d) failed w/%x\n",
+ virt, size, newvirt);
+ return newvirt;
}
+ virt = newvirt;
}
- if ((paddr = OF_alloc_phys(size, align)) == -1) {
+ if ((paddr = OF_alloc_phys(size, align)) == (paddr_t)-1LL) {
printf("OF_alloc_phys(%d,%d) failed\n", size, align);
OF_free_virt((vaddr_t)virt, size);
- return (void *)-1;
+ return (void *)-1LL;
}
if (OF_map_phys(paddr, size, (vaddr_t)virt, -1) == -1) {
- printf("OF_map_phys(%x,%d,%x,%d) failed\n", paddr, size, virt, -1);
+ printf("OF_map_phys(%x,%d,%x,%d) failed\n",
+ paddr, size, virt, -1);
OF_free_phys((paddr_t)paddr, size);
OF_free_virt((vaddr_t)virt, size);
- return (void *)-1;
+ return (void *)-1LL;
}
- return (void *)virt;
+ return virt;
#endif
}