diff options
| author | simonb <simonb@NetBSD.org> | 2006-05-12 06:05:22 +0000 |
|---|---|---|
| committer | simonb <simonb@NetBSD.org> | 2006-05-12 06:05:22 +0000 |
| commit | c1924fc56dcccb7fd5481e73246263e0ceffe056 (patch) | |
| tree | 2b375fd8674c783ffcbe68acfaea70194aa1765a /sys | |
| parent | 4fb473c54c761f2cf032479259a4c2611b8d593a (diff) | |
KNF, ANSIfy, white space clean up.
Diffstat (limited to 'sys')
56 files changed, 2354 insertions, 2530 deletions
diff --git a/sys/arch/pc532/conf/std.pc532 b/sys/arch/pc532/conf/std.pc532 index 5b77c95fcc3..8949692767c 100644 --- a/sys/arch/pc532/conf/std.pc532 +++ b/sys/arch/pc532/conf/std.pc532 @@ -1,15 +1,15 @@ -# $NetBSD: std.pc532,v 1.18 2005/12/11 12:18:31 christos Exp $ +# $NetBSD: std.pc532,v 1.19 2006/05/12 06:05:22 simonb Exp $ # # Standard configuration info for NetBSD/pc532. machine pc532 include "conf/std" # MI standard options -mainbus0 at root -clock0 at mainbus0 # system timer +mainbus0 at root +clock0 at mainbus0 # system timer rtc0 at mainbus0 # realtime clock ncr0 at mainbus0 # ncr SCSI driver -scsibus0 at ncr? # ncr SCSI bus +scsibus0 at ncr? # ncr SCSI bus #aic* at mainbus0 # aic SCSI driver #scsibus1 at aic? # aic SCSI bus #XXX Wildcards don't work with holes at the moment, diff --git a/sys/arch/pc532/dev/aic.c b/sys/arch/pc532/dev/aic.c index 15001131ee1..faf6f406560 100644 --- a/sys/arch/pc532/dev/aic.c +++ b/sys/arch/pc532/dev/aic.c @@ -1,4 +1,4 @@ -/* $NetBSD: aic.c,v 1.11 2005/12/11 12:18:31 christos Exp $ */ +/* $NetBSD: aic.c,v 1.12 2006/05/12 06:05:22 simonb Exp $ */ /* Written by Phil Nelson for the pc532. Used source with the following * copyrights as a model. @@ -49,7 +49,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: aic.c,v 1.11 2005/12/11 12:18:31 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: aic.c,v 1.12 2006/05/12 06:05:22 simonb Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -97,13 +97,17 @@ struct scsi_switch dp_switch = { 0, 0, 0 }; -int aicprobe(struct pc532_device *dvp) +int +aicprobe(struct pc532_device *dvp) { - return (0); /* All pc532s should have one, but it is not working now. */ + + /* All pc532s should have one, but it is not working now. */ + return (0); } -int aicattach(struct pc532_device *dvp) +int +aicattach(struct pc532_device *dvp) { int r; @@ -113,7 +117,8 @@ int aicattach(struct pc532_device *dvp) return(r); } -void aicminphys(struct buf *bp) +void +aicminphys(struct buf *bp) { if(bp->b_bcount > ((AIC_NSEG - 1) * PAGE_SIZE)) @@ -121,8 +126,10 @@ void aicminphys(struct buf *bp) minphys(bp); } -long int aic_adapter_info(int unit) +long int +aic_adapter_info(int unit) { + return (1); /* only 1 outstanding request. */ } @@ -131,8 +138,10 @@ long int aic_adapter_info(int unit) struct scsipi_xfer *cur_xs; -int aic_scsi_cmd(struct scsipi_xfer *xs) +int +aic_scsi_cmd(struct scsipi_xfer *xs) { + printf ("aic_scsi_cmd: ... \n"); cur_xs = xs; @@ -141,4 +150,5 @@ printf ("aic_scsi_cmd: ... \n"); void aic_intr (struct intrframe frame) { + } diff --git a/sys/arch/pc532/dev/lpt.c b/sys/arch/pc532/dev/lpt.c index 257f88c5685..f8ce161501c 100644 --- a/sys/arch/pc532/dev/lpt.c +++ b/sys/arch/pc532/dev/lpt.c @@ -1,4 +1,4 @@ -/* $NetBSD: lpt.c,v 1.43 2006/03/28 17:38:26 thorpej Exp $ */ +/* $NetBSD: lpt.c,v 1.44 2006/05/12 06:05:22 simonb Exp $ */ /* * Copyright (c) 1994 Matthias Pfaller. @@ -60,7 +60,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: lpt.c,v 1.43 2006/03/28 17:38:26 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lpt.c,v 1.44 2006/05/12 06:05:22 simonb Exp $"); #include "opt_inet.h" @@ -183,30 +183,30 @@ struct lpt_softc { #define LPTFLAGS(s) (minor(s) & 0xe0) #define LPTSOFTC(n) ((struct lpt_softc *) lpt_cd.cd_devs[n]) -static int lptmatch __P((struct device *, struct cfdata *, void *aux)); -static void lptattach __P((struct device *, struct device *, void *)); -static void lptintr __P((void *)); -static int notready __P((u_char, struct lpt_softc *)); -static void lptout __P((void *)); -static int pushbytes __P((struct lpt_softc *)); +static int lptmatch(struct device *, struct cfdata *, void *aux); +static void lptattach(struct device *, struct device *, void *); +static void lptintr(void *); +static int notready(u_char, struct lpt_softc *); +static void lptout(void *); +static int pushbytes(struct lpt_softc *); #if defined(INET) && defined(PLIP) /* Functions for the plip# interface */ -static void plipattach __P((struct lpt_softc *,int)); -static void plipinput __P((struct lpt_softc *)); -static int plipioctl __P((struct ifnet *, u_long, caddr_t)); -static void plipoutput __P((void *)); +static void plipattach(struct lpt_softc *,int); +static void plipinput(struct lpt_softc *); +static int plipioctl(struct ifnet *, u_long, caddr_t); +static void plipoutput(void *); #ifndef __OPTIMIZE__ static #endif - int plipreceive __P((volatile struct i8255 *, u_char *, int)); -static void pliprxenable __P((void *)); -static void plipsoftint __P((void *)); -static void plipstart __P((struct ifnet *)); + int plipreceive(volatile struct i8255 *, u_char *, int); +static void pliprxenable(void *); +static void plipsoftint(void *); +static void plipstart(struct ifnet *); #ifndef __OPTIMIZE__ static #endif - int pliptransmit __P((volatile struct i8255 *, u_char *, int)); + int pliptransmit(volatile struct i8255 *, u_char *, int); #endif CFATTACH_DECL(lpt, sizeof(struct lpt_softc), @@ -225,10 +225,7 @@ const struct cdevsw lpt_cdevsw = { }; static int -lptmatch(parent, cf, aux) - struct device *parent; - struct cfdata *cf; - void *aux; +lptmatch(struct device *parent, struct cfdata *cf, void *aux) { struct confargs *ca = aux; volatile struct i8255 *i8255 = @@ -262,9 +259,7 @@ lptmatch(parent, cf, aux) } static void -lptattach(parent, self, aux) - struct device *parent, *self; - void *aux; +lptattach(struct device *parent, struct device *self, void *aux) { struct confargs *ca = aux; struct lpt_softc *sc = (struct lpt_softc *) self; @@ -294,11 +289,7 @@ lptattach(parent, self, aux) * Reset the printer, then wait until it's selected and not busy. */ int -lptopen(dev, flag, mode, l) - dev_t dev; - int flag; - int mode; - struct lwp *l; +lptopen(dev_t dev, int flag, int mode, struct lwp *l) { struct lpt_softc *sc; volatile struct i8255 *i8255; @@ -361,19 +352,19 @@ lptopen(dev, flag, mode, l) } static int -notready(status, sc) - u_char status; - struct lpt_softc *sc; +notready(u_char status, struct lpt_softc *sc) { status ^= LPT_INVERT; if (status != sc->sc_status) { if (status & LPC_NOPAPER) - log(LOG_NOTICE, "%s: out of paper\n", sc->sc_dev.dv_xname); + log(LOG_NOTICE, "%s: out of paper\n", + sc->sc_dev.dv_xname); if (status & LPC_ONLINE) log(LOG_NOTICE, "%s: offline\n", sc->sc_dev.dv_xname); if (status & LPC_NERROR) - log(LOG_NOTICE, "%s: output error\n", sc->sc_dev.dv_xname); + log(LOG_NOTICE, "%s: output error\n", + sc->sc_dev.dv_xname); if (status & LPC_NACK) log(LOG_NOTICE, "%s: NACK low\n", sc->sc_dev.dv_xname); if (status & LPC_NBUSY) @@ -384,9 +375,9 @@ notready(status, sc) } static void -lptout(arg) - void *arg; +lptout(void *arg) { + struct lpt_softc *sc = arg; if (sc->sc_count > 0) sc->sc_i8255->port_control = LPT_IRQENABLE; @@ -396,11 +387,7 @@ lptout(arg) * Close the device, and free the local line buffer. */ int -lptclose(dev, flag, mode, l) - dev_t dev; - int flag; - int mode; - struct lwp *l; +lptclose(dev_t dev, int flag, int mode, struct lwp *l) { struct lpt_softc *sc = LPTSOFTC(LPTUNIT(dev)); @@ -415,8 +402,7 @@ lptclose(dev, flag, mode, l) } static int -pushbytes(sc) - struct lpt_softc *sc; +pushbytes(struct lpt_softc *sc) { volatile struct i8255 *i8255 = sc->sc_i8255; int error; @@ -435,10 +421,7 @@ pushbytes(sc) * get the chars moved to the output queue. */ int -lptwrite(dev, uio, flags) - dev_t dev; - struct uio *uio; - int flags; +lptwrite(dev_t dev, struct uio *uio, int flags) { struct lpt_softc *sc = LPTSOFTC(LPTUNIT(dev)); size_t n; @@ -467,8 +450,7 @@ lptwrite(dev, uio, flags) * another char. */ static void -lptintr(arg) - void *arg; +lptintr(void *arg) { struct lpt_softc *sc = arg; volatile struct i8255 *i8255 = sc->sc_i8255; @@ -509,12 +491,7 @@ lptintr(arg) } int -lptioctl(dev, cmd, data, flag, l) - dev_t dev; - u_long cmd; - caddr_t data; - int flag; - struct lwp *l; +lptioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct lwp *l) { int error = 0; @@ -529,12 +506,10 @@ lptioctl(dev, cmd, data, flag, l) #if defined(INET) && defined(PLIP) static void -plipattach(sc, unit) - struct lpt_softc *sc; - int unit; +plipattach(struct lpt_softc *sc, int unit) { struct ifnet *ifp = &sc->sc_ethercom.ec_if; - u_int8_t myaddr[ETHER_ADDR_LEN]; + uint8_t myaddr[ETHER_ADDR_LEN]; callout_init(&sc->sc_plipout_ch); callout_init(&sc->sc_pliprx_ch); @@ -560,10 +535,7 @@ plipattach(sc, unit) * Process an ioctl request. */ static int -plipioctl(ifp, cmd, data) - struct ifnet *ifp; - u_long cmd; - caddr_t data; +plipioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { struct proc *p = curproc; /* XXX ktrace-lwp */ struct lpt_softc *sc = (struct lpt_softc *)(ifp->if_softc); @@ -639,8 +611,8 @@ plipioctl(ifp, cmd, data) break; case SIOCSIFMTU: - if ((error = suser(p->p_ucred, &p->p_acflag))) - return(error); + if ((error = suser(p->p_ucred, &p->p_acflag))) + return(error); if (ifp->if_mtu != ifr->ifr_mtu) { ifp->if_mtu = ifr->ifr_mtu; if (sc->sc_ifbuf) { @@ -659,8 +631,7 @@ plipioctl(ifp, cmd, data) } static void -plipsoftint(arg) - void *arg; +plipsoftint(void *arg) { struct lpt_softc *sc = arg; int pending = sc->sc_pending; @@ -676,7 +647,8 @@ plipsoftint(arg) } #ifdef __OPTIMIZE__ -int plipreceive __P((volatile struct i8255 *, u_char *, int)) +int plipreceive(volatile struct i8255 *, u_char *, int) + __asm("plipreceive"); __asm(" \ plipreceive: \ @@ -732,10 +704,7 @@ plipreceive: \ "); #else static int -plipreceive(i8255, buf, len) - volatile struct i8255 *i8255; - u_char *buf; - int len; +plipreceive(volatile struct i8255 *i8255, u_char *buf, int len) { int i; u_char cksum = 0, c; @@ -757,17 +726,16 @@ plipreceive(i8255, buf, len) #endif static void -pliprxenable(arg) - void *arg; +pliprxenable(void *arg) { + struct lpt_softc *sc = arg; volatile struct i8255 *i8255 = sc->sc_i8255; i8255->port_a |= LPA_ACKENABLE | LPA_ACTIVE; } static void -plipinput(sc) - struct lpt_softc *sc; +plipinput(struct lpt_softc *sc) { struct ifnet *ifp = &sc->sc_ethercom.ec_if; volatile struct i8255 *i8255 = sc->sc_i8255; @@ -879,7 +847,8 @@ err: } #ifdef __OPTIMIZE__ -int pliptransmit __P((volatile struct i8255 *, u_char *, int)) +int pliptransmit(volatile struct i8255 *, u_char *, int) + __asm("pliptransmit"); __asm(" \ pliptransmit: \ @@ -939,10 +908,7 @@ pliptransmit: \ "); #else static int -pliptransmit(i8255, buf, len) - volatile struct i8255 *i8255; - u_char *buf; - int len; +pliptransmit(volatile struct i8255 *i8255, u_char *buf, int len) { int i; u_char cksum = 0, c; @@ -968,17 +934,16 @@ pliptransmit(i8255, buf, len) * Setup output on interface. */ static void -plipstart(ifp) - struct ifnet *ifp; +plipstart(struct ifnet *ifp) { + struct lpt_softc *sc = (struct lpt_softc *)(ifp->if_softc); sc->sc_pending |= PLIP_OPENDING; softintr(sc->sc_ifsoftint); } static void -plipoutput(arg) - void *arg; +plipoutput(void *arg) { struct lpt_softc *sc = arg; struct ifnet *ifp = &sc->sc_ethercom.ec_if; @@ -1083,5 +1048,4 @@ retry: i8255->port_a |= LPA_ACKENABLE | LPA_ACTIVE; sc->sc_ifoerrs++; } - #endif diff --git a/sys/arch/pc532/dev/ncr.c b/sys/arch/pc532/dev/ncr.c index e9ccf59f5c3..0e14536b293 100644 --- a/sys/arch/pc532/dev/ncr.c +++ b/sys/arch/pc532/dev/ncr.c @@ -1,4 +1,4 @@ -/* $NetBSD: ncr.c,v 1.54 2006/03/11 14:07:35 simonb Exp $ */ +/* $NetBSD: ncr.c,v 1.55 2006/05/12 06:05:22 simonb Exp $ */ /* * Copyright (c) 1996, 1997 Matthias Pfaller. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ncr.c,v 1.54 2006/03/11 14:07:35 simonb Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ncr.c,v 1.55 2006/05/12 06:05:22 simonb Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -52,13 +52,13 @@ __KERNEL_RCSID(0, "$NetBSD: ncr.c,v 1.54 2006/03/11 14:07:35 simonb Exp $"); /* * Function declarations: */ -static int ncr_pdma_in __P((struct ncr5380_softc *, int, int, u_char *)); -static int ncr_pdma_out __P((struct ncr5380_softc *, int, int, u_char *)); -static void ncr_intr __P((void *)); -static void ncr_attach __P((struct device *, struct device *, void *)); -static int ncr_match __P((struct device *, struct cfdata *, void *)); -static int ncr_ready __P((struct ncr5380_softc *sc)); -static void ncr_wait_not_req __P((struct ncr5380_softc *sc)); +static int ncr_pdma_in(struct ncr5380_softc *, int, int, u_char *); +static int ncr_pdma_out(struct ncr5380_softc *, int, int, u_char *); +static void ncr_intr(void *); +static void ncr_attach(struct device *, struct device *, void *); +static int ncr_match(struct device *, struct cfdata *, void *); +static int ncr_ready(struct ncr5380_softc *sc); +static void ncr_wait_not_req(struct ncr5380_softc *sc); /* * Some constants. @@ -90,10 +90,7 @@ CFATTACH_DECL(ncr, sizeof(struct ncr5380_softc), static int ncr_attached; static int -ncr_match(parent, cf, aux) - struct device *parent; - struct cfdata *cf; - void *aux; +ncr_match(struct device *parent, struct cfdata *cf, void *aux) { struct confargs *ca = aux; @@ -106,9 +103,7 @@ ncr_match(parent, cf, aux) } static void -ncr_attach(parent, self, aux) - struct device *parent, *self; - void *aux; +ncr_attach(struct device *parent, struct device *self, void *aux) { struct confargs *ca = aux; struct ncr5380_softc *sc = (struct ncr5380_softc *) self; @@ -174,8 +169,7 @@ ncr_attach(parent, self, aux) } static void -ncr_intr(arg) - void *arg; +ncr_intr(void *arg) { struct ncr5380_softc *sc = arg; @@ -218,15 +212,14 @@ ncr_intr(arg) #define TIMEOUT 1000000 static inline int -ncr_ready(sc) - struct ncr5380_softc *sc; +ncr_ready(struct ncr5380_softc *sc) { int i; for (i = TIMEOUT; i > 0; i--) { if ((*sc->sci_csr & (SCI_CSR_DREQ | SCI_CSR_PHASE_MATCH)) == (SCI_CSR_DREQ | SCI_CSR_PHASE_MATCH)) - return(1); + return(1); if ((*sc->sci_csr & SCI_CSR_PHASE_MATCH) == 0 || SCI_BUSY(sc) == 0) @@ -237,10 +230,11 @@ ncr_ready(sc) } /* Return zero on success. */ -static inline void ncr_wait_not_req(sc) - struct ncr5380_softc *sc; +static inline void +ncr_wait_not_req(struct ncr5380_softc *sc) { int timo; + for (timo = TIMEOUT; timo; timo--) { if ((*sc->sci_bus_csr & SCI_BUS_REQ) == 0 || (*sc->sci_csr & SCI_CSR_PHASE_MATCH) == 0 || @@ -252,10 +246,7 @@ static inline void ncr_wait_not_req(sc) } static int -ncr_pdma_in(sc, phase, datalen, data) - struct ncr5380_softc *sc; - int phase, datalen; - u_char *data; +ncr_pdma_in(struct ncr5380_softc *sc, int phase, int datalen, u_char *data) { volatile u_char *pdma = (void *)PDMA_ADDRESS; int resid, s; @@ -327,10 +318,7 @@ interrupt: } static int -ncr_pdma_out(sc, phase, datalen, data) - struct ncr5380_softc *sc; - int phase, datalen; - u_char *data; +ncr_pdma_out(struct ncr5380_softc *sc, int phase, int datalen, u_char *data) { u_char *pdma = (void *)PDMA_ADDRESS; int i, s, resid; diff --git a/sys/arch/pc532/dev/scn.c b/sys/arch/pc532/dev/scn.c index 50cec166584..1670ea7a8b7 100644 --- a/sys/arch/pc532/dev/scn.c +++ b/sys/arch/pc532/dev/scn.c @@ -1,4 +1,4 @@ -/* $NetBSD: scn.c,v 1.70 2006/03/29 03:58:48 thorpej Exp $ */ +/* $NetBSD: scn.c,v 1.71 2006/05/12 06:05:22 simonb Exp $ */ /* * Copyright (c) 1991, 1992, 1993 @@ -85,7 +85,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: scn.c,v 1.70 2006/03/29 03:58:48 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: scn.c,v 1.71 2006/05/12 06:05:22 simonb Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -121,18 +121,18 @@ __KERNEL_RCSID(0, "$NetBSD: scn.c,v 1.70 2006/03/29 03:58:48 thorpej Exp $"); static const char scnints[4] = {IR_TTY0, IR_TTY1, IR_TTY2, IR_TTY3}; static const char rxints[4] = {IR_TTY0RDY, IR_TTY1RDY, IR_TTY2RDY, IR_TTY3RDY}; -int scnprobe __P((struct device *, struct cfdata *, void *)); -void scnattach __P((struct device *, struct device *, void *)); -int scnparam __P((struct tty *, struct termios *)); -void scnstart __P((struct tty *)); -void scncnprobe __P((struct consdev *)); -void scncninit __P((struct consdev *)); -int scncngetc __P((void *)); -void scncnputc __P((void *, int)); -void scncnpollc __P((dev_t, int)); -int scninit __P((dev_t, int)); -void scncnreinit __P((void *)); -int scnhwiflow __P((struct tty *, int)); +int scnprobe(struct device *, struct cfdata *, void *); +void scnattach(struct device *, struct device *, void *); +int scnparam(struct tty *, struct termios *); +void scnstart(struct tty *); +void scncnprobe(struct consdev *); +void scncninit(struct consdev *); +int scncngetc(void *); +void scncnputc(void *, int); +void scncnpollc(dev_t, int); +int scninit(dev_t, int); +void scncnreinit(void *); +int scnhwiflow(struct tty *, int); CFATTACH_DECL(scn, sizeof(struct scn_softc), scnprobe, scnattach, NULL, NULL); @@ -176,18 +176,18 @@ int scnconsrate = CONSOLE_SPEED; #define SCN_ISCONSOLE(addr) \ (SCN_ADDR2DUART(addr) == SCN_CONSDUART && (SCN_ADDR2CHAN(addr) == SCN_CONSCHAN)) -static void scnintr __P((void *)); -static void scnrxintr __P((void *)); -static int scn_rxintr __P((struct scn_softc *)); -static void scnsoft __P((void *)); -static void scn_setchip __P((struct scn_softc *sc)); -static int scniter __P((int *, int, int*, int*, struct chan *, int)); -static int scn_config __P((int, int, int, int, u_char, u_char)); -static void scn_rxenable __P((struct scn_softc *)); -static void scn_rxdisable __P((struct scn_softc *)); -static void dcd_int __P((struct scn_softc *, struct tty *, u_char)); -static void scnoverrun __P((int, long *, const char *)); -static unsigned char opbits __P((struct scn_softc *, int)); +static void scnintr(void *); +static void scnrxintr(void *); +static int scn_rxintr(struct scn_softc *); +static void scnsoft(void *); +static void scn_setchip(struct scn_softc *sc); +static int scniter(int *, int, int*, int*, struct chan *, int); +static int scn_config(int, int, int, int, u_char, u_char); +static void scn_rxenable(struct scn_softc *); +static void scn_rxdisable(struct scn_softc *); +static void dcd_int(struct scn_softc *, struct tty *, u_char); +static void scnoverrun(int, long *, const char *); +static unsigned char opbits(struct scn_softc *, int); static int scnsir = -1; /* s/w intr number */ #define setsoftscn() softintr(scnsir) @@ -323,13 +323,13 @@ static u_char bothgroups[16] = { * for minimum error (from some of Dave Rand's code) */ const struct { - u_int16_t speed; - u_int16_t div; + uint16_t speed; + uint16_t div; } divs[] = { { 50, 2303 }, /* 2304 is exact?? */ { 110, 1047 }, /* Should be 1047.27 */ - { 134, 857 }, /* Should be 856.505576 */ - { 1050, 110 }, /* Should be 109.7142857 */ + { 134, 857 }, /* Should be 856.505576 */ + { 1050, 110 }, /* Should be 109.7142857 */ { 2000, 57 } /* Should be 57.6 */ }; #define DIVS (sizeof(divs)/sizeof(divs[0])) @@ -376,8 +376,7 @@ extern int kgdb_debug_init; */ static void -scn_setchip(sc) - struct scn_softc *sc; +scn_setchip(struct scn_softc *sc) { struct duart *dp; u_char acr, csr, mr1, mr2; @@ -461,7 +460,7 @@ scn_setchip(sc) /* program counter/timer only if necessary */ if (dp->counter != dp->ocounter) { - u_int16_t div; + uint16_t div; #ifdef DIVS int i; @@ -518,14 +517,10 @@ scn_setchip(sc) */ static int -scniter(index, wanted, counter, mode, other, c92) - int *index; /* IN/OUT: index */ - int wanted; /* IN: speed wanted */ - int *counter; /* IN/OUT: counter/timer rate */ - int *mode; /* IN/OUT: mode */ - struct chan *other; /* IN: other channel, or NULL */ - int c92; /* IN: true for 26C92 */ +scniter(int *index, int wanted, int *counter, int *mode, struct chan *other, + int c92) { + while (*index < TABENTRIES) { struct tabent *tp; @@ -579,13 +574,7 @@ scniter(index, wanted, counter, mode, other, c92) * rewritten 2/97 -plb */ static int -scn_config(unit, chan, ispeed, ospeed, mr1, mr2) - int unit; - int chan; - int ispeed; /* input speed in bps */ - int ospeed; /* output speed in bps */ - u_char mr1; /* new bits for MR1 */ - u_char mr2; /* new bits for MR2 */ +scn_config(int unit, int chan, int ispeed, int ospeed, u_char mr1, u_char mr2) { struct scn_softc *sc; struct duart *dp; @@ -703,9 +692,9 @@ scn_config(unit, chan, ispeed, ospeed, mr1, mr2) } return EINVAL; - gotit: + gotit: s = spltty(); - gotit2: + gotit2: dp->chan[chan].new_mr1 = mr1; dp->chan[chan].new_mr2 = mr2; dp->chan[chan].ispeed = ispeed; @@ -723,10 +712,7 @@ scn_config(unit, chan, ispeed, ospeed, mr1, mr2) } int -scnprobe(parent, cf, aux) - struct device *parent; - struct cfdata *cf; - void *aux; +scnprobe(struct device *parent, struct cfdata *cf, void *aux) { struct confargs *ca = aux; volatile u_char *ch_base; @@ -762,8 +748,7 @@ scnprobe(parent, cf, aux) * they're only called on setup, open & close! */ static inline void -scn_rxenable(sc) - struct scn_softc *sc; +scn_rxenable(struct scn_softc *sc) { struct duart *dp; int channel; @@ -780,8 +765,7 @@ scn_rxenable(sc) } static inline void -scn_rxdisable(sc) - struct scn_softc *sc; +scn_rxdisable(struct scn_softc *sc) { struct duart *dp; int channel; @@ -798,10 +782,7 @@ scn_rxdisable(sc) } void -scnattach(parent, self, aux) - struct device *parent; - struct device *self; - void *aux; +scnattach(struct device *parent, struct device *self, void *aux) { struct confargs *ca = aux; struct scn_softc *sc; @@ -923,7 +904,7 @@ scnattach(parent, self, aux) intr_establish(ca->ca_irq >> 4, scnrxintr, duart, intrname, IPL_ZERO, IPL_RTTY, LOW_LEVEL); - duart->base = duart_base; + duart->base = duart_base; duart->type = scntype; } /* Record channel, uart */ @@ -958,11 +939,11 @@ scnattach(parent, self, aux) } /* - * Set up the hardware to a base state, in particular: - * o reset transmitter and receiver - * o set speeds and configurations - * o receiver interrupts only (RxRDY and BREAK) - */ + * Set up the hardware to a base state, in particular: + * o reset transmitter and receiver + * o set speeds and configurations + * o receiver interrupts only (RxRDY and BREAK) + */ s = spltty(); /* RTS off... */ @@ -1073,11 +1054,7 @@ scnattach(parent, self, aux) /* ARGSUSED */ int -scnopen(dev, flag, mode, l) - dev_t dev; - int flag; - int mode; - struct lwp *l; +scnopen(dev_t dev, int flag, int mode, struct lwp *l) { struct tty *tp; int unit = DEV_UNIT(dev); @@ -1221,11 +1198,7 @@ scnopen(dev, flag, mode, l) /*ARGSUSED*/ int -scnclose(dev, flag, mode, l) - dev_t dev; - int flag; - int mode; - struct lwp *l; +scnclose(dev_t dev, int flag, int mode, struct lwp *l) { int unit = DEV_UNIT(dev); struct scn_softc *sc = SOFTC(unit); @@ -1262,10 +1235,7 @@ scnclose(dev, flag, mode, l) } int -scnread(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; +scnread(dev_t dev, struct uio *uio, int flag) { struct scn_softc *sc = SOFTC(DEV_UNIT(dev)); struct tty *tp = sc->sc_tty; @@ -1274,10 +1244,7 @@ scnread(dev, uio, flag) } int -scnwrite(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; +scnwrite(dev_t dev, struct uio *uio, int flag) { struct scn_softc *sc = SOFTC(DEV_UNIT(dev)); struct tty *tp = sc->sc_tty; @@ -1286,10 +1253,7 @@ scnwrite(dev, uio, flag) } int -scnpoll(dev, events, l) - dev_t dev; - int events; - struct lwp *l; +scnpoll(dev_t dev, int events, struct lwp *l) { struct scn_softc *sc = SOFTC(DEV_UNIT(dev)); struct tty *tp = sc->sc_tty; @@ -1298,8 +1262,7 @@ scnpoll(dev, events, l) } struct tty * -scntty(dev) - dev_t dev; +scntty(dev_t dev) { struct scn_softc *sc = SOFTC(DEV_UNIT(dev)); @@ -1308,11 +1271,9 @@ scntty(dev) /* Worker routines for interrupt processing */ static inline void -dcd_int(sc, tp, new) - struct scn_softc *sc; - struct tty *tp; - u_char new; +dcd_int(struct scn_softc *sc, struct tty *tp, u_char new) { + if (sc->sc_swflags & SCN_SW_SOFTCAR) return; @@ -1336,11 +1297,9 @@ dcd_int(sc, tp, new) * Print out a ring or fifo overrun error message. */ static void -scnoverrun(unit, ptime, what) - int unit; - long *ptime; - const char *what; +scnoverrun(int unit, long *ptime, const char *what) { + if (*ptime != time.tv_sec) { *ptime = time.tv_sec; log(LOG_WARNING, "scn%d: %s overrun\n", unit, what); @@ -1354,9 +1313,7 @@ scnoverrun(unit, ptime, what) * be set or cleared according to the "stop" arg passed. */ int -scnhwiflow(tp, stop) - struct tty *tp; - int stop; +scnhwiflow(struct tty *tp, int stop) { int unit = DEV_UNIT(tp->t_dev); struct scn_softc *sc = SOFTC(unit); @@ -1373,8 +1330,7 @@ scnhwiflow(tp, stop) } static void -scnintr(arg) - void *arg; +scnintr(void *arg) { struct duart *duart = arg; struct scn_softc *sc0 = duart->chan[0].sc; @@ -1515,8 +1471,7 @@ scn_rxintr(struct scn_softc *sc) } static void -scnrxintr(arg) - void *arg; +scnrxintr(void *arg) { struct duart *duart = arg; int work = 0; @@ -1550,8 +1505,7 @@ scnrxintr(arg) * -plb. */ static void -scnsoft(arg) - void *arg; +scnsoft(void *arg) { int s, unit; #ifdef SCN_TIMING @@ -1663,21 +1617,15 @@ scnsoft(arg) /* Convert TIOCM_xxx bits to output port bits. */ static unsigned char -opbits(sc, tioc_bits) - struct scn_softc *sc; - int tioc_bits; +opbits(struct scn_softc *sc, int tioc_bits) { + return ((((tioc_bits) & TIOCM_DTR) ? sc->sc_op_dtr : 0) | (((tioc_bits) & TIOCM_RTS) ? sc->sc_op_rts : 0)); } int -scnioctl(dev, cmd, data, flag, l) - dev_t dev; - u_long cmd; - caddr_t data; - int flag; - struct lwp *l; +scnioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct lwp *l) { int unit = DEV_UNIT(dev); struct scn_softc *sc = SOFTC(unit); @@ -1812,9 +1760,7 @@ scnioctl(dev, cmd, data, flag, l) } int -scnparam(tp, t) - struct tty *tp; - struct termios *t; +scnparam(struct tty *tp, struct termios *t) { int cflag = t->c_cflag; int unit = DEV_UNIT(tp->t_dev); @@ -1884,8 +1830,7 @@ scnparam(tp, t) } void -scnstart(tp) - struct tty *tp; +scnstart(struct tty *tp) { int s, c; int unit = DEV_UNIT(tp->t_dev); @@ -1922,9 +1867,7 @@ out: */ /*ARGSUSED*/ void -scnstop(tp, flag) - struct tty *tp; - int flag; +scnstop(struct tty *tp, int flag) { int s; @@ -1952,41 +1895,41 @@ extern int _mapped; (SCN_CONSDUART * 2 + SCN_CONSCHAN) * CH_SZ) void -scncnprobe(cp) - struct consdev *cp; +scncnprobe(struct consdev *cp) { + /* initialize required fields */ cp->cn_dev = makedev(cdevsw_lookup_major(&scn_cdevsw), SCN_CONSOLE); cp->cn_pri = CN_NORMAL; } void -scncnreinit(v) - void *v; +scncnreinit(void *v) { volatile u_char *du_base = DUADDR(); - du_base[DU_OPSET] = SCN_CONSCHAN ? (OP_RTSB | OP_DTRB) : (OP_RTSA | OP_DTRA); + du_base[DU_OPSET] = + SCN_CONSCHAN ? (OP_RTSB | OP_DTRB) : (OP_RTSA | OP_DTRA); } void -scncninit(cp) - struct consdev *cp; +scncninit(struct consdev *cp) { + scninit(cp->cn_dev, scnconsrate); } /* Used by scncninit and kgdb startup. */ int -scninit(dev, rate) - dev_t dev; - int rate; +scninit(dev_t dev, int rate) { volatile u_char *du_base = DUADDR(); int unit = DEV_UNIT(dev); - du_base[DU_OPSET] = SCN_CONSCHAN ? (OP_RTSB | OP_DTRB) : (OP_RTSA | OP_DTRA); - scn_config(unit, SCN_CONSCHAN, rate, rate, MR1_PNONE | MR1_CS8, MR2_STOP1); + du_base[DU_OPSET] = + SCN_CONSCHAN ? (OP_RTSB | OP_DTRB) : (OP_RTSA | OP_DTRA); + scn_config(unit, SCN_CONSCHAN, rate, rate, + MR1_PNONE | MR1_CS8, MR2_STOP1); return (0); } @@ -2012,10 +1955,9 @@ scncngetc(void *arg) /* The pc532 does not turn off console polling. */ void -scncnpollc(dev, on) - dev_t dev; - int on; +scncnpollc(dev_t dev, int on) { + } /* diff --git a/sys/arch/pc532/dev/scnvar.h b/sys/arch/pc532/dev/scnvar.h index 9f18aa709f7..28416a1e474 100644 --- a/sys/arch/pc532/dev/scnvar.h +++ b/sys/arch/pc532/dev/scnvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: scnvar.h,v 1.5 2005/12/11 12:18:31 christos Exp $ */ +/* $NetBSD: scnvar.h,v 1.6 2006/05/12 06:05:22 simonb Exp $ */ /* * Copyright (c) 1996, 1997 Philip L. Budne. @@ -45,7 +45,7 @@ #define SCN_SIZE 0x8 /* address space for port */ -#define SCN_CONSOLE 0 /* minor number of console */ +#define SCN_CONSOLE 0 /* minor number of console */ #define SCN_CONSDUART 0 #define SCN_CONSCHAN 0 @@ -53,8 +53,8 @@ #define SCN_CON_MAP_DATA 0xFFC80003 /* Mapped .... */ #define SCN_CON_MAP_ISR 0xFFC80005 -#define SCN_CON_STAT 0x28000001 /* raw addresses for console */ -#define SCN_CON_DATA 0x28000003 /* Unmapped .... */ +#define SCN_CON_STAT 0x28000001 /* raw addresses for console */ +#define SCN_CON_DATA 0x28000003 /* Unmapped .... */ #define SCN_CON_ISR 0x28000005 /* output port bits */ @@ -108,8 +108,8 @@ struct duart { u_char new_mr2; /* held changes */ } chan[2]; enum scntype { SCNUNK, SCN2681, SCN2692, SC26C92 } type; - u_int16_t counter; /* C/T generated bps, or zero */ - u_int16_t ocounter; /* last C/T generated bps, or zero */ + uint16_t counter; /* C/T generated bps, or zero */ + uint16_t ocounter; /* last C/T generated bps, or zero */ u_char mode; /* ACR[7] + MR0[2:0] */ u_char acr; /* ACR[6:0]*/ u_char imr; /* IMR bits */ diff --git a/sys/arch/pc532/fpu/README b/sys/arch/pc532/fpu/README index 072864f8b9e..f575cdc20dc 100644 --- a/sys/arch/pc532/fpu/README +++ b/sys/arch/pc532/fpu/README @@ -1,4 +1,4 @@ -# $NetBSD: README,v 1.7 2005/12/11 12:18:31 christos Exp $ +# $NetBSD: README,v 1.8 2006/05/12 06:05:22 simonb Exp $ IEEE handler README ------------------- @@ -93,7 +93,7 @@ In addition there are the hardware defined flags: FPC_IF 0x00000040 /* inexact result flag */ FPC_IEN 0x00000020 /* inexact result trap enable */ - FPC_UF 0x00000010 /* underflow flag */ + FPC_UF 0x00000010 /* underflow flag */ FPC_UEN 0x00000008 /* underflow trap enable */ If the corresponding enable flag is set when a trap occurs, then diff --git a/sys/arch/pc532/fpu/ieee_dze.c b/sys/arch/pc532/fpu/ieee_dze.c index 20de6e29fde..bff6b64d752 100644 --- a/sys/arch/pc532/fpu/ieee_dze.c +++ b/sys/arch/pc532/fpu/ieee_dze.c @@ -1,4 +1,4 @@ -/* $NetBSD: ieee_dze.c,v 1.5 2005/12/11 12:18:31 christos Exp $ */ +/* $NetBSD: ieee_dze.c,v 1.6 2006/05/12 06:05:22 simonb Exp $ */ /* * IEEE floating point support for NS32081 and NS32381 fpus. @@ -29,35 +29,38 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ieee_dze.c,v 1.5 2005/12/11 12:18:31 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ieee_dze.c,v 1.6 2006/05/12 06:05:22 simonb Exp $"); #include "ieee_internal.h" -int ieee_dze(struct operand *op1, struct operand *op2, - struct operand *f0_op, int xopcode, state *mystate) +int ieee_dze(struct operand *op1, struct operand *op2, struct operand *f0_op, + int xopcode, state *mystate) { - int user_trap = FPC_TT_NONE; - unsigned int fsr = mystate->FSR; - DP(1, "Divide by zero trap: xopcode = 0x%x\n", xopcode); - fsr |= FPC_DZF; - if (fsr & FPC_DZE) { - /* Users trap handler will fix it */ - user_trap = FPC_TT_DIV0; - } - else { - /* Set dest to + or - infinity ? */ - int sign1 = op2->data.d_bits.sign; - int sign2 = op1->data.d_bits.sign; - op2->data = infty; - op2->data.d_bits.sign = sign1 ^ sign2; - switch(xopcode) { - case LOGBF: - /* logb(0) gives a divide by zero exception according to ieee. - * No idea if the logbf instruction conforms, but just in case... - */ - op2->data.d_bits.sign = 1; - } - } - mystate->FSR = fsr; - return user_trap; + int user_trap = FPC_TT_NONE; + unsigned int fsr = mystate->FSR; + + DP(1, "Divide by zero trap: xopcode = 0x%x\n", xopcode); + fsr |= FPC_DZF; + if (fsr & FPC_DZE) { + /* Users trap handler will fix it */ + user_trap = FPC_TT_DIV0; + } else { + /* Set dest to + or - infinity ? */ + int sign1 = op2->data.d_bits.sign; + int sign2 = op1->data.d_bits.sign; + op2->data = infty; + op2->data.d_bits.sign = sign1 ^ sign2; + switch(xopcode) { + case LOGBF: + /* + * logb(0) gives a divide by zero exception according + * to ieee. + * No idea if the logbf instruction conforms, but just + * in case... + */ + op2->data.d_bits.sign = 1; + } + } + mystate->FSR = fsr; + return user_trap; } diff --git a/sys/arch/pc532/fpu/ieee_handler.c b/sys/arch/pc532/fpu/ieee_handler.c index 20ec64f2518..958a342e0dc 100644 --- a/sys/arch/pc532/fpu/ieee_handler.c +++ b/sys/arch/pc532/fpu/ieee_handler.c @@ -1,4 +1,4 @@ -/* $NetBSD: ieee_handler.c,v 1.21 2005/12/24 22:45:36 perry Exp $ */ +/* $NetBSD: ieee_handler.c,v 1.22 2006/05/12 06:05:22 simonb Exp $ */ /* * IEEE floating point support for NS32081 and NS32381 fpus. @@ -52,7 +52,7 @@ * */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ieee_handler.c,v 1.21 2005/12/24 22:45:36 perry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ieee_handler.c,v 1.22 2006/05/12 06:05:22 simonb Exp $"); #include <sys/types.h> #include "ieee_internal.h" @@ -90,47 +90,56 @@ __KERNEL_RCSID(0, "$NetBSD: ieee_handler.c,v 1.21 2005/12/24 22:45:36 perry Exp #endif -static void get_fstate(state *state) { - __asm("sfsr %0" : "=g" (state->FSR)); - __asm("movl f0, %0" : "=m" (state->LREG(0))); - __asm("movl f1, %0" : "=m" (state->LREG(1))); - __asm("movl f2, %0" : "=m" (state->LREG(2))); - __asm("movl f3, %0" : "=m" (state->LREG(3))); - __asm("movl f4, %0" : "=m" (state->LREG(4))); - __asm("movl f5, %0" : "=m" (state->LREG(5))); - __asm("movl f6, %0" : "=m" (state->LREG(6))); - __asm("movl f7, %0" : "=m" (state->LREG(7))); -} +static void +get_fstate(state *state) +{ -static void set_fstate(state *state) { - /* DON'T tell gcc we are clobbering fp registers, else it will - * save and restore some, undoing our changes! - */ - __asm("lfsr %0":: "g" (state->FSR)); - __asm("movl %0, f0":: "m" (state->LREG(0))); - __asm("movl %0, f1":: "m" (state->LREG(1))); - __asm("movl %0, f2":: "m" (state->LREG(2))); - __asm("movl %0, f3":: "m" (state->LREG(3))); - __asm("movl %0, f4":: "m" (state->LREG(4))); - __asm("movl %0, f5":: "m" (state->LREG(5))); - __asm("movl %0, f6":: "m" (state->LREG(6))); - __asm("movl %0, f7":: "m" (state->LREG(7))); + __asm("sfsr %0" : "=g" (state->FSR)); + __asm("movl f0, %0" : "=m" (state->LREG(0))); + __asm("movl f1, %0" : "=m" (state->LREG(1))); + __asm("movl f2, %0" : "=m" (state->LREG(2))); + __asm("movl f3, %0" : "=m" (state->LREG(3))); + __asm("movl f4, %0" : "=m" (state->LREG(4))); + __asm("movl f5, %0" : "=m" (state->LREG(5))); + __asm("movl f6, %0" : "=m" (state->LREG(6))); + __asm("movl f7, %0" : "=m" (state->LREG(7))); } +static void +set_fstate(state *state) +{ -int ieee_sig(int sig, int code, struct sigcontext *scp) + /* + * DON'T tell gcc we are clobbering fp registers, else it will + * save and restore some, undoing our changes! + */ + __asm("lfsr %0":: "g" (state->FSR)); + __asm("movl %0, f0":: "m" (state->LREG(0))); + __asm("movl %0, f1":: "m" (state->LREG(1))); + __asm("movl %0, f2":: "m" (state->LREG(2))); + __asm("movl %0, f3":: "m" (state->LREG(3))); + __asm("movl %0, f4":: "m" (state->LREG(4))); + __asm("movl %0, f5":: "m" (state->LREG(5))); + __asm("movl %0, f6":: "m" (state->LREG(6))); + __asm("movl %0, f7":: "m" (state->LREG(7))); +} + +int +ieee_sig(int sig, int code, struct sigcontext *scp) { - int ret; - vaddr_t orig_pc; - state state; - get_fstate(&state); - state.scp = scp; - orig_pc = state.PC; - DP(1, "sig = 0x%x, code = 0x%x, pc = 0x%x, fsr = 0x%x\n", sig, code, state.PC, state.FSR); - ret = ieee_handle_exception(&state); - DP(1, " pc incremented by %ld\n", state.PC - orig_pc); - set_fstate(&state); - return ret; + int ret; + vaddr_t orig_pc; + state state; + + get_fstate(&state); + state.scp = scp; + orig_pc = state.PC; + DP(1, "sig = 0x%x, code = 0x%x, pc = 0x%x, fsr = 0x%x\n", + sig, code, state.PC, state.FSR); + ret = ieee_handle_exception(&state); + DP(1, " pc incremented by %ld\n", state.PC - orig_pc); + set_fstate(&state); + return ret; } #endif /* KERNEL */ @@ -165,60 +174,67 @@ const union t_conv qnan = * or equal to 8. Also assume little endian. Assume no alignment * restrictions on short. */ -static inline int bit_extract(char *buffer, int offset, int nbits) +static inline int +bit_extract(char *buffer, int offset, int nbits) { - int start_byte = offset/8; - int end_byte = (offset + nbits - 1)/8; - return (((start_byte == end_byte? buffer[start_byte]: - *(short *)(buffer + start_byte)) >> offset%8) - & ((1 << nbits) - 1)); + int start_byte = offset/8; + int end_byte = (offset + nbits - 1)/8; + + return (((start_byte == end_byte ? buffer[start_byte] : + *(short *)(buffer + start_byte)) >> offset%8) & ((1 << nbits) - 1)); } #ifdef DEBUG -static int invalid_float(union t_conv *p, int size) +static int +invalid_float(union t_conv *p, int size) { - int val; - if ( size == sizeof (float) ) - val = (p->f_bits.exp == 0xff - || (p->f_bits.exp == 0 && p->f_bits.mantissa != 0)); - else if ( size == sizeof (double) ) - val = (p->d_bits.exp == 0x7ff - || (p->d_bits.exp == 0 && (p->d_bits.mantissa != 0 || p->d_bits.mantissa2 != 0))); - else - val = 1; - return (val); + int val; + if (size == sizeof(float)) + val = (p->f_bits.exp == 0xff + || (p->f_bits.exp == 0 && p->f_bits.mantissa != 0)); + else if (size == sizeof(double)) + val = (p->d_bits.exp == 0x7ff + || (p->d_bits.exp == 0 && + (p->d_bits.mantissa != 0 || p->d_bits.mantissa2 != 0))); + else + val = 1; + + return (val); } -static void print_op(struct operand *op) +static void +print_op(struct operand *op) { - if (op->type == op_type_float) { - if (invalid_float(&op->data, op->size)) { - if (op->size == sizeof(double)) { - printf("s: %d, e: %x, m1: %x, m2: %x", op->data.d_bits.sign, op->data.d_bits.exp, op->data.d_bits.mantissa, op->data.d_bits.mantissa2); - } - else { - printf("s: %d, e: %x, m1: %x", op->data.f_bits.sign, op->data.f_bits.exp, op->data.f_bits.mantissa); - } - } - else { - if (op->size == sizeof(double)) - printf("%25.17e", op->data.d); - else - printf("%18.10e", op->data.f); - } - } - else - switch(op->size) { - case 1: - printf("%d", op->data.c); - break; - case 2: - printf("%d", op->data.s); - break; - case 4: - printf("%d", op->data.i); - break; - } + if (op->type == op_type_float) { + if (invalid_float(&op->data, op->size)) { + if (op->size == sizeof(double)) { + printf("s: %d, e: %x, m1: %x, m2: %x", + op->data.d_bits.sign, op->data.d_bits.exp, + op->data.d_bits.mantissa, + op->data.d_bits.mantissa2); + } else { + printf("s: %d, e: %x, m1: %x", + op->data.f_bits.sign, op->data.f_bits.exp, + op->data.f_bits.mantissa); + } + } else { + if (op->size == sizeof(double)) + printf("%25.17e", op->data.d); + else + printf("%18.10e", op->data.f); + } + } else + switch(op->size) { + case 1: + printf("%d", op->data.c); + break; + case 2: + printf("%d", op->data.s); + break; + case 4: + printf("%d", op->data.i); + break; + } } #endif @@ -226,150 +242,183 @@ static const int regoffsets[] = {REGOFFSET(0), REGOFFSET(1), REGOFFSET(2), REGOFFSET(3), REGOFFSET(4), REGOFFSET(5), REGOFFSET(6), REGOFFSET(7)}; -static inline void read_reg(int regno, struct operand *op, state *mystate) { - vaddr_t addr = REGBASE(mystate) + regoffsets[regno]; - switch(op->size) { - case 1: *(char *) &op->data = *(char *) addr; break; - case 2: *(short *) &op->data = *(short *) addr; break; - default: *(int *) &op->data = *(int *) addr; break; - } - op->where.tag = op_where_register; - op->where.addr = (vaddr_t) &op->data; -} - -static inline vaddr_t reg_addr(int regno, state *mystate) { - return REGBASE(mystate) + regoffsets[regno]; +static inline void +read_reg(int regno, struct operand *op, state *mystate) +{ + vaddr_t addr = REGBASE(mystate) + regoffsets[regno]; + + switch(op->size) { + case 1: + *(char *) &op->data = *(char *) addr; + break; + case 2: + *(short *) &op->data = *(short *) addr; + break; + default: + *(int *) &op->data = *(int *) addr; + break; + } + op->where.tag = op_where_register; + op->where.addr = (vaddr_t) &op->data; } +static inline vaddr_t +reg_addr(int regno, state *mystate) +{ -static void read_freg(int regno, struct operand *op, state *mystate) { - vaddr_t addr; - if (op->size == sizeof(float)) { - static const int offsets[] = { - FREGOFFSET(0), FREGOFFSET(1), FREGOFFSET(2), FREGOFFSET(3), - FREGOFFSET(4), FREGOFFSET(5), FREGOFFSET(6), FREGOFFSET(7)}; - addr = FREGBASE(mystate) + offsets[regno]; - *(float *) &op->data = *(float *) addr; - } - else { - static const int offsets[] = { - LREGOFFSET(0), LREGOFFSET(1), LREGOFFSET(2), LREGOFFSET(3), - LREGOFFSET(4), LREGOFFSET(5), LREGOFFSET(6), LREGOFFSET(7)}; - addr = LREGBASE(mystate) + offsets[regno]; - *(double *) &op->data = *(double *) addr; - } - op->where.tag = op_where_register; - op->where.addr = addr; + return REGBASE(mystate) + regoffsets[regno]; } -static int canonical_to_size(struct operand *op) { - int ret = FPC_TT_NONE; - union t_conv t = op->data; - if(op->type == op_type_float) { - if (op->size == sizeof(float)) { - unsigned long mantissa; - int exp = t.d_bits.exp + EXP_FBIAS - EXP_DBIAS; - op->data.f_bits.sign = t.d_bits.sign; - op->data.f_bits.exp = (exp < 0)? 0: ((exp > 0xff)? 0xff: exp); - if(exp >= 0xff && t.d_bits.exp < 0x7ff) { - /* Overflow. need +- infinity. - * Allow for trap on overflow. - */ - ret = FPC_TT_OVFL; - mantissa = 0; - } - else { - mantissa = t.d_bits.mantissa << 3; - mantissa |= (t.d_bits.mantissa2 >> 29) & 7; - if(exp <= 0 && (mantissa != 0 || t.d_bits.exp != 0)) { - /* Denormalize */ - mantissa |= 0x800000; - mantissa >>= -exp; - ret = FPC_TT_UNDFL; +static void +read_freg(int regno, struct operand *op, state *mystate) +{ + vaddr_t addr; + + if (op->size == sizeof(float)) { + static const int offsets[] = { + FREGOFFSET(0), FREGOFFSET(1), + FREGOFFSET(2), FREGOFFSET(3), + FREGOFFSET(4), FREGOFFSET(5), + FREGOFFSET(6), FREGOFFSET(7) + }; + + addr = FREGBASE(mystate) + offsets[regno]; + *(float *) &op->data = *(float *) addr; + } else { + static const int offsets[] = { + LREGOFFSET(0), LREGOFFSET(1), + LREGOFFSET(2), LREGOFFSET(3), + LREGOFFSET(4), LREGOFFSET(5), + LREGOFFSET(6), LREGOFFSET(7) + }; + + addr = LREGBASE(mystate) + offsets[regno]; + *(double *) &op->data = *(double *) addr; } - if (mantissa == 0 && ISNAN(t)) - mantissa = 0x400000; /* Signaling NaN */ - } - op->data.f_bits.mantissa = mantissa; - } - } - else { - switch (op->size) { - case sizeof(char): - op->data.c = t.i; - break; - case sizeof(short): - op->data.s = t.i; - break; - } - } - return ret; + op->where.tag = op_where_register; + op->where.addr = addr; } - -static void canonicalise_op(struct operand *op) { - union t_conv t = op->data; - if(op->type == op_type_float) { - if (op->size == sizeof(float)) { - op->data.d_bits.sign = t.f_bits.sign; - op->data.d_bits.exp = (t.f_bits.exp == 0xff)? 0x7ff: t.f_bits.exp + EXP_DBIAS - EXP_FBIAS; - op->data.d_bits.mantissa = t.f_bits.mantissa >> 3; - op->data.d_bits.mantissa2 = (t.f_bits.mantissa & 7) << 29; - if (t.f_bits.exp == 0) { - if (t.f_bits.mantissa == 0) { - /* Float is zero */ - op->data.d_bits.exp = 0; +static int +canonical_to_size(struct operand *op) +{ + int ret = FPC_TT_NONE; + union t_conv t = op->data; + + if (op->type == op_type_float) { + if (op->size == sizeof(float)) { + unsigned long mantissa; + + int exp = t.d_bits.exp + EXP_FBIAS - EXP_DBIAS; + op->data.f_bits.sign = t.d_bits.sign; + op->data.f_bits.exp = + (exp < 0) ? 0 : ((exp > 0xff) ? 0xff : exp); + if (exp >= 0xff && t.d_bits.exp < 0x7ff) { + /* + * Overflow. need +- infinity. + * Allow for trap on overflow. + */ + ret = FPC_TT_OVFL; + mantissa = 0; + } else { + mantissa = t.d_bits.mantissa << 3; + mantissa |= (t.d_bits.mantissa2 >> 29) & 7; + if (exp <= 0 && + (mantissa != 0 || t.d_bits.exp != 0)) { + /* Denormalize */ + mantissa |= 0x800000; + mantissa >>= -exp; + ret = FPC_TT_UNDFL; + } + if (mantissa == 0 && ISNAN(t)) + /* Signaling NaN */ + mantissa = 0x400000; + } + op->data.f_bits.mantissa = mantissa; + } + } else { + switch (op->size) { + case sizeof(char): + op->data.c = t.i; + break; + case sizeof(short): + op->data.s = t.i; + break; + } } - else { - /* Was a subnormal float. Subnormal floats can always be converted - * to normal doubles. - */ - int norm; - op->data.d_bits.exp = 0; - norm = ieee_normalize(&(op->data)); - op->data.d_bits.exp = EXP_DBIAS - EXP_FBIAS + norm; + return ret; +} + +static void +canonicalise_op(struct operand *op) +{ + union t_conv t = op->data; + + if (op->type == op_type_float) { + if (op->size == sizeof(float)) { + op->data.d_bits.sign = t.f_bits.sign; + op->data.d_bits.exp = + (t.f_bits.exp == 0xff) ? 0x7ff : + t.f_bits.exp + EXP_DBIAS - EXP_FBIAS; + op->data.d_bits.mantissa = t.f_bits.mantissa >> 3; + op->data.d_bits.mantissa2 = + (t.f_bits.mantissa & 7) << 29; + if (t.f_bits.exp == 0) { + if (t.f_bits.mantissa == 0) { + /* Float is zero */ + op->data.d_bits.exp = 0; + } + else { + /* + * Was a subnormal float. Subnormal floats + * can always be converted to normal doubles. + */ + int norm; + + op->data.d_bits.exp = 0; + norm = ieee_normalize(&(op->data)); + op->data.d_bits.exp = + EXP_DBIAS - EXP_FBIAS + norm; + } + } + } + } else { + switch (op->size) { + case sizeof(char): + op->data.i = t.c; + break; + case sizeof(short): + op->data.i = t.s; + break; + } } - } - } - } - else { - switch (op->size) { - case sizeof(char): - op->data.i = t.c; - break; - case sizeof(short): - op->data.i = t.s; - break; - } - } } #define MAX_LEN 21 /* The longest an instruction can be */ static struct { - vaddr_t base; - char *max; - char buf[MAX_LEN]; + vaddr_t base; + char *max; + char buf[MAX_LEN]; #if defined(_KERNEL) && defined(__NetBSD__) && !defined(MACH) - label_t copyfail; + label_t copyfail; #else - jmp_buf copyfail; + jmp_buf copyfail; #endif } copyin_buffer; static void store_result(struct operand *op) { - if (op->where.tag == op_where_memory) { - /* copyout */ - if (copyout((AT) &op->data, (AT)op->where.addr, op->size) != 0) { - longjmp (copyin_buffer.copyfail, 1); - } - } - else { - /* Register */ - memcpy((char *)op->where.addr, (char *) &op->data, op->size); - } + if (op->where.tag == op_where_memory) { + /* copyout */ + if (copyout((AT)&op->data, (AT)op->where.addr, op->size) != 0) { + longjmp(copyin_buffer.copyfail, 1); + } + } else { + /* Register */ + memcpy((void *)op->where.addr, &op->data, op->size); + } } #define FETCH_DATA(addr) ((addr) < copyin_buffer.max? 1: fetch_data(addr)) @@ -382,407 +431,431 @@ static void store_result(struct operand *op) * we never read ahead past a page boundary incase that would not * be mapped. */ -static int fetch_data (char *addr) { - vaddr_t u_addr = copyin_buffer.base + copyin_buffer.max - copyin_buffer.buf; - vaddr_t u_end_addr = copyin_buffer.base + addr - copyin_buffer.buf; - vaddr_t k_addr = (vaddr_t) copyin_buffer.max; - int n; - int n_page = ns532_round_page(u_end_addr) - copyin_buffer.base + copyin_buffer.buf - copyin_buffer.max; - int n_max = MAX_LEN + copyin_buffer.buf - copyin_buffer.max; - int n_min = addr - copyin_buffer.max + 1; - n = MIN(n_max, MAX(n_min, MIN(FETCH_CHUNK, n_page))); - COPYIN(u_addr, k_addr, n); - DP(2, "fetch_data: addr = %p, from 0x%lx, to 0x%lx, n = %d\n", addr, - (long)u_addr, (long)k_addr, n); - copyin_buffer.max += n; - return 1; +static int +fetch_data(char *addr) +{ + vaddr_t u_addr = + copyin_buffer.base + copyin_buffer.max - copyin_buffer.buf; + vaddr_t u_end_addr = copyin_buffer.base + addr - copyin_buffer.buf; + vaddr_t k_addr = (vaddr_t) copyin_buffer.max; + int n; + int n_page = ns532_round_page(u_end_addr) - copyin_buffer.base + + copyin_buffer.buf - copyin_buffer.max; + int n_max = MAX_LEN + copyin_buffer.buf - copyin_buffer.max; + int n_min = addr - copyin_buffer.max + 1; + + n = MIN(n_max, MAX(n_min, MIN(FETCH_CHUNK, n_page))); + COPYIN(u_addr, k_addr, n); + DP(2, "fetch_data: addr = %p, from 0x%lx, to 0x%lx, n = %d\n", addr, + (long)u_addr, (long)k_addr, n); + copyin_buffer.max += n; + return 1; } -static int get_displacement (char **buffer) +static int +get_displacement(char **buffer) { - int disp = 0; - char *buf = *buffer; - FETCH_DATA(buf); - switch (*buf & 0xc0) - { - case 0x00: - case 0x40: - disp = *buf++ & 0x7f; - disp = (disp & 0x40) ? disp | 0xffffff80: disp; - break; - case 0x80: - FETCH_DATA(buf + 1); - disp = *buf++ & 0x3f; - disp = (disp & 0x20) ? disp | 0xffffffc0: disp; - disp = (disp << 8) | (0xff & *buf++); - break; - case 0xc0: - FETCH_DATA(buf + 3); - disp = *buf++ & 0x3f; - disp = (disp & 0x20) ? disp | 0xffffffc0: disp; - disp = (disp << 8) | (0xff & *buf++); - disp = (disp << 8) | (0xff & *buf++); - disp = (disp << 8) | (0xff & *buf++); - break; - } - *buffer = buf; - DP(1, "disp = %d\n", disp); - return disp; + int disp = 0; + char *buf = *buffer; + + FETCH_DATA(buf); + switch (*buf & 0xc0) + { + case 0x00: + case 0x40: + disp = *buf++ & 0x7f; + disp = (disp & 0x40) ? disp | 0xffffff80: disp; + break; + case 0x80: + FETCH_DATA(buf + 1); + disp = *buf++ & 0x3f; + disp = (disp & 0x20) ? disp | 0xffffffc0: disp; + disp = (disp << 8) | (0xff & *buf++); + break; + case 0xc0: + FETCH_DATA(buf + 3); + disp = *buf++ & 0x3f; + disp = (disp & 0x20) ? disp | 0xffffffc0: disp; + disp = (disp << 8) | (0xff & *buf++); + disp = (disp << 8) | (0xff & *buf++); + disp = (disp << 8) | (0xff & *buf++); + break; + } + *buffer = buf; + DP(1, "disp = %d\n", disp); + return disp; } -static int get_operand(char **buf, unsigned char gen, unsigned char index, struct operand *op, state *mystate) +static int +get_operand(char **buf, unsigned char gen, unsigned char index, + struct operand *op, state *mystate) { - int ret = FPC_TT_NONE; - vaddr_t addr = 0; - int disp1, disp2; - DP(1,"gen = 0x%x\n", gen); - - if (op->type == op_type_float && (gen & ~7) == 0) { - read_freg(gen, op, mystate); - return ret; - } - switch (gen) { - case 0: case 1: case 2: case 3: - case 4: case 5: case 6: case 7: - if (op->class != op_class_addr) { - read_reg(gen, op, mystate); - return ret; - } - else - addr = reg_addr(gen, mystate); - break; - case 0x8: case 0x9: case 0xa: case 0xb: - case 0xc: case 0xd: case 0xe: case 0xf: - /* Register relative disp(R0 -- R7) */ - /* rn out of mystate, then get data out of res_addr */ - disp1 = get_displacement (buf); - addr = (disp1 + *(unsigned int *)reg_addr(gen & 7, mystate)); - break; - case 0x10: - case 0x11: - case 0x12: - /* Memory relative disp2(disp1(FP, SP, SB)) */ - disp1 = get_displacement (buf); - disp2 = get_displacement (buf); - addr = (disp1 - + (vaddr_t) (gen == 0x10? mystate->FP: (gen == 0x11? mystate->SP: - mystate->SB))); - addr = disp2 + get_dword(addr); - break; - case 0x14: - /* Immediate */ - if (op->class == op_class_read) { - char *p; - int i; - FETCH_DATA(*buf + op->size - 1); - for(p = (char *)&op->data, i = op->size; i--; p++) { - *p = *(*buf + i); - } - op->where.tag = op_where_immediate; - op->where.addr = 0; - *buf += op->size; - return ret; - } - else { - return FPC_TT_ILL; - } - case 0x15: - /* Absolute @disp */ - disp1 = get_displacement (buf); - addr = disp1; - break; - case 0x16: - /* External EXT(disp1) + disp2 (Mod table stuff) */ - disp1 = get_displacement (buf); - disp2 = get_displacement (buf); - return FPC_TT_ILL; /* Unsupported */ - case 0x17: - /* Top of stack tos */ - addr = mystate->SP; - switch (op->class) { - case op_class_read: - mystate->SP += op->size; - break; - case op_class_write: - mystate->SP -= op->size; - addr = mystate->SP; - break; - default: ; - /* Keep gcc quiet */ - } - break; - case 0x18: - /* Memory space disp(FP) */ - disp1 = get_displacement (buf); - addr = (disp1 + (vaddr_t) mystate->FP); - break; - case 0x19: - /* Memory space disp(SP) */ - disp1 = get_displacement (buf); - addr = (disp1 + (vaddr_t) mystate->SP); - break; - case 0x1a: - /* Memory space disp(SB) */ - disp1 = get_displacement (buf); - addr = (disp1 + (vaddr_t) mystate->SB); - break; - case 0x1b: - /* Memory space disp(PC) */ - disp1 = get_displacement (buf); - addr = disp1 + (vaddr_t) mystate->PC; - break; - case 0x1c: - case 0x1d: - case 0x1e: - case 0x1f: - /* Scaled index basemode[R0 -- R7:B,W,D,Q] */ - { - enum op_class save = op->class; - op->class = op_class_addr; - if ((ret = get_operand(buf, index >> 3, 0, op, mystate)) != FPC_TT_NONE) + int ret = FPC_TT_NONE; + vaddr_t addr = 0; + int disp1, disp2; + + DP(1,"gen = 0x%x\n", gen); + + if (op->type == op_type_float && (gen & ~7) == 0) { + read_freg(gen, op, mystate); + return ret; + } + switch (gen) { + case 0: case 1: case 2: case 3: + case 4: case 5: case 6: case 7: + if (op->class != op_class_addr) { + read_reg(gen, op, mystate); + return ret; + } + else + addr = reg_addr(gen, mystate); + break; + case 0x8: case 0x9: case 0xa: case 0xb: + case 0xc: case 0xd: case 0xe: case 0xf: + /* Register relative disp(R0 -- R7) */ + /* rn out of mystate, then get data out of res_addr */ + disp1 = get_displacement (buf); + addr = (disp1 + *(unsigned int *)reg_addr(gen & 7, mystate)); + break; + case 0x10: + case 0x11: + case 0x12: + /* Memory relative disp2(disp1(FP, SP, SB)) */ + disp1 = get_displacement (buf); + disp2 = get_displacement (buf); + addr = disp1 + (vaddr_t) (gen == 0x10? mystate->FP: + (gen == 0x11? mystate->SP: mystate->SB)); + addr = disp2 + get_dword(addr); + break; + case 0x14: + /* Immediate */ + if (op->class == op_class_read) { + char *p; + int i; + FETCH_DATA(*buf + op->size - 1); + for(p = (char *)&op->data, i = op->size; i--; p++) { + *p = *(*buf + i); + } + op->where.tag = op_where_immediate; + op->where.addr = 0; + *buf += op->size; + return ret; + } + else { + return FPC_TT_ILL; + } + case 0x15: + /* Absolute @disp */ + disp1 = get_displacement (buf); + addr = disp1; + break; + case 0x16: + /* External EXT(disp1) + disp2 (Mod table stuff) */ + disp1 = get_displacement (buf); + disp2 = get_displacement (buf); + return FPC_TT_ILL; /* Unsupported */ + case 0x17: + /* Top of stack tos */ + addr = mystate->SP; + switch (op->class) { + case op_class_read: + mystate->SP += op->size; + break; + case op_class_write: + mystate->SP -= op->size; + addr = mystate->SP; + break; + default: ; + /* Keep gcc quiet */ + } + break; + case 0x18: + /* Memory space disp(FP) */ + disp1 = get_displacement (buf); + addr = (disp1 + (vaddr_t) mystate->FP); + break; + case 0x19: + /* Memory space disp(SP) */ + disp1 = get_displacement (buf); + addr = (disp1 + (vaddr_t) mystate->SP); + break; + case 0x1a: + /* Memory space disp(SB) */ + disp1 = get_displacement (buf); + addr = (disp1 + (vaddr_t) mystate->SB); + break; + case 0x1b: + /* Memory space disp(PC) */ + disp1 = get_displacement (buf); + addr = disp1 + (vaddr_t) mystate->PC; + break; + case 0x1c: + case 0x1d: + case 0x1e: + case 0x1f: + /* Scaled index basemode[R0 -- R7:B,W,D,Q] */ + { + enum op_class save = op->class; + op->class = op_class_addr; + if ((ret = get_operand(buf, index >> 3, 0, op, + mystate)) != FPC_TT_NONE) + return ret; + addr = op->where.addr + (*(int *)reg_addr(index & 7, + mystate)) * (1 << (gen & 3)); + op->class = save; + break; + } + } + if (op->class == op_class_read || op->class == op_class_rmw) { + COPYIN(addr, (vaddr_t)&op->data, op->size); + } + op->where.tag = op_where_memory; + op->where.addr = addr; return ret; - addr = op->where.addr + (* (int *) reg_addr(index & 7, mystate)) * (1 << (gen & 3)); - op->class = save; - break; - } - } - if (op->class == op_class_read || op->class == op_class_rmw) { - COPYIN(addr, (vaddr_t)&op->data, op->size); - } - op->where.tag = op_where_memory; - op->where.addr = addr; - return ret; } -static int default_trap_handle(struct operand *op1, struct operand *op2, struct operand *f0_op, int xopcode, state *mystate) +static int +default_trap_handle(struct operand *op1, struct operand *op2, + struct operand *f0_op, int xopcode, state *mystate) { - int user_trap = FPC_TT_NONE; - unsigned int fsr = mystate->FSR; - int trap_type = fsr & FPC_TT; - - DP(2, "trap type %d\n", trap_type); - { - int s = GET_SET_FSR(fsr & FPC_RM); /* Same rounding mode as at exception */ - - switch (trap_type) - { - case FPC_TT_UNDFL: /* Underflow */ - user_trap = ieee_undfl(op1, op2, f0_op, xopcode, mystate); - break; - case FPC_TT_OVFL: /* Overflow */ - user_trap = ieee_ovfl(op1, op2, f0_op, xopcode, mystate); - break; - case FPC_TT_DIV0: /* Divide by zero */ - user_trap = ieee_dze(op1, op2, f0_op, xopcode, mystate); - break; - case FPC_TT_ILL: /* Illegal instruction */ - /* Illegal instruction. Cause a SIGILL ? */ - user_trap = FPC_TT_ILL; - break; - case FPC_TT_INVOP: /* Invalid operation */ - user_trap = ieee_invop(op1, op2, f0_op, xopcode, mystate); - break; - case FPC_TT_INEXACT: /* Inexact result */ - /* Nothing to be done */ - /* Flags in hardware. We can't get here unless FPC_IEF is set */ - user_trap = FPC_TT_INEXACT; - break; - case FPC_TT_NONE: - default: - DP(0,"ieee_handler: fpu trap type none\n"); - } - SET_FSR(s); - } - return user_trap; + int user_trap = FPC_TT_NONE; + unsigned int fsr = mystate->FSR; + int trap_type = fsr & FPC_TT; + int s; + + DP(2, "trap type %d\n", trap_type); + s = GET_SET_FSR(fsr & FPC_RM); /* Same rounding mode as at exception */ + + switch (trap_type) + { + case FPC_TT_UNDFL: /* Underflow */ + user_trap = + ieee_undfl(op1, op2, f0_op, xopcode, mystate); + break; + case FPC_TT_OVFL: /* Overflow */ + user_trap = + ieee_ovfl(op1, op2, f0_op, xopcode, mystate); + break; + case FPC_TT_DIV0: /* Divide by zero */ + user_trap = ieee_dze(op1, op2, f0_op, xopcode, mystate); + break; + case FPC_TT_ILL: /* Illegal instruction */ + /* Illegal instruction. Cause a SIGILL ? */ + user_trap = FPC_TT_ILL; + break; + case FPC_TT_INVOP: /* Invalid operation */ + user_trap = + ieee_invop(op1, op2, f0_op, xopcode, mystate); + break; + case FPC_TT_INEXACT: /* Inexact result */ + /* + * Nothing to be done. + * Flags in hardware. + * We can't get here unless FPC_IEF is set. + */ + user_trap = FPC_TT_INEXACT; + break; + case FPC_TT_NONE: + default: + DP(0,"ieee_handler: fpu trap type none\n"); + } + SET_FSR(s); + return user_trap; } int ieee_handle_exception(state *mystate) { - int fmt, xopcode, ret; - int fsr, user_trap; - volatile int ofsr; /* Volatile for setjmp */ - unsigned char int_type, float_type, opcode, gen1, gen2, index1, index2; - struct operand op1, op2, f0_op, *res; - char *buf = copyin_buffer.buf; - copyin_buffer.base = mystate->PC; - /* Save fsr and set fsr to 0 so that floating point operations within - * the emulation proceed in a known way. */ - ofsr = GET_SET_FSR(0); - if (setjmp(copyin_buffer.copyfail) != 0) { - SET_FSR(ofsr); - return FPC_TT_ILL; - } - user_trap = FPC_TT_NONE; - int_type = 0; - float_type = 0; - opcode = 0; - index1 = 0; - index2 = 0; - copyin_buffer.max = buf; - /* All fp instructions are 24 bits - * and extensions start after 3 bytes - */ - FETCH_DATA(buf + 2); - - fsr = mystate->FSR; - - switch(fmt = bit_extract(buf, 0, 8)) - { - case 0x3e: /* Format 9 */ - int_type = bit_extract(buf, 8, 2); - float_type = bit_extract(buf, 10, 1); - opcode = bit_extract(buf, 11, 3); - fmt = fmt9; - break; - case 0xbe: /* Format 11 */ - case 0xfe: /* Format 12 */ - fmt = (fmt == 0xbe)? fmt11: fmt12; - float_type = bit_extract(buf, 8, 1); - opcode = bit_extract(buf, 10, 4); - break; - default: - user_trap = FPC_TT_ILL; - DP(0, "ieee_handler: format not of a floating point instruction\n"); - } - xopcode = XOPCODE(fmt, opcode); - DP(2, "xopcode: 0x%x\n", xopcode); - - gen2 = bit_extract(buf, 14, 5); - gen1 = bit_extract(buf, 19, 5); - buf += 3; - if (Adrmod_is_index(gen1)) { - FETCH_DATA(buf); - index1 = *buf++; - } - if (Adrmod_is_index(gen2)) { - FETCH_DATA(buf); - index2 = *buf++; - } - - op1.class = op_class_read; - op2.class = op_class_rmw; - op1.type = op2.type = op_type_float; - op1.size = op2.size = float_type? 4: 8; - res = &op2; - switch(xopcode) { - case MOVLF: - op1.type = op_type_float; op1.size = 8; - op2.size = 4; op2.class = op_class_write; - break; - case MOVFL: - op1.type = op_type_float; op1.size = 4; - op2.size = 8; op2.class = op_class_write; - break; - case MOVIF: - op1.type = op_type_int; op1.size = 1 << int_type; - op2.class = op_class_write; - break; - case NEGF: - op2.class = op_class_write; - break; - case ROUNDFI: - case TRUNCFI: - case FLOORFI: - op2.type = op_type_int; op2.size = 1 << int_type; - break; - case CMPF: - op2.class = op_class_read; - res = 0; - break; - case POLYF: - case DOTF: - op1.type = op2.type = f0_op.type = op_type_float; - op1.size = op2.size = f0_op.size = float_type? 4: 8; - op2.class = op_class_read; - f0_op.class = op_class_rmw; - read_freg(0, &f0_op, mystate); - canonicalise_op(&f0_op); - res = &f0_op; - break; - } - - if ((ret = get_operand(&buf, gen1, index1, &op1, mystate)) != FPC_TT_NONE) { - user_trap = ret; - DP(0, "get_operand failed\n"); - } - - if ((ret = get_operand(&buf, gen2, index2, &op2, mystate)) != FPC_TT_NONE) { - user_trap = ret; - DP(0, "get_operand failed\n"); - } + int fmt, xopcode, ret; + int fsr, user_trap; + volatile int ofsr; /* Volatile for setjmp */ + unsigned char int_type, float_type, opcode, gen1, gen2, index1, index2; + struct operand op1, op2, f0_op, *res; + char *buf = copyin_buffer.buf; + copyin_buffer.base = mystate->PC; + /* Save fsr and set fsr to 0 so that floating point operations within + * the emulation proceed in a known way. */ + ofsr = GET_SET_FSR(0); + if (setjmp(copyin_buffer.copyfail) != 0) { + SET_FSR(ofsr); + return FPC_TT_ILL; + } + user_trap = FPC_TT_NONE; + int_type = 0; + float_type = 0; + opcode = 0; + index1 = 0; + index2 = 0; + copyin_buffer.max = buf; + /* All fp instructions are 24 bits + * and extensions start after 3 bytes + */ + FETCH_DATA(buf + 2); + + fsr = mystate->FSR; + + switch(fmt = bit_extract(buf, 0, 8)) { + case 0x3e: /* Format 9 */ + int_type = bit_extract(buf, 8, 2); + float_type = bit_extract(buf, 10, 1); + opcode = bit_extract(buf, 11, 3); + fmt = fmt9; + break; + case 0xbe: /* Format 11 */ + case 0xfe: /* Format 12 */ + fmt = (fmt == 0xbe)? fmt11: fmt12; + float_type = bit_extract(buf, 8, 1); + opcode = bit_extract(buf, 10, 4); + break; + default: + user_trap = FPC_TT_ILL; + DP(0, "ieee_handler: format not of a floating point " + "instruction\n"); + } + xopcode = XOPCODE(fmt, opcode); + DP(2, "xopcode: 0x%x\n", xopcode); + + gen2 = bit_extract(buf, 14, 5); + gen1 = bit_extract(buf, 19, 5); + buf += 3; + if (Adrmod_is_index(gen1)) { + FETCH_DATA(buf); + index1 = *buf++; + } + if (Adrmod_is_index(gen2)) { + FETCH_DATA(buf); + index2 = *buf++; + } + + op1.class = op_class_read; + op2.class = op_class_rmw; + op1.type = op2.type = op_type_float; + op1.size = op2.size = float_type? 4: 8; + res = &op2; + switch(xopcode) { + case MOVLF: + op1.type = op_type_float; op1.size = 8; + op2.size = 4; op2.class = op_class_write; + break; + case MOVFL: + op1.type = op_type_float; op1.size = 4; + op2.size = 8; op2.class = op_class_write; + break; + case MOVIF: + op1.type = op_type_int; op1.size = 1 << int_type; + op2.class = op_class_write; + break; + case NEGF: + op2.class = op_class_write; + break; + case ROUNDFI: + case TRUNCFI: + case FLOORFI: + op2.type = op_type_int; op2.size = 1 << int_type; + break; + case CMPF: + op2.class = op_class_read; + res = 0; + break; + case POLYF: + case DOTF: + op1.type = op2.type = f0_op.type = op_type_float; + op1.size = op2.size = f0_op.size = float_type? 4: 8; + op2.class = op_class_read; + f0_op.class = op_class_rmw; + read_freg(0, &f0_op, mystate); + canonicalise_op(&f0_op); + res = &f0_op; + break; + } + + if ((ret = get_operand(&buf, gen1, index1, &op1, mystate)) != + FPC_TT_NONE) { + user_trap = ret; + DP(0, "get_operand failed\n"); + } + + if ((ret = get_operand(&buf, gen2, index2, &op2, mystate)) != + FPC_TT_NONE) { + user_trap = ret; + DP(0, "get_operand failed\n"); + } #ifdef DEBUG - if (ieee_handler_debug > 1) { - printf( "op1 = "); print_op(&op1); printf("\n"); - printf( "op2 = "); print_op(&op2); printf("\n"); - } + if (ieee_handler_debug > 1) { + printf( "op1 = "); print_op(&op1); printf("\n"); + printf( "op2 = "); print_op(&op2); printf("\n"); + } #endif - canonicalise_op(&op1); - canonicalise_op(&op2); - - if(user_trap == FPC_TT_NONE) { - user_trap = default_trap_handle(&op1, &op2, &f0_op, xopcode, mystate); - fsr = mystate->FSR; /* May have been side effected */ - - /* user_trap now has traps generated during emulation. Correct ieee - * results already calculated, but must see whether we need to - * pass trap on to user. - * - * User trap can be set for many reasons. eg dividing a denorm by 0 - * might initially result in an invalid operand trap, but during - * emulation we set the divide by zero trap. - */ - - if (res) { - int ret2; - if((ret2 = canonical_to_size(res)) != FPC_TT_NONE) - user_trap = ret2; - } - - switch (user_trap) { - case FPC_TT_UNDFL: - fsr |= FPC_UF; - if ((fsr & FPC_UNDE) == 0) - user_trap = FPC_TT_NONE; - break; - case FPC_TT_OVFL: - fsr |= FPC_OVF; - if ((fsr & FPC_OVE) == 0) - user_trap = FPC_TT_NONE; - break; - case FPC_TT_DIV0: - fsr |= FPC_DZF; - if ((fsr & FPC_DZE) == 0) - user_trap = FPC_TT_NONE; - break; - case FPC_TT_ILL: - break; - case FPC_TT_INVOP: - fsr |= FPC_IVF; - if ((fsr & FPC_IVE) == 0) - user_trap = FPC_TT_NONE; - break; - case FPC_TT_INEXACT: - fsr |= FPC_IF; - if ((fsr & FPC_IEN) == 0) - user_trap = FPC_TT_NONE; - break; - } - } + canonicalise_op(&op1); + canonicalise_op(&op2); + + if (user_trap == FPC_TT_NONE) { + user_trap = + default_trap_handle(&op1, &op2, &f0_op, xopcode, mystate); + fsr = mystate->FSR; /* May have been side effected */ + + /* + * user_trap now has traps generated during emulation. Correct + * ieee results already calculated, but must see whether we + * need to pass trap on to user. + * + * User trap can be set for many reasons. eg dividing a denorm + * by 0 might initially result in an invalid operand trap, but + * during emulation we set the divide by zero trap. + */ + + if (res) { + int ret2; + if ((ret2 = canonical_to_size(res)) != FPC_TT_NONE) + user_trap = ret2; + } + + switch (user_trap) { + case FPC_TT_UNDFL: + fsr |= FPC_UF; + if ((fsr & FPC_UNDE) == 0) + user_trap = FPC_TT_NONE; + break; + case FPC_TT_OVFL: + fsr |= FPC_OVF; + if ((fsr & FPC_OVE) == 0) + user_trap = FPC_TT_NONE; + break; + case FPC_TT_DIV0: + fsr |= FPC_DZF; + if ((fsr & FPC_DZE) == 0) + user_trap = FPC_TT_NONE; + break; + case FPC_TT_ILL: + break; + case FPC_TT_INVOP: + fsr |= FPC_IVF; + if ((fsr & FPC_IVE) == 0) + user_trap = FPC_TT_NONE; + break; + case FPC_TT_INEXACT: + fsr |= FPC_IF; + if ((fsr & FPC_IEN) == 0) + user_trap = FPC_TT_NONE; + break; + } + } - if(user_trap == FPC_TT_NONE) { - if(res) { + if (user_trap == FPC_TT_NONE) { + if (res) { #ifdef DEBUG - if (ieee_handler_debug > 1) { - printf( "res = "); print_op(res); printf("\n"); - } + if (ieee_handler_debug > 1) { + printf("res = "); + print_op(res); + printf("\n"); + } #endif - store_result(res); - } - } - mystate->PC = BUF_TO_UADDR(buf); - SET_FSR(ofsr); - mystate->FSR = fsr; - return user_trap; + store_result(res); + } + } + mystate->PC = BUF_TO_UADDR(buf); + SET_FSR(ofsr); + mystate->FSR = fsr; + return user_trap; } diff --git a/sys/arch/pc532/fpu/ieee_handler.h b/sys/arch/pc532/fpu/ieee_handler.h index 84c64cd7196..bc33c6ef9bb 100644 --- a/sys/arch/pc532/fpu/ieee_handler.h +++ b/sys/arch/pc532/fpu/ieee_handler.h @@ -1,4 +1,4 @@ -/* $NetBSD: ieee_handler.h,v 1.8 2005/12/11 12:18:31 christos Exp $ */ +/* $NetBSD: ieee_handler.h,v 1.9 2006/05/12 06:05:22 simonb Exp $ */ /* * IEEE floating point support for NS32081 and NS32381 fpus. @@ -45,8 +45,8 @@ #endif typedef struct { - struct ns532_saved_state *regs; - struct ns532_fp_state *fps; + struct ns532_saved_state *regs; + struct ns532_fp_state *fps; } state; #define LREGBASE(s) ((vaddr_t) (s)->fps) @@ -96,16 +96,20 @@ typedef struct lwp state; #include <signal.h> struct fstate { - unsigned int fsr; - union { - struct { double l0, l2, l4, l6, l1, l3, l5, l7;} l; - struct { float f0, f1, f2, f3, f4, f5, f6, f7;} f; - } regs; + unsigned int fsr; + union { + struct { + double l0, l2, l4, l6, l1, l3, l5, l7; + } l; + struct { + float f0, f1, f2, f3, f4, f5, f6, f7; + } f; + } regs; }; struct ns532_combined_state { - struct sigcontext *scp; - struct fstate fs; + struct sigcontext *scp; + struct fstate fs; }; typedef struct ns532_combined_state state; diff --git a/sys/arch/pc532/fpu/ieee_internal.h b/sys/arch/pc532/fpu/ieee_internal.h index a111f89341b..4bc1471097d 100644 --- a/sys/arch/pc532/fpu/ieee_internal.h +++ b/sys/arch/pc532/fpu/ieee_internal.h @@ -1,4 +1,4 @@ -/* $NetBSD: ieee_internal.h,v 1.9 2006/03/11 13:56:18 simonb Exp $ */ +/* $NetBSD: ieee_internal.h,v 1.10 2006/05/12 06:05:23 simonb Exp $ */ /* * IEEE floating point support for NS32081 and NS32381 fpus. @@ -36,7 +36,8 @@ #ifdef DEBUG extern int ieee_handler_debug; -#define DP(n, format, args...) if (ieee_handler_debug >= n) printf(format, ## args) +#define DP(n, format, args...) \ + if (ieee_handler_debug >= n) printf(format, ## args) #else #define DP(n, format, args...) #endif @@ -65,77 +66,80 @@ enum format { fmt9, fmt11, fmt12}; #define SFSR XOPCODE(fmt9, 6) union t_conv { - double d; - float f; - struct { - unsigned int mantissa2:32; - unsigned int mantissa:20; - unsigned int exp:11; - unsigned int sign :1; - } d_bits; - struct { - unsigned int mantissa:23; - unsigned int exp:8; - unsigned int sign :1; - } f_bits; - signed char c; - short s; - int i; + double d; + float f; + struct { + unsigned int mantissa2:32; + unsigned int mantissa:20; + unsigned int exp:11; + unsigned int sign :1; + } d_bits; + struct { + unsigned int mantissa:23; + unsigned int exp:8; + unsigned int sign :1; + } f_bits; + signed char c; + short s; + int i; }; /* These assume "double" interpretation of the union is valid */ -#define ISNAN(data) ((data).d_bits.exp == 0x7ff && \ - ((data).d_bits.mantissa != 0 || (data).d_bits.mantissa2 != 0)) +#define ISNAN(data) \ + ((data).d_bits.exp == 0x7ff && \ + ((data).d_bits.mantissa != 0 || (data).d_bits.mantissa2 != 0)) -#define ISQNAN(data) ((data).d_bits.exp == 0x7ff && \ - ((data).d_bits.mantissa & 0x80000) != 0) +#define ISQNAN(data) \ + ((data).d_bits.exp == 0x7ff && \ + ((data).d_bits.mantissa & 0x80000) != 0) -#define ISSNAN(data) ((data).d_bits.exp == 0x7ff && \ - ((data).d_bits.mantissa & 0x80000) == 0 && \ - ((data).d_bits.mantissa != 0 || (data).d_bits.mantissa2 != 0)) +#define ISSNAN(data) \ + ((data).d_bits.exp == 0x7ff && \ + ((data).d_bits.mantissa & 0x80000) == 0 && \ + ((data).d_bits.mantissa != 0 || (data).d_bits.mantissa2 != 0)) -#define ISINFTY(data) ((data).d_bits.exp == 0x7ff && (data).d_bits.mantissa == 0 && \ - (data).d_bits.mantissa2 == 0) +#define ISINFTY(data) \ + ((data).d_bits.exp == 0x7ff && (data).d_bits.mantissa == 0 && \ + (data).d_bits.mantissa2 == 0) -#define ISDENORM(data) ((data).d_bits.exp == 0 && ((data).d_bits.mantissa != 0 || (data).d_bits.mantissa2 != 0)) +#define ISDENORM(data) \ + ((data).d_bits.exp == 0 && ((data).d_bits.mantissa != 0 || \ + (data).d_bits.mantissa2 != 0)) -#define ISZERO(data) ((data).d_bits.exp == 0 && (data).d_bits.mantissa == 0 && (data).d_bits.mantissa2 == 0) +#define ISZERO(data) \ + ((data).d_bits.exp == 0 && (data).d_bits.mantissa == 0 && \ + (data).d_bits.mantissa2 == 0) #define EXP_DBIAS 1023 - #define EXP_FBIAS 127 enum op_type {op_type_float, op_type_int}; - enum op_class {op_class_read, op_class_write, op_class_rmw, op_class_addr}; - enum op_where_tag { op_where_register, op_where_memory, op_where_immediate }; extern const union t_conv infty; - extern const union t_conv snan; - extern const union t_conv qnan; struct operand { - enum op_type type; - enum op_class class; - struct { - enum op_where_tag tag; - vaddr_t addr; - } where; - char size; - union t_conv data; + enum op_type type; + enum op_class class; + struct { + enum op_where_tag tag; + vaddr_t addr; + } where; + char size; + union t_conv data; }; -int ieee_undfl(struct operand *, struct operand *, - struct operand *, int, state *); -int ieee_ovfl(struct operand *, struct operand *, - struct operand *, int, state *); -int ieee_dze(struct operand *, struct operand *, - struct operand *, int, state *); -int ieee_invop(struct operand *, struct operand *, - struct operand *, int, state *); +int ieee_undfl(struct operand *, struct operand *, struct operand *, int, + state *); +int ieee_ovfl(struct operand *, struct operand *, struct operand *, int, + state *); +int ieee_dze(struct operand *, struct operand *, struct operand *, int, + state *); +int ieee_invop(struct operand *, struct operand *, struct operand *, int, + state *); int ieee_add(double, double *); int ieee_mul(double, double *); int ieee_div(double, double *); diff --git a/sys/arch/pc532/fpu/ieee_invop.c b/sys/arch/pc532/fpu/ieee_invop.c index d19c334a206..cb6171191d8 100644 --- a/sys/arch/pc532/fpu/ieee_invop.c +++ b/sys/arch/pc532/fpu/ieee_invop.c @@ -1,4 +1,4 @@ -/* $NetBSD: ieee_invop.c,v 1.9 2005/12/11 12:18:31 christos Exp $ */ +/* $NetBSD: ieee_invop.c,v 1.10 2006/05/12 06:05:23 simonb Exp $ */ /* * IEEE floating point support for NS32081 and NS32381 fpus. @@ -45,7 +45,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ieee_invop.c,v 1.9 2005/12/11 12:18:31 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ieee_invop.c,v 1.10 2006/05/12 06:05:23 simonb Exp $"); #include "ieee_internal.h" @@ -56,284 +56,300 @@ __KERNEL_RCSID(0, "$NetBSD: ieee_invop.c,v 1.9 2005/12/11 12:18:31 christos Exp #include <limits.h> #endif -static int nan_2(union t_conv data1, union t_conv *data2) +static int +nan_2(union t_conv data1, union t_conv *data2) { - int nans = (ISNAN(data1)? 1: 0) + (ISNAN(*data2)? 2: 0); - switch (nans) { - case 0: - return 0; - case 1: - *data2 = data1; - break; - case 2: - break; - case 3: - if((data1.d_bits.mantissa > data2->d_bits.mantissa) - || (data1.d_bits.mantissa == data1.d_bits.mantissa - && data1.d_bits.mantissa2 > data2->d_bits.mantissa2)) { - *data2 = data1; - } - break; - } - data2->d_bits.mantissa |= 0x80000; /* Make sure it is a quiet NaN */ - return 1; + int nans = (ISNAN(data1)? 1: 0) + (ISNAN(*data2)? 2: 0); + + switch (nans) { + case 0: + return 0; + case 1: + *data2 = data1; + break; + case 2: + break; + case 3: + if ((data1.d_bits.mantissa > data2->d_bits.mantissa) || + (data1.d_bits.mantissa == data1.d_bits.mantissa && + data1.d_bits.mantissa2 > data2->d_bits.mantissa2)) { + *data2 = data1; + } + break; + } + data2->d_bits.mantissa |= 0x80000; /* Make sure it is a quiet NaN */ + return 1; } -static int add_iv (struct operand *op1, struct operand *op2) +static int +add_iv(struct operand *op1, struct operand *op2) { - int inftys; - int ret = FPC_TT_NONE; - if(nan_2(op1->data, &op2->data)) { - return ret; - } - inftys = (ISINFTY(op1->data)? 1: 0) + (ISINFTY(op2->data)? 2:0); - switch (inftys) { - case 0: - break; - case 1: - op2->data = op1->data; - return ret; - case 2: - return ret; - case 3: - if(op1->data.d_bits.sign != op2->data.d_bits.sign) { - op2->data = qnan; - return FPC_TT_INVOP; - } - return ret; - } - /* Must be subnormals */ - return ieee_add(op1->data.d, &op2->data.d); + int inftys; + int ret = FPC_TT_NONE; + + if (nan_2(op1->data, &op2->data)) { + return ret; + } + inftys = (ISINFTY(op1->data)? 1: 0) + (ISINFTY(op2->data)? 2:0); + switch (inftys) { + case 0: + break; + case 1: + op2->data = op1->data; + return ret; + case 2: + return ret; + case 3: + if (op1->data.d_bits.sign != op2->data.d_bits.sign) { + op2->data = qnan; + return FPC_TT_INVOP; + } + return ret; + } + /* Must be subnormals */ + return ieee_add(op1->data.d, &op2->data.d); } -static int div_iv (struct operand *op1, struct operand *op2) +static int +div_iv(struct operand *op1, struct operand *op2) { - int inftys, sign1, sign2; - int ret = FPC_TT_NONE; - if(nan_2(op1->data, &op2->data)) { - return ret; - } - inftys = (ISINFTY(op1->data)? 1: 0) + (ISINFTY(op2->data)? 2:0); - sign1 = op1->data.d_bits.sign; - sign2 = op2->data.d_bits.sign; - switch (inftys) { - case 0: - break; - case 1: /* n/oo */ - { - op2->data.d = 0.0; - op2->data.d_bits.sign = sign1 ^ sign2; - return ret; - } - case 2: /* oo/n */ - op2->data.d_bits.sign = sign1 ^ sign2; - return ret; - case 3: - op2->data = qnan; - return FPC_TT_INVOP; - } - if(ISZERO(op1->data)) { - if (ISZERO(op2->data)) { - /* Must be 0/0 */ - op2->data = qnan; - return FPC_TT_INVOP; - } - else { - /* Must be subnorm/0 */ - op2->data = infty; - op2->data.d_bits.sign = sign1 ^ sign2; - return FPC_TT_DIV0; - } - } - /* Must be subnorm/subnorm */ - return ieee_div(op1->data.d, &op2->data.d); + int inftys, sign1, sign2; + int ret = FPC_TT_NONE; + + if (nan_2(op1->data, &op2->data)) { + return ret; + } + inftys = (ISINFTY(op1->data)? 1: 0) + (ISINFTY(op2->data)? 2:0); + sign1 = op1->data.d_bits.sign; + sign2 = op2->data.d_bits.sign; + switch (inftys) { + case 0: + break; + case 1: /* n/oo */ + op2->data.d = 0.0; + op2->data.d_bits.sign = sign1 ^ sign2; + return ret; + case 2: /* oo/n */ + op2->data.d_bits.sign = sign1 ^ sign2; + return ret; + case 3: + op2->data = qnan; + return FPC_TT_INVOP; + } + if (ISZERO(op1->data)) { + if (ISZERO(op2->data)) { + /* Must be 0/0 */ + op2->data = qnan; + return FPC_TT_INVOP; + } else { + /* Must be subnorm/0 */ + op2->data = infty; + op2->data.d_bits.sign = sign1 ^ sign2; + return FPC_TT_DIV0; + } + } + /* Must be subnorm/subnorm */ + return ieee_div(op1->data.d, &op2->data.d); } -static int mul_iv (struct operand *op1, struct operand *op2) +static int +mul_iv(struct operand *op1, struct operand *op2) { - int inftys, sign1, sign2; - int ret = FPC_TT_NONE; - if(nan_2(op1->data, &op2->data)) { - return ret; - } - inftys = (ISINFTY(op1->data)? 1: 0) + (ISINFTY(op2->data)? 2:0); - sign1 = op1->data.d_bits.sign; - sign2 = op2->data.d_bits.sign; - switch (inftys) { - case 0: - break; - case 1: /* oo * n */ - if (ISZERO(op2->data)) { - op2->data = qnan; - return FPC_TT_INVOP; - } - else { - op2->data = op1->data; - op2->data.d_bits.sign = sign1 ^ sign2; - return ret; - } - case 2: /* n * oo */ - if (ISZERO(op1->data)) { - op2->data = qnan; - return FPC_TT_INVOP; - } - /* Fall through */ - case 3: /* oo * oo */ - op2->data.d_bits.sign = sign1 ^ sign2; - return ret; - } - /* Must be subnormals */ - return ieee_mul(op1->data.d, &op2->data.d); + int inftys, sign1, sign2; + int ret = FPC_TT_NONE; + + if (nan_2(op1->data, &op2->data)) { + return ret; + } + inftys = (ISINFTY(op1->data)? 1: 0) + (ISINFTY(op2->data)? 2:0); + sign1 = op1->data.d_bits.sign; + sign2 = op2->data.d_bits.sign; + switch (inftys) { + case 0: + break; + case 1: /* oo * n */ + if (ISZERO(op2->data)) { + op2->data = qnan; + return FPC_TT_INVOP; + } else { + op2->data = op1->data; + op2->data.d_bits.sign = sign1 ^ sign2; + return ret; + } + case 2: /* n * oo */ + if (ISZERO(op1->data)) { + op2->data = qnan; + return FPC_TT_INVOP; + } + /* Fall through */ + case 3: /* oo * oo */ + op2->data.d_bits.sign = sign1 ^ sign2; + return ret; + } + /* Must be subnormals */ + return ieee_mul(op1->data.d, &op2->data.d); } -static int dot_iv (struct operand *op1, struct operand *op2, struct operand *op3) +static int +dot_iv(struct operand *op1, struct operand *op2, struct operand *op3) { - int inftys; - int ret = FPC_TT_NONE; - union t_conv t = op2->data; - if(nan_2(op1->data, &t)) { - if(nan_2(t, &op3->data)) - return ret; - } - inftys = ((ISINFTY(op1->data)? 1: 0) + (ISINFTY(op2->data)? 2:0) - + (ISINFTY(op3->data)? 4: 0)); - switch (inftys) { - case 0: - break; - case 1: case 2: case 3: /* oo * n + m or n * oo + m or oo * oo + m */ - op3->data = op2->data; - return mul_iv(op1, op3); - case 4: /* n * m + oo */ - return ret; - case 5: case 6: case 7: - { - struct operand top = *op2; - mul_iv(op1, &top); - add_iv(&top, op3); - return ret; - } - } - /* Must be subnormals */ - return ieee_dot(op1->data.d, op2->data.d, &op3->data.d); + int inftys; + int ret = FPC_TT_NONE; + + union t_conv t = op2->data; + if (nan_2(op1->data, &t)) { + if (nan_2(t, &op3->data)) + return ret; + } + inftys = ((ISINFTY(op1->data)? 1: 0) + (ISINFTY(op2->data)? 2:0) + + (ISINFTY(op3->data)? 4: 0)); + switch (inftys) { + case 0: + break; + case 1: case 2: case 3: /* oo * n + m or n * oo + m or oo * oo + m */ + op3->data = op2->data; + return mul_iv(op1, op3); + case 4: /* n * m + oo */ + return ret; + case 5: case 6: case 7: { + struct operand top = *op2; + mul_iv(op1, &top); + add_iv(&top, op3); + return ret; + } + } + /* Must be subnormals */ + return ieee_dot(op1->data.d, op2->data.d, &op3->data.d); } -static int poly_iv (struct operand *op1, struct operand *op2, struct operand *op3) +static int +poly_iv(struct operand *op1, struct operand *op2, struct operand *op3) { - int ret; - struct operand t = *op2; - ret = dot_iv(op3, op1, &t); - *op3 = t; - return ret; + int ret; + struct operand t = *op2; + + ret = dot_iv(op3, op1, &t); + *op3 = t; + return ret; } -static int round_iv (struct operand *op1, struct operand *op2, int xopcode) +static int +round_iv(struct operand *op1, struct operand *op2, int xopcode) { - int ret = FPC_TT_NONE; - if(ISNAN(op1->data)) { - /* XXX */ - op2->data.i = 0; - return FPC_TT_INVOP; /* Need a special code */ - } - else if (ISINFTY(op1->data)) { - op2->data.i = op1->data.d_bits.sign? INT_MIN: INT_MAX; - } else { - /* Must be a denorm */ - op2->data.i = 0; - } - return ret; + int ret = FPC_TT_NONE; + + if (ISNAN(op1->data)) { + /* XXX */ + op2->data.i = 0; + return FPC_TT_INVOP; /* Need a special code */ + } + else if (ISINFTY(op1->data)) { + op2->data.i = op1->data.d_bits.sign? INT_MIN: INT_MAX; + } else { + /* Must be a denorm */ + op2->data.i = 0; + } + return ret; } -static int scalb_iv (struct operand *op1, struct operand *op2) +static int +scalb_iv(struct operand *op1, struct operand *op2) { - int ret = FPC_TT_NONE; - if(nan_2(op1->data, &op2->data)) { - return ret; - } - return ieee_scalb(op1->data.d, &op2->data.d); + int ret = FPC_TT_NONE; + + if (nan_2(op1->data, &op2->data)) { + return ret; + } + return ieee_scalb(op1->data.d, &op2->data.d); } -static int logb_iv (struct operand *op1, struct operand *op2) +static int +logb_iv(struct operand *op1, struct operand *op2) { - int ret = FPC_TT_NONE; - if (ISNAN(op1->data)) - op2->data = op1->data; - else if(ISINFTY(op1->data)) - op2->data = infty; - else { - /* Is a denormal */ - union t_conv t = op1->data; - int norm = ieee_normalize(&t); - op2->data.d = t.d_bits.exp + norm; - } - return ret; + int ret = FPC_TT_NONE; + + if (ISNAN(op1->data)) + op2->data = op1->data; + else if (ISINFTY(op1->data)) + op2->data = infty; + else { + /* Is a denormal */ + union t_conv t = op1->data; + int norm = ieee_normalize(&t); + op2->data.d = t.d_bits.exp + norm; + } + return ret; } -static void cmp_iv(struct operand *op1, struct operand *op2, state *mystate) +static void +cmp_iv(struct operand *op1, struct operand *op2, state *mystate) { - mystate->PSR &= ~(PSR_N | PSR_Z | PSR_L); - if (ISNAN(op1->data) || ISNAN(op2->data)) { - return; - } - ieee_cmp(op1->data.d, op2->data.d, mystate); - return; + mystate->PSR &= ~(PSR_N | PSR_Z | PSR_L); + + if (ISNAN(op1->data) || ISNAN(op2->data)) { + return; + } + ieee_cmp(op1->data.d, op2->data.d, mystate); + return; } -int ieee_invop(struct operand *op1, struct operand *op2, - struct operand *f0_op, int xopcode, state *mystate) +int +ieee_invop(struct operand *op1, struct operand *op2, struct operand *f0_op, + int xopcode, state *mystate) { - int user_trap = FPC_TT_NONE; + int user_trap = FPC_TT_NONE; - /* Don't fiddle with fsr. The FPC_TT_INVOP bit should only be set - * if we attempt to *generate* a NaN. This is achieved by returning - * FPC_TT_INVOP when we generate a NaN. - */ - /* - * Figure out right thing to do. - */ - switch(xopcode) { - case NEGF: - if(! ISNAN(op1->data)) - op1->data.d_bits.sign ^= 1; - /* Fall through */ - case MOVF: - case MOVLF: - case MOVFL: - op2->data = op1->data; - break; - case CMPF: - cmp_iv(op1, op2, mystate); - break; - case SUBF: - if(! ISNAN(op1->data)) - op1->data.d_bits.sign ^= 1; - /* Fall through */ - case ADDF: - user_trap = add_iv(op1, op2); - break; - case MULF: - user_trap = mul_iv(op1, op2); - break; - case DIVF: - user_trap = div_iv(op1, op2); - break; - case ROUNDFI: - case TRUNCFI: - case FLOORFI: - user_trap = round_iv(op1, op2, xopcode); - break; - case SCALBF: - user_trap = scalb_iv(op1, op2); - break; - case LOGBF: - user_trap = logb_iv(op1, op2); - break; - case DOTF: - user_trap = dot_iv(op1, op2, f0_op); - break; - case POLYF: - user_trap = poly_iv(op1, op2, f0_op); - break; - } - return user_trap; + /* Don't fiddle with fsr. The FPC_TT_INVOP bit should only be set + * if we attempt to *generate* a NaN. This is achieved by returning + * FPC_TT_INVOP when we generate a NaN. + */ + /* + * Figure out right thing to do. + */ + switch(xopcode) { + case NEGF: + if (! ISNAN(op1->data)) + op1->data.d_bits.sign ^= 1; + /* Fall through */ + case MOVF: + case MOVLF: + case MOVFL: + op2->data = op1->data; + break; + case CMPF: + cmp_iv(op1, op2, mystate); + break; + case SUBF: + if (! ISNAN(op1->data)) + op1->data.d_bits.sign ^= 1; + /* Fall through */ + case ADDF: + user_trap = add_iv(op1, op2); + break; + case MULF: + user_trap = mul_iv(op1, op2); + break; + case DIVF: + user_trap = div_iv(op1, op2); + break; + case ROUNDFI: + case TRUNCFI: + case FLOORFI: + user_trap = round_iv(op1, op2, xopcode); + break; + case SCALBF: + user_trap = scalb_iv(op1, op2); + break; + case LOGBF: + user_trap = logb_iv(op1, op2); + break; + case DOTF: + user_trap = dot_iv(op1, op2, f0_op); + break; + case POLYF: + user_trap = poly_iv(op1, op2, f0_op); + break; + } + return user_trap; } diff --git a/sys/arch/pc532/fpu/ieee_ovfl.c b/sys/arch/pc532/fpu/ieee_ovfl.c index c1f5360bdf9..3f05b2e384e 100644 --- a/sys/arch/pc532/fpu/ieee_ovfl.c +++ b/sys/arch/pc532/fpu/ieee_ovfl.c @@ -1,4 +1,4 @@ -/* $NetBSD: ieee_ovfl.c,v 1.7 2005/12/11 12:18:31 christos Exp $ */ +/* $NetBSD: ieee_ovfl.c,v 1.8 2006/05/12 06:05:23 simonb Exp $ */ /* * IEEE floating point support for NS32081 and NS32381 fpus. @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ieee_ovfl.c,v 1.7 2005/12/11 12:18:31 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ieee_ovfl.c,v 1.8 2006/05/12 06:05:23 simonb Exp $"); #include "ieee_internal.h" @@ -39,75 +39,77 @@ __KERNEL_RCSID(0, "$NetBSD: ieee_ovfl.c,v 1.7 2005/12/11 12:18:31 christos Exp $ #include <limits.h> #endif -int ieee_ovfl(struct operand *op1, struct operand *op2, - struct operand *f0_op, int xopcode, state *mystate) +int ieee_ovfl(struct operand *op1, struct operand *op2, struct operand *f0_op, + int xopcode, state *mystate) { - int user_trap = FPC_TT_NONE; - unsigned int fsr = mystate->FSR; + int user_trap = FPC_TT_NONE; + unsigned int fsr = mystate->FSR; - fsr |= FPC_OVF; - if (fsr & FPC_OVE) { - /* Users trap handler will fix it */ - user_trap = FPC_TT_OVFL; - } - else { - /* If destination is float or double, set to +- Infty, else - * if byte, word or long, set to max/min int. - */ - int sign1 = op1->data.d_bits.sign; - int sign2 = op2->data.d_bits.sign; - switch(xopcode) { - case NEGF: - sign1 ^= 1; - /* Fall through */ - case MOVF: - case MOVLF: - case MOVFL: - op2->data = infty; - op2->data.d_bits.sign = sign1; - break; - case CMPF: - /* Can't happen */ - break; - case SUBF: - sign1 ^= 1; - /* Fall through */ - case ADDF: - /* Overflow can only happen if both operands are same sign */ - op2->data = infty; - op2->data.d_bits.sign = sign2; - break; - case MULF: - case DIVF: - op2->data = infty; - op2->data.d_bits.sign = sign1 ^ sign2; - break; - case ROUNDFI: - case TRUNCFI: - case FLOORFI: - op2->data.i = sign1? INT_MIN: INT_MAX; - break; - case SCALBF: - op2->data = infty; - op2->data.d_bits.sign = sign1; - break; - case LOGBF: - op2->data = infty; - op2->data.d_bits.sign = ISZERO(op1->data)? 1: 0; - break; - case DOTF: - (void) ieee_dot(op1->data.d, op2->data.d, &f0_op->data.d); - break; - case POLYF: - { - union t_conv t; - t = op2->data; - (void) ieee_dot(f0_op->data.d, op1->data.d, &t.d); - f0_op->data = t; - } - break; - } - } - mystate->FSR = fsr; - return user_trap; + fsr |= FPC_OVF; + if (fsr & FPC_OVE) { + /* Users trap handler will fix it */ + user_trap = FPC_TT_OVFL; + } else { + /* If destination is float or double, set to +- Infty, else + * if byte, word or long, set to max/min int. + */ + int sign1 = op1->data.d_bits.sign; + int sign2 = op2->data.d_bits.sign; + switch(xopcode) { + case NEGF: + sign1 ^= 1; + /* Fall through */ + case MOVF: + case MOVLF: + case MOVFL: + op2->data = infty; + op2->data.d_bits.sign = sign1; + break; + case CMPF: + /* Can't happen */ + break; + case SUBF: + sign1 ^= 1; + /* Fall through */ + case ADDF: + /* + * Overflow can only happen if both operands are same + * sign. + */ + op2->data = infty; + op2->data.d_bits.sign = sign2; + break; + case MULF: + case DIVF: + op2->data = infty; + op2->data.d_bits.sign = sign1 ^ sign2; + break; + case ROUNDFI: + case TRUNCFI: + case FLOORFI: + op2->data.i = sign1? INT_MIN: INT_MAX; + break; + case SCALBF: + op2->data = infty; + op2->data.d_bits.sign = sign1; + break; + case LOGBF: + op2->data = infty; + op2->data.d_bits.sign = ISZERO(op1->data)? 1: 0; + break; + case DOTF: + (void)ieee_dot(op1->data.d, op2->data.d, + &f0_op->data.d); + break; + case POLYF: { + union t_conv t; + t = op2->data; + (void)ieee_dot(f0_op->data.d, op1->data.d, &t.d); + f0_op->data = t; + break; + } + } + } + mystate->FSR = fsr; + return user_trap; } diff --git a/sys/arch/pc532/fpu/ieee_subnormal.c b/sys/arch/pc532/fpu/ieee_subnormal.c index 20c9123662b..652ff471a85 100644 --- a/sys/arch/pc532/fpu/ieee_subnormal.c +++ b/sys/arch/pc532/fpu/ieee_subnormal.c @@ -1,4 +1,4 @@ -/* $NetBSD: ieee_subnormal.c,v 1.5 2005/12/11 12:18:31 christos Exp $ */ +/* $NetBSD: ieee_subnormal.c,v 1.6 2006/05/12 06:05:23 simonb Exp $ */ /* * IEEE floating point support for NS32081 and NS32381 fpus. @@ -30,70 +30,78 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ieee_subnormal.c,v 1.5 2005/12/11 12:18:31 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ieee_subnormal.c,v 1.6 2006/05/12 06:05:23 simonb Exp $"); #include "ieee_internal.h" #include <machine/psl.h> /* Return bit pos numbered from lsb 0 to 31. Returns 31 if no bit is set */ -static int find_msb(unsigned int t) { - static const int b_mask[] = { - 0xffff0000, - 0xff00ff00, - 0xf0f0f0f0, - 0xcccccccc, - 0xaaaaaaaa }; - int i; - int pos = 31; - int bit_incr = 16; /* Half no of bits in int */ - for (i = 0; i < 5; i++, bit_incr /= 2) { - if(t & b_mask[i]) { - t &= b_mask[i]; - } - else { - pos -= bit_incr; - t &= ~b_mask[i]; - } - } - return pos; +static int +find_msb(unsigned int t) +{ + static const int b_mask[] = { + 0xffff0000, + 0xff00ff00, + 0xf0f0f0f0, + 0xcccccccc, + 0xaaaaaaaa + }; + int i; + int pos = 31; + int bit_incr = 16; /* Half no of bits in int */ + + for (i = 0; i < 5; i++, bit_incr /= 2) { + if (t & b_mask[i]) { + t &= b_mask[i]; + } else { + pos -= bit_incr; + t &= ~b_mask[i]; + } + } + return pos; } -static int leading_zeros(union t_conv *data) +static int +leading_zeros(union t_conv *data) { - unsigned int t; - if ((t = data->d_bits.mantissa)) { - return 19 - find_msb(t); - } - else if ((t = data->d_bits.mantissa2)) { - return 51 - find_msb(t); - } - else - return 52; + unsigned int t; + + if ((t = data->d_bits.mantissa)) { + return 19 - find_msb(t); + } else if ((t = data->d_bits.mantissa2)) { + return 51 - find_msb(t); + } else + return 52; } -static void lshift_mantissa(union t_conv *data, int n) +static void +lshift_mantissa(union t_conv *data, int n) { - unsigned long t[2]; - t[1] = data->d_bits.mantissa; - t[0] = data->d_bits.mantissa2; - *(unsigned long long *) t <<= n; - data->d_bits.mantissa = t[1]; - data->d_bits.mantissa2 = t[0]; + unsigned long t[2]; + + t[1] = data->d_bits.mantissa; + t[0] = data->d_bits.mantissa2; + *(unsigned long long *) t <<= n; + data->d_bits.mantissa = t[1]; + data->d_bits.mantissa2 = t[0]; } -static void rshift_mantissa(union t_conv *data, int n) +static void +rshift_mantissa(union t_conv *data, int n) { - unsigned long t[2]; - t[1] = data->d_bits.mantissa | 0x100000; - t[0] = data->d_bits.mantissa2; - *(unsigned long long *) t >>= n; - data->d_bits.mantissa = t[1]; - data->d_bits.mantissa2 = t[0]; + unsigned long t[2]; + + t[1] = data->d_bits.mantissa | 0x100000; + t[0] = data->d_bits.mantissa2; + *(unsigned long long *) t >>= n; + data->d_bits.mantissa = t[1]; + data->d_bits.mantissa2 = t[0]; } -/* After this, the data is a normal double and the returned value is +/* + * After this, the data is a normal double and the returned value is * such that: * union t_conv t; * t = *data; @@ -102,333 +110,356 @@ static void rshift_mantissa(union t_conv *data, int n) * * Assume data is not already normalized. */ -int ieee_normalize(union t_conv *data) +int +ieee_normalize(union t_conv *data) { - int norm; - if(data->d_bits.exp != 0) - return 0; - norm = leading_zeros(data) + 1; /* plus one for the implied bit */ - data->d_bits.exp = 1; - lshift_mantissa(data, norm); - return -norm; + int norm; + + if (data->d_bits.exp != 0) + return 0; + norm = leading_zeros(data) + 1; /* plus one for the implied bit */ + data->d_bits.exp = 1; + lshift_mantissa(data, norm); + return -norm; } /* Divide by 2**n producing a denormalized no if necessary */ -static void denormalize(union t_conv *data, int n) +static void +denormalize(union t_conv *data, int n) { - int exp = data->d_bits.exp; - if(exp > n) - exp -= n; - else if (exp <= n) { - rshift_mantissa(data, n - exp + 1); /* plus 1 for the implied bit */ - exp = 0; - } - data->d_bits.exp = exp; + int exp = data->d_bits.exp; + + if (exp > n) + exp -= n; + else if (exp <= n) { + rshift_mantissa(data, n - exp + 1); + /* plus 1 for the implied bit */ + exp = 0; + } + data->d_bits.exp = exp; } -static int scale_and_check(union t_conv *d, int scale) +static int +scale_and_check(union t_conv *d, int scale) { - int exp; - exp = d->d_bits.exp - scale; - if(exp >= 0x7ff) { - /* Overflow */ - d->d_bits.exp = 0x7ff; - d->d_bits.mantissa = 0; - d->d_bits.mantissa2 = 0; /* XXX sig */ - return FPC_TT_OVFL; - } - if(exp <= 0) { - /* Underflow */ - denormalize(d, scale); /* XXX sig */ - return FPC_TT_UNDFL; - } - d->d_bits.exp = exp; - return FPC_TT_NONE; -} + int exp; + exp = d->d_bits.exp - scale; + if (exp >= 0x7ff) { + /* Overflow */ + d->d_bits.exp = 0x7ff; + d->d_bits.mantissa = 0; + d->d_bits.mantissa2 = 0; /* XXX sig */ + return FPC_TT_OVFL; + } + if (exp <= 0) { + /* Underflow */ + denormalize(d, scale); /* XXX sig */ + return FPC_TT_UNDFL; + } + d->d_bits.exp = exp; + return FPC_TT_NONE; +} -/* Add two doubles, not caring if one or both is a de-norm. +/* + * Add two doubles, not caring if one or both is a de-norm. * Strategy: First scale and normalize operands so the addition * can't overflow or underflow, then do a normal floating point * addition, then scale back and possibly denormalize. */ -int ieee_add(double data1, double *data2) +int +ieee_add(double data1, double *data2) { - union t_conv d1 = (union t_conv) data1; - union t_conv *d2 = (union t_conv *) data2; - int scale; - int norm1 = ieee_normalize(&d1); - int norm2 = ieee_normalize(d2); - int exp1 = d1.d_bits.exp + norm1; - int exp2 = d2->d_bits.exp + norm2; - if(exp1 > exp2) { - scale = EXP_DBIAS - exp1; - exp1 = EXP_DBIAS; - exp2 += scale; - } - else { - scale = EXP_DBIAS - exp2; - exp2 = EXP_DBIAS; - exp1 += scale; - } - if(exp1 > 0) { - d1.d_bits.exp = exp1; - if (exp2 > 0) { - d2->d_bits.exp = exp2; - d2->d += d1.d; - } - else { - d2->d = d1.d; - } - } - else { - d2->d_bits.exp = exp2; - } - return scale_and_check(d2, scale); + union t_conv d1 = (union t_conv) data1; + union t_conv *d2 = (union t_conv *) data2; + int scale; + int norm1 = ieee_normalize(&d1); + int norm2 = ieee_normalize(d2); + int exp1 = d1.d_bits.exp + norm1; + int exp2 = d2->d_bits.exp + norm2; + + if (exp1 > exp2) { + scale = EXP_DBIAS - exp1; + exp1 = EXP_DBIAS; + exp2 += scale; + } else { + scale = EXP_DBIAS - exp2; + exp2 = EXP_DBIAS; + exp1 += scale; + } + if (exp1 > 0) { + d1.d_bits.exp = exp1; + if (exp2 > 0) { + d2->d_bits.exp = exp2; + d2->d += d1.d; + } else { + d2->d = d1.d; + } + } else { + d2->d_bits.exp = exp2; + } + return scale_and_check(d2, scale); } -/* Multiply two doubles, not caring if one or both is a de-norm. +/* + * Multiply two doubles, not caring if one or both is a de-norm. * Strategy: First scale and normalize operands so the multiplication * can't overflow or underflow, then do a normal floating point * addition, then scale back and possibly denormalize. */ -int ieee_mul(double data1, double *data2) +int +ieee_mul(double data1, double *data2) { - union t_conv d1 = (union t_conv) data1; - union t_conv *d2 = (union t_conv *) data2; - int scale; - int norm1 = ieee_normalize(&d1); - int norm2 = ieee_normalize(d2); - int exp1 = d1.d_bits.exp + norm1; - int exp2 = d2->d_bits.exp + norm2; - d1.d_bits.exp = EXP_DBIAS; /* Add EXP_DBIAS - exp1 */ - d2->d_bits.exp = EXP_DBIAS; - d2->d *= d1.d; - scale = EXP_DBIAS - exp1 + EXP_DBIAS - exp2; - return scale_and_check(d2, scale); + union t_conv d1 = (union t_conv) data1; + union t_conv *d2 = (union t_conv *) data2; + int scale; + int norm1 = ieee_normalize(&d1); + int norm2 = ieee_normalize(d2); + int exp1 = d1.d_bits.exp + norm1; + int exp2 = d2->d_bits.exp + norm2; + + d1.d_bits.exp = EXP_DBIAS; /* Add EXP_DBIAS - exp1 */ + d2->d_bits.exp = EXP_DBIAS; + d2->d *= d1.d; + scale = EXP_DBIAS - exp1 + EXP_DBIAS - exp2; + return scale_and_check(d2, scale); } -/* Divide d2 by d1, not caring if one or both is a de-norm. +/* + * Divide d2 by d1, not caring if one or both is a de-norm. * Strategy: First scale and normalize operands so the division * can't overflow or underflow, then do a normal floating point * division, then scale back and possibly denormalize. */ -int ieee_div(double data1, double *data2) +int +ieee_div(double data1, double *data2) { - union t_conv d1 = (union t_conv) data1; - union t_conv *d2 = (union t_conv *) data2; - int scale; - int norm1 = ieee_normalize(&d1); - int norm2 = ieee_normalize(d2); - int exp1 = d1.d_bits.exp + norm1; - int exp2 = d2->d_bits.exp + norm2; - d1.d_bits.exp = EXP_DBIAS; /* Add EXP_DBIAS - exp1 */ - d2->d_bits.exp = EXP_DBIAS; - d2->d /= d1.d; - scale = exp1 - exp2; - return scale_and_check(d2, scale); + union t_conv d1 = (union t_conv) data1; + union t_conv *d2 = (union t_conv *) data2; + int scale; + int norm1 = ieee_normalize(&d1); + int norm2 = ieee_normalize(d2); + int exp1 = d1.d_bits.exp + norm1; + int exp2 = d2->d_bits.exp + norm2; + + d1.d_bits.exp = EXP_DBIAS; /* Add EXP_DBIAS - exp1 */ + d2->d_bits.exp = EXP_DBIAS; + d2->d /= d1.d; + scale = exp1 - exp2; + return scale_and_check(d2, scale); } -/* Add mul-add three doubles d1 * d2 + d3 -> d3, not caring if any a de-norm. +/* + * Add mul-add three doubles d1 * d2 + d3 -> d3, not caring if any a de-norm. * Strategy: First scale and normalize operands so the operations * can't overflow or underflow, then do a normal floating point operation * addition, then scale back and possibly denormalize. */ -int ieee_dot(double data1, double data2, double *data3) +int +ieee_dot(double data1, double data2, double *data3) { - union t_conv d1 = (union t_conv) data1; - union t_conv d2 = (union t_conv) data2; - union t_conv *d3 = (union t_conv *) data3; - int scale; - int norm1 = ieee_normalize(&d1); - int norm2 = ieee_normalize(&d2); - int norm3 = ieee_normalize(d3); - int exp1 = d1.d_bits.exp + norm1; - int exp2 = d2.d_bits.exp + norm2; - int exp3 = d3->d_bits.exp + norm3; - int exp_prod = exp1 + exp2; - if(exp_prod > exp3) { - scale = EXP_DBIAS + EXP_DBIAS - exp_prod; - exp1 = EXP_DBIAS; /* Add EXP_DBIAS - exp1 */ - exp2 = EXP_DBIAS; - exp3 += scale; - } - else { - scale = EXP_DBIAS - exp3; - exp3 = EXP_DBIAS; - exp1 = (exp_prod + scale)/2; - exp2 = exp_prod + scale - exp1; - } - - if(exp1 > 0 && exp2 > 0) { - d1.d_bits.exp = exp1; - d2.d_bits.exp = exp2; - if(exp3 > 0) { - d3->d_bits.exp = exp3; - d3->d += d1.d * d2.d; - } - else { - d3->d = d1.d * d2.d; - } - } - else { - d3->d_bits.exp = exp3; - } - return scale_and_check(d3, scale); + union t_conv d1 = (union t_conv) data1; + union t_conv d2 = (union t_conv) data2; + union t_conv *d3 = (union t_conv *) data3; + int scale; + int norm1 = ieee_normalize(&d1); + int norm2 = ieee_normalize(&d2); + int norm3 = ieee_normalize(d3); + int exp1 = d1.d_bits.exp + norm1; + int exp2 = d2.d_bits.exp + norm2; + int exp3 = d3->d_bits.exp + norm3; + int exp_prod = exp1 + exp2; + + if (exp_prod > exp3) { + scale = EXP_DBIAS + EXP_DBIAS - exp_prod; + exp1 = EXP_DBIAS; /* Add EXP_DBIAS - exp1 */ + exp2 = EXP_DBIAS; + exp3 += scale; + } else { + scale = EXP_DBIAS - exp3; + exp3 = EXP_DBIAS; + exp1 = (exp_prod + scale)/2; + exp2 = exp_prod + scale - exp1; + } + + if (exp1 > 0 && exp2 > 0) { + d1.d_bits.exp = exp1; + d2.d_bits.exp = exp2; + if (exp3 > 0) { + d3->d_bits.exp = exp3; + d3->d += d1.d * d2.d; + } else { + d3->d = d1.d * d2.d; + } + } else { + d3->d_bits.exp = exp3; + } + return scale_and_check(d3, scale); } -/* Compare the magnitude of two ops. +/* + * Compare the magnitude of two ops. * return: 1 |op1| > |op2| * -1 |op1| < |op2| * 0 |op1| == |op2| */ -static int u_cmp(double data1, double data2) +static int +u_cmp(double data1, double data2) { - union t_conv d1 = (union t_conv) data1; - union t_conv d2 = (union t_conv) data2; - int exp1 = d1.d_bits.exp; - int exp2 = d2.d_bits.exp; - if (exp1 > exp2) - return 1; - else if (exp1 < exp2) - return -1; - else if (d1.d_bits.mantissa > d2.d_bits.mantissa) - return 1; - else if (d1.d_bits.mantissa < d2.d_bits.mantissa) - return -1; - else if (d1.d_bits.mantissa2 > d2.d_bits.mantissa2) - return 1; - else if (d1.d_bits.mantissa2 < d2.d_bits.mantissa2) - return -1; - else - return 0; + union t_conv d1 = (union t_conv) data1; + union t_conv d2 = (union t_conv) data2; + int exp1 = d1.d_bits.exp; + int exp2 = d2.d_bits.exp; + + if (exp1 > exp2) + return 1; + else if (exp1 < exp2) + return -1; + else if (d1.d_bits.mantissa > d2.d_bits.mantissa) + return 1; + else if (d1.d_bits.mantissa < d2.d_bits.mantissa) + return -1; + else if (d1.d_bits.mantissa2 > d2.d_bits.mantissa2) + return 1; + else if (d1.d_bits.mantissa2 < d2.d_bits.mantissa2) + return -1; + else + return 0; } -void ieee_cmp(double data1, double data2, state *mystate) +void +ieee_cmp(double data1, double data2, state *mystate) { - union t_conv d1 = (union t_conv) data1; - union t_conv d2 = (union t_conv) data2; - int sign1 = d1.d_bits.sign; - int sign2 = d2.d_bits.sign; - mystate->PSR &= ~(PSR_N | PSR_Z | PSR_L); - switch(sign2 * 2 + sign1) { - case 2: /* op2 is negative op1 is positive */ - mystate->PSR |= PSR_N; - break; - case 1: /* op2 is positive op1 is negative */ - break; - case 0: /* Both ops same sign */ - case 3: - { - int cmp = u_cmp(d1.d, d2.d); - if(sign1) - cmp *= -1; - if(cmp > 0) - mystate->PSR |= PSR_N; - else if (cmp == 0) - mystate->PSR |= PSR_Z; - } - break; - } - return; + union t_conv d1 = (union t_conv) data1; + union t_conv d2 = (union t_conv) data2; + int sign1 = d1.d_bits.sign; + int sign2 = d2.d_bits.sign; + int cmp; + + mystate->PSR &= ~(PSR_N | PSR_Z | PSR_L); + switch(sign2 * 2 + sign1) { + case 2: /* op2 is negative op1 is positive */ + mystate->PSR |= PSR_N; + break; + case 1: /* op2 is positive op1 is negative */ + break; + case 0: /* Both ops same sign */ + case 3: + cmp = u_cmp(d1.d, d2.d); + + if (sign1) + cmp *= -1; + if (cmp > 0) + mystate->PSR |= PSR_N; + else if (cmp == 0) + mystate->PSR |= PSR_Z; + break; + } + return; } -int ieee_scalb(double data1, double *data2) +int +ieee_scalb(double data1, double *data2) { - union t_conv d1 = (union t_conv) data1; - union t_conv *d2 = (union t_conv *) data2; - int exp2 = d2->d_bits.exp - EXP_DBIAS; - int n; - if (exp2 > 16) { - *d2 = infty; - d2->d_bits.sign = d1.d_bits.sign; - return FPC_TT_OVFL; - } - else if (exp2 < -16) { - d2->d = 0.0; - d2->d_bits.sign = d1.d_bits.sign; - return FPC_TT_OVFL; - } - n = d2->d; - *d2 = d1; - return scale_and_check(d2, n); + union t_conv d1 = (union t_conv) data1; + union t_conv *d2 = (union t_conv *) data2; + int exp2 = d2->d_bits.exp - EXP_DBIAS; + int n; + + if (exp2 > 16) { + *d2 = infty; + d2->d_bits.sign = d1.d_bits.sign; + return FPC_TT_OVFL; + } else if (exp2 < -16) { + d2->d = 0.0; + d2->d_bits.sign = d1.d_bits.sign; + return FPC_TT_OVFL; + } + n = d2->d; + *d2 = d1; + return scale_and_check(d2, n); } -/* With no trap, hardware produces zero, which is fast but not +/* + * With no trap, hardware produces zero, which is fast but not * strictly correct. We should always have the hardware trap bit set * and generate denormalized numbers by simulation unless the user - * indicates via the FPC_UNDE flag they want to handle it. */ + * indicates via the FPC_UNDE flag they want to handle it. + */ -int ieee_undfl(struct operand *op1, struct operand *op2, - struct operand *f0_op, int xopcode, state *mystate) +int ieee_undfl(struct operand *op1, struct operand *op2, struct operand *f0_op, + int xopcode, state *mystate) { - unsigned int fsr = mystate->FSR; - int user_trap = FPC_TT_NONE; - DP(1, "Underflow trap: xopcode = 0x%x\n", xopcode); - if (fsr & FPC_UNDE) { - user_trap = FPC_TT_UNDFL; - } - else { - user_trap = FPC_TT_NONE; - /* Calculate correct denormal output. The easiest way is to - * prescale the operands so they won't underflow, then use the - * hardware operation, then post scale. - */ - - /* The exact sematics are a bit tricky. Apparently, we should only - * set flag if we underflowed *and* there was loss of precision - * For now, just set the flag always XXX - */ - fsr |= FPC_UF; - - switch(xopcode) { - case NEGF: - op1->data.d_bits.sign ^= 1; - /* Fall through */ - case MOVF: - case MOVLF: - case MOVFL: - op2->data = op1->data; - break; - case CMPF: - ieee_cmp(op1->data.d, op2->data.d, mystate); - break; - case SUBF: - op1->data.d_bits.sign ^= 1; - /* Fall through */ - case ADDF: - user_trap = ieee_add(op1->data.d, &op2->data.d); - break; - case MULF: - user_trap = ieee_mul(op1->data.d, &op2->data.d); - break; - case DIVF: - user_trap = ieee_div(op1->data.d, &op2->data.d); - break; - case ROUNDFI: - case TRUNCFI: - case FLOORFI: - op2->data.i = 0; - break; - case SCALBF: - user_trap = ieee_scalb(op1->data.d, &op2->data.d); - break; - case LOGBF: - op2->data.d = 0.0; - break; - case DOTF: - user_trap = ieee_dot(op1->data.d, op2->data.d, &f0_op->data.d); - break; - case POLYF: - { - union t_conv t = op2->data; - user_trap = ieee_dot(f0_op->data.d, op1->data.d, &t.d); - f0_op->data = t; - } - break; - } - } - mystate->FSR = fsr; - return user_trap; + unsigned int fsr = mystate->FSR; + int user_trap = FPC_TT_NONE; + + DP(1, "Underflow trap: xopcode = 0x%x\n", xopcode); + if (fsr & FPC_UNDE) { + user_trap = FPC_TT_UNDFL; + } else { + user_trap = FPC_TT_NONE; + /* + * Calculate correct denormal output. The easiest way is to + * prescale the operands so they won't underflow, then use the + * hardware operation, then post scale. + */ + + /* + * The exact sematics are a bit tricky. Apparently, we should + * only set flag if we underflowed *and* there was loss of + * precision. + * For now, just set the flag always XXX + */ + fsr |= FPC_UF; + + switch(xopcode) { + case NEGF: + op1->data.d_bits.sign ^= 1; + /* Fall through */ + case MOVF: + case MOVLF: + case MOVFL: + op2->data = op1->data; + break; + case CMPF: + ieee_cmp(op1->data.d, op2->data.d, mystate); + break; + case SUBF: + op1->data.d_bits.sign ^= 1; + /* Fall through */ + case ADDF: + user_trap = ieee_add(op1->data.d, &op2->data.d); + break; + case MULF: + user_trap = ieee_mul(op1->data.d, &op2->data.d); + break; + case DIVF: + user_trap = ieee_div(op1->data.d, &op2->data.d); + break; + case ROUNDFI: + case TRUNCFI: + case FLOORFI: + op2->data.i = 0; + break; + case SCALBF: + user_trap = ieee_scalb(op1->data.d, &op2->data.d); + break; + case LOGBF: + op2->data.d = 0.0; + break; + case DOTF: + user_trap = + ieee_dot(op1->data.d, op2->data.d, &f0_op->data.d); + break; + case POLYF: { + union t_conv t = op2->data; + user_trap = ieee_dot(f0_op->data.d, op1->data.d, &t.d); + f0_op->data = t; + } + break; + } + } + mystate->FSR = fsr; + return user_trap; } diff --git a/sys/arch/pc532/include/asm.h b/sys/arch/pc532/include/asm.h index c638ed8c9bd..09259999a4a 100644 --- a/sys/arch/pc532/include/asm.h +++ b/sys/arch/pc532/include/asm.h @@ -1,4 +1,4 @@ -/* $NetBSD: asm.h,v 1.19 2006/01/20 22:02:40 christos Exp $ */ +/* $NetBSD: asm.h,v 1.20 2006/05/12 06:05:23 simonb Exp $ */ /* * Mach Operating System @@ -29,7 +29,7 @@ */ /* - * File: asm.h + * File: asm.h * Author: Johannes Helander, Tero Kivinen, Tatu Ylonen * Modified by Phil Nelson for NetBSD. * Modified by Matthias Pfaller for PIC. @@ -69,7 +69,7 @@ #ifdef PIC #define PIC_PROLOGUE \ - sprd sb,tos ; \ + sprd sb,tos ; \ addr _C_LABEL(_GLOBAL_OFFSET_TABLE_)(pc),r1; \ lprd sb,r1 @@ -113,7 +113,7 @@ # ifndef _SAVELIST # define _SAVELIST # endif -# define _PROF_PROLOGUE \ +# define _PROF_PROLOGUE \ enter [_SAVELIST],0 ; \ bsr _ASM_LABEL(mcount) ; \ exit [_SAVELIST] @@ -198,7 +198,7 @@ */ #define PANIC(message) \ addr 9f,tos ; \ - bsr _C_LABEL(panic) ; \ + bsr _C_LABEL(panic) ; \ 9: .asciz message /* diff --git a/sys/arch/pc532/include/cpu.h b/sys/arch/pc532/include/cpu.h index 37fd6753c58..79fdabe89fc 100644 --- a/sys/arch/pc532/include/cpu.h +++ b/sys/arch/pc532/include/cpu.h @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.44 2005/12/11 12:18:31 christos Exp $ */ +/* $NetBSD: cpu.h,v 1.45 2006/05/12 06:05:23 simonb Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -65,7 +65,7 @@ extern struct cpu_info cpu_info_store; * referenced in generic code */ #define cpu_proc_fork(p1, p2) /* nothing */ -#define cpu_swapin(p) /* nothing */ +#define cpu_swapin(p) /* nothing */ #define cpu_number() 0 /* @@ -107,28 +107,27 @@ int want_resched; /* resched() was called */ * We need a machine-independent name for this. */ #define DELAY(n) delay(n) -void delay __P((int)); /* ieee_handler.c */ -int ieee_handle_exception __P((struct lwp *)); +int ieee_handle_exception(struct lwp *); /* locore.s */ -void delay __P((int)); struct pcb; -void proc_trampoline __P((void)); -int ram_size __P((void *)); -void restore_fpu_context __P((struct pcb *)); -void save_fpu_context __P((struct pcb *)); +void delay(int); +void proc_trampoline(void); +int ram_size(void *); +void restore_fpu_context(struct pcb *); +void save_fpu_context(struct pcb *); /* machdep.c */ -void dumpconf __P((void)); -void softnet __P((void *)); +void dumpconf(void); +void softnet(void *); /* mainbus.c */ -void icu_init __P((u_char *)); +void icu_init(u_char *); /* vm_machdep.c */ -int kvtop __P((caddr_t)); +int kvtop(caddr_t); #endif /* _KERNEL */ diff --git a/sys/arch/pc532/include/db_machdep.h b/sys/arch/pc532/include/db_machdep.h index 3e17c6d6a22..2ffb3436962 100644 --- a/sys/arch/pc532/include/db_machdep.h +++ b/sys/arch/pc532/include/db_machdep.h @@ -1,4 +1,4 @@ -/* $NetBSD: db_machdep.h,v 1.19 2006/04/01 15:44:59 cherry Exp $ */ +/* $NetBSD: db_machdep.h,v 1.20 2006/05/12 06:05:23 simonb Exp $ */ /* * Mach Operating System @@ -58,7 +58,7 @@ typedef vaddr_t db_addr_t; /* address - unsigned */ typedef long db_expr_t; /* expression - signed */ typedef struct trapframe db_regs_t; -db_regs_t ddb_regs; /* register state */ +db_regs_t ddb_regs; /* register state */ #define DDB_REGS (&ddb_regs) #define PC_REGS(regs) ((db_addr_t)(regs)->tf_regs.r_pc) @@ -101,9 +101,9 @@ typedef long kgdb_reg_t; #ifdef _KERNEL -int kdb_trap __P((int, int, db_regs_t *)); +int kdb_trap(int, int, db_regs_t *); struct insn; -int db_dasm_ns32k __P((struct insn *insn, db_addr_t loc)); +int db_dasm_ns32k(struct insn *insn, db_addr_t loc); #endif /* _KERNEL */ diff --git a/sys/arch/pc532/include/ieeefp.h b/sys/arch/pc532/include/ieeefp.h index c80f50f25d2..330a4cbae9b 100644 --- a/sys/arch/pc532/include/ieeefp.h +++ b/sys/arch/pc532/include/ieeefp.h @@ -1,4 +1,4 @@ -/* $NetBSD: ieeefp.h,v 1.5 2005/12/11 12:18:31 christos Exp $ */ +/* $NetBSD: ieeefp.h,v 1.6 2006/05/12 06:05:23 simonb Exp $ */ /* * Written by J.T. Conklin, Apr 28, 1995 @@ -16,10 +16,10 @@ typedef int fp_except; #define FP_X_UFL 0x8000 /* underflow exception */ typedef enum { - FP_RN=0, /* round to nearest representable number */ - FP_RZ=1, /* round to zero (truncate) */ - FP_RP=2, /* round toward positive infinity */ - FP_RM=3 /* round toward negative infinity */ + FP_RN=0, /* round to nearest representable number */ + FP_RZ=1, /* round to zero (truncate) */ + FP_RP=2, /* round toward positive infinity */ + FP_RM=3 /* round toward negative infinity */ } fp_rnd; #endif /* _PC532_IEEEFP_H_ */ diff --git a/sys/arch/pc532/include/intr.h b/sys/arch/pc532/include/intr.h index a9ae8d9d6b2..ac6adab3a4b 100644 --- a/sys/arch/pc532/include/intr.h +++ b/sys/arch/pc532/include/intr.h @@ -1,4 +1,4 @@ -/* $NetBSD: intr.h,v 1.9 2006/02/16 20:17:14 perry Exp $ */ +/* $NetBSD: intr.h,v 1.10 2006/05/12 06:05:23 simonb Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -75,7 +75,7 @@ * Structure of the software interrupt table */ struct iv { - void (*iv_vec) __P((void *)); + void (*iv_vec)(void *); void *iv_arg; long iv_level; long iv_mask; @@ -97,13 +97,13 @@ extern unsigned int imask[], Cur_pl, sirpending, astpending; # define INTR_INLINE __inline #endif -void intr_init __P((void)); -void check_sir __P((void *)); -int intr_establish __P((int, void (*)(void *), void *, const char *, - int, int, int)); +void intr_init(void); +void check_sir(void *); +int intr_establish(int, void (*)(void *), void *, const char *, int, int, + int); -INTR_STATIC INTR_INLINE int splraise __P((unsigned int)); -INTR_STATIC INTR_INLINE int splx __P((unsigned int)); +INTR_STATIC INTR_INLINE int splraise(unsigned int); +INTR_STATIC INTR_INLINE int splx(unsigned int); /* * Disable/Enable CPU-Interrupts @@ -117,10 +117,10 @@ INTR_STATIC INTR_INLINE int splx __P((unsigned int)); */ #if !defined(NO_INLINE_SPLX) || defined(DEFINE_SPLX) INTR_STATIC INTR_INLINE int -splraise(ncpl) - register unsigned int ncpl; +splraise(unsigned int ncpl) { - register unsigned int ocpl; + unsigned int ocpl; + di(); ocpl = Cur_pl; ncpl |= ocpl; @@ -138,10 +138,10 @@ splraise(ncpl) * usually optimized away by the compiler. */ INTR_STATIC INTR_INLINE int -splx(ncpl) - register unsigned int ncpl; +splx(unsigned int ncpl) { - register unsigned int ocpl; + unsigned int ocpl; + di(); ocpl = Cur_pl; ICUW(IMSK) = ncpl; diff --git a/sys/arch/pc532/include/kcore.h b/sys/arch/pc532/include/kcore.h index 6da7ce99c6f..6f182dcbe11 100644 --- a/sys/arch/pc532/include/kcore.h +++ b/sys/arch/pc532/include/kcore.h @@ -1,4 +1,4 @@ -/* $NetBSD: kcore.h,v 1.5 2005/12/11 12:18:31 christos Exp $ */ +/* $NetBSD: kcore.h,v 1.6 2006/05/12 06:05:23 simonb Exp $ */ /* * Copyright (c) 1997 Matthias Pfaller. @@ -35,7 +35,7 @@ typedef struct cpu_kcore_hdr { paddr_t ptd; /* Phys address of PTD */ - phys_ram_seg_t core_seg; /* Core addrs; only one seg */ + phys_ram_seg_t core_seg; /* Core addrs; only one seg */ } cpu_kcore_hdr_t; #endif /* _PC532_KCORE_H_ */ diff --git a/sys/arch/pc532/include/lock.h b/sys/arch/pc532/include/lock.h index cae10d01087..774cc6ec095 100644 --- a/sys/arch/pc532/include/lock.h +++ b/sys/arch/pc532/include/lock.h @@ -1,4 +1,4 @@ -/* $NetBSD: lock.h,v 1.8 2005/12/28 19:09:29 perry Exp $ */ +/* $NetBSD: lock.h,v 1.9 2006/05/12 06:05:23 simonb Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -43,13 +43,13 @@ #ifndef _PC532_LOCK_H_ #define _PC532_LOCK_H_ -static __inline void __cpu_simple_lock_init __P((__cpu_simple_lock_t *)) +static __inline void __cpu_simple_lock_init(__cpu_simple_lock_t *) __attribute__((__unused__)); -static __inline void __cpu_simple_lock __P((__cpu_simple_lock_t *)) +static __inline void __cpu_simple_lock(__cpu_simple_lock_t *) __attribute__((__unused__)); -static __inline int __cpu_simple_lock_try __P((__cpu_simple_lock_t *)) +static __inline int __cpu_simple_lock_try(__cpu_simple_lock_t *) __attribute__((__unused__)); -static __inline void __cpu_simple_unlock __P((__cpu_simple_lock_t *)) +static __inline void __cpu_simple_unlock(__cpu_simple_lock_t *) __attribute__((__unused__)); static __inline void diff --git a/sys/arch/pc532/include/param.h b/sys/arch/pc532/include/param.h index cae419e90b2..0dc2c9b9bf3 100644 --- a/sys/arch/pc532/include/param.h +++ b/sys/arch/pc532/include/param.h @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.32 2005/12/11 12:18:31 christos Exp $ */ +/* $NetBSD: param.h,v 1.33 2006/05/12 06:05:23 simonb Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -48,7 +48,7 @@ #include <machine/cpu.h> #endif -#define _MACHINE pc532 +#define _MACHINE pc532 #define MACHINE "pc532" #define _MACHINE_ARCH ns32k #define MACHINE_ARCH "ns32k" diff --git a/sys/arch/pc532/include/pmap.h b/sys/arch/pc532/include/pmap.h index 330bc547f5a..b1ec35e2b6b 100644 --- a/sys/arch/pc532/include/pmap.h +++ b/sys/arch/pc532/include/pmap.h @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.43 2006/02/16 20:17:14 perry Exp $ */ +/* $NetBSD: pmap.h,v 1.44 2006/05/12 06:05:23 simonb Exp $ */ /* * @@ -236,7 +236,7 @@ struct pmap { #define pm_lock pm_obj.vmobjlock LIST_ENTRY(pmap) pm_list; /* list (lck by pm_list lock) */ pd_entry_t *pm_pdir; /* VA of PD (lck by object lock) */ - u_int32_t pm_pdirpa; /* PA of PD (read-only after create) */ + uint32_t pm_pdirpa; /* PA of PD (read-only after create) */ struct vm_page *pm_ptphint; /* pointer to a PTP in our pmap */ struct pmap_statistics pm_stats; /* pmap stats (lck by object lock) */ }; @@ -331,34 +331,32 @@ extern int nkpde; /* current # of PDEs for kernel */ #define pmap_is_referenced(pg) pmap_test_attrs(pg, PG_U) #define pmap_move(DP,SP,D,L,S) #define pmap_phys_address(ppn) ns532_ptob(ppn) -#define pmap_valid_entry(E) ((E) & PG_V) /* is PDE or PTE valid? */ +#define pmap_valid_entry(E) ((E) & PG_V) /* is PDE or PTE valid? */ /* * prototypes */ -void pmap_bootstrap __P((vaddr_t)); -boolean_t pmap_change_attrs __P((struct vm_page *, int, int)); -static void pmap_page_protect __P((struct vm_page *, vm_prot_t)); -void pmap_page_remove __P((struct vm_page *)); -static void pmap_protect __P((struct pmap *, vaddr_t, - vaddr_t, vm_prot_t)); -void pmap_remove __P((struct pmap *, vaddr_t, vaddr_t)); -boolean_t pmap_test_attrs __P((struct vm_page *, int)); -static void pmap_update_pg __P((vaddr_t)); -static void pmap_update_2pg __P((vaddr_t,vaddr_t)); -void pmap_write_protect __P((struct pmap *, vaddr_t, - vaddr_t, vm_prot_t)); - -vaddr_t reserve_dumppages __P((vaddr_t)); /* XXX: not a pmap fn */ +void pmap_bootstrap(vaddr_t); +boolean_t pmap_change_attrs(struct vm_page *, int, int); +static void pmap_page_protect(struct vm_page *, vm_prot_t); +void pmap_page_remove(struct vm_page *); +static void pmap_protect(struct pmap *, vaddr_t, vaddr_t, vm_prot_t); +void pmap_remove(struct pmap *, vaddr_t, vaddr_t); +boolean_t pmap_test_attrs(struct vm_page *, int); +static void pmap_update_pg(vaddr_t); +static void pmap_update_2pg(vaddr_t,vaddr_t); +void pmap_write_protect(struct pmap *, vaddr_t, vaddr_t, vm_prot_t); + +vaddr_t reserve_dumppages(vaddr_t); /* XXX: not a pmap fn */ #define PMAP_GROWKERNEL /* turn on pmap_growkernel interface */ /* * Do idle page zero'ing uncached to avoid polluting the cache. */ -boolean_t pmap_zero_page_uncached __P((paddr_t)); +boolean_t pmap_zero_page_uncached(paddr_t); #define PMAP_PAGEIDLEZERO(pa) pmap_zero_page_uncached((pa)) /* @@ -368,6 +366,7 @@ boolean_t pmap_zero_page_uncached __P((paddr_t)); static __inline void pmap_remove_all(struct pmap *pmap) { + /* Nothing. */ } @@ -377,9 +376,9 @@ pmap_remove_all(struct pmap *pmap) */ __inline static void -pmap_update_pg(va) - vaddr_t va; +pmap_update_pg(vaddr_t va) { + tlbflush_entry((u_int) va); } @@ -388,9 +387,9 @@ pmap_update_pg(va) */ __inline static void -pmap_update_2pg(va, vb) - vaddr_t va, vb; +pmap_update_2pg(vaddr_t va, vaddr_t vb) { + tlbflush_entry((u_int) va); tlbflush_entry((u_int) vb); } @@ -405,10 +404,9 @@ pmap_update_2pg(va, vb) */ __inline static void -pmap_page_protect(pg, prot) - struct vm_page *pg; - vm_prot_t prot; +pmap_page_protect(struct vm_page *pg, vm_prot_t prot) { + if ((prot & VM_PROT_WRITE) == 0) { if (prot & (VM_PROT_READ|VM_PROT_EXECUTE)) { (void) pmap_change_attrs(pg, PG_RO, PG_RW); @@ -427,11 +425,9 @@ pmap_page_protect(pg, prot) */ __inline static void -pmap_protect(pmap, sva, eva, prot) - struct pmap *pmap; - vaddr_t sva, eva; - vm_prot_t prot; +pmap_protect(struct pmap *pmap, vaddr_t sva, vaddr_t eva, vm_prot_t prot) { + if ((prot & VM_PROT_WRITE) == 0) { if (prot & (VM_PROT_READ|VM_PROT_EXECUTE)) { pmap_write_protect(pmap, sva, eva, prot); @@ -470,8 +466,8 @@ kvtopte(vaddr_t va) return (PTE_BASE + ns532_btop(va)); } -paddr_t vtophys __P((vaddr_t)); -vaddr_t pmap_map __P((vaddr_t, paddr_t, paddr_t, vm_prot_t)); +paddr_t vtophys(vaddr_t); +vaddr_t pmap_map(vaddr_t, paddr_t, paddr_t, vm_prot_t); #endif /* _KERNEL */ #endif /* _NS532_PMAP_H_ */ diff --git a/sys/arch/pc532/include/profile.h b/sys/arch/pc532/include/profile.h index 97cc980f4a0..7d1f727018b 100644 --- a/sys/arch/pc532/include/profile.h +++ b/sys/arch/pc532/include/profile.h @@ -1,4 +1,4 @@ -/* $NetBSD: profile.h,v 1.13 2006/02/16 20:17:14 perry Exp $ */ +/* $NetBSD: profile.h,v 1.14 2006/05/12 06:05:23 simonb Exp $ */ /* * Copyright (c) 1992, 1993 @@ -35,7 +35,7 @@ */ /* profiles ... */ -__inline void _mcount __P((u_long, u_long)); +__inline void _mcount(u_long, u_long); void mcount(void); #define _MCOUNT_DECL __inline void _mcount @@ -47,6 +47,7 @@ void \ mcount(void) \ { \ int selfpc, frompcindex; \ + \ /* \ * find the return address for mcount, \ * and the return address for mcount's caller. \ diff --git a/sys/arch/pc532/include/pte.h b/sys/arch/pc532/include/pte.h index 2e3739b04e7..ac3df507529 100644 --- a/sys/arch/pc532/include/pte.h +++ b/sys/arch/pc532/include/pte.h @@ -1,4 +1,4 @@ -/* $NetBSD: pte.h,v 1.7 2005/12/11 12:18:31 christos Exp $ */ +/* $NetBSD: pte.h,v 1.8 2006/05/12 06:05:23 simonb Exp $ */ /* * @@ -125,8 +125,8 @@ * here we define the data types for PDEs and PTEs */ -typedef u_int32_t pd_entry_t; /* PDE */ -typedef u_int32_t pt_entry_t; /* PTE */ +typedef uint32_t pd_entry_t; /* PDE */ +typedef uint32_t pt_entry_t; /* PTE */ #endif diff --git a/sys/arch/pc532/include/reg.h b/sys/arch/pc532/include/reg.h index 033b935591b..772277a7584 100644 --- a/sys/arch/pc532/include/reg.h +++ b/sys/arch/pc532/include/reg.h @@ -1,4 +1,4 @@ -/* $NetBSD: reg.h,v 1.14 2005/12/11 12:18:31 christos Exp $ */ +/* $NetBSD: reg.h,v 1.15 2006/05/12 06:05:23 simonb Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -47,8 +47,10 @@ * Normal usage is u.u_ar0[XX] in kernel. */ -/* When referenced during a trap/exception and a syscall, - registers are at these offsets from p-p_regs*/ +/* + * When referenced during a trap/exception and a syscall, + * registers are at these offsets from p-p_regs. + */ #define REG_R0 (7) #define REG_R1 (6) diff --git a/sys/arch/pc532/include/userret.h b/sys/arch/pc532/include/userret.h index c56943125de..4fc6a1a128f 100644 --- a/sys/arch/pc532/include/userret.h +++ b/sys/arch/pc532/include/userret.h @@ -1,4 +1,4 @@ -/* $NetBSD: userret.h,v 1.1 2006/03/11 13:52:59 simonb Exp $ */ +/* $NetBSD: userret.h,v 1.2 2006/05/12 06:05:23 simonb Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -83,10 +83,7 @@ static inline void userret(struct lwp *, int, u_quad_t); * trap and syscall. */ static inline void -userret(l, pc, oticks) - struct lwp *l; - int pc; - u_quad_t oticks; +userret(struct lwp *l, int pc, u_quad_t oticks) { struct proc *p = l->l_proc; int sig; @@ -103,7 +100,7 @@ userret(l, pc, oticks) while ((sig = CURSIG(l)) != 0) postsig(sig); } - + /* * If profiling, charge recent system time to the trapped pc. */ diff --git a/sys/arch/pc532/include/varargs.h b/sys/arch/pc532/include/varargs.h index f89a3c7dc07..5f513e0fd57 100644 --- a/sys/arch/pc532/include/varargs.h +++ b/sys/arch/pc532/include/varargs.h @@ -1,4 +1,4 @@ -/* $NetBSD: varargs.h,v 1.14 2005/12/11 12:18:31 christos Exp $ */ +/* $NetBSD: varargs.h,v 1.15 2006/05/12 06:05:23 simonb Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -51,7 +51,6 @@ #define va_dcl long __builtin_va_alist; __va_ellipsis #undef va_start -#define va_start(ap) \ - ((ap) = (va_list)&__builtin_va_alist) +#define va_start(ap) ((ap) = (va_list)&__builtin_va_alist) #endif /* !_PC532_VARARGS_H_ */ diff --git a/sys/arch/pc532/include/vmparam.h b/sys/arch/pc532/include/vmparam.h index 2eaa37ad48d..47eb72d53b9 100644 --- a/sys/arch/pc532/include/vmparam.h +++ b/sys/arch/pc532/include/vmparam.h @@ -1,4 +1,4 @@ -/* $NetBSD: vmparam.h,v 1.32 2005/12/11 12:18:31 christos Exp $ */ +/* $NetBSD: vmparam.h,v 1.33 2006/05/12 06:05:23 simonb Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -135,7 +135,7 @@ * pmap specific data stored in the vm_physmem[] array */ struct pmap_physseg { - struct pv_head *pvhead; /* pv_head array */ + struct pv_head *pvhead; /* pv_head array */ short *attrs; /* attrs array */ }; diff --git a/sys/arch/pc532/pc532/autoconf.c b/sys/arch/pc532/pc532/autoconf.c index 85aea8f5a28..e3141d96bf4 100644 --- a/sys/arch/pc532/pc532/autoconf.c +++ b/sys/arch/pc532/pc532/autoconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.c,v 1.43 2006/02/28 23:08:20 kleink Exp $ */ +/* $NetBSD: autoconf.c,v 1.44 2006/05/12 06:05:23 simonb Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -44,7 +44,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.43 2006/02/28 23:08:20 kleink Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.44 2006/05/12 06:05:23 simonb Exp $"); #include <sys/param.h> #include <sys/conf.h> @@ -68,7 +68,7 @@ u_long bootdev = 0; /* should be dev_t, but not until 32 bits */ * Determine i/o configuration for a machine. */ void -cpu_configure() +cpu_configure(void) { extern int safepri; int i; @@ -91,7 +91,7 @@ cpu_configure() } void -cpu_rootconf() +cpu_rootconf(void) { booted_partition = B_PARTITION(bootdev); @@ -102,9 +102,7 @@ cpu_rootconf() } void -device_register(dev, aux) - struct device *dev; - void *aux; +device_register(struct device *dev, void *aux) { static int found; static struct device *booted_controller; diff --git a/sys/arch/pc532/pc532/clock.c b/sys/arch/pc532/pc532/clock.c index 110e8c9b850..92f08f54502 100644 --- a/sys/arch/pc532/pc532/clock.c +++ b/sys/arch/pc532/pc532/clock.c @@ -1,4 +1,4 @@ -/* $NetBSD: clock.c,v 1.29 2005/12/11 12:18:31 christos Exp $ */ +/* $NetBSD: clock.c,v 1.30 2006/05/12 06:05:23 simonb Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.29 2005/12/11 12:18:31 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.30 2006/05/12 06:05:23 simonb Exp $"); #include <sys/param.h> #include <sys/time.h> @@ -60,30 +60,27 @@ static u_char rtc_magic[8] = { 0xc5, 0x3a, 0xa3, 0x5c, 0xc5, 0x3a, 0xa3, 0x5c }; -static long clk_get_secs __P((void)); -static void clk_set_secs __P((long)); -static u_char bcd2bin __P((u_char)); -static u_char bin2bcd __P((u_char)); -static void rw_rtc __P((struct clock_ymdhms *, int)); -static void write_rtc __P((u_char *)); +static long clk_get_secs(void); +static void clk_set_secs(long); +static u_char bcd2bin(u_char); +static u_char bin2bcd(u_char); +static void rw_rtc(struct clock_ymdhms *, int); +static void write_rtc(u_char *); -static int clock_match __P((struct device *, struct cfdata *, void *args)); -static void clock_attach __P((struct device *, struct device *, void *)); +static int clock_match(struct device *, struct cfdata *, void *args); +static void clock_attach(struct device *, struct device *, void *); CFATTACH_DECL(clock, sizeof(struct device), clock_match, clock_attach, NULL, NULL); -static int rtc_match __P((struct device *, struct cfdata *, void *args)); -static void rtc_attach __P((struct device *, struct device *, void *)); +static int rtc_match(struct device *, struct cfdata *, void *args); +static void rtc_attach(struct device *, struct device *, void *); CFATTACH_DECL(rtc, sizeof(struct device), rtc_match, rtc_attach, NULL, NULL); static int -clock_match(parent, cf, aux) - struct device *parent; - struct cfdata *cf; - void *aux; +clock_match(struct device *parent, struct cfdata *cf, void *aux) { struct confargs *ca = aux; @@ -102,10 +99,7 @@ clock_match(parent, cf, aux) } static void -clock_attach(parent, self, aux) - struct device *parent; - struct device *self; - void *aux; +clock_attach(struct device *parent, struct device *self, void *aux) { static u_char icu_table[] = { CICTL, 0, /* Disable clock interrupt for now. */ @@ -133,23 +127,22 @@ clock_attach(parent, self, aux) } void -cpu_initclocks() +cpu_initclocks(void) { + /* Enable the clock interrupt. */ ICUB(CICTL) = 0x30; } void -setstatclockrate(arg) - int arg; +setstatclockrate(int arg) { /* Nothing */ } void -microtime(tvp) - register struct timeval *tvp; +microtime(struct timeval *tvp) { u_short count, delta, ipend; @@ -190,10 +183,7 @@ microtime(tvp) */ static int -rtc_match(parent, cf, aux) - struct device *parent; - struct cfdata *cf; - void *aux; +rtc_match(struct device *parent, struct cfdata *cf, void *aux) { struct confargs *ca = aux; int rom_val, rom_cnt, i; @@ -224,11 +214,9 @@ rtc_match(parent, cf, aux) } static void -rtc_attach(parent, self, aux) - struct device *parent; - struct device *self; - void *aux; +rtc_attach(struct device *parent, struct device *self, void *aux) { + printf("\n"); rtc_attached = 1; } @@ -238,8 +226,7 @@ rtc_attach(parent, self, aux) * which is, e.g. from a filesystem. */ void -inittodr(fs_time) - time_t fs_time; +inittodr(time_t fs_time) { long diff, clk_time; long long_ago = (5 * SECYR); @@ -291,7 +278,7 @@ inittodr(fs_time) * Resettodr restores the time of day hardware after a time change. */ void -resettodr() +resettodr(void) { /* * We might have been called by boot() due to a crash early @@ -316,22 +303,21 @@ resettodr() */ static u_char -bcd2bin(n) - u_char n; +bcd2bin(u_char n) { + return(((n >> 4) & 0x0f) * 10 + (n & 0x0f)); } static u_char -bin2bcd(n) - u_char n; +bin2bcd(u_char n) { + return((char)(((n / 10) << 4) & 0xf0) | ((n % 10) & 0x0f)); } static void -write_rtc(p) - u_char *p; +write_rtc(u_char *p) { u_char *q; int i; @@ -343,9 +329,7 @@ write_rtc(p) } static void -rw_rtc(dt, rw) - struct clock_ymdhms *dt; - int rw; +rw_rtc(struct clock_ymdhms *dt, int rw) { struct { u_char rtc_csec; @@ -411,7 +395,7 @@ rw_rtc(dt, rw) } static long -clk_get_secs() +clk_get_secs(void) { struct clock_ymdhms dt; long secs; @@ -437,8 +421,7 @@ clk_get_secs() } static void -clk_set_secs(secs) - long secs; +clk_set_secs(long secs) { struct clock_ymdhms dt; diff --git a/sys/arch/pc532/pc532/db_disasm.c b/sys/arch/pc532/pc532/db_disasm.c index ed9e0db9f90..5ae45875d2d 100644 --- a/sys/arch/pc532/pc532/db_disasm.c +++ b/sys/arch/pc532/pc532/db_disasm.c @@ -1,4 +1,4 @@ -/* $NetBSD: db_disasm.c,v 1.11 2006/02/11 02:19:31 simonb Exp $ */ +/* $NetBSD: db_disasm.c,v 1.12 2006/05/12 06:05:23 simonb Exp $ */ /* * Mach Operating System @@ -44,7 +44,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.11 2006/02/11 02:19:31 simonb Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.12 2006/05/12 06:05:23 simonb Exp $"); #define STATIC static @@ -521,22 +521,22 @@ unsigned char fmttab[128] = { STATIC char fmt1_table[16][8] = { - "bsr", /* branch to subroutine */ - "ret", /* return from subroutine */ - "cxp", /* call external procedure */ - "rxp", /* return from external procedure */ - "rett", /* return from trap */ - "reti", /* return from interrupt */ - "save", /* save general purpose registers */ - "restore", /* restore general purpose registers */ - "enter", /* enter new procedure context */ - "exit", /* exit procedure context */ - "nop", /* no operation */ - "wait", /* wait fro interrupt */ - "dia", /* diagnose */ - "flag", /* flag trap */ - "svc", /* supervisor call trap */ - "bpt" /* breakpoint trap */ + "bsr", /* branch to subroutine */ + "ret", /* return from subroutine */ + "cxp", /* call external procedure */ + "rxp", /* return from external procedure */ + "rett", /* return from trap */ + "reti", /* return from interrupt */ + "save", /* save general purpose registers */ + "restore", /* restore general purpose registers */ + "enter", /* enter new procedure context */ + "exit", /* exit procedure context */ + "nop", /* no operation */ + "wait", /* wait fro interrupt */ + "dia", /* diagnose */ + "flag", /* flag trap */ + "svc", /* supervisor call trap */ + "bpt" /* breakpoint trap */ }; #define FMT1_BSR 0x0 /* branch to subroutine */ @@ -558,13 +558,13 @@ char fmt1_table[16][8] = { STATIC char fmt2_table[7][5] = { - "addq", /* add quick */ - "cmpq", /* compare quick */ - "spr", /* save processor register */ - "s", /* save condition as boolean */ - "acb", /* add, compare and branch */ - "movq", /* move quick */ - "lpr" /* load processor register */ + "addq", /* add quick */ + "cmpq", /* compare quick */ + "spr", /* save processor register */ + "s", /* save condition as boolean */ + "acb", /* add, compare and branch */ + "movq", /* move quick */ + "lpr" /* load processor register */ }; #define FMT2_ADDQ 0x0 /* add quick */ @@ -577,14 +577,14 @@ char fmt2_table[7][5] = { STATIC char fmt3_table[8][7] = { - "cxpd", /* call external procedure with descriptor */ - "bicpsr", /* bit clear in PSR */ - "jump", /* jump */ - "bispsr", /* bit set in PSR */ - "?3?", /* UNDEFINED */ - "adjsp", /* adjust stack pointer */ - "jsr", /* jump to subroutine */ - "case" /* case branch */ + "cxpd", /* call external procedure with descriptor */ + "bicpsr", /* bit clear in PSR */ + "jump", /* jump */ + "bispsr", /* bit set in PSR */ + "?3?", /* UNDEFINED */ + "adjsp", /* adjust stack pointer */ + "jsr", /* jump to subroutine */ + "case" /* case branch */ }; #define FMT3_CXPD 0x0 /* call external procedure with descriptor */ @@ -598,22 +598,22 @@ char fmt3_table[8][7] = { STATIC char fmt4_table[16][5] = { - "add", /* add */ - "cmp", /* compare */ - "bic", /* bit clear */ - "?4?", /* UNDEFINED */ - "addc", /* add with carry */ - "mov", /* move */ - "or", /* or */ - "?4?", /* UNDEFINED */ - "sub", /* subtract */ - "addr", /* compute effective address */ - "and", /* and */ - "?4?", /* UNDEFINED */ - "subc", /* subtract with carry */ - "tbit", /* test bit */ - "xor", /* exclusive or */ - "?4?" /* UNDEFINED */ + "add", /* add */ + "cmp", /* compare */ + "bic", /* bit clear */ + "?4?", /* UNDEFINED */ + "addc", /* add with carry */ + "mov", /* move */ + "or", /* or */ + "?4?", /* UNDEFINED */ + "sub", /* subtract */ + "addr", /* compute effective address */ + "and", /* and */ + "?4?", /* UNDEFINED */ + "subc", /* subtract with carry */ + "tbit", /* test bit */ + "xor", /* exclusive or */ + "?4?" /* UNDEFINED */ }; #define FMT4_ADD 0x0 /* add */ @@ -631,10 +631,10 @@ char fmt4_table[16][5] = { STATIC char fmt5_table[4][7] = { - "movs", /* move string */ - "cmps", /* compare string */ - "setcfg", /* set configuration register */ - "skps" /* skip string */ + "movs", /* move string */ + "cmps", /* compare string */ + "setcfg", /* set configuration register */ + "skps" /* skip string */ }; #define FMT5_MOVS 0x0 /* move string */ @@ -644,22 +644,22 @@ char fmt5_table[4][7] = { STATIC char fmt6_table[16][6] = { - "rot", /* rotate */ - "ash", /* arithmetic shift */ - "cbit", /* clear bit */ - "cbiti", /* clear bit interlocked */ - "?6?", /* undefined */ - "lsh", /* logical shift */ - "sbit", /* set bit */ - "sbiti", /* set bit interlocked */ - "neg", /* negate */ - "not", /* not */ - "?6?", /* undefined */ - "subp", /* subtract packed decimal */ - "abs", /* absolute value */ - "com", /* complement */ - "ibit", /* invert bit */ - "addp" /* add packed decimal */ + "rot", /* rotate */ + "ash", /* arithmetic shift */ + "cbit", /* clear bit */ + "cbiti", /* clear bit interlocked */ + "?6?", /* undefined */ + "lsh", /* logical shift */ + "sbit", /* set bit */ + "sbiti", /* set bit interlocked */ + "neg", /* negate */ + "not", /* not */ + "?6?", /* undefined */ + "subp", /* subtract packed decimal */ + "abs", /* absolute value */ + "com", /* complement */ + "ibit", /* invert bit */ + "addp" /* add packed decimal */ }; #define FMT6_ROT 0x0 /* rotate */ @@ -681,22 +681,22 @@ char fmt6_table[16][6] = { STATIC char fmt7_table[16][7] = { - "movm", /* move multiple */ - "cmpm", /* compare multiple */ - "inss", /* insert field short */ - "exts", /* extract field short */ - "movxb", /* move with sign-extension byte to word */ - "movzb", /* move with zero-extension byte to word */ - "movz", /* move with zero extension i to double */ - "movx", /* move with sign-extension i to double */ - "mul", /* multiply */ - "mei", /* multiply extended integer */ - "?7?", /* undefined */ - "dei", /* divide extended integer */ - "quo", /* quotient */ - "rem", /* remainder */ - "mod", /* modulus */ - "div" /* divide */ + "movm", /* move multiple */ + "cmpm", /* compare multiple */ + "inss", /* insert field short */ + "exts", /* extract field short */ + "movxb", /* move with sign-extension byte to word */ + "movzb", /* move with zero-extension byte to word */ + "movz", /* move with zero extension i to double */ + "movx", /* move with sign-extension i to double */ + "mul", /* multiply */ + "mei", /* multiply extended integer */ + "?7?", /* undefined */ + "dei", /* divide extended integer */ + "quo", /* quotient */ + "rem", /* remainder */ + "mod", /* modulus */ + "div" /* divide */ }; #define FMT7_MOVM 0x0 /* move multiple */ @@ -718,14 +718,14 @@ char fmt7_table[16][7] = { STATIC char fmt8_table[8][6] = { - "ext", /* extract field */ - "cvtp", /* convert to bit pointer */ - "ins", /* insert field */ - "check", /* bounds check */ - "index", /* calculate index */ - "ffs", /* find first set bit */ - "mov", /* move supervisor to/from user space */ - "?8?" /* undefined */ + "ext", /* extract field */ + "cvtp", /* convert to bit pointer */ + "ins", /* insert field */ + "check", /* bounds check */ + "index", /* calculate index */ + "ffs", /* find first set bit */ + "mov", /* move supervisor to/from user space */ + "?8?" /* undefined */ }; #define FMT8_EXT 0x0 /* extract field */ @@ -739,14 +739,14 @@ char fmt8_table[8][6] = { STATIC char fmt9_table[8][6] = { - "mov", /* move converting integer to floating point */ - "lfsr", /* load floating-point status register */ - "movlf", /* move long floating to floating */ - "movfl", /* move floating to long floating */ - "round", /* round floating to integer */ - "trunc", /* truncate floating to integer */ - "sfsr", /* store floating-point status register */ - "floor" /* floor floating to integer */ + "mov", /* move converting integer to floating point */ + "lfsr", /* load floating-point status register */ + "movlf", /* move long floating to floating */ + "movfl", /* move floating to long floating */ + "round", /* round floating to integer */ + "trunc", /* truncate floating to integer */ + "sfsr", /* store floating-point status register */ + "floor" /* floor floating to integer */ }; #define FMT9_MOV 0x0 /* move converting integer to floating point */ @@ -762,42 +762,42 @@ char fmt9_table[8][6] = { STATIC char fmt11_table[16][4] = { - "add", /* add floating */ - "mov", /* move floating */ - "cmp", /* compare floating */ - "?f?", /* undefined */ - "sub", /* subtract floating */ - "neg", /* negate floating */ - "?f?", /* undefined */ - "?f?", /* undefined */ - "div", /* divide floating */ - "?f?", /* undefined */ - "?f?", /* undefined */ - "?f?", /* undefined */ - "mul", /* multiply floating */ - "abs", /* absolute value floating */ - "?f?", /* undefined */ - "?f?" /* undefined */ + "add", /* add floating */ + "mov", /* move floating */ + "cmp", /* compare floating */ + "?f?", /* undefined */ + "sub", /* subtract floating */ + "neg", /* negate floating */ + "?f?", /* undefined */ + "?f?", /* undefined */ + "div", /* divide floating */ + "?f?", /* undefined */ + "?f?", /* undefined */ + "?f?", /* undefined */ + "mul", /* multiply floating */ + "abs", /* absolute value floating */ + "?f?", /* undefined */ + "?f?" /* undefined */ }; STATIC char fmt12_table[16][6] = { - "?f?", /* 0 undefined */ - "?f?", /* 1 undefined */ - "poly", /* 2 */ - "dot", /* 3 */ - "scalb", /* 4 */ - "logb", /* 5 */ - "?f?", /* 6 undefined */ - "?f?", /* 7 undefined */ - "?f?", /* 8 undefined */ - "?f?", /* 9 undefined */ - "?f?", /* 10 undefined */ - "?f?", /* 11 undefined */ - "?f?", /* 12 undefined */ - "?f?", /* 13 undefined */ - "?f?", /* 14 undefined */ - "?f?", /* 15 undefined */ + "?f?", /* 0 undefined */ + "?f?", /* 1 undefined */ + "poly", /* 2 */ + "dot", /* 3 */ + "scalb", /* 4 */ + "logb", /* 5 */ + "?f?", /* 6 undefined */ + "?f?", /* 7 undefined */ + "?f?", /* 8 undefined */ + "?f?", /* 9 undefined */ + "?f?", /* 10 undefined */ + "?f?", /* 11 undefined */ + "?f?", /* 12 undefined */ + "?f?", /* 13 undefined */ + "?f?", /* 14 undefined */ + "?f?", /* 15 undefined */ }; #define FMT11_ADD 0x0 /* add floating */ @@ -824,16 +824,16 @@ char fmt12_table[16][6] = { STATIC char fmt14_table[][6] = { - "rdval", /* validate address for reading */ - "wrval", /* validate address for writing */ - "lmr", /* load memory managemnet register */ - "smr", /* store memory management register */ - "?14?", - "?14?", - "?14?", - "?14?", - "?14?", - "cinv", + "rdval", /* validate address for reading */ + "wrval", /* validate address for writing */ + "lmr", /* load memory managemnet register */ + "smr", /* store memory management register */ + "?14?", + "?14?", + "?14?", + "?14?", + "?14?", + "cinv", }; #define FMT14_RDVAL 0x0 /* validate address for reading */ @@ -884,67 +884,67 @@ char fmt14_table[][6] = { #define REG_NIL (REG_FSR+2) struct regTable { - const char *name; + const char *name; }; STATIC const struct regTable regTable[] = { - {"r0"}, /* General Register 0 */ - {"r1"}, /* General Register 1 */ - {"r2"}, /* General Register 2 */ - {"r3"}, /* General Register 3 */ - {"r4"}, /* General Register 4 */ - {"r5"}, /* General Register 5 */ - {"r6"}, /* General Register 6 */ - {"r7"}, /* General Register 7 */ - {"f0"}, /* Floating Point 0 */ - {"f1"}, /* Floating Point 1 */ - {"f2"}, /* Floating Point 2 */ - {"f3"}, /* Floating Point 3 */ - {"f4"}, /* Floating Point 4 */ - {"f5"}, /* Floating Point 5 */ - {"f6"}, /* Floating Point 6 */ - {"f7"}, /* Floating Point 7 */ - {"l1l"}, /* Floating Point L1 */ - {"l1h"}, /* Floating Point L1 */ - {"l3l"}, /* Floating Point L3 */ - {"l3h"}, /* Floating Point L3 */ - {"l5l"}, /* Floating Point L5 */ - {"l5h"}, /* Floating Point L5 */ - {"l7l"}, /* Floating Point L7 */ - {"l7h"}, /* Floating Point L7 */ - {"l0"}, - {"l1"}, - {"l2"}, - {"l3"}, - {"l4"}, - {"l5"}, - {"l6"}, - {"l7"}, - {"pc"}, /* Program counter */ - {"usp"}, /* 532 */ - {"isp"}, /* 532 */ - {"fp"}, /* Frame Pointer */ - {"sb"}, /* Static Base */ - {"intbase"}, /* Interrupt Base */ - {"mod"}, /* Module Register */ - {"psr"}, /* Processor Status */ - {"upsr"}, /* Processor Status */ - {"dcr"}, /* 532 */ - {"dsr"}, /* 532 */ - {"car"}, /* 532 */ - {"bpc"}, /* 532 */ - {"cfg"}, /* 532 */ - {"ptb0"}, /* Page Table Base 0 */ - {"ptb1"}, /* Page Table Base 1 */ - {"ivar0"}, /* 532 */ - {"ivar1"}, /* 532 */ - {"tear"}, /* 532 */ - {"mcr"}, /* 532 */ - {"msr"}, /* Memory Management Status */ - {"fsr"}, /* Floating Point Status */ - {"sp"}, /* x(x(sp)) adr mode */ - {"???"}, /* unknown reg */ + {"r0"}, /* General Register 0 */ + {"r1"}, /* General Register 1 */ + {"r2"}, /* General Register 2 */ + {"r3"}, /* General Register 3 */ + {"r4"}, /* General Register 4 */ + {"r5"}, /* General Register 5 */ + {"r6"}, /* General Register 6 */ + {"r7"}, /* General Register 7 */ + {"f0"}, /* Floating Point 0 */ + {"f1"}, /* Floating Point 1 */ + {"f2"}, /* Floating Point 2 */ + {"f3"}, /* Floating Point 3 */ + {"f4"}, /* Floating Point 4 */ + {"f5"}, /* Floating Point 5 */ + {"f6"}, /* Floating Point 6 */ + {"f7"}, /* Floating Point 7 */ + {"l1l"}, /* Floating Point L1 */ + {"l1h"}, /* Floating Point L1 */ + {"l3l"}, /* Floating Point L3 */ + {"l3h"}, /* Floating Point L3 */ + {"l5l"}, /* Floating Point L5 */ + {"l5h"}, /* Floating Point L5 */ + {"l7l"}, /* Floating Point L7 */ + {"l7h"}, /* Floating Point L7 */ + {"l0"}, + {"l1"}, + {"l2"}, + {"l3"}, + {"l4"}, + {"l5"}, + {"l6"}, + {"l7"}, + {"pc"}, /* Program counter */ + {"usp"}, /* 532 */ + {"isp"}, /* 532 */ + {"fp"}, /* Frame Pointer */ + {"sb"}, /* Static Base */ + {"intbase"}, /* Interrupt Base */ + {"mod"}, /* Module Register */ + {"psr"}, /* Processor Status */ + {"upsr"}, /* Processor Status */ + {"dcr"}, /* 532 */ + {"dsr"}, /* 532 */ + {"car"}, /* 532 */ + {"bpc"}, /* 532 */ + {"cfg"}, /* 532 */ + {"ptb0"}, /* Page Table Base 0 */ + {"ptb1"}, /* Page Table Base 1 */ + {"ivar0"}, /* 532 */ + {"ivar1"}, /* 532 */ + {"tear"}, /* 532 */ + {"mcr"}, /* 532 */ + {"msr"}, /* Memory Management Status */ + {"fsr"}, /* Floating Point Status */ + {"sp"}, /* x(x(sp)) adr mode */ + {"???"}, /* unknown reg */ }; #define REGTABLESZ ((sizeof regTable) / (sizeof (struct regTable))) @@ -958,36 +958,34 @@ const struct regTable regTable[] = { (gen) = (((input) & 0xf8) >> 3)) STATIC unsigned char cpuRegTable [] = { - REG_UPSR, REG_DCR, REG_BPC, REG_DSR, - REG_CAR, REG_NIL, REG_NIL, REG_NIL, - REG_FP, REG_SP, REG_SB, REG_USP, - REG_CFG, REG_PSR, REG_INTBASE, REG_MOD, + REG_UPSR, REG_DCR, REG_BPC, REG_DSR, + REG_CAR, REG_NIL, REG_NIL, REG_NIL, + REG_FP, REG_SP, REG_SB, REG_USP, + REG_CFG, REG_PSR, REG_INTBASE, REG_MOD, }; STATIC unsigned char mmuRegTable [] = { - REG_NIL, REG_NIL, REG_NIL, REG_NIL, - REG_NIL, REG_NIL, REG_NIL, REG_NIL, - REG_NIL, REG_MCR, REG_MSR, REG_TEAR, - REG_PTB0, REG_PTB1,REG_IVAR0, REG_IVAR1, + REG_NIL, REG_NIL, REG_NIL, REG_NIL, + REG_NIL, REG_NIL, REG_NIL, REG_NIL, + REG_NIL, REG_MCR, REG_MSR, REG_TEAR, + REG_PTB0, REG_PTB1, REG_IVAR0, REG_IVAR1, }; -void db_reverseBits __P((int *)); -void db_formatOperand __P((struct operand *, db_addr_t)); -void db_formatAsm __P((struct insn *, db_addr_t, boolean_t)); -void db_initInsn __P((struct insn *)); -int db_disp __P((db_addr_t, long *)); -int db_decode_operand __P((db_addr_t, unsigned char byte, - struct operand *, unsigned char)); -int db_gen __P(( struct insn *, db_addr_t, int, - unsigned char, unsigned char)); -int db_dasm_ns32k __P((struct insn *, db_addr_t)); -void db_reverseBits __P((int *)); +void db_reverseBits(int *); +void db_formatOperand(struct operand *, db_addr_t); +void db_formatAsm(struct insn *, db_addr_t, boolean_t); +void db_initInsn(struct insn *); +int db_disp(db_addr_t, long *); +int db_decode_operand(db_addr_t, unsigned char byte, struct operand *, + unsigned char); +int db_gen( struct insn *, db_addr_t, int, unsigned char, unsigned char); +int db_dasm_ns32k(struct insn *, db_addr_t); +void db_reverseBits(int *); #define get_byte(l) ((unsigned char) db_get_value(l, 1, FALSE)) -void db_formatOperand(operand, loc) - struct operand *operand; - db_addr_t loc; +void +db_formatOperand(struct operand *operand, db_addr_t loc) { int need_comma, i, mask, textlen; const char *p; @@ -1116,10 +1114,8 @@ bitlist: } } -void db_formatAsm(insn, loc, altfmt) - struct insn *insn; - db_addr_t loc; - boolean_t altfmt; +void +db_formatAsm(struct insn *insn, db_addr_t loc, boolean_t altfmt) { int i, j; @@ -1135,7 +1131,7 @@ void db_formatAsm(insn, loc, altfmt) for (i = 0; i < 4 && insn->i_opr[i].o_mode != AMODE_NONE; i++) { if (insn->i_opr[i].o_mode == AMODE_MSPC || insn->i_opr[i].o_mode == AMODE_RREL) { - register const struct db_variable *regp; + const struct db_variable *regp; db_expr_t value; if (strcmp(db_regs->name, "pc") == 0) { @@ -1170,9 +1166,10 @@ void db_formatAsm(insn, loc, altfmt) } } -void db_initInsn (insn) - struct insn *insn; +void +db_initInsn(struct insn *insn) { + insn->i_opr[0].o_mode = AMODE_NONE; insn->i_opr[0].o_iscale = 0; insn->i_opr[1].o_mode = AMODE_NONE; @@ -1183,9 +1180,8 @@ void db_initInsn (insn) insn->i_opr[3].o_iscale = 0; } -int db_disp(loc, result) - db_addr_t loc; - long *result; +int +db_disp(db_addr_t loc, long *result) { unsigned int b; @@ -1213,13 +1209,11 @@ int db_disp(loc, result) } } -int db_decode_operand(loc, byte, operand, iol) - db_addr_t loc; - unsigned char byte; - struct operand *operand; - unsigned char iol; +int +db_decode_operand(db_addr_t loc, unsigned char byte, struct operand *operand, + unsigned char iol) { - register int i, consumed = 0; + int i, consumed = 0; unsigned long value; switch (byte) { @@ -1322,11 +1316,10 @@ one_disp: return(consumed); } -int db_gen(insn, loc, mask, byte0, byte1) - struct insn *insn; - db_addr_t loc; - int mask; /* 1 to get gen1, 2 to get gen2 */ - unsigned char byte0, byte1; +/* mask == 1 to get gen1, mask == 2 to get gen2 */ +int +db_gen(struct insn *insn, db_addr_t loc, int mask, unsigned char byte0, + unsigned char byte1) { int opr = 0, opr2, consumed = 0; unsigned char gen0, gen1; @@ -1366,9 +1359,8 @@ int db_gen(insn, loc, mask, byte0, byte1) return(consumed); } -int db_dasm_ns32k(insn, loc) - struct insn *insn; - db_addr_t loc; /* start addr of this insn */ +int +db_dasm_ns32k(struct insn *insn, db_addr_t loc) { unsigned char byte0, byte1, byte2; int i, j; @@ -1865,8 +1857,8 @@ int db_dasm_ns32k(insn, loc) /* * Reverse the order of the bits in the LS byte of *ip. */ -void db_reverseBits (ip) - int *ip; +void +db_reverseBits(int *ip) { int i, src, dst; @@ -1885,9 +1877,7 @@ void db_reverseBits (ip) * next instruction. */ db_addr_t -db_disasm(loc, altfmt) - db_addr_t loc; - boolean_t altfmt; +db_disasm(db_addr_t loc, boolean_t altfmt) { int ate; struct insn insn; diff --git a/sys/arch/pc532/pc532/db_interface.c b/sys/arch/pc532/pc532/db_interface.c index 74af6b96fa4..8c407d3dda7 100644 --- a/sys/arch/pc532/pc532/db_interface.c +++ b/sys/arch/pc532/pc532/db_interface.c @@ -1,4 +1,4 @@ -/* $NetBSD: db_interface.c,v 1.14 2005/12/11 12:18:31 christos Exp $ */ +/* $NetBSD: db_interface.c,v 1.15 2006/05/12 06:05:23 simonb Exp $ */ /* * Mach Operating System @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.14 2005/12/11 12:18:31 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.15 2006/05/12 06:05:23 simonb Exp $"); #include "opt_ddb.h" @@ -63,15 +63,15 @@ extern int trap_types; int db_active = 0; long db_active_ipl; -static void kdbprinttrap __P((int, int)); +static void kdbprinttrap(int, int); /* * Print trap reason. */ static void -kdbprinttrap(type, code) - int type, code; +kdbprinttrap(int type, int code) { + printf("kernel: "); if (type >= trap_types || type < 0) db_printf("type %d", type); @@ -84,10 +84,9 @@ kdbprinttrap(type, code) * kdb_trap - field a TRACE or BPT trap */ int -kdb_trap(type, code, regs) - int type, code; - register db_regs_t *regs; +kdb_trap(int type, int code, db_regs_t *regs) { + switch (type) { case T_BPT: /* breakpoint */ case T_WATCHPOINT: /* watchpoint */ diff --git a/sys/arch/pc532/pc532/db_memrw.c b/sys/arch/pc532/pc532/db_memrw.c index 6ee06dc67e1..0ab36e4f247 100644 --- a/sys/arch/pc532/pc532/db_memrw.c +++ b/sys/arch/pc532/pc532/db_memrw.c @@ -1,4 +1,4 @@ -/* $NetBSD: db_memrw.c,v 1.13 2006/02/11 02:19:06 simonb Exp $ */ +/* $NetBSD: db_memrw.c,v 1.14 2006/05/12 06:05:23 simonb Exp $ */ /* * Copyright (c) 1996 Gordon W. Ross @@ -44,7 +44,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.13 2006/02/11 02:19:06 simonb Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.14 2006/05/12 06:05:23 simonb Exp $"); #include "opt_ddb.h" @@ -60,8 +60,8 @@ __KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.13 2006/02/11 02:19:06 simonb Exp $") #include <ddb/db_access.h> -static void set_pte __P((vaddr_t, pt_entry_t)); -static void db_write_text __P((vaddr_t, size_t, const char *)); +static void set_pte(vaddr_t, pt_entry_t); +static void db_write_text(vaddr_t, size_t, const char *); /* * Read bytes from kernel address space for debugger. @@ -69,20 +69,17 @@ static void db_write_text __P((vaddr_t, size_t, const char *)); * traps in DDB work correctly, "Just Do It!" */ void -db_read_bytes(addr, size, data) - vaddr_t addr; - size_t size; - char *data; +db_read_bytes(vaddr_t addr, size_t size, char *data) { - char *src = (char*)addr; + char *src = (char *)addr; if (size == 4) { - *((int*)data) = *((int*)src); + *((int *)data) = *((int*)src); return; } if (size == 2) { - *((short*)data) = *((short*)src); + *((short *)data) = *((short*)src); return; } @@ -93,10 +90,9 @@ db_read_bytes(addr, size, data) } static void -set_pte(addr, pte) - vaddr_t addr; - pt_entry_t pte; +set_pte(vaddr_t addr, pt_entry_t pte) { + *kvtopte(addr) = pte; tlbflush(); } @@ -106,10 +102,7 @@ set_pte(addr, pte) * Makes text page writable temporarily. */ static void -db_write_text(addr, size, data) - vaddr_t addr; - size_t size; - const char *data; +db_write_text(vaddr_t addr, size_t size, const char *data) { char *dst; pt_entry_t oldpte, tmppte; @@ -165,10 +158,7 @@ db_write_text(addr, size, data) * Write bytes to kernel address space for debugger. */ void -db_write_bytes(addr, size, data) - vaddr_t addr; - size_t size; - const char *data; +db_write_bytes(vaddr_t addr, size_t size, const char *data) { char *dst = (char *)addr; extern char kernel_text[], etext[]; @@ -197,8 +187,9 @@ db_write_bytes(addr, size, data) #ifdef DDB void -Debugger() +Debugger(void) { + breakpoint(); } #endif diff --git a/sys/arch/pc532/pc532/db_trace.c b/sys/arch/pc532/pc532/db_trace.c index 8e0e1744cee..732acba4801 100644 --- a/sys/arch/pc532/pc532/db_trace.c +++ b/sys/arch/pc532/pc532/db_trace.c @@ -1,4 +1,4 @@ -/* $NetBSD: db_trace.c,v 1.15 2005/12/11 12:18:31 christos Exp $ */ +/* $NetBSD: db_trace.c,v 1.16 2006/05/12 06:05:23 simonb Exp $ */ /* * Mach Operating System @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.15 2005/12/11 12:18:31 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.16 2006/05/12 06:05:23 simonb Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -52,31 +52,31 @@ __KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.15 2005/12/11 12:18:31 christos Exp $ #include <ddb/db_interface.h> struct ns532_frame; -static void db_nextframe __P((struct ns532_frame **, db_addr_t *, - int *, int, void (*)(const char *, ...))); -static int db_numargs __P((struct ns532_frame *)); -static int db_spec_regs __P((const struct db_variable *, db_expr_t *, int)); +static void db_nextframe(struct ns532_frame **, db_addr_t *, int *, int, + void (*)(const char *, ...)); +static int db_numargs(struct ns532_frame *); +static int db_spec_regs(const struct db_variable *, db_expr_t *, int); /* * Machine register set. */ const struct db_variable db_regs[] = { - { "r0", (long *)&ddb_regs.tf_regs.r_r0, FCN_NULL }, - { "r1", (long *)&ddb_regs.tf_regs.r_r1, FCN_NULL }, - { "r2", (long *)&ddb_regs.tf_regs.r_r2, FCN_NULL }, - { "r3", (long *)&ddb_regs.tf_regs.r_r3, FCN_NULL }, - { "r4", (long *)&ddb_regs.tf_regs.r_r4, FCN_NULL }, - { "r5", (long *)&ddb_regs.tf_regs.r_r5, FCN_NULL }, - { "r6", (long *)&ddb_regs.tf_regs.r_r6, FCN_NULL }, - { "r7", (long *)&ddb_regs.tf_regs.r_r7, FCN_NULL }, - { "sp", (long *)&ddb_regs.tf_regs.r_sp, FCN_NULL }, - { "fp", (long *)&ddb_regs.tf_regs.r_fp, FCN_NULL }, - { "sb", (long *)&ddb_regs.tf_regs.r_sb, FCN_NULL }, - { "pc", (long *)&ddb_regs.tf_regs.r_pc, FCN_NULL }, + { "r0", (long *)&ddb_regs.tf_regs.r_r0, FCN_NULL }, + { "r1", (long *)&ddb_regs.tf_regs.r_r1, FCN_NULL }, + { "r2", (long *)&ddb_regs.tf_regs.r_r2, FCN_NULL }, + { "r3", (long *)&ddb_regs.tf_regs.r_r3, FCN_NULL }, + { "r4", (long *)&ddb_regs.tf_regs.r_r4, FCN_NULL }, + { "r5", (long *)&ddb_regs.tf_regs.r_r5, FCN_NULL }, + { "r6", (long *)&ddb_regs.tf_regs.r_r6, FCN_NULL }, + { "r7", (long *)&ddb_regs.tf_regs.r_r7, FCN_NULL }, + { "sp", (long *)&ddb_regs.tf_regs.r_sp, FCN_NULL }, + { "fp", (long *)&ddb_regs.tf_regs.r_fp, FCN_NULL }, + { "sb", (long *)&ddb_regs.tf_regs.r_sb, FCN_NULL }, + { "pc", (long *)&ddb_regs.tf_regs.r_pc, FCN_NULL }, { "psr", (long *)&ddb_regs.tf_regs.r_psr,FCN_NULL }, { "tear", (long *)&ddb_regs.tf_tear, FCN_NULL }, { "msr", (long *)&ddb_regs.tf_msr, FCN_NULL }, - { "ipl", (long *)&db_active_ipl, FCN_NULL }, + { "ipl", (long *)&db_active_ipl, FCN_NULL }, { "intbase", (long *) 0, db_spec_regs }, { "ptb", (long *) 0, db_spec_regs }, @@ -116,8 +116,7 @@ boolean_t db_trace_symbols_found = FALSE; int db_numargs_default = 5; int -db_numargs(fp) - struct ns532_frame *fp; +db_numargs(struct ns532_frame *fp) { db_addr_t argp; int inst; @@ -133,7 +132,7 @@ db_numargs(fp) /* * After a bsr gcc may emit the following instructions * to remove the arguments from the stack: - * cmpqd 0,tos - to remove 4 bytes from the stack + * cmpqd 0,tos - to remove 4 bytes from the stack * cmpd tos,tos - to remove 8 bytes from the stack * adjsp[bwd] -n - to remove n bytes from the stack * Gcc sometimes delays emitting these instructions and @@ -197,12 +196,8 @@ db_numargs(fp) * of the function that faulted, but that could get hairy. */ static void -db_nextframe(fp, ip, argp, is_trap, pr) - struct ns532_frame **fp; /* in/out */ - db_addr_t *ip; /* out */ - int *argp; /* in */ - int is_trap; /* in */ - void (*pr) __P((const char *, ...)); +db_nextframe(struct ns532_frame **fp, db_addr_t *ip, int *argp, int is_trap, + void (*pr)(const char *, ...)) { struct trapframe *tf; struct syscframe *sf; @@ -235,12 +230,8 @@ db_nextframe(fp, ip, argp, is_trap, pr) } void -db_stack_trace_print(addr, have_addr, count, modif, pr) - db_expr_t addr; - boolean_t have_addr; - db_expr_t count; - char *modif; - void (*pr) __P((const char *, ...)); +db_stack_trace_print(db_expr_t addr, boolean_t have_addr, db_expr_t count, + char *modif, void (*pr)(const char *, ...)) { struct ns532_frame *frame, *lastframe; int *argp; @@ -378,18 +369,14 @@ db_stack_trace_print(addr, have_addr, count, modif, pr) } } -/********************************************** - - Get/Set value of special registers. - - *********************************************/ +/* + * Get/Set value of special registers. + */ static int -db_spec_regs(vp, valp, what) - const struct db_variable *vp; - db_expr_t *valp; - int what; +db_spec_regs(const struct db_variable *vp, db_expr_t *valp, int what) { + if (strcmp(vp->name, "intbase") == 0) { if (what == DB_VAR_GET) sprd(intbase, *valp); diff --git a/sys/arch/pc532/pc532/disksubr.c b/sys/arch/pc532/pc532/disksubr.c index 24b4b0a32b7..8b82af03b60 100644 --- a/sys/arch/pc532/pc532/disksubr.c +++ b/sys/arch/pc532/pc532/disksubr.c @@ -1,4 +1,4 @@ -/* $NetBSD: disksubr.c,v 1.28 2005/12/11 12:18:31 christos Exp $ */ +/* $NetBSD: disksubr.c,v 1.29 2006/05/12 06:05:23 simonb Exp $ */ /* * Copyright (c) 1982, 1986, 1988 Regents of the University of California. @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.28 2005/12/11 12:18:31 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.29 2006/05/12 06:05:23 simonb Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -58,11 +58,8 @@ __KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.28 2005/12/11 12:18:31 christos Exp $ * Returns null on success and an error string on failure. */ const char * -readdisklabel(dev, strat, lp, osdep) - dev_t dev; - void (*strat) __P((struct buf *)); - struct disklabel *lp; - struct cpu_disklabel *osdep; +readdisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, + struct cpu_disklabel *osdep) { struct buf *bp; struct disklabel *dlp; @@ -108,10 +105,8 @@ readdisklabel(dev, strat, lp, osdep) * before setting it. */ int -setdisklabel(olp, nlp, openmask, osdep) - struct disklabel *olp, *nlp; - u_long openmask; - struct cpu_disklabel *osdep; +setdisklabel(struct disklabel *olp, struct disklabel *nlp, u_long openmask, + struct cpu_disklabel *osdep) { int i; struct partition *opp, *npp; @@ -139,8 +134,8 @@ setdisklabel(olp, nlp, openmask, osdep) npp->p_cpg = opp->p_cpg; } } - nlp->d_checksum = 0; - nlp->d_checksum = dkcksum(nlp); + nlp->d_checksum = 0; + nlp->d_checksum = dkcksum(nlp); *olp = *nlp; return (0); } @@ -149,11 +144,8 @@ setdisklabel(olp, nlp, openmask, osdep) * Write disk label back to device after modification. */ int -writedisklabel(dev, strat, lp, osdep) - dev_t dev; - void (*strat) __P((struct buf *)); - struct disklabel *lp; - struct cpu_disklabel *osdep; +writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, + struct cpu_disklabel *osdep) { struct buf *bp; struct disklabel *dlp; diff --git a/sys/arch/pc532/pc532/genassym.cf b/sys/arch/pc532/pc532/genassym.cf index 97616a4c9a9..8504a04630b 100644 --- a/sys/arch/pc532/pc532/genassym.cf +++ b/sys/arch/pc532/pc532/genassym.cf @@ -1,4 +1,4 @@ -# $NetBSD: genassym.cf,v 1.12 2006/03/11 13:52:59 simonb Exp $ +# $NetBSD: genassym.cf,v 1.13 2006/05/12 06:05:23 simonb Exp $ # # Copyright (c) 1982, 1990 The Regents of the University of California. @@ -56,9 +56,9 @@ include <machine/vmparam.h> define LSRUN LSRUN define LSONPROC LSONPROC -define PDSHIFT PDSHIFT -define PGSHIFT PGSHIFT -define PGOFSET PGOFSET +define PDSHIFT PDSHIFT +define PGSHIFT PGSHIFT +define PGOFSET PGOFSET define NBPG NBPG define PDE_SIZE sizeof(pd_entry_t) @@ -71,18 +71,18 @@ define L_ADDR offsetof(struct lwp, l_addr) define L_BACK offsetof(struct lwp, l_back) define L_FORW offsetof(struct lwp, l_forw) define L_PRIORITY offsetof(struct lwp, l_priority) -define L_PROC offsetof(struct lwp, l_proc) +define L_PROC offsetof(struct lwp, l_proc) define L_STAT offsetof(struct lwp, l_stat) -define L_WCHAN offsetof(struct lwp, l_wchan) +define L_WCHAN offsetof(struct lwp, l_wchan) define P_MD_SYSCALL offsetof(struct proc, p_md.md_syscall) define V_INTR offsetof(struct uvmexp, intrs) define PCB_ONSTACK offsetof(struct pcb, pcb_onstack) -define PCB_FSR offsetof(struct pcb, pcb_fsr) -define PCB_KSP offsetof(struct pcb, pcb_ksp) -define PCB_KFP offsetof(struct pcb, pcb_kfp) -define PCB_PTB offsetof(struct pcb, pcb_ptb) +define PCB_FSR offsetof(struct pcb, pcb_fsr) +define PCB_KSP offsetof(struct pcb, pcb_ksp) +define PCB_KFP offsetof(struct pcb, pcb_kfp) +define PCB_PTB offsetof(struct pcb, pcb_ptb) define PCB_ONFAULT offsetof(struct pcb, pcb_onfault) define PCB_F0 offsetof(struct pcb, pcb_freg[0]) define PCB_F1 offsetof(struct pcb, pcb_freg[1]) @@ -94,15 +94,15 @@ define PCB_F6 offsetof(struct pcb, pcb_freg[6]) define PCB_F7 offsetof(struct pcb, pcb_freg[7]) define REGS_USP offsetof(struct reg, r_sp) -define REGS_FP offsetof(struct reg, r_fp) -define REGS_SB offsetof(struct reg, r_sb) +define REGS_FP offsetof(struct reg, r_fp) +define REGS_SB offsetof(struct reg, r_sb) define REGS_PSR offsetof(struct reg, r_psr) define IV_VEC offsetof(struct iv, iv_vec) define IV_ARG offsetof(struct iv, iv_arg) define IV_USE offsetof(struct iv, iv_use) -define IV_MASK offsetof(struct iv, iv_mask) +define IV_MASK offsetof(struct iv, iv_mask) define IV_EVCNT offsetof(struct iv, iv_evcnt) -define IV_SIZE sizeof(struct iv) +define IV_SIZE sizeof(struct iv) define EV_COUNT offsetof(struct evcnt, ev_count) diff --git a/sys/arch/pc532/pc532/in_cksum.c b/sys/arch/pc532/pc532/in_cksum.c index c177d1c2982..9151a07f979 100644 --- a/sys/arch/pc532/pc532/in_cksum.c +++ b/sys/arch/pc532/pc532/in_cksum.c @@ -1,4 +1,4 @@ -/* $NetBSD: in_cksum.c,v 1.13 2005/12/24 20:07:24 perry Exp $ */ +/* $NetBSD: in_cksum.c,v 1.14 2006/05/12 06:05:23 simonb Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -69,7 +69,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: in_cksum.c,v 1.13 2005/12/24 20:07:24 perry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in_cksum.c,v 1.14 2006/05/12 06:05:23 simonb Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -104,13 +104,11 @@ __KERNEL_RCSID(0, "$NetBSD: in_cksum.c,v 1.13 2005/12/24 20:07:24 perry Exp $"); #define ADDWORD {sum += *(u_short *)w;} int -in_cksum(m, len) - register struct mbuf *m; - register int len; +in_cksum(struct mbuf *m, int len) { - register u_char *w; - register unsigned sum = 0; - register int mlen = 0; + u_char *w; + unsigned sum = 0; + int mlen = 0; int byte_swapped = 0; for (; m && len; m = m->m_next) { diff --git a/sys/arch/pc532/pc532/intr.c b/sys/arch/pc532/pc532/intr.c index 51e71990e9e..3727fe955aa 100644 --- a/sys/arch/pc532/pc532/intr.c +++ b/sys/arch/pc532/pc532/intr.c @@ -1,4 +1,4 @@ -/* $NetBSD: intr.c,v 1.30 2005/12/11 12:18:31 christos Exp $ */ +/* $NetBSD: intr.c,v 1.31 2006/05/12 06:05:23 simonb Exp $ */ /* * Copyright (c) 1994 Matthias Pfaller. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.30 2005/12/11 12:18:31 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.31 2006/05/12 06:05:23 simonb Exp $"); #define DEFINE_SPLX #include <sys/param.h> @@ -48,14 +48,14 @@ static int next_sir = SOFTINT; unsigned int imask[NIPL] = {0xffffffff, 0xffffffff}; unsigned int Cur_pl = 0xffffffff, sirpending, astpending; -static void badhard __P((void *)); -static void badsoft __P((void *)); +static void badhard(void *); +static void badsoft(void *); /* * Initialize the interrupt system. */ void -intr_init() +intr_init(void) { int i, sir; static u_char icu_table[] = { @@ -115,11 +115,10 @@ intr_init() * Handle pending software interrupts. */ void -check_sir(arg) - void *arg; +check_sir(void *arg) { - register unsigned int cirpending, mask; - register struct iv *iv; + unsigned int cirpending, mask; + struct iv *iv; #ifdef DIAGNOSTIC if (Cur_pl != (imask[IPL_ZERO] | (1 << IR_SOFT))) @@ -133,7 +132,8 @@ check_sir(arg) for (iv = ivt + SOFTINT, mask = 0x10000; cirpending & -mask; mask <<= 1, iv++) { if ((cirpending & mask) != 0) { - register int s; + int s; + uvmexp.softs++; iv->iv_evcnt.ev_count++; s = splraise(iv->iv_mask); @@ -154,14 +154,8 @@ check_sir(arg) * is allocated. */ int -intr_establish(intr, vector, arg, use, blevel, rlevel, mode) - int intr; - void (*vector) __P((void *)); - void *arg; - const char *use; - int blevel; - int rlevel; - int mode; +intr_establish(int intr, void (*vector)(void *), void *arg, const char *use, + int blevel, int rlevel, int mode) { int i, soft; @@ -250,19 +244,20 @@ intr_establish(intr, vector, arg, use, blevel, rlevel, mode) * Default hardware interrupt handler */ static void -badhard(arg) - void *arg; +badhard(void *arg) { struct intrframe *frame = arg; static int bad_count = 0; di(); bad_count++; if (bad_count < 5) - printf("Unknown hardware interrupt: vec=%ld pc=0x%08x psr=0x%04x cpl=0x%08lx\n", - frame->if_vec, frame->if_regs.r_pc, frame->if_regs.r_psr, frame->if_pl); + printf("Unknown hardware interrupt: vec=%ld pc=0x%08x " + "psr=0x%04x cpl=0x%08lx\n", frame->if_vec, + frame->if_regs.r_pc, frame->if_regs.r_psr, frame->if_pl); if (bad_count == 5) - printf("Too many unknown hardware interrupts, quitting reporting them.\n"); + printf("Too many unknown hardware interrupts, quitting " + "reporting them.\n"); ei(); } @@ -270,10 +265,10 @@ badhard(arg) * Default software interrupt handler */ static void -badsoft(arg) - void *arg; +badsoft(void *arg) { static int bad_count = 0; + bad_count++; if (bad_count < 5) printf("Unknown software interrupt: vec=%d\n", (int)arg); diff --git a/sys/arch/pc532/pc532/kgdb_machdep.c b/sys/arch/pc532/pc532/kgdb_machdep.c index 24640825aa0..f4d81a5b6ab 100644 --- a/sys/arch/pc532/pc532/kgdb_machdep.c +++ b/sys/arch/pc532/pc532/kgdb_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: kgdb_machdep.c,v 1.12 2005/12/11 12:18:31 christos Exp $ */ +/* $NetBSD: kgdb_machdep.c,v 1.13 2006/05/12 06:05:23 simonb Exp $ */ /* * Copyright (c) 1996 Matthias Pfaller. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kgdb_machdep.c,v 1.12 2005/12/11 12:18:31 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kgdb_machdep.c,v 1.13 2006/05/12 06:05:23 simonb Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -49,9 +49,7 @@ __KERNEL_RCSID(0, "$NetBSD: kgdb_machdep.c,v 1.12 2005/12/11 12:18:31 christos E * Determine if the memory at va..(va+len) is valid. */ int -kgdb_acc(va, len) - vaddr_t va; - size_t len; +kgdb_acc(vaddr_t va, size_t len) { vaddr_t last_va; pt_entry_t *pte; @@ -75,9 +73,9 @@ kgdb_acc(va, len) * (gdb only understands unix signal numbers). */ int -kgdb_signal(type) - int type; +kgdb_signal(int type) { + switch (type) { case T_NVI: case T_NMI: @@ -120,10 +118,9 @@ kgdb_signal(type) * understood by gdb. */ void -kgdb_getregs(regs, gdb_regs) - db_regs_t *regs; - kgdb_reg_t *gdb_regs; +kgdb_getregs(db_regs_t *regs, kgdb_reg_t *gdb_regs) { + gdb_regs[R0_REGNUM + 0] = regs->tf_regs.r_r0; gdb_regs[R0_REGNUM + 1] = regs->tf_regs.r_r1; gdb_regs[R0_REGNUM + 2] = regs->tf_regs.r_r2; @@ -143,10 +140,9 @@ kgdb_getregs(regs, gdb_regs) * Reverse the above. */ void -kgdb_setregs(regs, gdb_regs) - db_regs_t *regs; - kgdb_reg_t *gdb_regs; +kgdb_setregs(db_regs_t *regs, kgdb_reg_t *gdb_regs) { + regs->tf_regs.r_r0 = gdb_regs[R0_REGNUM + 0]; regs->tf_regs.r_r1 = gdb_regs[R0_REGNUM + 1]; regs->tf_regs.r_r2 = gdb_regs[R0_REGNUM + 2]; @@ -168,8 +164,7 @@ kgdb_setregs(regs, gdb_regs) * noting on the console why nothing else is going on. */ void -kgdb_connect(verbose) - int verbose; +kgdb_connect(int verbose) { if (kgdb_dev < 0) @@ -191,8 +186,9 @@ kgdb_connect(verbose) * (This is called by panic, like Debugger()) */ void -kgdb_panic() +kgdb_panic(void) { + if (kgdb_dev >= 0 && kgdb_debug_panic) { printf("entering kgdb\n"); kgdb_connect(kgdb_active == 0); diff --git a/sys/arch/pc532/pc532/locore.s b/sys/arch/pc532/pc532/locore.s index b3deeda9139..b7cf2f73f29 100644 --- a/sys/arch/pc532/pc532/locore.s +++ b/sys/arch/pc532/pc532/locore.s @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.81 2006/03/11 13:52:59 simonb Exp $ */ +/* $NetBSD: locore.s,v 1.82 2006/05/12 06:05:23 simonb Exp $ */ /* * Copyright (c) 1993 Philip A. Nelson. @@ -128,7 +128,7 @@ KENTRY(delay, 4) /* bsr 2 cycles; 80 ns */ #ifdef CPU30MHZ nop; nop #endif - movd S_ARG0,r0 /* 2 cycles; 80 ns */ + movd S_ARG0,r0 /* 2 cycles; 80 ns */ acbd -1,r0,1f /* 5 cycles; 200 ns */ /* ====== */ /* 840 ns */ @@ -141,8 +141,8 @@ KENTRY(delay, 4) /* bsr 2 cycles; 80 ns */ #ifdef CPU30MHZ nop; nop #endif - acbd -1,r0,1b /* 5 cycles; 200 ns */ -2: ret ARGS /* 4 cycles; 160 ns */ + acbd -1,r0,1b /* 5 cycles; 200 ns */ +2: ret ARGS /* 4 cycles; 160 ns */ /****************************************************************************/ @@ -1080,7 +1080,7 @@ ENTRY_NOPROFILE(handle_trap) * Store the mmu status. * This is needed for abort traps. */ - smr tear,tos + smr tear,tos smr msr,tos bsr _C_LABEL(trap) adjspd -12 /* Pop off software part of frame. */ @@ -1194,7 +1194,7 @@ ASENTRY_NOPROFILE(interrupt) * r3 contains imask[IPL_ZERO] and IR_SOFT is * not set in imask[IPL_ZERO]. So the following * instruction just does a - * r0 = r3 | (1 << IR_SOFT). + * r0 = r3 | (1 << IR_SOFT). */ addr 1 << IR_SOFT(r3),r0 movd r0,_C_LABEL(Cur_pl)(pc) @@ -1293,7 +1293,7 @@ KENTRY(ram_size, 4) addr 2f(pc),4(sb) /* tmp NMI vector */ cinv ia,r0 /* Vector reads go through the icache? */ movd 8(fp),r0 /* r0 = start */ - addr PGOFSET(r0),r0 /* round up to page */ + addr PGOFSET(r0),r0 /* round up to page */ andd ~PGOFSET,r0 movd 0xa5a5a5a5,r3 comd r3,r4 diff --git a/sys/arch/pc532/pc532/machdep.c b/sys/arch/pc532/pc532/machdep.c index 2c6f3550499..1f406d6424e 100644 --- a/sys/arch/pc532/pc532/machdep.c +++ b/sys/arch/pc532/pc532/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.163 2005/12/24 20:07:24 perry Exp $ */ +/* $NetBSD: machdep.c,v 1.164 2006/05/12 06:05:23 simonb Exp $ */ /*- * Copyright (c) 1982, 1987, 1990 The Regents of the University of California. @@ -75,7 +75,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.163 2005/12/24 20:07:24 perry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.164 2006/05/12 06:05:23 simonb Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -172,19 +172,19 @@ extern paddr_t avail_start, avail_end; extern int nkpde; extern int ieee_handler_disable; -static paddr_t alloc_pages __P((int)); -static int cpu_dump __P((void)); -static int cpu_dumpsize __P((void)); -static void cpu_reset __P((void)); -static void dumpsys __P((void)); -void init532 __P((void)); -static void map __P((pd_entry_t *, vaddr_t, paddr_t, int, int)); +static paddr_t alloc_pages(int); +static int cpu_dump(void); +static int cpu_dumpsize(void); +static void cpu_reset(void); +static void dumpsys(void); +void init532(void); +static void map(pd_entry_t *, vaddr_t, paddr_t, int, int); /* * Machine-dependent startup code */ void -cpu_startup() +cpu_startup(void) { char pbuf[9]; vaddr_t minaddr, maxaddr; @@ -373,11 +373,8 @@ sendsig(const ksiginfo_t *ksi, const sigset_t *mask) } void -cpu_upcall(l, type, nevents, ninterrupted, sas, ap, sp, upcall) - struct lwp *l; - int type, nevents, ninterrupted; - void *sas, *ap, *sp; - sa_upcall_t upcall; +cpu_upcall(struct lwp *l, int type, int nevents, int ninterrupted, void *sas, + void *ap, void *sp, sa_upcall_t upcall) { struct saframe *sf, frame; struct reg *regs; @@ -404,10 +401,7 @@ cpu_upcall(l, type, nevents, ninterrupted, sas, ap, sp, upcall) } void -cpu_getmcontext(l, mcp, flags) - struct lwp *l; - mcontext_t *mcp; - unsigned int *flags; +cpu_getmcontext(struct lwp *l, mcontext_t *mcp, unsigned int *flags) { struct reg *regs = l->l_md.md_regs; @@ -433,10 +427,7 @@ cpu_getmcontext(l, mcp, flags) } int -cpu_setmcontext(l, mcp, flags) - struct lwp *l; - const mcontext_t *mcp; - unsigned int flags; +cpu_setmcontext(struct lwp *l, const mcontext_t *mcp, unsigned int flags) { struct reg *regs = l->l_md.md_regs; @@ -477,9 +468,7 @@ int waittime = -1; static struct switchframe dump_sf; void -cpu_reboot(howto, bootstr) - int howto; - char *bootstr; +cpu_reboot(int howto, char *bootstr) { int s; @@ -563,15 +552,15 @@ haltsys: /* * These variables are needed by /sbin/savecore */ -u_int32_t dumpmag = 0x8fca0101; /* magic number */ -int dumpsize = 0; /* pages */ -long dumplo = 0; /* blocks */ +uint32_t dumpmag = 0x8fca0101; /* magic number */ +int dumpsize = 0; /* pages */ +long dumplo = 0; /* blocks */ /* * cpu_dumpsize: calculate size of machine-dependent kernel core dump headers. */ static int -cpu_dumpsize() +cpu_dumpsize(void) { int size; @@ -586,10 +575,10 @@ cpu_dumpsize() * cpu_dump: dump machine-dependent kernel core dump headers. */ static int -cpu_dump() +cpu_dump(void) { const struct bdevsw *bdev; - int (*dump) __P((dev_t, daddr_t, caddr_t, size_t)); + int (*dump)(dev_t, daddr_t, caddr_t, size_t); long buf[dbtob(1) / sizeof (long)]; kcore_seg_t *segp; cpu_kcore_hdr_t *cpuhdrp; @@ -598,7 +587,7 @@ cpu_dump() if (bdev == NULL) return (ENXIO); - dump = bdev->d_dump; + dump = bdev->d_dump; segp = (kcore_seg_t *)buf; cpuhdrp = @@ -628,7 +617,7 @@ cpu_dump() * reduce the chance that swapping trashes it. */ void -cpu_dumpconf() +cpu_dumpconf(void) { const struct bdevsw *bdev; int nblks, dumpblks; /* size of dump area */ @@ -672,8 +661,7 @@ bad: static vaddr_t dumpspace; vaddr_t -reserve_dumppages(p) - vaddr_t p; +reserve_dumppages(vaddr_t p) { dumpspace = p; @@ -681,13 +669,13 @@ reserve_dumppages(p) } void -dumpsys() +dumpsys(void) { const struct bdevsw *bdev; unsigned bytes, i, n; int maddr, psize; daddr_t blkno; - int (*dump) __P((dev_t, daddr_t, caddr_t, size_t)); + int (*dump)(dev_t, daddr_t, caddr_t, size_t); int error; if (dumpdev == NODEV) @@ -786,10 +774,7 @@ err: * Clear registers on exec */ void -setregs(l, pack, stack) - struct lwp *l; - struct exec_package *pack; - u_long stack; +setregs(struct lwp *l, struct exec_package *pack, u_long stack) { struct proc *p = l->l_proc; struct reg *r = l->l_md.md_regs; @@ -813,8 +798,7 @@ setregs(l, pack, stack) * Allocate memory pages. */ static paddr_t -alloc_pages(pages) - int pages; +alloc_pages(int pages) { paddr_t p = avail_start; avail_start += pages * PAGE_SIZE; @@ -828,11 +812,7 @@ alloc_pages(pages) * are allocated for the selected virtual address range. */ static void -map(pd, virtual, physical, protection, size) - pd_entry_t *pd; - vaddr_t virtual; - paddr_t physical; - int protection, size; +map(pd_entry_t *pd, vaddr_t virtual, paddr_t physical, int protection, int size) { u_int ix1 = pdei(virtual); u_int ix2 = ptei(virtual); @@ -893,9 +873,9 @@ map(pd, virtual, physical, protection, size) #define kvpa(x) VA(ns532_round_page(x)) void -init532() +init532(void) { - extern void main __P((void *)); + extern void main(void *); extern int inttab[]; #if NKSYMS || defined(DDB) || defined(LKM) extern char *esym; @@ -1044,10 +1024,9 @@ init532() * Any takers for Sinix, Genix, SVR2/32000 or Minix? */ int -cpu_exec_aout_makecmds(l, epp) - struct lwp *l; - struct exec_package *epp; +cpu_exec_aout_makecmds(struct lwp *l, struct exec_package *epp) { + return ENOEXEC; } @@ -1057,7 +1036,7 @@ cpu_exec_aout_makecmds(l, epp) * to choose and initialize a console. */ void -consinit() +consinit(void) { cninit(); @@ -1071,14 +1050,15 @@ consinit() ksyms_init(*(int *)end, ((int *)end) + 1, (int *)esym); #endif #if defined (DDB) - if(boothowto & RB_KDB) - Debugger(); + if(boothowto & RB_KDB) + Debugger(); #endif } static void -cpu_reset() +cpu_reset(void) { + /* Mask all ICU interrupts. */ splhigh(); @@ -1091,7 +1071,7 @@ cpu_reset() /* Jump to low memory. */ __asm volatile( - "addr 1f(pc),r0;" + "addr 1f(pc),r0;" "andd ~%0,r0;" "jump 0(r0);" "1:" @@ -1115,19 +1095,18 @@ cpu_reset() * Network software interrupt routine */ void -softnet(arg) - void *arg; +softnet(void *arg) { - register int isr; + int isr; di(); isr = netisr; netisr = 0; ei(); if (isr == 0) return; #define DONETISR(bit, fn) \ - do { \ +do { \ if (isr & (1 << bit)) \ fn(); \ - } while (0) +} while (0) #include <net/netisr_dispatch.h> diff --git a/sys/arch/pc532/pc532/mainbus.c b/sys/arch/pc532/pc532/mainbus.c index 9d478be4774..c89a6d74b5a 100644 --- a/sys/arch/pc532/pc532/mainbus.c +++ b/sys/arch/pc532/pc532/mainbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: mainbus.c,v 1.19 2005/12/11 12:18:31 christos Exp $ */ +/* $NetBSD: mainbus.c,v 1.20 2006/05/12 06:05:23 simonb Exp $ */ /* * Copyright (c) 1997 Matthias Pfaller. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.19 2005/12/11 12:18:31 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.20 2006/05/12 06:05:23 simonb Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -41,28 +41,23 @@ __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.19 2005/12/11 12:18:31 christos Exp $" #include <machine/autoconf.h> #include <machine/icu.h> -static int mbprobe __P((struct device *, struct cfdata *, void *)); -static void mbattach __P((struct device *, struct device *, void *)); -static int mbsearch __P((struct device *, struct cfdata *, - const int *, void *)); -static int mbprint __P((void *, const char *)); +static int mbprobe(struct device *, struct cfdata *, void *); +static void mbattach(struct device *, struct device *, void *); +static int mbsearch(struct device *, struct cfdata *, const int *, void *); +static int mbprint(void *, const char *); CFATTACH_DECL(mainbus, sizeof(struct device), mbprobe, mbattach, NULL, NULL); static int -mbprobe(parent, cf, aux) - struct device *parent; - struct cfdata *cf; - void *aux; +mbprobe(struct device *parent, struct cfdata *cf, void *aux) { + return(strcmp(cf->cf_name, "mainbus") == 0); } static void -mbattach(parent, self, aux) - struct device *parent, *self; - void *aux; +mbattach(struct device *parent, struct device *self, void *aux) { int clk, net; static u_char icu_table[] = { @@ -97,9 +92,7 @@ mbattach(parent, self, aux) } static int -mbprint(aux, pnp) - void *aux; - const char *pnp; +mbprint(void *aux, const char *pnp) { const char *delim; struct confargs *ca = aux; @@ -120,11 +113,7 @@ mbprint(aux, pnp) } static int -mbsearch(parent, cf, ldesc, aux) - struct device *parent; - struct cfdata *cf; - const int *ldesc; - void *aux; +mbsearch(struct device *parent, struct cfdata *cf, const int *ldesc, void *aux) { struct confargs ca; @@ -141,9 +130,9 @@ mbsearch(parent, cf, ldesc, aux) } void -icu_init(p) - u_char *p; +icu_init(u_char *p) { + di(); while (*p != 0xff) { ICUB(p[0]) = p[1]; diff --git a/sys/arch/pc532/pc532/mem.c b/sys/arch/pc532/pc532/mem.c index 733b367518e..6e70688889a 100644 --- a/sys/arch/pc532/pc532/mem.c +++ b/sys/arch/pc532/pc532/mem.c @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.37 2005/12/11 12:18:31 christos Exp $ */ +/* $NetBSD: mem.c,v 1.38 2006/05/12 06:05:23 simonb Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.37 2005/12/11 12:18:31 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.38 2006/05/12 06:05:23 simonb Exp $"); #include <sys/param.h> #include <sys/conf.h> @@ -106,10 +106,7 @@ const struct cdevsw mem_cdevsw = { /*ARGSUSED*/ int -mmrw(dev, uio, flags) - dev_t dev; - struct uio *uio; - int flags; +mmrw(dev_t dev, struct uio *uio, int flags) { vaddr_t o, v; int c; @@ -196,10 +193,7 @@ mmrw(dev, uio, flags) } paddr_t -mmmmap(dev, off, prot) - dev_t dev; - off_t off; - int prot; +mmmmap(dev_t dev, off_t off, int prot) { struct proc *p = curproc; /* XXX */ diff --git a/sys/arch/pc532/pc532/pmap.c b/sys/arch/pc532/pc532/pmap.c index 9d813e1609c..67988ed8a9e 100644 --- a/sys/arch/pc532/pc532/pmap.c +++ b/sys/arch/pc532/pc532/pmap.c @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.79 2005/12/24 20:07:24 perry Exp $ */ +/* $NetBSD: pmap.c,v 1.80 2006/05/12 06:05:23 simonb Exp $ */ /* * @@ -60,7 +60,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.79 2005/12/24 20:07:24 perry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.80 2006/05/12 06:05:23 simonb Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -145,9 +145,9 @@ __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.79 2005/12/24 20:07:24 perry Exp $"); * is a void function. * * [B] new page tables pages (PTP) - * call uvm_pagealloc() - * => success: zero page, add to pm_pdir - * => failure: we are out of free vm_pages, let pmap_enter() + * call uvm_pagealloc() + * => success: zero page, add to pm_pdir + * => failure: we are out of free vm_pages, let pmap_enter() * tell UVM about it. * * note: for kernel PTPs, we start with NKPTP of them. as we map @@ -343,40 +343,37 @@ extern paddr_t msgbuf_paddr; * local prototypes */ -static struct pv_entry *pmap_add_pvpage __P((struct pv_page *, boolean_t)); -static struct vm_page *pmap_alloc_ptp __P((struct pmap *, int)); -static struct pv_entry *pmap_alloc_pv __P((struct pmap *, int)); /* see codes below */ +static struct pv_entry *pmap_add_pvpage(struct pv_page *, boolean_t); +static struct vm_page *pmap_alloc_ptp(struct pmap *, int); +static struct pv_entry *pmap_alloc_pv(struct pmap *, int); /* see codes below */ #define ALLOCPV_NEED 0 /* need PV now */ #define ALLOCPV_TRY 1 /* just try to allocate, don't steal */ #define ALLOCPV_NONEED 2 /* don't need PV, just growing cache */ -static struct pv_entry *pmap_alloc_pvpage __P((struct pmap *, int)); -static void pmap_enter_pv __P((struct pv_head *, - struct pv_entry *, struct pmap *, - vaddr_t, struct vm_page *)); -static void pmap_free_pv __P((struct pmap *, struct pv_entry *)); -static void pmap_free_pvs __P((struct pmap *, struct pv_entry *)); -static void pmap_free_pv_doit __P((struct pv_entry *)); -static void pmap_free_pvpage __P((void)); -static struct vm_page *pmap_get_ptp __P((struct pmap *, int)); -static boolean_t pmap_is_curpmap __P((struct pmap *)); -static pt_entry_t *pmap_map_ptes __P((struct pmap *)); -static struct pv_entry *pmap_remove_pv __P((struct pv_head *, struct pmap *, - vaddr_t)); -static void pmap_do_remove __P((struct pmap *, vaddr_t, - vaddr_t, int)); -static boolean_t pmap_remove_pte __P((struct pmap *, struct vm_page *, - pt_entry_t *, vaddr_t, int)); -static void pmap_remove_ptes __P((struct pmap *, - struct pmap_remove_record *, - struct vm_page *, vaddr_t, - vaddr_t, vaddr_t, int)); +static struct pv_entry *pmap_alloc_pvpage(struct pmap *, int); +static void pmap_enter_pv(struct pv_head *, struct pv_entry *, + struct pmap *, vaddr_t, struct vm_page *); +static void pmap_free_pv(struct pmap *, struct pv_entry *); +static void pmap_free_pvs(struct pmap *, struct pv_entry *); +static void pmap_free_pv_doit(struct pv_entry *); +static void pmap_free_pvpage(void); +static struct vm_page *pmap_get_ptp(struct pmap *, int); +static boolean_t pmap_is_curpmap(struct pmap *); +static pt_entry_t *pmap_map_ptes(struct pmap *); +static struct pv_entry *pmap_remove_pv(struct pv_head *, struct pmap *, + vaddr_t); +static void pmap_do_remove(struct pmap *, vaddr_t, vaddr_t, int); +static boolean_t pmap_remove_pte(struct pmap *, struct vm_page *, + pt_entry_t *, vaddr_t, int); +static void pmap_remove_ptes(struct pmap *, + struct pmap_remove_record *, struct vm_page *, + vaddr_t, vaddr_t, vaddr_t, int); #define PMAP_REMOVE_ALL 0 /* remove all mappings */ #define PMAP_REMOVE_SKIPWIRED 1 /* skip wired mappings */ -static vaddr_t pmap_tmpmap_pa __P((paddr_t)); -static pt_entry_t *pmap_tmpmap_pvepte __P((struct pv_entry *)); -static void pmap_tmpunmap_pa __P((void)); -static void pmap_tmpunmap_pvepte __P((struct pv_entry *)); -static void pmap_unmap_ptes __P((struct pmap *)); +static vaddr_t pmap_tmpmap_pa(paddr_t); +static pt_entry_t *pmap_tmpmap_pvepte(struct pv_entry *); +static void pmap_tmpunmap_pa(void); +static void pmap_tmpunmap_pvepte(struct pv_entry *); +static void pmap_unmap_ptes(struct pmap *); /* * p m a p i n l i n e h e l p e r f u n c t i o n s @@ -388,10 +385,10 @@ static void pmap_unmap_ptes __P((struct pmap *)); */ inline static boolean_t -pmap_is_curpmap(pmap) - struct pmap *pmap; +pmap_is_curpmap(struct pmap *pmap) { paddr_t ptb; + if (pmap == pmap_kernel()) return(1); smr(ptb0, ptb); @@ -407,9 +404,9 @@ pmap_is_curpmap(pmap) */ inline static vaddr_t -pmap_tmpmap_pa(pa) - paddr_t pa; +pmap_tmpmap_pa(paddr_t pa) { + simple_lock(&pmap_tmpptp_lock); #if defined(DIAGNOSTIC) if (*ptp_pte) @@ -426,7 +423,7 @@ pmap_tmpmap_pa(pa) */ inline static void -pmap_tmpunmap_pa() +pmap_tmpunmap_pa(void) { #if defined(DIAGNOSTIC) if (!pmap_valid_entry(*ptp_pte)) @@ -445,9 +442,9 @@ pmap_tmpunmap_pa() */ inline static pt_entry_t * -pmap_tmpmap_pvepte(pve) - struct pv_entry *pve; +pmap_tmpmap_pvepte(struct pv_entry *pve) { + #ifdef DIAGNOSTIC if (pve->pv_pmap == pmap_kernel()) panic("pmap_tmpmap_pvepte: attempt to map kernel"); @@ -468,9 +465,9 @@ pmap_tmpmap_pvepte(pve) */ inline static void -pmap_tmpunmap_pvepte(pve) - struct pv_entry *pve; +pmap_tmpunmap_pvepte(struct pv_entry *pve) { + /* was it current pmap? if so, return */ if (pmap_is_curpmap(pve->pv_pmap)) return; @@ -486,8 +483,7 @@ pmap_tmpunmap_pvepte(pve) */ inline static pt_entry_t * -pmap_map_ptes(pmap) - struct pmap *pmap; +pmap_map_ptes(struct pmap *pmap) { pd_entry_t opde; @@ -526,9 +522,9 @@ pmap_map_ptes(pmap) */ inline static void -pmap_unmap_ptes(pmap) - struct pmap *pmap; +pmap_unmap_ptes(struct pmap *pmap) { + if (pmap == pmap_kernel()) { return; } @@ -556,10 +552,7 @@ pmap_unmap_ptes(pmap) */ void -pmap_kenter_pa(va, pa, prot) - vaddr_t va; - paddr_t pa; - vm_prot_t prot; +pmap_kenter_pa(vaddr_t va, paddr_t pa, vm_prot_t prot) { pt_entry_t *pte, opte; @@ -585,9 +578,7 @@ pmap_kenter_pa(va, pa, prot) */ void -pmap_kremove(va, len) - vaddr_t va; - vsize_t len; +pmap_kremove(vaddr_t va, vsize_t len) { pt_entry_t *pte; @@ -626,8 +617,7 @@ pmap_kremove(va, len) */ void -pmap_bootstrap(kva_start) - vaddr_t kva_start; +pmap_bootstrap(vaddr_t kva_start) { struct pmap *kpm; pt_entry_t *pte; @@ -659,7 +649,7 @@ pmap_bootstrap(kva_start) * we can jam into a ns532 PTE. */ - protection_codes[VM_PROT_NONE] = 0; /* --- */ + protection_codes[VM_PROT_NONE] = 0; /* --- */ protection_codes[VM_PROT_EXECUTE] = PG_RO; /* --x */ protection_codes[VM_PROT_READ] = PG_RO; /* -r- */ protection_codes[VM_PROT_READ|VM_PROT_EXECUTE] = PG_RO; /* -rx */ @@ -687,7 +677,7 @@ pmap_bootstrap(kva_start) kpm->pm_obj.uo_refs = 1; memset(&kpm->pm_list, 0, sizeof(kpm->pm_list)); /* pm_list not used */ kpm->pm_pdir = (pd_entry_t *)(lwp0.l_addr->u_pcb.pcb_ptb + KERNBASE); - kpm->pm_pdirpa = (u_int32_t) lwp0.l_addr->u_pcb.pcb_ptb; + kpm->pm_pdirpa = (uint32_t) lwp0.l_addr->u_pcb.pcb_ptb; kpm->pm_stats.wired_count = kpm->pm_stats.resident_count = ns532_btop(kva_start - VM_MIN_KERNEL_ADDRESS); @@ -788,7 +778,7 @@ pmap_bootstrap(kva_start) */ void -pmap_init() +pmap_init(void) { int npages, lcv, i; vaddr_t addr; @@ -870,9 +860,7 @@ pmap_init() */ inline static struct pv_entry * -pmap_alloc_pv(pmap, mode) - struct pmap *pmap; - int mode; +pmap_alloc_pv(struct pmap *pmap, int mode) { struct pv_page *pvpage; struct pv_entry *pv; @@ -927,9 +915,7 @@ pmap_alloc_pv(pmap, mode) */ static struct pv_entry * -pmap_alloc_pvpage(pmap, mode) - struct pmap *pmap; - int mode; +pmap_alloc_pvpage(struct pmap *pmap, int mode) { struct pv_page *pvpage; struct pv_entry *pv; @@ -984,9 +970,7 @@ pmap_alloc_pvpage(pmap, mode) */ static struct pv_entry * -pmap_add_pvpage(pvp, need_entry) - struct pv_page *pvp; - boolean_t need_entry; +pmap_add_pvpage(struct pv_page *pvp, boolean_t need_entry) { int tofree, lcv; @@ -1017,8 +1001,7 @@ pmap_add_pvpage(pvp, need_entry) */ inline static void -pmap_free_pv_doit(pv) - struct pv_entry *pv; +pmap_free_pv_doit(struct pv_entry *pv) { struct pv_page *pvp; @@ -1052,9 +1035,7 @@ pmap_free_pv_doit(pv) */ inline static void -pmap_free_pv(pmap, pv) - struct pmap *pmap; - struct pv_entry *pv; +pmap_free_pv(struct pmap *pmap, struct pv_entry *pv) { simple_lock(&pvalloc_lock); pmap_free_pv_doit(pv); @@ -1077,9 +1058,7 @@ pmap_free_pv(pmap, pv) */ inline static void -pmap_free_pvs(pmap, pvs) - struct pmap *pmap; - struct pv_entry *pvs; +pmap_free_pvs(struct pmap *pmap, struct pv_entry *pvs) { struct pv_entry *nextpv; @@ -1111,7 +1090,7 @@ pmap_free_pvs(pmap, pvs) */ static void -pmap_free_pvpage() +pmap_free_pvpage(void) { int s; struct pv_page *pvp; @@ -1143,16 +1122,15 @@ pmap_free_pvpage() * => caller should have pmap locked * => we will gain the lock on the pv_head and allocate the new pv_entry * => caller should adjust ptp's wire_count before calling + * + * pve = preallocated pve for us to use + * ptp = PTP in pmap that maps this VA */ - inline static void -pmap_enter_pv(pvh, pve, pmap, va, ptp) - struct pv_head *pvh; - struct pv_entry *pve; /* preallocated pve for us to use */ - struct pmap *pmap; - vaddr_t va; - struct vm_page *ptp; /* PTP in pmap that maps this VA */ +pmap_enter_pv(struct pv_head *pvh, struct pv_entry *pve, struct pmap *pmap, + vaddr_t va, struct vm_page *ptp) { + pve->pv_pmap = pmap; pve->pv_va = va; pve->pv_ptp = ptp; /* NULL for kernel pmap */ @@ -1173,10 +1151,7 @@ pmap_enter_pv(pvh, pve, pmap, va, ptp) */ inline static struct pv_entry * -pmap_remove_pv(pvh, pmap, va) - struct pv_head *pvh; - struct pmap *pmap; - vaddr_t va; +pmap_remove_pv(struct pv_head *pvh, struct pmap *pmap, vaddr_t va) { struct pv_entry *pve, **prevptr; @@ -1207,9 +1182,7 @@ pmap_remove_pv(pvh, pmap, va) */ inline static struct vm_page * -pmap_alloc_ptp(pmap, pde_index) - struct pmap *pmap; - int pde_index; +pmap_alloc_ptp(struct pmap *pmap, int pde_index) { struct vm_page *ptp; @@ -1236,9 +1209,7 @@ pmap_alloc_ptp(pmap, pde_index) */ static struct vm_page * -pmap_get_ptp(pmap, pde_index) - struct pmap *pmap; - int pde_index; +pmap_get_ptp(struct pmap *pmap, int pde_index) { struct vm_page *ptp; @@ -1313,7 +1284,7 @@ pmap_pdp_ctor(void *arg, void *object, int flags) */ struct pmap * -pmap_create() +pmap_create(void) { struct pmap *pmap; @@ -1362,8 +1333,7 @@ pmap_create() */ void -pmap_destroy(pmap) - struct pmap *pmap; +pmap_destroy(struct pmap *pmap) { struct vm_page *pg; int refs; @@ -1418,9 +1388,9 @@ pmap_destroy(pmap) */ void -pmap_reference(pmap) - struct pmap *pmap; +pmap_reference(struct pmap *pmap) { + simple_lock(&pmap->pm_obj.vmobjlock); pmap->pm_obj.uo_refs++; simple_unlock(&pmap->pm_obj.vmobjlock); @@ -1434,8 +1404,7 @@ pmap_reference(pmap) */ void -pmap_activate(l) - struct lwp *l; +pmap_activate(struct lwp *l) { struct pcb *pcb = &l->l_addr->u_pcb; struct pmap *pmap = l->l_proc->p_vmspace->vm_map.pmap; @@ -1454,9 +1423,9 @@ pmap_activate(l) */ void -pmap_deactivate(l) - struct lwp *l; +pmap_deactivate(struct lwp *l) { + } /* @@ -1472,10 +1441,7 @@ pmap_deactivate(l) */ boolean_t -pmap_extract(pmap, va, pap) - struct pmap *pmap; - vaddr_t va; - paddr_t *pap; +pmap_extract(struct pmap *pmap, vaddr_t va, paddr_t *pap) { pt_entry_t *ptes, pte; pd_entry_t pde; @@ -1501,8 +1467,7 @@ pmap_extract(pmap, va, pap) */ paddr_t -vtophys(va) - vaddr_t va; +vtophys(vaddr_t va) { paddr_t pa; @@ -1518,10 +1483,9 @@ vtophys(va) */ void -pmap_virtual_space(startp, endp) - vaddr_t *startp; - vaddr_t *endp; +pmap_virtual_space(vaddr_t *startp, vaddr_t *endp) { + *startp = virtual_avail; *endp = virtual_end; } @@ -1534,11 +1498,9 @@ pmap_virtual_space(startp, endp) */ vaddr_t -pmap_map(va, spa, epa, prot) - vaddr_t va; - paddr_t spa, epa; - vm_prot_t prot; +pmap_map(vaddr_t va, paddr_t spa, paddr_t epa, vm_prot_t prot) { + while (spa < epa) { pmap_enter(pmap_kernel(), va, spa, prot, 0); va += PAGE_SIZE; @@ -1553,8 +1515,7 @@ pmap_map(va, spa, epa, prot) */ void -pmap_zero_page(pa) - paddr_t pa; +pmap_zero_page(paddr_t pa) { simple_lock(&pmap_zero_page_lock); @@ -1571,8 +1532,7 @@ pmap_zero_page(pa) */ boolean_t -pmap_zero_page_uncached(pa) - paddr_t pa; +pmap_zero_page_uncached(paddr_t pa) { boolean_t rv = TRUE; int i, *ptr; @@ -1606,9 +1566,9 @@ pmap_zero_page_uncached(pa) */ void -pmap_copy_page(srcpa, dstpa) - paddr_t srcpa, dstpa; +pmap_copy_page(paddr_t srcpa, paddr_t dstpa) { + simple_lock(&pmap_copy_page_lock); #ifdef DIAGNOSTIC if (*csrc_pte || *cdst_pte) @@ -1639,13 +1599,9 @@ pmap_copy_page(srcpa, dstpa) */ static void -pmap_remove_ptes(pmap, pmap_rr, ptp, ptpva, startva, endva, flags) - struct pmap *pmap; - struct pmap_remove_record *pmap_rr; - struct vm_page *ptp; - vaddr_t ptpva; - vaddr_t startva, endva; - int flags; +pmap_remove_ptes(struct pmap *pmap, struct pmap_remove_record *pmap_rr, + struct vm_page *ptp, vaddr_t ptpva, vaddr_t startva, vaddr_t endva, + int flags) { struct pv_entry *pv_tofree = NULL; /* list of pv_entrys to free */ struct pv_entry *pve; @@ -1741,12 +1697,8 @@ pmap_remove_ptes(pmap, pmap_rr, ptp, ptpva, startva, endva, flags) */ static boolean_t -pmap_remove_pte(pmap, ptp, pte, va, flags) - struct pmap *pmap; - struct vm_page *ptp; - pt_entry_t *pte; - vaddr_t va; - int flags; +pmap_remove_pte(struct pmap *pmap, struct vm_page *ptp, pt_entry_t *pte, + vaddr_t va, int flags) { pt_entry_t opte; int bank, off; @@ -1810,10 +1762,9 @@ pmap_remove_pte(pmap, ptp, pte, va, flags) */ void -pmap_remove(pmap, sva, eva) - struct pmap *pmap; - vaddr_t sva, eva; +pmap_remove(struct pmap *pmap, vaddr_t sva, vaddr_t eva) { + pmap_do_remove(pmap, sva, eva, PMAP_REMOVE_ALL); } @@ -1824,10 +1775,7 @@ pmap_remove(pmap, sva, eva) */ static void -pmap_do_remove(pmap, sva, eva, flags) - struct pmap *pmap; - vaddr_t sva, eva; - int flags; +pmap_do_remove(struct pmap *pmap, vaddr_t sva, vaddr_t eva, int flags) { pt_entry_t *ptes; boolean_t result; @@ -2003,8 +1951,7 @@ pmap_do_remove(pmap, sva, eva, flags) */ void -pmap_page_remove(pg) - struct vm_page *pg; +pmap_page_remove(struct vm_page *pg) { int bank, off; struct pv_head *pvh; @@ -2105,9 +2052,7 @@ pmap_page_remove(pg) */ boolean_t -pmap_test_attrs(pg, testbits) - struct vm_page *pg; - int testbits; +pmap_test_attrs(struct vm_page *pg, int testbits) { int bank, off; short *myattrs; @@ -2168,11 +2113,9 @@ pmap_test_attrs(pg, testbits) */ boolean_t -pmap_change_attrs(pg, setbits, clearbits) - struct vm_page *pg; - int setbits, clearbits; +pmap_change_attrs(struct vm_page *pg, int setbits, int clearbits) { - u_int32_t result; + uint32_t result; int bank, off; struct pv_head *pvh; struct pv_entry *pve; @@ -2248,15 +2191,12 @@ pmap_change_attrs(pg, setbits, clearbits) */ void -pmap_write_protect(pmap, sva, eva, prot) - struct pmap *pmap; - vaddr_t sva, eva; - vm_prot_t prot; +pmap_write_protect(struct pmap *pmap, vaddr_t sva, vaddr_t eva, vm_prot_t prot) { pt_entry_t *ptes, *spte, *epte, npte; struct pmap_remove_record pmap_rr, *prr; vaddr_t blockend, va; - u_int32_t md_prot; + uint32_t md_prot; ptes = pmap_map_ptes(pmap); /* locks pmap */ @@ -2359,9 +2299,7 @@ pmap_write_protect(pmap, sva, eva, prot) */ void -pmap_unwire(pmap, va) - struct pmap *pmap; - vaddr_t va; +pmap_unwire(struct pmap *pmap, vaddr_t va) { pt_entry_t *ptes; @@ -2399,14 +2337,13 @@ pmap_unwire(pmap, va) */ void -pmap_collect(pmap) - struct pmap *pmap; +pmap_collect(struct pmap *pmap) { + /* * free all of the pt pages by removing the physical mappings * for its entire address space. */ - pmap_do_remove(pmap, VM_MIN_ADDRESS, VM_MAX_ADDRESS, PMAP_REMOVE_SKIPWIRED); } @@ -2430,12 +2367,7 @@ pmap_collect(pmap) */ int -pmap_enter(pmap, va, pa, prot, flags) - struct pmap *pmap; - vaddr_t va; - paddr_t pa; - vm_prot_t prot; - int flags; +pmap_enter(struct pmap *pmap, vaddr_t va, paddr_t pa, vm_prot_t prot, int flags) { pt_entry_t *ptes, opte, npte; struct vm_page *ptp; @@ -2655,8 +2587,7 @@ out: */ vaddr_t -pmap_growkernel(maxkvaddr) - vaddr_t maxkvaddr; +pmap_growkernel(vaddr_t maxkvaddr) { struct pmap *kpm = pmap_kernel(), *pm; int needed_kpde; /* needed number of kernel PTPs */ @@ -2732,7 +2663,7 @@ out: } #ifdef DEBUG -void pmap_dump __P((struct pmap *, vaddr_t, vaddr_t)); +void pmap_dump(struct pmap *, vaddr_t, vaddr_t); /* * pmap_dump: dump all the mappings from a pmap @@ -2741,9 +2672,7 @@ void pmap_dump __P((struct pmap *, vaddr_t, vaddr_t)); */ void -pmap_dump(pmap, sva, eva) - struct pmap *pmap; - vaddr_t sva, eva; +pmap_dump(struct pmap *pmap, vaddr_t sva, vaddr_t eva) { pt_entry_t *ptes, *pte; vaddr_t blkendva; diff --git a/sys/arch/pc532/pc532/process_machdep.c b/sys/arch/pc532/pc532/process_machdep.c index da3c92b4ac4..8f86f1a0b15 100644 --- a/sys/arch/pc532/pc532/process_machdep.c +++ b/sys/arch/pc532/pc532/process_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: process_machdep.c,v 1.16 2005/12/11 12:18:31 christos Exp $ */ +/* $NetBSD: process_machdep.c,v 1.17 2006/05/12 06:05:23 simonb Exp $ */ /* * Copyright (c) 1993 The Regents of the University of California. @@ -93,7 +93,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.16 2005/12/11 12:18:31 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.17 2006/05/12 06:05:23 simonb Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -110,9 +110,7 @@ __KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.16 2005/12/11 12:18:31 christo extern struct lwp *fpu_lwp; int -process_read_regs(l, regs) - struct lwp *l; - struct reg *regs; +process_read_regs(struct lwp *l, struct reg *regs) { struct reg *pregs; @@ -125,9 +123,7 @@ process_read_regs(l, regs) } int -process_write_regs(l, regs) - struct lwp *l; - const struct reg *regs; +process_write_regs(struct lwp *l, const struct reg *regs) { struct reg *pregs; @@ -143,9 +139,7 @@ process_write_regs(l, regs) } int -process_read_fpregs(l, regs) - struct lwp *l; - struct fpreg *regs; +process_read_fpregs(struct lwp *l, struct fpreg *regs) { if ((l->l_flag & L_INMEM) == 0) return (EIO); @@ -159,9 +153,7 @@ process_read_fpregs(l, regs) } int -process_write_fpregs(l, regs) - struct lwp *l; - const struct fpreg *regs; +process_write_fpregs(struct lwp *l, const struct fpreg *regs) { if ((l->l_flag & L_INMEM) == 0) return (EIO); @@ -175,9 +167,7 @@ process_write_fpregs(l, regs) } int -process_sstep(l, sstep) - struct lwp *l; - int sstep; +process_sstep(struct lwp *l, int sstep) { struct reg *pregs; @@ -194,9 +184,7 @@ process_sstep(l, sstep) } int -process_set_pc(l, addr) - struct lwp *l; - caddr_t addr; +process_set_pc(struct lwp *l, caddr_t addr) { struct reg *pregs; diff --git a/sys/arch/pc532/pc532/procfs_machdep.c b/sys/arch/pc532/pc532/procfs_machdep.c index b55df941de1..116bd9e4121 100644 --- a/sys/arch/pc532/pc532/procfs_machdep.c +++ b/sys/arch/pc532/pc532/procfs_machdep.c @@ -1,7 +1,7 @@ -/* $NetBSD: procfs_machdep.c,v 1.4 2005/12/11 12:18:31 christos Exp $ */ +/* $NetBSD: procfs_machdep.c,v 1.5 2006/05/12 06:05:23 simonb Exp $ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.4 2005/12/11 12:18:31 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.5 2006/05/12 06:05:23 simonb Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -17,6 +17,7 @@ __KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.4 2005/12/11 12:18:31 christos int procfs_getcpuinfstr(char *buf, int *len) { + *len = 0; return 0; diff --git a/sys/arch/pc532/pc532/sys_machdep.c b/sys/arch/pc532/pc532/sys_machdep.c index 2617d4828bd..28c4b017579 100644 --- a/sys/arch/pc532/pc532/sys_machdep.c +++ b/sys/arch/pc532/pc532/sys_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: sys_machdep.c,v 1.14 2005/12/11 12:18:31 christos Exp $ */ +/* $NetBSD: sys_machdep.c,v 1.15 2006/05/12 06:05:23 simonb Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sys_machdep.c,v 1.14 2005/12/11 12:18:31 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_machdep.c,v 1.15 2006/05/12 06:05:23 simonb Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -51,10 +51,8 @@ __KERNEL_RCSID(0, "$NetBSD: sys_machdep.c,v 1.14 2005/12/11 12:18:31 christos Ex #include <sys/syscallargs.h> int -sys_sysarch(l, v, retval) - struct lwp *l; - void *v; - register_t *retval; +sys_sysarch(struct lwp *l, void *v, register_t *retval) { + return (ENOSYS); } diff --git a/sys/arch/pc532/pc532/syscall.c b/sys/arch/pc532/pc532/syscall.c index 927d596e0e0..286127e9e45 100644 --- a/sys/arch/pc532/pc532/syscall.c +++ b/sys/arch/pc532/pc532/syscall.c @@ -1,4 +1,4 @@ -/* $NetBSD: syscall.c,v 1.1 2006/03/11 13:52:59 simonb Exp $ */ +/* $NetBSD: syscall.c,v 1.2 2006/05/12 06:05:23 simonb Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.1 2006/03/11 13:52:59 simonb Exp $"); +__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.2 2006/05/12 06:05:23 simonb Exp $"); #include <sys/param.h> #include <sys/proc.h> @@ -96,12 +96,11 @@ __KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.1 2006/03/11 13:52:59 simonb Exp $"); #define __CDECL__ #endif -static void syscall_fancy __P((struct syscframe)) __CDECL__; -static void syscall_plain __P((struct syscframe)) __CDECL__; +static void syscall_fancy(struct syscframe) __CDECL__; +static void syscall_plain(struct syscframe) __CDECL__; void -syscall_intern(p) - struct proc *p; +syscall_intern(struct proc *p) { if (trace_is_enabled(p)) @@ -118,8 +117,7 @@ syscall_intern(p) */ /*ARGSUSED*/ void -syscall_plain(frame) - struct syscframe frame; +syscall_plain(struct syscframe frame) { caddr_t params; const struct sysent *callp; @@ -221,8 +219,7 @@ syscall_plain(frame) */ /*ARGSUSED*/ void -syscall_fancy(frame) - struct syscframe frame; +syscall_fancy(struct syscframe frame) { caddr_t params; const struct sysent *callp; diff --git a/sys/arch/pc532/pc532/trap.c b/sys/arch/pc532/pc532/trap.c index dfa81389977..1e9a7f489eb 100644 --- a/sys/arch/pc532/pc532/trap.c +++ b/sys/arch/pc532/pc532/trap.c @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.75 2006/05/12 05:42:36 skrll Exp $ */ +/* $NetBSD: trap.c,v 1.76 2006/05/12 06:05:23 simonb Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.75 2006/05/12 05:42:36 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.76 2006/05/12 06:05:23 simonb Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -126,7 +126,7 @@ int ieee_handler_disable = 0; #define __CDECL__ #endif -void trap __P((struct trapframe)) __CDECL__; +void trap(struct trapframe) __CDECL__; const char *trap_type[] = { "non-vectored interrupt", /* 0 T_NVI */ @@ -449,9 +449,9 @@ trap(struct trapframe frame) break; } - case T_TRC | T_USER: /* trace trap */ - case T_BPT | T_USER: /* breakpoint instruction */ - case T_DBG | T_USER: /* debug trap */ + case T_TRC | T_USER: /* trace trap */ + case T_BPT | T_USER: /* breakpoint instruction */ + case T_DBG | T_USER: /* debug trap */ trace: KSI_INIT_TRAP(&ksi); ksi.ksi_signo = SIGTRAP; diff --git a/sys/arch/pc532/pc532/umprintf.c b/sys/arch/pc532/pc532/umprintf.c index 3e5d82ce872..ab8d14197bb 100644 --- a/sys/arch/pc532/pc532/umprintf.c +++ b/sys/arch/pc532/pc532/umprintf.c @@ -1,4 +1,4 @@ -/* $NetBSD: umprintf.c,v 1.8 2005/12/11 12:18:31 christos Exp $ */ +/* $NetBSD: umprintf.c,v 1.9 2006/05/12 06:05:23 simonb Exp $ */ /*- * Copyright (c) 1986, 1988, 1991 The Regents of the University of California. @@ -33,10 +33,10 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: umprintf.c,v 1.8 2005/12/11 12:18:31 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: umprintf.c,v 1.9 2006/05/12 06:05:23 simonb Exp $"); #include <machine/stdarg.h> -static char *ksprintn __P((u_long num, int base, int *len)); +static char *ksprintn(u_long num, int base, int *len); void umprintf(char *fmt,...) @@ -84,12 +84,10 @@ number: p = ksprintn(ul, base, &tmp); * buffer. */ static char * -ksprintn(ul, base, lenp) - register u_long ul; - register int base, *lenp; +ksprintn(u_long ul, int base, int *lenp) { /* A long in base 8, plus NULL. */ static char buf[sizeof(long) * NBBY / 3 + 2]; - register char *p; + char *p; int d; p = buf; diff --git a/sys/arch/pc532/pc532/vm_machdep.c b/sys/arch/pc532/pc532/vm_machdep.c index 4fc87f05da1..622c76dda12 100644 --- a/sys/arch/pc532/pc532/vm_machdep.c +++ b/sys/arch/pc532/pc532/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.65 2005/12/11 12:18:31 christos Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.66 2006/05/12 06:05:23 simonb Exp $ */ /*- * Copyright (c) 1982, 1986 The Regents of the University of California. @@ -78,7 +78,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.65 2005/12/11 12:18:31 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.66 2006/05/12 06:05:23 simonb Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -98,7 +98,7 @@ __KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.65 2005/12/11 12:18:31 christos Exp extern struct lwp *fpu_lwp; -void setredzone __P((u_short *, caddr_t)); +void setredzone(u_short *, caddr_t); /* * Finish a fork operation, with process p2 nearly set up. @@ -119,12 +119,8 @@ void setredzone __P((u_short *, caddr_t)); * accordingly. */ void -cpu_lwp_fork(l1, l2, stack, stacksize, func, arg) - struct lwp *l1, *l2; - void *stack; - size_t stacksize; - void (*func) __P((void *)); - void *arg; +cpu_lwp_fork(struct lwp *l1, struct lwp *l2, void *stack, size_t stacksize, + void (*func)(void *), void *arg) { struct pcb *pcb = &l2->l_addr->u_pcb; struct syscframe *tf; @@ -171,10 +167,7 @@ cpu_lwp_fork(l1, l2, stack, stacksize, func, arg) } void -cpu_setfunc(l, func, arg) - struct lwp *l; - void (*func) __P((void *)); - void *arg; +cpu_setfunc(struct lwp *l, void (*func)(void *), void *arg) { struct pcb *pcb = &l->l_addr->u_pcb; struct syscframe *tf; @@ -200,9 +193,9 @@ cpu_setfunc(l, func, arg) * saved, so that it goes out with the pcb, which is in the user area. */ void -cpu_swapout(l) - struct lwp *l; +cpu_swapout(struct lwp *l) { + /* * Make sure we save the FP state before the user area vanishes. */ @@ -229,8 +222,7 @@ cpu_lwp_free(struct lwp *l, int proc) * jumps into switch() to wait for another process to wake up. */ void -cpu_exit(arg) - struct lwp *arg; +cpu_exit(struct lwp *arg) { extern struct user *proc0paddr; register struct lwp *l __asm("r3"); @@ -303,18 +295,19 @@ cpu_coredump(struct lwp *l, void *iocookie, struct core *chdr) /* * Set a red zone in the kernel stack after the u. area. */ -setredzone(pte, vaddr) - u_short *pte; - caddr_t vaddr; +setredzone(u_short *pte, caddr_t vaddr) { -/* eventually do this by setting up an expand-down stack segment - for ss0: selector, allowing stack access down to top of u. - this means though that protection violations need to be handled - thru a double fault exception that must do an integral task - switch to a known good context, within which a dump can be - taken. a sensible scheme might be to save the initial context - used by sched (that has physical memory mapped 1:1 at bottom) - and take the dump while still in mapped mode */ + +/* + * eventually do this by setting up an expand-down stack segment + * for ss0: selector, allowing stack access down to top of u. + * this means though that protection violations need to be handled + * thru a double fault exception that must do an integral task + * switch to a known good context, within which a dump can be + * taken. a sensible scheme might be to save the initial context + * used by sched (that has physical memory mapped 1:1 at bottom) + * and take the dump while still in mapped mode. + */ } #endif @@ -322,8 +315,7 @@ setredzone(pte, vaddr) * Convert kernel VA to physical address */ int -kvtop(addr) - register caddr_t addr; +kvtop(caddr_t addr) { paddr_t pa; @@ -338,9 +330,7 @@ kvtop(addr) * do not need to pass an access_type to pmap_enter(). */ void -vmapbuf(bp, len) - struct buf *bp; - vsize_t len; +vmapbuf(struct buf *bp, vsize_t len) { vaddr_t faddr, taddr, off; paddr_t fpa; @@ -379,9 +369,7 @@ vmapbuf(bp, len) * Unmap a previously-mapped user I/O request. */ void -vunmapbuf(bp, len) - struct buf *bp; - vsize_t len; +vunmapbuf(struct buf *bp, vsize_t len) { vaddr_t addr, off; diff --git a/sys/arch/pc532/stand/common/devopen.c b/sys/arch/pc532/stand/common/devopen.c index aca2e8e5556..13724d60f4e 100644 --- a/sys/arch/pc532/stand/common/devopen.c +++ b/sys/arch/pc532/stand/common/devopen.c @@ -1,4 +1,4 @@ -/* $NetBSD: devopen.c,v 1.4 2005/12/11 12:18:34 christos Exp $ */ +/* $NetBSD: devopen.c,v 1.5 2006/05/12 06:05:23 simonb Exp $ */ /*- * Copyright (c) 1993 John Brezak @@ -37,7 +37,7 @@ #include <pc532/stand/common/samachdep.h> static int atoi(const char *); -static void usage(void); +static void usage(void); static int devlookup(const char *, int); static int devparse(const char *, int *, int *, int *, int *, int *, char **); @@ -188,7 +188,8 @@ devopen(struct open_file *f, const char *fname, char **file) unit = B_UNIT(bootdev); part = B_PARTITION(bootdev); - if ((error = devparse(fname, &dev, &adapt, &ctlr, &unit, &part, file)) != 0) + if ((error = devparse(fname, &dev, &adapt, &ctlr, &unit, &part, file)) + != 0) return(error); dp = &devsw[dev]; diff --git a/sys/arch/pc532/stand/common/scsi_hi.c b/sys/arch/pc532/stand/common/scsi_hi.c index e6588da4e83..ce07fd95018 100644 --- a/sys/arch/pc532/stand/common/scsi_hi.c +++ b/sys/arch/pc532/stand/common/scsi_hi.c @@ -1,4 +1,4 @@ -/* $NetBSD: scsi_hi.c,v 1.4 2005/12/11 12:18:34 christos Exp $ */ +/* $NetBSD: scsi_hi.c,v 1.5 2006/05/12 06:05:23 simonb Exp $ */ /**************************************************************************** * NS32K Monitor SCSI high-level driver @@ -11,7 +11,7 @@ #include <pc532/stand/common/so.h> -#define OK 0 +#define OK 0 #define NOT_OK OK+1 #define PRIVATE #define PUBLIC @@ -44,7 +44,7 @@ PRIVATE struct drive drive_tbl[] = { * of four bytes. */ #define CMD_LEN 12 /* longest SCSI command */ -#define SENSE_LEN 24 /* extended sense length */ +#define SENSE_LEN 24 /* extended sense length */ #define MSG_LEN 4 #define STAT_LEN 4 diff --git a/sys/arch/pc532/stand/common/scsi_low.c b/sys/arch/pc532/stand/common/scsi_low.c index accd9d4bf66..a012438a5c4 100644 --- a/sys/arch/pc532/stand/common/scsi_low.c +++ b/sys/arch/pc532/stand/common/scsi_low.c @@ -1,4 +1,4 @@ -/* $NetBSD: scsi_low.c,v 1.5 2005/12/11 12:18:34 christos Exp $ */ +/* $NetBSD: scsi_low.c,v 1.6 2006/05/12 06:05:23 simonb Exp $ */ /**************************************************************************** * NS32K Monitor SCSI low-level driver @@ -19,7 +19,7 @@ #include <pc532/stand/common/so.h> -#define OK 0 +#define OK 0 #define NOT_OK OK+1 #define PRIVATE #define PUBLIC @@ -446,6 +446,7 @@ sc_receive(void) void scCtlrSelect(int ctlr) { + RD_ADR(ICU_IO) &= ~ICU_SCSI_BIT; /* i/o, not port */ RD_ADR(ICU_DIR) &= ~ICU_SCSI_BIT; /* output */ if (ctlr == DP8490) diff --git a/sys/arch/pc532/stand/common/sd.c b/sys/arch/pc532/stand/common/sd.c index b0da5f416dd..97c3515e4a2 100644 --- a/sys/arch/pc532/stand/common/sd.c +++ b/sys/arch/pc532/stand/common/sd.c @@ -1,4 +1,4 @@ -/* $NetBSD: sd.c,v 1.6 2005/12/11 12:18:34 christos Exp $ */ +/* $NetBSD: sd.c,v 1.7 2006/05/12 06:05:23 simonb Exp $ */ /* * Copyright (c) 1990, 1993 @@ -115,8 +115,9 @@ sdinit(int ctlr, int unit) { struct sd_softc *ss = &sd_softc[ctlr][unit]; - /* HP version does test_unit_ready - * followed by read_capacity to get blocksize + /* + * HP version does test_unit_ready + * followed by read_capacity to get blocksize */ ss->sc_alive = 1; return (1); |
