diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2006-08-31 21:28:36 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2006-08-31 21:28:36 +0000 |
commit | da4c4c5ee32dc553c207ad78995cddf836420749 (patch) | |
tree | ee48ad5818a34fea2b2232f578521c0139b5b0b5 | |
parent | c9caf22a5b753a554d8369d5bad5b05d872511ed (diff) |
Fix handling of 64-bit quantities in Open Firmware's client interface.
Spotted by tsi@, and shamelessly stolen from his diff. Fixes several
UltraSPARC-III machines wich have more than one memory bank filled.
ok deraadt@
-rw-r--r-- | sys/arch/sparc64/include/openfirm.h | 7 | ||||
-rw-r--r-- | sys/arch/sparc64/sparc64/ofw_machdep.c | 33 | ||||
-rw-r--r-- | sys/arch/sparc64/stand/ofwboot/Locore.c | 32 |
3 files changed, 35 insertions, 37 deletions
diff --git a/sys/arch/sparc64/include/openfirm.h b/sys/arch/sparc64/include/openfirm.h index 9b8433a9617..53bc42d29b6 100644 --- a/sys/arch/sparc64/include/openfirm.h +++ b/sys/arch/sparc64/include/openfirm.h @@ -1,4 +1,4 @@ -/* $OpenBSD: openfirm.h,v 1.5 2004/08/08 21:04:44 miod Exp $ */ +/* $OpenBSD: openfirm.h,v 1.6 2006/08/31 21:28:34 kettenis Exp $ */ /* $NetBSD: openfirm.h,v 1.8 2001/07/20 00:07:14 eeh Exp $ */ /* @@ -42,6 +42,11 @@ typedef u_int64_t cell_t; #define HDL2CELL(x) (cell_t)(u_int)(int)(x) #define ADR2CELL(x) (cell_t)(x) +#define HDQ2CELL_HI(x) (cell_t)(0) +#define HDQ2CELL_LO(x) (cell_t)(x) + +#define CELL2HDQ(hi, lo) (lo) + int OF_test (char *service); int OF_test_method (int handle, char *method); int OF_getproplen (int handle, char *prop); diff --git a/sys/arch/sparc64/sparc64/ofw_machdep.c b/sys/arch/sparc64/sparc64/ofw_machdep.c index a1167d98c61..2120ebca593 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.14 2005/07/01 01:12:04 brad Exp $ */ +/* $OpenBSD: ofw_machdep.c,v 1.15 2006/08/31 21:28:35 kettenis Exp $ */ /* $NetBSD: ofw_machdep.c,v 1.16 2001/07/20 00:07:14 eeh Exp $ */ /* @@ -163,7 +163,7 @@ prom_vtop(vaddr) (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)((((paddr_t)args.phys_hi)<<32)|(u_int32_t)args.phys_lo); + return (paddr_t)CELL2HDQ(args.phys_hi, args.phys_lo); } /* @@ -216,7 +216,6 @@ prom_alloc_virt(len, align) int len; int align; { - static int retaddr; struct { cell_t name; cell_t nargs; @@ -240,10 +239,9 @@ prom_alloc_virt(len, align) args.ihandle = HDL2CELL(mmuh); args.align = align; args.len = len; - args.retaddr = ADR2CELL(&retaddr); if (openfirmware(&args) != 0) return -1; - return retaddr; /* Kluge till we go 64-bit */ + return (vaddr_t)args.retaddr; } /* @@ -354,14 +352,14 @@ prom_map_phys(paddr, size, vaddr, mode) args.mode = mode; args.size = size; args.vaddr = ADR2CELL(vaddr); - args.phys_hi = HDL2CELL(paddr>>32); - args.phys_lo = HDL2CELL(paddr); + args.phys_hi = HDQ2CELL_HI(paddr); + args.phys_lo = HDQ2CELL_LO(paddr); if (openfirmware(&args) == -1) return -1; if (args.status) return -1; - return args.retaddr; + return (int)args.retaddr; } @@ -401,7 +399,7 @@ prom_alloc_phys(len, align) args.len = len; if (openfirmware(&args) != 0) return -1; - return (paddr_t)((((paddr_t)args.phys_hi)<<32)|(u_int32_t)args.phys_lo); + return (paddr_t)CELL2HDQ(args.phys_hi, args.phys_lo); } /* @@ -440,11 +438,11 @@ prom_claim_phys(phys, len) args.ihandle = HDL2CELL(memh); args.align = 0; args.len = len; - args.phys_hi = HDL2CELL(phys>>32); - args.phys_lo = HDL2CELL(phys); + args.phys_hi = HDQ2CELL_HI(phys); + args.phys_lo = HDQ2CELL_LO(phys); if (openfirmware(&args) != 0) return -1; - return (paddr_t)((((paddr_t)args.rphys_hi)<<32)|(u_int32_t)args.rphys_lo); + return (paddr_t)CELL2HDQ(args.rphys_hi, args.rphys_lo); } /* @@ -478,8 +476,8 @@ prom_free_phys(phys, len) args.method = ADR2CELL(&"release"); args.ihandle = HDL2CELL(memh); args.len = len; - args.phys_hi = HDL2CELL(phys>>32); - args.phys_lo = HDL2CELL(phys); + args.phys_hi = HDQ2CELL_HI(phys); + args.phys_lo = HDQ2CELL_LO(phys); return openfirmware(&args); } @@ -537,10 +535,9 @@ prom_get_msgbuf(len, align) args.len = len; args.align = align; args.status = -1; - if (openfirmware(&args) == 0 && args.status == 0) { - return (((paddr_t)args.phys_hi<<32)| - (u_int32_t)args.phys_lo); - } else prom_printf("prom_get_msgbuf: SUNW,retain failed\r\n"); + if (openfirmware(&args) == 0 && args.status == 0) + return (paddr_t)CELL2HDQ(args.phys_hi, args.phys_lo); + prom_printf("prom_get_msgbuf: SUNW,retain failed\r\n"); } else prom_printf("prom_get_msgbuf: test-method failed\r\n"); } else prom_printf("prom_get_msgbuf: test failed\r\n"); /* Allocate random memory -- page zero avail?*/ diff --git a/sys/arch/sparc64/stand/ofwboot/Locore.c b/sys/arch/sparc64/stand/ofwboot/Locore.c index e06f9412bff..ed259c11045 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.5 2002/10/12 01:09:44 krw Exp $ */ +/* $OpenBSD: Locore.c,v 1.6 2006/08/31 21:28:35 kettenis Exp $ */ /* $NetBSD: Locore.c,v 1.1 2000/08/20 14:58:36 mrg Exp $ */ /* @@ -324,8 +324,8 @@ OF_seek(handle, pos) 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; } @@ -474,7 +474,7 @@ int len; args.vaddr = ADR2CELL(vaddr); if(openfirmware(&args) != 0) return -1LL; - return args.retaddr; /* Kluge till we go 64-bit */ + return args.retaddr; } /* @@ -510,13 +510,13 @@ int align; args.nargs = 4; args.nreturns = 2; args.method = ADR2CELL("claim"); - args.ihandle = mmuh; + args.ihandle = HDL2CELL(mmuh); args.align = align; args.len = len; args.retaddr = ADR2CELL(&retaddr); if(openfirmware(&args) != 0) return -1LL; - return (vaddr_t)args.retaddr; /* Kluge till we go 64-bit */ + return (vaddr_t)args.retaddr; } /* @@ -633,8 +633,8 @@ int mode; args.mode = mode; args.size = size; args.vaddr = ADR2CELL(vaddr); - args.paddr_hi = ADR2CELL(paddr>>32); - args.paddr_lo = ADR2CELL(paddr); + args.paddr_hi = HDQ2CELL_HI(paddr); + args.paddr_lo = HDQ2CELL_LO(paddr); if (openfirmware(&args) == -1) return -1; @@ -654,7 +654,6 @@ OF_alloc_phys(len, align) int len; int align; { - paddr_t paddr; struct { cell_t name; cell_t nargs; @@ -683,8 +682,7 @@ int align; args.len = len; if(openfirmware(&args) != 0) return -1LL; - paddr = (paddr_t)(args.phys_hi<<32)|((unsigned int)(args.phys_lo)); - return paddr; /* Kluge till we go 64-bit */ + return (paddr_t)CELL2HDQ(args.phys_hi, args.phys_lo); } /* @@ -697,7 +695,6 @@ OF_claim_phys(phys, len) paddr_t phys; int len; { - paddr_t paddr; struct { cell_t name; cell_t nargs; @@ -727,12 +724,11 @@ int len; args.ihandle = HDL2CELL(memh); args.align = 0; args.len = len; - args.phys_hi = HDL2CELL(phys>>32); - args.phys_lo = HDL2CELL(phys); + args.phys_hi = HDQ2CELL_HI(phys); + args.phys_lo = HDQ2CELL_LO(phys); if(openfirmware(&args) != 0) return 0LL; - paddr = (paddr_t)(args.rphys_hi<<32)|((unsigned int)(args.rphys_lo)); - return paddr; + return (paddr_t)CELL2HDQ(args.phys_hi, args.phys_lo); } /* @@ -768,8 +764,8 @@ int len; args.method = ADR2CELL("release"); args.ihandle = HDL2CELL(memh); args.len = len; - args.phys_hi = HDL2CELL(phys>>32); - args.phys_lo = HDL2CELL(phys); + args.phys_hi = HDQ2CELL_HI(phys); + args.phys_lo = HDQ2CELL_LO(phys); return openfirmware(&args); } |