From ae67dbc85d8a9370168b1cef0346d96c539f8b48 Mon Sep 17 00:00:00 2001 From: tsubai Date: Sun, 10 Jan 1999 10:24:16 +0000 Subject: [PATCH] Fix void * arithmetic. --- sys/arch/powerpc/powerpc/copyinstr.c | 8 +++--- sys/arch/powerpc/powerpc/copyoutstr.c | 10 ++++--- sys/arch/powerpc/powerpc/openfirm.c | 38 ++++++++++++++------------- sys/arch/powerpc/powerpc/pmap.c | 4 +-- sys/arch/powerpc/powerpc/trap.c | 34 +++++++++++++----------- 5 files changed, 52 insertions(+), 42 deletions(-) diff --git a/sys/arch/powerpc/powerpc/copyinstr.c b/sys/arch/powerpc/powerpc/copyinstr.c index e8a2ea46dff7..fdaee784adec 100644 --- a/sys/arch/powerpc/powerpc/copyinstr.c +++ b/sys/arch/powerpc/powerpc/copyinstr.c @@ -1,4 +1,4 @@ -/* $NetBSD: copyinstr.c,v 1.1 1996/09/30 16:34:42 ws Exp $ */ +/* $NetBSD: copyinstr.c,v 1.2 1999/01/10 10:24:16 tsubai Exp $ */ /*- * Copyright (C) 1995 Wolfgang Solfrank. @@ -32,23 +32,25 @@ */ #include #include +#include /* * Emulate copyinstr. */ int copyinstr(udaddr, kaddr, len, done) - void *udaddr; + const void *udaddr; void *kaddr; size_t len; size_t *done; { int c; + const u_char *up = udaddr; u_char *kp = kaddr; int l; for (l = 0; len-- > 0; l++) { - if ((c = fubyte(udaddr++)) < 0) { + if ((c = fubyte(up++)) < 0) { *done = l; return EACCES; } diff --git a/sys/arch/powerpc/powerpc/copyoutstr.c b/sys/arch/powerpc/powerpc/copyoutstr.c index 730f16a01d67..4ce4315912ea 100644 --- a/sys/arch/powerpc/powerpc/copyoutstr.c +++ b/sys/arch/powerpc/powerpc/copyoutstr.c @@ -1,4 +1,4 @@ -/* $NetBSD: copyoutstr.c,v 1.1 1996/09/30 16:34:42 ws Exp $ */ +/* $NetBSD: copyoutstr.c,v 1.2 1999/01/10 10:24:16 tsubai Exp $ */ /*- * Copyright (C) 1995 Wolfgang Solfrank. @@ -32,22 +32,24 @@ */ #include #include +#include /* * Emulate copyoutstr. */ int copyoutstr(kaddr, udaddr, len, done) - void *kaddr; + const void *kaddr; void *udaddr; size_t len; size_t *done; { - u_char *kp = kaddr; + const u_char *kp = kaddr; + u_char *up = udaddr; int l; for (l = 0; len-- > 0; l++) { - if (subyte(udaddr++, *kp) < 0) { + if (subyte(up++, *kp) < 0) { *done = l; return EACCES; } diff --git a/sys/arch/powerpc/powerpc/openfirm.c b/sys/arch/powerpc/powerpc/openfirm.c index 0e5a2510c7b7..d2642e743b4a 100644 --- a/sys/arch/powerpc/powerpc/openfirm.c +++ b/sys/arch/powerpc/powerpc/openfirm.c @@ -1,4 +1,4 @@ -/* $NetBSD: openfirm.c,v 1.3 1998/11/15 19:53:25 tsubai Exp $ */ +/* $NetBSD: openfirm.c,v 1.4 1999/01/10 10:24:16 tsubai Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -57,7 +57,7 @@ OF_peer(phandle) 1, 1, }; - + ofw_stack(); args.phandle = phandle; if (openfirmware(&args) == -1) @@ -80,7 +80,7 @@ OF_child(phandle) 1, 1, }; - + ofw_stack(); args.phandle = phandle; if (openfirmware(&args) == -1) @@ -103,7 +103,7 @@ OF_parent(phandle) 1, 1, }; - + ofw_stack(); args.phandle = phandle; if (openfirmware(&args) == -1) @@ -212,7 +212,7 @@ OF_finddevice(name) "finddevice", 1, 1, - }; + }; ofw_stack(); args.device = name; @@ -274,7 +274,7 @@ OF_package_to_path(phandle, buf, buflen) 3, 1, }; - + ofw_stack(); if (buflen > NBPG) return -1; @@ -316,7 +316,7 @@ OF_call_method(method, ihandle, nargs, nreturns, va_alist) 1, }; int *ip, n; - + if (nargs > 6) return -1; args.nargs = nargs + 2; @@ -362,7 +362,7 @@ OF_call_method_1(method, ihandle, nargs, va_alist) 2, }; int *ip, n; - + if (nargs > 6) return -1; args.nargs = nargs + 2; @@ -396,7 +396,7 @@ OF_open(dname) 1, }; int l; - + ofw_stack(); if ((l = strlen(dname)) >= NBPG) return -1; @@ -427,7 +427,7 @@ OF_close(handle) openfirmware(&args); } -/* +/* * This assumes that character devices don't read in multiples of NBPG. */ int @@ -450,17 +450,18 @@ OF_read(handle, addr, len) 1, }; int l, act = 0; - + char *p = addr; + ofw_stack(); args.ihandle = handle; args.addr = OF_buf; - for (; len > 0; len -= l, addr += l) { + for (; len > 0; len -= l, p += l) { l = min(NBPG, len); args.len = l; if (openfirmware(&args) == -1) return -1; if (args.actual > 0) { - ofbcopy(OF_buf, addr, args.actual); + ofbcopy(OF_buf, p, args.actual); act += args.actual; } if (args.actual < l) @@ -492,13 +493,14 @@ OF_write(handle, addr, len) 1, }; int l, act = 0; - + char *p = addr; + ofw_stack(); args.ihandle = handle; args.addr = OF_buf; - for (; len > 0; len -= l, addr += l) { + for (; len > 0; len -= l, p += l) { l = min(NBPG, len); - ofbcopy(addr, OF_buf, l); + ofbcopy(p, OF_buf, l); args.len = l; if (openfirmware(&args) == -1) return -1; @@ -551,7 +553,7 @@ OF_boot(bootspec) 0, }; int l; - + if ((l = strlen(bootspec)) >= NBPG) panic("OF_boot"); ofw_stack(); @@ -633,7 +635,7 @@ ofbcopy(src, dst, len) if (src == dst) return; - + /* * Do some optimization? XXX */ diff --git a/sys/arch/powerpc/powerpc/pmap.c b/sys/arch/powerpc/powerpc/pmap.c index 36e38a863efd..ff801ad43c4f 100644 --- a/sys/arch/powerpc/powerpc/pmap.c +++ b/sys/arch/powerpc/powerpc/pmap.c @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.10 1998/10/13 11:30:47 tsubai Exp $ */ +/* $NetBSD: pmap.c,v 1.11 1999/01/10 10:24:17 tsubai Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -395,7 +395,7 @@ pmap_bootstrap(kernelstart, kernelend) if (s < mp1->start) break; if (mp1 < mp) { - bcopy(mp1, mp1 + 1, (void *)mp - (void *)mp1); + bcopy(mp1, mp1 + 1, (char *)mp - (char *)mp1); mp1->start = s; mp1->size = sz; } else { diff --git a/sys/arch/powerpc/powerpc/trap.c b/sys/arch/powerpc/powerpc/trap.c index e7b608ab8eee..7c6556378738 100644 --- a/sys/arch/powerpc/powerpc/trap.c +++ b/sys/arch/powerpc/powerpc/trap.c @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.14 1998/11/26 21:06:21 thorpej Exp $ */ +/* $NetBSD: trap.c,v 1.15 1999/01/10 10:24:17 tsubai Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -396,21 +396,23 @@ copyin(udaddr, kaddr, len) void *kaddr; size_t len; { - void *p; + const char *up = udaddr; + char *kp = kaddr; + char *p; size_t l; faultbuf env; if (setfault(env)) return EFAULT; while (len > 0) { - p = USER_ADDR + ((u_int)udaddr & ~SEGMENT_MASK); - l = (USER_ADDR + SEGMENT_LENGTH) - p; + p = (char *)USER_ADDR + ((u_int)up & ~SEGMENT_MASK); + l = ((char *)USER_ADDR + SEGMENT_LENGTH) - p; if (l > len) l = len; - setusr(curpcb->pcb_pm->pm_sr[(u_int)udaddr >> ADDR_SR_SHFT]); - bcopy(p, kaddr, l); - udaddr += l; - kaddr += l; + setusr(curpcb->pcb_pm->pm_sr[(u_int)up >> ADDR_SR_SHFT]); + bcopy(p, kp, l); + up += l; + kp += l; len -= l; } curpcb->pcb_onfault = 0; @@ -423,21 +425,23 @@ copyout(kaddr, udaddr, len) void *udaddr; size_t len; { - void *p; + const char *kp = kaddr; + char *up = udaddr; + char *p; size_t l; faultbuf env; if (setfault(env)) return EFAULT; while (len > 0) { - p = USER_ADDR + ((u_int)udaddr & ~SEGMENT_MASK); - l = (USER_ADDR + SEGMENT_LENGTH) - p; + p = (char *)USER_ADDR + ((u_int)up & ~SEGMENT_MASK); + l = ((char *)USER_ADDR + SEGMENT_LENGTH) - p; if (l > len) l = len; - setusr(curpcb->pcb_pm->pm_sr[(u_int)udaddr >> ADDR_SR_SHFT]); - bcopy(kaddr, p, l); - udaddr += l; - kaddr += l; + setusr(curpcb->pcb_pm->pm_sr[(u_int)up >> ADDR_SR_SHFT]); + bcopy(kp, p, l); + up += l; + kp += l; len -= l; } curpcb->pcb_onfault = 0;