diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1995-12-14 05:29:32 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1995-12-14 05:29:32 +0000 |
commit | 86b4fdd623d3c50d7bfd9427c2c9208454cd0da7 (patch) | |
tree | 5d95abcaf58d01703a30c7ab600537d3b8f67989 | |
parent | e2cd6c399798843e13e76f49dc8ee048b51f99f1 (diff) |
update from netbsd (verbatim)
167 files changed, 4127 insertions, 5666 deletions
diff --git a/sys/arch/atari/atari/conf.c b/sys/arch/atari/atari/conf.c index 3bc26be7f7a..6147c2b0798 100644 --- a/sys/arch/atari/atari/conf.c +++ b/sys/arch/atari/atari/conf.c @@ -1,4 +1,4 @@ -/* $NetBSD: conf.c,v 1.10.2.1 1995/10/12 08:18:59 leo Exp $ */ +/* $NetBSD: conf.c,v 1.11 1995/11/30 00:57:33 jtc Exp $ */ /* * Copyright (c) 1991 The Regents of the University of California. diff --git a/sys/arch/atari/atari/disksubr.c b/sys/arch/atari/atari/disksubr.c index 7a771c59192..f7f3cc9c4f9 100644 --- a/sys/arch/atari/atari/disksubr.c +++ b/sys/arch/atari/atari/disksubr.c @@ -1,4 +1,4 @@ -/* $NetBSD: disksubr.c,v 1.3.2.3 1995/11/21 11:30:22 leo Exp $ */ +/* $NetBSD: disksubr.c,v 1.5 1995/11/30 00:57:35 jtc Exp $ */ /* * Copyright (c) 1995 Leo Weppelman. diff --git a/sys/arch/atari/atari/locore.s b/sys/arch/atari/atari/locore.s index 77755e866ae..f7d598cfe74 100644 --- a/sys/arch/atari/atari/locore.s +++ b/sys/arch/atari/atari/locore.s @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.9.2.2 1995/10/21 13:04:54 leo Exp $ */ +/* $NetBSD: locore.s,v 1.12 1995/12/11 02:38:01 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -498,7 +498,6 @@ _spurintr: jra rei /* MFP timer A handler --- System clock --- */ - /* Note: Reduce by factor 4 before handling */ mfp_tima: moveml d0-d1/a0-a1,sp@- | save scratch registers lea sp@(16),a1 | get pointer to PS @@ -509,7 +508,21 @@ mfp_tima: moveml sp@+,d0-d1/a0-a1 | restore scratch regs addql #1,_cnt+V_INTR | chalk up another interrupt jra rei | all done - + +#ifdef STATCLOCK + /* MFP timer C handler --- Stat/Prof clock --- */ +mfp_timc: + moveml d0-d1/a0-a1,sp@- | save scratch registers + lea sp@(16),a1 | get pointer to PS + movl a1,sp@- | push pointer to PS, PC + jbsr _statintr | call statistics clock handler + addql #4,sp | pop params + addql #1,_intrcnt+36 | add another stat clock interrupt + moveml sp@+,d0-d1/a0-a1 | restore scratch regs + addql #1,_cnt+V_INTR | chalk up another interrupt + jra rei | all done +#endif /* STATCLOCK */ + /* MFP ACIA handler --- keyboard/midi --- */ mfp_kbd: addql #1,_intrcnt+8 | add another kbd/mouse interrupt @@ -1746,83 +1759,6 @@ ENTRY(_remque) rts /* - * {ov}bcopy(from, to, len) - * memcpy(to, from, len) - * - * Works for counts up to 128K. - */ -ENTRY(memcpy) - movl sp@(12),d0 | get count - jeq Lcpyexit | if zero, return - movl sp@(8),a0 | src address - movl sp@(4),a1 | dest address - jra Ldocopy - -ALTENTRY(ovbcopy, _bcopy) -ENTRY(bcopy) - movl sp@(12),d0 | get count - jeq Lcpyexit | if zero, return - movl sp@(4),a0 | src address - movl sp@(8),a1 | dest address -Ldocopy: - cmpl a1,a0 | src before dest? - jlt Lcpyback | yes, copy backwards (avoids overlap) - movl a0,d1 - btst #0,d1 | src address odd? - jeq Lcfeven | no, go check dest - movb a0@+,a1@+ | yes, copy a byte - subql #1,d0 | update count - jeq Lcpyexit | exit if done -Lcfeven: - movl a1,d1 - btst #0,d1 | dest address odd? - jne Lcfbyte | yes, must copy by bytes - movl d0,d1 | no, get count - lsrl #2,d1 | convert to longwords - jeq Lcfbyte | no longwords, copy bytes - subql #1,d1 | set up for dbf -Lcflloop: - movl a0@+,a1@+ | copy longwords - dbf d1,Lcflloop | til done - andl #3,d0 | get remaining count - jeq Lcpyexit | done if none -Lcfbyte: - subql #1,d0 | set up for dbf -Lcfbloop: - movb a0@+,a1@+ | copy bytes - dbf d0,Lcfbloop | til done -Lcpyexit: - rts -Lcpyback: - addl d0,a0 | add count to src - addl d0,a1 | add count to dest - movl a0,d1 - btst #0,d1 | src address odd? - jeq Lcbeven | no, go check dest - movb a0@-,a1@- | yes, copy a byte - subql #1,d0 | update count - jeq Lcpyexit | exit if done -Lcbeven: - movl a1,d1 - btst #0,d1 | dest address odd? - jne Lcbbyte | yes, must copy by bytes - movl d0,d1 | no, get count - lsrl #2,d1 | convert to longwords - jeq Lcbbyte | no longwords, copy bytes - subql #1,d1 | set up for dbf -Lcblloop: - movl a0@-,a1@- | copy longwords - dbf d1,Lcblloop | til done - andl #3,d0 | get remaining count - jeq Lcpyexit | done if none -Lcbbyte: - subql #1,d0 | set up for dbf -Lcbbloop: - movb a0@-,a1@- | copy bytes - dbf d0,Lcbbloop | til done - rts - -/* * Save and restore 68881 state. * Pretty awful looking since our assembler does not * recognize FP mnemonics. @@ -1947,8 +1883,9 @@ _intrnames: .asciz "5380-DMA" .asciz "nmi" .asciz "8530-SCC" + .asciz "statclock" _eintrnames: .even _intrcnt: - .long 0,0,0,0,0,0,0,0,0 + .long 0,0,0,0,0,0,0,0,0,0 _eintrcnt: diff --git a/sys/arch/atari/atari/pmap.c b/sys/arch/atari/atari/pmap.c index 9bbc8b36d9b..ca2eb527895 100644 --- a/sys/arch/atari/atari/pmap.c +++ b/sys/arch/atari/atari/pmap.c @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.6.2.1 1995/10/12 08:16:07 leo Exp $ */ +/* $NetBSD: pmap.c,v 1.7 1995/11/30 00:57:39 jtc Exp $ */ /* * Copyright (c) 1991 Regents of the University of California. diff --git a/sys/arch/atari/atari/swapgeneric.c b/sys/arch/atari/atari/swapgeneric.c index 42bd4b6d5b3..5ed756f32d0 100644 --- a/sys/arch/atari/atari/swapgeneric.c +++ b/sys/arch/atari/atari/swapgeneric.c @@ -1,4 +1,4 @@ -/* $NetBSD: swapgeneric.c,v 1.1.1.1 1995/03/26 07:12:19 leo Exp $ */ +/* $NetBSD: swapgeneric.c,v 1.2 1995/11/30 21:55:01 leo Exp $ */ /* * Copyright (c) 1995 Leo Weppelman @@ -123,23 +123,23 @@ char *bp; printf("format: <dev-name><unit> [ ':'<part> ] [ * ]\n"); printf("root device> "); gets(bp); - for(gc = genericconf; gc->gc_driver; gc++) - if(gc->gc_driver->cd_name[0] == bp[0] && + for (gc = genericconf; gc->gc_driver; gc++) + if (gc->gc_driver->cd_name[0] == bp[0] && gc->gc_driver->cd_name[1] == bp[1]) break; - if(gc->gc_driver == NULL) { + if (gc->gc_driver == NULL) { printf("use one of:"); - for(gc = genericconf; gc->gc_driver; gc++) + for (gc = genericconf; gc->gc_driver; gc++) printf(" %s%%d", gc->gc_driver->cd_name); printf("\n"); continue; } cp = bp + 2; - if(*cp >= '0' && *cp <= '9') + if (*cp >= '0' && *cp <= '9') break; printf("bad/missing unit number\n"); } - return(gc); + return (gc); } setconf() @@ -153,17 +153,17 @@ setconf() part = 0; unit = 0; - if(rootdev != NODEV) + if (rootdev != NODEV) goto justdoswap; - if(boothowto & RB_ASKNAME) { + if (boothowto & RB_ASKNAME) { gc = getgenconf(name); cp = name + 2; /* * Get unit number */ - while(*cp >= '0' && *cp <= '9') + while (*cp >= '0' && *cp <= '9') unit = 10 * unit + *cp++ - '0'; /* @@ -171,20 +171,20 @@ setconf() * This is only usefull when booting from floppy. So it is * possible to select the correct density. */ - if(*cp == ':') { + if (*cp == ':') { cp++; - while(*cp >= '0' && *cp <= '9') + while (*cp >= '0' && *cp <= '9') part = 10 * part + *cp++ - '0'; } - if(*cp == '*') + if (*cp == '*') swaponroot = 1; unit &= 0x7; } else { gc = guess_gc(1, &unit); - if(gc == NULL) { + if (gc == NULL) { printf("no suitable root\n"); asm("stop #0x2700"); } @@ -196,9 +196,9 @@ setconf() justdoswap: - if(!swaponroot) { + if (!swaponroot) { /* Find a suitable swap device */ - if((gc = guess_gc(0, &unit)) == NULL) { + if ((gc = guess_gc(0, &unit)) == NULL) { swdevt[0].sw_dev = dumpdev = MAKEDISKDEV(major(rootdev),DISKUNIT(rootdev),1); } @@ -261,11 +261,11 @@ int *rv_unit; struct partition *pp; struct dkdevice *dkp; struct bdevsw *bdp; - int unit; + int unit; - for(gc = genericconf; gc->gc_driver; gc++) { - for(unit = 0; unit < gc->gc_driver->cd_ndevs; unit++) { - if(gc->gc_driver->cd_devs[unit] == NULL) + for (gc = genericconf; gc->gc_driver; gc++) { + for (unit = 0; unit < gc->gc_driver->cd_ndevs; unit++) { + if (gc->gc_driver->cd_devs[unit] == NULL) continue; /* * this is a hack these drivers should use @@ -273,31 +273,31 @@ int *rv_unit; */ dkp = (struct dkdevice *) ((struct device *)gc->gc_driver->cd_devs[unit] + 1); - if(dkp->dk_driver == NULL || dkp->dk_driver->d_strategy == NULL) + if (dkp->dk_driver==NULL || dkp->dk_driver->d_strategy==NULL) continue; - for(bdp = bdevsw; bdp < (bdevsw + nblkdev); bdp++) - if(bdp->d_strategy == dkp->dk_driver->d_strategy) + for (bdp = bdevsw; bdp < (bdevsw + nblkdev); bdp++) + if (bdp->d_strategy == dkp->dk_driver->d_strategy) break; - if(bdp->d_open(MAKEDISKDEV(major(gc->gc_root), + if (bdp->d_open(MAKEDISKDEV(major(gc->gc_root), unit, 3), FREAD | FNONBLOCK, 0, curproc)) continue; bdp->d_close(MAKEDISKDEV(major(gc->gc_root), unit, 3), FREAD | FNONBLOCK, 0, curproc); - if(search_root) { + if (search_root) { pp = &dkp->dk_label.d_partitions[0]; - if(pp->p_size == 0 || pp->p_fstype != FS_BSDFFS) + if (pp->p_size == 0 || pp->p_fstype != FS_BSDFFS) continue; } else { /* must be swap */ pp = &dkp->dk_label.d_partitions[1]; - if(pp->p_size == 0 || pp->p_fstype != FS_SWAP) + if (pp->p_size == 0 || pp->p_fstype != FS_SWAP) continue; } goto found; } } - return(NULL); + return (NULL); found: *rv_unit = unit; - return(gc); + return (gc); } diff --git a/sys/arch/atari/atari/sys_machdep.c b/sys/arch/atari/atari/sys_machdep.c index 33b6aa377b5..c0e49eebb19 100644 --- a/sys/arch/atari/atari/sys_machdep.c +++ b/sys/arch/atari/atari/sys_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: sys_machdep.c,v 1.2.2.1 1995/10/12 08:18:09 leo Exp $ */ +/* $NetBSD: sys_machdep.c,v 1.4 1995/12/03 14:34:24 leo Exp $ */ /* * Copyright (c) 1982, 1986 Regents of the University of California. @@ -55,12 +55,12 @@ #ifdef TRACE int nvualarm; -vtrace(p, v, retval) +sys_vtrace(p, v, retval) struct proc *p; void *v; register_t *retval; { - register struct vtrace_args /* { + register struct sys_vtrace_args /* { syscallarg(int) request; syscallarg(int) value; } */ *uap = v; @@ -276,7 +276,7 @@ sys_sysarch(p, v, retval) void *v; register_t *retval; { - struct sysarch_args /* { + struct sys_sysarch_args /* { syscallarg(int) op; syscallarg(char*)parms; } */ *uap = v; diff --git a/sys/arch/atari/atari/trap.c b/sys/arch/atari/atari/trap.c index 201fbfaab1a..9ccb593926c 100644 --- a/sys/arch/atari/atari/trap.c +++ b/sys/arch/atari/atari/trap.c @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.9.2.3 1995/10/23 07:50:11 leo Exp $ */ +/* $NetBSD: trap.c,v 1.10 1995/11/30 00:57:42 jtc Exp $ */ /* * Copyright (c) 1988 University of Utah. diff --git a/sys/arch/atari/atari/vectors.s b/sys/arch/atari/atari/vectors.s index e7b81a13701..8543bd510f0 100644 --- a/sys/arch/atari/atari/vectors.s +++ b/sys/arch/atari/atari/vectors.s @@ -1,4 +1,4 @@ -/* $NetBSD: vectors.s,v 1.2 1995/05/05 16:30:35 leo Exp $ */ +/* $NetBSD: vectors.s,v 1.3 1995/11/30 21:52:50 leo Exp $ */ /* * Copyright (c) 1988 University of Utah @@ -133,7 +133,11 @@ Lvectab: .long _badmfpint | 66: modem port 1 - CTS .long _badmfpint | 67: unassigned .long _badmfpint | 68: modem port 1 baudgen (Timer D) +#ifdef STATCLOCK + .long mfp_timc | 69: Timer C {stat,prof}clock +#else .long _badmfpint | 69: Timer C +#endif /* STATCLOCK */ .long mfp_kbd | 70: KBD/MIDI IRQ .long mfp_fd_acsi | 71: FDC/ACSI DMA .long _badmfpint | 72: Display enable counter diff --git a/sys/arch/atari/atari/vm_machdep.c b/sys/arch/atari/atari/vm_machdep.c index ad17df208ae..70955e43434 100644 --- a/sys/arch/atari/atari/vm_machdep.c +++ b/sys/arch/atari/atari/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.3 1995/05/14 19:09:10 leo Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.4 1995/12/09 04:37:34 mycroft Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -68,6 +68,7 @@ * address in each process; in the future we will probably relocate * the frame pointers on the stack after copying. */ +void cpu_fork(p1, p2) register struct proc *p1, *p2; { @@ -95,8 +96,6 @@ cpu_fork(p1, p2) pcb->pcb_regs[6] = (int)child_return; /* A2 */ pcb->pcb_regs[7] = (int)p2; /* A3 */ pcb->pcb_regs[11] = (int)sf; /* SSP */ - - return (0); } /* diff --git a/sys/arch/atari/conf/ATARITT b/sys/arch/atari/conf/ATARITT index 95345459d2b..ac46604ffb0 100644 --- a/sys/arch/atari/conf/ATARITT +++ b/sys/arch/atari/conf/ATARITT @@ -1,5 +1,5 @@ # -# $NetBSD: ATARITT,v 1.6.2.1 1995/11/15 21:55:59 leo Exp $ +# $NetBSD: ATARITT,v 1.7 1995/11/30 00:57:44 jtc Exp $ # # ATARI-TT # diff --git a/sys/arch/atari/conf/BOOT b/sys/arch/atari/conf/BOOT index 91a9d6f7177..aad736bbbe1 100644 --- a/sys/arch/atari/conf/BOOT +++ b/sys/arch/atari/conf/BOOT @@ -1,5 +1,5 @@ # -# $NetBSD: BOOT,v 1.4.2.1 1995/11/15 21:56:03 leo Exp $ +# $NetBSD: BOOT,v 1.5 1995/11/30 00:57:46 jtc Exp $ # # BOOT # diff --git a/sys/arch/atari/conf/FALCON b/sys/arch/atari/conf/FALCON index dfbe1aba1ec..b7946954a6e 100644 --- a/sys/arch/atari/conf/FALCON +++ b/sys/arch/atari/conf/FALCON @@ -1,5 +1,5 @@ # -# $NetBSD: FALCON,v 1.3.2.1 1995/11/15 21:56:06 leo Exp $ +# $NetBSD: FALCON,v 1.4 1995/11/30 00:57:48 jtc Exp $ # # ATARI-FALCON # diff --git a/sys/arch/atari/conf/GENERIC b/sys/arch/atari/conf/GENERIC index ee274f8f438..fa8d92b6785 100644 --- a/sys/arch/atari/conf/GENERIC +++ b/sys/arch/atari/conf/GENERIC @@ -1,5 +1,5 @@ # -# $NetBSD: GENERIC,v 1.7.2.3 1995/11/15 21:56:08 leo Exp $ +# $NetBSD: GENERIC,v 1.9 1995/11/30 21:53:07 leo Exp $ # # Generic atari # @@ -90,6 +90,7 @@ options TT_SCSI # SCSI-support for TT options FALCON_SCSI # SCSI-support for Falcon options TT_VIDEO # Graphics support for TT options FALCON_VIDEO # Graphics support for FALCON +options STATCLOCK # Separate {stat,prof}clock # # Build one kernel that can boot from any disk. diff --git a/sys/arch/atari/conf/Makefile.atari b/sys/arch/atari/conf/Makefile.atari index 9d3dac3c37e..a790c68344b 100644 --- a/sys/arch/atari/conf/Makefile.atari +++ b/sys/arch/atari/conf/Makefile.atari @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.atari,v 1.7.2.1 1995/10/22 21:12:22 leo Exp $ +# $NetBSD: Makefile.atari,v 1.8 1995/11/30 00:57:51 jtc Exp $ # # Makefile for NetBSD Atari-TT # diff --git a/sys/arch/atari/conf/files.atari b/sys/arch/atari/conf/files.atari index 42545450be3..00716d0231c 100644 --- a/sys/arch/atari/conf/files.atari +++ b/sys/arch/atari/conf/files.atari @@ -1,5 +1,5 @@ # -# $NetBSD: files.atari,v 1.12 1995/08/28 19:31:16 leo Exp $ +# $NetBSD: files.atari,v 1.13 1995/12/01 19:53:07 leo Exp $ # maxpartitions 16 @@ -109,7 +109,7 @@ file arch/m68k/m68k/copy.s # Emulation modules # 6888x emulator (FPU_EMULATE) -file arch/m68k/fpe/fpu_emulate.c fpu_emulate +include "../../m68k/fpe/files.fpe" # Compatibility modules diff --git a/sys/arch/atari/dev/clock.c b/sys/arch/atari/dev/clock.c index c1471e4dc8d..aee79a46bfd 100644 --- a/sys/arch/atari/dev/clock.c +++ b/sys/arch/atari/dev/clock.c @@ -1,4 +1,4 @@ -/* $NetBSD: clock.c,v 1.4 1995/09/23 20:23:28 leo Exp $ */ +/* $NetBSD: clock.c,v 1.6 1995/12/01 19:51:53 leo Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -56,20 +56,19 @@ #endif /* + * The MFP clock runs at 2457600Hz. We use a {system,stat,prof}clock divider + * of 200. Therefore the timer runs at an effective rate of: + * 2457600/200 = 12288Hz. + */ +#define CLOCK_HZ 12288 + +/* * Machine-dependent clock routines. * - * Startrtclock restarts the real-time clock, which provides - * hardclock interrupts to kern_clock.c. - * * Inittodr initializes the time of day hardware which provides * date functions. * * Resettodr restores the time of day hardware after a time change. - * - * A note on the real-time clock: - * We actually load the clock with CLK_INTERVAL-1 instead of CLK_INTERVAL. - * This is because the counter decrements to zero after N+1 enabled clock - * periods where N is the value loaded into the counter. */ int clockmatch __P((struct device *, struct cfdata *, void *)); @@ -83,7 +82,22 @@ struct cfdriver clockcd = { static u_long gettod __P((void)); static int settod __P((u_long)); -static int divisor; +static int divisor; /* Systemclock divisor */ + +/* + * Statistics and profile clock intervals and variances. Variance must + * be a power of 2. Since this gives us an even number, not an odd number, + * we discard one case and compensate. That is, a variance of 64 would + * give us offsets in [0..63]. Instead, we take offsets in [1..63]. + * This is symetric around the point 32, or statvar/2, and thus averages + * to that value (assuming uniform random numbers). + */ +#ifdef STATCLOCK +static int statvar = 32; /* {stat,prof}clock variance */ +static int statmin; /* statclock divisor - variance/2 */ +static int profmin; /* profclock divisor - variance/2 */ +static int clk2min; /* current, from above choises */ +#endif int clockmatch(pdp, cfp, auxp) @@ -109,13 +123,33 @@ void *auxp; * at an effective rate of: 2457600/200 = 12288Hz. The * following expression works for 48, 64 or 96 hz. */ - divisor = 12288/hz; + divisor = CLOCK_HZ/hz; MFP->mf_tacr = 0; /* Stop timer */ MFP->mf_iera &= ~IA_TIMA; /* Disable timer interrupts */ MFP->mf_tadr = divisor; /* Set divisor */ + if (hz != 48 && hz != 64 && hz != 96) { /* XXX */ + printf (": illegal value %d for systemclock, reset to %d\n\t", + hz, 64); + hz = 64; + } printf(": system hz %d timer-A divisor 200/%d\n", hz, divisor); +#ifdef STATCLOCK + if ((stathz == 0) || (stathz > hz) || (CLOCK_HZ % stathz)) + stathz = hz; + if ((profhz == 0) || (profhz > (hz << 1)) || (CLOCK_HZ % profhz)) + profhz = hz << 1; + + MFP->mf_tcdcr &= 0x7; /* Stop timer */ + MFP->mf_ierb &= ~IB_TIMC; /* Disable timer inter. */ + MFP->mf_tcdr = CLOCK_HZ/stathz; /* Set divisor */ + + statmin = (CLOCK_HZ/stathz) - (statvar >> 1); + profmin = (CLOCK_HZ/profhz) - (statvar >> 1); + clk2min = statmin; +#endif /* STATCLOCK */ + /* * Initialize Timer-B in the ST-MFP. This timer is used by the 'delay' * function below. This time is setup to be continueously counting from @@ -134,13 +168,50 @@ void cpu_initclocks() MFP->mf_ipra &= ~IA_TIMA; /* Clear pending interrupts */ MFP->mf_iera |= IA_TIMA; /* Enable timer interrupts */ MFP->mf_imra |= IA_TIMA; /* ..... */ + +#ifdef STATCLOCK + MFP->mf_tcdcr = (MFP->mf_tcdcr & 0x7) | (T_Q200<<4); /* Start */ + MFP->mf_iprb &= ~IB_TIMC; /* Clear pending interrupts */ + MFP->mf_ierb |= IB_TIMC; /* Enable timer interrupts */ + MFP->mf_imrb |= IB_TIMC; /* ..... */ +#endif /* STATCLOCK */ } -setstatclockrate(hz) - int hz; +setstatclockrate(newhz) + int newhz; { +#ifdef STATCLOCK + if (newhz == stathz) + clk2min = statmin; + else clk2min = profmin; +#endif /* STATCLOCK */ } +#ifdef STATCLOCK +void +statintr(frame) + register struct clockframe *frame; +{ + register int var, r; + + var = statvar - 1; + do { + r = random() & var; + } while(r == 0); + + /* + * Note that we are always lagging behind as the new divisor + * value will not be loaded until the next interrupt. This + * shouldn't disturb the median frequency (I think ;-) ) as + * only the value used when switching frequencies is used + * twice. This shouldn't happen very often. + */ + MFP->mf_tcdr = clk2min + r; + + statclock(frame); +} +#endif /* STATCLOCK */ + /* * Returns number of usec since last recorded clock "tick" * (i.e. clock interrupt). @@ -203,97 +274,6 @@ int n; } } -#ifdef PROFTIMER -/* - * This code allows the amiga kernel to use one of the extra timers on - * the clock chip for profiling, instead of the regular system timer. - * The advantage of this is that the profiling timer can be turned up to - * a higher interrupt rate, giving finer resolution timing. The profclock - * routine is called from the lev6intr in locore, and is a specialized - * routine that calls addupc. The overhead then is far less than if - * hardclock/softclock was called. Further, the context switch code in - * locore has been changed to turn the profile clock on/off when switching - * into/out of a process that is profiling (startprofclock/stopprofclock). - * This reduces the impact of the profiling clock on other users, and might - * possibly increase the accuracy of the profiling. - */ -int profint = PRF_INTERVAL; /* Clock ticks between interrupts */ -int profscale = 0; /* Scale factor from sys clock to prof clock */ -char profon = 0; /* Is profiling clock on? */ - -/* profon values - do not change, locore.s assumes these values */ -#define PRF_NONE 0x00 -#define PRF_USER 0x01 -#define PRF_KERNEL 0x80 - -initprofclock() -{ -#if NCLOCK > 0 - struct proc *p = curproc; /* XXX */ - - /* - * If the high-res timer is running, force profiling off. - * Unfortunately, this gets reflected back to the user not as - * an error but as a lack of results. - */ - if (clockon) { - p->p_stats->p_prof.pr_scale = 0; - return; - } - /* - * Keep track of the number of user processes that are profiling - * by checking the scale value. - * - * XXX: this all assumes that the profiling code is well behaved; - * i.e. profil() is called once per process with pcscale non-zero - * to turn it on, and once with pcscale zero to turn it off. - * Also assumes you don't do any forks or execs. Oh well, there - * is always adb... - */ - if (p->p_stats->p_prof.pr_scale) - profprocs++; - else - profprocs--; -#endif - /* - * The profile interrupt interval must be an even divisor - * of the CLK_INTERVAL so that scaling from a system clock - * tick to a profile clock tick is possible using integer math. - */ - if (profint > CLK_INTERVAL || (CLK_INTERVAL % profint) != 0) - profint = CLK_INTERVAL; - profscale = CLK_INTERVAL / profint; -} - -startprofclock() -{ - unsigned short interval; - - /* stop timer B */ - ciab.crb = ciab.crb & 0xc0; - - /* load interval into registers. - the clocks run at NTSC: 715.909kHz or PAL: 709.379kHz */ - - interval = profint - 1; - - /* order of setting is important ! */ - ciab.tblo = interval & 0xff; - ciab.tbhi = interval >> 8; - - /* enable interrupts for timer B */ - ciab.icr = (1<<7) | (1<<1); - - /* start timer B in continuous shot mode */ - ciab.crb = (ciab.crb & 0xc0) | 1; -} - -stopprofclock() -{ - /* stop timer B */ - ciab.crb = ciab.crb & 0xc0; -} - #ifdef GPROF /* * profclock() is expanded in line in lev6intr() unless profiling kernel. @@ -333,7 +313,6 @@ profclock(pc, ps) } } #endif -#endif /* * Initialize the time of day register, based on the time base which is, e.g. diff --git a/sys/arch/atari/dev/dma.c b/sys/arch/atari/dev/dma.c index 70bbf10a7cd..decad0ce889 100644 --- a/sys/arch/atari/dev/dma.c +++ b/sys/arch/atari/dev/dma.c @@ -1,4 +1,4 @@ -/* $NetBSD: dma.c,v 1.4.2.1 1995/11/06 21:51:12 leo Exp $ */ +/* $NetBSD: dma.c,v 1.5 1995/11/06 21:13:38 leo Exp $ */ /* * Copyright (c) 1995 Leo Weppelman. diff --git a/sys/arch/atari/dev/fd.c b/sys/arch/atari/dev/fd.c index 586e0b2f53a..8a7369e89da 100644 --- a/sys/arch/atari/dev/fd.c +++ b/sys/arch/atari/dev/fd.c @@ -1,4 +1,4 @@ -/* $NetBSD: fd.c,v 1.10.2.1 1995/10/14 20:19:41 leo Exp $ */ +/* $NetBSD: fd.c,v 1.12 1995/12/10 14:25:12 leo Exp $ */ /* * Copyright (c) 1995 Leo Weppelman. @@ -185,6 +185,7 @@ static void fdtestdrv __P((struct fd_softc *)); static int fdgetdisklabel __P((struct fd_softc *, dev_t)); static int fdselect __P((int, int, int)); static void fddeselect __P((void)); +static void fdmoff __P((struct fd_softc *)); extern __inline__ u_char read_fdreg(u_short regno) { @@ -231,8 +232,10 @@ fdcattach(pdp, dp, auxp) struct device *pdp, *dp; void *auxp; { + extern struct cfdriver fdcd; + struct fd_softc fdsoftc; - int i, nfound = 0; + int i, nfound, first_found = 0; printf("\n"); fddeselect(); @@ -247,12 +250,24 @@ void *auxp; st_dmafree(&fdsoftc, &lock_stat); if(!(fdsoftc.flags & FLPF_NOTRESP)) { + if(!nfound) + first_found = i; nfound++; config_found(dp, (void*)i, fdcprint); } } if(nfound) { + + /* + * Make sure motor will be turned of when a floppy is + * inserted in the first selected drive. + */ + fdselect(first_found, 0, FLP_DD); + fd_state = FLP_MON; + timeout((FPV)fdmotoroff, (void*)getsoftc(fdcd, first_found), + FLP_MONDELAY); + /* * enable disk related interrupts */ @@ -1076,9 +1091,12 @@ struct fd_softc *sc; /* * Turn motor off. */ - if(selected) - fddeselect(); - fd_state = FLP_IDLE; + if(selected) { + int tmp; + + st_dmagrab(fdcint, fdmoff, sc, &tmp, 0); + } + else fd_state = FLP_IDLE; break; } splx(sps); @@ -1115,6 +1133,35 @@ struct buf *bp; } /* + * Called from fdmotoroff to turn the motor actually off.... + * This can't be done in fdmotoroff itself, because exclusive access to the + * DMA controller is needed to read the FDC-status register. The function + * 'fdmoff()' always runs as the result of a 'dmagrab()'. + * We need to test the status-register because we want to be sure that the + * drive motor is really off before deselecting the drive. The FDC only + * turns off the drive motor after having seen 10 index-pulses. You only + * get index-pulses when a drive is selected....This means that if the + * drive is deselected when the motor is still spinning, it will continue + * to spin _even_ when you insert a floppy later on... + */ +static void +fdmoff(fdsoftc) +struct fd_softc *fdsoftc; +{ + int tmp; + + if ((fd_state == FLP_MON) && selected) { + tmp = read_fdreg(FDC_CS); + if (!(tmp & MOTORON)) { + fddeselect(); + fd_state = FLP_IDLE; + } + else timeout((FPV)fdmotoroff, (void*)fdsoftc, 10*FLP_MONDELAY); + } + st_dmafree(fdsoftc, &tmp); +} + +/* * Used to find out wich drives are actually connected. We do this by issueing * is 'RESTORE' command and check if the 'track-0' bit is set. This also works * if the drive is present but no floppy is inserted. diff --git a/sys/arch/atari/dev/ncr5380.c b/sys/arch/atari/dev/ncr5380.c index 3916e6d550b..e3e63eef9a4 100644 --- a/sys/arch/atari/dev/ncr5380.c +++ b/sys/arch/atari/dev/ncr5380.c @@ -1,4 +1,4 @@ -/* $NetBSD: ncr5380.c,v 1.11.2.3 1995/11/01 15:16:54 leo Exp $ */ +/* $NetBSD: ncr5380.c,v 1.12 1995/11/30 00:57:56 jtc Exp $ */ /* * Copyright (c) 1995 Leo Weppelman. diff --git a/sys/arch/atari/dev/zs.c b/sys/arch/atari/dev/zs.c index 96c8ae02cb0..5dcd8919daf 100644 --- a/sys/arch/atari/dev/zs.c +++ b/sys/arch/atari/dev/zs.c @@ -1,4 +1,4 @@ -/* $NetBSD: zs.c,v 1.9.2.1 1995/11/15 21:39:45 leo Exp $ */ +/* $NetBSD: zs.c,v 1.11 1995/12/03 14:32:39 leo Exp $ */ /* * Copyright (c) 1995 L. Weppelman (Atari modifications) @@ -824,7 +824,7 @@ struct proc *p; if(userbits & TIOCFLAG_SOFTCAR && userbits & TIOCFLAG_CLOCAL) return(EINVAL); if(userbits & TIOCFLAG_MDMBUF) /* don't support this (yet?) */ - return(ENXIO); + return(ENODEV); s = splzs(); if((userbits & TIOCFLAG_SOFTCAR)) { diff --git a/sys/arch/atari/dev/zsvar.h b/sys/arch/atari/dev/zsvar.h index 920d69794d6..3a7de2efa82 100644 --- a/sys/arch/atari/dev/zsvar.h +++ b/sys/arch/atari/dev/zsvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: zsvar.h,v 1.2.2.1 1995/11/15 21:39:47 leo Exp $ */ +/* $NetBSD: zsvar.h,v 1.3 1995/11/30 00:58:00 jtc Exp $ */ /* * Copyright (c) 1995 Leo Weppelman (Atari modifications) diff --git a/sys/arch/atari/include/disklabel.h b/sys/arch/atari/include/disklabel.h index ff6c3e6a20c..5f9677f45a5 100644 --- a/sys/arch/atari/include/disklabel.h +++ b/sys/arch/atari/include/disklabel.h @@ -1,4 +1,4 @@ -/* $NetBSD: disklabel.h,v 1.3 1995/08/05 20:24:42 leo Exp $ */ +/* $NetBSD: disklabel.h,v 1.4 1995/11/30 00:58:03 jtc Exp $ */ /* * Copyright (c) 1995 Leo Weppelman. @@ -33,41 +33,27 @@ #ifndef _MACHINE_DISKLABEL_H_ #define _MACHINE_DISKLABEL_H_ -#define LABELSECTOR 0 /* start of boot block */ +/* + * On a volume, exclusively used by NetBSD, the boot block starts at + * sector 0. To allow shared use of a volume between two or more OS's + * the vendor specific AHDI format is supported. In this case the boot + * block is located at the start of an AHDI partition. In any case the + * size of the boot block is 8KB, the disk label is at offset 7KB. + */ +#define LABELSECTOR 0 /* `natural' start of boot block */ #define LABELOFFSET (7 * 1024) /* offset of disklabel in bytes, relative to start of boot block */ #define MAXPARTITIONS 16 -#define RAW_PART 2 /* xx?c is raw partition */ - -#define MK_PARTID(x,y,z) ( ((u_int32_t)(x) << 16) \ - | ((u_int32_t)(y) << 8) \ - | ((u_int32_t)(z)) \ - ) -/* - * Various `well known' AHDI partition identifiers. - */ -#define CPU_PID_XGM MK_PARTID('X','G','M') -#define CPU_PID_BGM MK_PARTID('B','G','M') -#define CPU_PID_GEM MK_PARTID('G','E','M') -#define CPU_PID_RAW MK_PARTID('R','A','W') -#define CPU_PID_SWP MK_PARTID('S','W','P') -#define CPU_PID_NBD MK_PARTID('N','B','D') -#define CPU_PID_NBR MK_PARTID('N','B','R') -#define CPU_PID_NBS MK_PARTID('N','B','S') -#define CPU_PID_NBU MK_PARTID('N','B','U') +#define RAW_PART 2 /* xx?c is raw partition */ -struct cpu_partition { /* AHDI partition descriptor: */ - u_int32_t cp_id; /* identifier (see above) */ - u_int32_t cp_st; /* start and size in */ - u_int32_t cp_size; /* 512 byte blocks */ -}; +#define MAX_TOS_ROOTS 61 /* max. # of auxilary root sectors */ struct cpu_disklabel { - u_int32_t cd_bslst; /* start of AHDI bad sector list */ - u_int32_t cd_bslsize; /* size of AHDI bad sector list */ - u_int32_t cd_npartitions; /* number of AHDI partitions */ - struct cpu_partition *cd_partitions; /* list of AHDI partitions */ - struct cpu_partition *cd_labelpart; /* AHDI partition with disklabel */ + u_int32_t cd_bblock; /* start of NetBSD boot block */ +#define NO_BOOT_BLOCK ((u_int32_t) -1) + u_int32_t cd_bslst; /* start of TOS bad sector list */ + u_int32_t cd_bslsize; /* size of TOS bad sector list */ + u_int32_t cd_roots[MAX_TOS_ROOTS]; /* TOS root sectors */ }; #endif /* _MACHINE_DISKLABEL_H_ */ diff --git a/sys/arch/atari/include/tospart.h b/sys/arch/atari/include/tospart.h index aef66374581..0109eed9b72 100644 --- a/sys/arch/atari/include/tospart.h +++ b/sys/arch/atari/include/tospart.h @@ -1,4 +1,4 @@ -/* $NetBSD: tospart.h,v 1.2 1995/08/05 20:24:43 leo Exp $ */ +/* $NetBSD: tospart.h,v 1.3 1995/11/30 00:58:05 jtc Exp $ */ /* * Copyright (c) 1995 Leo Weppelman. @@ -33,26 +33,61 @@ #ifndef _MACHINE_TOSPART_H #define _MACHINE_TOSPART_H +#include <machine/disklabel.h> + #define TOS_BSIZE 512 /* TOS blocksize */ #define TOS_BBLOCK 0 /* TOS bootblock */ +#define MK_PARTID(x,y,z) ( ((u_int32_t)(x) << 16) \ + | ((u_int32_t)(y) << 8) \ + | ((u_int32_t)(z)) \ + ) /* - * Format of TOS bootblock. + * Various `well known' AHDI partition identifiers. */ -#define NTOS_PARTS 4 /* Max. # of entries in part. table */ +#define PID_XGM MK_PARTID('X','G','M') +#define PID_BGM MK_PARTID('B','G','M') +#define PID_GEM MK_PARTID('G','E','M') +#define PID_RAW MK_PARTID('R','A','W') +#define PID_SWP MK_PARTID('S','W','P') +#define PID_NBD MK_PARTID('N','B','D') +#define PID_NBR MK_PARTID('N','B','R') +#define PID_NBS MK_PARTID('N','B','S') +#define PID_NBU MK_PARTID('N','B','U') + +/* + * Format of TOS boot block. + */ +#define NTOS_PARTS 4 /* Max. # of entries in TOS bootblock */ struct tos_part { - u_char tp_flg; /* bit 0 is in-use flag */ - u_char tp_id[3]; /* id: GEM, BGM, XGM, UNX, MIX */ - u_int32_t tp_st; /* block where partition starts */ - u_int32_t tp_size; /* partition size in blocks */ + u_char tp_flg; /* bit 0 is in-use flag */ + u_char tp_id[3]; /* id: GEM, BGM, XGM, UNX, MIX */ + u_int32_t tp_st; /* block where partition starts */ + u_int32_t tp_size; /* partition size in blocks */ }; struct tos_root { - u_char tr_fill[0x1c2]; /* filler, can be boot code */ - u_int32_t tr_hdsize; /* size of entire volume in blocks */ - struct tos_part tr_parts[NTOS_PARTS]; /* partition table */ - u_int32_t tr_bslst; /* start of bad-sector list */ - u_int32_t tr_bslsize; /* # of blocks in bad-sector list */ + u_char tr_fill[0x1c2]; /* filler, can be boot code */ + u_int32_t tr_hdsize; /* size of entire volume in blocks */ + struct tos_part tr_parts[NTOS_PARTS]; /* partition table */ + u_int32_t tr_bslst; /* start of bad-sector list */ + u_int32_t tr_bslsize; /* # of blocks in bad-sector list */ +}; + +/* + * TOS partition table. + */ +#define MAX_TOS_PARTS (MAX_TOS_ROOTS + 3) /* Max. # of TOS partitions */ + +struct tos_table { + struct cpu_disklabel *tt_cdl; + u_int32_t tt_nroots; /* # of auxilary root sectors */ + u_int32_t tt_nparts; /* # of TOS partitions */ + struct tos_part tt_parts[MAX_TOS_PARTS]; +#define tt_roots tt_cdl->cd_roots +#define tt_bblock tt_cdl->cd_bblock +#define tt_bslst tt_cdl->cd_bslst +#define tt_bslsize tt_cdl->cd_bslsize }; #endif /* _MACHINE_TOSPART_H */ diff --git a/sys/arch/atari/include/video.h b/sys/arch/atari/include/video.h index b4c126689bc..3229c516e1f 100644 --- a/sys/arch/atari/include/video.h +++ b/sys/arch/atari/include/video.h @@ -1,4 +1,4 @@ -/* $NetBSD: video.h,v 1.2.2.1 1995/11/16 20:30:13 leo Exp $ */ +/* $NetBSD: video.h,v 1.3 1995/11/30 00:58:07 jtc Exp $ */ /* * Copyright (c) 1995 Leo Weppelman. diff --git a/sys/arch/hp300/conf/BASALT b/sys/arch/hp300/conf/BASALT index 87b2bf3a0ac..9f4fa0cc38e 100644 --- a/sys/arch/hp300/conf/BASALT +++ b/sys/arch/hp300/conf/BASALT @@ -1,4 +1,4 @@ -# $NetBSD: BASALT,v 1.2 1995/09/21 07:27:52 thorpej Exp $ +# $NetBSD: BASALT,v 1.3 1995/11/28 08:48:18 thorpej Exp $ # # BASALT - thorpej's hp380 # @@ -46,6 +46,7 @@ options NMBCLUSTERS="1024" # Crank this up # Options for HP hardware options FPSP # floating point interface for 68040 options USELEDS # make the lights twinkle +options COMPAT_HPUX # HP-UX binary compatibility # Debugging options options DDB # Kernel Dynamic Debugger diff --git a/sys/arch/hp300/conf/DISKLESS b/sys/arch/hp300/conf/DISKLESS index 7ab1eebebd4..ddece0f7b0a 100644 --- a/sys/arch/hp300/conf/DISKLESS +++ b/sys/arch/hp300/conf/DISKLESS @@ -1,4 +1,4 @@ -# $NetBSD: DISKLESS,v 1.3 1995/10/10 02:12:37 thorpej Exp $ +# $NetBSD: DISKLESS,v 1.4 1995/11/28 08:47:39 thorpej Exp $ # # Diskless HP 9000/300-series workstation. # @@ -51,7 +51,10 @@ options FPSP # floating point interface for 68040 options USELEDS # make the lights twinkle #options PANICBUTTON # two fast <reset>s on HIL dump kernel -# XXX DOESN'T WORK YET! +# +# HP-UX binary compatibility. +# NOTE: THIS IS STILL VERY EXPERIMENTAL. YOUR MILEAGE MAY VARY. +# #options COMPAT_HPUX # HP-UX binary compatibility # Debugging options diff --git a/sys/arch/hp300/conf/GENERIC b/sys/arch/hp300/conf/GENERIC index e3a1a7039d3..9c3a1cba9e1 100644 --- a/sys/arch/hp300/conf/GENERIC +++ b/sys/arch/hp300/conf/GENERIC @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.6 1995/10/10 02:12:41 thorpej Exp $ +# $NetBSD: GENERIC,v 1.7 1995/11/28 08:47:38 thorpej Exp $ # # Generic kernel - one size fits all. # @@ -56,7 +56,10 @@ options USELEDS # make the lights twinkle options COMPAT_NOLABEL # defaults for unlabeled disks #options PANICBUTTON # two fast <reset>s on HIL dump kernel -# XXX DOESN'T WORK YET! +# +# HP-UX binary compatibility. +# NOTE: THIS IS STILL VERY EXPERIMENTAL. YOUR MILEAGE MAY VARY. +# #options COMPAT_HPUX # HP-UX binary compatibility # Debugging options diff --git a/sys/arch/hp300/conf/Makefile.hp300 b/sys/arch/hp300/conf/Makefile.hp300 index 8e3920cef04..d95395b8a5f 100644 --- a/sys/arch/hp300/conf/Makefile.hp300 +++ b/sys/arch/hp300/conf/Makefile.hp300 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.hp300,v 1.26.2.2 1995/10/22 03:41:15 thorpej Exp $ +# $NetBSD: Makefile.hp300,v 1.28 1995/10/22 06:05:21 thorpej Exp $ # @(#)Makefile.hp300 8.2 (Berkeley) 1/23/94 # diff --git a/sys/arch/hp300/conf/files.hp300.oldconf b/sys/arch/hp300/conf/files.hp300.oldconf index b57daabd268..0542c7fa33e 100644 --- a/sys/arch/hp300/conf/files.hp300.oldconf +++ b/sys/arch/hp300/conf/files.hp300.oldconf @@ -1,4 +1,4 @@ -# $NetBSD: files.hp300.oldconf,v 1.20 1995/08/18 16:07:40 thorpej Exp $ +# $NetBSD: files.hp300.oldconf,v 1.21 1995/11/28 08:10:09 thorpej Exp $ # arch/hp300/hp300/autoconf.c standard arch/hp300/hp300/clock.c standard @@ -65,6 +65,8 @@ thisisfor_in_proto.c optional hy # include "../../../compat/hpux/files.hpux" compat/hpux/hpux_compat.c optional compat_hpux +compat/hpux/hpux_file.c optional compat_hpux +compat/hpux/hpux_exec.c optional compat_hpux compat/hpux/hpux_net.c optional compat_hpux compat/hpux/hpux_sig.c optional compat_hpux compat/hpux/hpux_syscalls.c optional compat_hpux diff --git a/sys/arch/hp300/dev/ac.c b/sys/arch/hp300/dev/ac.c index ed0d149d57d..89e9241d213 100644 --- a/sys/arch/hp300/dev/ac.c +++ b/sys/arch/hp300/dev/ac.c @@ -1,4 +1,4 @@ -/* $NetBSD: ac.c,v 1.2 1994/10/26 07:23:23 cgd Exp $ */ +/* $NetBSD: ac.c,v 1.3 1995/12/02 18:21:49 thorpej Exp $ */ /* * Copyright (c) 1991 University of Utah. @@ -73,13 +73,15 @@ extern int scsigo(); extern void scsifree(); extern void scsireset(); extern void scsi_delay(); +extern void scsi_str __P((char *, char *, size_t)); extern int scsi_immed_command(); -int acinit(), acstart(), acgo(), acintr(); +int acmatch(), acstart(), acgo(), acintr(); +void acattach(); struct driver acdriver = { - acinit, "ac", acstart, acgo, acintr, + acmatch, acattach, "ac", acstart, acgo, acintr, }; struct ac_softc ac_softc[NAC]; @@ -92,7 +94,8 @@ int ac_debug = 0x0000; #define ACD_OPEN 0x0002 #endif -acinit(hd) +int +acmatch(hd) register struct hp_device *hd; { int unit = hd->hp_unit; @@ -100,8 +103,21 @@ acinit(hd) sc->sc_hd = hd; sc->sc_punit = hd->hp_flags & 7; - if (acident(sc, hd) < 0) - return(0); + if (acident(sc, hd, 0) < 0) + return (0); + + return (1); +} + +void +acattach(hd) + register struct hp_device *hd; +{ + int unit = hd->hp_unit; + register struct ac_softc *sc = &ac_softc[unit]; + + (void)acident(sc, hd, 1); /* XXX Ick. */ + sc->sc_dq.dq_unit = unit; sc->sc_dq.dq_ctlr = hd->hp_ctlr; sc->sc_dq.dq_slave = hd->hp_slave; @@ -109,19 +125,19 @@ acinit(hd) sc->sc_bp = &acbuf[unit]; sc->sc_cmd = &accmd[unit]; sc->sc_flags = ACF_ALIVE; - return(1); } -acident(sc, hd) +acident(sc, hd, verbose) register struct ac_softc *sc; register struct hp_device *hd; + int verbose; { int unit; register int ctlr, slave; int i, stat; int tries = 5; - char idstr[32]; struct scsi_inquiry inqbuf; + char vendor[9], product[17], revision[5]; static struct scsi_fmt_cdb inq = { 6, CMD_INQUIRY, 0, 0, 0, sizeof(inqbuf), 0 @@ -162,21 +178,18 @@ acident(sc, hd) if (inqbuf.type != 8 || inqbuf.qual != 0x80 || inqbuf.version != 2) goto failed; - bcopy((caddr_t)&inqbuf.vendor_id, (caddr_t)idstr, 28); - for (i = 27; i > 23; --i) - if (idstr[i] != ' ') - break; - idstr[i+1] = 0; - for (i = 23; i > 7; --i) - if (idstr[i] != ' ') - break; - idstr[i+1] = 0; - for (i = 7; i >= 0; --i) - if (idstr[i] != ' ') - break; - idstr[i+1] = 0; - printf("ac%d: %s %s rev %s\n", hd->hp_unit, - &idstr[0], &idstr[8], &idstr[24]); + /* + * Get a usable id string + */ + bzero(vendor, sizeof(vendor)); + bzero(product, sizeof(product)); + bzero(revision, sizeof(revision)); + scsi_str(inqbuf.vendor_id, vendor, sizeof(inqbuf.vendor_id)); + scsi_str(inqbuf.product_id, product, sizeof(inqbuf.product_id)); + scsi_str(inqbuf.rev, revision, sizeof(inqbuf.rev)); + + if (verbose) + printf(": <%s, %s, %s>\n", vendor, product, revision); scsi_delay(0); return(inqbuf.type); @@ -429,13 +442,14 @@ acintr(unit, stat) scsi_request_sense(sc->sc_hd->hp_ctlr, sc->sc_hd->hp_slave, sc->sc_punit, sensebuf, sizeof sensebuf); sp = (struct scsi_xsense *)sensebuf; - printf("ac%d: acintr sense key=%x, ac=%x, acq=%x\n", - unit, sp->key, sp->info4, sp->len); + printf("%s: acintr sense key=%x, ac=%x, acq=%x\n", + sc->sc_hd->hp_xname, sp->key, sp->info4, sp->len); bp->b_flags |= B_ERROR; bp->b_error = EIO; break; default: - printf("ac%d: acintr unknown status 0x%x\n", unit, stat); + printf("%s: acintr unknown status 0x%x\n", sc->sc_hd->hp_xname, + stat); break; } (void) biodone(sc->sc_bp); diff --git a/sys/arch/hp300/dev/ct.c b/sys/arch/hp300/dev/ct.c index dfab8c0f353..e3ad6174909 100644 --- a/sys/arch/hp300/dev/ct.c +++ b/sys/arch/hp300/dev/ct.c @@ -1,4 +1,4 @@ -/* $NetBSD: ct.c,v 1.12 1995/10/09 07:57:43 thorpej Exp $ */ +/* $NetBSD: ct.c,v 1.13 1995/12/02 18:21:52 thorpej Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -64,10 +64,10 @@ /* number of eof marks to remember */ #define EOFS 128 -int ctinit(), ctstart(), ctgo(), ctintr(); -void ctstrategy(), ctdone(); +int ctmatch(), ctstart(), ctgo(), ctintr(); +void ctattach(), ctstrategy(), ctdone(); struct driver ctdriver = { - ctinit, "ct", ctstart, ctgo, ctintr, + ctmatch, ctattach, "ct", ctstart, ctgo, ctintr, }; struct ct_softc { @@ -135,7 +135,8 @@ int ctdebug = 0; #define CT_BSF 0x02 #endif -ctinit(hd) +int +ctmatch(hd) register struct hp_device *hd; { register struct ct_softc *sc = &ct_softc[hd->hp_unit]; @@ -145,20 +146,33 @@ ctinit(hd) bp->b_actb = &bp->b_actf; sc->sc_hd = hd; sc->sc_punit = ctpunit(hd->hp_flags); - if (ctident(sc, hd) < 0) - return(0); + if (ctident(sc, hd, 0) < 0) + return (0); + + return (1); +} + +void +ctattach(hd) + register struct hp_device *hd; +{ + struct ct_softc *sc = &ct_softc[hd->hp_unit]; + + (void)ctident(sc, hd, 1); /* XXX Ick. */ + ctreset(sc, hd); sc->sc_dq.dq_ctlr = hd->hp_ctlr; sc->sc_dq.dq_unit = hd->hp_unit; sc->sc_dq.dq_slave = hd->hp_slave; sc->sc_dq.dq_driver = &ctdriver; sc->sc_flags |= CTF_ALIVE; - return(1); } -ctident(sc, hd) +int +ctident(sc, hd, verbose) register struct ct_softc *sc; register struct hp_device *hd; + int verbose; { struct ct_describe desc; u_char stat, cmd[3]; @@ -216,8 +230,9 @@ ctident(sc, hd) sc->sc_type = CT88140; break; } - printf("ct%d: %s %stape\n", hd->hp_unit, ctinfo[id].desc, - (sc->sc_flags & CTF_CANSTREAM) ? "streaming " : " "); + if (verbose) + printf(": %s %stape\n", ctinfo[id].desc, + (sc->sc_flags & CTF_CANSTREAM) ? "streaming " : " "); return(id); } @@ -318,8 +333,9 @@ ctclose(dev, flag) sc->sc_eofp--; #ifdef DEBUG if(ctdebug & CT_BSF) - printf("ct%d: ctclose backup eofs prt %d blk %d\n", - UNIT(dev), sc->sc_eofp, sc->sc_eofs[sc->sc_eofp]); + printf("%s: ctclose backup eofs prt %d blk %d\n", + sc->sc_hd->hp_xname, sc->sc_eofp, + sc->sc_eofs[sc->sc_eofp]); #endif } if ((minor(dev) & CT_NOREW) == 0) @@ -371,8 +387,8 @@ again: sc->sc_eofp--; #ifdef DEBUG if (ctdebug & CT_BSF) - printf("ct%d: backup eof pos %d blk %d\n", - UNIT(dev), sc->sc_eofp, + printf("%s: backup eof pos %d blk %d\n", + sc->sc_hd->hp_xname, sc->sc_eofp, sc->sc_eofs[sc->sc_eofp]); #endif } @@ -469,7 +485,8 @@ again: sc->sc_blkno = 0; #ifdef DEBUG if(ctdebug & CT_BSF) - printf("ct%d: clearing eofs\n", unit); + printf("%s: clearing eofs\n", + sc->sc_hd->hp_xname); #endif for (i=0; i<EOFS; i++) sc->sc_eofs[i] = 0; @@ -628,7 +645,7 @@ ctintr(unit) bp = cttab[unit].b_actf; if (bp == NULL) { - printf("ct%d: bp == NULL\n", unit); + printf("%s: bp == NULL\n", sc->sc_hd->hp_xname); return; } if (sc->sc_flags & CTF_IO) { @@ -683,17 +700,19 @@ ctintr(unit) if (sc->sc_stat.c_aef & 0x5800) { if (sc->sc_stat.c_aef & 0x4000) tprintf(sc->sc_tpr, - "ct%d: uninitialized media\n", - unit); + "%s: uninitialized media\n", + sc->sc_hd->hp_xname); if (sc->sc_stat.c_aef & 0x1000) tprintf(sc->sc_tpr, - "ct%d: not ready\n", unit); + "%s: not ready\n", + sc->sc_hd->hp_xname); if (sc->sc_stat.c_aef & 0x0800) tprintf(sc->sc_tpr, - "ct%d: write protect\n", unit); + "%s: write protect\n", + sc->sc_hd->hp_xname); } else { - printf("ct%d err: v%d u%d ru%d bn%d, ", - unit, + printf("%s err: v%d u%d ru%d bn%d, ", + sc->sc_hd->hp_xname, (sc->sc_stat.c_vu>>4)&0xF, sc->sc_stat.c_vu&0xF, sc->sc_stat.c_pend, @@ -705,7 +724,8 @@ ctintr(unit) sc->sc_stat.c_ief); } } else - printf("ct%d: request status failed\n", unit); + printf("%s: request status failed\n", + sc->sc_hd->hp_xname); bp->b_flags |= B_ERROR; bp->b_error = EIO; goto done; @@ -867,8 +887,8 @@ ctaddeof(unit) } #ifdef DEBUG if (ctdebug & CT_BSF) - printf("ct%d: add eof pos %d blk %d\n", - unit, sc->sc_eofp, + printf("%s: add eof pos %d blk %d\n", + sc->sc_hd->hp_xname, sc->sc_eofp, sc->sc_eofs[sc->sc_eofp]); #endif } diff --git a/sys/arch/hp300/dev/dca.c b/sys/arch/hp300/dev/dca.c index b82e145e1f9..af741cf74ac 100644 --- a/sys/arch/hp300/dev/dca.c +++ b/sys/arch/hp300/dev/dca.c @@ -1,6 +1,7 @@ -/* $NetBSD: dca.c,v 1.17 1995/10/04 17:46:08 thorpej Exp $ */ +/* $NetBSD: dca.c,v 1.18 1995/12/02 18:15:50 thorpej Exp $ */ /* + * Copyright (c) 1995 Jason R. Thorpe. All rights reserved. * Copyright (c) 1982, 1986, 1990, 1993 * The Regents of the University of California. All rights reserved. * @@ -37,11 +38,10 @@ #include "dca.h" #if NDCA > 0 + /* - * Driver for National Semiconductor INS8250/NS16550AF/WD16C552 UARTs. - * Includes: - * 98626/98644/internal serial interface on hp300/hp400 - * internal serial ports on hp700 + * Driver for the 98626/98644/internal serial interface on hp300/hp400, + * based on the National Semiconductor INS8250/NS16550AF/WD16C552 UARTs. * * N.B. On the hp700 and some hp300s, there is a "secret bit" with * undocumented behavior. The third bit of the Modem Control Register @@ -50,6 +50,7 @@ * be any harmful side-effects from setting this bit on non-affected * machines. */ + #include <sys/param.h> #include <sys/systm.h> #include <sys/ioctl.h> @@ -65,23 +66,33 @@ #include <hp300/dev/dcareg.h> #include <machine/cpu.h> -#ifdef hp300 #include <hp300/hp300/isr.h> -#endif -#ifdef hp700 -#include <machine/asp.h> -#endif -int dcaprobe(); +int dcamatch(); +void dcaattach(); struct driver dcadriver = { - dcaprobe, "dca", + dcamatch, dcaattach, "dca", }; +struct dca_softc { + struct hp_device *sc_hd; /* device info */ + struct dcadevice *sc_dca; /* pointer to hardware */ + struct tty *sc_tty; /* our tty instance */ + struct isr sc_isr; /* interrupt handler */ + int sc_oflows; /* overflow counter */ + short sc_flags; /* state flags */ + + /* + * Bits for sc_flags. + */ +#define DCA_ACTIVE 0x0001 /* indicates live unit */ +#define DCA_SOFTCAR 0x0002 /* indicates soft-carrier */ +#define DCA_HASFIFO 0x0004 /* indicates unit has FIFO */ + +} dca_softc[NDCA]; + void dcastart(); int dcaparam(), dcaintr(); -int dcasoftCAR; -int dca_active; -int dca_hasfifo; int ndca = NDCA; #ifdef DCACONSOLE int dcaconsole = DCACONSOLE; @@ -91,13 +102,7 @@ int dcaconsole = -1; int dcaconsinit; int dcadefaultrate = TTYDEF_SPEED; int dcamajor; -struct dcadevice *dca_addr[NDCA]; -struct tty *dca_tty[NDCA]; -#ifdef hp300 -struct isr dcaisr[NDCA]; int dcafastservice; -#endif -int dcaoflows[NDCA]; struct speedtab dcaspeedtab[] = { 0, 0, @@ -127,7 +132,7 @@ extern int kgdb_rate; extern int kgdb_debug_init; #endif -#define UNIT(x) minor(x) +#define DCAUNIT(x) minor(x) #ifdef DEBUG long fifoin[17]; @@ -136,87 +141,96 @@ long dcaintrcount[16]; long dcamintcount[16]; #endif -dcaprobe(hd) +int +dcamatch(hd) register struct hp_device *hd; { - register struct dcadevice *dca; - register int unit; + struct dcadevice *dca = (struct dcadevice *)hd->hp_addr; + struct dca_softc *sc = &dca_softc[hd->hp_unit]; - dca = (struct dcadevice *)hd->hp_addr; -#ifdef hp300 if (dca->dca_id != DCAID0 && dca->dca_id != DCAREMID0 && dca->dca_id != DCAID1 && dca->dca_id != DCAREMID1) return (0); -#endif - unit = hd->hp_unit; + + hd->hp_ipl = DCAIPL(dca->dca_ic); + sc->sc_hd = hd; + + return (1); +} + +void +dcaattach(hd) + register struct hp_device *hd; +{ + int unit = hd->hp_unit; + struct dcadevice *dca = (struct dcadevice *)hd->hp_addr; + struct dca_softc *sc = &dca_softc[unit]; if (unit == dcaconsole) DELAY(100000); -#ifdef hp300 dca->dca_reset = 0xFF; DELAY(100); -#endif /* look for a NS 16550AF UART with FIFOs */ dca->dca_fifo = FIFO_ENABLE|FIFO_RCV_RST|FIFO_XMT_RST|FIFO_TRIGGER_14; DELAY(100); if ((dca->dca_iir & IIR_FIFO_MASK) == IIR_FIFO_MASK) - dca_hasfifo |= 1 << unit; + sc->sc_flags |= DCA_HASFIFO; - dca_addr[unit] = dca; -#ifdef hp300 - hd->hp_ipl = DCAIPL(dca->dca_ic); - dcaisr[unit].isr_ipl = hd->hp_ipl; - dcaisr[unit].isr_arg = unit; - dcaisr[unit].isr_intr = dcaintr; - isrlink(&dcaisr[unit]); -#endif - dca_active |= 1 << unit; + sc->sc_dca = dca; + + /* Establish interrupt handler. */ + sc->sc_isr.isr_ipl = hd->hp_ipl; + sc->sc_isr.isr_arg = unit; + sc->sc_isr.isr_intr = dcaintr; + isrlink(&sc->sc_isr); + + sc->sc_flags |= DCA_ACTIVE; if (hd->hp_flags) - dcasoftCAR |= (1 << unit); + sc->sc_flags |= DCA_SOFTCAR; + + /* Enable interrupts. */ + dca->dca_ic = IC_IE; + + /* + * Need to reset baud rate, etc. of next print so reset dcaconsinit. + * Also make sure console is always "hardwired." + */ + if (unit == dcaconsole) { + dcaconsinit = 0; + sc->sc_flags |= DCA_SOFTCAR; + printf(": console, "); + } else + printf(": "); + + if (sc->sc_flags & DCA_HASFIFO) + printf("working fifo\n"); + else + printf("no fifo\n"); + #ifdef KGDB if (kgdb_dev == makedev(dcamajor, unit)) { if (dcaconsole == unit) kgdb_dev = NODEV; /* can't debug over console port */ else { - (void) dcainit(unit, kgdb_rate); + (void) dcainit(sc, kgdb_rate); dcaconsinit = 1; /* don't re-init in dcaputc */ if (kgdb_debug_init) { /* * Print prefix of device name, * let kgdb_connect print the rest. */ - printf("dca%d: ", unit); + printf("%s: ", sc->sc_hd->hp_xname); kgdb_connect(1); } else - printf("dca%d: kgdb enabled\n", unit); + printf("%s: kgdb enabled\n", + sc->sc_hd->hp_xname); } } #endif -#ifdef hp300 - dca->dca_ic = IC_IE; -#endif - - /* - * Need to reset baud rate, etc. of next print so reset dcaconsinit. - * Also make sure console is always "hardwired." - */ - if (unit == dcaconsole) { - dcaconsinit = 0; - dcasoftCAR |= (1 << unit); - printf("dca%d: console, ", unit); - } else - printf("dca%d: ", unit); - - if (dca_hasfifo & (1 << unit)) - printf("working fifo\n"); - else - printf("no fifo\n"); - - return (1); } /* ARGSUSED */ @@ -226,32 +240,37 @@ dcaopen(dev, flag, mode, p) int flag, mode; struct proc *p; { - register struct tty *tp; - register int unit; + int unit = DCAUNIT(dev); + struct dca_softc *sc; + struct tty *tp; struct dcadevice *dca; u_char code; int s, error = 0; - unit = UNIT(dev); - if (unit >= NDCA || (dca_active & (1 << unit)) == 0) + if (unit >= NDCA) + return (ENXIO); + + sc = &dca_softc[unit]; + if ((sc->sc_flags & DCA_ACTIVE) == 0) return (ENXIO); - if (!dca_tty[unit]) - tp = dca_tty[unit] = ttymalloc(); + + dca = sc->sc_dca; + + if (sc->sc_tty == NULL) + tp = sc->sc_tty = ttymalloc(); else - tp = dca_tty[unit]; + tp = sc->sc_tty; tp->t_oproc = dcastart; tp->t_param = dcaparam; tp->t_dev = dev; - dca = dca_addr[unit]; - if ((tp->t_state & TS_ISOPEN) == 0) { /* * Sanity clause: reset the card on first open. * The card might be left in an inconsistent state * if card memory is read inadvertently. */ - dcainit(unit, dcadefaultrate); + dcainit(sc, dcadefaultrate); tp->t_state |= TS_WOPEN; ttychars(tp); @@ -267,7 +286,7 @@ dcaopen(dev, flag, mode, p) ttsetwater(tp); /* Set the FIFO threshold based on the receive speed. */ - if (dca_hasfifo & (1 << unit)) + if (sc->sc_flags & DCA_HASFIFO) dca->dca_fifo = FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | (tp->t_ispeed <= 1200 ? FIFO_TRIGGER_1 : @@ -283,10 +302,10 @@ dcaopen(dev, flag, mode, p) s = spltty(); /* Set modem control state. */ - (void) dcamctl(dev, MCR_DTR | MCR_RTS, DMSET); + (void) dcamctl(sc, MCR_DTR | MCR_RTS, DMSET); /* Set soft-carrier if so configured. */ - if ((dcasoftCAR & (1 << unit)) || (dcamctl(dev, 0, DMGET) & MSR_DCD)) + if ((sc->sc_flags & DCA_SOFTCAR) || (dcamctl(sc, 0, DMGET) & MSR_DCD)) tp->t_state |= TS_CARR_ON; /* Wait for carrier if necessary. */ @@ -305,15 +324,14 @@ dcaopen(dev, flag, mode, p) if (error == 0) error = (*linesw[tp->t_line].l_open)(dev, tp); -#ifdef hp300 /* * XXX hack to speed up unbuffered builtin port. * If dca_fastservice is set, a level 5 interrupt * will be directed to dcaintr first. */ - if (error == 0 && unit == 0 && (dca_hasfifo & 1) == 0) + if (error == 0 && unit == 0 && (sc->sc_flags & DCA_HASFIFO) == 0) dcafastservice = 1; -#endif + return (error); } @@ -324,18 +342,20 @@ dcaclose(dev, flag, mode, p) int flag, mode; struct proc *p; { + struct dca_softc *sc; register struct tty *tp; register struct dcadevice *dca; register int unit; int s; - unit = UNIT(dev); -#ifdef hp300 + unit = DCAUNIT(dev); + if (unit == 0) dcafastservice = 0; -#endif - dca = dca_addr[unit]; - tp = dca_tty[unit]; + + sc = &dca_softc[unit]; + dca = sc->sc_dca; + tp = sc->sc_tty; (*linesw[tp->t_line].l_close)(tp, flag); s = spltty(); @@ -346,16 +366,16 @@ dcaclose(dev, flag, mode, p) if (dev != kgdb_dev) #endif dca->dca_ier = 0; - if (tp->t_cflag & HUPCL && (dcasoftCAR & (1 << unit)) == 0) { + if (tp->t_cflag & HUPCL && (sc->sc_flags & DCA_SOFTCAR) == 0) { /* XXX perhaps only clear DTR */ - (void) dcamctl(dev, 0, DMSET); + (void) dcamctl(sc, 0, DMSET); } tp->t_state &= ~(TS_BUSY | TS_FLUSH); splx(s); ttyclose(tp); #if 0 ttyfree(tp); - dca_tty[unit] = (struct tty *)0; + sc->sc_tty = NULL; #endif return (0); } @@ -366,18 +386,19 @@ dcaread(dev, uio, flag) struct uio *uio; int flag; { - int unit = UNIT(dev); - register struct tty *tp = dca_tty[unit]; + int unit = DCAUNIT(dev); + struct dca_softc *sc = &dca_softc[unit]; + struct tty *tp = sc->sc_tty; int error, of; - of = dcaoflows[unit]; + of = sc->sc_oflows; error = (*linesw[tp->t_line].l_read)(tp, uio, flag); /* * XXX hardly a reasonable thing to do, but reporting overflows * at interrupt time just exacerbates the problem. */ - if (dcaoflows[unit] != of) - log(LOG_WARNING, "dca%d: silo overflow\n", unit); + if (sc->sc_oflows != of) + log(LOG_WARNING, "%s: silo overflow\n", sc->sc_hd->hp_xname); return (error); } @@ -387,7 +408,7 @@ dcawrite(dev, uio, flag) struct uio *uio; int flag; { - register struct tty *tp = dca_tty[UNIT(dev)]; + struct tty *tp = dca_softc[DCAUNIT(dev)].sc_tty; return ((*linesw[tp->t_line].l_write)(tp, uio, flag)); } @@ -397,24 +418,26 @@ dcatty(dev) dev_t dev; { - return (dca_tty[UNIT(dev)]); + return (dca_softc[DCAUNIT(dev)].sc_tty); } int dcaintr(unit) register int unit; { - register struct dcadevice *dca; + struct dca_softc *sc = &dca_softc[unit]; + register struct dcadevice *dca = sc->sc_dca; + register struct tty *tp = sc->sc_tty; register u_char code; - register struct tty *tp; int iflowdone = 0; - dca = dca_addr[unit]; -#ifdef hp300 + /* + * If interrupts aren't enabled, then the interrupt can't + * be for us. + */ if ((dca->dca_ic & (IC_IR|IC_IE)) != (IC_IR|IC_IE)) return (0); -#endif - tp = dca_tty[unit]; + for (;;) { code = dca->dca_iir; #ifdef DEBUG @@ -445,7 +468,7 @@ dcaintr(unit) (*linesw[tp->t_line].l_rint)(code, tp) #endif RCVBYTE(); - if (dca_hasfifo & (1 << unit)) { + if (sc->sc_flags & DCA_HASFIFO) { #ifdef DEBUG register int fifocnt = 1; #endif @@ -453,7 +476,7 @@ dcaintr(unit) if (code == LSR_RXRDY) { RCVBYTE(); } else - dcaeint(unit, code, dca); + dcaeint(sc, code); #ifdef DEBUG fifocnt++; #endif @@ -479,35 +502,36 @@ dcaintr(unit) dcastart(tp); break; case IIR_RLS: - dcaeint(unit, dca->dca_lsr, dca); + dcaeint(sc, dca->dca_lsr); break; default: if (code & IIR_NOPEND) return (1); - log(LOG_WARNING, "dca%d: weird interrupt: 0x%x\n", - unit, code); + log(LOG_WARNING, "%s: weird interrupt: 0x%x\n", + sc->sc_hd->hp_xname, code); /* fall through */ case IIR_MLSC: - dcamint(unit, dca); + dcamint(sc); break; } } } -dcaeint(unit, stat, dca) - register int unit, stat; - register struct dcadevice *dca; +dcaeint(sc, stat) + struct dca_softc *sc; + int stat; { - register struct tty *tp; - register int c; + struct tty *tp = sc->sc_tty; + struct dcadevice *dca = sc->sc_dca; + int c; - tp = dca_tty[unit]; c = dca->dca_data; if ((tp->t_state & TS_ISOPEN) == 0) { #ifdef KGDB /* we don't care about parity errors */ if (((stat & (LSR_BI|LSR_FE|LSR_PE)) == LSR_PE) && - kgdb_dev == makedev(dcamajor, unit) && c == FRAME_END) + kgdb_dev == makedev(dcamajor, sc->sc_hd->hp_unit) + && c == FRAME_END) kgdb_connect(0); /* trap into kgdb */ #endif return; @@ -517,24 +541,23 @@ dcaeint(unit, stat, dca) else if (stat & LSR_PE) c |= TTY_PE; else if (stat & LSR_OE) - dcaoflows[unit]++; + sc->sc_oflows++; (*linesw[tp->t_line].l_rint)(c, tp); } -dcamint(unit, dca) - register int unit; - register struct dcadevice *dca; +dcamint(sc) + struct dca_softc *sc; { - register struct tty *tp; - register u_char stat; + struct tty *tp = sc->sc_tty; + struct dcadevice *dca = sc->sc_dca; + u_char stat; - tp = dca_tty[unit]; stat = dca->dca_msr; #ifdef DEBUG dcamintcount[stat & 0xf]++; #endif if ((stat & MSR_DDCD) && - (dcasoftCAR & (1 << unit)) == 0) { + (sc->sc_flags & DCA_SOFTCAR) == 0) { if (stat & MSR_DCD) (void)(*linesw[tp->t_line].l_modem)(tp, 1); else if ((*linesw[tp->t_line].l_modem)(tp, 0) == 0) @@ -563,12 +586,12 @@ dcaioctl(dev, cmd, data, flag, p) int flag; struct proc *p; { - register struct tty *tp; - register int unit = UNIT(dev); - register struct dcadevice *dca; - register int error; + int unit = DCAUNIT(dev); + struct dca_softc *sc = &dca_softc[unit]; + struct tty *tp = sc->sc_tty; + struct dcadevice *dca = sc->sc_dca; + int error; - tp = dca_tty[unit]; error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); if (error >= 0) return (error); @@ -576,8 +599,6 @@ dcaioctl(dev, cmd, data, flag, p) if (error >= 0) return (error); - dca = dca_addr[unit]; - switch (cmd) { case TIOCSBRK: dca->dca_cfcr |= CFCR_SBREAK; @@ -588,33 +609,33 @@ dcaioctl(dev, cmd, data, flag, p) break; case TIOCSDTR: - (void) dcamctl(dev, MCR_DTR | MCR_RTS, DMBIS); + (void) dcamctl(sc, MCR_DTR | MCR_RTS, DMBIS); break; case TIOCCDTR: - (void) dcamctl(dev, MCR_DTR | MCR_RTS, DMBIC); + (void) dcamctl(sc, MCR_DTR | MCR_RTS, DMBIC); break; case TIOCMSET: - (void) dcamctl(dev, *(int *)data, DMSET); + (void) dcamctl(sc, *(int *)data, DMSET); break; case TIOCMBIS: - (void) dcamctl(dev, *(int *)data, DMBIS); + (void) dcamctl(sc, *(int *)data, DMBIS); break; case TIOCMBIC: - (void) dcamctl(dev, *(int *)data, DMBIC); + (void) dcamctl(sc, *(int *)data, DMBIC); break; case TIOCMGET: - *(int *)data = dcamctl(dev, 0, DMGET); + *(int *)data = dcamctl(sc, 0, DMGET); break; case TIOCGFLAGS: { int bits = 0; - if (dcasoftCAR & (1 << unit)) + if (sc->sc_flags & DCA_SOFTCAR) bits |= TIOCFLAG_SOFTCAR; if (tp->t_cflag & CLOCAL) @@ -634,7 +655,7 @@ dcaioctl(dev, cmd, data, flag, p) userbits = *(int *)data; if ((userbits & TIOCFLAG_SOFTCAR) || (unit == dcaconsole)) - dcasoftCAR |= (1 << unit); + sc->sc_flags |= DCA_SOFTCAR; if (userbits & TIOCFLAG_CLOCAL) tp->t_cflag |= CLOCAL; @@ -653,9 +674,10 @@ dcaparam(tp, t) register struct tty *tp; register struct termios *t; { - register struct dcadevice *dca; - register int cfcr, cflag = t->c_cflag; - int unit = UNIT(tp->t_dev); + int unit = DCAUNIT(tp->t_dev); + struct dca_softc *sc = &dca_softc[unit]; + struct dcadevice *dca = sc->sc_dca; + int cfcr, cflag = t->c_cflag; int ospeed = ttspeedtab(t->c_ospeed, dcaspeedtab); int s; @@ -663,8 +685,6 @@ dcaparam(tp, t) if (ospeed < 0 || (t->c_ispeed && t->c_ispeed != t->c_ospeed)) return (EINVAL); - dca = dca_addr[unit]; - switch (cflag & CSIZE) { case CS5: cfcr = CFCR_5BITS; @@ -693,14 +713,14 @@ dcaparam(tp, t) s = spltty(); if (ospeed == 0) - (void) dcamctl(unit, 0, DMSET); /* hang up line */ + (void) dcamctl(sc, 0, DMSET); /* hang up line */ /* * Set the FIFO threshold based on the recieve speed, if we * are changing it. */ if (tp->t_ispeed != t->c_ispeed) { - if (dca_hasfifo & (1 << unit)) + if (sc->sc_flags & DCA_HASFIFO) dca->dca_fifo = FIFO_ENABLE | (t->c_ispeed <= 1200 ? FIFO_TRIGGER_1 : FIFO_TRIGGER_14); @@ -730,12 +750,10 @@ void dcastart(tp) register struct tty *tp; { - register struct dcadevice *dca; - int s, unit, c; + int s, c, unit = DCAUNIT(tp->t_dev); + struct dca_softc *sc = &dca_softc[unit]; + struct dcadevice *dca = sc->sc_dca; - unit = UNIT(tp->t_dev); - dca = dca_addr[unit]; - s = spltty(); if (tp->t_state & (TS_TIMEOUT|TS_TTSTOP)) @@ -751,7 +769,7 @@ dcastart(tp) } if (dca->dca_lsr & LSR_TXRDY) { tp->t_state |= TS_BUSY; - if (dca_hasfifo & (1 << unit)) { + if (sc->sc_flags & DCA_HASFIFO) { for (c = 0; c < 16 && tp->t_outq.c_cc; ++c) dca->dca_data = getc(&tp->t_outq); #ifdef DEBUG @@ -786,21 +804,18 @@ dcastop(tp, flag) splx(s); } -dcamctl(dev, bits, how) - dev_t dev; +dcamctl(sc, bits, how) + struct dca_softc *sc; int bits, how; { - register struct dcadevice *dca; - register int unit; + struct dcadevice *dca = sc->sc_dca; int s; - unit = UNIT(dev); - dca = dca_addr[unit]; /* * Always make sure MCR_IEN is set (unless setting to 0) */ #ifdef KGDB - if (how == DMSET && kgdb_dev == makedev(dcamajor, unit)) + if (how == DMSET && kgdb_dev == makedev(dcamajor, sc->sc_hd->hp_unit)) bits |= MCR_IEN; else #endif @@ -809,8 +824,8 @@ dcamctl(dev, bits, how) else if (how == DMBIC) bits &= ~MCR_IEN; s = spltty(); - switch (how) { + switch (how) { case DMSET: dca->dca_mcr = bits; break; @@ -840,6 +855,7 @@ void dcacnprobe(cp) struct consdev *cp; { + struct dca_softc *sc; int unit; /* locate the major number */ @@ -849,23 +865,20 @@ dcacnprobe(cp) /* XXX: ick */ unit = CONUNIT; -#ifdef hp300 - dca_addr[CONUNIT] = (struct dcadevice *) sctova(CONSCODE); + sc = &dca_softc[unit]; + + sc->sc_dca = (struct dcadevice *) sctova(CONSCODE); /* make sure hardware exists */ - if (badaddr((short *)dca_addr[unit])) { + if (badaddr((short *)sc->sc_dca)) { cp->cn_pri = CN_DEAD; return; } -#endif -#ifdef hp700 - dca_addr[CONUNIT] = CONPORT; -#endif /* initialize required fields */ cp->cn_dev = makedev(dcamajor, unit); -#ifdef hp300 - switch (dca_addr[unit]->dca_id) { + + switch (sc->sc_dca->dca_id) { case DCAID0: case DCAID1: cp->cn_pri = CN_NORMAL; @@ -878,10 +891,7 @@ dcacnprobe(cp) cp->cn_pri = CN_DEAD; break; } -#endif -#ifdef hp700 - cp->cn_pri = CN_NORMAL; -#endif + /* * If dcaconsole is initialized, raise our priority. */ @@ -897,32 +907,31 @@ void dcacninit(cp) struct consdev *cp; { - int unit = UNIT(cp->cn_dev); + int unit = DCAUNIT(cp->cn_dev); + struct dca_softc *sc = &dca_softc[unit]; - dcainit(unit, dcadefaultrate); + dcainit(sc, dcadefaultrate); dcaconsole = unit; dcaconsinit = 1; } -dcainit(unit, rate) - int unit, rate; +dcainit(sc, rate) + struct dca_softc *sc; + int rate; { - register struct dcadevice *dca; + struct dcadevice *dca = sc->sc_dca; int s; short stat; #ifdef lint - stat = unit; if (stat) return; + stat = sc->sc_hd->hp_unit; if (stat) return; #endif - dca = dca_addr[unit]; s = splhigh(); -#ifdef hp300 dca->dca_reset = 0xFF; DELAY(100); dca->dca_ic = IC_IE; -#endif dca->dca_cfcr = CFCR_DLAB; rate = ttspeedtab(rate, dcaspeedtab); @@ -941,8 +950,9 @@ int dcacngetc(dev) dev_t dev; { - register struct dcadevice *dca = dca_addr[UNIT(dev)]; - register u_char stat; + struct dca_softc *sc = &dca_softc[DCAUNIT(dev)]; + struct dcadevice *dca = sc->sc_dca; + u_char stat; int c, s; #ifdef lint @@ -965,16 +975,17 @@ dcacnputc(dev, c) dev_t dev; register int c; { - register struct dcadevice *dca = dca_addr[UNIT(dev)]; - register int timo; - register u_char stat; + struct dca_softc *sc = &dca_softc[DCAUNIT(dev)]; + struct dcadevice *dca = sc->sc_dca; + int timo; + u_char stat; int s = splhigh(); #ifdef lint stat = dev; if (stat) return; #endif if (dcaconsinit == 0) { - (void) dcainit(UNIT(dev), dcadefaultrate); + (void) dcainit(sc, dcadefaultrate); dcaconsinit = 1; } /* wait for any pending transmission to finish */ @@ -991,7 +1002,7 @@ dcacnputc(dev, c) * we must let our interrupt through to keep things moving. * Otherwise, we clear the interrupt that we have caused. */ - if ((dca_tty[UNIT(dev)]->t_state & TS_BUSY) == 0) + if ((sc->sc_tty->t_state & TS_BUSY) == 0) stat = dca->dca_iir; splx(s); } diff --git a/sys/arch/hp300/dev/dcm.c b/sys/arch/hp300/dev/dcm.c index 3e7a886ab62..11f424db983 100644 --- a/sys/arch/hp300/dev/dcm.c +++ b/sys/arch/hp300/dev/dcm.c @@ -1,6 +1,7 @@ -/* $NetBSD: dcm.c,v 1.19 1995/10/04 08:39:14 thorpej Exp $ */ +/* $NetBSD: dcm.c,v 1.20 1995/12/02 18:18:50 thorpej Exp $ */ /* + * Copyright (c) 1995 Jason R. Thorpe. All rights reserved. * Copyright (c) 1988 University of Utah. * Copyright (c) 1982, 1986, 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -75,24 +76,12 @@ #define DEFAULT_BAUD_RATE 9600 #endif -int dcmprobe(), dcmintr(), dcmparam(); -void dcmstart(); +int dcmmatch(), dcmintr(), dcmparam(); +void dcmattach(), dcmstart(); struct driver dcmdriver = { - dcmprobe, "dcm", + dcmmatch, dcmattach, "dcm", }; -#define NDCMLINE (NDCM*4) - -struct tty *dcm_tty[NDCMLINE]; -struct modemreg *dcm_modem[NDCMLINE]; -char mcndlast[NDCMLINE]; /* XXX last modem status for line */ -int ndcm = NDCMLINE; - -int dcm_active; -int dcmsoftCAR[NDCM]; -struct dcmdevice *dcm_addr[NDCM]; -struct isr dcmisr[NDCM]; - struct speedtab dcmspeedtab[] = { 0, BR_0, 50, BR_50, @@ -130,7 +119,7 @@ struct dcmischeme { long dis_time; /* last time examined */ int dis_intr; /* recv interrupts during last interval */ int dis_char; /* characters read during last interval */ -} dcmischeme[NDCM]; +}; /* * Console support @@ -184,13 +173,12 @@ struct dcmstats { long rchars; /* # of recv chars */ long xsilo[DCMXBSIZE+2]; /* times this many chars xmit on one int */ long rsilo[DCMRBSIZE+2]; /* times this many chars read on one int */ -} dcmstats[NDCM]; +}; #endif -#define UNIT(x) minor(x) -#define BOARD(x) (((x) >> 2) & 0x3f) -#define PORT(x) ((x) & 3) -#define MKUNIT(b,p) (((b) << 2) | (p)) +#define DCMUNIT(x) minor(x) +#define DCMBOARD(x) (((x) >> 2) & 0x3f) +#define DCMPORT(x) ((x) & 3) /* * Conversion from "HP DCE" to almost-normal DCE: on the 638 8-port mux, @@ -217,7 +205,6 @@ struct dcmstats { * "RTS" 8 20 DTR * "SR" 23 4 RTS (often not needed) */ -#define FLAG_STDDCE 0x10 /* map inputs if this bit is set in flags */ #define hp2dce_in(ibits) (iconv[(ibits) & 0xf]) static char iconv[16] = { 0, MI_DM, MI_CTS, MI_CTS|MI_DM, @@ -227,28 +214,66 @@ static char iconv[16] = { MI_RI|MI_CD|MI_CTS|MI_DM }; -dcmprobe(hd) +#define NDCMPORT 4 /* XXX what about 8-port cards? */ + +struct dcm_softc { + struct hp_device *sc_hd; /* device info */ + struct dcmdevice *sc_dcm; /* pointer to hardware */ + struct tty *sc_tty[NDCMPORT]; /* our tty instances */ + struct modemreg *sc_modem[NDCMPORT]; /* modem control */ + char sc_mcndlast[NDCMPORT]; /* XXX last modem status for port */ + struct isr sc_isr; /* interrupt handler */ + short sc_softCAR; /* mask of ports with soft-carrier */ + struct dcmischeme sc_scheme; /* interrupt scheme for board */ + + /* + * Mask of soft-carrier bits in config flags. + * XXX What about 8-port cards? + */ +#define DCM_SOFTCAR 0x0000000f + + int sc_flags; /* misc. configuration info */ + + /* + * Bits for sc_flags + */ +#define DCM_ACTIVE 0x00000001 /* indicates board is alive */ +#define DCM_STDDCE 0x00000010 /* re-map DCE to standard */ +#define DCM_FLAGMASK (DCM_STDDCE) /* mask of valid bits in config flags */ + +#ifdef DCMSTATS + struct dcmstats sc_stats; /* metrics gathering */ +#endif +} dcm_softc[NDCM]; + +int +dcmmatch(hd) register struct hp_device *hd; { - register struct dcmdevice *dcm; - register int i; - register int timo = 0; + struct dcm_softc *sc = &dcm_softc[hd->hp_unit]; + struct dcmdevice *dcm; + int i, timo = 0; int s, brd, isconsole, mbits; dcm = (struct dcmdevice *)hd->hp_addr; if ((dcm->dcm_rsid & 0x1f) != DCMID) return (0); + brd = hd->hp_unit; - isconsole = (brd == BOARD(dcmconsole)); + isconsole = (brd == DCMBOARD(dcmconsole)); + /* * XXX selected console device (CONSUNIT) as determined by * dcmcnprobe does not agree with logical numbering imposed * by the config file (i.e. lowest address DCM is not unit * CONSUNIT). Don't recognize this card. */ - if (isconsole && dcm != dcm_addr[BOARD(dcmconsole)]) + if (isconsole && (dcm != sc->sc_dcm)) return (0); + sc->sc_hd = hd; + hd->hp_ipl = DCMIPL(dcm->dcm_ic); + /* * Empirically derived self-test magic */ @@ -275,64 +300,94 @@ dcmprobe(hd) dcm->dcm_ic = IC_ID; splx(s); - hd->hp_ipl = DCMIPL(dcm->dcm_ic); - dcm_addr[brd] = dcm; - dcm_active |= 1 << brd; - dcmsoftCAR[brd] = hd->hp_flags; - dcmisr[brd].isr_ipl = hd->hp_ipl; - dcmisr[brd].isr_arg = brd; - dcmisr[brd].isr_intr = dcmintr; - isrlink(&dcmisr[brd]); -#ifdef KGDB - if (major(kgdb_dev) == dcmmajor && BOARD(kgdb_dev) == brd) { - if (dcmconsole == UNIT(kgdb_dev)) - kgdb_dev = NODEV; /* can't debug over console port */ -#ifndef KGDB_CHEAT - /* - * The following could potentially be replaced - * by the corresponding code in dcmcnprobe. - */ - else { - (void) dcminit(kgdb_dev, kgdb_rate); - if (kgdb_debug_init) { - printf("dcm%d: ", UNIT(kgdb_dev)); - kgdb_connect(1); - } else - printf("dcm%d: kgdb enabled\n", UNIT(kgdb_dev)); - } - /* end could be replaced */ -#endif - } -#endif + return (1); +} + +void +dcmattach(hd) + register struct hp_device *hd; +{ + struct dcm_softc *sc = &dcm_softc[hd->hp_unit]; + struct dcmdevice *dcm; + int i, timo = 0; + int s, brd, isconsole, mbits; + + dcm = sc->sc_dcm = (struct dcmdevice *)hd->hp_addr; + + brd = hd->hp_unit; + isconsole = (brd == DCMBOARD(dcmconsole)); + + /* Extract configuration info from flags. */ + sc->sc_softCAR = (hd->hp_flags & DCM_SOFTCAR); + sc->sc_flags = (hd->hp_flags & DCM_FLAGMASK); + + /* Mark our unit as configured. */ + sc->sc_flags |= DCM_ACTIVE; + + /* Establish the interrupt handler. */ + sc->sc_isr.isr_ipl = hd->hp_ipl; + sc->sc_isr.isr_arg = brd; + sc->sc_isr.isr_intr = dcmintr; + isrlink(&sc->sc_isr); + if (dcmistype == DIS_TIMER) dcmsetischeme(brd, DIS_RESET|DIS_TIMER); else dcmsetischeme(brd, DIS_RESET|DIS_PERCHAR); /* load pointers to modem control */ - dcm_modem[MKUNIT(brd, 0)] = &dcm->dcm_modem0; - dcm_modem[MKUNIT(brd, 1)] = &dcm->dcm_modem1; - dcm_modem[MKUNIT(brd, 2)] = &dcm->dcm_modem2; - dcm_modem[MKUNIT(brd, 3)] = &dcm->dcm_modem3; + sc->sc_modem[0] = &dcm->dcm_modem0; + sc->sc_modem[1] = &dcm->dcm_modem1; + sc->sc_modem[2] = &dcm->dcm_modem2; + sc->sc_modem[3] = &dcm->dcm_modem3; + /* set DCD (modem) and CTS (flow control) on all ports */ - if (dcmsoftCAR[brd] & FLAG_STDDCE) + if (sc->sc_flags & DCM_STDDCE) mbits = hp2dce_in(MI_CD|MI_CTS); else mbits = MI_CD|MI_CTS; - for (i = 0; i < 4; i++) - dcm_modem[MKUNIT(brd, i)]->mdmmsk = mbits; + + for (i = 0; i < NDCMPORT; i++) + sc->sc_modem[i]->mdmmsk = mbits; dcm->dcm_ic = IC_IE; /* turn all interrupts on */ + /* * Need to reset baud rate, etc. of next print so reset dcmconsole. * Also make sure console is always "hardwired" */ if (isconsole) { dcmconsinit = 0; - dcmsoftCAR[brd] |= (1 << PORT(dcmconsole)); - printf("dcm%d: console on port %d\n", brd, PORT(dcmconsole)); + sc->sc_softCAR |= (1 << DCMPORT(dcmconsole)); + printf(": console on port %d\n", DCMPORT(dcmconsole)); + } else + printf("\n"); + +#ifdef KGDB + if (major(kgdb_dev) == dcmmajor && + DCMBOARD(DCMUNIT(kgdb_dev)) == brd) { + if (dcmconsole == DCMUNIT(kgdb_dev)) + kgdb_dev = NODEV; /* can't debug over console port */ +#ifndef KGDB_CHEAT + /* + * The following could potentially be replaced + * by the corresponding code in dcmcnprobe. + */ + else { + (void) dcminit(kgdb_dev, kgdb_rate); + if (kgdb_debug_init) { + printf("%s port %d: ", sc->sc_hd->hp_xname, + DCMPORT(DCMUNIT(kgdb_dev))); + kgdb_connect(1); + } else + printf("%s port %d: kgdb enabled\n", + sc->sc_hd->hp_xname, + DCMPORT(DCMUNIT(kgdb_dev))); + } + /* end could be replaced */ +#endif } - return (1); +#endif } /* ARGSUSED */ @@ -342,18 +397,27 @@ dcmopen(dev, flag, mode, p) int flag, mode; struct proc *p; { - register struct tty *tp; - register int unit, brd; + struct dcm_softc *sc; + struct tty *tp; + int unit, brd, port; int error = 0, mbits, s; - unit = UNIT(dev); - brd = BOARD(unit); - if (unit >= NDCMLINE || (dcm_active & (1 << brd)) == 0) + unit = DCMUNIT(dev); + brd = DCMBOARD(unit); + port = DCMPORT(unit); + + if ((brd >= NDCM) || (port >= NDCMPORT)) return (ENXIO); - if (!dcm_tty[unit]) - tp = dcm_tty[unit] = ttymalloc(); + + sc = &dcm_softc[brd]; + if ((sc->sc_flags & DCM_ACTIVE) == 0) + return (ENXIO); + + if (sc->sc_tty[port] == NULL) + tp = sc->sc_tty[port] = ttymalloc(); else - tp = dcm_tty[unit]; + tp = sc->sc_tty[port]; + tp->t_oproc = dcmstart; tp->t_param = dcmparam; tp->t_dev = dev; @@ -385,19 +449,21 @@ dcmopen(dev, flag, mode, p) /* Set modem control state. */ mbits = MO_ON; - if (dcmsoftCAR[brd] & FLAG_STDDCE) + if (sc->sc_flags & DCM_STDDCE) mbits |= MO_SR; /* pin 23, could be used as RTS */ + (void) dcmmctl(dev, mbits, DMSET); /* enable port */ /* Set soft-carrier if so configured. */ - if ((dcmsoftCAR[brd] & (1 << PORT(unit))) || + if ((sc->sc_softCAR & (1 << port)) || (dcmmctl(dev, MO_OFF, DMGET) & MI_CD)) tp->t_state |= TS_CARR_ON; #ifdef DEBUG if (dcmdebug & DDB_MODEM) - printf("dcm%d: dcmopen port %d softcarr %c\n", - brd, unit, (tp->t_state & TS_CARR_ON) ? '1' : '0'); + printf("%s: dcmopen port %d softcarr %c\n", + sc->sc_hd->hp_xname, port, + (tp->t_state & TS_CARR_ON) ? '1' : '0'); #endif /* Wait for carrier if necessary. */ @@ -417,8 +483,8 @@ dcmopen(dev, flag, mode, p) #ifdef DEBUG if (dcmdebug & DDB_OPENCLOSE) - printf("dcmopen: u %x st %x fl %x\n", - unit, tp->t_state, tp->t_flags); + printf("%s port %d: dcmopen: st %x fl %x\n", + sc->sc_hd->hp_xname, port, tp->t_state, tp->t_flags); #endif if (error == 0) error = (*linesw[tp->t_line].l_open)(dev, tp); @@ -433,11 +499,17 @@ dcmclose(dev, flag, mode, p) int flag, mode; struct proc *p; { - register struct tty *tp; - int s, unit; + int s, unit, board, port; + struct dcm_softc *sc; + struct tty *tp; - unit = UNIT(dev); - tp = dcm_tty[unit]; + unit = DCMUNIT(dev); + board = DCMBOARD(unit); + port = DCMPORT(unit); + + sc = &dcm_softc[board]; + tp = sc->sc_tty[port]; + (*linesw[tp->t_line].l_close)(tp, flag); s = spltty(); @@ -447,14 +519,14 @@ dcmclose(dev, flag, mode, p) (void) dcmmctl(dev, MO_OFF, DMSET); #ifdef DEBUG if (dcmdebug & DDB_OPENCLOSE) - printf("dcmclose: u %x st %x fl %x\n", - unit, tp->t_state, tp->t_flags); + printf("%s port %d: dcmclose: st %x fl %x\n", + sc->sc_hd->hp_xname, port, tp->t_state, tp->t_flags); #endif splx(s); ttyclose(tp); #if 0 ttyfree(tp); - dcm_tty[unit] = (struct tty *)0; + sc->sc_tty[port] == NULL; #endif return (0); } @@ -465,7 +537,16 @@ dcmread(dev, uio, flag) struct uio *uio; int flag; { - register struct tty *tp = dcm_tty[UNIT(dev)]; + int unit, board, port; + struct dcm_softc *sc; + register struct tty *tp; + + unit = DCMUNIT(dev); + board = DCMBOARD(unit); + port = DCMPORT(unit); + + sc = &dcm_softc[board]; + tp = sc->sc_tty[port]; return ((*linesw[tp->t_line].l_read)(tp, uio, flag)); } @@ -476,7 +557,16 @@ dcmwrite(dev, uio, flag) struct uio *uio; int flag; { - register struct tty *tp = dcm_tty[UNIT(dev)]; + int unit, board, port; + struct dcm_softc *sc; + register struct tty *tp; + + unit = DCMUNIT(dev); + board = DCMBOARD(unit); + port = DCMPORT(unit); + + sc = &dcm_softc[board]; + tp = sc->sc_tty[port]; return ((*linesw[tp->t_line].l_write)(tp, uio, flag)); } @@ -485,18 +575,26 @@ struct tty * dcmtty(dev) dev_t dev; { + int unit, board, port; + struct dcm_softc *sc; - return (dcm_tty[UNIT(dev)]); + unit = DCMUNIT(dev); + board = DCMBOARD(unit); + port = DCMPORT(unit); + + sc = &dcm_softc[board]; + + return (sc->sc_tty[port]); } int dcmintr(brd) register int brd; { - register struct dcmdevice *dcm = dcm_addr[brd]; - register struct dcmischeme *dis; - register int unit = MKUNIT(brd, 0); - register int code, i; + struct dcm_softc *sc = &dcm_softc[brd]; + struct dcmdevice *dcm = sc->sc_dcm; + struct dcmischeme *dis = &sc->sc_scheme; + int code, i; int pcnd[4], mcode, mcnd[4]; /* @@ -511,8 +609,8 @@ dcmintr(brd) for (i = 0; i < 4; i++) { pcnd[i] = dcm->dcm_icrtab[i].dcm_data; dcm->dcm_icrtab[i].dcm_data = 0; - code = dcm_modem[unit+i]->mdmin; - if (dcmsoftCAR[brd] & FLAG_STDDCE) + code = sc->sc_modem[i]->mdmin; + if (sc->sc_flags & DCM_STDDCE) code = hp2dce_in(code); mcnd[i] = code; } @@ -524,34 +622,34 @@ dcmintr(brd) #ifdef DEBUG if (dcmdebug & DDB_INTR) { - printf("dcmintr(%d): iir %x pc %x/%x/%x/%x ", - brd, code, pcnd[0], pcnd[1], pcnd[2], pcnd[3]); + printf("%s: dcmintr: iir %x pc %x/%x/%x/%x ", + sc->sc_hd->hp_xname, code, pcnd[0], pcnd[1], + pcnd[2], pcnd[3]); printf("miir %x mc %x/%x/%x/%x\n", mcode, mcnd[0], mcnd[1], mcnd[2], mcnd[3]); } #endif if (code & IIR_TIMEO) - dcmrint(brd, dcm); + dcmrint(sc); if (code & IIR_PORT0) - dcmpint(unit+0, pcnd[0], dcm); + dcmpint(sc, 0, pcnd[0]); if (code & IIR_PORT1) - dcmpint(unit+1, pcnd[1], dcm); + dcmpint(sc, 1, pcnd[1]); if (code & IIR_PORT2) - dcmpint(unit+2, pcnd[2], dcm); + dcmpint(sc, 2, pcnd[2]); if (code & IIR_PORT3) - dcmpint(unit+3, pcnd[3], dcm); + dcmpint(sc, 3, pcnd[3]); if (code & IIR_MODM) { if (mcode == 0 || mcode & 0x1) /* mcode==0 -> 98642 board */ - dcmmint(unit+0, mcnd[0], dcm); + dcmmint(sc, 0, mcnd[0]); if (mcode & 0x2) - dcmmint(unit+1, mcnd[1], dcm); + dcmmint(sc, 1, mcnd[1]); if (mcode & 0x4) - dcmmint(unit+2, mcnd[2], dcm); + dcmmint(sc, 2, mcnd[2]); if (mcode & 0x8) - dcmmint(unit+3, mcnd[3], dcm); + dcmmint(sc, 3, mcnd[3]); } - dis = &dcmischeme[brd]; /* * Chalk up a receiver interrupt if the timer running or one of * the ports reports a special character interrupt. @@ -584,7 +682,7 @@ dcmintr(brd) */ else if (!dis->dis_perchar && dis->dis_intr > dis->dis_char) { dcmsetischeme(brd, DIS_PERCHAR); - dcmrint(brd, dcm); + dcmrint(sc); } dis->dis_intr = dis->dis_char = 0; dis->dis_time = time.tv_sec; @@ -597,50 +695,45 @@ dcmintr(brd) * First, it might be a special character (exception interrupt); * Second, it may be a buffer empty (transmit interrupt); */ -dcmpint(unit, code, dcm) - int unit, code; - struct dcmdevice *dcm; +dcmpint(sc, port, code) + struct dcm_softc *sc; + int port, code; { - struct tty *tp = dcm_tty[unit]; if (code & IT_SPEC) - dcmreadbuf(unit, dcm, tp); + dcmreadbuf(sc, port); if (code & IT_TX) - dcmxint(unit, dcm, tp); + dcmxint(sc, port); } -dcmrint(brd, dcm) - int brd; - register struct dcmdevice *dcm; +dcmrint(sc) + struct dcm_softc *sc; { - register int i, unit; - register struct tty *tp; + int port; - unit = MKUNIT(brd, 0); - tp = dcm_tty[unit]; - for (i = 0; i < 4; i++, tp++, unit++) - dcmreadbuf(unit, dcm, tp); + for (port = 0; port < NDCMPORT; port++) + dcmreadbuf(sc, port); } -dcmreadbuf(unit, dcm, tp) - int unit; - register struct dcmdevice *dcm; - register struct tty *tp; +dcmreadbuf(sc, port) + struct dcm_softc *sc; + int port; { - int port = PORT(unit); - register struct dcmpreg *pp = dcm_preg(dcm, port); - register struct dcmrfifo *fifo; - register int c, stat; - register unsigned head; + struct dcmdevice *dcm = sc->sc_dcm; + struct tty *tp = sc->sc_tty[port]; + struct dcmpreg *pp = dcm_preg(dcm, port); + struct dcmrfifo *fifo; + int c, stat; + u_int head; int nch = 0; #ifdef DCMSTATS - struct dcmstats *dsp = &dcmstats[BOARD(unit)]; + struct dcmstats *dsp = &sc->sc_stats; dsp->rints++; #endif if ((tp->t_state & TS_ISOPEN) == 0) { #ifdef KGDB - if ((makedev(dcmmajor, unit) == kgdb_dev) && + if ((makedev(dcmmajor, minor(tp->t_dev)) == kgdb_dev) && (head = pp->r_head & RX_MASK) != (pp->r_tail & RX_MASK) && dcm->dcm_rfifos[3-port][head>>1].data_char == FRAME_START) { pp->r_head = (head + 2) & RX_MASK; @@ -671,8 +764,9 @@ dcmreadbuf(unit, dcm, tp) #ifdef DEBUG if (dcmdebug & DDB_INPUT) - printf("dcmreadbuf(%d): c%x('%c') s%x f%x h%x t%x\n", - unit, c&0xFF, c, stat&0xFF, + printf("%s port %d: dcmreadbuf: c%x('%c') s%x f%x h%x t%x\n", + sc->sc_hd->hp_xname, port, + c&0xFF, c, stat&0xFF, tp->t_flags, head, pp->r_tail); #endif /* @@ -681,8 +775,9 @@ dcmreadbuf(unit, dcm, tp) if (stat & RD_MASK) { #ifdef DEBUG if (dcmdebug & (DDB_INPUT|DDB_SIOERR)) - printf("dcmreadbuf(%d): err: c%x('%c') s%x\n", - unit, stat, c&0xFF, c); + printf("%s port %d: dcmreadbuf: err: c%x('%c') s%x\n", + sc->sc_hd->hp_xname, port, + stat, c&0xFF, c); #endif if (stat & (RD_BD | RD_FE)) c |= TTY_FE; @@ -690,14 +785,17 @@ dcmreadbuf(unit, dcm, tp) c |= TTY_PE; else if (stat & RD_OVF) log(LOG_WARNING, - "dcm%d: silo overflow\n", unit); + "%s port %d: silo overflow\n", + sc->sc_hd->hp_xname, port); else if (stat & RD_OE) log(LOG_WARNING, - "dcm%d: uart overflow\n", unit); + "%s port %d: uart overflow\n", + sc->sc_hd->hp_xname, port); } (*linesw[tp->t_line].l_rint)(c, tp); } - dcmischeme[BOARD(unit)].dis_char += nch; + sc->sc_scheme.dis_char += nch; + #ifdef DCMSTATS dsp->rchars += nch; if (nch <= DCMRBSIZE) @@ -707,33 +805,35 @@ dcmreadbuf(unit, dcm, tp) #endif } -dcmxint(unit, dcm, tp) - int unit; - struct dcmdevice *dcm; - register struct tty *tp; +dcmxint(sc, port) + struct dcm_softc *sc; + int port; { + struct tty *tp = sc->sc_tty[port]; + tp->t_state &= ~TS_BUSY; if (tp->t_state & TS_FLUSH) tp->t_state &= ~TS_FLUSH; (*linesw[tp->t_line].l_start)(tp); } -dcmmint(unit, mcnd, dcm) - register int unit; - register struct dcmdevice *dcm; - int mcnd; +dcmmint(sc, port, mcnd) + struct dcm_softc *sc; + int port, mcnd; { - register struct tty *tp; int delta; + struct tty *tp; + struct dcmdevice *dcm = sc->sc_dcm; + + tp = sc->sc_tty[port]; #ifdef DEBUG if (dcmdebug & DDB_MODEM) - printf("dcmmint: port %d mcnd %x mcndlast %x\n", - unit, mcnd, mcndlast[unit]); + printf("%s port %d: dcmmint: mcnd %x mcndlast %x\n", + sc->sc_hd->hp_xname, port, mcnd, sc->sc_mcndlast[port]); #endif - tp = dcm_tty[unit]; - delta = mcnd ^ mcndlast[unit]; - mcndlast[unit] = mcnd; + delta = mcnd ^ sc->sc_mcndlast[port]; + sc->sc_mcndlast[port] = mcnd; if ((delta & MI_CTS) && (tp->t_state & TS_ISOPEN) && (tp->t_flags & CCTS_OFLOW)) { if (mcnd & MI_CTS) { @@ -745,11 +845,11 @@ dcmmint(unit, mcnd, dcm) if (delta & MI_CD) { if (mcnd & MI_CD) (void)(*linesw[tp->t_line].l_modem)(tp, 1); - else if ((dcmsoftCAR[BOARD(unit)] & (1 << PORT(unit))) == 0 && + else if ((sc->sc_softCAR & (1 << port)) == 0 && (*linesw[tp->t_line].l_modem)(tp, 0) == 0) { - dcm_modem[unit]->mdmout = MO_OFF; + sc->sc_modem[port]->mdmout = MO_OFF; SEM_LOCK(dcm); - dcm->dcm_modemchng |= 1<<(unit & 3); + dcm->dcm_modemchng |= (1 << port); dcm->dcm_cr |= CR_MODM; SEM_UNLOCK(dcm); DELAY(10); /* time to change lines */ @@ -765,18 +865,24 @@ dcmioctl(dev, cmd, data, flag, p) int flag; struct proc *p; { - register struct tty *tp; - register int unit = UNIT(dev); - register struct dcmdevice *dcm; - register int board, port; + struct dcm_softc *sc; + struct tty *tp; + struct dcmdevice *dcm; + int board, port, unit = DCMUNIT(dev); int error, s; + + port = DCMPORT(unit); + board = DCMBOARD(unit); + + sc = &dcm_softc[board]; + dcm = sc->sc_dcm; + tp = sc->sc_tty[port]; #ifdef DEBUG if (dcmdebug & DDB_IOCTL) - printf("dcmioctl: unit %d cmd %x data %x flag %x\n", - unit, cmd, *data, flag); + printf("%s port %d: dcmioctl: cmd %x data %x flag %x\n", + sc->sc_hd->hp_xname, port, cmd, *data, flag); #endif - tp = dcm_tty[unit]; error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); if (error >= 0) return (error); @@ -784,9 +890,6 @@ dcmioctl(dev, cmd, data, flag, p) if (error >= 0) return (error); - port = PORT(unit); - board = BOARD(unit); - dcm = dcm_addr[board]; switch (cmd) { case TIOCSBRK: /* @@ -836,7 +939,7 @@ dcmioctl(dev, cmd, data, flag, p) case TIOCGFLAGS: { int bits = 0; - if ((dcmsoftCAR[board] & (1 << port))) + if ((sc->sc_softCAR & (1 << port))) bits |= TIOCFLAG_SOFTCAR; if (tp->t_cflag & CLOCAL) @@ -856,9 +959,9 @@ dcmioctl(dev, cmd, data, flag, p) userbits = *(int *)data; if ((userbits & TIOCFLAG_SOFTCAR) || - ((board == BOARD(dcmconsole)) && - (port == PORT(dcmconsole)))) - dcmsoftCAR[board] |= (1 << port); + ((board == DCMBOARD(dcmconsole)) && + (port == DCMPORT(dcmconsole)))) + sc->sc_softCAR |= (1 << port); if (userbits & TIOCFLAG_CLOCAL) tp->t_cflag |= CLOCAL; @@ -877,10 +980,18 @@ dcmparam(tp, t) register struct tty *tp; register struct termios *t; { - register struct dcmdevice *dcm; - register int port, mode, cflag = t->c_cflag; + struct dcm_softc *sc; + struct dcmdevice *dcm; + int unit, board, port, mode, cflag = t->c_cflag; int ospeed = ttspeedtab(t->c_ospeed, dcmspeedtab); + unit = DCMUNIT(tp->t_dev); + board = DCMBOARD(unit); + port = DCMPORT(unit); + + sc = &dcm_softc[board]; + dcm = sc->sc_dcm; + /* check requested parameters */ if (ospeed < 0 || (t->c_ispeed && t->c_ispeed != t->c_ospeed)) return (EINVAL); @@ -889,7 +1000,7 @@ dcmparam(tp, t) tp->t_ospeed = t->c_ospeed; tp->t_cflag = cflag; if (ospeed == 0) { - (void) dcmmctl(UNIT(tp->t_dev), MO_OFF, DMSET); + (void) dcmmctl(DCMUNIT(tp->t_dev), MO_OFF, DMSET); return (0); } @@ -916,13 +1027,11 @@ dcmparam(tp, t) mode |= LC_1STOP; #ifdef DEBUG if (dcmdebug & DDB_PARAM) - printf("dcmparam(%d): cflag %x mode %x speed %d uperch %d\n", - UNIT(tp->t_dev), cflag, mode, tp->t_ospeed, + printf("%s port %d: dcmparam: cflag %x mode %x speed %d uperch %d\n", + sc->sc_hd->hp_xname, port, cflag, mode, tp->t_ospeed, DCM_USPERCH(tp->t_ospeed)); #endif - port = PORT(tp->t_dev); - dcm = dcm_addr[BOARD(tp->t_dev)]; /* * Wait for transmitter buffer to empty. */ @@ -949,28 +1058,35 @@ void dcmstart(tp) register struct tty *tp; { - register struct dcmdevice *dcm; - register struct dcmpreg *pp; - register struct dcmtfifo *fifo; - register char *bp; - register unsigned tail, next; - register int port, nch; - unsigned head; + struct dcm_softc *sc; + struct dcmdevice *dcm; + struct dcmpreg *pp; + struct dcmtfifo *fifo; + char *bp; + u_int head, tail, next; + int unit, board, port, nch; char buf[16]; int s; #ifdef DCMSTATS - struct dcmstats *dsp = &dcmstats[BOARD(tp->t_dev)]; + struct dcmstats *dsp = &sc->sc_stats; int tch = 0; #endif + unit = DCMUNIT(tp->t_dev); + board = DCMBOARD(unit); + port = DCMPORT(unit); + + sc = &dcm_softc[board]; + dcm = sc->sc_dcm; + s = spltty(); #ifdef DCMSTATS dsp->xints++; #endif #ifdef DEBUG if (dcmdebug & DDB_OUTPUT) - printf("dcmstart(%d): state %x flags %x outcc %d\n", - UNIT(tp->t_dev), tp->t_state, tp->t_flags, + printf("%s port %d: dcmstart: state %x flags %x outcc %d\n", + sc->sc_hd->hp_xname, port, tp->t_state, tp->t_flags, tp->t_outq.c_cc); #endif if (tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP)) @@ -989,8 +1105,6 @@ dcmstart(tp) goto out; } - dcm = dcm_addr[BOARD(tp->t_dev)]; - port = PORT(tp->t_dev); pp = dcm_preg(dcm, port); tail = pp->t_tail & TX_MASK; next = (tail + 1) & TX_MASK; @@ -1053,8 +1167,8 @@ again: } #ifdef DEBUG if (dcmdebug & DDB_INTR) - printf("dcmstart(%d): head %x tail %x outqcc %d\n", - UNIT(tp->t_dev), head, tail, tp->t_outq.c_cc); + printf("%s port %d: dcmstart(%d): head %x tail %x outqcc %d\n", + sc->sc_hd->hp_xname, port, head, tail, tp->t_outq.c_cc); #endif out: #ifdef DCMSTATS @@ -1093,39 +1207,43 @@ dcmmctl(dev, bits, how) dev_t dev; int bits, how; { - register struct dcmdevice *dcm; - int s, unit, brd, hit = 0; + struct dcm_softc *sc; + struct dcmdevice *dcm; + int s, unit, brd, port, hit = 0; + + unit = DCMUNIT(dev); + brd = DCMBOARD(unit); + port = DCMPORT(unit); + sc = &dcm_softc[brd]; + dcm = sc->sc_dcm; - unit = UNIT(dev); #ifdef DEBUG if (dcmdebug & DDB_MODEM) - printf("dcmmctl(%d) unit %d bits 0x%x how %x\n", - BOARD(unit), unit, bits, how); + printf("%s port %d: dcmmctl: bits 0x%x how %x\n", + sc->sc_hd->hp_xname, port, bits, how); #endif - brd = BOARD(unit); - dcm = dcm_addr[brd]; s = spltty(); - switch (how) { + switch (how) { case DMSET: - dcm_modem[unit]->mdmout = bits; + sc->sc_modem[port]->mdmout = bits; hit++; break; case DMBIS: - dcm_modem[unit]->mdmout |= bits; + sc->sc_modem[port]->mdmout |= bits; hit++; break; case DMBIC: - dcm_modem[unit]->mdmout &= ~bits; + sc->sc_modem[port]->mdmout &= ~bits; hit++; break; case DMGET: - bits = dcm_modem[unit]->mdmin; - if (dcmsoftCAR[brd] & FLAG_STDDCE) + bits = sc->sc_modem[port]->mdmin; + if (sc->sc_flags & DCM_STDDCE) bits = hp2dce_in(bits); break; } @@ -1146,20 +1264,21 @@ dcmmctl(dev, bits, how) dcmsetischeme(brd, flags) int brd, flags; { - register struct dcmdevice *dcm = dcm_addr[brd]; - register struct dcmischeme *dis = &dcmischeme[brd]; - register int i; + struct dcm_softc *sc = &dcm_softc[brd]; + struct dcmdevice *dcm = sc->sc_dcm; + struct dcmischeme *dis = &sc->sc_scheme; + int i; u_char mask; int perchar = flags & DIS_PERCHAR; #ifdef DEBUG if (dcmdebug & DDB_INTSCHM) - printf("dcmsetischeme(%d, %d): cur %d, ints %d, chars %d\n", - brd, perchar, dis->dis_perchar, + printf("%s: dcmsetischeme(%d): cur %d, ints %d, chars %d\n", + sc->sc_hd->hp_xname, perchar, dis->dis_perchar, dis->dis_intr, dis->dis_char); if ((flags & DIS_RESET) == 0 && perchar == dis->dis_perchar) { - printf("dcmsetischeme(%d): redundent request %d\n", - brd, perchar); + printf("%s: dcmsetischeme: redundent request %d\n", + sc->sc_hd->hp_xname, perchar); return; } #endif @@ -1177,10 +1296,12 @@ dcmsetischeme(brd, flags) * chars for any port on the board. */ if (!perchar) { - register struct tty *tp = dcm_tty[MKUNIT(brd, 0)]; + register struct tty *tp; int c; - for (i = 0; i < 4; i++, tp++) { + for (i = 0; i < NDCMPORT; i++) { + tp = sc->sc_tty[i]; + if ((c = tp->t_cc[VSTART]) != _POSIX_VDISABLE) dcm->dcm_bmap[c].data_data |= (1 << i); if ((c = tp->t_cc[VSTOP]) != _POSIX_VDISABLE) @@ -1213,7 +1334,9 @@ void dcmcnprobe(cp) struct consdev *cp; { - register struct hp_hw *hw; + struct dcm_softc *sc; + struct dcmdevice *dcm; + struct hp_hw *hw; int unit; /* locate the major number */ @@ -1233,33 +1356,39 @@ dcmcnprobe(cp) cp->cn_pri = CN_DEAD; return; } + unit = CONUNIT; - dcm_addr[BOARD(CONUNIT)] = (struct dcmdevice *)hw->hw_kva; + sc = &dcm_softc[DCMBOARD(CONUNIT)]; + dcm = sc->sc_dcm = (struct dcmdevice *)hw->hw_kva; /* initialize required fields */ cp->cn_dev = makedev(dcmmajor, unit); - switch (dcm_addr[BOARD(unit)]->dcm_rsid) { + switch (dcm->dcm_rsid) { case DCMID: cp->cn_pri = CN_NORMAL; break; + case DCMID|DCMCON: cp->cn_pri = CN_REMOTE; break; + default: cp->cn_pri = CN_DEAD; return; } + /* * If dcmconsole is initialized, raise our priority. */ - if (dcmconsole == UNIT(unit)) + if (dcmconsole == unit) cp->cn_pri = CN_REMOTE; #ifdef KGDB_CHEAT /* * This doesn't currently work, at least not with ite consoles; * the console hasn't been initialized yet. */ - if (major(kgdb_dev) == dcmmajor && BOARD(kgdb_dev) == BOARD(unit)) { + if (major(kgdb_dev) == dcmmajor && + DCMBOARD(DCMUNIT(kgdb_dev)) == DCMBOARD(unit)) { (void) dcminit(kgdb_dev, kgdb_rate); if (kgdb_debug_init) { /* @@ -1268,7 +1397,7 @@ dcmcnprobe(cp) * has been selected already and will init * on the first putc. */ - printf("dcm%d: ", UNIT(kgdb_dev)); + printf("dcm%d: ", DCMUNIT(kgdb_dev)); kgdb_connect(1); } } @@ -1279,26 +1408,37 @@ void dcmcninit(cp) struct consdev *cp; { + dcminit(cp->cn_dev, dcmdefaultrate); dcmconsinit = 1; - dcmconsole = UNIT(cp->cn_dev); + dcmconsole = DCMUNIT(cp->cn_dev); } dcminit(dev, rate) dev_t dev; int rate; { - register struct dcmdevice *dcm = dcm_addr[BOARD(dev)]; - int s, mode, port; + struct dcm_softc *sc; + struct dcmdevice *dcm; + int s, mode, unit, board, port; + + unit = DCMUNIT(dev); + board = DCMBOARD(unit); + port = DCMPORT(unit); + + sc = &dcm_softc[board]; + dcm = sc->sc_dcm; - port = PORT(dev); mode = LC_8BITS | LC_1STOP; + s = splhigh(); + /* * Wait for transmitter buffer to empty. */ while (dcm->dcm_thead[port].ptr != dcm->dcm_ttail[port].ptr) DELAY(DCM_USPERCH(rate)); + /* * Make changes known to hardware. */ @@ -1308,6 +1448,7 @@ dcminit(dev, rate) dcm->dcm_cmdtab[port].dcm_data |= CT_CON; dcm->dcm_cr |= (1 << port); SEM_UNLOCK(dcm); + /* * Delay for config change to take place. Weighted by baud. * XXX why do we do this? @@ -1320,14 +1461,21 @@ int dcmcngetc(dev) dev_t dev; { - register struct dcmdevice *dcm = dcm_addr[BOARD(dev)]; - register struct dcmrfifo *fifo; - register struct dcmpreg *pp; - register unsigned head; - int s, c, stat, port; + struct dcm_softc *sc; + struct dcmdevice *dcm; + struct dcmrfifo *fifo; + struct dcmpreg *pp; + u_int head; + int s, c, stat, unit, board, port; + + unit = DCMUNIT(dev); + board = DCMBOARD(unit); + port = DCMPORT(unit); - port = PORT(dev); + sc = &dcm_softc[board]; + dcm = sc->sc_dcm; pp = dcm_preg(dcm, port); + s = splhigh(); head = pp->r_head & RX_MASK; fifo = &dcm->dcm_rfifos[3-port][head>>1]; @@ -1357,13 +1505,20 @@ dcmcnputc(dev, c) dev_t dev; int c; { - register struct dcmdevice *dcm = dcm_addr[BOARD(dev)]; - register struct dcmpreg *pp; + struct dcm_softc *sc; + struct dcmdevice *dcm; + struct dcmpreg *pp; unsigned tail; - int s, port, stat; + int s, unit, board, port, stat; - port = PORT(dev); + unit = DCMUNIT(dev); + board = DCMBOARD(unit); + port = DCMPORT(unit); + + sc = &dcm_softc[board]; + dcm = sc->sc_dcm; pp = dcm_preg(dcm, port); + s = splhigh(); #ifdef KGDB if (dev != kgdb_dev) diff --git a/sys/arch/hp300/dev/device.h b/sys/arch/hp300/dev/device.h index cb76e0c60ae..e1c87334a40 100644 --- a/sys/arch/hp300/dev/device.h +++ b/sys/arch/hp300/dev/device.h @@ -1,4 +1,4 @@ -/* $NetBSD: device.h,v 1.5 1995/03/28 18:15:55 jtc Exp $ */ +/* $NetBSD: device.h,v 1.6 1995/12/02 18:21:54 thorpej Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -36,7 +36,8 @@ */ struct driver { - int (*d_init)(); + int (*d_match)(); + void (*d_attach)(); char *d_name; int (*d_start)(); int (*d_go)(); @@ -44,6 +45,16 @@ struct driver { int (*d_done)(); }; +struct hp_hw { + caddr_t hw_pa; /* physical address of control space */ + int hw_size; /* size of control space */ + caddr_t hw_kva; /* kernel virtual address of control space */ + short hw_id; /* HW returned id */ + short hw_secid; /* secondary HW id (displays) */ + short hw_type; /* type (defined below) */ + short hw_sc; /* select code (if applicable) */ +}; + struct hp_ctlr { struct driver *hp_driver; int hp_unit; @@ -51,6 +62,8 @@ struct hp_ctlr { char *hp_addr; int hp_flags; int hp_ipl; + struct hp_hw *hp_args; + char hp_xname[8]; }; struct hp_device { @@ -64,6 +77,8 @@ struct hp_device { int hp_flags; int hp_alive; int hp_ipl; + struct hp_hw *hp_args; + char hp_xname[8]; }; struct devqueue { @@ -78,16 +93,6 @@ struct devqueue { #define MAXCTLRS 16 /* Size of HW table (arbitrary) */ #define MAXSLAVES 8 /* Slaves per controller (HPIB/SCSI limit) */ -struct hp_hw { - caddr_t hw_pa; /* physical address of control space */ - int hw_size; /* size of control space */ - caddr_t hw_kva; /* kernel virtual address of control space */ - short hw_id; /* HW returned id */ - short hw_secid; /* secondary HW id (displays) */ - short hw_type; /* type (defined below) */ - short hw_sc; /* select code (if applicable) */ -}; - /* bus types */ #define B_MASK 0xE000 #define B_DIO 0x2000 diff --git a/sys/arch/hp300/dev/dma.c b/sys/arch/hp300/dev/dma.c index e788b4497e3..cb22512d334 100644 --- a/sys/arch/hp300/dev/dma.c +++ b/sys/arch/hp300/dev/dma.c @@ -1,6 +1,7 @@ -/* $NetBSD: dma.c,v 1.5 1994/10/26 07:23:40 cgd Exp $ */ +/* $NetBSD: dma.c,v 1.6 1995/12/02 02:46:45 thorpej Exp $ */ /* + * Copyright (c) 1995 Jason R. Thorpe. * Copyright (c) 1982, 1990, 1993 * The Regents of the University of California. All rights reserved. * @@ -72,16 +73,23 @@ struct dma_chain { char *dc_addr; }; +struct dma_channel { + struct dma_softc *dm_softc; /* pointer back to softc */ + struct dmadevice *dm_hwaddr; /* registers if DMA_C */ + struct dmaBdevice *dm_Bhwaddr; /* registers if not DMA_C */ + char dm_flags; /* misc. flags */ + u_short dm_cmd; /* DMA controller command */ + struct dma_chain *dm_cur; /* current segment */ + struct dma_chain *dm_last; /* last segment */ + struct dma_chain dm_chain[DMAMAXIO]; /* all segments */ +}; + struct dma_softc { - struct dmadevice *sc_hwaddr; - struct dmaBdevice *sc_Bhwaddr; - char sc_type; - char sc_flags; - u_short sc_cmd; - struct dma_chain *sc_cur; - struct dma_chain *sc_last; - struct dma_chain sc_chain[DMAMAXIO]; -} dma_softc[NDMA]; + char *sc_xname; /* XXX external name */ + struct dmareg *sc_dmareg; /* pointer to our hardware */ + struct dma_channel sc_chan[NDMACHAN]; /* 2 channels */ + char sc_type; /* A, B, or C */ +} Dma_softc; /* types */ #define DMA_B 0 @@ -92,7 +100,7 @@ struct dma_softc { #define DMAF_VCFLUSH 0x02 #define DMAF_NOINTR 0x04 -struct devqueue dmachan[NDMA + 1]; +struct devqueue dmachan[NDMACHAN + 1]; int dmaintr(); #ifdef DEBUG @@ -103,54 +111,75 @@ int dmadebug = 0; #define DDB_IO 0x08 void dmatimeout __P((void *)); -int dmatimo[NDMA]; +int dmatimo[NDMACHAN]; -long dmahits[NDMA]; -long dmamisses[NDMA]; -long dmabyte[NDMA]; -long dmaword[NDMA]; -long dmalword[NDMA]; +long dmahits[NDMACHAN]; +long dmamisses[NDMACHAN]; +long dmabyte[NDMACHAN]; +long dmaword[NDMACHAN]; +long dmalword[NDMACHAN]; #endif void dmainit() { - register struct dmareg *dma = (struct dmareg *)DMA_BASE; - register struct dma_softc *dc; - register int i; + struct dma_softc *sc = &Dma_softc; + struct dmareg *dma; + struct dma_channel *dc; + int i; char rev; + /* There's just one. */ + sc->sc_dmareg = (struct dmareg *)DMA_BASE; + dma = sc->sc_dmareg; + sc->sc_xname = "dma0"; + /* - * Determine the DMA type. - * Don't know how to easily differentiate the A and B cards, + * Determine the DMA type. A DMA_A or DMA_B will fail the + * following probe. + * + * XXX Don't know how to easily differentiate the A and B cards, * so we just hope nobody has an A card (A cards will work if * DMAINTLVL is set to 3). */ - if (!badbaddr((char *)&dma->dma_id[2])) - rev = dma->dma_id[2]; - else { + if (badbaddr((char *)&dma->dma_id[2])) { rev = 'B'; #if !defined(HP320) panic("dmainit: DMA card requires hp320 support"); #endif - } + } else + rev = dma->dma_id[2]; - dc = &dma_softc[0]; - for (i = 0; i < NDMA; i++) { - dc->sc_hwaddr = (i & 1) ? &dma->dma_chan1 : &dma->dma_chan0; - dc->sc_Bhwaddr = (i & 1) ? &dma->dma_Bchan1 : &dma->dma_Bchan0; - dc->sc_type = rev == 'B' ? DMA_B : DMA_C; - dc++; + sc->sc_type = (rev == 'B') ? DMA_B : DMA_C; + + for (i = 0; i < NDMACHAN; i++) { + dc = &sc->sc_chan[i]; + dc->dm_softc = sc; + switch (i) { + case 0: + dc->dm_hwaddr = &dma->dma_chan0; + dc->dm_Bhwaddr = &dma->dma_Bchan0; + break; + + case 1: + dc->dm_hwaddr = &dma->dma_chan1; + dc->dm_Bhwaddr = &dma->dma_Bchan1; + break; + + default: + panic("dmainit: more than 2 channels?"); + /* NOTREACHED */ + } dmachan[i].dq_forw = dmachan[i].dq_back = &dmachan[i]; } dmachan[i].dq_forw = dmachan[i].dq_back = &dmachan[i]; #ifdef DEBUG /* make sure timeout is really not needed */ - timeout(dmatimeout, (void *)0, 30 * hz); + timeout(dmatimeout, sc, 30 * hz); #endif - printf("dma: 98620%c with 2 channels, %d bit DMA\n", - rev, rev == 'B' ? 16 : 32); + printf("%s: 98620%c, 2 channels, %d bit\n", sc->sc_xname, + rev, (rev == 'B') ? 16 : 32); } int @@ -162,7 +191,7 @@ dmareq(dq) register int s = splbio(); chan = dq->dq_ctlr; - i = NDMA; + i = NDMACHAN; while (--i >= 0) { if ((chan & (1 << i)) == 0) continue; @@ -173,7 +202,7 @@ dmareq(dq) splx(s); return(1); } - insque(dq, dmachan[NDMA].dq_back); + insque(dq, dmachan[NDMACHAN].dq_back); splx(s); return(0); } @@ -183,7 +212,8 @@ dmafree(dq) register struct devqueue *dq; { int unit = dq->dq_ctlr; - register struct dma_softc *dc = &dma_softc[unit]; + struct dma_softc *sc = &Dma_softc; + register struct dma_channel *dc = &sc->sc_chan[unit]; register struct devqueue *dn; register int chan, s; @@ -196,13 +226,13 @@ dmafree(dq) /* * XXX we may not always go thru the flush code in dmastop() */ - if (dc->sc_flags & DMAF_PCFLUSH) { + if (dc->dm_flags & DMAF_PCFLUSH) { PCIA(); - dc->sc_flags &= ~DMAF_PCFLUSH; + dc->dm_flags &= ~DMAF_PCFLUSH; } #endif #if defined(HP320) || defined(HP350) - if (dc->sc_flags & DMAF_VCFLUSH) { + if (dc->dm_flags & DMAF_VCFLUSH) { /* * 320/350s have VACs that may also need flushing. * In our case we only flush the supervisor side @@ -213,13 +243,13 @@ dmafree(dq) * mapping. */ DCIS(); - dc->sc_flags &= ~DMAF_VCFLUSH; + dc->dm_flags &= ~DMAF_VCFLUSH; } #endif remque(dq); chan = 1 << unit; - for (dn = dmachan[NDMA].dq_forw; - dn != &dmachan[NDMA]; dn = dn->dq_forw) { + for (dn = dmachan[NDMACHAN].dq_forw; + dn != &dmachan[NDMACHAN]; dn = dn->dq_forw) { if (dn->dq_ctlr & chan) { remque((caddr_t)dn); insque((caddr_t)dn, (caddr_t)dq->dq_back); @@ -239,7 +269,8 @@ dmago(unit, addr, count, flags) register int count; register int flags; { - register struct dma_softc *dc = &dma_softc[unit]; + struct dma_softc *sc = &Dma_softc; + register struct dma_channel *dc = &sc->sc_chan[unit]; register struct dma_chain *dcp; register char *dmaend = NULL; register int tcount; @@ -247,7 +278,7 @@ dmago(unit, addr, count, flags) if (count > MAXPHYS) panic("dmago: count > MAXPHYS"); #if defined(HP320) - if (dc->sc_type == DMA_B && (flags & DMAGO_LWORD)) + if (sc->sc_type == DMA_B && (flags & DMAGO_LWORD)) panic("dmago: no can do 32-bit DMA"); #endif #ifdef DEBUG @@ -264,7 +295,7 @@ dmago(unit, addr, count, flags) /* * Build the DMA chain */ - for (dcp = dc->sc_chain; count > 0; dcp++) { + for (dcp = dc->dm_chain; count > 0; dcp++) { dcp->dc_addr = (char *) kvtop(addr); #if defined(HP380) /* @@ -285,7 +316,7 @@ dmago(unit, addr, count, flags) if (dcp->dc_addr == dmaend #if defined(HP320) /* only 16-bit count on 98620B */ - && (dc->sc_type != DMA_B || + && (sc->sc_type != DMA_B || (dcp-1)->dc_count + tcount <= 65536) #endif ) { @@ -302,21 +333,21 @@ dmago(unit, addr, count, flags) dcp->dc_count = tcount; } } - dc->sc_cur = dc->sc_chain; - dc->sc_last = --dcp; - dc->sc_flags = 0; + dc->dm_cur = dc->dm_chain; + dc->dm_last = --dcp; + dc->dm_flags = 0; /* * Set up the command word based on flags */ - dc->sc_cmd = DMA_ENAB | DMA_IPL(DMAINTLVL) | DMA_START; + dc->dm_cmd = DMA_ENAB | DMA_IPL(DMAINTLVL) | DMA_START; if ((flags & DMAGO_READ) == 0) - dc->sc_cmd |= DMA_WRT; + dc->dm_cmd |= DMA_WRT; if (flags & DMAGO_LWORD) - dc->sc_cmd |= DMA_LWORD; + dc->dm_cmd |= DMA_LWORD; else if (flags & DMAGO_WORD) - dc->sc_cmd |= DMA_WORD; + dc->dm_cmd |= DMA_WORD; if (flags & DMAGO_PRI) - dc->sc_cmd |= DMA_PRI; + dc->dm_cmd |= DMA_PRI; #if defined(HP380) /* * On the 68040 we need to flush (push) the data cache before a @@ -326,7 +357,7 @@ dmago(unit, addr, count, flags) * involved in the DMA we might purge some valid data. */ if (mmutype == MMU_68040 && (flags & DMAGO_READ)) - dc->sc_flags |= DMAF_PCFLUSH; + dc->dm_flags |= DMAF_PCFLUSH; #endif #if defined(HP360) || defined(HP370) /* @@ -334,30 +365,30 @@ dmago(unit, addr, count, flags) * DMA is done. We only do this if we are reading (writing memory). */ if (ectype == EC_PHYS && (flags & DMAGO_READ)) - dc->sc_flags |= DMAF_PCFLUSH; + dc->dm_flags |= DMAF_PCFLUSH; #endif #if defined(HP320) || defined(HP350) if (ectype == EC_VIRT && (flags & DMAGO_READ)) - dc->sc_flags |= DMAF_VCFLUSH; + dc->dm_flags |= DMAF_VCFLUSH; #endif /* * Remember if we can skip the dma completion interrupt on * the last segment in the chain. */ if (flags & DMAGO_NOINT) { - if (dc->sc_cur == dc->sc_last) - dc->sc_cmd &= ~DMA_ENAB; + if (dc->dm_cur == dc->dm_last) + dc->dm_cmd &= ~DMA_ENAB; else - dc->sc_flags |= DMAF_NOINTR; + dc->dm_flags |= DMAF_NOINTR; } #ifdef DEBUG if (dmadebug & DDB_IO) - if ((dmadebug&DDB_WORD) && (dc->sc_cmd&DMA_WORD) || - (dmadebug&DDB_LWORD) && (dc->sc_cmd&DMA_LWORD)) { + if ((dmadebug&DDB_WORD) && (dc->dm_cmd&DMA_WORD) || + (dmadebug&DDB_LWORD) && (dc->dm_cmd&DMA_LWORD)) { printf("dmago: cmd %x, flags %x\n", - dc->sc_cmd, dc->sc_flags); - for (dcp = dc->sc_chain; dcp <= dc->sc_last; dcp++) - printf(" %d: %d@%x\n", dcp-dc->sc_chain, + dc->dm_cmd, dc->dm_flags); + for (dcp = dc->dm_chain; dcp <= dc->dm_last; dcp++) + printf(" %d: %d@%x\n", dcp-dc->dm_chain, dcp->dc_count, dcp->dc_addr); } dmatimo[unit] = 1; @@ -369,7 +400,8 @@ void dmastop(unit) register int unit; { - register struct dma_softc *dc = &dma_softc[unit]; + struct dma_softc *sc = &Dma_softc; + register struct dma_channel *dc = &sc->sc_chan[unit]; register struct devqueue *dq; #ifdef DEBUG @@ -379,13 +411,13 @@ dmastop(unit) #endif DMA_CLEAR(dc); #if defined(HP360) || defined(HP370) || defined(HP380) - if (dc->sc_flags & DMAF_PCFLUSH) { + if (dc->dm_flags & DMAF_PCFLUSH) { PCIA(); - dc->sc_flags &= ~DMAF_PCFLUSH; + dc->dm_flags &= ~DMAF_PCFLUSH; } #endif #if defined(HP320) || defined(HP350) - if (dc->sc_flags & DMAF_VCFLUSH) { + if (dc->dm_flags & DMAF_VCFLUSH) { /* * 320/350s have VACs that may also need flushing. * In our case we only flush the supervisor side @@ -396,7 +428,7 @@ dmastop(unit) * mapping. */ DCIS(); - dc->sc_flags &= ~DMAF_VCFLUSH; + dc->dm_flags &= ~DMAF_VCFLUSH; } #endif /* @@ -412,7 +444,8 @@ dmastop(unit) int dmaintr() { - register struct dma_softc *dc; + struct dma_softc *sc = &Dma_softc; + register struct dma_channel *dc; register int i, stat; int found = 0; @@ -420,31 +453,33 @@ dmaintr() if (dmadebug & DDB_FOLLOW) printf("dmaintr\n"); #endif - for (i = 0, dc = dma_softc; i < NDMA; i++, dc++) { + for (i = 0; i < NDMACHAN; i++) { + dc = &sc->sc_chan[i]; stat = DMA_STAT(dc); if ((stat & DMA_INTR) == 0) continue; found++; #ifdef DEBUG if (dmadebug & DDB_IO) { - if ((dmadebug&DDB_WORD) && (dc->sc_cmd&DMA_WORD) || - (dmadebug&DDB_LWORD) && (dc->sc_cmd&DMA_LWORD)) + if ((dmadebug&DDB_WORD) && (dc->dm_cmd&DMA_WORD) || + (dmadebug&DDB_LWORD) && (dc->dm_cmd&DMA_LWORD)) printf("dmaintr: unit %d stat %x next %d\n", - i, stat, (dc->sc_cur-dc->sc_chain)+1); + i, stat, (dc->dm_cur-dc->dm_chain)+1); } if (stat & DMA_ARMED) - printf("dma%d: intr when armed\n", i); + printf("%s, chan %d: intr when armed\n", + sc->sc_xname, i); #endif - if (++dc->sc_cur <= dc->sc_last) { + if (++dc->dm_cur <= dc->dm_last) { #ifdef DEBUG dmatimo[i] = 1; #endif /* * Last chain segment, disable DMA interrupt. */ - if (dc->sc_cur == dc->sc_last && - (dc->sc_flags & DMAF_NOINTR)) - dc->sc_cmd &= ~DMA_ENAB; + if (dc->dm_cur == dc->dm_last && + (dc->dm_flags & DMAF_NOINTR)) + dc->dm_cmd &= ~DMA_ENAB; DMA_CLEAR(dc); DMA_ARM(dc); } else @@ -459,17 +494,18 @@ dmatimeout(arg) void *arg; { register int i, s; + struct dma_softc *sc = arg; - for (i = 0; i < NDMA; i++) { + for (i = 0; i < NDMACHAN; i++) { s = splbio(); if (dmatimo[i]) { if (dmatimo[i] > 1) - printf("dma%d: timeout #%d\n", + printf("%s: timeout #%d\n", sc->sc_xname, i, dmatimo[i]-1); dmatimo[i]++; } splx(s); } - timeout(dmatimeout, (void *)0, 30 * hz); + timeout(dmatimeout, sc, 30 * hz); } #endif diff --git a/sys/arch/hp300/dev/dmareg.h b/sys/arch/hp300/dev/dmareg.h index acd29276a64..3a6ae6538f9 100644 --- a/sys/arch/hp300/dev/dmareg.h +++ b/sys/arch/hp300/dev/dmareg.h @@ -1,4 +1,4 @@ -/* $NetBSD: dmareg.h,v 1.5 1995/03/28 18:15:59 jtc Exp $ */ +/* $NetBSD: dmareg.h,v 1.6 1995/12/02 02:46:49 thorpej Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -70,7 +70,8 @@ struct dmareg { struct dmadevice dma_chan1; }; -#define NDMA 2 +/* The hp300 has 2 DMA channels. */ +#define NDMACHAN 2 /* intr level must be >= level of any device using dma. i.e., splbio */ #define DMAINTLVL 5 @@ -110,29 +111,29 @@ struct dmareg { * look at the 98620C status to get the extended bits. * DMA_ARM: Load address, count and kick-off DMA. */ -#define DMA_CLEAR(dc) { v_int dmaclr = (int)dc->sc_Bhwaddr->dmaB_addr; } -#define DMA_STAT(dc) dc->sc_Bhwaddr->dmaB_stat +#define DMA_CLEAR(dc) { v_int dmaclr = (int) dc->dm_Bhwaddr->dmaB_addr; } +#define DMA_STAT(dc) dc->dm_Bhwaddr->dmaB_stat #if defined(HP320) #define DMA_ARM(dc) \ - if (dc->sc_type == DMA_B) { \ - register struct dmaBdevice *dma = dc->sc_Bhwaddr; \ - dma->dmaB_addr = dc->sc_cur->dc_addr; \ - dma->dmaB_count = dc->sc_cur->dc_count - 1; \ - dma->dmaB_cmd = dc->sc_cmd; \ + if (dc->dm_softc->sc_type == DMA_B) { \ + register struct dmaBdevice *dma = dc->dm_Bhwaddr; \ + dma->dmaB_addr = dc->dm_cur->dc_addr; \ + dma->dmaB_count = dc->dm_cur->dc_count - 1; \ + dma->dmaB_cmd = dc->dm_cmd; \ } else { \ - register struct dmadevice *dma = dc->sc_hwaddr; \ - dma->dma_addr = dc->sc_cur->dc_addr; \ - dma->dma_count = dc->sc_cur->dc_count - 1; \ - dma->dma_cmd = dc->sc_cmd; \ + register struct dmadevice *dma = dc->dm_hwaddr; \ + dma->dma_addr = dc->dm_cur->dc_addr; \ + dma->dma_count = dc->dm_cur->dc_count - 1; \ + dma->dma_cmd = dc->dm_cmd; \ } #else #define DMA_ARM(dc) \ { \ - register struct dmadevice *dma = dc->sc_hwaddr; \ - dma->dma_addr = dc->sc_cur->dc_addr; \ - dma->dma_count = dc->sc_cur->dc_count - 1; \ - dma->dma_cmd = dc->sc_cmd; \ + register struct dmadevice *dma = dc->dm_hwaddr; \ + dma->dma_addr = dc->dm_cur->dc_addr; \ + dma->dma_count = dc->dm_cur->dc_count - 1; \ + dma->dma_cmd = dc->dm_cmd; \ } #endif #endif diff --git a/sys/arch/hp300/dev/fhpib.c b/sys/arch/hp300/dev/fhpib.c index 9cae78f1226..53e85c7e5f9 100644 --- a/sys/arch/hp300/dev/fhpib.c +++ b/sys/arch/hp300/dev/fhpib.c @@ -1,4 +1,4 @@ -/* $NetBSD: fhpib.c,v 1.6 1995/01/07 10:30:10 mycroft Exp $ */ +/* $NetBSD: fhpib.c,v 1.8 1995/12/02 18:21:56 thorpej Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -79,6 +79,30 @@ long fhpibppollfail[NHPIB] = { 0 }; int fhpibcmd[NHPIB]; +void fhpibreset __P((int)); +int fhpibsend __P((int, int, int, void *, int)); +int fhpibrecv __P((int, int, int, void *, int)); +int fhpibppoll __P((int)); +void fhpibppwatch __P((void *)); +void fhpibgo __P((int, int, int, void *, int, int, int)); +void fhpibdone __P((int)); +int fhpibintr __P((int)); + +/* + * Our controller ops structure. + */ +struct hpib_controller fhpib_controller = { + fhpibreset, + fhpibsend, + fhpibrecv, + fhpibppoll, + fhpibppwatch, + fhpibgo, + fhpibdone, + fhpibintr +}; + +int fhpibtype(hc) register struct hp_ctlr *hc; { @@ -86,13 +110,30 @@ fhpibtype(hc) register struct fhpibdevice *hd = (struct fhpibdevice *)hc->hp_addr; if (hd->hpib_cid != HPIBC) - return(0); + return (0); + hs->sc_type = HPIBC; - hs->sc_ba = HPIBC_BA; hc->hp_ipl = HPIB_IPL(hd->hpib_ids); - return(1); + + return (1); } +void +fhpibattach(hc) + struct hp_ctlr *hc; +{ + register struct hpib_softc *hs = &hpib_softc[hc->hp_unit]; + + if (hs->sc_type != HPIBC) + panic("fhpibattach: unknown type 0x%x", hs->sc_type); + /* NOTREACHED */ + + hs->sc_ba = HPIBC_BA; + hs->sc_descrip = "98625A or 98625B fast HP-IB"; + hs->sc_controller = &fhpib_controller; +} + +void fhpibreset(unit) int unit; { @@ -135,14 +176,16 @@ fhpibifc(hd) hd->hpib_stat = ST_ATN; } -fhpibsend(unit, slave, sec, addr, origcnt) +int +fhpibsend(unit, slave, sec, ptr, origcnt) int unit, slave, sec, origcnt; - register char *addr; + void *ptr; { register struct hpib_softc *hs = &hpib_softc[unit]; register struct fhpibdevice *hd; register int cnt = origcnt; register int timo; + char *addr = ptr; hd = (struct fhpibdevice *)hs->sc_hc->hp_addr; hd->hpib_stat = 0; @@ -189,22 +232,24 @@ senderr: fhpibifc(hd); #ifdef DEBUG if (fhpibdebug & FDB_FAIL) { - printf("hpib%d: fhpibsend failed: slave %d, sec %x, ", - unit, slave, sec); + printf("%s: fhpibsend failed: slave %d, sec %x, ", + hs->sc_hc->hp_xname, slave, sec); printf("sent %d of %d bytes\n", origcnt-cnt-1, origcnt); } #endif return (origcnt - cnt - 1); } -fhpibrecv(unit, slave, sec, addr, origcnt) +int +fhpibrecv(unit, slave, sec, ptr, origcnt) int unit, slave, sec, origcnt; - register char *addr; + void *ptr; { register struct hpib_softc *hs = &hpib_softc[unit]; register struct fhpibdevice *hd; register int cnt = origcnt; register int timo; + char *addr = ptr; hd = (struct fhpibdevice *)hs->sc_hc->hp_addr; /* @@ -251,22 +296,23 @@ recvbyteserror: hd->hpib_imask = 0; #ifdef DEBUG if (fhpibdebug & FDB_FAIL) { - printf("hpib%d: fhpibrecv failed: slave %d, sec %x, ", - unit, slave, sec); + printf("%s: fhpibrecv failed: slave %d, sec %x, ", + hs->sc_hc->hp_xname, slave, sec); printf("got %d of %d bytes\n", origcnt-cnt-1, origcnt); } #endif return (origcnt - cnt - 1); } -fhpibgo(unit, slave, sec, addr, count, rw, timo) - register int unit; - int slave, sec, count, rw; - char *addr; +void +fhpibgo(unit, slave, sec, ptr, count, rw, timo) + int unit, slave, sec, count, rw, timo; + void *ptr; { register struct hpib_softc *hs = &hpib_softc[unit]; register struct fhpibdevice *hd; register int i; + char *addr = ptr; int flags = 0; hd = (struct fhpibdevice *)hs->sc_hc->hp_addr; @@ -381,6 +427,7 @@ fhpibdmadone(arg) (void) splx(s); } +void fhpibdone(unit) int unit; { @@ -423,6 +470,7 @@ fhpibdone(unit) hd->hpib_ie = IDS_IE; } +int fhpibintr(unit) register int unit; { @@ -437,8 +485,8 @@ fhpibintr(unit) #ifdef DEBUG if ((fhpibdebug & FDB_FAIL) && (stat0 & IDS_IR) && (hs->sc_flags & (HPIBF_IO|HPIBF_DONE)) != HPIBF_IO) - printf("hpib%d: fhpibintr: bad status %x\n", - unit, stat0); + printf("%s: fhpibintr: bad status %x\n", + hs->sc_hc->hp_xname, stat0); fhpibbadint[0]++; #endif return(0); @@ -471,8 +519,8 @@ fhpibintr(unit) #ifdef DEBUG if ((fhpibdebug & FDB_FAIL) && doppollint && (stat0 & IM_PPRESP) == 0) - printf("hpib%d: fhpibintr: bad intr reg %x\n", - unit, stat0); + printf("%s: fhpibintr: bad intr reg %x\n", + hs->sc_hc->hp_xname, stat0); #endif hd->hpib_stat = 0; hd->hpib_imask = 0; @@ -499,6 +547,7 @@ fhpibintr(unit) return(1); } +int fhpibppoll(unit) int unit; { @@ -521,6 +570,7 @@ fhpibppoll(unit) return(ppoll); } +int fhpibwait(hd, x) register struct fhpibdevice *hd; int x; @@ -576,4 +626,4 @@ fhpibppwatch(arg) hd->hpib_imask = IM_PPRESP | IM_PABORT; hd->hpib_ie = IDS_IE; } -#endif +#endif /* NHPIB > 0 */ diff --git a/sys/arch/hp300/dev/grf.c b/sys/arch/hp300/dev/grf.c index 15f34e180a7..9594ded7fe0 100644 --- a/sys/arch/hp300/dev/grf.c +++ b/sys/arch/hp300/dev/grf.c @@ -1,4 +1,4 @@ -/* $NetBSD: grf.c,v 1.14 1995/04/22 20:25:42 christos Exp $ */ +/* $NetBSD: grf.c,v 1.16 1995/11/28 08:14:30 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -66,7 +66,7 @@ #include <machine/cpu.h> #ifdef COMPAT_HPUX -#include <hp300/hpux/hpux.h> +#include <compat/hpux/hpux.h> extern struct emul emul_hpux; #endif @@ -77,7 +77,7 @@ extern struct emul emul_hpux; #include <miscfs/specfs/specdev.h> -#include <ite.h> +#include "ite.h" #if NITE == 0 #define iteon(u,f) #define iteoff(u,f) diff --git a/sys/arch/hp300/dev/grf_machdep.c b/sys/arch/hp300/dev/grf_machdep.c index 3e6d0244b92..9a97a65e38c 100644 --- a/sys/arch/hp300/dev/grf_machdep.c +++ b/sys/arch/hp300/dev/grf_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: grf_machdep.c,v 1.2 1994/10/26 07:23:59 cgd Exp $ */ +/* $NetBSD: grf_machdep.c,v 1.3 1995/12/02 18:21:58 thorpej Exp $ */ /* * Copyright (c) 1991 University of Utah. @@ -57,8 +57,9 @@ #include <hp300/dev/grfvar.h> #include <hp300/dev/grfreg.h> -int grfprobe(); -struct driver grfdriver = { grfprobe, "grf" }; +int grfmatch(); +void grfattach(); +struct driver grfdriver = { grfmatch, grfattach, "grf" }; /* * XXX called from ite console init routine. @@ -109,22 +110,32 @@ grfconfig() /* * Normal init routine called by configure() code */ -grfprobe(hd) +int +grfmatch(hd) struct hp_device *hd; { struct grf_softc *gp = &grf_softc[hd->hp_unit]; if ((gp->g_flags & GF_ALIVE) == 0 && !grfinit(hd->hp_addr, hd->hp_unit)) - return(0); - printf("grf%d: %d x %d ", hd->hp_unit, - gp->g_display.gd_dwidth, gp->g_display.gd_dheight); + return (0); + + return(1); +} + +void +grfattach(hd) + struct hp_device *hd; +{ + struct grf_softc *gp = &grf_softc[hd->hp_unit]; + + printf(": %d x %d ", gp->g_display.gd_dwidth, + gp->g_display.gd_dheight); if (gp->g_display.gd_colors == 2) printf("monochrome"); else printf("%d color", gp->g_display.gd_colors); printf(" %s display\n", gp->g_sw->gd_desc); - return(1); } grfinit(addr, unit) diff --git a/sys/arch/hp300/dev/hil.c b/sys/arch/hp300/dev/hil.c index 65d32dd9951..e29e171d7e0 100644 --- a/sys/arch/hp300/dev/hil.c +++ b/sys/arch/hp300/dev/hil.c @@ -1,4 +1,4 @@ -/* $NetBSD: hil.c,v 1.19 1995/04/22 20:25:45 christos Exp $ */ +/* $NetBSD: hil.c,v 1.20 1995/12/02 02:48:47 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -72,7 +72,7 @@ #include "hil.h" #endif -struct hilloop hilloop[NHIL]; +struct hil_softc hil_softc[NHIL]; struct _hilbell default_bell = { BELLDUR, BELLFREQ }; #ifdef hp800 int hilspl; @@ -100,7 +100,7 @@ hilsoftinit(unit, hilbase) int unit; struct hil_dev *hilbase; { - register struct hilloop *hilp = &hilloop[unit]; + register struct hil_softc *hilp = &hil_softc[unit]; register int i; #ifdef DEBUG @@ -136,7 +136,7 @@ hilinit(unit, hilbase) int unit; struct hil_dev *hilbase; { - register struct hilloop *hilp = &hilloop[unit]; + register struct hil_softc *hilp = &hil_softc[unit]; #ifdef DEBUG if (hildebug & HDB_FOLLOW) printf("hilinit(%d, %x)\n", unit, hilbase); @@ -161,7 +161,7 @@ hilopen(dev, flags, mode, p) int flags, mode; struct proc *p; { - register struct hilloop *hilp = &hilloop[HILLOOP(dev)]; + register struct hil_softc *hilp = &hil_softc[HILLOOP(dev)]; register struct hilloopdev *dptr; u_char device = HILUNIT(dev); @@ -239,7 +239,7 @@ hilclose(dev, flags, mode, p) int flags, mode; struct proc *p; { - register struct hilloop *hilp = &hilloop[HILLOOP(dev)]; + register struct hil_softc *hilp = &hil_softc[HILLOOP(dev)]; register struct hilloopdev *dptr; register int i; u_char device = HILUNIT(dev); @@ -263,7 +263,7 @@ hilclose(dev, flags, mode, p) if (device == 0) { for (i = 0; i < NHILQ; i++) if (hilp->hl_queue[i].hq_procp == p) - (void) hilqfree(hilp, i); + (void) hilqfree(hilp, i, p); } else { mask = ~hildevmask(device); (void) splhil(); @@ -320,7 +320,7 @@ hilread(dev, uio) dev_t dev; register struct uio *uio; { - struct hilloop *hilp = &hilloop[HILLOOP(dev)]; + struct hil_softc *hilp = &hil_softc[HILLOOP(dev)]; register struct hilloopdev *dptr; register int cc; u_char device = HILUNIT(dev); @@ -373,7 +373,7 @@ hilioctl(dev, cmd, data, flag, p) caddr_t data; struct proc *p; { - register struct hilloop *hilp = &hilloop[HILLOOP(dev)]; + register struct hil_softc *hilp = &hil_softc[HILLOOP(dev)]; char device = HILUNIT(dev); struct hilloopdev *dptr; register int i; @@ -503,19 +503,19 @@ hilioctl(dev, cmd, data, flag, p) break; case HILIOCALLOCQ: - error = hilqalloc(hilp, (struct hilqinfo *)data); + error = hilqalloc(hilp, (struct hilqinfo *)data, p); break; case HILIOCFREEQ: - error = hilqfree(hilp, ((struct hilqinfo *)data)->qid); + error = hilqfree(hilp, ((struct hilqinfo *)data)->qid, p); break; case HILIOCMAPQ: - error = hilqmap(hilp, *(int *)data, device); + error = hilqmap(hilp, *(int *)data, device, p); break; case HILIOCUNMAPQ: - error = hilqunmap(hilp, *(int *)data, device); + error = hilqunmap(hilp, *(int *)data, device, p); break; case HILIOCHPUX: @@ -550,7 +550,7 @@ hpuxhilioctl(dev, cmd, data, flag) int cmd, flag; caddr_t data; { - register struct hilloop *hilp = &hilloop[HILLOOP(dev)]; + register struct hil_softc *hilp = &hil_softc[HILLOOP(dev)]; char device = HILUNIT(dev); struct hilloopdev *dptr; register int i; @@ -684,7 +684,7 @@ hilselect(dev, rw, p) int rw; struct proc *p; { - register struct hilloop *hilp = &hilloop[HILLOOP(dev)]; + register struct hil_softc *hilp = &hil_softc[HILLOOP(dev)]; register struct hilloopdev *dptr; register struct hiliqueue *qp; register int mask; @@ -749,9 +749,9 @@ hilint(unit) int unit; { #ifdef hp300 - struct hilloop *hilp = &hilloop[0]; /* XXX how do we know on 300? */ + struct hil_softc *hilp = &hil_softc[0]; /* XXX how do we know on 300? */ #else - struct hilloop *hilp = &hilloop[unit]; + struct hil_softc *hilp = &hil_softc[unit]; #endif register struct hil_dev *hildevice = hilp->hl_addr; u_char c, stat; @@ -764,7 +764,7 @@ hilint(unit) #include "ite.h" hil_process_int(hilp, stat, c) - register struct hilloop *hilp; + register struct hil_softc *hilp; register u_char stat, c; { #ifdef DEBUG @@ -844,7 +844,7 @@ hil_process_int(hilp, stat, c) ((eq)->size == HEVQSIZE && (eq)->tail >= 0 && (eq)->tail < HEVQSIZE) hilevent(hilp) - struct hilloop *hilp; + struct hil_softc *hilp; { register struct hilloopdev *dptr = &hilp->hl_device[hilp->hl_actdev]; register int len, mask, qnum; @@ -953,7 +953,7 @@ hilevent(hilp) #undef HQFULL hpuxhilevent(hilp, dptr) - register struct hilloop *hilp; + register struct hil_softc *hilp; register struct hilloopdev *dptr; { register int len; @@ -996,11 +996,11 @@ hpuxhilevent(hilp, dptr) * Shared queue manipulation routines */ -hilqalloc(hilp, qip) - register struct hilloop *hilp; +hilqalloc(hilp, qip, p) + register struct hil_softc *hilp; struct hilqinfo *qip; + struct proc *p; { - struct proc *p = curproc; /* XXX */ #ifdef DEBUG if (hildebug & HDB_FOLLOW) @@ -1009,11 +1009,10 @@ hilqalloc(hilp, qip) return(EINVAL); } -hilqfree(hilp, qnum) - register struct hilloop *hilp; +hilqfree(hilp, qnum, p) + register struct hil_softc *hilp; register int qnum; { - struct proc *p = curproc; /* XXX */ #ifdef DEBUG if (hildebug & HDB_FOLLOW) @@ -1022,11 +1021,11 @@ hilqfree(hilp, qnum) return(EINVAL); } -hilqmap(hilp, qnum, device) - register struct hilloop *hilp; +hilqmap(hilp, qnum, device, p) + register struct hil_softc *hilp; register int qnum, device; + struct proc *p; { - struct proc *p = curproc; /* XXX */ register struct hilloopdev *dptr = &hilp->hl_device[device]; int s; @@ -1058,11 +1057,11 @@ hilqmap(hilp, qnum, device) return(0); } -hilqunmap(hilp, qnum, device) - register struct hilloop *hilp; +hilqunmap(hilp, qnum, device, p) + register struct hil_softc *hilp; register int qnum, device; + struct proc *p; { - struct proc *p = curproc; /* XXX */ int s; #ifdef DEBUG @@ -1096,7 +1095,7 @@ hilqunmap(hilp, qnum, device) kbdbell(unit) int unit; { - struct hilloop *hilp = &hilloop[unit]; + struct hil_softc *hilp = &hil_softc[unit]; hilbeep(hilp, &default_bell); } @@ -1104,7 +1103,7 @@ kbdbell(unit) kbdenable(unit) int unit; { - struct hilloop *hilp = &hilloop[unit]; + struct hil_softc *hilp = &hil_softc[unit]; register struct hil_dev *hildevice = hilp->hl_addr; char db; @@ -1133,7 +1132,7 @@ kbddisable(unit) kbdgetc(unit, statp) int unit, *statp; { - struct hilloop *hilp = &hilloop[unit]; + struct hil_softc *hilp = &hil_softc[unit]; register struct hil_dev *hildevice = hilp->hl_addr; register int c, stat; int s; @@ -1160,9 +1159,9 @@ kbdnmi(unit) int unit; { #ifdef hp300 - struct hilloop *hilp = &hilloop[0]; /* XXX how do we know on 300? */ + struct hil_softc *hilp = &hil_softc[0]; /* XXX how do we know on 300? */ #else - struct hilloop *hilp = &hilloop[unit]; + struct hil_softc *hilp = &hil_softc[unit]; #endif #ifdef hp300 if ((*KBDNMISTAT & KBDNMI) == 0) @@ -1186,7 +1185,7 @@ kbdnmi(unit) hilinfo(unit) int unit; { - register struct hilloop *hilp = &hilloop[unit]; + register struct hil_softc *hilp = &hil_softc[unit]; register int id, len; register struct kbdmap *km; @@ -1244,7 +1243,7 @@ hilinfo(unit) * we prefer to just assume people won't move things around. */ hilconfig(hilp) - register struct hilloop *hilp; + register struct hil_softc *hilp; { u_char db; int s; @@ -1348,7 +1347,7 @@ hilconfig(hilp) } hilreset(hilp) - struct hilloop *hilp; + struct hil_softc *hilp; { register struct hil_dev *hildevice = hilp->hl_addr; u_char db; @@ -1388,7 +1387,7 @@ hilreset(hilp) } hilbeep(hilp, bp) - struct hilloop *hilp; + struct hil_softc *hilp; register struct _hilbell *bp; { u_char buf[2]; @@ -1402,7 +1401,7 @@ hilbeep(hilp, bp) * Locate and return the address of the first ID module, 0 if none present. */ hiliddev(hilp) - register struct hilloop *hilp; + register struct hil_softc *hilp; { register int i, len; @@ -1510,7 +1509,7 @@ send_hil_cmd(hildevice, cmd, data, dlen, rdata) * splimp (clock only interrupts) seems to be good enough in practice. */ send_hildev_cmd(hilp, device, cmd) - register struct hilloop *hilp; + register struct hil_softc *hilp; char device, cmd; { register struct hil_dev *hildevice = hilp->hl_addr; @@ -1614,7 +1613,7 @@ pollon(hildevice) #ifdef DEBUG printhilpollbuf(hilp) - register struct hilloop *hilp; + register struct hil_softc *hilp; { register u_char *cp; register int i, len; @@ -1627,7 +1626,7 @@ printhilpollbuf(hilp) } printhilcmdbuf(hilp) - register struct hilloop *hilp; + register struct hil_softc *hilp; { register u_char *cp; register int i, len; @@ -1640,7 +1639,7 @@ printhilcmdbuf(hilp) } hilreport(hilp) - register struct hilloop *hilp; + register struct hil_softc *hilp; { register int i, len; int s = splhil(); diff --git a/sys/arch/hp300/dev/hil_keymaps.c b/sys/arch/hp300/dev/hil_keymaps.c index e3d87394c70..03f8174dc95 100644 --- a/sys/arch/hp300/dev/hil_keymaps.c +++ b/sys/arch/hp300/dev/hil_keymaps.c @@ -1,4 +1,4 @@ -/* $NetBSD: hil_keymaps.c,v 1.5 1994/10/26 07:24:13 cgd Exp $ */ +/* $NetBSD: hil_keymaps.c,v 1.6 1995/12/06 22:13:23 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -238,6 +238,84 @@ char uk_ctrlshiftmap[] = { }; #endif +#ifdef SE_KEYBOARD +char se_keymap[] = { + NULL, '<', '\'', ESC, NULL, DEL, NULL, NULL, + '\n', '\t', NULL, NULL, NULL, NULL, NULL, NULL, + NULL, '\n', NULL, NULL, NULL, NULL, NULL, NULL, + NULL, '\t', NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, '\b', NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + ESC, '\r', NULL, '\n', '0', '.', ',', '+', + '1', '2', '3', '-', '4', '5', '6', '*', + '7', '8', '9', '/', 'E', '(', ')', '^', + '1', '2', '3', '4', '5', '6', '7', '8', + '9', '0', '+', '`', '}', '~', '|', '{', + ',', '.', '-', '\040', 'o', 'p', 'k', 'l', + 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', + 'a', 's', 'd', 'f', 'g', 'h', 'j', 'm', + 'z', 'x', 'c', 'v', 'b', 'n', NULL, NULL +}; + +char se_shiftmap[] = { + NULL, '>', '*', DEL, NULL, DEL, NULL, NULL, + '\n', '\t', NULL, NULL, NULL, NULL, NULL, NULL, + NULL, '\n', NULL, NULL, NULL, NULL, NULL, NULL, + NULL, '\t', NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, DEL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + ESC, '\r', NULL, '\n', '0', '.', ',', '+', + '1', '2', '3', '-', '4', '5', '6', '*', + '7', '8', '9', '-', '`', '*', '\\', '>', + '!', '\"', '#', '$', '%', '&', '/', '(', + ')', '=', '?', '@', ']', '^', '\\', '[', + ';', ':', '_', '\040', 'O', 'P', 'K', 'L', + 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', + 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'M', + 'Z', 'X', 'C', 'V', 'B', 'N', NULL, NULL +}; + +char se_ctrlmap[] = { + NULL, '`', '\034', ESC, NULL, DEL, NULL, NULL, + '\n', '\t', NULL, NULL, NULL, NULL, NULL, NULL, + NULL, '\n', NULL, NULL, NULL, NULL, NULL, NULL, + NULL, '\t', NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, '\b', NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + ESC, '\r', NULL, '\n', '0', '.', ',', '+', + '1', '2', '3', '-', '4', '5', '6', '*', + '7', '8', '9', '/', 'E', '(', ')', '\036', + '1', '2', '3', '4', '5', '6', '7', '8', + '9', '0', '-', '=', '\033', '\035', ';', '\'', + ',', '.', '/', '\040', '\017', '\020', '\013', '\014', + '\021', '\027', '\005', '\022', '\024', '\031', '\025', '\011', + '\001', '\023', '\004', '\006', '\007', '\010', '\012', '\015', + '\032', '\030', '\003', '\026', '\002', '\016', NULL, NULL +}; + +char se_ctrlshiftmap[] = { + NULL, '~', '|', DEL, NULL, DEL, NULL, NULL, + '\n', '\t', NULL, NULL, NULL, NULL, NULL, NULL, + NULL, '\n', NULL, NULL, NULL, NULL, NULL, NULL, + NULL, '\t', NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, DEL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + ESC, '\r', NULL, '\n', '0', '.', ',', '+', + '1', '2', '3', '-', '4', '5', '6', '*', + '7', '8', '9', '/', '`', '|', '\034', '~', + '!', '\000', '#', '$', '%', '\036', '&', '*', + '(', ')', '\037', '+', '{', '}', ':', '\"', + '<', '>', '?', '\040', '\017', '\020', '\013', '\014', + '\021', '\027', '\005', '\022', '\024', '\031', '\025', '\011', + '\001', '\023', '\004', '\006', '\007', '\010', '\012', '\015', + '\032', '\030', '\003', '\026', '\002', '\016', NULL, NULL +}; +#endif + /* * The keyboard map table. * Lookup is by hardware returned language code. @@ -253,6 +331,12 @@ struct kbdmap kbd_map[] = { us_stringmap, #endif +#ifdef SE_KEYBOARD + KBD_SE, "Swedish", + se_keymap, se_shiftmap, se_ctrlmap, se_ctrlshiftmap, + us_stringmap, +#endif + 0, NULL, NULL, NULL, NULL, NULL, NULL, diff --git a/sys/arch/hp300/dev/hilvar.h b/sys/arch/hp300/dev/hilvar.h index a295d52a0d8..078268a514a 100644 --- a/sys/arch/hp300/dev/hilvar.h +++ b/sys/arch/hp300/dev/hilvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: hilvar.h,v 1.8 1994/10/26 07:24:16 cgd Exp $ */ +/* $NetBSD: hilvar.h,v 1.11 1995/12/11 19:41:47 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -95,7 +95,7 @@ struct hilloopdev { #define HIL_ASLEEP 0x40 /* process awaiting input on device */ #define HIL_DERROR 0x80 /* loop has reconfigured, reality altered */ -struct hilloop { +struct hil_softc { struct hil_dev *hl_addr; /* base of hardware registers */ u_char hl_cmddone; /* */ u_char hl_cmdending; /* */ diff --git a/sys/arch/hp300/dev/hpib.c b/sys/arch/hp300/dev/hpib.c index 708a3f8fdd8..c6819ddc5bd 100644 --- a/sys/arch/hp300/dev/hpib.c +++ b/sys/arch/hp300/dev/hpib.c @@ -1,4 +1,4 @@ -/* $NetBSD: hpib.c,v 1.5 1995/01/07 10:30:12 mycroft Exp $ */ +/* $NetBSD: hpib.c,v 1.7 1995/12/02 18:22:01 thorpej Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -52,47 +52,107 @@ #include <machine/cpu.h> #include <hp300/hp300/isr.h> -int hpibinit(), hpibstart(), hpibgo(), hpibintr(), hpibdone(); +int hpibmatch __P((struct hp_ctlr *)); +void hpibattach __P((struct hp_ctlr *)); +void hpibstart __P((int)); +void hpibgo __P((int, int, int, void *, int, int, int)); +void hpibdone __P((int)); +int hpibintr __P((int)); + struct driver hpibdriver = { - hpibinit, "hpib", hpibstart, hpibgo, hpibintr, hpibdone, + hpibmatch, + hpibattach, + "hpib", + (int(*)())hpibstart, /* XXX */ + (int(*)())hpibgo, /* XXX */ + hpibintr, + (int(*)())hpibdone, /* XXX */ }; struct hpib_softc hpib_softc[NHPIB]; struct isr hpib_isr[NHPIB]; -int nhpibppoll(), fhpibppoll(); + +extern int nhpibtype __P((struct hp_ctlr *)); /* XXX */ +extern int fhpibtype __P((struct hp_ctlr *)); /* XXX */ +extern void nhpibattach __P((struct hp_ctlr *)); /* XXX */ +extern void fhpibattach __P((struct hp_ctlr *)); /* XXX */ int hpibtimeout = 100000; /* # of status tests before we give up */ int hpibidtimeout = 10000; /* # of status tests for hpibid() calls */ int hpibdmathresh = 3; /* byte count beyond which to attempt dma */ -hpibinit(hc) +int +hpibmatch(hc) register struct hp_ctlr *hc; { - register struct hpib_softc *hs = &hpib_softc[hc->hp_unit]; - - if (!nhpibtype(hc) && !fhpibtype(hc)) - return(0); + struct hp_hw *hw = hc->hp_args; + extern caddr_t internalhpib; + + /* Special case for internal HP-IB. */ + if ((hw->hw_sc == 7) && internalhpib) + goto hwid_ok; + + switch (hw->hw_id) { + case 8: /* 98625B */ + case 128: /* 98624A */ + hwid_ok: + if (nhpibtype(hc) || fhpibtype(hc)) + return (1); + } + + return (0); +} + +void +hpibattach(hc) + struct hp_ctlr *hc; +{ + struct hpib_softc *hs = &hpib_softc[hc->hp_unit]; + + /* + * Call the appropriate "attach" routine for this controller. + * The type is set in the "type" routine. + */ + switch (hs->sc_type) { + case HPIBA: + case HPIBB: + nhpibattach(hc); + break; + + case HPIBC: + fhpibattach(hc); + break; + + default: + panic("hpibattach: unknown type 0x%x", hs->sc_type); + /* NOTREACHED */ + } + hs->sc_hc = hc; hs->sc_dq.dq_unit = hc->hp_unit; hs->sc_dq.dq_driver = &hpibdriver; hs->sc_sq.dq_forw = hs->sc_sq.dq_back = &hs->sc_sq; + + /* Establish the interrupt handler. */ hpib_isr[hc->hp_unit].isr_intr = hpibintr; hpib_isr[hc->hp_unit].isr_ipl = hc->hp_ipl; hpib_isr[hc->hp_unit].isr_arg = hc->hp_unit; isrlink(&hpib_isr[hc->hp_unit]); + + /* Reset the controller, display what we've seen, and we're done. */ hpibreset(hc->hp_unit); - return(1); + printf(": %s\n", hs->sc_descrip); } +void hpibreset(unit) register int unit; { - if (hpib_softc[unit].sc_type == HPIBC) - fhpibreset(unit); - else - nhpibreset(unit); + + (hpib_softc[unit].sc_controller->hpib_reset)(unit); } +int hpibreq(dq) register struct devqueue *dq; { @@ -105,6 +165,7 @@ hpibreq(dq) return(0); } +void hpibfree(dq) register struct devqueue *dq; { @@ -116,6 +177,7 @@ hpibfree(dq) (dq->dq_driver->d_start)(dq->dq_unit); } +int hpibid(unit, slave) int unit, slave; { @@ -134,36 +196,37 @@ hpibid(unit, slave) return(id); } +int hpibsend(unit, slave, sec, addr, cnt) - register int unit; - int slave, sec, addr, cnt; + int unit, slave, sec, cnt; + void *addr; { - if (hpib_softc[unit].sc_type == HPIBC) - return(fhpibsend(unit, slave, sec, addr, cnt)); - else - return(nhpibsend(unit, slave, sec, addr, cnt)); + + return ((hpib_softc[unit].sc_controller->hpib_send)(unit, slave, + sec, addr, cnt)); } +int hpibrecv(unit, slave, sec, addr, cnt) - register int unit; - int slave, sec, addr, cnt; + int unit, slave, sec, cnt; + void *addr; { - if (hpib_softc[unit].sc_type == HPIBC) - return(fhpibrecv(unit, slave, sec, addr, cnt)); - else - return(nhpibrecv(unit, slave, sec, addr, cnt)); + + return ((hpib_softc[unit].sc_controller->hpib_recv)(unit, slave, + sec, addr, cnt)); } +int hpibpptest(unit, slave) register int unit; int slave; { - int (*ppoll)(); - ppoll = (hpib_softc[unit].sc_type == HPIBC) ? fhpibppoll : nhpibppoll; - return((*ppoll)(unit) & (0x80 >> slave)); + return ((hpib_softc[unit].sc_controller->hpib_ppoll)(unit) & + (0x80 >> slave)); } +void hpibppclear(unit) int unit; { @@ -176,29 +239,29 @@ hpibawait(unit) register struct hpib_softc *hs = &hpib_softc[unit]; hs->sc_flags |= HPIBF_PPOLL; - if (hs->sc_type == HPIBC) - fhpibppwatch((void *)unit); - else - nhpibppwatch((void *)unit); + (hs->sc_controller->hpib_ppwatch)((void *)unit); } +int hpibswait(unit, slave) register int unit; int slave; { register int timo = hpibtimeout; - register int mask, (*ppoll)(); + register int mask, (*ppoll) __P((int)); - ppoll = (hpib_softc[unit].sc_type == HPIBC) ? fhpibppoll : nhpibppoll; + ppoll = hpib_softc[unit].sc_controller->hpib_ppoll; mask = 0x80 >> slave; while (((ppoll)(unit) & mask) == 0) if (--timo == 0) { - printf("hpib%d: swait timeout\n", unit); + printf("%s: swait timeout\n", + hpib_softc[unit].sc_hc->hp_xname); return(-1); } return(0); } +int hpibustart(unit) int unit; { @@ -213,6 +276,7 @@ hpibustart(unit) return(0); } +void hpibstart(unit) int unit; { @@ -222,34 +286,29 @@ hpibstart(unit) (dq->dq_driver->d_go)(dq->dq_unit); } +void hpibgo(unit, slave, sec, addr, count, rw, timo) - register int unit; - int slave, sec, addr, count, rw; + int unit, slave, sec, count, rw, timo; + void *addr; { - if (hpib_softc[unit].sc_type == HPIBC) - fhpibgo(unit, slave, sec, addr, count, rw, timo); - else - nhpibgo(unit, slave, sec, addr, count, rw, timo); + + (hpib_softc[unit].sc_controller->hpib_go)(unit, slave, sec, + addr, count, rw, timo); } +void hpibdone(unit) register int unit; { - if (hpib_softc[unit].sc_type == HPIBC) - fhpibdone(unit); - else - nhpibdone(unit); + + (hpib_softc[unit].sc_controller->hpib_done)(unit); } +int hpibintr(unit) register int unit; { - int found; - if (hpib_softc[unit].sc_type == HPIBC) - found = fhpibintr(unit); - else - found = nhpibintr(unit); - return(found); + return ((hpib_softc[unit].sc_controller->hpib_intr)(unit)); } -#endif +#endif /* NHPIB > 0 */ diff --git a/sys/arch/hp300/dev/hpibvar.h b/sys/arch/hp300/dev/hpibvar.h index f50b4ff7c07..4a2a67d9718 100644 --- a/sys/arch/hp300/dev/hpibvar.h +++ b/sys/arch/hp300/dev/hpibvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: hpibvar.h,v 1.6 1995/03/28 18:16:09 jtc Exp $ */ +/* $NetBSD: hpibvar.h,v 1.7 1995/11/19 17:57:18 thorpej Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -66,8 +66,25 @@ #define C_UNT_P 0xdf /* with odd parity */ #define C_SCG 0x60 /* Secondary group commands */ +/* + * Each of the HP-IB controller drivers fills in this structure, which + * is used by the indirect driver to call controller-specific functions. + */ +struct hpib_controller { + void (*hpib_reset) __P((int)); + int (*hpib_send) __P((int, int, int, void *, int)); + int (*hpib_recv) __P((int, int, int, void *, int)); + int (*hpib_ppoll) __P((int)); + void (*hpib_ppwatch) __P((void *)); + void (*hpib_go) __P((int, int, int, void *, int, int, int)); + void (*hpib_done) __P((int)); + int (*hpib_intr) __P((int)); +}; + struct hpib_softc { struct hp_ctlr *sc_hc; + struct hpib_controller *sc_controller; + char *sc_descrip; int sc_flags; struct devqueue sc_dq; struct devqueue sc_sq; @@ -91,6 +108,8 @@ extern struct hpib_softc hpib_softc[]; extern caddr_t internalhpib; extern int hpibtimeout; extern int hpibdmathresh; -void fhpibppwatch __P((void *arg)); -void nhpibppwatch __P((void *arg)); + +void hpibreset __P((int)); +int hpibsend __P((int, int, int, void *, int)); +int hpibrecv __P((int, int, int, void *, int)); #endif diff --git a/sys/arch/hp300/dev/if_le.c b/sys/arch/hp300/dev/if_le.c index e62fcfd5803..c0bb48780da 100644 --- a/sys/arch/hp300/dev/if_le.c +++ b/sys/arch/hp300/dev/if_le.c @@ -1,8 +1,12 @@ -/* $NetBSD: if_le.c,v 1.22 1995/08/04 08:08:41 thorpej Exp $ */ +/* $NetBSD: if_le.c,v 1.24 1995/12/10 00:49:33 mycroft Exp $ */ -/* - * Copyright (c) 1982, 1990 The Regents of the University of California. - * All rights reserved. +/*- + * Copyright (c) 1995 Charles M. Hannum. All rights reserved. + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell and Rick Macklem. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -32,51 +36,28 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)if_le.c 7.6 (Berkeley) 5/8/91 + * @(#)if_le.c 8.2 (Berkeley) 11/16/93 */ -#include "le.h" -#if NLE > 0 - #include "bpfilter.h" -/* - * AMD 7990 LANCE - */ #include <sys/param.h> #include <sys/systm.h> -#include <sys/kernel.h> #include <sys/mbuf.h> -#include <sys/buf.h> -#include <sys/socket.h> #include <sys/syslog.h> -#include <sys/ioctl.h> -#include <sys/malloc.h> -#include <sys/errno.h> +#include <sys/socket.h> +#include <sys/device.h> #include <net/if.h> -#include <net/netisr.h> -#include <net/route.h> -#if NBPFILTER > 0 -#include <net/bpf.h> -#include <net/bpfdesc.h> -#endif #ifdef INET #include <netinet/in.h> -#include <netinet/in_systm.h> -#include <netinet/in_var.h> -#include <netinet/ip.h> #include <netinet/if_ether.h> #endif -#ifdef NS -#include <netns/ns.h> -#include <netns/ns_if.h> -#endif - #include <machine/cpu.h> #include <machine/mtpr.h> + #include <hp300/hp300/isr.h> #ifdef USELEDS #include <hp300/hp300/led.h> @@ -84,71 +65,33 @@ #include <hp300/dev/device.h> #include <hp300/dev/if_lereg.h> +#include <hp300/dev/if_levar.h> +#include <dev/ic/am7990reg.h> +#define LE_NEED_BUF_CONTIG +#include <dev/ic/am7990var.h> +#include "le.h" +struct le_softc le_softc[NLE]; -#define ETHER_MIN_LEN 64 -#define ETHER_MAX_LEN 1518 -#define ETHER_ADDR_LEN 6 - - -/* offsets for: ID, REGS, MEM, NVRAM */ -int lestd[] = { 0, 0x4000, 0x8000, 0xC008 }; - -struct isr le_isr[NLE]; - -/* - * Ethernet software status per interface. - * - * Each interface is referenced by a network interface structure, - * arpcom.ac_if, which the routing code uses to locate the interface. - * This structure contains the output queue for the interface, its address, ... - */ -struct le_softc { - struct arpcom sc_arpcom; /* common Ethernet structures */ - struct lereg0 *sc_r0; /* DIO registers */ - struct lereg1 *sc_r1; /* LANCE registers */ - void *sc_mem; - struct init_block *sc_init; - struct mds *sc_rd, *sc_td; - u_char *sc_rbuf, *sc_tbuf; - int sc_last_rd, sc_last_td; - int sc_no_td; -#ifdef LEDEBUG - int sc_debug; -#endif -} le_softc[NLE]; - -int leintr __P((int)); -int leioctl __P((struct ifnet *, u_long, caddr_t)); -void lestart __P((struct ifnet *)); -void lewatchdog __P((int)); -static inline void lewrcsr __P((/* struct le_softc *, u_short, u_short */)); -static inline u_short lerdcsr __P((/* struct le_softc *, u_short */)); -void leinit __P((struct le_softc *)); -void lememinit __P((struct le_softc *)); -void lereset __P((struct le_softc *)); -void lestop __P((struct le_softc *)); -void letint __P((int)); -void lerint __P((int)); -void leread __P((struct le_softc *, u_char *, int)); -struct mbuf *leget __P((u_char *, int, struct ifnet *)); -#ifdef LEDEBUG -void recv_print __P((struct le_softc *, int)); -void xmit_print __P((struct le_softc *, int)); -#endif -void lesetladrf __P((struct arpcom *, u_long *)); +#define LE_SOFTC(unit) &le_softc[unit] +#define LE_DELAY(x) DELAY(x) +#define LEINTR_UNIT -int leattach __P((struct hp_device *)); +int lematch __P((struct hp_device *)); +void leattach __P((struct hp_device *)); +int leintr __P((int)); struct driver ledriver = { - leattach, "le", + lematch, leattach, "le", }; -static inline void +/* offsets for: ID, REGS, MEM, NVRAM */ +int lestd[] = { 0, 0x4000, 0x8000, 0xC008 }; + +integrate void lewrcsr(sc, port, val) struct le_softc *sc; - register u_short port; - register u_short val; + u_int16_t port, val; { register struct lereg0 *ler0 = sc->sc_r0; register struct lereg1 *ler1 = sc->sc_r1; @@ -161,14 +104,14 @@ lewrcsr(sc, port, val) } while ((ler0->ler0_status & LE_ACK) == 0); } -static inline u_short +integrate u_int16_t lerdcsr(sc, port) struct le_softc *sc; - register u_short port; + u_int16_t port; { register struct lereg0 *ler0 = sc->sc_r0; register struct lereg1 *ler1 = sc->sc_r1; - register u_short val; + u_int16_t val; do { ler1->ler1_rap = port; @@ -179,32 +122,51 @@ lerdcsr(sc, port) return (val); } +int +lematch(hd) + struct hp_device *hd; +{ + register struct lereg0 *ler0; + struct le_softc *sc = LE_SOFTC(hd->hp_unit); + + ler0 = (struct lereg0 *)(lestd[0] + (int)hd->hp_addr); + if (ler0->ler0_id != LEID) + return (0); + + hd->hp_ipl = LE_IPL(ler0->ler0_status); + sc->sc_hd = hd; + + return (1); +} + /* * Interface exists: make available by filling in network interface * record. System will initialize the interface when it is ready * to accept packets. */ -int +void leattach(hd) struct hp_device *hd; { register struct lereg0 *ler0; - struct le_softc *sc = &le_softc[hd->hp_unit]; - struct ifnet *ifp = &sc->sc_arpcom.ac_if; + struct le_softc *sc = LE_SOFTC(hd->hp_unit); char *cp; int i; ler0 = sc->sc_r0 = (struct lereg0 *)(lestd[0] + (int)hd->hp_addr); - if (ler0->ler0_id != LEID) - return(0); - sc->sc_r1 = (struct lereg1 *)(lestd[1] + (int)hd->hp_addr); - sc->sc_mem = (void *)(lestd[2] + (int)hd->hp_addr); - le_isr[hd->hp_unit].isr_intr = leintr; - hd->hp_ipl = le_isr[hd->hp_unit].isr_ipl = LE_IPL(ler0->ler0_status); - le_isr[hd->hp_unit].isr_arg = hd->hp_unit; ler0->ler0_id = 0xFF; DELAY(100); + /* XXXX kluge for now */ + sc->sc_dev.dv_unit = hd->hp_unit; + sprintf(sc->sc_dev.dv_xname, "%s%d", ledriver.d_name, hd->hp_unit); + + sc->sc_r1 = (struct lereg1 *)(lestd[1] + (int)hd->hp_addr); + sc->sc_mem = (void *)(lestd[2] + (int)hd->hp_addr); + sc->sc_conf3 = LE_C3_BSWP; + sc->sc_addr = 0; + sc->sc_memsize = 16384; + /* * Read the ethernet address off the board, one nibble at a time. */ @@ -215,843 +177,21 @@ leattach(hd) sc->sc_arpcom.ac_enaddr[i] |= *++cp & 0xF; cp++; } - printf("le%d: hardware address %s\n", hd->hp_unit, - ether_sprintf(sc->sc_arpcom.ac_enaddr)); - - isrlink(&le_isr[hd->hp_unit]); - ler0->ler0_status = LE_IE; - - ifp->if_unit = hd->hp_unit; - ifp->if_name = "le"; - ifp->if_output = ether_output; - ifp->if_start = lestart; - ifp->if_ioctl = leioctl; - ifp->if_watchdog = lewatchdog; - ifp->if_flags = - IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST; - - if_attach(ifp); - ether_ifattach(ifp); - -#if NBPFILTER > 0 - bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header)); -#endif - return (1); -} - -void -lereset(sc) - struct le_softc *sc; -{ - - leinit(sc); -} - -void -lewatchdog(unit) - int unit; -{ - struct le_softc *sc = &le_softc[unit]; - - log(LOG_ERR, "le%d: device timeout\n", unit); - ++sc->sc_arpcom.ac_if.if_oerrors; - - lereset(sc); -} - -#define LANCE_ADDR(sc, a) \ - ((u_long)(a) - (u_long)sc->sc_mem) - -/* LANCE initialization block set up. */ -void -lememinit(sc) - register struct le_softc *sc; -{ - struct ifnet *ifp = &sc->sc_arpcom.ac_if; - int i; - void *mem; - u_long a; - - /* - * At this point we assume that the memory allocated to the Lance is - * quadword aligned. If it isn't then the initialisation is going - * fail later on. - */ - mem = sc->sc_mem; - - sc->sc_init = mem; -#if NBPFILTER > 0 - if (ifp->if_flags & IFF_PROMISC) - sc->sc_init->mode = LE_NORMAL | LE_PROM; - else -#endif - sc->sc_init->mode = LE_NORMAL; - for (i = 0; i < ETHER_ADDR_LEN; i++) - sc->sc_init->padr[i] = sc->sc_arpcom.ac_enaddr[i^1]; - lesetladrf(&sc->sc_arpcom, sc->sc_init->ladrf); - mem += sizeof(struct init_block); - - sc->sc_rd = mem; - a = LANCE_ADDR(sc, mem); - sc->sc_init->rdra = a; - sc->sc_init->rlen = ((a >> 16) & 0xff) | (RLEN << 13); - mem += NRBUF * sizeof(struct mds); - - sc->sc_td = mem; - a = LANCE_ADDR(sc, mem); - sc->sc_init->tdra = a; - sc->sc_init->tlen = ((a >> 16) & 0xff) | (TLEN << 13); - mem += NTBUF * sizeof(struct mds); - - /* - * Set up receive ring descriptors. - */ - sc->sc_rbuf = mem; - for (i = 0; i < NRBUF; i++) { - a = LANCE_ADDR(sc, mem); - sc->sc_rd[i].addr = a; - sc->sc_rd[i].flags = ((a >> 16) & 0xff) | LE_OWN; - sc->sc_rd[i].bcnt = -BUFSIZE; - sc->sc_rd[i].mcnt = 0; - mem += BUFSIZE; - } - - /* - * Set up transmit ring descriptors. - */ - sc->sc_tbuf = mem; - for (i = 0; i < NTBUF; i++) { - a = LANCE_ADDR(sc, mem); - sc->sc_td[i].addr = a; - sc->sc_td[i].flags= ((a >> 16) & 0xff); - sc->sc_td[i].bcnt = 0xf000; - sc->sc_td[i].mcnt = 0; - mem += BUFSIZE; - } -} - -void -lestop(sc) - struct le_softc *sc; -{ - - lewrcsr(sc, 0, LE_STOP); -} -/* - * Initialization of interface; set up initialization block - * and transmit/receive descriptor rings. - */ -void -leinit(sc) - register struct le_softc *sc; -{ - struct ifnet *ifp = &sc->sc_arpcom.ac_if; - int s; - register int timo; - u_long a; + sc->sc_copytodesc = copytobuf_contig; + sc->sc_copyfromdesc = copyfrombuf_contig; + sc->sc_copytobuf = copytobuf_contig; + sc->sc_copyfrombuf = copyfrombuf_contig; + sc->sc_zerobuf = zerobuf_contig; - s = splimp(); + sc->sc_arpcom.ac_if.if_name = ledriver.d_name; + leconfig(sc); - /* Don't want to get in a weird state. */ - lewrcsr(sc, 0, LE_STOP); - DELAY(100); - - sc->sc_last_rd = sc->sc_last_td = sc->sc_no_td = 0; - - /* Set up LANCE init block. */ - lememinit(sc); - - /* Turn on byte swapping. */ - lewrcsr(sc, 3, LE_BSWP); - - /* Give LANCE the physical address of its init block. */ - a = LANCE_ADDR(sc, sc->sc_init); - lewrcsr(sc, 1, a); - lewrcsr(sc, 2, (a >> 16) & 0xff); - - /* Try to initialize the LANCE. */ - DELAY(100); - lewrcsr(sc, 0, LE_INIT); - - /* Wait for initialization to finish. */ - for (timo = 100000; timo; timo--) - if (lerdcsr(sc, 0) & LE_IDON) - break; - - if (lerdcsr(sc, 0) & LE_IDON) { - /* Start the LANCE. */ - lewrcsr(sc, 0, LE_INEA | LE_STRT | LE_IDON); - ifp->if_flags |= IFF_RUNNING; - ifp->if_flags &= ~IFF_OACTIVE; - lestart(ifp); - } else - printf("le%d: card failed to initialize\n", ifp->if_unit); - - (void) splx(s); -} - -/* - * Controller interrupt. - */ -int -leintr(unit) - int unit; -{ - register struct le_softc *sc = &le_softc[unit]; - register u_short isr; - - isr = lerdcsr(sc, 0); -#ifdef LEDEBUG - if (sc->sc_debug) - printf("le%d: leintr entering with isr=%04x\n", - unit, isr); -#endif - if ((isr & LE_INTR) == 0) - return 0; - - do { - lewrcsr(sc, 0, - isr & (LE_INEA | LE_BABL | LE_MISS | LE_MERR | - LE_RINT | LE_TINT | LE_IDON)); - if (isr & (LE_BABL | LE_CERR | LE_MISS | LE_MERR)) { - if (isr & LE_BABL) { - printf("le%d: BABL\n", unit); - sc->sc_arpcom.ac_if.if_oerrors++; - } -#if 0 - if (isr & LE_CERR) { - printf("le%d: CERR\n", unit); - sc->sc_arpcom.ac_if.if_collisions++; - } -#endif - if (isr & LE_MISS) { -#if 0 - printf("le%d: MISS\n", unit); -#endif - sc->sc_arpcom.ac_if.if_ierrors++; - } - if (isr & LE_MERR) { - printf("le%d: MERR\n", unit); - lereset(sc); - goto out; - } - } - - if ((isr & LE_RXON) == 0) { - printf("le%d: receiver disabled\n", unit); - sc->sc_arpcom.ac_if.if_ierrors++; - lereset(sc); - goto out; - } - if ((isr & LE_TXON) == 0) { - printf("le%d: transmitter disabled\n", unit); - sc->sc_arpcom.ac_if.if_oerrors++; - lereset(sc); - goto out; - } - - if (isr & LE_RINT) { - /* Reset watchdog timer. */ - sc->sc_arpcom.ac_if.if_timer = 0; - lerint(unit); - } - if (isr & LE_TINT) { - /* Reset watchdog timer. */ - sc->sc_arpcom.ac_if.if_timer = 0; - letint(unit); - } - - isr = lerdcsr(sc, 0); - } while ((isr & LE_INTR) != 0); - -#ifdef LEDEBUG - if (sc->sc_debug) - printf("le%d: leintr returning with isr=%04x\n", - unit, isr); -#endif - -out: - return 1; -} - -#define NEXTTDS \ - if (++tmd == NTBUF) tmd=0, cdm=sc->sc_td; else ++cdm - -/* - * Setup output on interface. - * Get another datagram to send off of the interface queue, and map it to the - * interface before starting the output. - * Called only at splimp or interrupt level. - */ -void -lestart(ifp) - struct ifnet *ifp; -{ - register struct le_softc *sc = &le_softc[ifp->if_unit]; - register int tmd; - struct mds *cdm; - struct mbuf *m0, *m; - u_char *buffer; - int len; - - if ((sc->sc_arpcom.ac_if.if_flags & (IFF_RUNNING | IFF_OACTIVE)) != - IFF_RUNNING) - return; - - tmd = sc->sc_last_td; - cdm = &sc->sc_td[tmd]; - - for (;;) { - if (sc->sc_no_td >= NTBUF) { - sc->sc_arpcom.ac_if.if_flags |= IFF_OACTIVE; -#ifdef LEDEBUG - if (sc->sc_debug) - printf("no_td = %d, last_td = %d\n", sc->sc_no_td, - sc->sc_last_td); -#endif - break; - } - -#ifdef LEDEBUG - if (cdm->flags & LE_OWN) { - sc->sc_arpcom.ac_if.if_flags |= IFF_OACTIVE; - printf("missing buffer, no_td = %d, last_td = %d\n", - sc->sc_no_td, sc->sc_last_td); - } -#endif - - IF_DEQUEUE(&sc->sc_arpcom.ac_if.if_snd, m); - if (!m) - break; - - ++sc->sc_no_td; - - /* - * Copy the mbuf chain into the transmit buffer. - */ - buffer = sc->sc_tbuf + (BUFSIZE * sc->sc_last_td); - len = 0; - for (m0 = m; m; m = m->m_next) { - bcopy(mtod(m, caddr_t), buffer, m->m_len); - buffer += m->m_len; - len += m->m_len; - } - -#ifdef LEDEBUG - if (len > ETHER_MAX_LEN) - printf("packet length %d\n", len); -#endif - -#if NBPFILTER > 0 - if (sc->sc_arpcom.ac_if.if_bpf) - bpf_mtap(sc->sc_arpcom.ac_if.if_bpf, m0); -#endif - - m_freem(m0); - len = max(len, ETHER_MIN_LEN); - - /* - * Init transmit registers, and set transmit start flag. - */ - cdm->bcnt = -len; - cdm->mcnt = 0; - cdm->flags |= LE_OWN | LE_STP | LE_ENP; - -#ifdef LEDEBUG - if (sc->sc_debug) - xmit_print(sc, sc->sc_last_td); -#endif - - lewrcsr(sc, 0, LE_INEA | LE_TDMD); - - NEXTTDS; - } - - sc->sc_last_td = tmd; -} - -void -letint(unit) - int unit; -{ - register struct le_softc *sc = &le_softc[unit]; - register int tmd = (sc->sc_last_td - sc->sc_no_td + NTBUF) % NTBUF; - struct mds *cdm = &sc->sc_td[tmd]; - -#ifdef USELEDS - if (inledcontrol == 0) - ledcontrol(0, 0, LED_LANXMT); -#endif - - if (cdm->flags & LE_OWN) { - /* Race condition with loop below. */ -#ifdef LEDEBUG - if (sc->sc_debug) - printf("le%d: extra tint\n", unit); -#endif - return; - } - - sc->sc_arpcom.ac_if.if_flags &= ~IFF_OACTIVE; - - do { - if (sc->sc_no_td <= 0) - break; -#ifdef LEDEBUG - if (sc->sc_debug) - printf("trans cdm = %x\n", cdm); -#endif - sc->sc_arpcom.ac_if.if_opackets++; - --sc->sc_no_td; - if (cdm->mcnt & (LE_TBUFF | LE_UFLO | LE_LCOL | LE_LCAR | LE_RTRY)) { - if (cdm->mcnt & LE_TBUFF) - printf("le%d: TBUFF\n", unit); - if ((cdm->mcnt & (LE_TBUFF | LE_UFLO)) == LE_UFLO) - printf("le%d: UFLO\n", unit); - if (cdm->mcnt & LE_UFLO) { - lereset(sc); - return; - } -#if 0 - if (cdm->mcnt & LE_LCOL) { - printf("le%d: late collision\n", unit); - sc->sc_arpcom.ac_if.if_collisions++; - } - if (cdm->mcnt & LE_LCAR) - printf("le%d: lost carrier\n", unit); - if (cdm->mcnt & LE_RTRY) { - printf("le%d: excessive collisions, tdr %d\n", - unit, cdm->mcnt & 0x1ff); - sc->sc_arpcom.ac_if.if_collisions += 16; - } -#endif - } else if (cdm->flags & LE_ONE) - sc->sc_arpcom.ac_if.if_collisions++; - else if (cdm->flags & LE_MORE) - /* Real number is unknown. */ - sc->sc_arpcom.ac_if.if_collisions += 2; - NEXTTDS; - } while ((cdm->flags & LE_OWN) == 0); - - lestart(&sc->sc_arpcom.ac_if); -} - -#define NEXTRDS \ - if (++rmd == NRBUF) rmd=0, cdm=sc->sc_rd; else ++cdm - -/* only called from one place, so may as well integrate */ -void -lerint(unit) - int unit; -{ - register struct le_softc *sc = &le_softc[unit]; - register int rmd = sc->sc_last_rd; - struct mds *cdm = &sc->sc_rd[rmd]; - -#ifdef USELEDS - if (inledcontrol == 0) - ledcontrol(0, 0, LED_LANRCV); -#endif - - if (cdm->flags & LE_OWN) { - /* Race condition with loop below. */ -#ifdef LEDEBUG - if (sc->sc_debug) - printf("le%d: extra rint\n", unit); -#endif - return; - } - - /* Process all buffers with valid data. */ - do { - if (cdm->flags & (LE_FRAM | LE_OFLO | LE_CRC | LE_RBUFF)) { - if ((cdm->flags & (LE_FRAM | LE_OFLO | LE_ENP)) == (LE_FRAM | LE_ENP)) - printf("le%d: FRAM\n", unit); - if ((cdm->flags & (LE_OFLO | LE_ENP)) == LE_OFLO) - printf("le%d: OFLO\n", unit); - if ((cdm->flags & (LE_CRC | LE_OFLO | LE_ENP)) == (LE_CRC | LE_ENP)) - printf("le%d: CRC\n", unit); - if (cdm->flags & LE_RBUFF) - printf("le%d: RBUFF\n", unit); - } else if (cdm->flags & (LE_STP | LE_ENP) != (LE_STP | LE_ENP)) { - do { - cdm->mcnt = 0; - cdm->flags |= LE_OWN; - NEXTRDS; - } while ((cdm->flags & (LE_OWN | LE_ERR | LE_STP | LE_ENP)) == 0); - sc->sc_last_rd = rmd; - printf("le%d: chained buffer\n", unit); - if ((cdm->flags & (LE_OWN | LE_ERR | LE_STP | LE_ENP)) != LE_ENP) { - lereset(sc); - return; - } - } else { -#ifdef LEDEBUG - if (sc->sc_debug) - recv_print(sc, sc->sc_last_rd); -#endif - leread(sc, sc->sc_rbuf + (BUFSIZE * rmd), - (int)cdm->mcnt); - sc->sc_arpcom.ac_if.if_ipackets++; - } - - cdm->mcnt = 0; - cdm->flags |= LE_OWN; - NEXTRDS; -#ifdef LEDEBUG - if (sc->sc_debug) - printf("sc->sc_last_rd = %x, cdm = %x\n", - sc->sc_last_rd, cdm); -#endif - } while ((cdm->flags & LE_OWN) == 0); - - sc->sc_last_rd = rmd; -} - -/* - * Pass a packet to the higher levels. - */ -void -leread(sc, buf, len) - register struct le_softc *sc; - u_char *buf; - int len; -{ - struct ifnet *ifp; - struct mbuf *m; - struct ether_header *eh; - - len -= 4; - if (len <= 0) - return; - - /* Pull packet off interface. */ - ifp = &sc->sc_arpcom.ac_if; - m = leget(buf, len, ifp); - if (m == 0) - return; - - /* We assume that the header fit entirely in one mbuf. */ - eh = mtod(m, struct ether_header *); - -#if NBPFILTER > 0 - /* - * Check if there's a BPF listener on this interface. - * If so, hand off the raw packet to BPF. - */ - if (ifp->if_bpf) { - bpf_mtap(ifp->if_bpf, m); - - /* - * Note that the interface cannot be in promiscuous mode if - * there are no BPF listeners. And if we are in promiscuous - * mode, we have to check if this packet is really ours. - */ - if ((ifp->if_flags & IFF_PROMISC) && - (eh->ether_dhost[0] & 1) == 0 && /* !mcast and !bcast */ - bcmp(eh->ether_dhost, sc->sc_arpcom.ac_enaddr, - sizeof(eh->ether_dhost)) != 0) { - m_freem(m); - return; - } - } -#endif - - /* We assume that the header fit entirely in one mbuf. */ - m->m_pkthdr.len -= sizeof(*eh); - m->m_len -= sizeof(*eh); - m->m_data += sizeof(*eh); - - ether_input(ifp, eh, m); -} - -/* - * Supporting routines - */ - -/* - * Pull data off an interface. - * Len is length of data, with local net header stripped. - * We copy the data into mbufs. When full cluster sized units are present - * we copy into clusters. - */ -struct mbuf * -leget(buf, totlen, ifp) - u_char *buf; - int totlen; - struct ifnet *ifp; -{ - struct mbuf *top, **mp, *m; - int len; - - MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m == 0) - return 0; - m->m_pkthdr.rcvif = ifp; - m->m_pkthdr.len = totlen; - len = MHLEN; - top = 0; - mp = ⊤ - - while (totlen > 0) { - if (top) { - MGET(m, M_DONTWAIT, MT_DATA); - if (m == 0) { - m_freem(top); - return 0; - } - len = MLEN; - } - if (totlen >= MINCLSIZE) { - MCLGET(m, M_DONTWAIT); - if (m->m_flags & M_EXT) - len = MCLBYTES; - } - m->m_len = len = min(totlen, len); - bcopy((caddr_t)buf, mtod(m, caddr_t), len); - buf += len; - totlen -= len; - *mp = m; - mp = &m->m_next; - } - - return top; -} - -/* - * Process an ioctl request. - */ -int -leioctl(ifp, cmd, data) - register struct ifnet *ifp; - u_long cmd; - caddr_t data; -{ - struct le_softc *sc = &le_softc[ifp->if_unit]; - struct ifaddr *ifa = (struct ifaddr *)data; - struct ifreq *ifr = (struct ifreq *)data; - int s, error = 0; - - s = splimp(); - - switch (cmd) { - - case SIOCSIFADDR: - ifp->if_flags |= IFF_UP; - - switch (ifa->ifa_addr->sa_family) { -#ifdef INET - case AF_INET: - leinit(sc); - arp_ifinit(&sc->sc_arpcom, ifa); - break; -#endif -#ifdef NS - /* XXX - This code is probably wrong. */ - case AF_NS: - { - register struct ns_addr *ina = &IA_SNS(ifa)->sns_addr; - - if (ns_nullhost(*ina)) - ina->x_host = - *(union ns_host *)(sc->sc_arpcom.ac_enaddr); - else - bcopy(ina->x_host.c_host, - sc->sc_arpcom.ac_enaddr, - sizeof(sc->sc_arpcom.ac_enaddr)); - /* Set new address. */ - leinit(sc); - break; - } -#endif - default: - leinit(sc); - break; - } - break; - - case SIOCSIFFLAGS: - /* - * If interface is marked down and it is running, then stop it - */ - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { - /* - * If interface is marked down and it is running, then - * stop it. - */ - lestop(sc); - ifp->if_flags &= ~IFF_RUNNING; - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { - /* - * If interface is marked up and it is stopped, then - * start it. - */ - leinit(sc); - } else { - /* - * Reset the interface to pick up changes in any other - * flags that affect hardware registers. - */ - /*lestop(sc);*/ - leinit(sc); - } -#ifdef LEDEBUG - if (ifp->if_flags & IFF_DEBUG) - sc->sc_debug = 1; - else - sc->sc_debug = 0; -#endif - break; - - case SIOCADDMULTI: - case SIOCDELMULTI: - error = (cmd == SIOCADDMULTI) ? - ether_addmulti(ifr, &sc->sc_arpcom): - ether_delmulti(ifr, &sc->sc_arpcom); - - if (error == ENETRESET) { - /* - * Multicast list has changed; set the hardware filter - * accordingly. - */ - leinit(sc); - error = 0; - } - break; - - default: - error = EINVAL; - } - (void) splx(s); - return error; -} - -#ifdef LEDEBUG -void -recv_print(sc, no) - struct le_softc *sc; - int no; -{ - struct mds *rmd; - int i, printed = 0; - u_short len; - - rmd = &sc->sc_rd[no]; - len = rmd->mcnt; - printf("%s: receive buffer %d, len = %d\n", sc->sc_dev.dv_xname, no, - len); - printf("%s: status %x\n", sc->sc_dev.dv_xname, lerdcsr(sc, 0)); - for (i = 0; i < len; i++) { - if (!printed) { - printed = 1; - printf("%s: data: ", sc->sc_dev.dv_xname); - } - printf("%x ", *(sc->sc_rbuf + (BUFSIZE*no) + i)); - } - if (printed) - printf("\n"); -} - -void -xmit_print(sc, no) - struct le_softc *sc; - int no; -{ - struct mds *rmd; - int i, printed=0; - u_short len; - - rmd = &sc->sc_td[no]; - len = -rmd->bcnt; - printf("%s: transmit buffer %d, len = %d\n", sc->sc_dev.dv_xname, no, - len); - printf("%s: status %x\n", sc->sc_dev.dv_xname, lerdcsr(sc, 0)); - printf("%s: addr %x, flags %x, bcnt %x, mcnt %x\n", - sc->sc_dev.dv_xname, rmd->addr, rmd->flags, rmd->bcnt, rmd->mcnt); - for (i = 0; i < len; i++) { - if (!printed) { - printed = 1; - printf("%s: data: ", sc->sc_dev.dv_xname); - } - printf("%x ", *(sc->sc_tbuf + (BUFSIZE*no) + i)); - } - if (printed) - printf("\n"); -} -#endif /* LEDEBUG */ - -/* - * Set up the logical address filter. - */ -void -lesetladrf(ac, af) - struct arpcom *ac; - u_long *af; -{ - struct ifnet *ifp = &ac->ac_if; - struct ether_multi *enm; - register u_char *cp, c; - register u_long crc; - register int i, len; - struct ether_multistep step; - - /* - * Set up multicast address filter by passing all multicast addresses - * through a crc generator, and then using the high order 6 bits as an - * index into the 64 bit logical address filter. The high order bit - * selects the word, while the rest of the bits select the bit within - * the word. - */ - - if (ifp->if_flags & IFF_PROMISC) { - ifp->if_flags |= IFF_ALLMULTI; - af[0] = af[1] = 0xffffffff; - return; - } - - af[0] = af[1] = 0; - ETHER_FIRST_MULTI(step, ac, enm); - while (enm != NULL) { - if (bcmp(enm->enm_addrlo, enm->enm_addrhi, - sizeof(enm->enm_addrlo)) != 0) { - /* - * We must listen to a range of multicast addresses. - * For now, just accept all multicasts, rather than - * trying to set only those filter bits needed to match - * the range. (At this time, the only use of address - * ranges is for IP multicast routing, for which the - * range is big enough to require all bits set.) - */ - ifp->if_flags |= IFF_ALLMULTI; - af[0] = af[1] = 0xffffffff; - return; - } - - cp = enm->enm_addrlo; - crc = 0xffffffff; - for (len = sizeof(enm->enm_addrlo); --len >= 0;) { - c = *cp++; - for (i = 8; --i >= 0;) { - if ((crc & 0x01) ^ (c & 0x01)) { - crc >>= 1; - crc ^= 0x6db88320 | 0x80000000; - } else - crc >>= 1; - c >>= 1; - } - } - /* Just want the 6 most significant bits. */ - crc >>= 26; - - /* Turn on the corresponding bit in the filter. */ - af[crc >> 5] |= 1 << ((crc & 0x1f) ^ 16); - - ETHER_NEXT_MULTI(step, enm); - } - ifp->if_flags &= ~IFF_ALLMULTI; + sc->sc_isr.isr_intr = leintr; + sc->sc_isr.isr_arg = hd->hp_unit; + sc->sc_isr.isr_ipl = hd->hp_ipl; + isrlink(&sc->sc_isr); + ler0->ler0_status = LE_IE; } -#endif /* NLE > 0 */ +#include <dev/ic/am7990.c> diff --git a/sys/arch/hp300/dev/if_lereg.h b/sys/arch/hp300/dev/if_lereg.h index 6a21d24eb10..b745ad6ee06 100644 --- a/sys/arch/hp300/dev/if_lereg.h +++ b/sys/arch/hp300/dev/if_lereg.h @@ -1,4 +1,4 @@ -/* $NetBSD: if_lereg.h,v 1.7 1994/10/26 07:24:23 cgd Exp $ */ +/* $NetBSD: if_lereg.h,v 1.8 1995/12/10 00:49:36 mycroft Exp $ */ /* * Copyright (c) 1982, 1990 The Regents of the University of California. @@ -37,23 +37,14 @@ #define LEID 21 -#define NTBUF 2 -#define TLEN 1 -#define NRBUF 8 -#define RLEN 3 -#define BUFSIZE 1518 - -#define vu_char volatile u_char -#define vu_short volatile u_short - /* - * LANCE registers. + * DIO registers. */ struct lereg0 { - u_char ler0_pad0; - vu_char ler0_id; /* ID */ - u_char ler0_pad1; - vu_char ler0_status; /* interrupt enable/status */ + u_int8_t ler0_pad0; + volatile u_int8_t ler0_id; /* ID */ + u_int8_t ler0_pad1; + volatile u_int8_t ler0_status; /* interrupt enable/status */ }; /* @@ -66,97 +57,10 @@ struct lereg0 { #define LE_JAB 0x02 /* loss of tx clock (???) */ #define LE_IPL(x) ((((x) >> 4) & 0x3) + 3) -struct lereg1 { - vu_short ler1_rdp; /* data port */ - vu_short ler1_rap; /* register select port */ -}; - -/* - * Control and status bits -- lereg1 - */ -#define LE_SERR 0x8000 -#define LE_BABL 0x4000 -#define LE_CERR 0x2000 -#define LE_MISS 0x1000 -#define LE_MERR 0x0800 -#define LE_RINT 0x0400 -#define LE_TINT 0x0200 -#define LE_IDON 0x0100 -#define LE_INTR 0x0080 -#define LE_INEA 0x0040 -#define LE_RXON 0x0020 -#define LE_TXON 0x0010 -#define LE_TDMD 0x0008 -#define LE_STOP 0x0004 -#define LE_STRT 0x0002 -#define LE_INIT 0x0001 - -#define LE_BSWP 0x0004 -#define LE_ACON 0x0002 -#define LE_BCON 0x0001 - -/* - * Overlayed on 16K dual-port RAM. - * Current size is 15,284 bytes with 8 x 1518 receive buffers and - * 2 x 1518 transmit buffers. - */ - /* - * LANCE initialization block - */ -struct init_block { - u_short mode; /* mode register */ - u_char padr[6]; /* ethernet address */ - u_long ladrf[2]; /* logical address filter (multicast) */ - u_short rdra; /* low order pointer to receive ring */ - u_short rlen; /* high order pointer and no. rings */ - u_short tdra; /* low order pointer to transmit ring */ - u_short tlen; /* high order pointer and no rings */ -}; - -/* - * Mode bits -- init_block - */ -#define LE_PROM 0x8000 /* promiscuous */ -#define LE_INTL 0x0040 /* internal loopback */ -#define LE_DRTY 0x0020 /* disable retry */ -#define LE_COLL 0x0010 /* force collision */ -#define LE_DTCR 0x0008 /* disable transmit crc */ -#define LE_LOOP 0x0004 /* loopback */ -#define LE_DTX 0x0002 /* disable transmitter */ -#define LE_DRX 0x0001 /* disable receiver */ -#define LE_NORMAL 0x0000 - -/* - * Message descriptor + * LANCE registers. */ -struct mds { - u_short addr; - u_short flags; - u_short bcnt; - u_short mcnt; +struct lereg1 { + volatile u_int16_t ler1_rdp; /* data port */ + volatile u_int16_t ler1_rap; /* register select port */ }; - -/* Message descriptor flags */ -#define LE_OWN 0x8000 /* owner bit, 0=host, 1=LANCE */ -#define LE_ERR 0x4000 /* error */ -#define LE_STP 0x0200 /* start of packet */ -#define LE_ENP 0x0100 /* end of packet */ - -/* Receive ring status flags */ -#define LE_FRAM 0x2000 /* framing error error */ -#define LE_OFLO 0x1000 /* silo overflow */ -#define LE_CRC 0x0800 /* CRC error */ -#define LE_RBUFF 0x0400 /* buffer error */ - -/* Transmit ring status flags */ -#define LE_MORE 0x1000 /* more than 1 retry */ -#define LE_ONE 0x0800 /* one retry */ -#define LE_DEF 0x0400 /* deferred transmit */ - -/* Transmit errors */ -#define LE_TBUFF 0x8000 /* buffer error */ -#define LE_UFLO 0x4000 /* silo underflow */ -#define LE_LCOL 0x1000 /* late collision */ -#define LE_LCAR 0x0800 /* loss of carrier */ -#define LE_RTRY 0x0400 /* tried 16 times */ diff --git a/sys/arch/hp300/dev/if_levar.h b/sys/arch/hp300/dev/if_levar.h new file mode 100644 index 00000000000..fd77b37ebc3 --- /dev/null +++ b/sys/arch/hp300/dev/if_levar.h @@ -0,0 +1,85 @@ +/* $NetBSD: if_levar.h,v 1.1 1995/12/10 00:49:37 mycroft Exp $ */ + +/*- + * Copyright (c) 1995 Charles M. Hannum. All rights reserved. + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell and Rick Macklem. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)if_le.c 8.2 (Berkeley) 11/16/93 + */ + +/* + * Ethernet software status per interface. + * + * Each interface is referenced by a network interface structure, + * arpcom.ac_if, which the routing code uses to locate the interface. + * This structure contains the output queue for the interface, its address, ... + */ +struct le_softc { + struct device sc_dev; /* base structure */ + struct arpcom sc_arpcom; /* Ethernet common part */ + + void (*sc_copytodesc)(); /* Copy to descriptor */ + void (*sc_copyfromdesc)(); /* Copy from descriptor */ + + void (*sc_copytobuf)(); /* Copy to buffer */ + void (*sc_copyfrombuf)(); /* Copy from buffer */ + void (*sc_zerobuf)(); /* and Zero bytes in buffer */ + + u_int16_t sc_conf3; /* CSR3 value */ + + void *sc_mem; /* base address of RAM -- CPU's view */ + u_long sc_addr; /* base address of RAM -- LANCE's view */ + u_long sc_memsize; /* size of RAM */ + + int sc_nrbuf; /* number of receive buffers */ + int sc_ntbuf; /* number of transmit buffers */ + int sc_last_rd; + int sc_first_td, sc_last_td, sc_no_td; + + int sc_initaddr; + int sc_rmdaddr; + int sc_tmdaddr; + int sc_rbufaddr; + int sc_tbufaddr; + +#ifdef LEDEBUG + int sc_debug; +#endif + + struct hp_device *sc_hd; + struct isr sc_isr; + struct lereg0 *sc_r0; /* DIO registers */ + struct lereg1 *sc_r1; /* LANCE registers */ +}; diff --git a/sys/arch/hp300/dev/ite.c b/sys/arch/hp300/dev/ite.c index 2d5f4d46b5a..bc1b738e7bb 100644 --- a/sys/arch/hp300/dev/ite.c +++ b/sys/arch/hp300/dev/ite.c @@ -1,4 +1,4 @@ -/* $NetBSD: ite.c,v 1.27.2.1 1995/11/19 23:18:27 thorpej Exp $ */ +/* $NetBSD: ite.c,v 1.28 1995/11/19 23:14:22 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. diff --git a/sys/arch/hp300/dev/itevar.h b/sys/arch/hp300/dev/itevar.h index 97fbaffa2ed..28b13d3064d 100644 --- a/sys/arch/hp300/dev/itevar.h +++ b/sys/arch/hp300/dev/itevar.h @@ -1,4 +1,4 @@ -/* $NetBSD: itevar.h,v 1.7.2.1 1995/11/19 23:18:31 thorpej Exp $ */ +/* $NetBSD: itevar.h,v 1.8 1995/11/19 23:14:25 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. diff --git a/sys/arch/hp300/dev/kbdmap.h b/sys/arch/hp300/dev/kbdmap.h index 424e59ff27d..38511760c51 100644 --- a/sys/arch/hp300/dev/kbdmap.h +++ b/sys/arch/hp300/dev/kbdmap.h @@ -1,4 +1,4 @@ -/* $NetBSD: kbdmap.h,v 1.5 1995/03/28 18:16:17 jtc Exp $ */ +/* $NetBSD: kbdmap.h,v 1.6 1995/12/06 22:13:26 thorpej Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -52,6 +52,7 @@ struct kbdmap { #define KBD_SPECIAL 0x00 /* user defined */ #define KBD_US 0x1F /* US ASCII */ #define KBD_UK 0x17 /* United Kingdom */ +#define KBD_SE 0x0e /* Swedish */ #define KBD_DEFAULT KBD_US /* default type */ diff --git a/sys/arch/hp300/dev/mt.c b/sys/arch/hp300/dev/mt.c index 2167809c99b..49defe6daf2 100644 --- a/sys/arch/hp300/dev/mt.c +++ b/sys/arch/hp300/dev/mt.c @@ -1,4 +1,4 @@ -/* $NetBSD: mt.c,v 1.1 1995/10/02 00:28:20 thorpej Exp $ */ +/* $NetBSD: mt.c,v 1.2 1995/12/02 18:22:04 thorpej Exp $ */ /* * Copyright (c) 1992, The University of Utah and @@ -62,6 +62,7 @@ struct mtinfo { int nmtinfo = sizeof(mtinfo) / sizeof(mtinfo[0]); struct mt_softc { + struct hp_device *sc_hd; short sc_hpibno; /* logical HPIB this slave it attached to */ short sc_slave; /* HPIB slave address (0-6) */ short sc_flags; /* see below */ @@ -90,35 +91,55 @@ int mtdebug = 0; #define B_CMD B_XXX /* command buf instead of data */ #define b_cmd b_blkno /* blkno holds cmd when B_CMD */ -int mtinit(), mtintr(); -void mtustart(), mtstart(), mtgo(), mtstrategy(); +int mtmatch(), mtintr(); +void mtattach(), mtustart(), mtstart(), mtgo(), mtstrategy(); struct driver mtdriver = { - mtinit, "mt", (int (*)()) mtstart, (int (*)()) mtgo, mtintr, + mtmatch, mtattach, "mt", (int (*)()) mtstart, (int (*)()) mtgo, mtintr, }; -mtinit(hd) +int +mtmatch(hd) register struct hp_device *hd; { register int unit; register int hpibno = hd->hp_ctlr; register int slave = hd->hp_slave; - register struct mt_softc *sc; + register struct mt_softc *sc = &mt_softc[hd->hp_unit]; register int id; register struct buf *bp; - + + sc->sc_hd = hd; + for (bp = mttab; bp < &mttab[NMT]; bp++) bp->b_actb = &bp->b_actf; unit = hpibid(hpibno, slave); for (id = 0; id < nmtinfo; id++) if (unit == mtinfo[id].hwid) - goto gottype; + return (1); return (0); /* not a known HP magtape */ +} + +void +mtattach(hd) + register struct hp_device *hd; +{ + register int unit; + register int hpibno = hd->hp_ctlr; + register int slave = hd->hp_slave; + register struct mt_softc *sc; + register int id; + register struct buf *bp; + + /* XXX Ick. */ + unit = hpibid(hpibno, slave); + for (id = 0; id < nmtinfo; id++) + if (unit == mtinfo[id].hwid) + break; - gottype: unit = hd->hp_unit; sc = &mt_softc[unit]; sc->sc_type = mtinfo[id].hwid; - printf("mt%d: %s tape\n", unit, mtinfo[id].desc); + printf(": %s tape\n", mtinfo[id].desc); sc->sc_hpibno = hpibno; sc->sc_slave = slave; @@ -127,7 +148,6 @@ mtinit(hd) sc->sc_dq.dq_unit = unit; sc->sc_dq.dq_slave = slave; sc->sc_dq.dq_driver = &mtdriver; - return (1); } /* @@ -248,7 +268,7 @@ mtopen(dev, flag, mode, p) goto errout; } if (!(sc->sc_stat1 & SR1_ONLINE)) { - uprintf("mt%d: not online\n", unit); + uprintf("%s: not online\n", sc->sc_hd->hp_xname); error = EIO; goto errout; } @@ -285,7 +305,8 @@ mtopen(dev, flag, mode, p) if (flag & FWRITE) { if (!(sc->sc_stat1 & SR1_BOT)) { if (sc->sc_density != req_den) { - uprintf("mt%d: can't change density mid-tape\n", unit); + uprintf("%s: can't change density mid-tape\n", + sc->sc_hd->hp_xname); error = EIO; goto errout; } @@ -376,8 +397,8 @@ mtstrategy(bp) #if 0 if (bp->b_bcount & ((1 << WRITE_BITS_IGNORED) - 1)) { tprintf(sc->sc_ttyp, - "mt%d: write record must be multiple of %d\n", - unit, 1 << WRITE_BITS_IGNORED); + "%s: write record must be multiple of %d\n", + sc->sc_hd->hp_xname, 1 << WRITE_BITS_IGNORED); goto error; } #endif @@ -396,8 +417,8 @@ mtstrategy(bp) } if (bp->b_bcount > s) { tprintf(sc->sc_ttyp, - "mt%d: write record (%d) too big: limit (%d)\n", - unit, bp->b_bcount, s); + "%s: write record (%d) too big: limit (%d)\n", + sc->sc_hd->hp_xname, bp->b_bcount, s); error: bp->b_flags |= B_ERROR; bp->b_error = EIO; @@ -732,8 +753,8 @@ mtintr(unit) } if (sc->sc_stat1 & (SR1_ERR | SR1_REJECT)) { i = sc->sc_stat4 & SR4_ERCLMASK; - log(LOG_ERR, "mt%d: %s error, retry %d, SR2/3 %x/%x, code %d\n", - unit, i == SR4_DEVICE ? "device" : + log(LOG_ERR, "%s: %s error, retry %d, SR2/3 %x/%x, code %d\n", + sc->sc_hd->hp_xname, i == SR4_DEVICE ? "device" : (i == SR4_PROTOCOL ? "protocol" : (i == SR4_SELFTEST ? "selftest" : "unknown")), sc->sc_stat4 & SR4_RETRYMASK, sc->sc_stat2, @@ -749,8 +770,8 @@ mtintr(unit) * Report and clear any soft errors. */ if (sc->sc_stat1 & SR1_SOFTERR) { - log(LOG_WARNING, "mt%d: soft error, retry %d\n", - unit, sc->sc_stat4 & SR4_RETRYMASK); + log(LOG_WARNING, "%s: soft error, retry %d\n", + sc->sc_hd->hp_xname, sc->sc_stat4 & SR4_RETRYMASK); sc->sc_stat1 &= ~SR1_SOFTERR; } /* @@ -810,8 +831,8 @@ mtintr(unit) unit, bp->b_bcount, bp->b_resid); } else { tprintf(sc->sc_ttyp, - "mt%d: record (%d) larger than wanted (%d)\n", - unit, i, bp->b_bcount); + "%s: record (%d) larger than wanted (%d)\n", + sc->sc_hd->hp_xname, i, bp->b_bcount); error: sc->sc_flags &= ~MTF_IO; bp->b_error = EIO; diff --git a/sys/arch/hp300/dev/nhpib.c b/sys/arch/hp300/dev/nhpib.c index 7d2342535a2..f7864d20ecb 100644 --- a/sys/arch/hp300/dev/nhpib.c +++ b/sys/arch/hp300/dev/nhpib.c @@ -1,4 +1,4 @@ -/* $NetBSD: nhpib.c,v 1.6 1995/01/07 10:30:14 mycroft Exp $ */ +/* $NetBSD: nhpib.c,v 1.8 1995/12/02 18:22:06 thorpej Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -74,6 +74,30 @@ static u_char sec_par[] = { 0370,0171,0172,0373,0174,0375,0376,0177 }; +void nhpibreset __P((int)); +int nhpibsend __P((int, int, int, void *, int)); +int nhpibrecv __P((int, int, int, void *, int)); +int nhpibppoll __P((int)); +void nhpibppwatch __P((void *)); +void nhpibgo __P((int, int, int, void *, int, int, int)); +void nhpibdone __P((int)); +int nhpibintr __P((int)); + +/* + * Our controller ops structure. + */ +struct hpib_controller nhpib_controller = { + nhpibreset, + nhpibsend, + nhpibrecv, + nhpibppoll, + nhpibppwatch, + nhpibgo, + nhpibdone, + nhpibintr +}; + +int nhpibtype(hc) register struct hp_ctlr *hc; { @@ -82,19 +106,44 @@ nhpibtype(hc) if (hc->hp_addr == internalhpib) { hs->sc_type = HPIBA; - hs->sc_ba = HPIBA_BA; hc->hp_ipl = HPIBA_IPL; - } - else if (hd->hpib_cid == HPIBB) { + return (1); + } else if (hd->hpib_cid == HPIBB) { hs->sc_type = HPIBB; - hs->sc_ba = hd->hpib_csa & CSA_BA; hc->hp_ipl = HPIB_IPL(hd->hpib_ids); + return (1); } - else - return(0); - return(1); + + return(0); +} + +void +nhpibattach(hc) + register struct hp_ctlr *hc; +{ + struct hpib_softc *hs = &hpib_softc[hc->hp_unit]; + register struct nhpibdevice *hd = (struct nhpibdevice *)hc->hp_addr; + + switch (hs->sc_type) { + case HPIBA: + hs->sc_ba = HPIBA_BA; + hs->sc_descrip = "Internal HP-IB"; + break; + + case HPIBB: + hs->sc_ba = hd->hpib_csa & CSA_BA; + hs->sc_descrip = "98624 HP-IB"; + break; + + default: + panic("nhpibattach: unknown type 0x%x", hs->sc_type); + /* NOTREACHED */ + } + + hs->sc_controller = &nhpib_controller; } +void nhpibreset(unit) int unit; { @@ -132,13 +181,15 @@ nhpibifc(hd) hd->hpib_acr = AUX_SSRE; } -nhpibsend(unit, slave, sec, addr, origcnt) +int +nhpibsend(unit, slave, sec, ptr, origcnt) int unit, slave, sec, origcnt; - register char *addr; + void *ptr; { register struct hpib_softc *hs = &hpib_softc[unit]; register struct nhpibdevice *hd; register int cnt = origcnt; + char *addr = ptr; hd = (struct nhpibdevice *)hs->sc_hc->hp_addr; hd->hpib_acr = AUX_TCA; @@ -188,13 +239,15 @@ senderror: return(origcnt - cnt - 1); } -nhpibrecv(unit, slave, sec, addr, origcnt) +int +nhpibrecv(unit, slave, sec, ptr, origcnt) int unit, slave, sec, origcnt; - register char *addr; + void *ptr; { register struct hpib_softc *hs = &hpib_softc[unit]; register struct nhpibdevice *hd; register int cnt = origcnt; + char *addr = ptr; hd = (struct nhpibdevice *)hs->sc_hc->hp_addr; /* @@ -239,13 +292,14 @@ recvbyteserror: return(origcnt - cnt - 1); } -nhpibgo(unit, slave, sec, addr, count, rw, timo) - register int unit, slave; - int sec, count, rw; - char *addr; +void +nhpibgo(unit, slave, sec, ptr, count, rw, timo) + int unit, slave, sec, count, rw, timo; + void *ptr; { register struct hpib_softc *hs = &hpib_softc[unit]; register struct nhpibdevice *hd; + char *addr = ptr; hd = (struct nhpibdevice *)hs->sc_hc->hp_addr; hs->sc_flags |= HPIBF_IO; @@ -313,6 +367,7 @@ nhpibreadtimo(arg) (void) splx(s); } +void nhpibdone(unit) register int unit; { @@ -344,6 +399,7 @@ nhpibdone(unit) } } +int nhpibintr(unit) register int unit; { @@ -382,13 +438,14 @@ nhpibintr(unit) } #ifdef DEBUG else - printf("hpib%d: PPOLL intr bad status %x\n", - unit, stat0); + printf("%s: PPOLL intr bad status %x\n", + hs->sc_hc->hp_xname, stat0); #endif } return(1); } +int nhpibppoll(unit) int unit; { @@ -407,6 +464,7 @@ nhpibppoll(unit) int nhpibreporttimo = 0; #endif +int nhpibwait(hd, x) register struct nhpibdevice *hd; int x; @@ -446,4 +504,4 @@ again: else timeout(nhpibppwatch, (void *)unit, 1); } -#endif +#endif /* NHPIB > 0 */ diff --git a/sys/arch/hp300/dev/ppi.c b/sys/arch/hp300/dev/ppi.c index 62a41b89493..d34eb549453 100644 --- a/sys/arch/hp300/dev/ppi.c +++ b/sys/arch/hp300/dev/ppi.c @@ -1,4 +1,4 @@ -/* $NetBSD: ppi.c,v 1.6 1994/10/26 07:24:46 cgd Exp $ */ +/* $NetBSD: ppi.c,v 1.7 1995/12/02 18:22:08 thorpej Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -51,10 +51,10 @@ #include <hp300/dev/device.h> #include <hp300/dev/ppiioctl.h> -int ppiattach(), ppistart(); -void ppitimo(); +int ppimatch(), ppistart(); +void ppiattach(), ppitimo(); struct driver ppidriver = { - ppiattach, "ppi", ppistart, + ppimatch, ppiattach, "ppi", ppistart, }; struct ppi_softc { @@ -84,7 +84,8 @@ int ppidebug = 0x80; #define PDB_NOCHECK 0x80 #endif -ppiattach(hd) +int +ppimatch(hd) register struct hp_device *hd; { register struct ppi_softc *sc = &ppi_softc[hd->hp_unit]; @@ -98,14 +99,25 @@ ppiattach(hd) * a cs80 disk or tape for a ppi device. */ if (hpibid(hd->hp_ctlr, hd->hp_slave) & 0x200) - return(0); + return (0); + + sc->sc_hd = hd; + return (1); +} + +void +ppiattach(hd) + register struct hp_device *hd; +{ + struct ppi_softc *sc = &ppi_softc[hd->hp_unit]; + + printf("\n"); + sc->sc_flags = PPIF_ALIVE; sc->sc_dq.dq_ctlr = hd->hp_ctlr; sc->sc_dq.dq_unit = hd->hp_unit; sc->sc_dq.dq_slave = hd->hp_slave; sc->sc_dq.dq_driver = &ppidriver; - sc->sc_hd = hd; - return(1); } ppiopen(dev, flags) diff --git a/sys/arch/hp300/dev/rd.c b/sys/arch/hp300/dev/rd.c index c5a3f3fc767..2b479345a3a 100644 --- a/sys/arch/hp300/dev/rd.c +++ b/sys/arch/hp300/dev/rd.c @@ -1,4 +1,4 @@ -/* $NetBSD: rd.c,v 1.13 1995/10/09 07:57:46 thorpej Exp $ */ +/* $NetBSD: rd.c,v 1.16 1995/12/09 07:31:07 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -69,10 +69,10 @@ #include <vm/vm_prot.h> #include <vm/pmap.h> -int rdinit(), rdstart(), rdgo(), rdintr(); -void rdstrategy(); +int rdmatch(), rdstart(), rdgo(), rdintr(); +void rdattach(), rdstrategy(); struct driver rddriver = { - rdinit, "rd", rdstart, rdgo, rdintr, + rdmatch, rdattach, "rd", rdstart, rdgo, rdintr, }; struct rd_softc rd_softc[NRD]; @@ -162,38 +162,88 @@ int rddebug = 0x80; * Nothing really critical here, could do without it. */ struct rdidentinfo rdidentinfo[] = { - { RD7946AID, 0, "7945A", 108416 }, - { RD9134DID, 1, "9134D", 29088 }, - { RD9134LID, 1, "9122S", 1232 }, - { RD7912PID, 0, "7912P", 128128 }, - { RD7914PID, 0, "7914P", 258048 }, - { RD7958AID, 0, "7958A", 255276 }, - { RD7957AID, 0, "7957A", 159544 }, - { RD7933HID, 0, "7933H", 789958 }, - { RD9134LID, 1, "9134L", 77840 }, - { RD7936HID, 0, "7936H", 600978 }, - { RD7937HID, 0, "7937H", 1116102 }, - { RD7914CTID, 0, "7914CT", 258048 }, - { RD7946AID, 0, "7946A", 108416 }, - { RD9134LID, 1, "9122D", 1232 }, - { RD7957BID, 0, "7957B", 159894 }, - { RD7958BID, 0, "7958B", 297108 }, - { RD7959BID, 0, "7959B", 594216 }, - { RD2200AID, 0, "2200A", 654948 }, - { RD2203AID, 0, "2203A", 1309896 } + { RD7946AID, 0, "7945A", NRD7945ABPT, + NRD7945ATRK, 968, 108416 }, + + { RD9134DID, 1, "9134D", NRD9134DBPT, + NRD9134DTRK, 303, 29088 }, + + { RD9134LID, 1, "9122S", NRD9122SBPT, + NRD9122STRK, 77, 1232 }, + + { RD7912PID, 0, "7912P", NRD7912PBPT, + NRD7912PTRK, 572, 128128 }, + + { RD7914PID, 0, "7914P", NRD7914PBPT, + NRD7914PTRK, 1152, 258048 }, + + { RD7958AID, 0, "7958A", NRD7958ABPT, + NRD7958ATRK, 1013, 255276 }, + + { RD7957AID, 0, "7957A", NRD7957ABPT, + NRD7957ATRK, 1036, 159544 }, + + { RD7933HID, 0, "7933H", NRD7933HBPT, + NRD7933HTRK, 1321, 789958 }, + + { RD9134LID, 1, "9134L", NRD9134LBPT, + NRD9134LTRK, 973, 77840 }, + + { RD7936HID, 0, "7936H", NRD7936HBPT, + NRD7936HTRK, 698, 600978 }, + + { RD7937HID, 0, "7937H", NRD7937HBPT, + NRD7937HTRK, 698, 1116102 }, + + { RD7914CTID, 0, "7914CT", NRD7914PBPT, + NRD7914PTRK, 1152, 258048 }, + + { RD7946AID, 0, "7946A", NRD7945ABPT, + NRD7945ATRK, 968, 108416 }, + + { RD9134LID, 1, "9122D", NRD9122SBPT, + NRD9122STRK, 77, 1232 }, + + { RD7957BID, 0, "7957B", NRD7957BBPT, + NRD7957BTRK, 1269, 159894 }, + + { RD7958BID, 0, "7958B", NRD7958BBPT, + NRD7958BTRK, 786, 297108 }, + + { RD7959BID, 0, "7959B", NRD7959BBPT, + NRD7959BTRK, 1572, 594216 }, + + { RD2200AID, 0, "2200A", NRD2200ABPT, + NRD2200ATRK, 1449, 654948 }, + + { RD2203AID, 0, "2203A", NRD2203ABPT, + NRD2203ATRK, 1449, 1309896 } }; int numrdidentinfo = sizeof(rdidentinfo) / sizeof(rdidentinfo[0]); -rdinit(hd) +int +rdmatch(hd) register struct hp_device *hd; { register struct rd_softc *rs = &rd_softc[hd->hp_unit]; rs->sc_hd = hd; rs->sc_punit = rdpunit(hd->hp_flags); - rs->sc_type = rdident(rs, hd); + rs->sc_type = rdident(rs, hd, 0); if (rs->sc_type < 0) - return(0); + return (0); + + return (1); +} + +void +rdattach(hd) + register struct hp_device *hd; +{ + register struct rd_softc *rs = &rd_softc[hd->hp_unit]; + + (void)rdident(rs, hd, 1); /* XXX Ick. */ + rs->sc_dq.dq_ctlr = hd->hp_ctlr; rs->sc_dq.dq_unit = hd->hp_unit; rs->sc_dq.dq_slave = hd->hp_slave; @@ -204,14 +254,15 @@ rdinit(hd) if (rddebug & RDB_ERROR) rderrthresh = 0; #endif - return(1); } -rdident(rs, hd) +int +rdident(rs, hd, verbose) struct rd_softc *rs; struct hp_device *hd; + int verbose; { - struct rd_describe desc; + struct rd_describe *desc = &rs->sc_rddesc; u_char stat, cmd[3]; int unit, lunit; char name[7]; @@ -252,33 +303,34 @@ rdident(rs, hd) cmd[1] = C_SVOL(0); cmd[2] = C_DESC; hpibsend(ctlr, slave, C_CMD, cmd, sizeof(cmd)); - hpibrecv(ctlr, slave, C_EXEC, &desc, 37); + hpibrecv(ctlr, slave, C_EXEC, desc, 37); hpibrecv(ctlr, slave, C_QSTAT, &stat, sizeof(stat)); bzero(name, sizeof(name)); if (!stat) { - register int n = desc.d_name; + register int n = desc->d_name; for (i = 5; i >= 0; i--) { name[i] = (n & 0xf) + '0'; n >>= 4; } /* use drive characteristics to calculate xfer rate */ - rs->sc_wpms = 1000000 * (desc.d_sectsize/2) / desc.d_blocktime; + rs->sc_wpms = 1000000 * (desc->d_sectsize/2) / + desc->d_blocktime; } #ifdef DEBUG if (rddebug & RDB_IDENT) { printf("rd%d: name: %x ('%s')\n", - lunit, desc.d_name, name); + lunit, desc->d_name, name); printf(" iuw %x, maxxfr %d, ctype %d\n", - desc.d_iuw, desc.d_cmaxxfr, desc.d_ctype); + desc->d_iuw, desc->d_cmaxxfr, desc->d_ctype); printf(" utype %d, bps %d, blkbuf %d, burst %d, blktime %d\n", - desc.d_utype, desc.d_sectsize, - desc.d_blkbuf, desc.d_burstsize, desc.d_blocktime); + desc->d_utype, desc->d_sectsize, + desc->d_blkbuf, desc->d_burstsize, desc->d_blocktime); printf(" avxfr %d, ort %d, atp %d, maxint %d, fv %x, rv %x\n", - desc.d_uavexfr, desc.d_retry, desc.d_access, - desc.d_maxint, desc.d_fvbyte, desc.d_rvbyte); + desc->d_uavexfr, desc->d_retry, desc->d_access, + desc->d_maxint, desc->d_fvbyte, desc->d_rvbyte); printf(" maxcyl/head/sect %d/%d/%d, maxvsect %d, inter %d\n", - desc.d_maxcyl, desc.d_maxhead, desc.d_maxsect, - desc.d_maxvsectl, desc.d_interleave); + desc->d_maxcyl, desc->d_maxhead, desc->d_maxsect, + desc->d_maxvsectl, desc->d_interleave); } #endif /* @@ -309,7 +361,18 @@ rdident(rs, hd) id = RD9134D; break; } - printf("rd%d: %s\n", lunit, rdidentinfo[id].ri_desc); + /* + * XXX We use DEV_BSIZE instead of the sector size value pulled + * off the driver because all of this code assumes 512 byte + * blocks. ICK! + */ + if (verbose) { + printf(": %s\n", rdidentinfo[id].ri_desc); + printf("%s: %d cylinders, %d heads, %d blocks, %d bytes/block\n", + rs->sc_hd->hp_xname, rdidentinfo[id].ri_ncyl, + rdidentinfo[id].ri_ntpc, rdidentinfo[id].ri_nblocks, + DEV_BSIZE); + } return(id); } @@ -379,12 +442,12 @@ rdgetinfo(dev) /* * Now try to read the disklabel */ - msg = readdisklabel(rdlabdev(dev), rdstrategy, lp); + msg = readdisklabel(rdlabdev(dev), rdstrategy, lp, NULL); if (msg == NULL) return(0); pi = lp->d_partitions; - printf("rd%d: WARNING: %s, ", unit, msg); + printf("%s: WARNING: %s, ", rs->sc_hd->hp_xname, msg); #ifdef COMPAT_NOLABEL printf("using old default partitioning\n"); rdmakedisklabel(unit, lp); @@ -643,8 +706,8 @@ again: */ #ifdef DEBUG if (rddebug & RDB_ERROR) - printf("rd%d: rdstart: cmd %x adr %d blk %d len %d ecnt %d\n", - unit, rs->sc_ioc.c_cmd, rs->sc_ioc.c_addr, + printf("%s: rdstart: cmd %x adr %d blk %d len %d ecnt %d\n", + rs->sc_hd->hp_xname, rs->sc_ioc.c_cmd, rs->sc_ioc.c_addr, bp->b_blkno, rs->sc_resid, rdtab[unit].b_errcnt); rdstats[unit].rdretries++; #endif @@ -652,8 +715,8 @@ again: rdreset(rs, hp); if (rdtab[unit].b_errcnt++ < RDRETRY) goto again; - printf("rd%d: rdstart err: cmd 0x%x sect %d blk %d len %d\n", - unit, rs->sc_ioc.c_cmd, rs->sc_ioc.c_addr, + printf("%s: rdstart err: cmd 0x%x sect %d blk %d len %d\n", + rs->sc_hd->hp_xname, rs->sc_ioc.c_cmd, rs->sc_ioc.c_addr, bp->b_blkno, rs->sc_resid); bp->b_flags |= B_ERROR; bp->b_error = EIO; @@ -703,7 +766,7 @@ rdintr(unit) printf("rdintr(%d): bp %x, %c, flags %x\n", unit, bp, (bp->b_flags & B_READ) ? 'R' : 'W', rs->sc_flags); if (bp == NULL) { - printf("rd%d: bp == NULL\n", unit); + printf("%s: bp == NULL\n", rs->sc_hd->hp_xname); return; } #endif @@ -812,7 +875,7 @@ rderror(unit) if (rdstatus(rs)) { #ifdef DEBUG - printf("rd%d: couldn't get status\n", unit); + printf("%s: couldn't get status\n", rs->sc_hd->hp_xname); #endif rdreset(rs, rs->sc_hd); return(1); @@ -835,8 +898,8 @@ rderror(unit) extern int hz; int rdtimo = RDWAITC << rdtab[unit].b_errcnt; #ifdef DEBUG - printf("rd%d: internal maintenance, %d second timeout\n", - unit, rdtimo); + printf("%s: internal maintenance, %d second timeout\n", + rs->sc_hd->hp_xname, rdtimo); rdstats[unit].rdtimeouts++; #endif hpibfree(&rs->sc_dq); diff --git a/sys/arch/hp300/dev/rd_compat.c b/sys/arch/hp300/dev/rd_compat.c index cf7f001b81a..239dd4bc0e6 100644 --- a/sys/arch/hp300/dev/rd_compat.c +++ b/sys/arch/hp300/dev/rd_compat.c @@ -1,4 +1,4 @@ -/* $NetBSD: rd_compat.c,v 1.3 1994/10/26 07:24:52 cgd Exp $ */ +/* $NetBSD: rd_compat.c,v 1.4 1995/11/19 19:07:20 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -228,49 +228,45 @@ struct size { * Indexed the same as rdidentinfo array. */ struct rdcompatinfo { - int nbpt; /* DEV_BSIZE blocks per track */ - int ntpc; /* tracks per cylinder */ - int ncyl; /* cylinders per unit */ struct size *sizes; /* partition info */ } rdcompatinfo[] = { - NRD7945ABPT, NRD7945ATRK, 968, rd7945A_sizes, - NRD9134DBPT, NRD9134DTRK, 303, rd9134D_sizes, - NRD9122SBPT, NRD9122STRK, 77, rd9122S_sizes, - NRD7912PBPT, NRD7912PTRK, 572, rd7912P_sizes, - NRD7914PBPT, NRD7914PTRK, 1152, rd7914P_sizes, - NRD7958ABPT, NRD7958ATRK, 1013, rd7958A_sizes, - NRD7957ABPT, NRD7957ATRK, 1036, rd7957A_sizes, - NRD7933HBPT, NRD7933HTRK, 1321, rd7933H_sizes, - NRD9134LBPT, NRD9134LTRK, 973, rd9134L_sizes, - NRD7936HBPT, NRD7936HTRK, 698, rd7936H_sizes, - NRD7937HBPT, NRD7937HTRK, 698, rd7937H_sizes, - NRD7914PBPT, NRD7914PTRK, 1152, rd7914P_sizes, - NRD7945ABPT, NRD7945ATRK, 968, rd7945A_sizes, - NRD9122SBPT, NRD9122STRK, 77, rd9122S_sizes, - NRD7957BBPT, NRD7957BTRK, 1269, rd7957B_sizes, - NRD7958BBPT, NRD7958BTRK, 786, rd7958B_sizes, - NRD7959BBPT, NRD7959BTRK, 1572, rd7959B_sizes, - NRD2200ABPT, NRD2200ATRK, 1449, rd2200A_sizes, - NRD2203ABPT, NRD2203ATRK, 1449, rd2203A_sizes, + rd7945A_sizes, + rd9134D_sizes, + rd9122S_sizes, + rd7912P_sizes, + rd7914P_sizes, + rd7958A_sizes, + rd7957A_sizes, + rd7933H_sizes, + rd9134L_sizes, + rd7936H_sizes, + rd7937H_sizes, + rd7914P_sizes, + rd7945A_sizes, + rd9122S_sizes, + rd7957B_sizes, + rd7958B_sizes, + rd7959B_sizes, + rd2200A_sizes, + rd2203A_sizes, }; int nrdcompatinfo = sizeof(rdcompatinfo) / sizeof(rdcompatinfo[0]); -extern struct rd_softc rd_softc[]; - rdmakedisklabel(unit, lp) int unit; struct disklabel *lp; { register struct rd_softc *rs = &rd_softc[unit]; register struct rdcompatinfo *ci = &rdcompatinfo[rs->sc_type]; + struct rdidentinfo *ri = &rdidentinfo[rs->sc_type]; register struct partition *pi; register int dcount; - lp->d_nsectors = ci->nbpt; - lp->d_ntracks = ci->ntpc; - lp->d_ncylinders = ci->ncyl; - lp->d_secpercyl = ci->nbpt * ci->ntpc; - lp->d_secperunit = lp->d_secpercyl * ci->ncyl; + lp->d_nsectors = ri->ri_nbpt; + lp->d_ntracks = ri->ri_ntpc; + lp->d_ncylinders = ri->ri_ncyl; + lp->d_secpercyl = ri->ri_nbpt * ri->ri_ntpc; + lp->d_secperunit = lp->d_secpercyl * ri->ri_ncyl; lp->d_rpm = 3600; lp->d_interleave = 1; lp->d_npartitions = 8; diff --git a/sys/arch/hp300/dev/rdvar.h b/sys/arch/hp300/dev/rdvar.h index 2bd93d2715f..6d1214d46a7 100644 --- a/sys/arch/hp300/dev/rdvar.h +++ b/sys/arch/hp300/dev/rdvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: rdvar.h,v 1.2 1994/10/26 07:24:56 cgd Exp $ */ +/* $NetBSD: rdvar.h,v 1.3 1995/11/19 19:07:21 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -46,6 +46,9 @@ struct rdidentinfo { short ri_hwid; /* 2 byte HW id */ short ri_maxunum; /* maximum allowed unit number */ char *ri_desc; /* drive type description */ + int ri_nbpt; /* DEV_BSIZE blocks per track */ + int ri_ntpc; /* tracks per cylinder */ + int ri_ncyl; /* cylinders per unit */ int ri_nblocks; /* DEV_BSIZE blocks on disk */ }; @@ -65,6 +68,7 @@ struct rd_softc { int sc_resid; u_int sc_wpms; struct rdinfo sc_info; + struct rd_describe sc_rddesc; struct devqueue sc_dq; struct rd_iocmd sc_ioc; struct rd_rscmd sc_rsc; @@ -100,3 +104,8 @@ struct rdstats { #define RDRETRY 5 #define RDWAITC 1 /* min time for timeout in seconds */ + +#ifdef _KERNEL +extern struct rdidentinfo rdidentinfo[]; +extern struct rd_softc rd_softc[]; +#endif diff --git a/sys/arch/hp300/dev/scsi.c b/sys/arch/hp300/dev/scsi.c index 04e69fdf8a2..b61f563dd8d 100644 --- a/sys/arch/hp300/dev/scsi.c +++ b/sys/arch/hp300/dev/scsi.c @@ -1,4 +1,4 @@ -/* $NetBSD: scsi.c,v 1.5.2.1 1995/10/16 09:01:39 thorpej Exp $ */ +/* $NetBSD: scsi.c,v 1.7 1995/12/02 18:22:12 thorpej Exp $ */ /* * Copyright (c) 1990, 1993 @@ -72,10 +72,10 @@ extern void isrlink(); extern void _insque(); extern void _remque(); -int scsiinit(), scsigo(), scsiintr(), scsixfer(); -void scsistart(), scsidone(), scsifree(), scsireset(); +int scsimatch(), scsigo(), scsiintr(), scsixfer(); +void scsiattach(), scsistart(), scsidone(), scsifree(), scsireset(); struct driver scsidriver = { - scsiinit, "scsi", (int (*)())scsistart, scsigo, scsiintr, + scsimatch, scsiattach, "scsi", (int (*)())scsistart, scsigo, scsiintr, (int (*)())scsidone, }; @@ -122,8 +122,8 @@ scsiabort(hs, hd, where) int startlen; /* XXX - kludge till I understand whats *supposed* to happen */ u_char junk; - printf("scsi%d: abort from %s: phase=0x%x, ssts=0x%x, ints=0x%x\n", - hs->sc_hc->hp_unit, where, hd->scsi_psns, hd->scsi_ssts, + printf("%s: abort from %s: phase=0x%x, ssts=0x%x, ints=0x%x\n", + hs->sc_hc->hp_xname, where, hd->scsi_psns, hd->scsi_ssts, hd->scsi_ints); hd->scsi_ints = hd->scsi_ints; @@ -178,8 +178,8 @@ out: * Either way, reset the card & the SPC. */ if (len < 0 && hs) - printf("scsi%d: abort failed. phase=0x%x, ssts=0x%x\n", - hs->sc_hc->hp_unit, hd->scsi_psns, hd->scsi_ssts); + printf("%s: abort failed. phase=0x%x, ssts=0x%x\n", + hs->sc_hc->hp_xname, hd->scsi_psns, hd->scsi_ssts); if (! ((junk = hd->scsi_ints) & INTS_RESEL)) { hd->scsi_sctl |= SCTL_CTRLRST; @@ -220,15 +220,39 @@ scsi_delay(delay) } int -scsiinit(hc) +scsimatch(hc) register struct hp_ctlr *hc; { register struct scsi_softc *hs = &scsi_softc[hc->hp_unit]; register struct scsidevice *hd = (struct scsidevice *)hc->hp_addr; - - if ((hd->scsi_id & ID_MASK) != SCSI_ID) - return(0); - hc->hp_ipl = SCSI_IPL(hd->scsi_csr); + struct hp_hw *hw = hc->hp_args; + + /* + * This is probably a little redundant, but what the heck. + */ + switch (hw->hw_id) { + case 7: + case 7+32: + case 7+64: + case 7+96: + if ((hd->scsi_id & ID_MASK) != SCSI_ID) + return (0); + + hc->hp_ipl = SCSI_IPL(hd->scsi_csr); + return (1); + /* NOTREACHED */ + } + + return (0); +} + +void +scsiattach(hc) + struct hp_ctlr *hc; +{ + register struct scsi_softc *hs = &scsi_softc[hc->hp_unit]; + register struct scsidevice *hd = (struct scsidevice *)hc->hp_addr; + hs->sc_hc = hc; hs->sc_dq.dq_unit = hc->hp_unit; hs->sc_dq.dq_driver = &scsidriver; @@ -238,12 +262,45 @@ scsiinit(hc) scsi_isr[hc->hp_unit].isr_arg = hc->hp_unit; isrlink(&scsi_isr[hc->hp_unit]); scsireset(hc->hp_unit); + + /* + * Print information about what we've found. + */ + printf(":"); + if (hs->sc_flags & SCSI_DMA32) + printf(" 32 bit dma, "); + + switch (hs->sc_sync) { + case 0: + printf("async"); + break; + + case (TMOD_SYNC | 0x3e): + printf("250ns sync"); + break; + + case (TMOD_SYNC | 0x5e): + printf("375ns sync"); + break; + + case (TMOD_SYNC | 0x7d): + printf("500ns sync"); + break; + + default: + panic("scsiattach: unknown sync param 0x%x", hs->sc_sync); + } + + if ((hd->scsi_hconf & HCONF_PARITY) == 0) + printf(", no parity"); + + printf(", scsi id %d\n", hs->sc_scsiid); + /* * XXX scale initialization wait according to CPU speed. * Should we do this for all wait? Should we do this at all? */ scsi_init_wait *= cpuspeed; - return(1); } void @@ -258,8 +315,6 @@ scsireset(unit) if (hs->sc_flags & SCSI_ALIVE) scsiabort(hs, hd, "reset"); - printf("scsi%d: ", unit); - hd->scsi_id = 0xFF; DELAY(100); /* @@ -276,10 +331,8 @@ scsireset(unit) hd->scsi_tcl = 0; hd->scsi_ints = 0; - if ((hd->scsi_id & ID_WORD_DMA) == 0) { + if ((hd->scsi_id & ID_WORD_DMA) == 0) hs->sc_flags |= SCSI_DMA32; - printf("32 bit dma, "); - } /* Determine Max Synchronous Transfer Rate */ if (scsi_nosync) @@ -289,19 +342,15 @@ scsireset(unit) switch (i) { case 0: hs->sc_sync = TMOD_SYNC | 0x3e; /* 250 nsecs */ - printf("250ns sync"); break; case 1: hs->sc_sync = TMOD_SYNC | 0x5e; /* 375 nsecs */ - printf("375ns sync"); break; case 2: hs->sc_sync = TMOD_SYNC | 0x7d; /* 500 nsecs */ - printf("500ns sync"); break; case 3: hs->sc_sync = 0; - printf("async"); break; } @@ -312,19 +361,17 @@ scsireset(unit) i = (~hd->scsi_hconf) & 0x7; hs->sc_scsi_addr = 1 << i; hd->scsi_bdid = i; + hs->sc_scsiid = i; if (hd->scsi_hconf & HCONF_PARITY) hd->scsi_sctl = SCTL_DISABLE | SCTL_ABRT_ENAB | SCTL_SEL_ENAB | SCTL_RESEL_ENAB | SCTL_INTR_ENAB | SCTL_PARITY_ENAB; - else { + else hd->scsi_sctl = SCTL_DISABLE | SCTL_ABRT_ENAB | SCTL_SEL_ENAB | SCTL_RESEL_ENAB | SCTL_INTR_ENAB; - printf(", no parity"); - } - hd->scsi_sctl &=~ SCTL_DISABLE; - printf(", scsi id %d\n", i); + hd->scsi_sctl &=~ SCTL_DISABLE; hs->sc_flags |= SCSI_ALIVE; } @@ -337,7 +384,7 @@ scsierror(hs, hd, ints) int unit = hs->sc_hc->hp_unit; char *sep = ""; - printf("scsi%d: ", unit); + printf("%s: ", hs->sc_hc->hp_xname); if (ints & INTS_RST) { DELAY(100); if (hd->scsi_hconf & HCONF_SD) @@ -668,8 +715,8 @@ scsiicmd(hs, target, cbuf, clen, buf, len, xferphase) goto out; default: - printf("scsi%d: unexpected phase %d in icmd from %d\n", - hs->sc_hc->hp_unit, phase, target); + printf("%s: unexpected phase %d in icmd from %d\n", + hs->sc_hc->hp_xname, phase, target); goto abort; } /* wait for last command to complete */ @@ -773,8 +820,8 @@ finishxfer(hs, hd, target) return; default: - printf("scsi%d: unexpected phase %d in finishxfer from %d\n", - hs->sc_hc->hp_unit, phase, target); + printf("%s: unexpected phase %d in finishxfer from %d\n", + hs->sc_hc->hp_xname, phase, target); goto abort; } if (ints = hd->scsi_ints) { @@ -996,8 +1043,8 @@ scsigo(ctlr, slave, unit, bp, cdb, pad) goto out; default: - printf("scsi%d: unexpected phase %d in go from %d\n", - hs->sc_hc->hp_unit, phase, slave); + printf("%s: unexpected phase %d in go from %d\n", + hs->sc_hc->hp_xname, phase, slave); goto abort; } while ((ints = hd->scsi_ints) == 0) { @@ -1073,8 +1120,8 @@ out: #ifdef DEBUG hs->sc_flags |= SCSI_PAD; if (i & 1) - printf("scsi%d: odd byte count: %d bytes @ %d\n", - ctlr, i, bp->b_cylin); + printf("%s: odd byte count: %d bytes @ %d\n", + hs->sc_hc->hp_xname, i, bp->b_cylin); #endif } else i += 4; @@ -1102,7 +1149,7 @@ scsidone(unit) #ifdef DEBUG if (scsi_debug) - printf("scsi%d: done called!\n", unit); + printf("%s: done called!\n", scsi_softc[unit].sc_hc->hp_xname); #endif /* dma operation is done -- turn off card dma */ hd->scsi_csr &=~ (CSR_DE1|CSR_DE0); diff --git a/sys/arch/hp300/dev/scsivar.h b/sys/arch/hp300/dev/scsivar.h index 8e8941f73aa..6f7db737286 100644 --- a/sys/arch/hp300/dev/scsivar.h +++ b/sys/arch/hp300/dev/scsivar.h @@ -1,4 +1,4 @@ -/* $NetBSD: scsivar.h,v 1.4 1994/10/26 07:25:01 cgd Exp $ */ +/* $NetBSD: scsivar.h,v 1.5 1995/12/02 18:22:14 thorpej Exp $ */ /* * Copyright (c) 1990, 1993 @@ -45,6 +45,7 @@ struct scsi_softc { u_char sc_flags; u_char sc_sync; u_char sc_scsi_addr; + u_char sc_scsiid; /* XXX unencoded copy of sc_scsi_addr */ u_char sc_stat[2]; u_char sc_msg[7]; }; diff --git a/sys/arch/hp300/dev/sd.c b/sys/arch/hp300/dev/sd.c index 3f3bf119f19..c6c26a42bbb 100644 --- a/sys/arch/hp300/dev/sd.c +++ b/sys/arch/hp300/dev/sd.c @@ -1,4 +1,4 @@ -/* $NetBSD: sd.c,v 1.16.2.2 1995/10/16 09:01:36 thorpej Exp $ */ +/* $NetBSD: sd.c,v 1.20 1995/12/09 07:31:03 thorpej Exp $ */ /* * Copyright (c) 1990, 1993 @@ -85,11 +85,12 @@ extern void biodone(); extern int physio(); extern void TBIS(); -int sdinit(); -void sdstrategy(), sdstart(), sdustart(), sdgo(), sdintr(); +int sdmatch(); +void sdattach(), sdstrategy(), sdstart(), sdustart(), sdgo(), sdintr(); struct driver sddriver = { - sdinit, "sd", (int (*)())sdstart, (int (*)())sdgo, (int (*)())sdintr, + sdmatch, sdattach, "sd", (int (*)())sdstart, + (int (*)())sdgo, (int (*)())sdintr, }; #ifdef DEBUG @@ -170,9 +171,10 @@ sdgetgeom(sc, hd) } static int -sdident(sc, hd) +sdident(sc, hd, verbose) struct sd_softc *sc; struct hp_device *hd; + int verbose; { int unit; register int ctlr, slave; @@ -265,45 +267,50 @@ sdident(sc, hd) switch (inqbuf.version) { case 1: case 2: - printf("sd%d: %s %s", hd->hp_unit, vendor, product); - if (revision[0] != '\0') - printf(" rev %s", revision); - if (inqbuf.version == 2) - printf(" (SCSI-2)"); + if (verbose) { + printf(": <%s, %s, %s>", vendor, product, revision); + if (inqbuf.version == 2) + printf(" (SCSI-2)"); + } break; default: - printf("sd%d: type 0x%x, qual 0x%x, ver %d", hd->hp_unit, - inqbuf.type, inqbuf.qual, inqbuf.version); + if (verbose) + printf(": type 0x%x, qual 0x%x, ver %d", + inqbuf.type, inqbuf.qual, inqbuf.version); break; } - printf("\n"); + if (verbose) + printf("\n"); - /* - * Print out some additional information. - */ - printf("sd%d: ", hd->hp_unit); - switch (inqbuf.type) { - case 4: - printf("WORM, "); - break; + if (verbose) { + /* + * Print out some additional information. + */ + printf("%s: ", hd->hp_xname); + switch (inqbuf.type) { + case 4: + printf("WORM, "); + break; - case 5: - printf("CD-ROM, "); - break; + case 5: + printf("CD-ROM, "); + break; - case 7: - printf("Magneto-optical, "); - break; + case 7: + printf("Magneto-optical, "); + break; - default: - printf("%d cylinders, %d heads, ", sc->sc_cyls, sc->sc_heads); - } + default: + printf("%d cylinders, %d heads, ", + sc->sc_cyls, sc->sc_heads); + } - if (sc->sc_blks) - printf("%d blocks, %d bytes/block\n", - sc->sc_blks >> sc->sc_bshift, sc->sc_blksize); - else - printf("drive empty\n"); + if (sc->sc_blks) + printf("%d blocks, %d bytes/block\n", + sc->sc_blks >> sc->sc_bshift, sc->sc_blksize); + else + printf("drive empty\n"); + } sc->sc_wpms = 32 * (60 * DEV_BSIZE / 2); /* XXX */ scsi_delay(0); @@ -314,7 +321,7 @@ failed: } int -sdinit(hd) +sdmatch(hd) register struct hp_device *hd; { register struct sd_softc *sc = &sd_softc[hd->hp_unit]; @@ -327,16 +334,27 @@ sdinit(hd) */ sc->sc_format_pid = -1; sc->sc_punit = sdpunit(hd->hp_flags); - sc->sc_type = sdident(sc, hd); + sc->sc_type = sdident(sc, hd, 0); if (sc->sc_type < 0) - return(0); + return (0); + + return (1); +} + +void +sdattach(hd) + register struct hp_device *hd; +{ + struct sd_softc *sc = &sd_softc[hd->hp_unit]; + + (void)sdident(sc, hd, 1); /* XXX Ick. */ + sc->sc_dq.dq_ctlr = hd->hp_ctlr; sc->sc_dq.dq_unit = hd->hp_unit; sc->sc_dq.dq_slave = hd->hp_slave; sc->sc_dq.dq_driver = &sddriver; sc->sc_flags |= SDF_ALIVE; - return(1); } void @@ -400,8 +418,8 @@ sdgetcapacity(sc, hd, dev) if (i != STS_CHECKCOND || (sc->sc_flags & SDF_RMEDIA) == 0) { #ifdef DEBUG if (sddebug & SDB_CAPACITY) - printf("sd%d: read_capacity returns %d\n", - hd->hp_unit, i); + printf("%s: read_capacity returns %d\n", + hd->hp_xname, i); #endif free(capbuf, M_DEVBUF); return (-1); @@ -414,8 +432,8 @@ sdgetcapacity(sc, hd, dev) sc->sc_bshift = 0; #ifdef DEBUG if (sddebug & SDB_CAPACITY) - printf("sd%d: removable media not present\n", - hd->hp_unit); + printf("%s: removable media not present\n", + hd->hp_xname); #endif free(capbuf, M_DEVBUF); return (1); @@ -430,8 +448,8 @@ sdgetcapacity(sc, hd, dev) if (sc->sc_blksize != DEV_BSIZE) { if (sc->sc_blksize < DEV_BSIZE) { - printf("sd%d: need at least %d byte blocks - %s\n", - hd->hp_unit, DEV_BSIZE, "drive ignored"); + printf("%s: need at least %d byte blocks - %s\n", + hd->hp_xname, DEV_BSIZE, "drive ignored"); return (-1); } for (i = sc->sc_blksize; i > DEV_BSIZE; i >>= 1) @@ -440,7 +458,7 @@ sdgetcapacity(sc, hd, dev) } #ifdef DEBUG if (sddebug & SDB_CAPACITY) - printf("sd%d: blks=%d, blksize=%d, bshift=%d\n", hd->hp_unit, + printf("%s: blks=%d, blksize=%d, bshift=%d\n", hd->hp_xname, sc->sc_blks, sc->sc_blksize, sc->sc_bshift); #endif sdgetgeom(sc, hd); @@ -520,13 +538,13 @@ sdgetinfo(dev) /* XXX ensure size is at least one device block */ lp->d_partitions[2].p_size = roundup(LABELSECTOR+1, btodb(sc->sc_blksize)); - msg = readdisklabel(sdlabdev(dev), sdstrategy, lp); + msg = readdisklabel(sdlabdev(dev), sdstrategy, lp, NULL); if (msg == NULL) return (0); } pi = lp->d_partitions; - printf("sd%d: WARNING: %s, ", unit, msg); + printf("%s: WARNING: %s, ", sc->sc_hd->hp_xname, msg); #ifdef COMPAT_NOLABEL if (usedefault) { printf("using old default partitioning\n"); @@ -825,7 +843,7 @@ sderror(unit, sc, hp, stat) sc->sc_punit, sdsense[unit].sense, sizeof(sdsense[unit].sense)); sp = (struct scsi_xsense *)sdsense[unit].sense; - printf("sd%d: scsi sense class %d, code %d", unit, + printf("%s: scsi sense class %d, code %d", hp->hp_xname, sp->class, sp->code); if (sp->class == 7) { printf(", key %d", sp->key); @@ -955,8 +973,8 @@ sdgo(unit) pad = (bp->b_bcount & (sc->sc_blksize - 1)) != 0; #ifdef DEBUG if (pad) - printf("sd%d: partial block xfer -- %x bytes\n", - unit, bp->b_bcount); + printf("%s: partial block xfer -- %x bytes\n", + sc->sc_hd->hp_xname, bp->b_bcount); #endif sdstats[unit].sdtransfers++; } @@ -975,8 +993,9 @@ sdgo(unit) } #ifdef DEBUG if (sddebug & SDB_ERROR) - printf("sd%d: sdstart: %s adr %d blk %d len %d ecnt %d\n", - unit, bp->b_flags & B_READ? "read" : "write", + printf("%s: sdstart: %s adr %d blk %d len %d ecnt %d\n", + sc->sc_hd->hp_xname, + bp->b_flags & B_READ? "read" : "write", bp->b_un.b_addr, bp->b_cylin, bp->b_bcount, sdtab[unit].b_errcnt); #endif @@ -996,7 +1015,7 @@ sdintr(unit, stat) int cond; if (bp == NULL) { - printf("sd%d: bp == NULL\n", unit); + printf("%s: bp == NULL\n", sc->sc_hd->hp_xname); return; } if (hp->hp_dk >= 0) @@ -1004,16 +1023,17 @@ sdintr(unit, stat) if (stat) { #ifdef DEBUG if (sddebug & SDB_ERROR) - printf("sd%d: sdintr: bad scsi status 0x%x\n", - unit, stat); + printf("%s: sdintr: bad scsi status 0x%x\n", + sc->sc_hd->hp_xname, stat); #endif cond = sderror(unit, sc, hp, stat); if (cond) { if (cond < 0 && sdtab[unit].b_errcnt++ < SDRETRY) { #ifdef DEBUG if (sddebug & SDB_ERROR) - printf("sd%d: retry #%d\n", - unit, sdtab[unit].b_errcnt); + printf("%s: retry #%d\n", + sc->sc_hd->hp_xname, + sdtab[unit].b_errcnt); #endif sdstart(unit); return; diff --git a/sys/arch/hp300/dev/sdvar.h b/sys/arch/hp300/dev/sdvar.h index 906227f927f..13a74c6398a 100644 --- a/sys/arch/hp300/dev/sdvar.h +++ b/sys/arch/hp300/dev/sdvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: sdvar.h,v 1.2.2.1 1995/10/15 10:11:06 thorpej Exp $ */ +/* $NetBSD: sdvar.h,v 1.3 1995/10/15 10:03:20 thorpej Exp $ */ /* * Copyright (c) 1990, 1993 diff --git a/sys/arch/hp300/dev/st.c b/sys/arch/hp300/dev/st.c index b7bcf6265c4..69841b2f550 100644 --- a/sys/arch/hp300/dev/st.c +++ b/sys/arch/hp300/dev/st.c @@ -1,4 +1,4 @@ -/* $NetBSD: st.c,v 1.11.2.1 1995/10/16 09:01:38 thorpej Exp $ */ +/* $NetBSD: st.c,v 1.13 1995/12/02 18:22:18 thorpej Exp $ */ /* * Copyright (c) 1990 University of Utah. @@ -104,9 +104,10 @@ extern void scsi_str __P((char *, char *, size_t)); extern int scsi_immed_command(); -int stinit(), ststart(), stgo(), stintr(); +int stmatch(), ststart(), stgo(), stintr(); +void stattach(); struct driver stdriver = { - stinit, "st", ststart, stgo, stintr, + stmatch, stattach, "st", ststart, stgo, stintr, }; struct st_softc { @@ -223,7 +224,8 @@ int st_extti = 0x01; /* bitmask of unit numbers, do extra */ /* sensing so TTi display gets updated */ #endif -stinit(hd) +int +stmatch(hd) register struct hp_device *hd; { register struct st_softc *sc = &st_softc[hd->hp_unit]; @@ -233,21 +235,34 @@ stinit(hd) bp->b_actb = &bp->b_actf; sc->sc_hd = hd; sc->sc_punit = stpunit(hd->hp_flags); - sc->sc_type = stident(sc, hd); + sc->sc_type = stident(sc, hd, 0); if (sc->sc_type < 0) - return(0); + return (0); + + return (1); +} + +void +stattach(hd) + register struct hp_device *hd; +{ + struct st_softc *sc = &st_softc[hd->hp_unit]; + + (void)stident(sc, hd, 1); /* XXX Ick. */ + sc->sc_dq.dq_ctlr = hd->hp_ctlr; sc->sc_dq.dq_unit = hd->hp_unit; sc->sc_dq.dq_slave = hd->hp_slave; sc->sc_dq.dq_driver = &stdriver; sc->sc_blkno = 0; sc->sc_flags = STF_ALIVE; - return(1); } -stident(sc, hd) +int +stident(sc, hd, verbose) register struct st_softc *sc; register struct hp_device *hd; + int verbose; { int unit; int ctlr, slave; @@ -315,12 +330,12 @@ st_inqbuf.inqbuf.qual, st_inqbuf.inqbuf.version); sizeof(st_inqbuf.inqbuf.product_id)); scsi_str(st_inqbuf.inqbuf.rev, revision, sizeof(st_inqbuf.inqbuf.rev)); - printf("st%d: %s, %s rev %s\n", hd->hp_unit, vendor, product, - revision); + if (verbose) + printf(": <%s, %s, %s>\n", vendor, product, revision); } if (stat == 0xff) { - printf("st%d: Cant handle this tape drive\n", hd->hp_unit); + printf("st%d: Can't handle this tape drive\n", hd->hp_unit); goto failed; } @@ -359,8 +374,9 @@ st_inqbuf.inqbuf.qual, st_inqbuf.inqbuf.version); sc->sc_datalen[CMD_MODE_SELECT] = 12; sc->sc_datalen[CMD_MODE_SENSE] = 12; } else { - printf("st%d: Unsupported tape device, faking it\n", - hd->hp_unit); + if (verbose) + printf("%s: Unsupported tape device, faking it\n", + sc->sc_hd->hp_xname); sc->sc_tapeid = MT_ISAR; sc->sc_datalen[CMD_REQUEST_SENSE] = 8; sc->sc_datalen[CMD_INQUIRY] = 5; @@ -618,7 +634,7 @@ retryselect: } break; default: - uprintf("st%d: not ready\n", UNIT(dev)); + uprintf("%s: not ready\n", sc->sc_hd->hp_xname); prtkey(UNIT(dev), sc); break; } @@ -660,7 +676,8 @@ retryselect: sc->sc_filepos = 0; #ifdef DEBUG if (st_debug & ST_FMKS) - printf("st%d: open filepos = %d\n", UNIT(dev), sc->sc_filepos); + printf("%s: open filepos = %d\n", sc->sc_hd->hp_xname, + sc->sc_filepos); #endif sc->sc_flags |= (STF_OPEN); @@ -780,8 +797,9 @@ stgo(unit) nblks = bp->b_bcount / sc->sc_blklen; if (bp->b_bcount % sc->sc_blklen) { tprintf(sc->sc_ctty, - "st%d: I/O not block aligned %d/%ld\n", - unit, sc->sc_blklen, bp->b_bcount); + "%s: I/O not block aligned %d/%ld\n", + sc->sc_hd->hp_xname, sc->sc_blklen, + bp->b_bcount); cmd->cdb[1] &= 0xfe; /* force error */ } } else /* variable len */ @@ -810,8 +828,8 @@ stgo(unit) if (bp->b_bcount & 1) { #ifdef DEBUG if (st_debug & ST_ODDIO) - printf("stgo%d: odd count %d using manual transfer\n", - unit, bp->b_bcount); + printf("%s: stgo: odd count %d using manual transfer\n", + sc->sc_hd->hp_xname, bp->b_bcount); #endif stat = scsi_tt_oddio(hp->hp_ctlr, hp->hp_slave, sc->sc_punit, bp->b_un.b_addr, bp->b_bcount, @@ -980,7 +998,7 @@ stintr(unit, stat) #ifdef DEBUG if (bp == NULL) { - printf("st%d: bp == NULL\n", unit); + printf("%s: bp == NULL\n", sc->sc_hd->hp_xname); return; } #endif @@ -1021,8 +1039,9 @@ stintr(unit, stat) */ if (sc->sc_blklen) { tprintf(sc->sc_ctty, - "st%d: Incorrect Length Indicator, blkcnt diff %d\n", - unit, sc->sc_blklen - bp->b_resid); + "%s: Incorrect Length Indicator, blkcnt diff %d\n", + sc->sc_hd->hp_xname, + sc->sc_blklen - bp->b_resid); bp->b_flags |= B_ERROR; bp->b_error = EIO; break; @@ -1047,8 +1066,8 @@ stintr(unit, stat) */ if (!st_dmaoddretry) { tprintf(sc->sc_ctty, - "st%d: Odd length read %d\n", - UNIT(bp->b_dev), + "%s: Odd length read %d\n", + sc->sc_hd->hp_xname, bp->b_bcount - bp->b_resid); bp->b_error = EIO; bp->b_flags |= B_ERROR; @@ -1059,8 +1078,8 @@ stintr(unit, stat) */ #ifdef DEBUG if (st_debug & ST_ODDIO) - printf("st%d: stintr odd count %d, do BSR then oddio\n", - UNIT(bp->b_dev), + printf("%s: stintr odd count %d, do BSR then oddio\n", + sc->sc_hd->hp_xname, bp->b_bcount - bp->b_resid); #endif stat = scsi_tt_oddio(hp->hp_ctlr, hp->hp_slave, @@ -1087,13 +1106,15 @@ stintr(unit, stat) bp->b_error = ENOSPC; break; } - tprintf(sc->sc_ctty, "st%d: unknown scsi error\n", unit); + tprintf(sc->sc_ctty, "%s: unknown scsi error\n", + sc->sc_hd->hp_xname); bp->b_flags |= B_ERROR; bp->b_error = EIO; break; default: - printf("st%d: stintr unknown stat 0x%x\n", unit, stat); + printf("%s: stintr unknown stat 0x%x\n", sc->sc_hd->hp_xname, + stat); break; } #ifdef DEBUG @@ -1205,8 +1226,8 @@ stcommand(dev, command, cnt) sc->sc_filepos = 0; break; default: - printf("st%d: stcommand bad command 0x%x\n", - UNIT(dev), command); + printf("%s: stcommand bad command 0x%x\n", + sc->sc_hd->hp_xname, command); } sc->sc_flags |= STF_CMD; @@ -1216,8 +1237,8 @@ stcommand(dev, command, cnt) again: #ifdef DEBUG if (st_debug & ST_FMKS) - printf("st%d: stcommand filepos %d cmdcnt %d cnt %d\n", - UNIT(dev), sc->sc_filepos, cmdcnt, cnt); + printf("%s: stcommand filepos %d cmdcnt %d cnt %d\n", + sc->sc_hd->hp_xname, sc->sc_filepos, cmdcnt, cnt); #endif s = splbio(); while (bp->b_flags & B_BUSY) { @@ -1258,7 +1279,8 @@ sterror(unit, sc, stat) prtkey(unit, sc); else if (stat) tprintf(sc->sc_ctty, - "st%d: bad scsi status 0x%x\n", unit, stat); + "%s: bad scsi status 0x%x\n", sc->sc_hd->hp_xname, + stat); if ((sc->sc_flags & STF_CMD) && sc->sc_cmd == CMD_SPACE) /* fsf */ sc->sc_filepos--; @@ -1290,32 +1312,36 @@ prtkey(unit, sc) case XSK_NOTUSEDE: break; case XSK_REVERVED: - tprintf(sc->sc_ctty, "st%d: Reserved sense key 0x%x\n", - unit, xp->sc_xsense.key); + tprintf(sc->sc_ctty, "%s: Reserved sense key 0x%x\n", + sc->sc_hd->hp_xname, xp->sc_xsense.key); break; case XSK_NOTRDY: - tprintf(sc->sc_ctty, "st%d: NOT READY\n", unit); + tprintf(sc->sc_ctty, "%s: NOT READY\n", sc->sc_hd->hp_xname); break; case XSK_MEDERR: - tprintf(sc->sc_ctty, "st%d: MEDIUM ERROR\n", unit); + tprintf(sc->sc_ctty, "%s: MEDIUM ERROR\n", sc->sc_hd->hp_xname); break; case XSK_HRDWERR: - tprintf(sc->sc_ctty, "st%d: HARDWARE ERROR\n", unit); + tprintf(sc->sc_ctty, "%s: HARDWARE ERROR\n", + sc->sc_hd->hp_xname); break; case XSK_ILLREQ: - tprintf(sc->sc_ctty, "st%d: ILLEGAL REQUEST\n", unit); + tprintf(sc->sc_ctty, "%s: ILLEGAL REQUEST\n", + sc->sc_hd->hp_xname); break; case XSK_UNTATTEN: - tprintf(sc->sc_ctty, "st%d: UNIT ATTENTION\n", unit); + tprintf(sc->sc_ctty, "%s: UNIT ATTENTION\n", + sc->sc_hd->hp_xname); break; case XSK_DATAPROT: - tprintf(sc->sc_ctty, "st%d: DATA PROTECT\n", unit); + tprintf(sc->sc_ctty, "%s: DATA PROTECT\n", sc->sc_hd->hp_xname); break; case XSK_BLNKCHK: - tprintf(sc->sc_ctty, "st%d: BLANK CHECK\n", unit); + tprintf(sc->sc_ctty, "%s: BLANK CHECK\n", sc->sc_hd->hp_xname); break; case XSK_VENDOR: - tprintf(sc->sc_ctty, "st%d: VENDER UNIQUE SENSE KEY ", unit); + tprintf(sc->sc_ctty, "%s: VENDER UNIQUE SENSE KEY ", + sc->sc_hd->hp_xname); switch (sc->sc_tapeid) { case MT_ISEXABYTE: tprintf(sc->sc_ctty, "Exabyte: "); @@ -1331,48 +1357,58 @@ prtkey(unit, sc) } break; case XSK_CPYABORT: - tprintf(sc->sc_ctty, "st%d: COPY ABORTED\n", unit); + tprintf(sc->sc_ctty, "%s: COPY ABORTED\n", sc->sc_hd->hp_xname); break; case XSK_ABORTCMD: - tprintf(sc->sc_ctty, "st%d: ABORTED COMMAND\n", unit); + tprintf(sc->sc_ctty, "%s: ABORTED COMMAND\n", + sc->sc_hd->hp_xname); break; case XSK_VOLOVER: - tprintf(sc->sc_ctty, "st%d: VOLUME OVERFLOW\n", unit); + tprintf(sc->sc_ctty, "%s: VOLUME OVERFLOW\n", + sc->sc_hd->hp_xname); break; default: - tprintf(sc->sc_ctty, "st%d: unknown sense key 0x%x\n", - unit, xp->sc_xsense.key); + tprintf(sc->sc_ctty, "%s: unknown sense key 0x%x\n", + sc->sc_hd->hp_xname, xp->sc_xsense.key); } if (sc->sc_tapeid == MT_ISEXABYTE) { if (xp->exb_xsense.bpe) - tprintf(sc->sc_ctty, "st%d: Bus Parity Errorn", unit); + tprintf(sc->sc_ctty, "%s: Bus Parity Error", + sc->sc_hd->hp_xname); if (xp->exb_xsense.fpe) tprintf(sc->sc_ctty, - "st%d: Formatted Buffer Parity Errorn", unit); + "%s: Formatted Buffer Parity Error", + sc->sc_hd->hp_xname); if (xp->exb_xsense.eco) - tprintf(sc->sc_ctty, "st%d: Error Counter Overflown", - unit); + tprintf(sc->sc_ctty, "%s: Error Counter Overflow", + sc->sc_hd->hp_xname); if (xp->exb_xsense.tme) - tprintf(sc->sc_ctty, "st%d: Tape Motion Errorn", unit); + tprintf(sc->sc_ctty, "%s: Tape Motion Error", + sc->sc_hd->hp_xname); if (xp->exb_xsense.xfr) - tprintf(sc->sc_ctty, "st%d: Transfer About Errorn", - unit); + tprintf(sc->sc_ctty, "%s: Transfer About Error", + sc->sc_hd->hp_xname); if (xp->exb_xsense.tmd) - tprintf(sc->sc_ctty, "st%d: Tape Mark Detect Errorn", - unit); + tprintf(sc->sc_ctty, "%s: Tape Mark Detect Error", + sc->sc_hd->hp_xname); if (xp->exb_xsense.fmke) - tprintf(sc->sc_ctty, "st%d: Filemark Errorn", unit); + tprintf(sc->sc_ctty, "%s: Filemark Error", + sc->sc_hd->hp_xname); if (xp->exb_xsense.ure) - tprintf(sc->sc_ctty, "st%d: Under Run Errorn", unit); + tprintf(sc->sc_ctty, "%s: Under Run Error", + sc->sc_hd->hp_xname); if (xp->exb_xsense.sse) - tprintf(sc->sc_ctty, "st%d: Servo System Errorn", - unit); + tprintf(sc->sc_ctty, "%s: Servo System Error", + sc->sc_hd->hp_xname); if (xp->exb_xsense.fe) - tprintf(sc->sc_ctty, "st%d: Formatter Errorn", unit); + tprintf(sc->sc_ctty, "%s: Formatter Error", + sc->sc_hd->hp_xname); if (xp->exb_xsense.wseb) - tprintf(sc->sc_ctty, "st%d: WSEB Errorn", unit); + tprintf(sc->sc_ctty, "%s: WSEB Error", + sc->sc_hd->hp_xname); if (xp->exb_xsense.wseo) - tprintf(sc->sc_ctty, "st%d: WSEO Errorn", unit); + tprintf(sc->sc_ctty, "%s: WSEO Error", + sc->sc_hd->hp_xname); } } diff --git a/sys/arch/hp300/hp300/autoconf.c b/sys/arch/hp300/hp300/autoconf.c index 006a69b856b..2c166e160bb 100644 --- a/sys/arch/hp300/hp300/autoconf.c +++ b/sys/arch/hp300/hp300/autoconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.c,v 1.11 1995/09/02 23:36:09 thorpej Exp $ */ +/* $NetBSD: autoconf.c,v 1.12 1995/12/02 18:11:21 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -199,25 +199,38 @@ find_controller(hw) if (match_c == NULL) return(0); /* - * Found a match, attempt to initialize and configure all attached - * slaves. Note, we can still fail if HW won't initialize. + * Found a configuration match, now let's see if the hardware + * agrees with us. If it does, attach it. */ hc = match_c; oaddr = hc->hp_addr; hc->hp_addr = hw->hw_kva; - if ((*hc->hp_driver->d_init)(hc)) { + hc->hp_args = hw; + if ((*hc->hp_driver->d_match)(hc)) { hc->hp_alive = 1; - printf("%s%d", hc->hp_driver->d_name, hc->hp_unit); + + /* Set up external name. */ + bzero(hc->hp_xname, sizeof(hc->hp_xname)); + sprintf(hc->hp_xname, "%s%d", hc->hp_driver->d_name, + hc->hp_unit); + + /* Print what we've found. */ + printf("%s at ", hc->hp_xname); sc = patosc(hw->hw_pa); if (sc < 256) - printf(" at sc%d,", sc); + printf("scode%d", sc); else - printf(" csr 0x%x,", sc); + printf("addr 0x%x,", sc); printf(" ipl %d", hc->hp_ipl); if (hc->hp_flags) printf(" flags 0x%x", hc->hp_flags); - printf("\n"); - find_slaves(hc); + + /* + * Call device "attach" routine. It will print the + * newline for us. + */ + (*hc->hp_driver->d_attach)(hc); + find_slaves(hc); /* XXX do this in attach? */ } else hc->hp_addr = oaddr; return(1); @@ -289,25 +302,38 @@ find_device(hw) if (match_d == NULL) return(0); /* - * Found a match, attempt to initialize. - * Note, we can still fail if HW won't initialize. + * Found a configuration match, now let's see if the hardware + * agrees with us. If it does, attach it. */ hd = match_d; oaddr = hd->hp_addr; hd->hp_addr = hw->hw_kva; - if ((*hd->hp_driver->d_init)(hd)) { + hd->hp_args = hw; + if ((*hd->hp_driver->d_match)(hd)) { hd->hp_alive = 1; - printf("%s%d", hd->hp_driver->d_name, hd->hp_unit); + + /* Set up external name. */ + bzero(hd->hp_xname, sizeof(hd->hp_xname)); + sprintf(hd->hp_xname, "%s%d", hd->hp_driver->d_name, + hd->hp_unit); + + /* Print what we've found. */ + printf("%s at ", hd->hp_xname); sc = patosc(hw->hw_pa); if (sc < 256) - printf(" at sc%d", sc); + printf("scode%d", sc); else - printf(" csr 0x%x", sc); + printf("addr 0x%x", sc); if (hd->hp_ipl) - printf(", ipl %d", hd->hp_ipl); + printf(" ipl %d", hd->hp_ipl); if (hd->hp_flags) - printf(", flags 0x%x", hd->hp_flags); - printf("\n"); + printf(" flags 0x%x", hd->hp_flags); + + /* + * Call device "attach" routine. It will print the + * newline for us. + */ + (*hd->hp_driver->d_attach)(hd); } else hd->hp_addr = oaddr; return(1); @@ -360,8 +386,7 @@ find_busslaves(hc, startslave, endslave) #define LASTSLAVE(s) (startslave < endslave ? (s)-- : (s)++) #ifdef DEBUG if (acdebug) - printf("find_busslaves: for %s%d\n", - hc->hp_driver->d_name, hc->hp_unit); + printf("find_busslaves: for %s\n", hc->hp_xname); #endif NEXTSLAVE(endslave); for (s = startslave; s != endslave; NEXTSLAVE(s)) { @@ -453,24 +478,35 @@ find_busslaves(hc, startslave, endslave) hd->hp_unit, hd->hp_slave); #endif - if ((*hd->hp_driver->d_init)(hd)) { + if ((*hd->hp_driver->d_match)(hd)) { #ifdef DEBUG if (acdebug) printf("found\n"); #endif - printf("%s%d at %s%d, slave %d", - hd->hp_driver->d_name, hd->hp_unit, - hc->hp_driver->d_name, hd->hp_ctlr, + /* Set up external name. */ + bzero(hd->hp_xname, sizeof(hd->hp_xname)); + sprintf(hd->hp_xname, "%s%d", + hd->hp_driver->d_name, + hd->hp_unit); + + /* Print what we've found. */ + printf("%s at %s slave %d", + hd->hp_xname, hc->hp_xname, hd->hp_slave); if (hd->hp_flags) printf(" flags 0x%x", hd->hp_flags); - printf("\n"); hd->hp_alive = 1; if (hd->hp_dk && dkn < DK_NDRIVE) hd->hp_dk = dkn++; else hd->hp_dk = -1; rescan = 1; + + /* + * Call the device "attach" routine. + * It will print the newline for us. + */ + (*hd->hp_driver->d_attach)(hd); } else { #ifdef DEBUG if (acdebug) diff --git a/sys/arch/hp300/hp300/genassym.c b/sys/arch/hp300/hp300/genassym.c index 65988f4d920..c9315e169cb 100644 --- a/sys/arch/hp300/hp300/genassym.c +++ b/sys/arch/hp300/hp300/genassym.c @@ -1,4 +1,4 @@ -/* $NetBSD: genassym.c,v 1.15 1995/05/25 01:09:13 mycroft Exp $ */ +/* $NetBSD: genassym.c,v 1.16 1995/12/11 17:09:09 thorpej Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -98,6 +98,29 @@ flush() main() { + /* CPU types */ +#ifdef M68020 + def("M68020", 1); +#endif +#ifdef M68030 + def("M68030", 1); +#endif +#ifdef M68040 + def("M68040", 1); +#endif + + /* MMU types */ +#ifdef M68K_MMU_MOTOROLA + def("M68K_MMU_MOTOROLA", 1); +#endif +#ifdef M68K_MMU_HP + def("M68K_MMU_HP", 1); +#endif + def("MMU_68040", MMU_68040); + def("MMU_68030", MMU_68030); + def("MMU_HP", MMU_HP); + def("MMU_68851", MMU_68851); + /* general constants */ def("UPAGES", UPAGES); def("USPACE", USPACE); diff --git a/sys/arch/hp300/hp300/locore.s b/sys/arch/hp300/hp300/locore.s index a88606b2567..98f31668f9a 100644 --- a/sys/arch/hp300/hp300/locore.s +++ b/sys/arch/hp300/hp300/locore.s @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.44 1995/10/08 20:19:22 thorpej Exp $ */ +/* $NetBSD: locore.s,v 1.46 1995/12/11 17:09:11 thorpej Exp $ */ #undef STACKCHECK /* doesn't work any more */ @@ -109,8 +109,8 @@ _buserr: movl _nofault,sp@- | yes, jbsr _longjmp | longjmp(nofault) Lberr: -#if defined(HP380) - cmpl #-2,_mmutype | 68040? +#if defined(M68040) + cmpl #MMU_68040,_mmutype | 68040? jne _addrerr | no, skip clrl sp@- | stack adjust count moveml #0xFFFF,sp@- | save user registers @@ -144,8 +144,8 @@ _addrerr: movl usp,a0 | save the user SP movl a0,sp@(FR_SP) | in the savearea lea sp@(FR_HW),a1 | grab base of HW berr frame -#if defined(HP380) - cmpl #-2,_mmutype | 68040? +#if defined(M68040) + cmpl #MMU_68040,_mmutype | 68040? jne Lbenot040 | no, skip movl a1@(8),sp@- | yes, push fault address clrl sp@- | no SSW for address fault @@ -193,7 +193,7 @@ Lbe10: andw #0x0FFF,d0 | clear out frame format cmpw #12,d0 | address error vector? jeq Lisaerr | yes, go to it -#if defined(HP330) || defined(HP360) || defined(HP370) +#if defined(M68K_MMU_MOTOROLA) tstl _mmutype | HP MMU? jeq Lbehpmmu | yes, skip movl d1,a0 | fault address @@ -205,7 +205,7 @@ Lbe10: jra Lisberr | and process as normal bus error Lbehpmmu: #endif -#if defined(HP320) || defined(HP350) +#if defined(M68K_MMU_HP) MMUADDR(a0) movl a0@(MMUSTAT),d0 | read status btst #3,d0 | MMU fault? @@ -247,7 +247,7 @@ Lstkadj: * FP exceptions. */ _fpfline: -#if defined(HP380) +#if defined(M68040) cmpw #0x202c,sp@(6) | format type 2? jne _illinst | no, not an FP emulation #ifdef FPSP @@ -264,8 +264,8 @@ _fpfline: #endif _fpunsupp: -#if defined(HP380) - cmpl #-2,_mmutype | 68040? +#if defined(M68040) + cmpl #MMU_68040,_mmutype | 68040? jne _illinst | no, treat as illinst #ifdef FPSP .globl fpsp_unsupp @@ -898,7 +898,7 @@ start: tstl d0 | zero? jeq Lnot68030 | yes, we have 68020/68040 RELOC(_mmutype, a0) | no, we have 68030 - movl #-1,a0@ | set to reflect 68030 PMMU + movl #MMU_68030,a0@ | set to reflect 68030 PMMU RELOC(_machineid, a0) movl #0x80,a1@(MMUCMD) | set magic cookie movl a1@(MMUCMD),d0 | read it back @@ -933,7 +933,7 @@ Lnot68030: moveq #0,d0 | now turn it back off movec d0,cacr | before we access any data RELOC(_mmutype, a0) - movl #-2,a0@ | with a 68040 MMU + movl #MMU_68040,a0@ | with a 68040 MMU RELOC(_ectype, a0) movl #0,a0@ | and no cache (for now XXX) RELOC(_machineid, a0) @@ -952,7 +952,7 @@ Lis68020: btst #0,d0 | non-zero? jne Lishpmmu | yes, we have HP MMU RELOC(_mmutype, a0) - movl #1,a0@ | no, we have PMMU + movl #MMU_68851,a0@ | no, we have PMMU RELOC(_machineid, a0) movl #1,a0@ | and 330 CPU jra Lstart1 @@ -1018,7 +1018,7 @@ Lstart2: RELOC(_mmutype, a0) tstl a0@ | HP MMU? jeq Lhpmmu2 | yes, skip - cmpl #-2,a0@ | 68040? + cmpl #MMU_68040,a0@ | 68040? jne Lmotommu1 | no, skip .long 0x4e7b1807 | movc d1,srp jra Lstploaddone @@ -1047,7 +1047,7 @@ Lhighcode: RELOC(_mmutype, a0) tstl a0@ | HP MMU? jeq Lhpmmu3 | yes, skip - cmpl #-2,a0@ | 68040? + cmpl #MMU_68040,a0@ | 68040? jne Lmotommu2 | no, skip movw #0,INTIOBASE+MMUBASE+MMUCMD+2 movw #MMU_IEN+MMU_CEN+MMU_FPE,INTIOBASE+MMUBASE+MMUCMD+2 @@ -1102,7 +1102,7 @@ Lfinish: #endif /* flush TLB and turn on caches */ jbsr _TBIA | invalidate TLB - cmpl #-2,_mmutype | 68040? + cmpl #MMU_68040,_mmutype | 68040? jeq Lnocache0 | yes, cache already on movl #CACHE_ON,d0 movc d0,cacr | clear cache(s) @@ -1186,8 +1186,8 @@ ENTRY(copypage) movl sp@(4),a0 | source address movl sp@(8),a1 | destination address movl #NBPG/32,d0 | number of 32 byte chunks -#if defined(HP380) - cmpl #-2,_mmutype | 68040? +#if defined(M68040) + cmpl #MMU_68040,_mmutype | 68040? jne Lmlloop | no, use movl Lm16loop: .long 0xf6209000 | move16 a0@+,a1@+ @@ -1467,8 +1467,8 @@ Lswnofpsave: Lswnochg: lea tmpstk,sp | now goto a tmp stack for NMI -#if defined(HP380) - cmpl #-2,_mmutype | 68040? +#if defined(M68040) + cmpl #MMU_68040,_mmutype | 68040? jne Lres1a | no, skip .word 0xf518 | yes, pflusha movl a1@(PCB_USTP),d0 | get USTP @@ -1480,7 +1480,7 @@ Lres1a: #endif movl #CACHE_CLR,d0 movc d0,cacr | invalidate cache(s) -#if defined(HP330) || defined(HP360) || defined(HP370) +#if defined(M68K_MMU_MOTOROLA) tstl _mmutype | HP MMU? jeq Lhpmmu4 | yes, skip pflusha | flush entire TLB @@ -1493,7 +1493,7 @@ Lres1a: jra Lcxswdone | thats it Lhpmmu4: #endif -#if defined(HP320) || defined(HP350) +#if defined(M68K_MMU_HP) MMUADDR(a0) movl a0@(MMUTBINVAL),d1 | invalidate TLB tstl _ectype | got external VAC? @@ -1511,8 +1511,8 @@ Lcxswdone: lea a1@(PCB_FPCTX),a0 | pointer to FP save area tstb a0@ | null state frame? jeq Lresfprest | yes, easy -#if defined(HP380) - cmpl #-2,_mmutype | 68040? +#if defined(M68040) + cmpl #MMU_68040,_mmutype | 68040? jne Lresnot040 | no, skip clrl sp@- | yes... frestore sp@+ | ...magic! @@ -1549,7 +1549,7 @@ Lsvnofpsave: moveq #0,d0 | return 0 rts -#if defined(HP380) +#if defined(M68040) ENTRY(suline) movl sp@(4),a0 | address to write movl _curpcb,a1 | current pcb @@ -1582,27 +1582,25 @@ Lsldone: */ ENTRY(TBIA) __TBIA: -#if defined(HP380) - cmpl #-2,_mmutype | 68040? +#if defined(M68040) + cmpl #MMU_68040,_mmutype | 68040? jne Lmotommu3 | no, skip .word 0xf518 | yes, pflusha rts Lmotommu3: #endif -#if defined(HP330) || defined(HP360) || defined(HP370) +#if defined(M68K_MMU_MOTOROLA) tstl _mmutype | HP MMU? jeq Lhpmmu6 | yes, skip pflusha | flush entire TLB -#if defined(HP360) || defined(HP370) jpl Lmc68851a | 68851 implies no d-cache movl #DC_CLEAR,d0 movc d0,cacr | invalidate on-chip d-cache Lmc68851a: -#endif rts Lhpmmu6: #endif -#if defined(HP320) || defined(HP350) +#if defined(M68K_MMU_HP) MMUADDR(a0) movl a0@(MMUTBINVAL),sp@- | do not ask me, this addql #4,sp | is how hpux does it @@ -1621,8 +1619,8 @@ ENTRY(TBIS) tstl fulltflush | being conservative? jne __TBIA | yes, flush entire TLB #endif -#if defined(HP380) - cmpl #-2,_mmutype | 68040? +#if defined(M68040) + cmpl #MMU_68040,_mmutype | 68040? jne Lmotommu4 | no, skip movl sp@(4),a0 movc dfc,d1 @@ -1636,23 +1634,21 @@ ENTRY(TBIS) rts Lmotommu4: #endif -#if defined(HP330) || defined(HP360) || defined(HP370) +#if defined(M68K_MMU_MOTOROLA) tstl _mmutype | HP MMU? jeq Lhpmmu5 | yes, skip movl sp@(4),a0 | get addr to flush -#if defined(HP360) || defined(HP370) jpl Lmc68851b | is 68851? pflush #0,#0,a0@ | flush address from both sides movl #DC_CLEAR,d0 movc d0,cacr | invalidate on-chip data cache rts Lmc68851b: -#endif pflushs #0,#0,a0@ | flush address from both sides rts Lhpmmu5: #endif -#if defined(HP320) || defined(HP350) +#if defined(M68K_MMU_HP) movl sp@(4),d0 | VA to invalidate bclr #0,d0 | ensure even movl d0,a0 @@ -1676,29 +1672,27 @@ ENTRY(TBIAS) tstl fulltflush | being conservative? jne __TBIA | yes, flush everything #endif -#if defined(HP380) - cmpl #-2,_mmutype | 68040? +#if defined(M68040) + cmpl #MMU_68040,_mmutype | 68040? jne Lmotommu5 | no, skip .word 0xf518 | yes, pflusha (for now) XXX rts Lmotommu5: #endif -#if defined(HP330) || defined(HP360) || defined(HP370) +#if defined(M68K_MMU_MOTOROLA) tstl _mmutype | HP MMU? jeq Lhpmmu7 | yes, skip -#if defined(HP360) || defined(HP370) jpl Lmc68851c | 68851? pflush #4,#4 | flush supervisor TLB entries movl #DC_CLEAR,d0 movc d0,cacr | invalidate on-chip d-cache rts Lmc68851c: -#endif pflushs #4,#4 | flush supervisor TLB entries rts Lhpmmu7: #endif -#if defined(HP320) || defined(HP350) +#if defined(M68K_MMU_HP) MMUADDR(a0) movl #0x8000,d0 | more movl d0,a0@(MMUTBINVAL) | HP magic @@ -1717,29 +1711,27 @@ ENTRY(TBIAU) tstl fulltflush | being conservative? jne __TBIA | yes, flush everything #endif -#if defined(HP380) - cmpl #-2,_mmutype | 68040? +#if defined(M68040) + cmpl #MMU_68040,_mmutype | 68040? jne Lmotommu6 | no, skip .word 0xf518 | yes, pflusha (for now) XXX rts Lmotommu6: #endif -#if defined(HP330) || defined(HP360) || defined(HP370) +#if defined(M68K_MMU_MOTOROLA) tstl _mmutype | HP MMU? jeq Lhpmmu8 | yes, skip -#if defined(HP360) || defined(HP370) jpl Lmc68851d | 68851? pflush #0,#4 | flush user TLB entries movl #DC_CLEAR,d0 movc d0,cacr | invalidate on-chip d-cache rts Lmc68851d: -#endif pflushs #0,#4 | flush user TLB entries rts Lhpmmu8: #endif -#if defined(HP320) || defined(HP350) +#if defined(M68K_MMU_HP) MMUADDR(a0) moveq #0,d0 | more movl d0,a0@(MMUTBINVAL) | HP magic @@ -1754,9 +1746,9 @@ Lhpmmu8: * Invalidate instruction cache */ ENTRY(ICIA) -#if defined(HP380) +#if defined(M68040) ENTRY(ICPA) - cmpl #-2,_mmutype | 68040 + cmpl #MMU_68040,_mmutype | 68040 jne Lmotommu7 | no, skip .word 0xf498 | cinva ic rts @@ -1776,14 +1768,14 @@ Lmotommu7: */ ENTRY(DCIA) __DCIA: -#if defined(HP380) - cmpl #-2,_mmutype | 68040 +#if defined(M68040) + cmpl #MMU_68040,_mmutype | 68040 jne Lmotommu8 | no, skip /* XXX implement */ rts Lmotommu8: #endif -#if defined(HP320) || defined(HP350) +#if defined(M68K_MMU_HP) tstl _ectype | got external VAC? jle Lnocache2 | no, all done MMUADDR(a0) @@ -1795,14 +1787,14 @@ Lnocache2: ENTRY(DCIS) __DCIS: -#if defined(HP380) - cmpl #-2,_mmutype | 68040 +#if defined(M68040) + cmpl #MMU_68040,_mmutype | 68040 jne Lmotommu9 | no, skip /* XXX implement */ rts Lmotommu9: #endif -#if defined(HP320) || defined(HP350) +#if defined(M68K_MMU_HP) tstl _ectype | got external VAC? jle Lnocache3 | no, all done MMUADDR(a0) @@ -1814,14 +1806,14 @@ Lnocache3: ENTRY(DCIU) __DCIU: -#if defined(HP380) - cmpl #-2,_mmutype | 68040 +#if defined(M68040) + cmpl #MMU_68040,_mmutype | 68040 jne LmotommuA | no, skip /* XXX implement */ rts LmotommuA: #endif -#if defined(HP320) || defined(HP350) +#if defined(M68K_MMU_HP) tstl _ectype | got external VAC? jle Lnocache4 | no, all done MMUADDR(a0) @@ -1831,7 +1823,7 @@ Lnocache4: #endif rts -#if defined(HP380) +#if defined(M68040) ENTRY(ICPL) movl sp@(4),a0 | address .word 0xf488 | cinvl ic,a0@ @@ -1862,15 +1854,15 @@ ENTRY(DCFP) #endif ENTRY(PCIA) -#if defined(HP380) +#if defined(M68040) ENTRY(DCFA) - cmpl #-2,_mmutype | 68040 + cmpl #MMU_68040,_mmutype | 68040 jne LmotommuB | no, skip .word 0xf478 | cpusha dc rts LmotommuB: #endif -#if defined(HP360) || defined(HP370) +#if defined(M68K_MMU_MOTOROLA) movl #DC_CLEAR,d0 movc d0,cacr | invalidate on-chip d-cache tstl _ectype | got external PAC? @@ -1910,14 +1902,14 @@ _getdfc: * Load a new user segment table pointer. */ ENTRY(loadustp) -#if defined(HP330) || defined(HP360) || defined(HP370) || defined(HP380) +#if defined(M68K_MMU_MOTOROLA) tstl _mmutype | HP MMU? jeq Lhpmmu9 | yes, skip movl sp@(4),d0 | new USTP moveq #PGSHIFT,d1 lsll d1,d0 | convert to addr -#if defined(HP380) - cmpl #-2,_mmutype | 68040? +#if defined(M68040) + cmpl #MMU_68040,_mmutype | 68040? jne LmotommuC | no, skip .long 0x4e7b0806 | movc d0,urp rts @@ -1931,16 +1923,25 @@ LmotommuC: rts | since pmove flushes TLB Lhpmmu9: #endif -#if defined(HP320) || defined(HP350) +#if defined(M68K_MMU_HP) MMUADDR(a0) movl sp@(4),a0@(MMUUSTP) | load a new USTP #endif rts ENTRY(ploadw) -#if defined(HP330) || defined(HP360) || defined(HP370) +#if defined(M68K_MMU_MOTOROLA) movl sp@(4),a0 | address to load +#if defined(M68K_MMU_HP) + tstl _mmutype | HP MMU? + jeq Lploadwskp | yes, skip +#endif +#if defined(M68040) + cmpl #MMU_68040,_mmutype | 68040? + jeq Lploadwskp | yes, skip +#endif ploadw #1,a0@ | pre-load translation +Lploadwskp: #endif rts @@ -1988,82 +1989,6 @@ ENTRY(_remque) movw d0,sr rts -/* - * {ov}bcopy(from, to, len) - * memcpy(to, from len) - * - * Works for counts up to 128K. - */ -ENTRY(memcpy) - movl sp@(12),d0 | get count - jeq Lcpyexit | if zero, return - movl sp@(8), a0 | src address - movl sp@(4), a1 | dest address - jra Ldocopy | jump into bcopy -ALTENTRY(ovbcopy, _bcopy) -ENTRY(bcopy) - movl sp@(12),d0 | get count - jeq Lcpyexit | if zero, return - movl sp@(4),a0 | src address - movl sp@(8),a1 | dest address -Ldocopy: - cmpl a1,a0 | src before dest? - jlt Lcpyback | yes, copy backwards (avoids overlap) - movl a0,d1 - btst #0,d1 | src address odd? - jeq Lcfeven | no, go check dest - movb a0@+,a1@+ | yes, copy a byte - subql #1,d0 | update count - jeq Lcpyexit | exit if done -Lcfeven: - movl a1,d1 - btst #0,d1 | dest address odd? - jne Lcfbyte | yes, must copy by bytes - movl d0,d1 | no, get count - lsrl #2,d1 | convert to longwords - jeq Lcfbyte | no longwords, copy bytes - subql #1,d1 | set up for dbf -Lcflloop: - movl a0@+,a1@+ | copy longwords - dbf d1,Lcflloop | til done - andl #3,d0 | get remaining count - jeq Lcpyexit | done if none -Lcfbyte: - subql #1,d0 | set up for dbf -Lcfbloop: - movb a0@+,a1@+ | copy bytes - dbf d0,Lcfbloop | til done -Lcpyexit: - rts -Lcpyback: - addl d0,a0 | add count to src - addl d0,a1 | add count to dest - movl a0,d1 - btst #0,d1 | src address odd? - jeq Lcbeven | no, go check dest - movb a0@-,a1@- | yes, copy a byte - subql #1,d0 | update count - jeq Lcpyexit | exit if done -Lcbeven: - movl a1,d1 - btst #0,d1 | dest address odd? - jne Lcbbyte | yes, must copy by bytes - movl d0,d1 | no, get count - lsrl #2,d1 | convert to longwords - jeq Lcbbyte | no longwords, copy bytes - subql #1,d1 | set up for dbf -Lcblloop: - movl a0@-,a1@- | copy longwords - dbf d1,Lcblloop | til done - andl #3,d0 | get remaining count - jeq Lcpyexit | done if none -Lcbbyte: - subql #1,d0 | set up for dbf -Lcbbloop: - movb a0@-,a1@- | copy bytes - dbf d0,Lcbbloop | til done - rts - #ifdef FPCOPROC /* * Save and restore 68881 state. @@ -2101,18 +2026,16 @@ Lm68881rdone: */ .globl _doboot _doboot: -#if defined(HP380) - cmpl #-2,_mmutype | 68040? +#if defined(M68040) + cmpl #MMU_68040,_mmutype | 68040? jeq Lnocache5 | yes, skip #endif movl #CACHE_OFF,d0 movc d0,cacr | disable on-chip cache(s) -#if defined(HP320) || defined(HP350) || defined(HP370) - tstl _ectype - jeq Lnocache5 + tstl _ectype | external cache? + jeq Lnocache5 | no, skip MMUADDR(a0) andl #~MMU_CEN,a0@(MMUCMD) | disable external cache -#endif Lnocache5: lea MAXADDR,a0 | last page of physical memory movl _boothowto,a0@+ | store howto @@ -2123,8 +2046,8 @@ Lbootcopy: movw a1@+,a0@+ | copy a word cmpl a3,a1 | done yet? jcs Lbootcopy | no, keep going -#if defined(HP380) - cmpl #-2,_mmutype | 68040? +#if defined(M68040) + cmpl #MMU_68040,_mmutype | 68040? jne LmotommuE | no, skip .word 0xf4f8 | cpusha bc LmotommuE: @@ -2133,8 +2056,8 @@ LmotommuE: Lbootcode: lea MAXADDR+0x800,sp | physical SP in case of NMI -#if defined(HP380) - cmpl #-2,_mmutype | 68040? +#if defined(M68040) + cmpl #MMU_68040,_mmutype | 68040? jne LmotommuF | no, skip movl #0,d0 movc d0,cacr | caches off @@ -2143,7 +2066,7 @@ Lbootcode: jmp 0x1A4 | goto REQ_REBOOT LmotommuF: #endif -#if defined(HP330) || defined(HP360) || defined(HP370) +#if defined(M68K_MMU_MOTOROLA) tstl _mmutype | HP MMU? jeq LhpmmuB | yes, skip movl #0,a0@ | value for pmove to TC (turn off MMU) @@ -2151,7 +2074,7 @@ LmotommuF: jmp 0x1A4 | goto REQ_REBOOT LhpmmuB: #endif -#if defined(HP320) || defined(HP350) +#if defined(M68K_MMU_HP) MMUADDR(a0) movl #0xFFFF0000,a0@(MMUCMD) | totally disable MMU movl d2,MAXADDR+NBPG-4 | restore old high page contents diff --git a/sys/arch/hp300/hp300/machdep.c b/sys/arch/hp300/hp300/machdep.c index d5b257ef03a..719b271f633 100644 --- a/sys/arch/hp300/hp300/machdep.c +++ b/sys/arch/hp300/hp300/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.52 1995/10/07 06:25:31 mycroft Exp $ */ +/* $NetBSD: machdep.c,v 1.54 1995/11/20 00:58:54 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -1104,12 +1104,20 @@ void boot(howto) register int howto; { + extern int cold; + /* take a snap shot before clobbering any registers */ if (curproc && curproc->p_addr) savectx(curproc->p_addr); + /* If system is cold, just halt. */ + if (cold) { + howto |= RB_HALT; + goto haltsys; + } + boothowto = howto; - if ((howto&RB_NOSYNC) == 0 && waittime < 0) { + if ((howto & RB_NOSYNC) == 0 && waittime < 0) { waittime = 0; vfs_shutdown(); /* @@ -1118,16 +1126,36 @@ boot(howto) */ resettodr(); } - splhigh(); /* extreme priority */ - if (howto&RB_HALT) { - printf("halted\n\n"); + + /* Disable interrupts. */ + splhigh(); + + /* If rebooting and a dump is requested do it. */ + if (howto & RB_DUMP) + dumpsys(); + + haltsys: + /* Run any shutdown hooks. */ + doshutdownhooks(); + +#ifdef PANICWAIT + if ((howto & RB_HALT) == 0) { + printf("hit any hey to reboot...\n"); + (void)cngetc(); + printf("\n"); + } +#endif + + /* Finally, halt/reboot the system. */ + if (howto & RB_HALT) { + printf("System halted.\n\n"); asm(" stop #0x2700"); - } else { - if (howto & RB_DUMP) - dumpsys(); - doboot(); - /*NOTREACHED*/ + /* NOTREACHED */ } + + printf("rebooting...\n"); + DELAY(1000000); + doboot(); /*NOTREACHED*/ } diff --git a/sys/arch/hp300/hp300/pmap.c b/sys/arch/hp300/hp300/pmap.c index d252abce40a..8bef13a6290 100644 --- a/sys/arch/hp300/hp300/pmap.c +++ b/sys/arch/hp300/hp300/pmap.c @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.22 1995/10/08 19:33:36 thorpej Exp $ */ +/* $NetBSD: pmap.c,v 1.24 1995/12/11 17:09:14 thorpej Exp $ */ /* * Copyright (c) 1991, 1993 @@ -176,7 +176,7 @@ int pmapdebug = 0x2000; #define PDB_WIRING 0x4000 #define PDB_PVDUMP 0x8000 -#ifdef HAVEVAC +#ifdef M68K_MMU_HP int pmapvacflush = 0; #define PVF_ENTER 0x01 #define PVF_REMOVE 0x02 @@ -184,7 +184,7 @@ int pmapvacflush = 0; #define PVF_TOTAL 0x80 #endif -#if defined(HP380) +#if defined(M68040) int dowriteback = 1; /* 68040: enable writeback caching */ int dokwriteback = 1; /* 68040: enable writeback caching of kernel AS */ #endif @@ -195,7 +195,7 @@ extern vm_offset_t pager_sva, pager_eva; /* * Get STEs and PTEs for user/kernel address space */ -#if defined(HP380) +#if defined(M68040) #define pmap_ste1(m, v) \ (&((m)->pm_stab[(vm_offset_t)(v) >> SG4_SHIFT1])) /* XXX assumes physically contiguous ST pages (if more than one) */ @@ -281,10 +281,10 @@ char *pmap_attributes; /* reference and modify bits */ TAILQ_HEAD(pv_page_list, pv_page) pv_page_freelist; int pv_nfree; -#ifdef HAVEVAC +#ifdef M68K_MMU_HP int pmap_aliasmask; /* seperation at which VA aliasing ok */ #endif -#if defined(HP380) +#if defined(M68040) int protostfree; /* prototype (default) free ST map */ #endif @@ -457,7 +457,17 @@ bogons: * map where we want it. */ addr = HP_PTBASE; - s = min(HP_PTMAXSIZE, maxproc*HP_MAX_PTSIZE); + if ((HP_PTMAXSIZE / HP_MAX_PTSIZE) < maxproc) { + s = HP_PTMAXSIZE; + /* + * XXX We don't want to hang when we run out of + * page tables, so we lower maxproc so that fork() + * will fail instead. Note that root could still raise + * this value via sysctl(2). + */ + maxproc = (HP_PTMAXSIZE / HP_MAX_PTSIZE); + } else + s = (maxproc * HP_MAX_PTSIZE); addr2 = addr + s; rv = vm_map_find(kernel_map, NULL, 0, &addr, s, TRUE); if (rv != KERN_SUCCESS) @@ -474,7 +484,7 @@ bogons: printf("pmap_init: pt_map [%x - %x)\n", addr, addr2); #endif -#if defined(HP380) +#if defined(M68040) if (mmutype == MMU_68040) { protostfree = ~l2tobm(0); for (rv = MAXUL2SIZE; rv < sizeof(protostfree)*NBBY; rv++) @@ -693,7 +703,7 @@ pmap_pinit(pmap) */ pmap->pm_stab = Segtabzero; pmap->pm_stpa = Segtabzeropa; -#if defined(HP380) +#if defined(M68040) if (mmutype == MMU_68040) pmap->pm_stfree = protostfree; #endif @@ -853,7 +863,7 @@ pmap_remove(pmap, sva, eva) pte = pmap_pte(pmap, sva); while (sva < nssva) { if (pmap_pte_v(pte)) { -#ifdef HAVEVAC +#ifdef M68K_MMU_HP if (pmap_aliasmask) { /* * Purge kernel side of VAC to ensure @@ -888,7 +898,7 @@ pmap_remove(pmap, sva, eva) */ if (firstpage) return; -#ifdef HAVEVAC +#ifdef M68K_MMU_HP /* * In a couple of cases, we don't need to worry about flushing * the VAC: @@ -1041,7 +1051,7 @@ pmap_protect(pmap, sva, eva, prot) pte = pmap_pte(pmap, sva); while (sva < nssva) { if (pmap_pte_v(pte) && pmap_pte_prot_chg(pte, isro)) { -#ifdef HAVEVAC +#ifdef M68K_MMU_HP /* * Purge kernel side of VAC to ensure we * get the correct state of any hardware @@ -1053,7 +1063,7 @@ pmap_protect(pmap, sva, eva, prot) if (firstpage && pmap_aliasmask) DCIS(); #endif -#if defined(HP380) +#if defined(M68040) /* * Clear caches if making RO (see section * "7.3 Cache Coherency" in the manual). @@ -1085,7 +1095,7 @@ pmap_protect(pmap, sva, eva, prot) sva += NBPG; } } -#if defined(HAVEVAC) && defined(DEBUG) +#if defined(M68K_MMU_HP) && defined(DEBUG) if (pmap_aliasmask && (pmapvacflush & PVF_PROTECT)) { if (pmapvacflush & PVF_TOTAL) DCIA(); @@ -1279,7 +1289,7 @@ pmap_enter(pmap, va, pa, prot, wired) if (!npv->pv_next) enter_stats.secondpv++; #endif -#ifdef HAVEVAC +#ifdef M68K_MMU_HP /* * Since there is another logical mapping for the * same page we may need to cache-inhibit the @@ -1351,7 +1361,7 @@ pmap_enter(pmap, va, pa, prot, wired) pmap->pm_stats.wired_count++; validate: -#ifdef HAVEVAC +#ifdef M68K_MMU_HP /* * Purge kernel side of VAC to ensure we get correct state * of HW bits so we don't clobber them. @@ -1367,7 +1377,7 @@ validate: npte |= PG_W; if (!checkpv && !cacheable) npte |= PG_CI; -#if defined(HP380) +#if defined(M68040) if (mmutype == MMU_68040 && (npte & (PG_PROT|PG_CI)) == PG_RW) #ifdef DEBUG if (dowriteback && (dokwriteback || pmap != pmap_kernel())) @@ -1383,7 +1393,7 @@ validate: * If so, we need not flush the TLB and caches. */ wired = ((*pte ^ npte) == PG_W); -#if defined(HP380) +#if defined(M68040) if (mmutype == MMU_68040 && !wired) { DCFP(pa); ICPP(pa); @@ -1392,7 +1402,7 @@ validate: *pte = npte; if (!wired && active_pmap(pmap)) TBIS(va); -#ifdef HAVEVAC +#ifdef M68K_MMU_HP /* * The following is executed if we are entering a second * (or greater) mapping for a physical page and the mappings @@ -1973,7 +1983,7 @@ pmap_remove_mapping(pmap, va, pte, flags) if (*pte == PG_NV) return; } -#ifdef HAVEVAC +#ifdef M68K_MMU_HP if (pmap_aliasmask && (flags & PRM_CFLUSH)) { /* * Purge kernel side of VAC to ensure we get the correct @@ -2087,7 +2097,7 @@ pmap_remove_mapping(pmap, va, pte, flags) pmap_free_pv(npv); pv = pa_to_pvh(pa); } -#ifdef HAVEVAC +#ifdef M68K_MMU_HP /* * If only one mapping left we no longer need to cache inhibit */ @@ -2119,7 +2129,7 @@ pmap_remove_mapping(pmap, va, pte, flags) printf("remove: ste was %x@%x pte was %x@%x\n", *ste, ste, opte, pmap_pte(pmap, va)); #endif -#if defined(HP380) +#if defined(M68040) if (mmutype == MMU_68040) { st_entry_t *este = &ste[NPTEPG/SG4_LEV3SIZE]; @@ -2156,7 +2166,7 @@ pmap_remove_mapping(pmap, va, pte, flags) HP_STSIZE); ptpmap->pm_stab = Segtabzero; ptpmap->pm_stpa = Segtabzeropa; -#if defined(HP380) +#if defined(M68040) if (mmutype == MMU_68040) ptpmap->pm_stfree = protostfree; #endif @@ -2218,7 +2228,7 @@ pmap_testbit(pa, bit) splx(s); return(TRUE); } -#ifdef HAVEVAC +#ifdef M68K_MMU_HP /* * Flush VAC to get correct state of any hardware maintained bits. */ @@ -2305,7 +2315,7 @@ pmap_changebit(pa, bit, setem) } pte = pmap_pte(pv->pv_pmap, va); -#ifdef HAVEVAC +#ifdef M68K_MMU_HP /* * Flush VAC to ensure we get correct state of HW bits * so we don't clobber them. @@ -2320,7 +2330,7 @@ pmap_changebit(pa, bit, setem) else npte = *pte & ~bit; if (*pte != npte) { -#if defined(HP380) +#if defined(M68040) /* * If we are changing caching status or * protection make sure the caches are @@ -2353,7 +2363,7 @@ pmap_changebit(pa, bit, setem) } #endif } -#if defined(HAVEVAC) && defined(DEBUG) +#if defined(M68K_MMU_HP) && defined(DEBUG) if (setem && bit == PG_RO && (pmapvacflush & PVF_PROTECT)) { if ((pmapvacflush & PVF_TOTAL) || toflush == 3) DCIA(); @@ -2397,7 +2407,7 @@ pmap_enter_ptpage(pmap, va) kmem_alloc(st_map, HP_STSIZE); pmap->pm_stpa = (st_entry_t *) pmap_extract(pmap_kernel(), (vm_offset_t)pmap->pm_stab); -#if defined(HP380) +#if defined(M68040) if (mmutype == MMU_68040) { #ifdef DEBUG if (dowriteback && dokwriteback) @@ -2421,7 +2431,7 @@ pmap_enter_ptpage(pmap, va) } ste = pmap_ste(pmap, va); -#if defined(HP380) +#if defined(M68040) /* * Allocate level 2 descriptor block if necessary */ @@ -2534,7 +2544,7 @@ pmap_enter_ptpage(pmap, va) PHYS_TO_VM_PAGE(ptpa)->flags |= PG_PTPAGE; #endif } -#if defined(HP380) +#if defined(M68040) /* * Turn off copyback caching of page table pages, * could get ugly otherwise. @@ -2586,7 +2596,7 @@ pmap_enter_ptpage(pmap, va) * it would be difficult to identify ST pages in pmap_pageable to * release them. We also avoid the overhead of vm_map_pageable. */ -#if defined(HP380) +#if defined(M68040) if (mmutype == MMU_68040) { st_entry_t *este; diff --git a/sys/arch/hp300/hp300/pmap_bootstrap.c b/sys/arch/hp300/hp300/pmap_bootstrap.c index 7c0456cc71a..c7d8b3fa2c2 100644 --- a/sys/arch/hp300/hp300/pmap_bootstrap.c +++ b/sys/arch/hp300/hp300/pmap_bootstrap.c @@ -1,4 +1,4 @@ -/* $NetBSD: pmap_bootstrap.c,v 1.7 1995/10/05 06:54:12 thorpej Exp $ */ +/* $NetBSD: pmap_bootstrap.c,v 1.9 1995/12/11 17:09:16 thorpej Exp $ */ /* * Copyright (c) 1991, 1993 @@ -61,7 +61,7 @@ extern int maxmem, physmem; extern vm_offset_t avail_start, avail_end, virtual_avail, virtual_end; extern vm_size_t mem_size; extern int protection_codes[]; -#ifdef HAVEVAC +#ifdef M68K_MMU_HP extern int pmap_aliasmask; #endif @@ -410,18 +410,25 @@ pmap_bootstrap(nextpa, firstpa) /* * VM data structures are now initialized, set up data for * the pmap module. + * + * Note about avail_end: msgbuf is initialized just after + * avail_end in machdep.c. Since the last page is used + * for rebooting the system (code is copied there and + * excution continues from copied code before the MMU + * is disabled), the msgbuf will get trounced between + * reboots if it's placed in the last physical page. + * To work around this, we move avail_end back one more + * page so the msgbuf can be preserved. */ RELOC(avail_start, vm_offset_t) = nextpa; - RELOC(avail_end, vm_offset_t) = - hp300_ptob(RELOC(maxmem, int)) - /* XXX allow for msgbuf */ - - hp300_round_page(sizeof(struct msgbuf)); + RELOC(avail_end, vm_offset_t) = hp300_ptob(RELOC(maxmem, int)) - + (hp300_round_page(sizeof(struct msgbuf)) + hp300_ptob(1)); RELOC(mem_size, vm_size_t) = hp300_ptob(RELOC(physmem, int)); RELOC(virtual_avail, vm_offset_t) = VM_MIN_KERNEL_ADDRESS + (nextpa - firstpa); RELOC(virtual_end, vm_offset_t) = VM_MAX_KERNEL_ADDRESS; -#ifdef HAVEVAC +#ifdef M68K_MMU_HP /* * Determine VA aliasing distance if any */ diff --git a/sys/arch/hp300/hp300/sys_machdep.c b/sys/arch/hp300/hp300/sys_machdep.c index b600185a4df..9f1823e1401 100644 --- a/sys/arch/hp300/hp300/sys_machdep.c +++ b/sys/arch/hp300/hp300/sys_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: sys_machdep.c,v 1.12 1995/10/08 19:01:26 thorpej Exp $ */ +/* $NetBSD: sys_machdep.c,v 1.13 1995/12/11 17:09:17 thorpej Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -137,7 +137,7 @@ cachectl(req, addr, len) { int error = 0; -#if defined(HP380) +#if defined(M68040) if (mmutype == MMU_68040) { register int inc = 0; int pa = 0, doall = 0; diff --git a/sys/arch/hp300/hp300/trap.c b/sys/arch/hp300/hp300/trap.c index 12852ac6384..eb33b83aeb4 100644 --- a/sys/arch/hp300/hp300/trap.c +++ b/sys/arch/hp300/hp300/trap.c @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.38 1995/09/03 00:44:43 thorpej Exp $ */ +/* $NetBSD: trap.c,v 1.40 1995/12/11 17:09:18 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -66,7 +66,7 @@ #include <vm/pmap.h> #ifdef COMPAT_HPUX -#include <hp300/hpux/hpux.h> +#include <compat/hpux/hpux.h> #endif char *trap_type[] = { @@ -104,7 +104,7 @@ short exframesize[] = { -1, -1, -1, -1 /* type C-F - undefined */ }; -#ifdef HP380 +#ifdef M68040 #define KDFAULT(c) (mmutype == MMU_68040 ? \ ((c) & SSW4_TMMASK) == SSW4_TMKD : \ ((c) & (SSW_DF|FC_SUPERD)) == (SSW_DF|FC_SUPERD)) @@ -138,7 +138,7 @@ userret(p, fp, oticks, faultaddr, fromtrap) int fromtrap; { int sig, s; -#ifdef HP380 +#ifdef M68040 int beenhere = 0; again: @@ -174,7 +174,7 @@ again: addupc_task(p, fp->f_pc, (int)(p->p_sticks - oticks) * psratio); } -#ifdef HP380 +#ifdef M68040 /* * Deal with user mode writebacks (from trap, or from sigreturn). * If any writeback fails, go back and attempt signal delivery. @@ -314,7 +314,7 @@ copyfault: break; #endif -#ifdef HP380 +#ifdef M68040 case T_FPEMULI|T_USER: /* unimplemented FP instuction */ case T_FPEMULD|T_USER: /* unimplemented FP data type */ /* XXX need to FSAVE */ @@ -546,7 +546,7 @@ copyfault: } if (rv == KERN_SUCCESS) { if (type == T_MMUFLT) { -#ifdef HP380 +#ifdef M68040 if (mmutype == MMU_68040) (void) writeback(&frame, 1); #endif @@ -575,7 +575,7 @@ out: userret(p, &frame, sticks, v, 1); } -#ifdef HP380 +#ifdef M68040 #ifdef DEBUG struct writebackstats { int calls; diff --git a/sys/arch/hp300/hp300/vm_machdep.c b/sys/arch/hp300/hp300/vm_machdep.c index 59aaae84826..98e8a0d8289 100644 --- a/sys/arch/hp300/hp300/vm_machdep.c +++ b/sys/arch/hp300/hp300/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.25 1995/08/07 06:13:57 mycroft Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.26 1995/12/09 04:37:38 mycroft Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -68,7 +68,7 @@ * address in each process; in the future we will probably relocate * the frame pointers on the stack after copying. */ -int +void cpu_fork(p1, p2) register struct proc *p1, *p2; { @@ -98,8 +98,6 @@ cpu_fork(p1, p2) pcb->pcb_regs[6] = (int)child_return; /* A2 */ pcb->pcb_regs[7] = (int)p2; /* A3 */ pcb->pcb_regs[11] = (int)sf; /* SSP */ - - return (0); } void diff --git a/sys/arch/hp300/include/cpu.h b/sys/arch/hp300/include/cpu.h index 5412512f98b..562acbf1285 100644 --- a/sys/arch/hp300/include/cpu.h +++ b/sys/arch/hp300/include/cpu.h @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.14 1995/06/28 02:55:45 cgd Exp $ */ +/* $NetBSD: cpu.h,v 1.15 1995/12/11 17:09:22 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -42,6 +42,9 @@ * @(#)cpu.h 8.4 (Berkeley) 1/5/94 */ +#ifndef _HP300_CPU_H_ +#define _HP300_CPU_H_ + /* * Exported definitions unique to hp300/68k cpu support. */ @@ -126,6 +129,58 @@ extern unsigned char ssir; { "console_device", CTLTYPE_STRUCT }, \ } +#ifdef _KERNEL +/* + * Associate HP 9000/300 models with CPU/MMU combinations. + */ + +/* + * HP 68020-based computers. HP320 and HP350 have an HP MMU. + * HP330 has a Motorola MMU. + */ +#if (defined(HP320) || defined(HP330) || defined(HP350)) +#ifndef M68020 +#define M68020 +#endif /* ! M68020 */ + +#if defined(HP330) && !defined(M68K_MMU_MOTOROLA) +#define M68K_MMU_MOTOROLA +#endif /* HP330 && ! M68K_MMU_MOTOROLA */ + +#if (defined(HP320) || defined(HP350)) && !defined(M68K_MMU_HP) +#define M68K_MMU_HP /* include cheezy VAC support */ +#endif /* (HP320 || HP350) && ! M68K_MMU_HP */ +#endif /* HP320 || HP330 || HP350 */ + +/* + * HP 68030-based computers. HP375 includes support for the + * 345, 400t, and 400s. + */ +#if (defined(HP340) || defined(HP360) || defined(HP370) || defined(HP375)) +#ifndef M68030 +#define M68030 +#endif /* ! M68030 */ + +#ifndef M68K_MMU_MOTOROLA +#define M68K_MMU_MOTOROLA +#endif /* ! M68K_MMU_MOTOROLA */ +#endif /* HP340 || HP360 || HP370 || HP375 */ + +/* + * HP 68040-based computers. HP380 includes support for the + * 425t, 425s, and 433s. + */ +#if defined(HP380) +#ifndef M68040 +#define M68040 +#endif /* ! M68040 */ + +#ifndef M68K_MMU_MOTOROLA +#define M68K_MMU_MOTOROLA +#endif /* ! M68K_MMU_MOTOROLA */ +#endif /* HP380 */ +#endif /* _KERNEL */ + /* * The rest of this should probably be moved to ../hp300/hp300cpu.h, * although some of it could probably be put into generic 68k headers. @@ -302,3 +357,5 @@ extern char *intiobase, *intiolimit; #define CACHE4_ON (IC4_ENABLE|DC4_ENABLE) #define CACHE4_OFF (0) + +#endif /* _HP300_CPU_H_ */ diff --git a/sys/arch/hp300/include/exec.h b/sys/arch/hp300/include/exec.h index 9559df95c95..5e068296ea5 100644 --- a/sys/arch/hp300/include/exec.h +++ b/sys/arch/hp300/include/exec.h @@ -1,4 +1,4 @@ -/* $NetBSD: exec.h,v 1.9 1995/03/28 18:16:33 jtc Exp $ */ +/* $NetBSD: exec.h,v 1.10 1995/11/20 01:15:26 thorpej Exp $ */ /* * Copyright (c) 1993 Christopher G. Demetriou @@ -27,42 +27,13 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _HP300_EXEC_H_ -#define _HP300_EXEC_H_ - -#ifdef _KERNEL - -#ifdef COMPAT_HPUX -#include "user.h" /* for pcb */ -#include "hp300/hpux/hpux_exec.h" -#endif - -/* - * the following, if defined, prepares a set of vmspace commands for - * a given exectable package defined by epp. - * The standard executable formats are taken care of automatically; - * machine-specific ones can be defined using this function. - */ -int cpu_exec_makecmds __P((struct proc *p, struct exec_package *epp)); - -/* - * the following function/macro checks to see if a given machine - * type (a_mid) field is valid for this architecture - * a non-zero return value indicates that the machine type is correct. - */ -#ifdef COMPAT_HPUX -#define cpu_exec_checkmid(mid) ((mid == MID_HP200) || (mid == MID_HP300) || \ - (mid == MID_HPUX)) -#else -#define cpu_exec_checkmid(mid) ((mid == MID_HP200) || (mid == MID_HP300))) -#endif - -#endif /* _KERNEL */ +#ifndef _MACHINE_EXEC_H_ +#define _MACHINE_EXEC_H_ #define __LDPGSZ 4096 /* Relocation format. */ -struct relocation_info_hp300 { +struct relocation_info_m68k { int r_address; /* offset in text or data segment */ unsigned int r_symbolnum : 24, /* ordinal number of add symbol */ r_pcrel : 1, /* 1 if value should be pc-relative */ @@ -73,6 +44,6 @@ struct relocation_info_hp300 { r_relative : 1, /* load address relative */ r_copy : 1; /* run time copy */ }; -#define relocation_info relocation_info_hp300 +#define relocation_info relocation_info_m68k -#endif /* _HP300_EXEC_H_ */ +#endif /* _MACHINE_EXEC_H_ */ diff --git a/sys/arch/hp300/include/pmap.h b/sys/arch/hp300/include/pmap.h index 073d68743bb..13de98c2a0d 100644 --- a/sys/arch/hp300/include/pmap.h +++ b/sys/arch/hp300/include/pmap.h @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.9 1995/05/11 16:53:03 jtc Exp $ */ +/* $NetBSD: pmap.h,v 1.10 1995/12/11 17:09:23 thorpej Exp $ */ /* * Copyright (c) 1987 Carnegie-Mellon University @@ -43,9 +43,10 @@ #ifndef _HP300_PMAP_H_ #define _HP300_PMAP_H_ +#include <machine/cpu.h> #include <machine/pte.h> -#if defined(HP380) +#if defined(M68040) #define HP_SEG_SIZE (mmutype == MMU_68040 ? 0x40000 : NBSEG) #else #define HP_SEG_SIZE NBSEG @@ -135,11 +136,6 @@ struct pv_page { struct pv_entry pvp_pv[NPVPPG]; }; -#ifdef _KERNEL -#if defined(HP320) || defined(HP350) -#define HAVEVAC /* include cheezy VAC support */ -#endif - extern struct pmap kernel_pmap_store; #define pmap_kernel() (&kernel_pmap_store) @@ -156,6 +152,5 @@ extern struct pv_entry *pv_table; /* array of entries, one per page */ extern pt_entry_t *Sysmap; extern char *vmmap; /* map for mem, dumps, etc. */ -#endif /* _KERNEL */ #endif /* !_HP300_PMAP_H_ */ diff --git a/sys/arch/hp300/stand/if_le.c b/sys/arch/hp300/stand/if_le.c index 24983328460..12cea60a0ef 100644 --- a/sys/arch/hp300/stand/if_le.c +++ b/sys/arch/hp300/stand/if_le.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_le.c,v 1.6.2.1 1995/10/19 20:42:41 thorpej Exp $ */ +/* $NetBSD: if_le.c,v 1.7 1995/10/19 18:43:27 thorpej Exp $ */ /* * Copyright (c) 1993 Adam Glass diff --git a/sys/arch/pc532/To.Do b/sys/arch/pc532/To.Do index 88173f4628d..225f3d636bc 100644 --- a/sys/arch/pc532/To.Do +++ b/sys/arch/pc532/To.Do @@ -1,37 +1,31 @@ -$NetBSD: To.Do,v 1.4 1995/06/09 06:03:45 phil Exp $ +$NetBSD: To.Do,v 1.5 1995/12/07 07:55:11 phil Exp $ This is the "To Do" list for NetBSD/pc532 (Order is not in order of importance.) + (Last updated, 12/6/95) - improve scn driver (integrate mods from Phil Bunde) - get kernel debugger working -- get the dp scsi driver working +- get the ncr interrupt driven scsi driver working debugged - write an aic scsi driver -- improve copyin/out and friends +- improve copyin/out and friends (kernel work) -- get gdb working (partially done) +- remove double mapping of the user area (kernel work) -- ptrace syscall (?) - -- improve bim (detect a non-writeable disklabel, ...) +- get gdb working (partially done) including kernel debugging - man4 man pages - man8 man pages -- mods to better support ufs boot loader - -- integrate printer driver from matthias (partially done) +- mods to better support ffs boot loader -- verify all devices including vn, tun, ... - -- integrate other machine independent "devices" - -- write a bim.8 +- improve bim (detect a non-writeable disklabel, ...) + write a bim.8 - find or write a "usable" comm package to replace kermit for initial downloading. diff --git a/sys/arch/pc532/conf/DEFAULT b/sys/arch/pc532/conf/DEFAULT index f25774619f9..47217dacfbe 100644 --- a/sys/arch/pc532/conf/DEFAULT +++ b/sys/arch/pc532/conf/DEFAULT @@ -63,7 +63,8 @@ options GENERIC membus0 at root -ncr0 at membus? +#ncr0 at membus? +oldncr0 at membus? scsibus0 at scsi? diff --git a/sys/arch/pc532/conf/INSTALL b/sys/arch/pc532/conf/INSTALL index 2ae8556d6c4..4261d846ab3 100644 --- a/sys/arch/pc532/conf/INSTALL +++ b/sys/arch/pc532/conf/INSTALL @@ -1,4 +1,4 @@ -# $NetBSD: INSTALL,v 1.3 1995/09/29 04:16:48 phil Exp $ +# $NetBSD: INSTALL,v 1.4 1995/11/30 00:58:39 jtc Exp $ # # INSTALL -- install kernel # @@ -43,7 +43,8 @@ membus0 at root rd0 at membus? options RD_SIZE=0x200000 -ncr0 at membus? +#ncr0 at membus? +oldncr0 at membus? scsibus0 at scsi? sd* at scsibus? target ? lun ? diff --git a/sys/arch/pc532/conf/STEELHEAD b/sys/arch/pc532/conf/STEELHEAD index 076615e0393..b78d97c35e5 100644 --- a/sys/arch/pc532/conf/STEELHEAD +++ b/sys/arch/pc532/conf/STEELHEAD @@ -1,4 +1,4 @@ -# $NetBSD: STEELHEAD,v 1.9 1995/09/26 20:16:02 phil Exp $ +# $NetBSD: STEELHEAD,v 1.10 1995/11/30 00:58:40 jtc Exp $ # # STEELHEAD: Phil Nelson's pc532 # @@ -59,7 +59,8 @@ membus0 at root #rd0 at membus? -ncr0 at membus? +#ncr0 at membus? +oldncr0 at membus? scsibus0 at scsi? diff --git a/sys/arch/pc532/conf/files.pc532 b/sys/arch/pc532/conf/files.pc532 index 06d6a76db93..7e561c9e402 100644 --- a/sys/arch/pc532/conf/files.pc532 +++ b/sys/arch/pc532/conf/files.pc532 @@ -1,4 +1,4 @@ -# $NetBSD: files.pc532,v 1.15.2.1 1995/10/17 00:18:56 phil Exp $ +# $NetBSD: files.pc532,v 1.16 1995/11/30 00:58:42 jtc Exp $ # # new style config file for pc532 architecture # diff --git a/sys/arch/pc532/dev/lpt.c b/sys/arch/pc532/dev/lpt.c index 0bd190c85ea..b851f22b527 100644 --- a/sys/arch/pc532/dev/lpt.c +++ b/sys/arch/pc532/dev/lpt.c @@ -1,4 +1,4 @@ -/* $NetBSD: lpt.c,v 1.6.2.1 1995/10/19 01:33:06 phil Exp $ */ +/* $NetBSD: lpt.c,v 1.7 1995/11/30 00:58:45 jtc Exp $ */ /* * Copyright (c) 1994 Matthias Pfaller. diff --git a/sys/arch/pc532/dev/ncr.c b/sys/arch/pc532/dev/ncr.c index a67d5d620bd..414a31d1a0d 100644 --- a/sys/arch/pc532/dev/ncr.c +++ b/sys/arch/pc532/dev/ncr.c @@ -1,4 +1,4 @@ -/* $NetBSD: ncr.c,v 1.20.2.1 1995/10/19 01:33:08 phil Exp $ */ +/* $NetBSD: ncr.c,v 1.21 1995/11/30 00:58:47 jtc Exp $ */ /* * Copyright (c) 1994 Matthias Pfaller. @@ -29,7 +29,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: ncr.c,v 1.2 1995/10/26 01:11:45 deraadt Exp $ + * $Id: ncr.c,v 1.3 1995/12/14 05:29:21 deraadt Exp $ */ #include <sys/param.h> diff --git a/sys/arch/pc532/dev/ncr5380.c b/sys/arch/pc532/dev/ncr5380.c index a0372cdef00..068161e7c55 100644 --- a/sys/arch/pc532/dev/ncr5380.c +++ b/sys/arch/pc532/dev/ncr5380.c @@ -1,4 +1,4 @@ -/* $NetBSD: ncr5380.c,v 1.5.2.1 1995/10/19 01:33:09 phil Exp $ */ +/* $NetBSD: ncr5380.c,v 1.6 1995/11/30 00:58:50 jtc Exp $ */ /* * Copyright (c) 1995 Leo Weppelman. diff --git a/sys/arch/pc532/dev/ncr5380reg.h b/sys/arch/pc532/dev/ncr5380reg.h index 11945a4341c..07fc0c00be3 100644 --- a/sys/arch/pc532/dev/ncr5380reg.h +++ b/sys/arch/pc532/dev/ncr5380reg.h @@ -1,4 +1,4 @@ -/* $NetBSD: ncr5380reg.h,v 1.3.2.1 1995/10/19 01:33:11 phil Exp $ */ +/* $NetBSD: ncr5380reg.h,v 1.4 1995/11/30 00:58:54 jtc Exp $ */ /* * Copyright (c) 1995 Leo Weppelman. diff --git a/sys/arch/pc532/dev/ncrreg.h b/sys/arch/pc532/dev/ncrreg.h index 41f91fe446f..7016e37550d 100644 --- a/sys/arch/pc532/dev/ncrreg.h +++ b/sys/arch/pc532/dev/ncrreg.h @@ -1,4 +1,4 @@ -/* $NetBSD: ncrreg.h,v 1.2.2.1 1995/10/19 01:33:12 phil Exp $ */ +/* $NetBSD: ncrreg.h,v 1.3 1995/11/30 00:58:56 jtc Exp $ */ /* * Copyright (c) 1994 Matthias Pfaller. @@ -29,7 +29,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: ncrreg.h,v 1.2 1995/10/26 01:11:48 deraadt Exp $ + * $Id: ncrreg.h,v 1.3 1995/12/14 05:29:24 deraadt Exp $ */ #ifndef _NCRREG_H diff --git a/sys/arch/pc532/include/types.h b/sys/arch/pc532/include/types.h index c048c9ae906..776ea0dc7ea 100644 --- a/sys/arch/pc532/include/types.h +++ b/sys/arch/pc532/include/types.h @@ -1,4 +1,4 @@ -/* $NetBSD: types.h,v 1.11 1995/08/25 07:52:20 phil Exp $ */ +/* $NetBSD: types.h,v 1.12 1995/12/09 04:41:41 mycroft Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -70,5 +70,6 @@ typedef unsigned long long u_int64_t; typedef int32_t register_t; #define __SWAP_BROKEN +#define __FORK_BRAINDAMAGE #endif /* _MACHTYPES_H_ */ diff --git a/sys/arch/pc532/pc532/locore.s b/sys/arch/pc532/pc532/locore.s index f468675555d..2862bf29997 100644 --- a/sys/arch/pc532/pc532/locore.s +++ b/sys/arch/pc532/pc532/locore.s @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.29.2.1 1995/10/17 00:19:05 phil Exp $ */ +/* $NetBSD: locore.s,v 1.30 1995/11/30 00:59:00 jtc Exp $ */ /* * Copyright (c) 1993 Philip A. Nelson. diff --git a/sys/arch/pc532/pc532/machdep.c b/sys/arch/pc532/pc532/machdep.c index 42289c3da3a..cf6b5fa0c22 100644 --- a/sys/arch/pc532/pc532/machdep.c +++ b/sys/arch/pc532/pc532/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.40.2.2 1995/11/22 20:36:08 phil Exp $ */ +/* $NetBSD: machdep.c,v 1.41 1995/11/30 00:59:02 jtc Exp $ */ /*- * Copyright (c) 1982, 1987, 1990 The Regents of the University of California. diff --git a/sys/arch/pc532/stand/Makefile b/sys/arch/pc532/stand/Makefile index e3b12949760..70405bfa716 100644 --- a/sys/arch/pc532/stand/Makefile +++ b/sys/arch/pc532/stand/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.7.2.2 1995/10/24 19:23:09 phil Exp $ +# $NetBSD: Makefile,v 1.8 1995/11/30 00:59:05 jtc Exp $ # @(#)Makefile 8.1 (Berkeley) 6/10/93 diff --git a/sys/arch/pc532/stand/boot.c b/sys/arch/pc532/stand/boot.c index bd69ffb0b41..2aa99d1e2d7 100644 --- a/sys/arch/pc532/stand/boot.c +++ b/sys/arch/pc532/stand/boot.c @@ -1,4 +1,4 @@ -/* $NetBSD: boot.c,v 1.4.2.1 1995/10/17 00:19:15 phil Exp $ */ +/* $NetBSD: boot.c,v 1.5 1995/11/30 00:59:06 jtc Exp $ */ /*- * Copyright (c) 1982, 1986, 1990, 1993 @@ -36,7 +36,7 @@ */ #ifndef lint -static char rcsid[] = "$NetBSD: boot.c,v 1.4.2.1 1995/10/17 00:19:15 phil Exp $"; +static char rcsid[] = "$NetBSD: boot.c,v 1.5 1995/11/30 00:59:06 jtc Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -74,7 +74,7 @@ main() cninit(); scsiinit(); - printf("\n>> NetBSD BOOT pc532 [$Revision: 1.2 $]\n"); + printf("\n>> NetBSD BOOT pc532 [$Revision: 1.3 $]\n"); bdev = B_TYPE(bootdev); bctlr = B_CONTROLLER(bootdev); diff --git a/sys/arch/pmax/conf/Makefile.pmax b/sys/arch/pmax/conf/Makefile.pmax index 56aa6778934..834a013b9dc 100644 --- a/sys/arch/pmax/conf/Makefile.pmax +++ b/sys/arch/pmax/conf/Makefile.pmax @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.pmax,v 1.16.2.2 1995/10/13 03:15:59 jonathan Exp $ +# $NetBSD: Makefile.pmax,v 1.17 1995/11/25 05:55:38 mellon Exp $ # @(#)Makefile.pmax 8.2 (Berkeley) 2/16/94 # @@ -33,9 +33,9 @@ INCLUDES= -I. -I$S/arch -I$S -I$S/sys COPTS= ${INCLUDES} ${IDENT} -D_KERNEL -Dpmax -D__NetBSD__ ${GP} CPPOPTS=${INCLUDES} ${IDENT} -D_KERNEL -Dpmax -D__NetBSD__ .ifdef DEBUG -CFLAGS= ${DEBUG} -Werror ${COPTS} +CFLAGS= ${DEBUG} -Werror -fno-builtin ${COPTS} .else -CFLAGS= -O2 -Werror ${COPTS} +CFLAGS= -O2 -Werror -fno-builtin ${COPTS} .endif ### find out what to use for libkern @@ -54,6 +54,18 @@ LIBCOMPAT= ${COMPATLIB} LIBCOMPAT= ${COMPATLIB_PROF} .endif +TARGET_MACHINE = pmax +TARGET_ARCH = mips +.if (${MACHINE_ARCH} != pmax) +CC= /usr/local/mips-dec-netbsd/bin/gcc +LD= /usr/local/mips-dec-netbsd/bin/ld +AS= /usr/local/mips-dec-netbsd/bin/as +AR= /usr/local/mips-dec-netbsd/bin/ar +NM= /usr/local/mips-dec-netbsd/bin/nm +LORDER= NM=$(NM) sh ../../../../../../../usr.bin/lorder/lorder.sh.gnm +RANLIB= /usr/local/mips-dec-netbsd/bin/ranlib +.endif + # compile rules: rules are named ${TYPE}_${SUFFIX}${CONFIG_DEP} # where TYPE is NORMAL, DRIVER, or PROFILE}; SUFFIX is the file suffix, # capitalized (e.g. C for a .c file), and CONFIG_DEP is _C if the file @@ -143,7 +155,7 @@ assym.h: genassym ./genassym >assym.h genassym: ${PMAX}/pmax/genassym.c - ${CC} ${INCLUDES} ${IDENT} ${PARAM} -o genassym ${PMAX}/pmax/genassym.c + cc ${INCLUDES} ${IDENT} ${PARAM} -o genassym ${PMAX}/pmax/genassym.c depend: assym.h param.c vnode_if.h mkdep ${COPTS} ${CFILES} ioconf.c param.c diff --git a/sys/arch/pmax/dev/bt478.c b/sys/arch/pmax/dev/bt478.c index 23f5e543163..e672cfd1c2c 100644 --- a/sys/arch/pmax/dev/bt478.c +++ b/sys/arch/pmax/dev/bt478.c @@ -1,4 +1,4 @@ -/* $NetBSD: bt478.c,v 1.1 1995/09/11 08:11:22 jonathan Exp $ */ +/* $NetBSD: bt478.c,v 1.2 1995/11/25 10:38:42 mellon Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -121,7 +121,6 @@ bt478init(fi) * Initialize the color map and the screen. */ bt478InitColorMap(fi); - bt478RestoreCursorColor (fi); return (1); } @@ -211,14 +210,15 @@ bt478InitColorMap (fi) if (fi -> fi_type.fb_depth == 1) { vdac->mapWA = 0; MachEmptyWriteBuffer(); for (i = 0; i < 256; i++) { - ((u_char *)(fi -> fi_cmap_bits)) [i * 3] - = vdac->map = (i < 128) ? 0x00 : 0xff; - MachEmptyWriteBuffer(); + ((u_char *)(fi -> fi_cmap_bits)) [i * 3] = 0; ((u_char *)(fi -> fi_cmap_bits)) [i * 3 + 1] - = vdac->map = (i < 128) ? 0x00 : 0xff; + = (i < 128) ? 0x00 : 0xff; + ((u_char *)(fi -> fi_cmap_bits)) [i * 3 + 2] = 0; + vdac->map = 0; + MachEmptyWriteBuffer(); + vdac->map = (i < 128) ? 0x00 : 0xff; MachEmptyWriteBuffer(); - ((u_char *)(fi -> fi_cmap_bits)) [i * 3 + 2] - = vdac->map = (i < 128) ? 0x00 : 0xff; + vdac->map = 0; MachEmptyWriteBuffer(); } } else { @@ -244,8 +244,6 @@ bt478InitColorMap (fi) vdac->map = 0xff; MachEmptyWriteBuffer(); } -#if 0 -#endif } for (i = 0; i < 3; i++) { diff --git a/sys/arch/pmax/dev/pm.c b/sys/arch/pmax/dev/pm.c index 63f7feaf36e..28a4a093ee9 100644 --- a/sys/arch/pmax/dev/pm.c +++ b/sys/arch/pmax/dev/pm.c @@ -1,4 +1,4 @@ -/* $NetBSD: pm.c,v 1.8.2.1 1995/10/17 00:19:23 jonathan Exp $ */ +/* $NetBSD: pm.c,v 1.10 1995/11/25 10:39:57 mellon Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -381,141 +381,6 @@ pmLoadCursor(fi, cur) pcc->cmdr = curReg; } -#if 0 -/* - * ---------------------------------------------------------------------------- - * - * pmRestoreCursorColor -- - * - * Routine to restore the color of the cursor. - * - * Results: - * None. - * - * Side effects: - * None. - * - * ---------------------------------------------------------------------------- - */ -static void -pmRestoreCursorColor(fi) - struct fbinfo *fi; -{ - register VDACRegs *vdac = (VDACRegs *)MACH_PHYS_TO_UNCACHED(KN01_SYS_VDAC); - register int i; - - vdac->overWA = 0x04; - MachEmptyWriteBuffer(); - for (i = 0; i < 3; i++) { - vdac->over = bg_RGB[i]; - MachEmptyWriteBuffer(); - } - - vdac->overWA = 0x08; - MachEmptyWriteBuffer(); - vdac->over = 0x00; - MachEmptyWriteBuffer(); - vdac->over = 0x00; - MachEmptyWriteBuffer(); - vdac->over = 0x7f; - MachEmptyWriteBuffer(); - - vdac->overWA = 0x0c; - MachEmptyWriteBuffer(); - for (i = 0; i < 3; i++) { - vdac->over = fg_RGB[i]; - MachEmptyWriteBuffer(); - } -} - -/* - * ---------------------------------------------------------------------------- - * - * pmCursorColor -- - * - * Set the color of the cursor. - * - * Results: - * None. - * - * Side effects: - * None. - * - * ---------------------------------------------------------------------------- - */ -static void -pmCursorColor(color) - unsigned int color[]; -{ - register int i, j; - - for (i = 0; i < 3; i++) - bg_RGB[i] = (u_char)(color[i] >> 8); - - for (i = 3, j = 0; i < 6; i++, j++) - fg_RGB[j] = (u_char)(color[i] >> 8); - - pmRestoreCursorColor(); -} - -/* - * ---------------------------------------------------------------------------- - * - * pmInitColorMap -- - * - * Initialize the color map. - * - * Results: - * None. - * - * Side effects: - * The colormap is initialized appropriately whether it is color or - * monochrome. - * - * ---------------------------------------------------------------------------- - */ -static void -pmInitColorMap() -{ - register VDACRegs *vdac = (VDACRegs *)MACH_PHYS_TO_UNCACHED(KN01_SYS_VDAC); - register int i; - - *(volatile char *)MACH_PHYS_TO_UNCACHED(KN01_PHYS_COLMASK_START) = 0xff; - MachEmptyWriteBuffer(); - - if (fi->fi_type.fb_depth == 1) { - vdac->mapWA = 0; MachEmptyWriteBuffer(); - for (i = 0; i < 256; i++) { - vdac->map = (i < 128) ? 0x00 : 0xff; - MachEmptyWriteBuffer(); - vdac->map = (i < 128) ? 0x00 : 0xff; - MachEmptyWriteBuffer(); - vdac->map = (i < 128) ? 0x00 : 0xff; - MachEmptyWriteBuffer(); - } - } else { - vdac->mapWA = 0; MachEmptyWriteBuffer(); - vdac->map = 0; MachEmptyWriteBuffer(); - vdac->map = 0; MachEmptyWriteBuffer(); - vdac->map = 0; MachEmptyWriteBuffer(); - - for (i = 1; i < 256; i++) { - vdac->map = 0xff; MachEmptyWriteBuffer(); - vdac->map = 0xff; MachEmptyWriteBuffer(); - vdac->map = 0xff; MachEmptyWriteBuffer(); - } - } - - for (i = 0; i < 3; i++) { - bg_RGB[i] = 0x00; - fg_RGB[i] = 0xff; - } - pmRestoreCursorColor(); -} - - -#endif /* 0 */ - /* should zap pmloadcolormap too, but i haven't fixed the callers yet */ /* diff --git a/sys/arch/pmax/include/types.h b/sys/arch/pmax/include/types.h index 7e02fc291e0..4e42f810bdf 100644 --- a/sys/arch/pmax/include/types.h +++ b/sys/arch/pmax/include/types.h @@ -1,4 +1,4 @@ -/* $NetBSD: types.h,v 1.10 1995/07/06 03:39:43 cgd Exp $ */ +/* $NetBSD: types.h,v 1.11 1995/12/09 04:41:47 mycroft Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -74,5 +74,6 @@ typedef int32_t register_t; #define __BDEVSW_DUMP_OLD_TYPE #define __SWAP_BROKEN +#define __FORK_BRAINDAMAGE #endif /* _MACHTYPES_H_ */ diff --git a/sys/arch/pmax/pmax/sys_machdep.c b/sys/arch/pmax/pmax/sys_machdep.c index 6980ab07908..0f746c7f5a9 100644 --- a/sys/arch/pmax/pmax/sys_machdep.c +++ b/sys/arch/pmax/pmax/sys_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: sys_machdep.c,v 1.8.2.1 1995/10/13 03:18:11 jonathan Exp $ */ +/* $NetBSD: sys_machdep.c,v 1.9 1995/11/30 00:59:11 jtc Exp $ */ /* * Copyright (c) 1992, 1993 diff --git a/sys/arch/pmax/stand/byteswap.h b/sys/arch/pmax/stand/byteswap.h new file mode 100644 index 00000000000..c553c2775de --- /dev/null +++ b/sys/arch/pmax/stand/byteswap.h @@ -0,0 +1,8 @@ +/* + * inline macros for doing byteswapping on a little-endian machine. + * for boot. + */ +#define ntohs(x) \ + ( ( ((u_short)(x)&0xff) << 8) | ( ((u_short) (x)&0xff00) >> 8) ) +#define ntohl(x) \ + ( ((ntohs((u_short)(x))) << 16) | (ntohs( (u_short) ((x)>>16) )) ) diff --git a/sys/arch/vax/include/ioa.h b/sys/arch/pmax/stand/filesystem.c index b09da95056f..5277d83c9e8 100644 --- a/sys/arch/vax/include/ioa.h +++ b/sys/arch/pmax/stand/filesystem.c @@ -1,7 +1,5 @@ -/* $NetBSD: ioa.h,v 1.2 1994/10/26 08:02:09 cgd Exp $ */ - /* - * Copyright (c) 1994 Ludd, University of Lule}, Sweden. + * Copyright (c) 1993 Philip A. Nelson. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -14,23 +12,37 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed at Ludd, University of Lule}. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission + * This product includes software developed by Philip A. Nelson. + * 4. The name of Philip A. Nelson may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * THIS SOFTWARE IS PROVIDED BY PHILIP NELSON ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * IN NO EVENT SHALL PHILIP NELSON BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * filesystem.c + * + * $Id: filesystem.c,v 1.1 1995/12/14 05:26:27 deraadt Exp $ */ - /* All bugs are subject to removal without further notice */ - - +#include <stand.h> +#include <ufs.h> + +struct fs_ops file_system[] = { +#ifdef SMALL + { ufs_open, 0, ufs_read, 0, ufs_seek, ufs_stat } +#else + { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat } +#endif +}; + +int nfsys = sizeof(file_system)/sizeof(struct fs_ops); diff --git a/sys/arch/pmax/stand/libsa/strcmp.c b/sys/arch/pmax/stand/libsa/strcmp.c index 18489463bb1..ae936f99d51 100644 --- a/sys/arch/pmax/stand/libsa/strcmp.c +++ b/sys/arch/pmax/stand/libsa/strcmp.c @@ -1,4 +1,4 @@ -/* $NetBSD: strcmp.c,v 1.5 1995/01/18 06:53:58 mellon Exp $ */ +/* $NetBSD: strcmp.c,v 1.6 1995/10/26 01:39:49 jonathan Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -39,9 +39,10 @@ */ #include <arch/pmax/stand/dec_prom.h> +#undef strcmp strcmp(s1, s2) char *s1, *s2; { - return (callv->strcmp(s1, s2)); + return (callv->_strcmp(s1, s2)); } diff --git a/sys/arch/pmax/tc/if_le.c b/sys/arch/pmax/tc/if_le.c index 63a8dc6ac77..544abb001c6 100644 --- a/sys/arch/pmax/tc/if_le.c +++ b/sys/arch/pmax/tc/if_le.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_le.c,v 1.2.2.1 1995/10/13 03:22:51 jonathan Exp $ */ +/* $NetBSD: if_le.c,v 1.3 1995/11/25 01:23:51 cgd Exp $ */ /*- * Copyright (c) 1995 Charles M. Hannum. All rights reserved. @@ -77,6 +77,7 @@ extern u_long asic_base; #include <pmax/tc/tc.h> #include <pmax/pmax/asic.h> #include <pmax/tc/if_levar.h> +#define LEINTR_UNIT 1 /* pmax interrupts take a unit as arg */ #else /* Alpha */ typedef u_int64 word_t; @@ -93,9 +94,11 @@ typedef u_int64 word_t; #include <dev/ic/am7990reg.h> +#define LE_NEED_BUF_CONTIG +#define LE_NEED_BUF_GAP2 +#define LE_NEED_BUF_GAP16 #include <dev/ic/am7990var.h> - /* access LANCE registers */ void lewritereg(); #define LERDWR(cntl, src, dst) { (dst) = (src); wbflush(); } @@ -110,43 +113,19 @@ extern caddr_t le_iomem; #define LE_SOFTC(unit) lecd.cd_devs[unit] #define LE_DELAY(x) DELAY(x) -/* - * Routines for accessing the transmit and receive buffers. Unfortunately, - * CPU addressing of these buffers is done in one of 3 ways: - * - contiguous (for the 3max and turbochannel option card) - * - gap2, which means shorts (2 bytes) interspersed with short (2 byte) - * spaces (for the kn01) - * - gap16, which means 16bytes interspersed with 16byte spaces - * for buffers which must begin on a 32byte boundary (for 3min, - * maxine and 3maxplus). The gap16 machines still need gap2 for DMA - * ring-buffer descriptors. - * These functions are now defined in the machine-independent code; - * set the preprocessor macros that say which ones we need. - */ - -#define LE_NEED_BUF_CONTIG -#define LE_NEED_BUF_GAP2 -#define LE_NEED_BUF_GAP16 - int lematch __P((struct device *, void *, void *)); void leattach __P((struct device *, struct device *, void *)); -int leintr __P((void *)); +#ifdef LEINTR_UNIT +int leintr __P((int unit)); +#else +int leintr __P((void *sc)); +#endif struct cfdriver lecd = { NULL, "le", lematch, leattach, DV_IFNET, sizeof (struct le_softc) }; -void copytobuf_contig __P((struct le_softc *, void *, int, int)); -void copyfrombuf_contig __P((struct le_softc *, void *, int, int)); -void zerobuf_contig __P((struct le_softc *, int, int)); -integrate void copytobuf_gap16 __P((struct le_softc *, void *, int, int)); -integrate void copyfrombuf_gap16 __P((struct le_softc *, void *, int, int)); -integrate void zerobuf_gap16 __P((struct le_softc *, int, int)); -integrate void copytobuf_gap2 __P((struct le_softc *, void *, int, int)); -integrate void copyfrombuf_gap2 __P((struct le_softc *, void *, int, int)); -integrate void zerobuf_gap2 __P((struct le_softc *, int, int)); - integrate void lewrcsr(sc, port, val) struct le_softc *sc; @@ -191,7 +170,7 @@ lematch(parent, match, aux) /* make sure that we're looking for this type of device. */ if (!BUS_MATCHNAME(ca, "PMAD-BA ") && /* untested alpha TC option */ !BUS_MATCHNAME(ca, "PMAD-AA ") && /* KN02 baseboard, old option */ - !BUS_MATCHNAME(ca, "lance")) /* Our name for baseboard devices */ + !BUS_MATCHNAME(ca, "lance")) /* NetBSD name for b'board */ return (0); #ifdef notdef /* XXX */ @@ -225,11 +204,9 @@ leattach(parent, self, aux) sc->sc_r1 = (struct lereg1 *) MACH_PHYS_TO_UNCACHED(BUS_CVTADDR(ca)); - -#ifdef alpha /* !pmax */ +#ifdef alpha sc->sc_r1 = TC_DENSE_TO_SPARSE(sc->sc_r1); -#endif /* !pmax */ - +#endif sc->sc_mem = (void *)MACH_PHYS_TO_UNCACHED(le_iomem); /* XXX */ cp = (u_char *)ASIC_SYS_ETHER_ADDRESS(asic_base); @@ -244,20 +221,17 @@ leattach(parent, self, aux) */ ldp = (volatile u_int *) (ASIC_REG_LANCE_DMAPTR(asic_base)); dma_mask = ((word_t)le_iomem << 3); - -#ifdef alpha /* !pmax */ +#ifdef alpha /* Set upper 64 bits of DMA mask */ dma_mask = (dma_mask & ~(word_t)0x1f) | (((word_t)le_iomem >> 29) & 0x1f); -#endif /* alpha*/ - - *ldp = dma_mask; +#endif /*alpha*/ *(volatile u_int *)ASIC_REG_CSR(asic_base) |= ASIC_CSR_DMAEN_LANCE; wbflush(); - } else + } #ifdef pmax - if (sc->sc_dev.dv_unit == 0 && (pmax_boardtype == DS_PMAX)) { + else if (sc->sc_dev.dv_unit == 0 && (pmax_boardtype == DS_PMAX)) { /* It's on the baseboard, attached directly to mainbus. */ sc->sc_r1 = (struct lereg1 *)BUS_CVTADDR(ca); @@ -270,7 +244,7 @@ leattach(parent, self, aux) sc->sc_copyfrombuf = copyfrombuf_gap2; sc->sc_zerobuf = zerobuf_gap2; } -#endif /* pmax */ +#endif else { /* It's on the turbochannel proper, or on KN02 baseboard. */ sc->sc_r1 = (struct lereg1 *) @@ -301,8 +275,11 @@ leattach(parent, self, aux) sc->sc_arpcom.ac_if.if_name = lecd.cd_name; leconfig(sc); +#ifdef LEINTR_UNIT + BUS_INTR_ESTABLISH(ca, leintr, self->dv_unit); +#else BUS_INTR_ESTABLISH(ca, leintr, sc); - +#endif if (SYSTEM_HAS_ASIC()) { /* XXX YEECH!!! */ *(volatile u_int *)ASIC_REG_IMSK(asic_base) |= ASIC_INTR_LANCE; @@ -334,238 +311,17 @@ lewritereg(regptr, val) } } -#include <dev/ic/am7990.c> - -/** - ** XXX These could arguably go in dev/ic/am7990.c, or at least somewhere - ** sharable with other Lance drivers that need them. - **/ - -/* - * Routines for accessing the transmit and receive buffers. - * The various CPU and adapter configurations supported by this - * driver require three different access methods for buffers - * and descriptors: - * (1) contig (contiguous data; no padding), - * (2) gap2 (two bytes of data followed by two bytes of padding), - * (3) gap16 (16 bytes of data followed by 16 bytes of padding). - */ - -#ifdef LE_NEED_BUF_CONTIG -/* - * contig: contiguous data with no padding. - * - * Buffers may have any alignment. - */ - -/*integrate*/ void -copytobuf_contig(sc, from, boff, len) - struct le_softc *sc; - void *from; - int boff, len; -{ - volatile caddr_t buf = sc->sc_mem; - - /* - * Just call bcopy() to do the work. - */ - bcopy(from, buf + boff, len); -} - -/*integrate*/ void -copyfrombuf_contig(sc, to, boff, len) - struct le_softc *sc; - void *to; - int boff, len; -{ - volatile caddr_t buf = sc->sc_mem; - - /* - * Just call bcopy() to do the work. - */ - bcopy(buf + boff, to, len); -} - -/*integrate*/ void -zerobuf_contig(sc, boff, len) - struct le_softc *sc; - int boff, len; -{ - volatile caddr_t buf = sc->sc_mem; - - /* - * Just let bzero() do the work - */ - bzero(buf + boff, len); -} -#endif /* LE_NEED_BUF_CONTIG */ - -#ifdef LE_NEED_BUF_GAP2 -/* - * gap2: two bytes of data followed by two bytes of pad. - * - * Buffers must be 4-byte aligned. The code doesn't worry about - * doing an extra byte. - */ - -integrate void -copytobuf_gap2(sc, fromv, boff, len) - struct le_softc *sc; - void *fromv; - int boff; - register int len; -{ - volatile caddr_t buf = sc->sc_mem; - register caddr_t from = fromv; - register volatile u_int16_t *bptr; - register int xfer; - - if (boff & 0x1) { - /* handle unaligned first byte */ - bptr = ((volatile u_int16_t *)buf) + (boff - 1); - *bptr = (*from++ << 8) | (*bptr & 0xff); - bptr += 2; - len--; - } else - bptr = ((volatile u_int16_t *)buf) + boff; - while (len > 1) { - *bptr = (from[1] << 8) | (from[0] & 0xff); - bptr += 2; - from += 2; - len -= 2; - } - if (len == 1) - *bptr = (u_int16_t)*from; -} - -integrate void -copyfrombuf_gap2(sc, tov, boff, len) - struct le_softc *sc; - void *tov; - int boff, len; -{ - volatile caddr_t buf = sc->sc_mem; - register caddr_t to = tov; - register volatile u_int16_t *bptr; - register u_int16_t tmp; - register int xfer; - - if (boff & 0x1) { - /* handle unaligned first byte */ - bptr = ((volatile u_int16_t *)buf) + (boff - 1); - *to++ = (*bptr >> 8) & 0xff; - bptr += 2; - len--; - } else - bptr = ((volatile u_int16_t *)buf) + boff; - while (len > 1) { - tmp = *bptr; - *to++ = tmp & 0xff; - *to++ = (tmp >> 8) & 0xff; - bptr += 2; - len -= 2; - } - if (len == 1) - *to = *bptr & 0xff; -} - -integrate void -zerobuf_gap2(sc, boff, len) - struct le_softc *sc; - int boff, len; -{ - volatile caddr_t buf = sc->sc_mem; - register volatile u_int16_t *bptr; - - if ((unsigned)boff & 0x1) { - bptr = ((volatile u_int16_t *)buf) + (boff - 1); - *bptr &= 0xff; - bptr += 2; - len--; - } else - bptr = ((volatile u_int16_t *)buf) + boff; - while (len > 0) { - *bptr = 0; - bptr += 2; - len -= 2; - } -} -#endif /* LE_NEED_BUF_GAP2 */ - -#ifdef LE_NEED_BUF_GAP16 /* - * gap16: 16 bytes of data followed by 16 bytes of pad. - * - * Buffers must be 32-byte aligned. + * Routines for accessing the transmit and receive buffers are provided + * by am7990.c, because of the LE_NEED_BUF_* macros defined above. + * Unfortunately, CPU addressing of these buffers is done in one of + * 3 ways: + * - contiguous (for the 3max and turbochannel option card) + * - gap2, which means shorts (2 bytes) interspersed with short (2 byte) + * spaces (for the pmax) + * - gap16, which means 16bytes interspersed with 16byte spaces + * for buffers which must begin on a 32byte boundary (for 3min and maxine) + * The buffer offset is the logical byte offset, assuming contiguous storage. */ -integrate void -copytobuf_gap16(sc, fromv, boff, len) - struct le_softc *sc; - void *fromv; - int boff; - register int len; -{ - volatile caddr_t buf = sc->sc_mem; - register caddr_t from = fromv; - register caddr_t bptr; - register int xfer; - - bptr = buf + ((boff << 1) & ~0x1f); - boff &= 0xf; - xfer = min(len, 16 - boff); - while (len > 0) { - bcopy(from, bptr + boff, xfer); - from += xfer; - bptr += 32; - boff = 0; - len -= xfer; - xfer = min(len, 16); - } -} - -integrate void -copyfrombuf_gap16(sc, tov, boff, len) - struct le_softc *sc; - void *tov; - int boff, len; -{ - volatile caddr_t buf = sc->sc_mem; - register caddr_t to = tov; - register caddr_t bptr; - register int xfer; - - bptr = buf + ((boff << 1) & ~0x1f); - boff &= 0xf; - xfer = min(len, 16 - boff); - while (len > 0) { - bcopy(bptr + boff, to, xfer); - to += xfer; - bptr += 32; - boff = 0; - len -= xfer; - xfer = min(len, 16); - } -} - -integrate void -zerobuf_gap16(sc, boff, len) - struct le_softc *sc; - int boff, len; -{ - volatile caddr_t buf = sc->sc_mem; - register caddr_t bptr; - register int xfer; - - bptr = buf + ((boff << 1) & ~0x1f); - boff &= 0xf; - xfer = min(len, 16 - boff); - while (len > 0) { - bzero(bptr + boff, xfer); - bptr += 32; - boff = 0; - len -= xfer; - xfer = min(len, 16); - } -} -#endif /* LE_NEED_BUF_GAP16 */ +#include <dev/ic/am7990.c> diff --git a/sys/arch/sun3/conf/DISKLESS b/sys/arch/sun3/conf/DISKLESS index 15b24d9f074..60a2534f636 100644 --- a/sys/arch/sun3/conf/DISKLESS +++ b/sys/arch/sun3/conf/DISKLESS @@ -1,4 +1,4 @@ -# $NetBSD: DISKLESS,v 1.10.2.1 1995/11/18 07:15:46 gwr Exp $ +# $NetBSD: DISKLESS,v 1.11 1995/11/17 23:31:11 gwr Exp $ # # DISKLESS Sun3 (3/50, 3/60, 3/110, 3/160, 3/260) diff --git a/sys/arch/sun3/conf/GENERIC b/sys/arch/sun3/conf/GENERIC index 9c69d4f17f6..50f1585f22b 100644 --- a/sys/arch/sun3/conf/GENERIC +++ b/sys/arch/sun3/conf/GENERIC @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.24.2.1 1995/11/18 07:15:57 gwr Exp $ +# $NetBSD: GENERIC,v 1.25 1995/11/17 23:31:12 gwr Exp $ # # GENERIC Sun3 (3/50, 3/60, 3/110, 3/160, 3/260) diff --git a/sys/arch/sun3/conf/Makefile.sun3 b/sys/arch/sun3/conf/Makefile.sun3 index 7a1d907d841..ef93edd51da 100644 --- a/sys/arch/sun3/conf/Makefile.sun3 +++ b/sys/arch/sun3/conf/Makefile.sun3 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.sun3,v 1.34.2.1 1995/11/18 07:16:06 gwr Exp $ +# $NetBSD: Makefile.sun3,v 1.35 1995/11/17 23:31:14 gwr Exp $ # # Makefile for NetBSD diff --git a/sys/arch/sun3/conf/RAMDISK b/sys/arch/sun3/conf/RAMDISK index 162db395a3d..b6a0eb87049 100644 --- a/sys/arch/sun3/conf/RAMDISK +++ b/sys/arch/sun3/conf/RAMDISK @@ -1,4 +1,4 @@ -# $NetBSD: RAMDISK,v 1.1.2.1 1995/11/18 07:16:14 gwr Exp $ +# $NetBSD: RAMDISK,v 1.2 1995/11/17 23:31:15 gwr Exp $ # # RAMDISK: Root/swap on ramdisk diff --git a/sys/arch/sun3/conf/files.sun3 b/sys/arch/sun3/conf/files.sun3 index 56dc25b1976..c77b50a3f05 100644 --- a/sys/arch/sun3/conf/files.sun3 +++ b/sys/arch/sun3/conf/files.sun3 @@ -1,4 +1,4 @@ -# $NetBSD: files.sun3,v 1.13.2.1 1995/10/30 23:33:41 gwr Exp $ +# $NetBSD: files.sun3,v 1.15 1995/10/30 21:15:40 gwr Exp $ # # sun3-specific configuration info diff --git a/sys/arch/sun3/dev/bw2.c b/sys/arch/sun3/dev/bw2.c index 6dd639470aa..6825a694da5 100644 --- a/sys/arch/sun3/dev/bw2.c +++ b/sys/arch/sun3/dev/bw2.c @@ -1,4 +1,4 @@ -/* $NetBSD: bw2.c,v 1.4.2.1 1995/11/10 22:12:54 gwr Exp $ */ +/* $NetBSD: bw2.c,v 1.5 1995/11/10 21:59:30 gwr Exp $ */ /* * Copyright (c) 1992, 1993 diff --git a/sys/arch/sun3/dev/if_le.c b/sys/arch/sun3/dev/if_le.c index 721b81dc605..7ce0b32d43a 100644 --- a/sys/arch/sun3/dev/if_le.c +++ b/sys/arch/sun3/dev/if_le.c @@ -1,1031 +1,154 @@ -/* $NetBSD: if_le.c,v 1.22.2.1 1995/10/27 18:43:36 gwr Exp $ */ +/* $NetBSD: if_le.c,v 1.24 1995/12/10 08:46:05 mycroft Exp $ */ -/* - * LANCE Ethernet driver +/*- + * Copyright (c) 1995 Charles M. Hannum. All rights reserved. + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. * - * Copyright (c) 1995 Gordon W. Ross - * Copyright (c) 1994 Charles Hannum. + * This code is derived from software contributed to Berkeley by + * Ralph Campbell and Rick Macklem. * - * Copyright (C) 1993, Paul Richards. This software may be used, modified, - * copied, distributed, and sold, in both source and binary form provided - * that the above copyright and these terms are retained. Under no - * circumstances is the author responsible for the proper functioning - * of this software, nor does the author assume any responsibility - * for damages incurred with its use. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)if_le.c 8.2 (Berkeley) 11/16/93 */ #include "bpfilter.h" #include <sys/param.h> #include <sys/systm.h> -#include <sys/errno.h> -#include <sys/ioctl.h> #include <sys/mbuf.h> -#include <sys/socket.h> #include <sys/syslog.h> +#include <sys/socket.h> #include <sys/device.h> #include <net/if.h> -#include <net/if_dl.h> -#include <net/if_types.h> -#include <net/netisr.h> #ifdef INET #include <netinet/in.h> -#include <netinet/in_systm.h> -#include <netinet/in_var.h> -#include <netinet/ip.h> #include <netinet/if_ether.h> #endif -#ifdef NS -#include <netns/ns.h> -#include <netns/ns_if.h> -#endif - -#if NBPFILTER > 0 -#include <net/bpf.h> -#include <net/bpfdesc.h> -#endif - #include <machine/autoconf.h> #include <machine/cpu.h> +#include <machine/dvma.h> +#include <machine/isr.h> +#include <machine/obio.h> +#include <machine/idprom.h> -/* - * XXX - Be warned: Most Sun3/50 and many Sun3/60 machines have - * the LANCE Rev. C bug, which we MUST avoid or suffer likely - * NFS file corruption and worse! That said, if you are SURE - * your LANCE is OK, you can remove this work-around using: - * options LANCE_REVC_BUG=0 - * in your kernel config file. - */ -#ifndef LANCE_REVC_BUG -#define LANCE_REVC_BUG 1 -#endif - -/* #define LEDEBUG 1 */ - -#include "if_lereg.h" -#include "if_le.h" -#include "if_le_subr.h" +#include <sun3/dev/if_lereg.h> +#include <sun3/dev/if_levar.h> +#include <dev/ic/am7990reg.h> +#define LE_NEED_BUF_CONTIG +#include <dev/ic/am7990var.h> -#define RMD_BITS "\20\20own\17err\16fram\15oflo\14crc\13rbuf\12stp\11enp" +#define LE_SOFTC(unit) lecd.cd_devs[unit] +#define LE_DELAY(x) DELAY(x) -#define ETHER_MIN_LEN 64 -#define ETHER_MAX_LEN 1518 - -/* - * The lance has only 24 address lines. When it accesses memory, - * the high address lines are hard-wired to 0xFF, so we must: - * (1) put what we want the LANCE to see above 0xFF000000, and - * (2) mask our CPU addresses down to 24 bits for the LANCE. - */ -#define LANCE_ADDR(sc,x) ((u_int)(x) & 0xFFffff) - -#ifdef PACKETSTATS -long lexpacketsizes[LEMTU+1]; -long lerpacketsizes[LEMTU+1]; -#endif - -/* autoconfiguration driver */ -void le_attach(struct device *, struct device *, void *); +int lematch __P((struct device *, void *, void *)); +void leattach __P((struct device *, struct device *, void *)); +int leintr __P((void *)); struct cfdriver lecd = { - NULL, "le", le_md_match, le_attach, - DV_IFNET, sizeof(struct le_softc), + NULL, "le", lematch, leattach, DV_IFNET, sizeof(struct le_softc) }; -int leioctl __P((struct ifnet *, u_long, caddr_t)); -void lestart __P((struct ifnet *)); -void lewatchdog __P((/* short */)); -static inline void lewrcsr __P((/* struct le_softc *, u_short, u_short */)); -static inline u_short lerdcsr __P((/* struct le_softc *, u_short */)); -void leinit __P((struct le_softc *)); -void lememinit __P((struct le_softc *)); -void lereset __P((struct le_softc *)); -void lestop __P((struct le_softc *)); -void letint __P((struct le_softc *)); -void lerint __P((struct le_softc *)); -void leread __P((struct le_softc *, u_char *, int)); -struct mbuf *leget __P((u_char *, int, struct ifnet *)); -void lesetladrf __P((struct arpcom *, u_long *)); -#ifdef LEDEBUG -void recv_print __P((struct le_softc *, int)); -void xmit_print __P((struct le_softc *, int)); -#endif - -/* - * Inline routines to read and write the LANCE registers. - */ - -static inline void -lewrcsr(sc, regnum, value) +integrate void +lewrcsr(sc, port, val) struct le_softc *sc; - u_short regnum; - u_short value; + u_int16_t port, val; { - volatile struct le_regs *regs = sc->sc_regs; + register struct lereg1 *ler1 = sc->sc_r1; - regs->lereg_addr = regnum; - regs->lereg_data = value; + ler1->ler1_rap = port; + ler1->ler1_rdp = val; } -static inline u_short -lerdcsr(sc, regnum) +integrate u_int16_t +lerdcsr(sc, port) struct le_softc *sc; - u_short regnum; + u_int16_t port; { - volatile struct le_regs *regs = sc->sc_regs; - u_short value; + register struct lereg1 *ler1 = sc->sc_r1; + u_int16_t val; - regs->lereg_addr = regnum; - value = regs->lereg_data; - - return (value); + ler1->ler1_rap = port; + val = ler1->ler1_rdp; + return (val); } -/* - * The probe is done in if_le_subr.c:if_md_match() - */ - -/* - * Interface exists: make available by filling in network interface - * record. System will initialize the interface when it is ready - * to accept packets. We get the ethernet address here. - */ -void -le_attach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct le_softc *sc = (void *)self; - struct confargs *ca = aux; - struct ifnet *ifp = &sc->sc_if; - int pri; - u_int a; - - le_md_attach(parent, self, aux); - printf(" hwaddr %s\n", ether_sprintf(sc->sc_enaddr)); - - /* - * Initialize and attach S/W interface - */ - ifp->if_unit = sc->sc_dev.dv_unit; - ifp->if_name = lecd.cd_name; - ifp->if_start = lestart; - ifp->if_ioctl = leioctl; - ifp->if_watchdog = lewatchdog; - ifp->if_flags = - IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS; - -#if LANCE_REVC_BUG == 0 - /* The work-around precludes multicast... */ - ifp->if_flags |= IFF_MULTICAST; -#endif - - /* Attach the interface. */ - if_attach(ifp); - ether_ifattach(ifp); - -#if NBPFILTER > 0 - bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header)); -#endif -} - -void -lereset(sc) - struct le_softc *sc; -{ - - leinit(sc); -} - -void -lewatchdog(unit) - short unit; -{ - struct le_softc *sc = lecd.cd_devs[unit]; - - log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname); - ++sc->sc_if.if_oerrors; - lereset(sc); -} - -/* LANCE initialization block set up. */ -void -lememinit(sc) - register struct le_softc *sc; -{ - struct ifnet *ifp = &sc->sc_if; - int i; - void *mem; - u_long a; - - /* - * At this point we assume that the memory allocated to the Lance is - * quadword aligned. If it isn't then the initialisation is going - * fail later on. - */ - mem = sc->sc_mem; - - sc->sc_init = mem; -#if NBPFILTER > 0 - if (ifp->if_flags & IFF_PROMISC) - sc->sc_init->mode = LE_NORMAL | LE_PROM; - else -#endif - sc->sc_init->mode = LE_NORMAL; - - /* Set the Ethernet address (have to byte-swap) */ - for (i = 0; i < 6; i += 2) { - sc->sc_init->padr[i] = sc->sc_enaddr[i+1]; - sc->sc_init->padr[i+1] = sc->sc_enaddr[i]; - } - lesetladrf(&sc->sc_ac, sc->sc_init->ladrf); - mem += sizeof(struct init_block); - - sc->sc_rd = mem; - a = LANCE_ADDR(sc, mem); - sc->sc_init->rdra = a; - sc->sc_init->rlen = ((a >> 16) & 0xff) | (RLEN << 13); - mem += NRBUF * sizeof(struct mds); - - sc->sc_td = mem; - a = LANCE_ADDR(sc, mem); - sc->sc_init->tdra = a; - sc->sc_init->tlen = ((a >> 16) & 0xff) | (TLEN << 13); - mem += NTBUF * sizeof(struct mds); - - /* - * Set up receive ring descriptors. - */ - sc->sc_rbuf = mem; - for (i = 0; i < NRBUF; i++) { - a = LANCE_ADDR(sc, mem); - sc->sc_rd[i].addr = a; - sc->sc_rd[i].flags = ((a >> 16) & 0xff) | LE_OWN; - sc->sc_rd[i].bcnt = -BUFSIZE; - sc->sc_rd[i].mcnt = 0; - mem += BUFSIZE; - } - - /* - * Set up transmit ring descriptors. - */ - sc->sc_tbuf = mem; - for (i = 0; i < NTBUF; i++) { - a = LANCE_ADDR(sc, mem); - sc->sc_td[i].addr = a; - sc->sc_td[i].flags= ((a >> 16) & 0xff); - sc->sc_td[i].bcnt = 0xf000; - sc->sc_td[i].mcnt = 0; - mem += BUFSIZE; - } - -#ifdef DIAGNOSTIC - if (mem > (sc->sc_mem + MEMSIZE)) - panic("lememinit: used 0x%x\n", mem - sc->sc_mem); -#endif -} - -void -lestop(sc) - struct le_softc *sc; -{ - - lewrcsr(sc, 0, LE_STOP); -} - -/* - * Initialization of interface; set up initialization block - * and transmit/receive descriptor rings. - */ -void -leinit(sc) - register struct le_softc *sc; -{ - struct ifnet *ifp = &sc->sc_if; - int s; - register int timo; - u_long a; - - s = splimp(); - - /* Don't want to get in a weird state. */ - lewrcsr(sc, 0, LE_STOP); - delay(100); - - sc->sc_last_rd = sc->sc_last_td = sc->sc_no_td = 0; - - /* Set up LANCE init block. */ - lememinit(sc); - - /* Set byte swapping etc. */ - lewrcsr(sc, 3, LE_CONF3); - - /* Give LANCE the physical address of its init block. */ - a = LANCE_ADDR(sc, sc->sc_init); - lewrcsr(sc, 1, a); - lewrcsr(sc, 2, (a >> 16) & 0xff); - - /* Try to initialize the LANCE. */ - delay(100); - lewrcsr(sc, 0, LE_INIT); - - /* Wait for initialization to finish. */ - for (timo = 1000; timo; timo--) - if (lerdcsr(sc, 0) & LE_IDON) - break; - - if (lerdcsr(sc, 0) & LE_IDON) { - /* Start the LANCE. */ - lewrcsr(sc, 0, LE_INEA | LE_STRT | LE_IDON); - ifp->if_flags |= IFF_RUNNING; - ifp->if_flags &= ~IFF_OACTIVE; - lestart(ifp); - } else - printf("%s: card failed to initialize\n", sc->sc_dev.dv_xname); - - (void) splx(s); -} - -/* - * Controller interrupt. - */ int -leintr(vsc) - void *vsc; -{ - register struct le_softc *sc = vsc; - register u_short isr; - - isr = lerdcsr(sc, 0); -#ifdef LEDEBUG - if (sc->sc_debug) - printf("%s: leintr entering with isr=%04x\n", - sc->sc_dev.dv_xname, isr); -#endif - if ((isr & LE_INTR) == 0) - return 0; - - do { - lewrcsr(sc, 0, - isr & (LE_INEA | LE_BABL | LE_MISS | LE_MERR | - LE_RINT | LE_TINT | LE_IDON)); - if (isr & (LE_BABL | LE_CERR | LE_MISS | LE_MERR)) { - if (isr & LE_BABL) { - printf("%s: babble\n", sc->sc_dev.dv_xname); - sc->sc_if.if_oerrors++; - } -#if 0 - if (isr & LE_CERR) { - printf("%s: collision error\n", sc->sc_dev.dv_xname); - sc->sc_if.if_collisions++; - } -#endif - if (isr & LE_MISS) { -#if 0 - printf("%s: missed packet\n", sc->sc_dev.dv_xname); -#endif - sc->sc_if.if_ierrors++; - } - if (isr & LE_MERR) { - printf("%s: memory error\n", sc->sc_dev.dv_xname); - lereset(sc); - goto out; - } - } - - if ((isr & LE_RXON) == 0) { - printf("%s: receiver disabled\n", sc->sc_dev.dv_xname); - sc->sc_if.if_ierrors++; - lereset(sc); - goto out; - } - if ((isr & LE_TXON) == 0) { - printf("%s: transmitter disabled\n", sc->sc_dev.dv_xname); - sc->sc_if.if_oerrors++; - lereset(sc); - goto out; - } - - if (isr & LE_RINT) { - /* Reset watchdog timer. */ - sc->sc_if.if_timer = 0; - lerint(sc); - } - if (isr & LE_TINT) { - /* Reset watchdog timer. */ - sc->sc_if.if_timer = 0; - letint(sc); - } - - isr = lerdcsr(sc, 0); - } while ((isr & LE_INTR) != 0); - -#ifdef LEDEBUG - if (sc->sc_debug) - printf("%s: leintr returning with isr=%04x\n", - sc->sc_dev.dv_xname, isr); -#endif - -out: - return 1; -} - -#define NEXTTDS \ - if (++tmd == NTBUF) tmd=0, cdm=sc->sc_td; else ++cdm - -/* - * Setup output on interface. - * Get another datagram to send off of the interface queue, and map it to the - * interface before starting the output. - * Called only at splimp or interrupt level. - */ -void -lestart(ifp) - struct ifnet *ifp; -{ - register struct le_softc *sc = lecd.cd_devs[ifp->if_unit]; - register int tmd; - volatile struct mds *cdm; - struct mbuf *m0, *m; - u_char *buffer; - int len; - - if ((sc->sc_if.if_flags & (IFF_RUNNING | IFF_OACTIVE)) != - IFF_RUNNING) - return; - - tmd = sc->sc_last_td; - cdm = &sc->sc_td[tmd]; - - for (;;) { - if (sc->sc_no_td >= NTBUF) { - sc->sc_if.if_flags |= IFF_OACTIVE; -#ifdef LEDEBUG - if (sc->sc_debug) - printf("no_td = %d, last_td = %d\n", sc->sc_no_td, - sc->sc_last_td); -#endif - break; - } - -#ifdef LEDEBUG - if (cdm->flags & LE_OWN) { - sc->sc_if.if_flags |= IFF_OACTIVE; - printf("missing buffer, no_td = %d, last_td = %d\n", - sc->sc_no_td, sc->sc_last_td); - } -#endif - - IF_DEQUEUE(&sc->sc_if.if_snd, m); - if (!m) - break; - - ++sc->sc_no_td; - - /* - * Copy the mbuf chain into the transmit buffer. - */ - buffer = sc->sc_tbuf + (BUFSIZE * sc->sc_last_td); - len = 0; - for (m0 = m; m; m = m->m_next) { - bcopy(mtod(m, caddr_t), buffer, m->m_len); - buffer += m->m_len; - len += m->m_len; - } - -#ifdef LEDEBUG - if (len > ETHER_MAX_LEN) - printf("packet length %d\n", len); -#endif - -#if NBPFILTER > 0 - if (sc->sc_if.if_bpf) - bpf_mtap(sc->sc_if.if_bpf, m0); -#endif - - m_freem(m0); - len = max(len, ETHER_MIN_LEN); - - /* - * Init transmit registers, and set transmit start flag. - */ - cdm->bcnt = -len; - cdm->mcnt = 0; - cdm->flags |= LE_OWN | LE_STP | LE_ENP; - -#ifdef LEDEBUG - if (sc->sc_debug) - xmit_print(sc, sc->sc_last_td); -#endif - - lewrcsr(sc, 0, LE_INEA | LE_TDMD); - - NEXTTDS; - } - - sc->sc_last_td = tmd; -} - -void -letint(sc) - struct le_softc *sc; -{ - register int tmd = (sc->sc_last_td - sc->sc_no_td + NTBUF) % NTBUF; - volatile struct mds *cdm; - - cdm = &sc->sc_td[tmd]; - if (cdm->flags & LE_OWN) { - /* Race condition with loop below. */ -#ifdef LEDEBUG - if (sc->sc_debug) - printf("%s: extra tint\n", sc->sc_dev.dv_xname); -#endif - return; - } - - sc->sc_if.if_flags &= ~IFF_OACTIVE; - - do { - if (sc->sc_no_td <= 0) - break; -#ifdef LEDEBUG - if (sc->sc_debug) - printf("trans cdm = %x\n", cdm); -#endif - sc->sc_if.if_opackets++; - --sc->sc_no_td; - if (cdm->mcnt & (LE_TBUFF | LE_UFLO | LE_LCOL | LE_LCAR | LE_RTRY)) { - if (cdm->mcnt & LE_TBUFF) - printf("%s: transmit buffer error\n", sc->sc_dev.dv_xname); - if ((cdm->mcnt & (LE_TBUFF | LE_UFLO)) == LE_UFLO) - printf("%s: underflow\n", sc->sc_dev.dv_xname); - if (cdm->mcnt & LE_UFLO) { - lereset(sc); - return; - } -#if 0 - if (cdm->mcnt & LE_LCOL) { - printf("%s: late collision\n", sc->sc_dev.dv_xname); - sc->sc_if.if_collisions++; - } - if (cdm->mcnt & LE_LCAR) - printf("%s: lost carrier\n", sc->sc_dev.dv_xname); - if (cdm->mcnt & LE_RTRY) { - printf("%s: excessive collisions, tdr %d\n", - sc->sc_dev.dv_xname, cdm->flags & 0x1ff); - sc->sc_if.if_collisions += 16; - } -#endif - } else if (cdm->flags & LE_ONE) - sc->sc_if.if_collisions++; - else if (cdm->flags & LE_MORE) - /* Real number is unknown. */ - sc->sc_if.if_collisions += 2; - NEXTTDS; - } while ((cdm->flags & LE_OWN) == 0); - - lestart(&sc->sc_if); -} - -#define NEXTRDS \ - if (++rmd == NRBUF) rmd=0, cdm=sc->sc_rd; else ++cdm - -/* only called from one place, so may as well integrate */ -void -lerint(sc) - struct le_softc *sc; +lematch(parent, match, aux) + struct device *parent; + void *match, *aux; { - register int rmd = sc->sc_last_rd; - volatile struct mds *cdm; - - cdm = &sc->sc_rd[rmd]; - if (cdm->flags & LE_OWN) { - /* Race condition with loop below. */ -#ifdef LEDEBUG - if (sc->sc_debug) - printf("%s: extra rint\n", sc->sc_dev.dv_xname); -#endif - return; - } - - /* Process all buffers with valid data. */ - do { - if (cdm->flags & LE_ERR) { -#ifdef LEDEBUG - /* - * XXX - These happen a LOT on the Sun3/50 so - * it is really NOT appropriate to print them. - */ - printf("%s: error, cdm->flags=%b\n", - sc->sc_dev.dv_xname, cdm->flags, RMD_BITS); -#endif - sc->sc_if.if_ierrors++; - } else if (cdm->flags & (LE_STP | LE_ENP) != (LE_STP | LE_ENP)) { - do { - cdm->mcnt = 0; - cdm->flags |= LE_OWN; - NEXTRDS; - } while ((cdm->flags & (LE_OWN | LE_ERR | LE_STP | LE_ENP)) == 0); - sc->sc_last_rd = rmd; - printf("%s: chained buffer\n", sc->sc_dev.dv_xname); - if ((cdm->flags & (LE_OWN | LE_ERR | LE_STP | LE_ENP)) != LE_ENP) { - lereset(sc); - return; - } - } else { -#ifdef LEDEBUG - if (sc->sc_debug) - recv_print(sc, sc->sc_last_rd); -#endif - leread(sc, sc->sc_rbuf + (BUFSIZE * rmd), - (int)cdm->mcnt); - } + struct confargs *ca = aux; + int x; - cdm->bcnt = -BUFSIZE; - cdm->mcnt = 0; - cdm->flags |= LE_OWN; - NEXTRDS; -#ifdef LEDEBUG - if (sc->sc_debug) - printf("sc->sc_last_rd = %x, cdm = %x\n", - sc->sc_last_rd, cdm); -#endif - } while ((cdm->flags & LE_OWN) == 0); + if (ca->ca_paddr == -1) + ca->ca_paddr = OBIO_AMD_ETHER; + if (ca->ca_intpri == -1) + ca->ca_intpri = 3; - sc->sc_last_rd = rmd; + /* The peek returns -1 on bus error. */ + x = bus_peek(ca->ca_bustype, ca->ca_paddr, 1); + return (x != -1); } -/* - * Pass a packet to the higher levels. - */ void -leread(sc, buf, len) - register struct le_softc *sc; - u_char *buf; - int len; -{ - struct ifnet *ifp; - struct mbuf *m; - struct ether_header *eh; - - ifp = &sc->sc_if; - - if ((len < ETHERMIN) || (len > ETHER_MAX_LEN)) { - log(LOG_ERR, "%s: invalid packet size %d; dropping\n", - sc->sc_dev.dv_xname, len); - ifp->if_ierrors++; - return; - } - - /* Pull packet off interface. */ - m = leget(buf, len, ifp); - if (m == 0) { - ifp->if_ierrors++; - return; - } - - ifp->if_ipackets++; - - /* We assume that the header fit entirely in one mbuf. */ - eh = mtod(m, struct ether_header *); - -#if NBPFILTER > 0 - /* - * Check if there's a BPF listener on this interface. - * If so, hand off the raw packet to BPF. - */ - if (ifp->if_bpf) { - /* Note that BPF may see garbage! (if LANCE_REVC_BUG) */ - bpf_mtap(ifp->if_bpf, m); - } -#endif /* NBPFILTER */ - -#if LANCE_REVC_BUG - /* - * Check for unreported packet errors. Rev C of the LANCE chip - * has a bug which can cause "random" bytes to be prepended to - * the start of the packet. The work-around is to make sure that - * the Ethernet destination address in the packet matches our - * address (or the broadcast address). Must ALWAYS check! - */ - if (bcmp(eh->ether_dhost, sc->sc_enaddr, 6) && - bcmp(eh->ether_dhost, etherbroadcastaddr, 6)) - { - /* Not for us. */ - m_freem(m); - return; - } -#else /* LANCE_REVC_BUG */ -#if NBPFILTER > 0 - if (ifp->if_bpf) { - /* - * Note that the interface cannot be in promiscuous mode if - * there are no BPF listeners. And if we are in promiscuous - * mode, we have to check if this packet is really ours. - */ - if ((ifp->if_flags & IFF_PROMISC) && - (eh->ether_dhost[0] & 1) == 0 && /* !mcast and !bcast */ - bcmp(eh->ether_dhost, sc->sc_enaddr, 6) != 0) - { - m_freem(m); - return; - } - } -#endif /* NBPFILTER */ -#endif /* LANCE_REVC_BUG */ - - /* Pass the packet up, with the ether header sort-of removed. */ - m_adj(m, sizeof(struct ether_header)); - ether_input(ifp, eh, m); -} - -/* - * Supporting routines - */ - -/* - * Pull data off an interface. - * Len is length of data, with local net header stripped. - * We copy the data into mbufs. When full cluster sized units are present - * we copy into clusters. - */ -struct mbuf * -leget(buf, totlen, ifp) - u_char *buf; - int totlen; - struct ifnet *ifp; -{ - struct mbuf *top, **mp, *m; - int len; - - MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m == 0) - return 0; - m->m_pkthdr.rcvif = ifp; - m->m_pkthdr.len = totlen; - len = MHLEN; - top = 0; - mp = ⊤ - - while (totlen > 0) { - if (top) { - MGET(m, M_DONTWAIT, MT_DATA); - if (m == 0) { - m_freem(top); - return 0; - } - len = MLEN; - } - if (totlen >= MINCLSIZE) { - MCLGET(m, M_DONTWAIT); - if (m->m_flags & M_EXT) - len = MCLBYTES; - } - m->m_len = len = min(totlen, len); - bcopy((caddr_t)buf, mtod(m, caddr_t), len); - buf += len; - totlen -= len; - *mp = m; - mp = &m->m_next; - } - - return top; -} - -/* - * Process an ioctl request. - */ -int -leioctl(ifp, cmd, data) - register struct ifnet *ifp; - u_long cmd; - caddr_t data; +leattach(parent, self, aux) + struct device *parent, *self; + void *aux; { - struct le_softc *sc = lecd.cd_devs[ifp->if_unit]; - struct ifaddr *ifa = (struct ifaddr *)data; - struct ifreq *ifr = (struct ifreq *)data; - int s, error = 0; - - s = splimp(); - - switch (cmd) { - - case SIOCSIFADDR: - ifp->if_flags |= IFF_UP; - - switch (ifa->ifa_addr->sa_family) { -#ifdef INET - case AF_INET: - leinit(sc); - arp_ifinit(&sc->sc_ac, ifa); - break; -#endif -#ifdef NS - /* XXX - This code is probably wrong. */ - case AF_NS: - { - register struct ns_addr *ina = &IA_SNS(ifa)->sns_addr; - - if (ns_nullhost(*ina)) - ina->x_host = - *(union ns_host *)(sc->sc_enaddr); - else - bcopy(ina->x_host.c_host, - sc->sc_enaddr, - sizeof(sc->sc_enaddr)); - /* Set new address. */ - leinit(sc); - break; - } -#endif - default: - leinit(sc); - break; - } - break; + struct le_softc *sc = (void *)self; + struct confargs *ca = aux; - case SIOCSIFFLAGS: - /* - * If interface is marked down and it is running, then stop it - */ - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { - /* - * If interface is marked down and it is running, then - * stop it. - */ - lestop(sc); - ifp->if_flags &= ~IFF_RUNNING; - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { - /* - * If interface is marked up and it is stopped, then - * start it. - */ - leinit(sc); - } else { - /* - * Reset the interface to pick up changes in any other - * flags that affect hardware registers. - */ - /*lestop(sc);*/ - leinit(sc); - } -#ifdef LEDEBUG - if (ifp->if_flags & IFF_DEBUG) - sc->sc_debug = 1; - else - sc->sc_debug = 0; -#endif - break; + sc->sc_r1 = (struct lereg1 *) + obio_alloc(ca->ca_paddr, OBIO_AMD_ETHER_SIZE); + sc->sc_mem = dvma_malloc(MEMSIZE); + sc->sc_conf3 = LE_C3_BSWP; + sc->sc_addr = (u_long)sc->sc_mem & 0xffffff; + sc->sc_memsize = MEMSIZE; - case SIOCADDMULTI: - case SIOCDELMULTI: - error = (cmd == SIOCADDMULTI) ? - ether_addmulti(ifr, &sc->sc_ac): - ether_delmulti(ifr, &sc->sc_ac); + idprom_etheraddr(sc->sc_arpcom.ac_enaddr); - if (error == ENETRESET) { - /* - * Multicast list has changed; set the hardware filter - * accordingly. - */ - leinit(sc); - error = 0; - } - break; + sc->sc_copytodesc = copytobuf_contig; + sc->sc_copyfromdesc = copyfrombuf_contig; + sc->sc_copytobuf = copytobuf_contig; + sc->sc_copyfrombuf = copyfrombuf_contig; + sc->sc_zerobuf = zerobuf_contig; - default: - error = EINVAL; - } - (void) splx(s); - return error; -} + sc->sc_arpcom.ac_if.if_name = lecd.cd_name; + leconfig(sc); -#ifdef LEDEBUG -void -recv_print(sc, no) - struct le_softc *sc; - int no; -{ - struct mds *rmd; - int i, printed = 0; - u_short len; - - rmd = &sc->sc_rd[no]; - len = rmd->mcnt; - printf("%s: receive buffer %d, len = %d\n", sc->sc_dev.dv_xname, no, - len); - printf("%s: status %x\n", sc->sc_dev.dv_xname, lerdcsr(sc, 0)); - for (i = 0; i < len; i++) { - if (!printed) { - printed = 1; - printf("%s: data: ", sc->sc_dev.dv_xname); - } - printf("%x ", *(sc->sc_rbuf + (BUFSIZE*no) + i)); - } - if (printed) - printf("\n"); -} - -void -xmit_print(sc, no) - struct le_softc *sc; - int no; -{ - struct mds *rmd; - int i, printed=0; - u_short len; - - rmd = &sc->sc_td[no]; - len = -rmd->bcnt; - printf("%s: transmit buffer %d, len = %d\n", sc->sc_dev.dv_xname, no, - len); - printf("%s: status %x\n", sc->sc_dev.dv_xname, lerdcsr(sc, 0)); - printf("%s: addr %x, flags %x, bcnt %x, mcnt %x\n", - sc->sc_dev.dv_xname, rmd->addr, rmd->flags, rmd->bcnt, rmd->mcnt); - for (i = 0; i < len; i++) { - if (!printed) { - printed = 1; - printf("%s: data: ", sc->sc_dev.dv_xname); - } - printf("%x ", *(sc->sc_tbuf + (BUFSIZE*no) + i)); - } - if (printed) - printf("\n"); + /* Install interrupt handler. */ + isr_add_autovect(leintr, (void *)sc, ca->ca_intpri); } -#endif /* LEDEBUG */ - -/* - * Set up the logical address filter. - */ -void -lesetladrf(ac, af) - struct arpcom *ac; - u_long *af; -{ - struct ifnet *ifp = &ac->ac_if; - struct ether_multi *enm; - register u_char *cp, c; - register u_long crc; - register int i, len; - struct ether_multistep step; - /* - * Set up multicast address filter by passing all multicast addresses - * through a crc generator, and then using the high order 6 bits as an - * index into the 64 bit logical address filter. The high order bit - * selects the word, while the rest of the bits select the bit within - * the word. - */ - - if (ifp->if_flags & IFF_PROMISC) { - ifp->if_flags |= IFF_ALLMULTI; - af[0] = af[1] = 0xffffffff; - return; - } - - af[0] = af[1] = 0; - ETHER_FIRST_MULTI(step, ac, enm); - while (enm != NULL) { - if (bcmp(enm->enm_addrlo, enm->enm_addrhi, - sizeof(enm->enm_addrlo)) != 0) { - /* - * We must listen to a range of multicast addresses. - * For now, just accept all multicasts, rather than - * trying to set only those filter bits needed to match - * the range. (At this time, the only use of address - * ranges is for IP multicast routing, for which the - * range is big enough to require all bits set.) - */ - ifp->if_flags |= IFF_ALLMULTI; - af[0] = af[1] = 0xffffffff; - return; - } - - cp = enm->enm_addrlo; - crc = 0xffffffff; - for (len = sizeof(enm->enm_addrlo); --len >= 0;) { - c = *cp++; - for (i = 8; --i >= 0;) { - if ((crc & 0x01) ^ (c & 0x01)) { - crc >>= 1; - crc ^= 0x6db88320 | 0x80000000; - } else - crc >>= 1; - c >>= 1; - } - } - /* Just want the 6 most significant bits. */ - crc >>= 26; - - /* Turn on the corresponding bit in the filter. */ - af[crc >> 5] |= 1 << ((crc & 0x1f) ^ 0); - - ETHER_NEXT_MULTI(step, enm); - } - ifp->if_flags &= ~IFF_ALLMULTI; -} +#include <dev/ic/am7990.c> diff --git a/sys/arch/sun3/dev/if_lereg.h b/sys/arch/sun3/dev/if_lereg.h index 5d51af3098c..07580beed4c 100644 --- a/sys/arch/sun3/dev/if_lereg.h +++ b/sys/arch/sun3/dev/if_lereg.h @@ -1,127 +1,46 @@ -/* $NetBSD: if_lereg.h,v 1.10 1995/01/24 05:50:52 gwr Exp $ */ +/* $NetBSD: if_lereg.h,v 1.11 1995/12/10 08:46:07 mycroft Exp $ */ /* - * LANCE Ethernet driver header file + * Copyright (c) 1982, 1990 The Regents of the University of California. + * All rights reserved. * - * Copyright (c) 1995 Gordon W. Ross - * Copyright (c) 1994 Charles Hannum. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * Copyright (C) 1993, Paul Richards. This software may be used, modified, - * copied, distributed, and sold, in both source and binary form provided - * that the above copyright and these terms are retained. Under no - * circumstances is the author responsible for the proper functioning - * of this software, nor does the author assume any responsibility - * for damages incurred with its use. + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)if_lereg.h 7.1 (Berkeley) 5/8/90 */ -/* Declarations specific to this driver */ -#define NTBUF 2 -#define TLEN 1 -#define NRBUF 8 -#define RLEN 3 -#define BUFSIZE 1536 - #define MEMSIZE 0x4000 -/* Local Area Network Controller for Ethernet (LANCE) registers */ -struct le_regs { - u_short lereg_data; /* data port */ - u_short lereg_addr; /* address port */ -}; - -/* - * Control and status bits - */ -#define LE_SERR 0x8000 -#define LE_BABL 0x4000 -#define LE_CERR 0x2000 -#define LE_MISS 0x1000 -#define LE_MERR 0x0800 -#define LE_RINT 0x0400 -#define LE_TINT 0x0200 -#define LE_IDON 0x0100 -#define LE_INTR 0x0080 -#define LE_INEA 0x0040 -#define LE_RXON 0x0020 -#define LE_TXON 0x0010 -#define LE_TDMD 0x0008 -#define LE_STOP 0x0004 -#define LE_STRT 0x0002 -#define LE_INIT 0x0001 - -#define LE_BSWP 0x0004 -#define LE_ACON 0x0002 -#define LE_BCON 0x0001 - -/* - * LANCE initialization block - */ -struct init_block { - u_short mode; /* mode register */ - u_char padr[6]; /* ethernet address */ - u_long ladrf[2]; /* logical address filter (multicast) */ - u_short rdra; /* low order pointer to receive ring */ - u_short rlen; /* high order pointer and no. rings */ - u_short tdra; /* low order pointer to transmit ring */ - u_short tlen; /* high order pointer and no rings */ -}; - -/* - * Mode bits -- init_block - */ -#define LE_PROM 0x8000 /* promiscuous */ -#define LE_INTL 0x0040 /* internal loopback */ -#define LE_DRTY 0x0020 /* disable retry */ -#define LE_COLL 0x0010 /* force collision */ -#define LE_DTCR 0x0008 /* disable transmit crc */ -#define LE_LOOP 0x0004 /* loopback */ -#define LE_DTX 0x0002 /* disable transmitter */ -#define LE_DRX 0x0001 /* disable receiver */ -#define LE_NORMAL 0x0000 - /* - * Message descriptor + * LANCE registers. */ -struct mds { - u_short addr; - u_short flags; - u_short bcnt; - u_short mcnt; +struct lereg1 { + volatile u_int16_t ler1_rdp; /* data port */ + volatile u_int16_t ler1_rap; /* register select port */ }; - -/* Message descriptor flags */ -#define LE_OWN 0x8000 /* owner bit, 0=host, 1=LANCE */ -#define LE_ERR 0x4000 /* error */ -#define LE_STP 0x0200 /* start of packet */ -#define LE_ENP 0x0100 /* end of packet */ - -/* Receive ring status flags */ -#define LE_FRAM 0x2000 /* framing error error */ -#define LE_OFLO 0x1000 /* silo overflow */ -#define LE_CRC 0x0800 /* CRC error */ -#define LE_RBUFF 0x0400 /* buffer error */ - -/* Transmit ring status flags */ -#define LE_MORE 0x1000 /* more than 1 retry */ -#define LE_ONE 0x0800 /* one retry */ -#define LE_DEF 0x0400 /* deferred transmit */ - -/* Transmit errors */ -#define LE_TBUFF 0x8000 /* buffer error */ -#define LE_UFLO 0x4000 /* silo underflow */ -#define LE_LCOL 0x1000 /* late collision */ -#define LE_LCAR 0x0800 /* loss of carrier */ -#define LE_RTRY 0x0400 /* tried 16 times */ - - -/* DEPCA-specific definitions */ -#define DEPCA_CSR 0x0 -#define DEPCA_CSR_SHE 0x80 /* Shared memory enabled */ -#define DEPCA_CSR_SWAP32 0x40 /* Byte swapped */ -#define DEPCA_CSR_DUM 0x08 /* rev E compatibility */ -#define DEPCA_CSR_IM 0x04 /* Interrupt masked */ -#define DEPCA_CSR_IEN 0x02 /* Interrupt enabled */ -#define DEPCA_CSR_NORMAL \ - (DEPCA_CSR_SHE | DEPCA_CSR_DUM | DEPCA_CSR_IEN) - -#define DEPCA_ADP 0xc diff --git a/sys/arch/sun3/dev/if_levar.h b/sys/arch/sun3/dev/if_levar.h new file mode 100644 index 00000000000..17fea04312e --- /dev/null +++ b/sys/arch/sun3/dev/if_levar.h @@ -0,0 +1,82 @@ +/* $NetBSD: if_levar.h,v 1.1 1995/12/10 08:46:08 mycroft Exp $ */ + +/*- + * Copyright (c) 1995 Charles M. Hannum. All rights reserved. + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell and Rick Macklem. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)if_le.c 8.2 (Berkeley) 11/16/93 + */ + +/* + * Ethernet software status per interface. + * + * Each interface is referenced by a network interface structure, + * arpcom.ac_if, which the routing code uses to locate the interface. + * This structure contains the output queue for the interface, its address, ... + */ +struct le_softc { + struct device sc_dev; /* base structure */ + struct arpcom sc_arpcom; /* Ethernet common part */ + + void (*sc_copytodesc)(); /* Copy to descriptor */ + void (*sc_copyfromdesc)(); /* Copy from descriptor */ + + void (*sc_copytobuf)(); /* Copy to buffer */ + void (*sc_copyfrombuf)(); /* Copy from buffer */ + void (*sc_zerobuf)(); /* and Zero bytes in buffer */ + + u_int16_t sc_conf3; /* CSR3 value */ + + void *sc_mem; /* base address of RAM -- CPU's view */ + u_long sc_addr; /* base address of RAM -- LANCE's view */ + u_long sc_memsize; /* size of RAM */ + + int sc_nrbuf; /* number of receive buffers */ + int sc_ntbuf; /* number of transmit buffers */ + int sc_last_rd; + int sc_first_td, sc_last_td, sc_no_td; + + int sc_initaddr; + int sc_rmdaddr; + int sc_tmdaddr; + int sc_rbufaddr; + int sc_tbufaddr; + +#ifdef LEDEBUG + int sc_debug; +#endif + + struct lereg1 *sc_r1; /* LANCE registers */ +}; diff --git a/sys/arch/sun3/dev/ncr5380reg.h b/sys/arch/sun3/dev/ncr5380reg.h index 4a1e87101b2..5b7f7bebc15 100644 --- a/sys/arch/sun3/dev/ncr5380reg.h +++ b/sys/arch/sun3/dev/ncr5380reg.h @@ -1,4 +1,4 @@ -/* $NetBSD: ncr5380reg.h,v 1.1.2.1 1995/11/18 07:08:23 gwr Exp $ */ +/* $NetBSD: ncr5380reg.h,v 1.2 1995/11/17 23:27:41 gwr Exp $ */ /* * Mach Operating System diff --git a/sys/arch/sun3/dev/ncr5380sbc.c b/sys/arch/sun3/dev/ncr5380sbc.c index 18900d6cedf..3060cbb2a6f 100644 --- a/sys/arch/sun3/dev/ncr5380sbc.c +++ b/sys/arch/sun3/dev/ncr5380sbc.c @@ -1,4 +1,4 @@ -/* $NetBSD: ncr5380sbc.c,v 1.1.2.1 1995/11/18 07:08:34 gwr Exp $ */ +/* $NetBSD: ncr5380sbc.c,v 1.2 1995/11/17 23:27:45 gwr Exp $ */ /* * Copyright (c) 1995 David Jones, Gordon W. Ross diff --git a/sys/arch/sun3/dev/ncr5380var.h b/sys/arch/sun3/dev/ncr5380var.h index 1ae35b4d58b..a481210c1a6 100644 --- a/sys/arch/sun3/dev/ncr5380var.h +++ b/sys/arch/sun3/dev/ncr5380var.h @@ -1,4 +1,4 @@ -/* $NetBSD: ncr5380var.h,v 1.1.2.1 1995/11/18 07:08:41 gwr Exp $ */ +/* $NetBSD: ncr5380var.h,v 1.2 1995/11/17 23:27:49 gwr Exp $ */ /* * Copyright (c) 1995 David Jones, Gordon W. Ross diff --git a/sys/arch/sun3/dev/ncr_si.c b/sys/arch/sun3/dev/ncr_si.c index 07119e08f30..2ae03eb3948 100644 --- a/sys/arch/sun3/dev/ncr_si.c +++ b/sys/arch/sun3/dev/ncr_si.c @@ -1,4 +1,4 @@ -/* $NetBSD: ncr_si.c,v 1.1.2.1 1995/11/18 07:08:48 gwr Exp $ */ +/* $NetBSD: ncr_si.c,v 1.2 1995/11/17 23:27:52 gwr Exp $ */ /* * Copyright (c) 1995 David Jones, Gordon W. Ross diff --git a/sys/arch/sun3/dev/ncr_sireg.h b/sys/arch/sun3/dev/ncr_sireg.h index 450ed652e3c..2d75eb6f824 100644 --- a/sys/arch/sun3/dev/ncr_sireg.h +++ b/sys/arch/sun3/dev/ncr_sireg.h @@ -1,4 +1,4 @@ -/* $NetBSD: ncr_sireg.h,v 1.1.2.1 1995/11/18 07:08:55 gwr Exp $ */ +/* $NetBSD: ncr_sireg.h,v 1.2 1995/11/17 23:27:55 gwr Exp $ */ /* * Register map for the Sun3 SCSI Interface (si) diff --git a/sys/arch/sun3/dev/rd_root.c b/sys/arch/sun3/dev/rd_root.c index 5e510ac5379..10b341611a5 100644 --- a/sys/arch/sun3/dev/rd_root.c +++ b/sys/arch/sun3/dev/rd_root.c @@ -1,4 +1,4 @@ -/* $NetBSD: rd_root.c,v 1.1.2.1 1995/11/18 06:59:42 gwr Exp $ */ +/* $NetBSD: rd_root.c,v 1.2 1995/11/17 23:24:56 gwr Exp $ */ /* * Copyright (c) 1995 Gordon W. Ross diff --git a/sys/arch/sun3/include/disklabel.h b/sys/arch/sun3/include/disklabel.h index fb03ee9d7b0..3de0e4e1c77 100644 --- a/sys/arch/sun3/include/disklabel.h +++ b/sys/arch/sun3/include/disklabel.h @@ -1,4 +1,4 @@ -/* $NetBSD: disklabel.h,v 1.2.2.1 1995/11/10 22:08:54 gwr Exp $ */ +/* $NetBSD: disklabel.h,v 1.3 1995/11/10 22:05:52 gwr Exp $ */ /* * Copyright (c) 1994 Christopher G. Demetriou diff --git a/sys/arch/sun3/include/param.h b/sys/arch/sun3/include/param.h index b72278c3e5c..aaaa50cd1aa 100644 --- a/sys/arch/sun3/include/param.h +++ b/sys/arch/sun3/include/param.h @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.29.2.1 1995/11/10 22:09:00 gwr Exp $ */ +/* $NetBSD: param.h,v 1.30 1995/11/10 22:04:48 gwr Exp $ */ /* * Copyright (c) 1994, 1995 Gordon W. Ross diff --git a/sys/arch/sun3/stand/Makefile.inc b/sys/arch/sun3/stand/Makefile.inc index f454d6ea438..d6d6a9b9450 100644 --- a/sys/arch/sun3/stand/Makefile.inc +++ b/sys/arch/sun3/stand/Makefile.inc @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.5.2.1 1995/11/18 06:47:31 gwr Exp $ +# $NetBSD: Makefile.inc,v 1.6 1995/11/17 23:23:44 gwr Exp $ .if defined(SA_PROG) diff --git a/sys/arch/sun3/stand/README b/sys/arch/sun3/stand/README index 9f8e098c0b5..9088c5a3662 100644 --- a/sys/arch/sun3/stand/README +++ b/sys/arch/sun3/stand/README @@ -1,4 +1,4 @@ -/* $NetBSD: README,v 1.2.2.1 1995/11/18 06:47:34 gwr Exp $ */ +/* $NetBSD: README,v 1.3 1995/11/17 23:23:45 gwr Exp $ */ The sun bootblocks are split into two parts: a small 1st-level program that gets written right after the superblock in a partition (and is hence limited diff --git a/sys/arch/sun3/stand/bootxx/Makefile b/sys/arch/sun3/stand/bootxx/Makefile index 10fe650671c..c8e56066b72 100644 --- a/sys/arch/sun3/stand/bootxx/Makefile +++ b/sys/arch/sun3/stand/bootxx/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.2.2.1 1995/11/18 06:47:36 gwr Exp $ +# $NetBSD: Makefile,v 1.3 1995/11/17 23:23:48 gwr Exp $ SA_PROG= bootxx SRCS= bootxx.c conf.c diff --git a/sys/arch/sun3/stand/installboot/installboot.8 b/sys/arch/sun3/stand/installboot/installboot.8 index e5495d80c93..d859114b7e8 100644 --- a/sys/arch/sun3/stand/installboot/installboot.8 +++ b/sys/arch/sun3/stand/installboot/installboot.8 @@ -1,4 +1,4 @@ -.\" $Id: installboot.8,v 1.2 1995/11/19 13:53:12 deraadt Exp $ +.\" $Id: installboot.8,v 1.3 1995/12/14 05:26:56 deraadt Exp $ .\" .Dd 31 May 1995 .Dt INSTALLBOOT 8 diff --git a/sys/arch/sun3/stand/installboot/installboot.c b/sys/arch/sun3/stand/installboot/installboot.c index 3592da16b1b..19ed48b0d2a 100644 --- a/sys/arch/sun3/stand/installboot/installboot.c +++ b/sys/arch/sun3/stand/installboot/installboot.c @@ -1,4 +1,4 @@ -/* $NetBSD: installboot.c,v 1.3.2.2 1995/11/18 06:47:40 gwr Exp $ */ +/* $NetBSD: installboot.c,v 1.5 1995/11/17 23:23:50 gwr Exp $ */ /* * Copyright (c) 1994 Paul Kranenburg diff --git a/sys/arch/sun3/stand/libsa/Makefile b/sys/arch/sun3/stand/libsa/Makefile index 2838d9a70d6..88f8d933115 100644 --- a/sys/arch/sun3/stand/libsa/Makefile +++ b/sys/arch/sun3/stand/libsa/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.8.2.1 1995/11/18 06:47:43 gwr Exp $ +# $NetBSD: Makefile,v 1.9 1995/11/17 23:23:52 gwr Exp $ LIB=sa diff --git a/sys/arch/sun3/stand/netboot/Makefile b/sys/arch/sun3/stand/netboot/Makefile index 41c398cc3f6..8d024431190 100644 --- a/sys/arch/sun3/stand/netboot/Makefile +++ b/sys/arch/sun3/stand/netboot/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.3.2.1 1995/11/18 06:47:45 gwr Exp $ +# $NetBSD: Makefile,v 1.4 1995/11/17 23:23:55 gwr Exp $ SA_PROG= netboot SRCS= boot.c conf.c version.c dev_net.c diff --git a/sys/arch/sun3/stand/tapeboot/Makefile b/sys/arch/sun3/stand/tapeboot/Makefile index 3665e85b6b7..593a811776d 100644 --- a/sys/arch/sun3/stand/tapeboot/Makefile +++ b/sys/arch/sun3/stand/tapeboot/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.2.2.1 1995/11/18 06:47:47 gwr Exp $ +# $NetBSD: Makefile,v 1.3 1995/11/17 23:23:56 gwr Exp $ SA_PROG= tapeboot SRCS= boot.c conf.c rawfs.c dev_tape.c version.c diff --git a/sys/arch/sun3/stand/ufsboot/Makefile b/sys/arch/sun3/stand/ufsboot/Makefile index 72c46884a6d..aabae5aa414 100644 --- a/sys/arch/sun3/stand/ufsboot/Makefile +++ b/sys/arch/sun3/stand/ufsboot/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.2.2.1 1995/11/18 06:47:49 gwr Exp $ +# $NetBSD: Makefile,v 1.3 1995/11/17 23:23:58 gwr Exp $ SA_PROG= ufsboot SRCS= boot.c conf.c version.c diff --git a/sys/arch/sun3/sun3/conf.c b/sys/arch/sun3/sun3/conf.c index 6c139549b7e..aa6142019f5 100644 --- a/sys/arch/sun3/sun3/conf.c +++ b/sys/arch/sun3/sun3/conf.c @@ -1,4 +1,4 @@ -/* $NetBSD: conf.c,v 1.44.2.1 1995/10/29 04:22:44 gwr Exp $ */ +/* $NetBSD: conf.c,v 1.45 1995/10/29 04:15:59 gwr Exp $ */ /*- * Copyright (c) 1994 Adam Glass, Gordon W. Ross diff --git a/sys/arch/sun3/sun3/control.c b/sys/arch/sun3/sun3/control.c index 4f59c5f95e7..4b940c0680d 100644 --- a/sys/arch/sun3/sun3/control.c +++ b/sys/arch/sun3/sun3/control.c @@ -1,4 +1,4 @@ -/* $NetBSD: control.c,v 1.12.2.1 1995/11/18 06:56:12 gwr Exp $ */ +/* $NetBSD: control.c,v 1.13 1995/11/17 23:29:30 gwr Exp $ */ /* * Copyright (c) 1993 Adam Glass diff --git a/sys/arch/sun3/sun3/db_machdep.c b/sys/arch/sun3/sun3/db_machdep.c index f185ef1a961..b8fc34692e4 100644 --- a/sys/arch/sun3/sun3/db_machdep.c +++ b/sys/arch/sun3/sun3/db_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: db_machdep.c,v 1.5.2.1 1995/10/23 21:53:16 gwr Exp $ */ +/* $NetBSD: db_machdep.c,v 1.6 1995/10/23 18:40:35 gwr Exp $ */ /* * Copyright (c) 1994, 1995 Gordon W. Ross diff --git a/sys/arch/sun3/sun3/disksubr.c b/sys/arch/sun3/sun3/disksubr.c index f16a50520ca..baa89a823ba 100644 --- a/sys/arch/sun3/sun3/disksubr.c +++ b/sys/arch/sun3/sun3/disksubr.c @@ -1,4 +1,4 @@ -/* $NetBSD: disksubr.c,v 1.9.2.2 1995/11/18 06:58:03 gwr Exp $ */ +/* $NetBSD: disksubr.c,v 1.11 1995/11/17 23:30:19 gwr Exp $ */ /* * Copyright (c) 1994, 1995 Gordon W. Ross diff --git a/sys/arch/sun3/sun3/locore.s b/sys/arch/sun3/sun3/locore.s index dfb663e0932..f4a66acd68f 100644 --- a/sys/arch/sun3/sun3/locore.s +++ b/sys/arch/sun3/sun3/locore.s @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.33 1995/10/10 21:35:42 gwr Exp $ */ +/* $NetBSD: locore.s,v 1.34 1995/12/11 02:38:13 thorpej Exp $ */ /* * Copyright (c) 1994, 1995 Gordon W. Ross @@ -1158,82 +1158,6 @@ ENTRY(_remque) rts /* - * {ov}bcopy(from, to, len) - * memcpy(to, from, len) - * - * Works for counts up to 128K. - */ -ENTRY(memcpy) - movl sp@(12),d0 | get count - jeq Lcpyexit | if zero, return - movl sp@(8), a0 | src address - movl sp@(4), a1 | dest address - jra Ldocopy | jump into bcopy -ALTENTRY(ovbcopy, _bcopy) -ENTRY(bcopy) - movl sp@(12),d0 | get count - jeq Lcpyexit | if zero, return - movl sp@(4),a0 | src address - movl sp@(8),a1 | dest address -Ldocopy: - cmpl a1,a0 | src before dest? - jlt Lcpyback | yes, copy backwards (avoids overlap) - movl a0,d1 - btst #0,d1 | src address odd? - jeq Lcfeven | no, go check dest - movb a0@+,a1@+ | yes, copy a byte - subql #1,d0 | update count - jeq Lcpyexit | exit if done -Lcfeven: - movl a1,d1 - btst #0,d1 | dest address odd? - jne Lcfbyte | yes, must copy by bytes - movl d0,d1 | no, get count - lsrl #2,d1 | convert to longwords - jeq Lcfbyte | no longwords, copy bytes - subql #1,d1 | set up for dbf -Lcflloop: - movl a0@+,a1@+ | copy longwords - dbf d1,Lcflloop | til done - andl #3,d0 | get remaining count - jeq Lcpyexit | done if none -Lcfbyte: - subql #1,d0 | set up for dbf -Lcfbloop: - movb a0@+,a1@+ | copy bytes - dbf d0,Lcfbloop | til done -Lcpyexit: - rts -Lcpyback: - addl d0,a0 | add count to src - addl d0,a1 | add count to dest - movl a0,d1 - btst #0,d1 | src address odd? - jeq Lcbeven | no, go check dest - movb a0@-,a1@- | yes, copy a byte - subql #1,d0 | update count - jeq Lcpyexit | exit if done -Lcbeven: - movl a1,d1 - btst #0,d1 | dest address odd? - jne Lcbbyte | yes, must copy by bytes - movl d0,d1 | no, get count - lsrl #2,d1 | convert to longwords - jeq Lcbbyte | no longwords, copy bytes - subql #1,d1 | set up for dbf -Lcblloop: - movl a0@-,a1@- | copy longwords - dbf d1,Lcblloop | til done - andl #3,d0 | get remaining count - jeq Lcpyexit | done if none -Lcbbyte: - subql #1,d0 | set up for dbf -Lcbbloop: - movb a0@-,a1@- | copy bytes - dbf d0,Lcbbloop | til done - rts - -/* * Save and restore 68881 state. * Pretty awful looking since our assembler does not * recognize FP mnemonics. diff --git a/sys/arch/sun3/sun3/sys_machdep.c b/sys/arch/sun3/sun3/sys_machdep.c index 64420acb557..23a3ea0c7db 100644 --- a/sys/arch/sun3/sun3/sys_machdep.c +++ b/sys/arch/sun3/sun3/sys_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: sys_machdep.c,v 1.2.2.1 1995/10/27 18:41:58 gwr Exp $ */ +/* $NetBSD: sys_machdep.c,v 1.3 1995/10/27 15:58:23 gwr Exp $ */ /* * Copyright (c) 1982, 1986, 1993 diff --git a/sys/arch/sun3/sun3/vm_machdep.c b/sys/arch/sun3/sun3/vm_machdep.c index a01348645b7..d23fbfb3541 100644 --- a/sys/arch/sun3/sun3/vm_machdep.c +++ b/sys/arch/sun3/sun3/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.31 1995/09/26 04:02:30 gwr Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.32 1995/12/09 04:37:58 mycroft Exp $ */ /* * Copyright (c) 1994, 1995 Gordon W. Ross @@ -76,7 +76,7 @@ void cpu_set_kpc __P((struct proc *p, u_long func)); * ready to run, and marking it so that it can return differently * than the parent. Returns 1 in the child process, 0 in the parent. */ -int +void cpu_fork(p1, p2) register struct proc *p1, *p2; { @@ -132,8 +132,6 @@ cpu_fork(p1, p2) * When p2 runs, it will find itself in child_return(). */ cpu_set_kpc(p2, (long)child_return); - - return (0); } /* diff --git a/sys/arch/vax/conf/GENERIC b/sys/arch/vax/conf/GENERIC index b187a85c1e8..6c0176464b0 100644 --- a/sys/arch/vax/conf/GENERIC +++ b/sys/arch/vax/conf/GENERIC @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.7.2.1 1995/10/15 13:52:58 ragge Exp $ +# $NetBSD: GENERIC,v 1.8 1995/11/30 00:59:20 jtc Exp $ # # GENERIC VAX, currently only supports 11/750 anyway. # diff --git a/sys/arch/vax/if/if_de.c b/sys/arch/vax/if/if_de.c index 18f01217787..d42a45ec242 100644 --- a/sys/arch/vax/if/if_de.c +++ b/sys/arch/vax/if/if_de.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_de.c,v 1.7.2.1 1995/10/15 13:56:24 ragge Exp $ */ +/* $NetBSD: if_de.c,v 1.10 1995/12/01 19:37:55 ragge Exp $ */ /* * Copyright (c) 1982, 1986, 1989 Regents of the University of California. @@ -36,7 +36,6 @@ */ #include "de.h" -#if NDE > 0 /* * DEC DEUNA interface @@ -54,14 +53,13 @@ #include "sys/buf.h" #include "sys/protosw.h" #include "sys/socket.h" -/* #include "sys/vmmac.h" */ #include "sys/ioctl.h" #include "sys/errno.h" #include "sys/syslog.h" #include "sys/device.h" -#include "vax/include/pte.h" -#include "vax/include/sid.h" +#include "machine/pte.h" +#include "machine/sid.h" #include "net/if.h" #include "net/netisr.h" @@ -98,16 +96,6 @@ extern char all_es_snpa[], all_is_snpa[]; int dedebug = 0; - -int deprobe(), deattach(), deintr(); -struct uba_device *deinfo[NDE]; -u_short destd[] = { 0 }; -struct uba_driver dedriver = - { deprobe, 0, deattach, 0, destd, "de", deinfo }; -int deinit(),deioctl(),dereset(); -void destart(); - - /* * Ethernet software status per interface. * @@ -121,7 +109,9 @@ void destart(); * efficiently. */ struct de_softc { + struct device ds_device; /* Configuration common part */ struct arpcom ds_ac; /* Ethernet common part */ + struct dedevice *ds_vaddr; /* Virtual address of this interface */ #define ds_if ds_ac.ac_if /* network-visible interface */ #define ds_addr ds_ac.ac_enaddr /* hardware Ethernet address */ int ds_flags; @@ -138,74 +128,54 @@ struct de_softc { struct de_udbbuf ds_udbbuf; /* UNIBUS data buffer */ /* end mapped area */ #define INCORE_BASE(p) ((char *)&(p)->ds_pcbb) -#define RVAL_OFF(n) ((char *)&de_softc[0].n - INCORE_BASE(&de_softc[0])) -#define LVAL_OFF(n) ((char *)de_softc[0].n - INCORE_BASE(&de_softc[0])) -#define PCBB_OFFSET RVAL_OFF(ds_pcbb) -#define XRENT_OFFSET LVAL_OFF(ds_xrent) -#define RRENT_OFFSET LVAL_OFF(ds_rrent) -#define UDBBUF_OFFSET RVAL_OFF(ds_udbbuf) -#define INCORE_SIZE RVAL_OFF(ds_xindex) +#define RVAL_OFF(s,n) ((char *)&(s)->n - INCORE_BASE(s)) +#define LVAL_OFF(s,n) ((char *)(s)->n - INCORE_BASE(s)) +#define PCBB_OFFSET(s) RVAL_OFF(s,ds_pcbb) +#define XRENT_OFFSET(s) LVAL_OFF(s,ds_xrent) +#define RRENT_OFFSET(s) LVAL_OFF(s,ds_rrent) +#define UDBBUF_OFFSET(s) RVAL_OFF(s,ds_udbbuf) +#define INCORE_SIZE(s) RVAL_OFF(s, ds_xindex) int ds_xindex; /* UNA index into transmit chain */ int ds_rindex; /* UNA index into receive chain */ int ds_xfree; /* index for next transmit buffer */ int ds_nxmit; /* # of transmits in progress */ -} de_softc[NDE]; - -deprobe(reg) - caddr_t reg; -{ - register int br, cvec; /* r11, r10 value-result */ - volatile struct dedevice *addr = (struct dedevice *)reg; - register i; +}; -#ifdef lint - br = 0; cvec = br; br = cvec; - i = 0; derint(i); deintr(i); -#endif +int dematch __P((struct device *, void *, void *)); +void deattach __P((struct device *, struct device *, void *)); +int dewait __P((struct de_softc *, char *)); +void deinit __P((int)); +int deioctl __P((struct ifnet *, u_long, caddr_t)); +int dereset __P((int)); +void destart __P((struct ifnet *)); +void deread __P((struct de_softc *, struct ifrw *, int)); +void derecv __P((int)); +void de_setaddr __P((u_char *, int)); - /* - * Make sure self-test is finished before we screw with the board. - * Self-test on a DELUA can take 15 seconds (argh). - */ - for (i = 0; - i < 160 && - (addr->pcsr0 & PCSR0_FATI) == 0 && - (addr->pcsr1 & PCSR1_STMASK) == STAT_RESET; - ++i) - waitabit(10); - if ((addr->pcsr0 & PCSR0_FATI) != 0 || - (addr->pcsr1 & PCSR1_STMASK) != STAT_READY && - (addr->pcsr1 & PCSR1_STMASK) != STAT_RUN) - return(0); - addr->pcsr0 = 0; - waitabit(1); - addr->pcsr0 = PCSR0_RSET; - while ((addr->pcsr0 & PCSR0_INTR) == 0) - ; - /* make board interrupt by executing a GETPCBB command */ - addr->pcsr0 = PCSR0_INTE; - addr->pcsr2 = 0; - addr->pcsr3 = 0; - addr->pcsr0 = PCSR0_INTE|CMD_GETPCBB; - waitabit(10); - return(1); -} +struct cfdriver decd = + { 0,"de",dematch, deattach, DV_IFNET, sizeof(struct de_softc) }; /* * Interface exists: make available by filling in network interface * record. System will initialize the interface when it is ready * to accept packets. We get the ethernet address here. */ -deattach(ui) - struct uba_device *ui; +void +deattach(parent, self, aux) + struct device *parent, *self; + void *aux; { - register struct de_softc *ds = &de_softc[ui->ui_unit]; - register struct ifnet *ifp = &ds->ds_if; - volatile struct dedevice *addr = (struct dedevice *)ui->ui_addr; + struct uba_attach_args *ua = aux; + struct de_softc *ds = (struct de_softc *)self; + struct ifnet *ifp = &ds->ds_if; + struct dedevice *addr; int csr1; - ifp->if_unit = ui->ui_unit; + printf("\n"); + addr = (struct dedevice *)ua->ua_addr; + ds->ds_vaddr = addr; + ifp->if_unit = ds->ds_device.dv_unit; ifp->if_name = "de"; ifp->if_flags = IFF_BROADCAST | IFF_NOTRAILERS; @@ -216,36 +186,36 @@ deattach(ui) */ csr1 = addr->pcsr1; if (csr1 & 0xff60) - printf("de%d: broken\n", ui->ui_unit); + printf("de%d: broken\n", ds->ds_device.dv_unit); else if (csr1 & 0x10) - printf("de%d: delua\n", ui->ui_unit); + printf("de%d: delua\n", ds->ds_device.dv_unit); else - printf("de%d: deuna\n", ui->ui_unit); + printf("de%d: deuna\n", ds->ds_device.dv_unit); /* * Reset the board and temporarily map * the pcbb buffer onto the Unibus. */ addr->pcsr0 = 0; /* reset INTE */ - waitabit(1); + DELAY(5000); addr->pcsr0 = PCSR0_RSET; - (void)dewait(ui, "reset"); + (void)dewait(ds, "reset"); - ds->ds_ubaddr = uballoc(ui->ui_ubanum, (char *)&ds->ds_pcbb, - sizeof (struct de_pcbb), 0); + ds->ds_ubaddr = uballoc(ds->ds_device.dv_parent->dv_unit, + (char *)&ds->ds_pcbb, sizeof (struct de_pcbb), 0); addr->pcsr2 = ds->ds_ubaddr & 0xffff; addr->pcsr3 = (ds->ds_ubaddr >> 16) & 0x3; addr->pclow = CMD_GETPCBB; - (void)dewait(ui, "pcbb"); + (void)dewait(ds, "pcbb"); ds->ds_pcbb.pcbb0 = FC_RDPHYAD; addr->pclow = CMD_GETCMD; - (void)dewait(ui, "read addr "); + (void)dewait(ds, "read addr "); - ubarelse(ui->ui_ubanum, &ds->ds_ubaddr); + ubarelse(ds->ds_device.dv_parent->dv_unit, &ds->ds_ubaddr); bcopy((caddr_t)&ds->ds_pcbb.pcbb2, (caddr_t)ds->ds_addr, sizeof (ds->ds_addr)); - printf("de%d: hardware address %s\n", ui->ui_unit, + printf("de%d: hardware address %s\n", ds->ds_device.dv_unit, ether_sprintf(ds->ds_addr)); ifp->if_ioctl = deioctl; ifp->if_reset = dereset; @@ -263,9 +233,11 @@ deattach(ui) * Reset of interface after UNIBUS reset. * If interface is on specified uba, reset its state. */ -dereset(unit, uban) - int unit, uban; +int +dereset(unit) + int unit; { +#if 0 register struct uba_device *ui; if (unit >= NDE || (ui = deinfo[unit]) == 0 || ui->ui_alive == 0 || @@ -277,17 +249,19 @@ dereset(unit, uban) ((struct dedevice *)ui->ui_addr)->pcsr0 = PCSR0_RSET; (void)dewait(ui, "reset"); deinit(unit); +#endif + return 0; } /* * Initialization of interface; clear recorded pending * operations, and reinitialize UNIBUS usage. */ +void deinit(unit) int unit; { struct de_softc *ds; - struct uba_device *ui; volatile struct dedevice *addr; struct ifrw *ifrw; struct ifxmt *ifxp; @@ -295,8 +269,7 @@ deinit(unit) struct de_ring *rp; int s,incaddr; - ds = &de_softc[unit]; - ui = deinfo[unit]; + ds = (struct de_softc *)decd.cd_devs[unit]; ifp = &ds->ds_if; /* not yet, if address still unknown */ @@ -306,53 +279,53 @@ deinit(unit) if (ds->ds_flags & DSF_RUNNING) return; if ((ifp->if_flags & IFF_RUNNING) == 0) { - if (if_ubaminit(&ds->ds_deuba, ui->ui_ubanum, + if (if_ubaminit(&ds->ds_deuba, ds->ds_device.dv_parent->dv_unit, sizeof (struct ether_header), (int)btoc(ETHERMTU), ds->ds_ifr, NRCV, ds->ds_ifw, NXMT) == 0) { printf("de%d: can't initialize\n", unit); ds->ds_if.if_flags &= ~IFF_UP; return; } - ds->ds_ubaddr = uballoc(ui->ui_ubanum, INCORE_BASE(ds), - INCORE_SIZE, 0); + ds->ds_ubaddr = uballoc(ds->ds_device.dv_parent->dv_unit, + INCORE_BASE(ds), INCORE_SIZE(ds), 0); } - addr = (struct dedevice *)ui->ui_addr; + addr = ds->ds_vaddr; /* set the pcbb block address */ - incaddr = ds->ds_ubaddr + PCBB_OFFSET; + incaddr = ds->ds_ubaddr + PCBB_OFFSET(ds); addr->pcsr2 = incaddr & 0xffff; addr->pcsr3 = (incaddr >> 16) & 0x3; addr->pclow = 0; /* reset INTE */ - waitabit(1); + DELAY(5000); addr->pclow = CMD_GETPCBB; - (void)dewait(ui, "pcbb"); + (void)dewait(ds, "pcbb"); /* set the transmit and receive ring header addresses */ - incaddr = ds->ds_ubaddr + UDBBUF_OFFSET; + incaddr = ds->ds_ubaddr + UDBBUF_OFFSET(ds); ds->ds_pcbb.pcbb0 = FC_WTRING; ds->ds_pcbb.pcbb2 = incaddr & 0xffff; ds->ds_pcbb.pcbb4 = (incaddr >> 16) & 0x3; - incaddr = ds->ds_ubaddr + XRENT_OFFSET; + incaddr = ds->ds_ubaddr + XRENT_OFFSET(ds); ds->ds_udbbuf.b_tdrbl = incaddr & 0xffff; ds->ds_udbbuf.b_tdrbh = (incaddr >> 16) & 0x3; ds->ds_udbbuf.b_telen = sizeof (struct de_ring) / sizeof (short); ds->ds_udbbuf.b_trlen = NXMT; - incaddr = ds->ds_ubaddr + RRENT_OFFSET; + incaddr = ds->ds_ubaddr + RRENT_OFFSET(ds); ds->ds_udbbuf.b_rdrbl = incaddr & 0xffff; ds->ds_udbbuf.b_rdrbh = (incaddr >> 16) & 0x3; ds->ds_udbbuf.b_relen = sizeof (struct de_ring) / sizeof (short); ds->ds_udbbuf.b_rrlen = NRCV; addr->pclow = CMD_GETCMD; - (void)dewait(ui, "wtring"); + (void)dewait(ds, "wtring"); /* initialize the mode - enable hardware padding */ ds->ds_pcbb.pcbb0 = FC_WTMODE; /* let hardware do padding - set MTCH bit on broadcast */ ds->ds_pcbb.pcbb2 = MOD_TPAD|MOD_HDX; addr->pclow = CMD_GETCMD; - (void)dewait(ui, "wtmode"); + (void)dewait(ds, "wtmode"); /* set up the receive and transmit ring entries */ ifxp = &ds->ds_ifw[0]; @@ -396,9 +369,8 @@ destart(ifp) { int len; int unit = ifp->if_unit; - struct uba_device *ui = deinfo[unit]; - volatile struct dedevice *addr = (struct dedevice *)ui->ui_addr; - register struct de_softc *ds = &de_softc[unit]; + register struct de_softc *ds = decd.cd_devs[ifp->if_unit]; + volatile struct dedevice *addr = ds->ds_vaddr; register struct de_ring *rp; struct mbuf *m; register int nxmit; @@ -439,18 +411,18 @@ destart(ifp) /* * Command done interrupt. */ -deintr(uba,vector,level,unit) +void +deintr(unit) + int unit; { - struct uba_device *ui; volatile struct dedevice *addr; register struct de_softc *ds; register struct de_ring *rp; register struct ifxmt *ifxp; short csr0; - ui = deinfo[unit]; - addr = (struct dedevice *)ui->ui_addr; - ds = &de_softc[unit]; + ds = decd.cd_devs[unit]; + addr = ds->ds_vaddr; /* save flags right away - clear out interrupt bits */ @@ -527,10 +499,11 @@ deintr(uba,vector,level,unit) * packet based on type and pass to type specific higher-level * input routine. */ +void derecv(unit) int unit; { - register struct de_softc *ds = &de_softc[unit]; + register struct de_softc *ds = decd.cd_devs[unit]; register struct de_ring *rp; int len; @@ -571,6 +544,7 @@ derecv(unit) * Pass a packet to the higher levels. * We deal with the trailer protocol here. */ +void deread(ds, ifrw, len) register struct de_softc *ds; struct ifrw *ifrw; @@ -587,7 +561,6 @@ deread(ds, ifrw, len) * Remember that type was trailer by setting off. */ eh = (struct ether_header *)ifrw->ifrw_addr; -/* eh->ether_type = ntohs((u_short)eh->ether_type); */ if (len == 0) return; @@ -603,13 +576,14 @@ deread(ds, ifrw, len) /* * Process an ioctl request. */ +int deioctl(ifp, cmd, data) register struct ifnet *ifp; - int cmd; + u_long cmd; caddr_t data; { register struct ifaddr *ifa = (struct ifaddr *)data; - register struct de_softc *ds = &de_softc[ifp->if_unit]; + register struct de_softc *ds = decd.cd_devs[ifp->if_unit]; int s = splimp(), error = 0; switch (cmd) { @@ -642,11 +616,9 @@ deioctl(ifp, cmd, data) case SIOCSIFFLAGS: if ((ifp->if_flags & IFF_UP) == 0 && ds->ds_flags & DSF_RUNNING) { - ((struct dedevice *) - (deinfo[ifp->if_unit]->ui_addr))->pclow = 0; - waitabit(1); - ((struct dedevice *) - (deinfo[ifp->if_unit]->ui_addr))->pclow = PCSR0_RSET; + ds->ds_vaddr->pclow = 0; + DELAY(5000); + ds->ds_vaddr->pclow = PCSR0_RSET; ds->ds_flags &= ~DSF_RUNNING; ds->ds_if.if_flags &= ~IFF_OACTIVE; } else if (ifp->if_flags & IFF_UP && @@ -664,13 +636,13 @@ deioctl(ifp, cmd, data) /* * set ethernet address for unit */ +void de_setaddr(physaddr, unit) - u_char *physaddr; - int unit; + u_char *physaddr; + int unit; { - register struct de_softc *ds = &de_softc[unit]; - struct uba_device *ui = deinfo[unit]; - volatile struct dedevice *addr= (struct dedevice *)ui->ui_addr; + register struct de_softc *ds = decd.cd_devs[unit]; + volatile struct dedevice *addr= ds->ds_vaddr; if (! (ds->ds_flags & DSF_RUNNING)) return; @@ -678,7 +650,7 @@ de_setaddr(physaddr, unit) bcopy((caddr_t) physaddr, (caddr_t) &ds->ds_pcbb.pcbb2, 6); ds->ds_pcbb.pcbb0 = FC_WTPHYAD; addr->pclow = PCSR0_INTE|CMD_GETCMD; - if (dewait(ui, "address change") == 0) { + if (dewait(ds, "address change") == 0) { ds->ds_flags |= DSF_SETADDR; bcopy((caddr_t) physaddr, (caddr_t) ds->ds_addr, 6); } @@ -688,11 +660,12 @@ de_setaddr(physaddr, unit) * Await completion of the named function * and check for errors. */ -dewait(ui, fn) - register struct uba_device *ui; +int +dewait(ds, fn) + register struct de_softc *ds; char *fn; { - volatile struct dedevice *addr = (struct dedevice *)ui->ui_addr; + volatile struct dedevice *addr = ds->ds_vaddr; register csr0; while ((addr->pcsr0 & PCSR0_INTR) == 0) @@ -701,23 +674,48 @@ dewait(ui, fn) addr->pchigh = csr0 >> 8; if (csr0 & PCSR0_PCEI) printf("de%d: %s failed, csr0=%b csr1=%b\n", - ui->ui_unit, fn, csr0, PCSR0_BITS, + ds->ds_device.dv_unit, fn, csr0, PCSR0_BITS, addr->pcsr1, PCSR1_BITS); return (csr0 & PCSR0_PCEI); } -de_match(){ - printf("de_match\n"); - return 0; -} - -void -de_attach(){ - printf("de_attach\n"); -} - -struct cfdriver decd = - { NULL,"de",de_match, de_attach, DV_IFNET, sizeof(struct uba_driver) }; +int +dematch(parent, match, aux) + struct device *parent; + void *match, *aux; +{ + struct de_softc *sc = match; + struct uba_attach_args *ua = aux; + volatile struct dedevice *addr = (struct dedevice *)ua->ua_addr; + int i; + /* + * Make sure self-test is finished before we screw with the board. + * Self-test on a DELUA can take 15 seconds (argh). + */ + for (i = 0; + i < 160 && + (addr->pcsr0 & PCSR0_FATI) == 0 && + (addr->pcsr1 & PCSR1_STMASK) == STAT_RESET; + ++i) + DELAY(50000); + if ((addr->pcsr0 & PCSR0_FATI) != 0 || + (addr->pcsr1 & PCSR1_STMASK) != STAT_READY && + (addr->pcsr1 & PCSR1_STMASK) != STAT_RUN) + return(0); -#endif + addr->pcsr0 = 0; + DELAY(5000); + addr->pcsr0 = PCSR0_RSET; + while ((addr->pcsr0 & PCSR0_INTR) == 0) + ; + /* make board interrupt by executing a GETPCBB command */ + addr->pcsr0 = PCSR0_INTE; + addr->pcsr2 = 0; + addr->pcsr3 = 0; + addr->pcsr0 = PCSR0_INTE|CMD_GETPCBB; + DELAY(50000); + ua->ua_ivec = deintr; + ua->ua_iarg = sc->ds_device.dv_unit; + return 1; +} diff --git a/sys/arch/vax/if/if_qe.c b/sys/arch/vax/if/if_qe.c index fbf584fd09e..a468d3011f4 100644 --- a/sys/arch/vax/if/if_qe.c +++ b/sys/arch/vax/if/if_qe.c @@ -1,4 +1,5 @@ -/* $NetBSD: if_qe.c,v 1.4.2.1 1995/10/15 13:56:26 ragge Exp $ */ +/* $NetBSD: if_qe.c,v 1.7 1995/12/01 19:37:59 ragge Exp $ */ + /* * Copyright (c) 1988 Regents of the University of California. * All rights reserved. @@ -133,8 +134,6 @@ * --------------------------------------------------------------------- */ -#include "qe.h" -#if NQE > 0 /* * Digital Q-BUS to NI Adapter */ @@ -174,19 +173,15 @@ extern char all_es_snpa[], all_is_snpa[], all_l1is_snpa[], all_l2is_snpa[]; #endif -#include "vax/include/pte.h" -#include "vax/include/cpu.h" -#include "vax/include/mtpr.h" +#include "machine/pte.h" +#include "machine/cpu.h" +#include "machine/mtpr.h" #include "if_qereg.h" #include "if_uba.h" #include "vax/uba/ubareg.h" #include "vax/uba/ubavar.h" -#if NQE == 1 && !defined(QNIVERT) #define NRCV 15 /* Receive descriptors */ -#else -#define NRCV 10 /* Receive descriptors */ -#endif #define NXMT 5 /* Transmit descriptors */ #define NTOT (NXMT + NRCV) @@ -205,12 +200,14 @@ void qetimeout(int); * This structure contains the output queue for the interface, its address, ... */ struct qe_softc { + struct device qe_device; /* Configuration common part */ struct arpcom qe_ac; /* Ethernet common part */ #define qe_if qe_ac.ac_if /* network-visible interface */ #define qe_addr qe_ac.ac_enaddr /* hardware Ethernet address */ struct ifubinfo qe_uba; /* Q-bus resources */ - volatile struct ifrw qe_ifr[NRCV]; /* for receive buffers; */ - volatile struct ifxmt qe_ifw[NXMT]; /* for xmit buffers; */ + struct ifrw qe_ifr[NRCV]; /* for receive buffers; */ + struct ifxmt qe_ifw[NXMT]; /* for xmit buffers; */ + struct qedevice *qe_vaddr; int qe_flags; /* software state */ #define QEF_RUNNING 0x01 #define QEF_SETADDR 0x02 @@ -219,30 +216,38 @@ struct qe_softc { int ipl; /* interrupt priority */ struct qe_ring *rringaddr; /* mapping info for rings */ struct qe_ring *tringaddr; /* "" */ - volatile struct qe_ring rring[NRCV+1]; /* Receive ring descriptors */ - volatile struct qe_ring tring[NXMT+1]; /* Xmit ring descriptors */ + struct qe_ring rring[NRCV+1]; /* Receive ring descriptors */ + struct qe_ring tring[NXMT+1]; /* Xmit ring descriptors */ u_char setup_pkt[16][8]; /* Setup packet */ int rindex; /* Receive index */ int tindex; /* Transmit index */ int otindex; /* Old transmit index */ int qe_intvec; /* Interrupt vector */ - volatile struct qedevice *addr; /* device addr */ + struct qedevice *addr; /* device addr */ int setupqueued; /* setup packet queued */ int nxmit; /* Transmits in progress */ int qe_restarts; /* timeouts */ -} qe_softc[NQE]; - -struct uba_device *qeinfo[NQE]; - -extern struct timeval time; - -int qeprobe(), qeattach(), qeintr(); -int qeinit(), qeioctl(), qereset(); -void qestart(); +}; + +int qematch __P((struct device *, void *, void *)); +void qeattach __P((struct device *, struct device *, void *)); +int qereset __P((int)); +void qeinit __P((int)); +void qestart __P((struct ifnet *)); +void qeintr __P((int)); +void qetint __P((int)); +void qerint __P((int)); +int qeioctl __P((struct ifnet *, u_long, caddr_t)); +void qe_setaddr __P((u_char *, int)); +void qeinitdesc __P((struct qe_ring *, caddr_t, int)); +void qesetup __P((struct qe_softc *)); +void qeread __P((struct qe_softc *, struct ifrw *, int)); +void qetimeout __P((int)); +void qerestart __P((struct qe_softc *)); + +struct cfdriver qecd = + { 0, "qe", qematch, qeattach, DV_IFNET, sizeof(struct qe_softc) }; -u_short qestd[] = { 0 }; -struct uba_driver qedriver = - { qeprobe, 0, qeattach, 0, qestd, "qe", qeinfo }; #define QEUNIT(x) minor(x) /* @@ -252,40 +257,39 @@ struct uba_driver qedriver = * size buffers. */ #define MAXPACKETSIZE 2048 /* Should really be ETHERMTU */ + /* * Probe the QNA to see if it's there */ -qeprobe(reg, ui) - caddr_t reg; - struct uba_device *ui; +int +qematch(parent, match, aux) + struct device *parent; + void *match, *aux; { - /* register int br, cvec; r11, r10 value-result */ - register volatile struct qedevice *addr = (struct qedevice *)reg; - register volatile struct qe_ring *rp; - register struct qe_ring *prp; /* physical rp */ - register int i; - register volatile struct qe_softc *sc = &qe_softc[ui->ui_unit]; - -#ifdef lint - br = 0; cvec = br; br = cvec; - qeintr(0); -#endif + struct qe_softc *sc = match; + struct uba_attach_args *ua = aux; + struct uba_softc *ubasc = (struct uba_softc *)parent; + struct qe_ring *rp; + struct qe_ring *prp; /* physical rp */ + volatile struct qedevice *addr = (struct qedevice *)ua->ua_addr; + int i; /* * The QNA interrupts on i/o operations. To do an I/O operation * we have to setup the interface by transmitting a setup packet. */ + addr->qe_csr = QE_RESET; addr->qe_csr &= ~QE_RESET; - addr->qe_vector = (uba_hd[numuba].uh_lastiv -= 4); + addr->qe_vector = (ubasc->uh_lastiv -= 4); /* * Map the communications area and the setup packet. */ sc->setupaddr = - uballoc(0, (caddr_t)sc->setup_pkt, sizeof(sc->setup_pkt), 0); + uballoc(0, (caddr_t)sc->setup_pkt, sizeof(sc->setup_pkt), 0); sc->rringaddr = (struct qe_ring *) uballoc(0, (caddr_t)sc->rring, - sizeof(struct qe_ring) * (NTOT+2), 0); + sizeof(struct qe_ring) * (NTOT+2), 0); prp = (struct qe_ring *)UBAI_ADDR((int)sc->rringaddr); /* @@ -314,10 +318,10 @@ qeprobe(reg, ui) * packet. This code looks strange due to the fact that the address * is placed in the setup packet in col. major order. */ - for( i = 0 ; i < 6 ; i++ ) + for (i = 0; i < 6; i++) sc->setup_pkt[i][1] = addr->qe_sta_addr[i]; - qesetup( sc ); + qesetup(sc); /* * Start the interface and wait for the packet. */ @@ -334,7 +338,9 @@ qeprobe(reg, ui) ubarelse(0, &sc->setupaddr); ubarelse(0, (int *)&sc->rringaddr); sc->ipl = 0x15; - return( sizeof(struct qedevice) ); + ua->ua_ivec = qeintr; + ua->ua_iarg = sc->qe_device.dv_unit; + return 1; } /* @@ -342,15 +348,20 @@ qeprobe(reg, ui) * record. System will initialize the interface when it is ready * to accept packets. */ -qeattach(ui) - struct uba_device *ui; +void +qeattach(parent, self, aux) + struct device *parent, *self; + void *aux; { - struct qe_softc *sc = &qe_softc[ui->ui_unit]; - struct ifnet *ifp = (struct ifnet *)&sc->qe_if; - volatile struct qedevice *addr=(struct qedevice *)ui->ui_addr; + struct uba_attach_args *ua = aux; + struct qe_softc *sc = (struct qe_softc *)self; + struct ifnet *ifp = (struct ifnet *)&sc->qe_if; + struct qedevice *addr =(struct qedevice *)ua->ua_addr; int i; - ifp->if_unit = ui->ui_unit; + printf("\n"); + sc->qe_vaddr = addr; + ifp->if_unit = sc->qe_device.dv_unit; ifp->if_name = "qe"; /* * The Deqna is cable of transmitting broadcasts, but @@ -361,10 +372,11 @@ qeattach(ui) /* * Read the address from the prom and save it. */ - for( i=0 ; i<6 ; i++ ) - sc->setup_pkt[i][1] = sc->qe_addr[i] = addr->qe_sta_addr[i] & 0xff; + for (i = 0; i < 6; i++) + sc->setup_pkt[i][1] = sc->qe_addr[i] = + addr->qe_sta_addr[i] & 0xff; addr->qe_vector |= 1; - printf("qe%d: %s, hardware address %s\n", ui->ui_unit, + printf("qe%d: %s, hardware address %s\n", sc->qe_device.dv_unit, addr->qe_vector&01 ? "delqa":"deqna", ether_sprintf(sc->qe_addr)); addr->qe_vector &= ~1; @@ -387,28 +399,31 @@ qeattach(ui) * Reset of interface after UNIBUS reset. * If interface is on specified uba, reset its state. */ -qereset(unit, uban) - int unit, uban; +qereset(unit) + int unit; { register struct uba_device *ui; + panic("qereset"); +#ifdef notyet if (unit >= NQE || (ui = qeinfo[unit]) == 0 || ui->ui_alive == 0 || ui->ui_ubanum != uban) return; printf(" qe%d", unit); qe_softc[unit].qe_if.if_flags &= ~IFF_RUNNING; qeinit(unit); +#endif } /* * Initialization of interface. */ +void qeinit(unit) int unit; { - volatile struct qe_softc *sc = &qe_softc[unit]; - struct uba_device *ui = qeinfo[unit]; - volatile struct qedevice *addr=(struct qedevice *)ui->ui_addr; + struct qe_softc *sc = (struct qe_softc *)qecd.cd_devs[unit]; + struct qedevice *addr = sc->qe_vaddr; struct ifnet *ifp = (struct ifnet *)&sc->qe_if; int i; int s; @@ -437,7 +452,7 @@ qeinit(unit) /* * init buffers and maps */ - if (if_ubaminit(&sc->qe_uba, ui->ui_ubanum, + if (if_ubaminit(&sc->qe_uba, sc->qe_device.dv_parent->dv_unit, sizeof (struct ether_header), (int)btoc(MAXPACKETSIZE), sc->qe_ifr, NRCV, sc->qe_ifw, NXMT) == 0) { fail: @@ -504,17 +519,15 @@ qestart(ifp) struct ifnet *ifp; { int unit = ifp->if_unit; - struct uba_device *ui = qeinfo[unit]; - register volatile struct qe_softc *sc = &qe_softc[unit]; - register volatile struct qedevice *addr; - register volatile struct qe_ring *rp; + register struct qe_softc *sc = qecd.cd_devs[ifp->if_unit]; + volatile struct qedevice *addr = sc->qe_vaddr; + register struct qe_ring *rp; register index; struct mbuf *m; int buf_addr, len, s; s = splimp(); - addr = (struct qedevice *)ui->ui_addr; /* * The deqna doesn't look at anything but the valid bit * to determine if it should transmit this packet. If you have @@ -537,7 +550,7 @@ qestart(ifp) sc->setupqueued = 0; } else { IF_DEQUEUE(&sc->qe_if.if_snd, m); - if( m == 0 ){ + if (m == 0) { splx(s); return; } @@ -582,26 +595,31 @@ qestart(ifp) /* * Ethernet interface interrupt processor */ -qeintr(uba, vector, level, unit) +void +qeintr(unit) + int unit; { - register volatile struct qe_softc *sc = &qe_softc[unit]; - volatile struct qedevice *addr = - (struct qedevice *)qeinfo[unit]->ui_addr; + register struct qe_softc *sc; + volatile struct qedevice *addr; int buf_addr, csr; + sc = qecd.cd_devs[unit]; + addr = sc->qe_vaddr; splx(sc->ipl); if (!(sc->qe_flags & QEF_FASTTIMEO)) sc->qe_if.if_timer = QESLOWTIMEOUT; /* Restart timer clock */ csr = addr->qe_csr; - addr->qe_csr = QE_RCV_ENABLE | QE_INT_ENABLE | QE_XMIT_INT | QE_RCV_INT | QE_ILOOP; - if( csr & QE_RCV_INT ) - qerint( unit ); - if( csr & QE_XMIT_INT ) - qetint( unit ); - if( csr & QE_NEX_MEM_INT ) + addr->qe_csr = QE_RCV_ENABLE | QE_INT_ENABLE | + QE_XMIT_INT | QE_RCV_INT | QE_ILOOP; + if (csr & QE_RCV_INT) + qerint(unit); + if (csr & QE_XMIT_INT) + qetint(unit ); + if (csr & QE_NEX_MEM_INT) printf("qe%d: Nonexistent memory interrupt\n", unit); - if( addr->qe_csr & QE_RL_INVALID && sc->rring[sc->rindex].qe_status1 == QE_NOTYET ) { + if (addr->qe_csr & QE_RL_INVALID && sc->rring[sc->rindex].qe_status1 == + QE_NOTYET) { buf_addr = (int)&sc->rringaddr[sc->rindex]; addr->qe_rcvlist_lo = (short)buf_addr; addr->qe_rcvlist_hi = (short)(buf_addr >> 16); @@ -611,18 +629,19 @@ qeintr(uba, vector, level, unit) /* * Ethernet interface transmit interrupt. */ - +void qetint(unit) int unit; { - register volatile struct qe_softc *sc = &qe_softc[unit]; - register volatile struct qe_ring *rp; - register volatile struct ifxmt *ifxp; + register struct qe_softc *sc = qecd.cd_devs[unit]; + register struct qe_ring *rp; + register struct ifxmt *ifxp; int status1, setupflag; short len; - while( sc->otindex != sc->tindex && sc->tring[sc->otindex].qe_status1 != QE_NOTYET && sc->nxmit > 0 ) { + while (sc->otindex != sc->tindex && sc->tring[sc->otindex].qe_status1 + != QE_NOTYET && sc->nxmit > 0) { /* * Save the status words from the descriptor so that it can * be released. @@ -657,7 +676,7 @@ qetint(unit) } sc->otindex = ++sc->otindex % NXMT; } - qestart( &sc->qe_if ); + qestart(&sc->qe_if); } /* @@ -666,11 +685,12 @@ qetint(unit) * Othewise decapsulate packet based on type and pass to type specific * higher-level input routine. */ +void qerint(unit) int unit; { - register volatile struct qe_softc *sc = &qe_softc[unit]; - register volatile struct qe_ring *rp; + register struct qe_softc *sc = qecd.cd_devs[unit]; + register struct qe_ring *rp; register int nrcv = 0; int len, status1, status2; int bufaddr; @@ -708,7 +728,8 @@ qerint(unit) log(LOG_ERR, "qe%d: ring overrun, resync'd by skipping %d\n", unit, nrcv); - for( ; sc->rring[sc->rindex].qe_status1 != QE_NOTYET ; sc->rindex = ++sc->rindex % NRCV ){ + for (; sc->rring[sc->rindex].qe_status1 != QE_NOTYET; + sc->rindex = ++sc->rindex % NRCV) { rp = &sc->rring[sc->rindex]; status1 = rp->qe_status1; status2 = rp->qe_status2; @@ -725,7 +746,7 @@ qerint(unit) /* * We don't process setup packets. */ - if( !(status1 & QE_ESETUP) ) + if (!(status1 & QE_ESETUP)) qeread(sc, &sc->qe_ifr[sc->rindex], len - sizeof(struct ether_header)); } @@ -744,12 +765,13 @@ qerint(unit) /* * Process an ioctl request. */ +int qeioctl(ifp, cmd, data) register struct ifnet *ifp; - int cmd; + u_long cmd; caddr_t data; { - struct qe_softc *sc = &qe_softc[ifp->if_unit]; + struct qe_softc *sc = qecd.cd_devs[ifp->if_unit]; struct ifaddr *ifa = (struct ifaddr *)data; int s = splimp(), error = 0; @@ -782,8 +804,7 @@ qeioctl(ifp, cmd, data) case SIOCSIFFLAGS: if ((ifp->if_flags & IFF_UP) == 0 && sc->qe_flags & QEF_RUNNING) { - ((volatile struct qedevice *) - (qeinfo[ifp->if_unit]->ui_addr))->qe_csr = QE_RESET; + sc->qe_vaddr->qe_csr = QE_RESET; sc->qe_flags &= ~QEF_RUNNING; } else if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) == IFF_RUNNING && (sc->qe_flags & QEF_RUNNING) == 0) @@ -801,11 +822,12 @@ qeioctl(ifp, cmd, data) /* * set ethernet address for unit */ +void qe_setaddr(physaddr, unit) u_char *physaddr; int unit; { - register volatile struct qe_softc *sc = &qe_softc[unit]; + register struct qe_softc *sc = qecd.cd_devs[unit]; register int i; for (i = 0; i < 6; i++) @@ -820,8 +842,9 @@ qe_setaddr(physaddr, unit) /* * Initialize a ring descriptor with mbuf allocation side effects */ +void qeinitdesc(rp, addr, len) - register volatile struct qe_ring *rp; + register struct qe_ring *rp; caddr_t addr; /* mapped address */ int len; { @@ -830,7 +853,7 @@ qeinitdesc(rp, addr, len) */ bzero((caddr_t)rp, sizeof(struct qe_ring)); - if( len ) { + if (len) { rp->qe_buf_len = -(len/2); rp->qe_addr_lo = (short)((int)addr); rp->qe_addr_hi = (short)((int)addr >> 16); @@ -840,16 +863,17 @@ qeinitdesc(rp, addr, len) * Build a setup packet - the physical address will already be present * in first column. */ -qesetup( sc ) - volatile struct qe_softc *sc; +void +qesetup(sc) + struct qe_softc *sc; { register i, j; /* * Copy the target address to the rest of the entries in this row. */ - for ( j = 0; j < 6 ; j++ ) - for ( i = 2 ; i < 8 ; i++ ) + for (j = 0; j < 6; j++) + for (i = 2; i < 8; i++) sc->setup_pkt[j][i] = sc->setup_pkt[j][1]; /* * Duplicate the first half. @@ -858,7 +882,7 @@ qesetup( sc ) /* * Fill in the broadcast (and ISO multicast) address(es). */ - for ( i = 0; i < 6 ; i++ ) { + for (i = 0; i < 6; i++) { sc->setup_pkt[i][2] = 0xff; #ifdef ISO sc->setup_pkt[i][3] = all_es_snpa[i]; @@ -874,9 +898,10 @@ qesetup( sc ) * Pass a packet to the higher levels. * We deal with the trailer protocol here. */ +void qeread(sc, ifrw, len) - register volatile struct qe_softc *sc; - volatile struct ifrw *ifrw; + register struct qe_softc *sc; + struct ifrw *ifrw; int len; { struct ether_header *eh; @@ -923,9 +948,9 @@ void qetimeout(unit) int unit; { - register volatile struct qe_softc *sc; + register struct qe_softc *sc; - sc = &qe_softc[unit]; + sc = qecd.cd_devs[unit]; #ifdef notdef log(LOG_ERR, "qe%d: transmit timeout, restarted %d\n", unit, sc->qe_restarts++); @@ -935,17 +960,18 @@ qetimeout(unit) /* * Restart for board lockup problem. */ +void qerestart(sc) - register volatile struct qe_softc *sc; + struct qe_softc *sc; { register struct ifnet *ifp = (struct ifnet *)&sc->qe_if; - register volatile struct qedevice *addr = sc->addr; - register volatile struct qe_ring *rp; + register struct qedevice *addr = sc->addr; + register struct qe_ring *rp; register i; addr->qe_csr = QE_RESET; addr->qe_csr &= ~QE_RESET; - qesetup( sc ); + qesetup(sc); for (i = 0, rp = sc->tring; i < NXMT; rp++, i++) { rp->qe_flag = rp->qe_status1 = QE_NOTYET; rp->qe_valid = 0; @@ -958,18 +984,3 @@ qerestart(sc) sc->qe_flags |= QEF_RUNNING; qestart(ifp); } - -qe_match(){ - printf("qe_match\n"); - return 0; -} - -void -qe_attach(){ - printf("qe_attach\n"); -} - -struct cfdriver qecd = - { 0,"qe",qe_match, qe_attach, DV_IFNET, sizeof(struct uba_driver) }; - -#endif diff --git a/sys/arch/vax/if/if_uba.c b/sys/arch/vax/if/if_uba.c index 1ef5b3f8179..c2e012fb217 100644 --- a/sys/arch/vax/if/if_uba.c +++ b/sys/arch/vax/if/if_uba.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_uba.c,v 1.6 1995/04/11 06:19:09 mycroft Exp $ */ +/* $NetBSD: if_uba.c,v 1.7 1995/11/10 19:25:56 ragge Exp $ */ /* * Copyright (c) 1982, 1986, 1988 Regents of the University of California. @@ -46,13 +46,13 @@ #include "net/if.h" -#include "vax/include/pte.h" -#include "vax/include/mtpr.h" +#include "machine/pte.h" +#include "machine/mtpr.h" +#include "machine/vmparam.h" +#include "machine/macros.h" #include "if_uba.h" -#include "vax/include/vmparam.h" #include "vax/uba/ubareg.h" #include "vax/uba/ubavar.h" -#include "machine/macros.h" static if_ubaalloc(struct ifubinfo *, struct ifrw *, int); static rcv_xmtbuf(struct ifxmt *); @@ -78,6 +78,7 @@ if_ubaminit(ifu, uban, hlen, nmr, ifr, nr, ifw, nw) register struct ifrw *ifr; register struct ifxmt *ifw; { + struct uba_softc *ubasc; register caddr_t p; caddr_t cp; int i, nclbytes, off; @@ -108,8 +109,9 @@ if_ubaminit(ifu, uban, hlen, nmr, ifr, nr, ifw, nw) } ifu->iff_hlen = hlen; ifu->iff_uban = uban; - ifu->iff_uba = uba_hd[uban].uh_uba; - ifu->iff_ubamr = uba_hd[uban].uh_mr; + ubasc = ubacd.cd_devs[uban]; + ifu->iff_uba = ubasc->uh_uba; + ifu->iff_ubamr = ubasc->uh_mr; } for (i = 0; i < nr; i++) if (if_ubaalloc(ifu, &ifr[i], nmr) == 0) { @@ -233,7 +235,7 @@ if_ubaget(ifu, ifr, totlen, ifp) pp = mtod(m, char *); cpte = (struct pte *)kvtopte(cp); ppte = (struct pte *)kvtopte(pp); - x = vax_btop(cp - ifr->ifrw_addr); + x = btop(cp - ifr->ifrw_addr); ip = (int *)&ifr->ifrw_mr[x]; for (i = 0; i < MCLBYTES/NBPG; i++) { struct pte t; @@ -347,7 +349,7 @@ if_ubaput(ifu, ifw, m) int *ip; pte = (struct pte *)kvtopte(dp); - x = vax_btop(cp - ifw->ifw_addr); + x = btop(cp - ifw->ifw_addr); ip = (int *)&ifw->ifw_mr[x]; for (i = 0; i < MCLBYTES/NBPG; i++) *ip++ = ifw->ifw_proto | pte++->pg_pfn; diff --git a/sys/arch/vax/include/loconf.h b/sys/arch/vax/include/frame.h index 62fb2f2b802..0031315aa5d 100644 --- a/sys/arch/vax/include/loconf.h +++ b/sys/arch/vax/include/frame.h @@ -1,7 +1,6 @@ -/* $NetBSD: loconf.h,v 1.2 1994/10/26 08:02:13 cgd Exp $ */ - +/* $NetBSD: frame.h,v 1.1 1995/11/12 15:07:30 ragge Exp $ */ /* - * Copyright (c) 1994 Ludd, University of Lule}, Sweden. + * Copyright (c) 1995 Ludd, University of Lule}, Sweden. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -14,7 +13,8 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed at Ludd, University of Lule}. + * This product includes software developed at Ludd, University of + * Lule}, Sweden and its contributors. * 4. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission * @@ -30,28 +30,21 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - /* All bugs are subject to removal without further notice */ - - - - - -#define ISTACK_SIZE 4*NBPG - -/* XXX If kernel never crashes with kernel stack overflow trap - * kstack can be removed altogether. (Was 4*NBPG) +/* + * Description of calls frame on stack. This is the + * standard way of making procedure calls on vax systems. */ +struct callsframe { + unsigned int ca_cond; /* condition handler */ + unsigned int ca_maskpsw; /* register mask and saved psw */ + unsigned int ca_ap; /* argument pointer */ + unsigned int ca_fp; /* frame pointer */ + unsigned int ca_pc; /* program counter */ + unsigned int ca_argno; /* argument count on stack */ + unsigned int ca_arg1; /* first arg on stack */ + /* This can be followed by more arguments */ +}; + +/* Offset to beginning of calls frame from first arg */ +#define FRAMEOFFSET(arg1) ((struct callsframe *)((unsigned int)&(arg1) - 24)) -#define PROC_PAGES 0 - -#define MAX_UCODE 1024*1024*6 -#define MAX_UDATA 1024*1024*32 -#define MAX_USTCK 1024*1024*8 - -#define MAX_PROCESSES 32 - -#define PROCOFFSET (MAX_UCODE+MAX_UDATA+MAX_USTCK)/16384 - -/* Add 1 to USERPAGES if (MAX_PROCESSES mod 8) != 0 */ - -#define USERPAGES (MAX_UCODE+MAX_UDATA+MAX_USTCK)*MAX_PROCESSES/(512*128*128) diff --git a/sys/arch/vax/include/ka750.h b/sys/arch/vax/include/ka750.h index c6c0b494fa4..9b5f71b0745 100644 --- a/sys/arch/vax/include/ka750.h +++ b/sys/arch/vax/include/ka750.h @@ -1,4 +1,4 @@ -/* $NetBSD: ka750.h,v 1.2 1994/10/26 08:02:10 cgd Exp $ */ +/* $NetBSD: ka750.h,v 1.3 1995/11/12 14:37:20 ragge Exp $ */ /* * Copyright (c) 1994 Ludd, University of Lule}, Sweden. @@ -30,12 +30,15 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - /* All bugs are subject to removal without further notice */ - - - -/* ka750.h - definitioner enbart f|r VAX 750 940328/ragge */ +#include "machine/nexus.h" #define V750UCODE(x) ((x>>8)&255) #define V750HARDW(x) (x&255) +#define NNEX750 NNEXSBI +#define NEX750 (0xf20000) +#define NEX750SZ (NNEX750 * sizeof(struct nexus)) + +/* 11/750 specific pages needed to be stolen when bootstrapping */ +#define V750PGS 4 + diff --git a/sys/arch/vax/include/kg.h b/sys/arch/vax/include/kg.h deleted file mode 100644 index e37e6f94c2c..00000000000 --- a/sys/arch/vax/include/kg.h +++ /dev/null @@ -1,36 +0,0 @@ -/* $NetBSD: kg.h,v 1.2 1994/10/26 08:02:11 cgd Exp $ */ - -/* - * Copyright (c) 1994 Ludd, University of Lule}, Sweden. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed at Ludd, University of Lule}. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - /* All bugs are subject to removal without further notice */ - - - diff --git a/sys/arch/vax/include/nexus.h b/sys/arch/vax/include/nexus.h index a4c9a8ce678..9586ae7f41b 100644 --- a/sys/arch/vax/include/nexus.h +++ b/sys/arch/vax/include/nexus.h @@ -1,4 +1,4 @@ -/* $NetBSD: nexus.h,v 1.4 1995/02/23 17:51:42 ragge Exp $ */ +/* $NetBSD: nexus.h,v 1.5 1995/11/12 14:37:22 ragge Exp $ */ /*- * Copyright (c) 1982, 1986 The Regents of the University of California. @@ -57,14 +57,6 @@ #define NNEX780 NNEXSBI #define NEX780 ((struct nexus *)0x20000000) #endif -#if VAX750 -#define NNEX750 NNEXSBI -#ifndef ASSEMBLER -#define NEX750 ((struct nexus*)0xf20000) -#else -#define NEX750 (0xF20000) -#endif -#endif #if VAX730 #define NNEX730 NNEXSBI #define NEX730 ((struct nexus *)0xf20000) @@ -94,9 +86,10 @@ struct nexus { }; struct sbi_attach_args { - u_int nexnum; - u_int type; - void *nexaddr; + u_int nexnum; /* This nexus TR number */ + u_int type; /* This nexus type */ + int nexinfo; /* Some info sent between attach & match */ + void *nexaddr; /* Virtual address of this nexus */ }; struct iobus { @@ -177,3 +170,7 @@ extern caddr_t *nex_vec; #define NEX_MEM256U 0x72 /* 256K chips, non-interleaved, upper */ #define NEX_MEM256UI 0x73 /* 256K chips, ext-interleaved, upper */ #define NEX_MEM256I 0x74 /* 256K chips, interleaved */ + +#ifndef ASSEMBLER +struct nexus *nexus; +#endif diff --git a/sys/arch/vax/include/param.h b/sys/arch/vax/include/param.h index 208a254711a..9829484dddd 100644 --- a/sys/arch/vax/include/param.h +++ b/sys/arch/vax/include/param.h @@ -1,11 +1,9 @@ -/* $NetBSD: param.h,v 1.12 1995/08/13 00:45:21 mycroft Exp $ */ +/* $NetBSD: param.h,v 1.13 1995/12/04 22:32:53 ragge Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * - * Modified for VAX 940213/Ragge - * * This code is derived from software contributed to Berkeley by * William Jolitz. * @@ -44,15 +42,15 @@ #define _VAX_PARAM_H_ #include "machine/macros.h" -#include "psl.h" +#include "machine/psl.h" /* * Machine dependent constants for VAX. */ #define MACHINE "vax" +#define MACHINE_ARCH "vax" #define MID_MACHINE MID_VAX -#define UNIX "vmunix" /* * Round p (pointer or byte index) up to a correctly-aligned value @@ -132,6 +130,7 @@ /* clicks to bytes */ #define ctob(x) ((x) << PGSHIFT) #define btoc(x) (((x) + PGOFSET) >> PGSHIFT) +#define btop(x) (((unsigned)(x)) >> PGSHIFT) /* bytes to disk blocks */ #define btodb(x) ((x) >> DEV_BSHIFT) @@ -146,19 +145,6 @@ #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) -/* - * Mach derived conversion macros - */ - -#define vax_round_pdr(x) ((((unsigned)(x)) + NBPDR - 1) & ~(NBPDR-1)) -#define vax_trunc_pdr(x) ((unsigned)(x) & ~(NBPDR-1)) -#define vax_round_page(x) ((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1)) -#define vax_trunc_page(x) ((unsigned)(x) & ~(NBPG-1)) -#define vax_btod(x) ((unsigned)(x) >> PDRSHIFT) -#define vax_dtob(x) ((unsigned)(x) << PDRSHIFT) -#define vax_btop(x) ((unsigned)(x) >> PGSHIFT) -#define vax_ptob(x) ((unsigned)(x) << PGSHIFT) - #define splx(reg) \ ({ \ register int val; \ @@ -187,9 +173,6 @@ #define vmapbuf(p,q) #define vunmapbuf(p,q) -#if !defined(VAX630) && !defined(VAX410) -#define todr() mfpr(PR_TODR) -#endif -#define DELAY(x) {int N=todr()+(x/1000)+1;while(todr()!=N);} +#define DELAY(x) delay(x) #endif /* _VAX_PARAM_H_ */ diff --git a/sys/arch/vax/include/pmap.h b/sys/arch/vax/include/pmap.h index a753c873e51..bfc1996e920 100644 --- a/sys/arch/vax/include/pmap.h +++ b/sys/arch/vax/include/pmap.h @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.10 1995/05/11 16:53:14 jtc Exp $ */ +/* $NetBSD: pmap.h,v 1.11 1995/11/12 14:41:41 ragge Exp $ */ /* * Copyright (c) 1987 Carnegie-Mellon University @@ -83,6 +83,21 @@ typedef struct pv_entry { #define PHYS_TO_PV(phys_page) (&pv_table[((phys_page)>>PAGE_SHIFT)]) +/* ROUND_PAGE used before vm system is initialized */ +#define ROUND_PAGE(x) (((uint)(x) + PAGE_SIZE-1)& ~(PAGE_SIZE - 1)) + +/* Mapping macros used when allocating SPT */ +#define MAPVIRT(ptr, count) \ + (vm_offset_t)ptr = virtual_avail; \ + virtual_avail += (count) * NBPG; + +#define MAPPHYS(ptr, count, perm) \ + pmap_map(virtual_avail, avail_start, avail_start + \ + (count) * NBPG, perm); \ + (vm_offset_t)ptr = virtual_avail; \ + virtual_avail += (count) * NBPG; \ + avail_start += (count) * NBPG; + #ifdef _KERNEL pv_entry_t pv_table; /* array of entries, one per LOGICAL page */ diff --git a/sys/arch/vax/include/pte.h b/sys/arch/vax/include/pte.h index f99839e1931..fb5bd91a5aa 100644 --- a/sys/arch/vax/include/pte.h +++ b/sys/arch/vax/include/pte.h @@ -1,4 +1,4 @@ -/* $NetBSD: pte.h,v 1.5 1995/08/21 03:28:50 ragge Exp $ */ +/* $NetBSD: pte.h,v 1.6 1995/11/12 14:40:26 ragge Exp $ */ /* * Copyright (c) 1994 Ludd, University of Lule}, Sweden. @@ -30,10 +30,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - /* All bugs are subject to removal without further notice */ - - -#include "vax/include/param.h" +#include "machine/param.h" #ifndef ASSEMBLER @@ -41,19 +38,19 @@ * VAX page table entries */ struct pte { - unsigned int pg_pfn:21; /* Page Frame Number or 0 */ - unsigned int pg_u:1; /* Uniform bit, does WHAT?? XXX */ - unsigned int pg_w:1; /* Wired bit */ - unsigned int pg_sref:1; /* Help for ref simulation */ - unsigned int pg_ref:1; /* Simulated reference bit */ - unsigned int pg_z:1; /* Zero DIGITAL = 0 */ - unsigned int pg_m:1; /* Modify DIGITAL */ - unsigned int pg_prot:4; /* reserved at zero */ - unsigned int pg_v:1; /* valid bit */ + unsigned int pg_pfn:21; /* Page Frame Number or 0 */ + unsigned int pg_u:1; /* Uniform bit, does WHAT?? XXX */ + unsigned int pg_w:1; /* Wired bit */ + unsigned int pg_sref:1; /* Help for ref simulation */ + unsigned int pg_ref:1; /* Simulated reference bit */ + unsigned int pg_z:1; /* Zero DIGITAL = 0 */ + unsigned int pg_m:1; /* Modify DIGITAL */ + unsigned int pg_prot:4; /* reserved at zero */ + unsigned int pg_v:1; /* valid bit */ }; -typedef unsigned int pt_entry_t; /* Mach page table entry */ +typedef struct pte pt_entry_t; /* Mach page table entry */ #endif ASSEMBLER @@ -74,11 +71,7 @@ typedef unsigned int pt_entry_t; /* Mach page table entry */ #define PG_W 0x00400000 #define PG_U 0x00200000 #define PG_FRAME 0x001fffff -#define PG_SHIFT 9 -#define PG_PFNUM(x) ((x) >> PG_SHIFT) - - -#define VAX_MAX_KPTSIZE VM_KERNEL_PT_PAGES +#define PG_PFNUM(x) ((x) >> PGSHIFT) #ifndef ASSEMBLER extern pt_entry_t *Sysmap; @@ -88,8 +81,8 @@ extern pt_entry_t *Sysmap; #endif #define kvtopte(va) \ - (&Sysmap[((unsigned)(va) - KERNBASE) >> PGSHIFT]) + (&Sysmap[((unsigned)(va) & ~KERNBASE) >> PGSHIFT]) #define ptetokv(pt) \ ((((pt_entry_t *)(pt) - Sysmap) << PGSHIFT) + 0x80000000) #define kvtophys(va) \ - ((kvtopte(va)->pg_pfnum << PGSHIFT) | ((int)(va) & PGOFSET)) + (((kvtopte(va))->pg_pfn << PGSHIFT) | ((int)(va) & PGOFSET)) diff --git a/sys/arch/vax/include/scb.h b/sys/arch/vax/include/scb.h index f5663183149..6d5234088b7 100644 --- a/sys/arch/vax/include/scb.h +++ b/sys/arch/vax/include/scb.h @@ -1,4 +1,4 @@ -/* $NetBSD: scb.h,v 1.2 1994/10/26 08:02:26 cgd Exp $ */ +/* $NetBSD: scb.h,v 1.3 1995/11/12 14:38:31 ragge Exp $ */ /* * Copyright (c) 1994 Ludd, University of Lule}, Sweden. @@ -30,10 +30,10 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - /* All bugs are subject to removal without further notice */ - - struct scb { }; +#ifdef _KERNEL +extern struct scb *scb; +#endif diff --git a/sys/arch/vax/include/sid.h b/sys/arch/vax/include/sid.h index 91f89399156..2888b904525 100644 --- a/sys/arch/vax/include/sid.h +++ b/sys/arch/vax/include/sid.h @@ -1,4 +1,4 @@ -/* $NetBSD: sid.h,v 1.5 1995/02/23 17:51:44 ragge Exp $ */ +/* $NetBSD: sid.h,v 1.6 1995/11/12 14:37:18 ragge Exp $ */ /* * Copyright (c) 1994 Ludd, University of Lule}, Sweden. @@ -48,7 +48,6 @@ #define MACHID(x) ((x>>24)&255) #define V750UCODE(x) ((x>>8)&255) -#define V750HARDW(x) (cpu_type&255) /* * The MicroVAXII CPU chip (78032) is used on more than one type of system diff --git a/sys/arch/vax/include/trap.h b/sys/arch/vax/include/trap.h index b1cafc13785..2eb245a4de4 100644 --- a/sys/arch/vax/include/trap.h +++ b/sys/arch/vax/include/trap.h @@ -1,4 +1,4 @@ -/* $NetBSD: trap.h,v 1.8 1995/06/16 15:17:40 ragge Exp $ */ +/* $NetBSD: trap.h,v 1.9 1995/11/12 14:33:11 ragge Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -104,6 +104,27 @@ struct trapframe { u_int pc; /* User pc */ u_int psl; /* User psl */ }; + +/* + * This struct is used when setting up interrupt vectors dynamically. + * It pushes a longword between 0-63 on the stack; this number is + * normally used as the ctlr number on devices. This use effectively + * limits the number of interruptable ctlrs on the unibus to 64. + */ +struct ivec_dsp { + char pushr; /* pushr */ + char pushrarg; /* $3f */ + char pushl; /* pushl */ + char pushlarg; /* $? */ + char nop; /* nop, for foolish gcc */ + char calls[3]; /* calls $1,? */ + u_int hoppaddr; /* jump for calls */ + char popr; /* popr $0x3f */ + char poprarg; + char rei; /* rei */ + char pad; /* sizeof(struct ivec_dsp) == 16 */ +}; + #endif /* ASSEMBLER */ #endif _VAX_TRAP_H_ diff --git a/sys/arch/vax/include/types.h b/sys/arch/vax/include/types.h index dbf36014062..89497fc4862 100644 --- a/sys/arch/vax/include/types.h +++ b/sys/arch/vax/include/types.h @@ -1,4 +1,4 @@ -/* $NetBSD: types.h,v 1.5 1995/07/06 03:39:45 cgd Exp $ */ +/* $NetBSD: types.h,v 1.6 1995/12/09 04:41:57 mycroft Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -73,5 +73,6 @@ typedef unsigned long long u_int64_t; typedef int32_t register_t; #define __BDEVSW_DUMP_OLD_TYPE +#define __FORK_BRAINDAMAGE #endif /* _MACHTYPES_H_ */ diff --git a/sys/arch/vax/uba/tmscp.c b/sys/arch/vax/uba/tmscp.c index 5a7cbb47d99..03960efd58d 100644 --- a/sys/arch/vax/uba/tmscp.c +++ b/sys/arch/vax/uba/tmscp.c @@ -1,4 +1,4 @@ -/* $NetBSD: tmscp.c,v 1.4.2.1 1995/10/15 13:57:40 ragge Exp $ */ +/* $NetBSD: tmscp.c,v 1.6 1995/11/30 00:59:29 jtc Exp $ */ /*- * Copyright (c) 1991 The Regents of the University of California. @@ -192,6 +192,8 @@ #include "vax/vax/tmscpinf.h" #include "vax/vax/mscpvar.h" +void tmscpstrategy __P((struct buf *)); + /* Software state per controller */ struct tmscp_softc { @@ -312,7 +314,7 @@ struct uba_driver tmscpdriver = /*************************************************************************/ #define DELAYTEN 1000 - +extern struct cfdriver ubacd; /* * Unfortunately qbgetpri can't be used because the TK50 doesn't flip the @@ -330,6 +332,7 @@ tmscpprobe(reg, ctlr, um) /* ptr to software controller structure */ volatile struct tmscpdevice *tmscpaddr; int count; /* for probe delay time out */ + struct uba_softc *ubasc; # ifdef lint br = 0; cvec = br; br = cvec; reg = reg; @@ -344,7 +347,8 @@ tmscpprobe(reg, ctlr, um) * The device is not really initialized at this point, this is just to * find out if the device exists. */ - sc->sc_ivec = (uba_hd[numuba].uh_lastiv -= 4); + ubasc = ubacd.cd_devs[0]; /* XXX */ + sc->sc_ivec = (ubasc->uh_lastiv -= 4); tmscpaddr->tmscpip = 0; count=0; @@ -487,7 +491,7 @@ tmscpattach (ui) /* * TMSCP interrupt routine. */ -tmscpintr(uba,vector,level,d) +tmscpintr(d) { volatile struct uba_ctlr *um = tmscpminfo[d]; volatile struct tmscpdevice *tmscpaddr = @@ -1360,6 +1364,7 @@ tmscprsp(um, tm, sc, i) struct uba_device *ui; struct buf *dp, *bp; int st; + struct uba_softc *ubasc; mp = &tm->tmscp_rsp[i]; mp->mscp_header.tmscp_msglen = mscp_msglen; @@ -1543,6 +1548,7 @@ tmscprsp(um, tm, sc, i) panic("tmscp: don't work2!"); dp->b_actf = bp->b_actf; # if defined(VAX750) + ubasc = ubacd.cd_devs[um->um_ubanum]; if (cpunumber == VAX_750) { if ((tmscpwtab[um->um_ctlr].b_actf == NULL) && (um->um_ubinfo != 0)) { @@ -1551,7 +1557,7 @@ tmscprsp(um, tm, sc, i) else { if (mp->mscp_opcode == (M_OP_READ|M_OP_END) || mp->mscp_opcode == (M_OP_WRITE|M_OP_END)) - UBAPURGE(uba_hd[um->um_ubanum].uh_uba,(um->um_ubinfo >>28) & 0x0f); + UBAPURGE(ubasc->uh_uba,(um->um_ubinfo >>28) & 0x0f); } } # endif @@ -1704,7 +1710,6 @@ errinfo(st) /* * Manage buffers and perform block mode read and write operations. */ - void tmscpstrategy (bp) register struct buf *bp; @@ -1819,7 +1824,7 @@ tmscpdump(dev) ui = phys(struct uba_device *, tmsdinfo[unit]); if (ui->ui_alive == 0) return (ENXIO); - uba = phys(struct uba_hd *, ui->ui_hd)->uh_physuba; + uba = phys(struct uba_softc *, ui->ui_hd)->uh_physuba; ubainit(uba); tmscpaddr = (struct tmscpdevice *)ui->ui_physaddr; DELAY(2000000); diff --git a/sys/arch/vax/uba/uba.c b/sys/arch/vax/uba/uba.c index 6f3d9c9eb5e..e9ac5bf5014 100644 --- a/sys/arch/vax/uba/uba.c +++ b/sys/arch/vax/uba/uba.c @@ -1,4 +1,4 @@ -/* $NetBSD: uba.c,v 1.8 1995/06/16 15:26:11 ragge Exp $ */ +/* $NetBSD: uba.c,v 1.10 1995/12/01 19:22:56 ragge Exp $ */ /* * Copyright (c) 1982, 1986 The Regents of the University of California. @@ -37,8 +37,6 @@ * @(#)autoconf.c 7.20 (Berkeley) 5/9/91 */ - /* All bugs are subject to removal without further notice */ - #include "sys/param.h" #include "sys/types.h" #include "sys/time.h" @@ -53,34 +51,38 @@ #include "sys/malloc.h" #include "sys/device.h" +#include "vm/vm.h" +#include "vm/vm_kern.h" + #include "machine/pte.h" #include "machine/cpu.h" #include "machine/mtpr.h" #include "machine/nexus.h" #include "machine/sid.h" -#if VAX630 -#include "machine/uvaxII.h" -#endif -#include "uba.h" +#include "machine/scb.h" +#include "machine/trap.h" +#include "machine/frame.h" + #include "ubareg.h" #include "ubavar.h" -int (*vekmatris[NUBA][128])(); -int interinfo[NUBA][128]; int dkn; extern int cold; -struct uba_hd uba_hd[NUBA]; -/* F|r att f} genom kompilatorn :( Nollpekare f|r interrupt... */ -int cvec=0; volatile int rbr,rcvec; -#if VAX630 || VAX410 -extern struct uvaxIIcpu *uvaxIIcpu_ptr; -#endif -#if VAX630 -extern struct ka630clock *ka630clk_ptr; -#endif +int uba_match __P((struct device *, void *, void *)); +void uba_attach __P((struct device *, struct device *, void *)); +void ubascan __P((struct device *, void *)); +int ubaprint __P((void *, char *)); + +struct cfdriver ubacd = { + NULL, "uba", uba_match, uba_attach, DV_DULL, + sizeof(struct uba_softc), 1 +}; + + +#ifdef 0 /* * Mark addresses starting at "addr" and continuing * "size" bytes as allocated in the map "ualloc". @@ -105,46 +107,27 @@ csralloc(ualloc, addr, size) *p = 1; } } - -/* - * Make an IO register area accessible at physical address physa - * by mapping kernel ptes starting at pte. - */ -ioaccess(physa, pte, size) - u_int physa; - u_int *pte; - u_int size; -{ - u_int i = (size>>PG_SHIFT); - u_int v = (physa>>PG_SHIFT); - - do { - *pte = PG_V|PG_KW|v; - pte++; - v++; - } while (--i > 0); - mtpr(0, PR_TBIA); -} - -/* - * General uba interrupt handler. - */ -ubainterrupt(level, uba,vektor){ -/*printf("ubainterrupt: level %x, uba %x, vektor %x\n",level, uba,vektor); */ - (*vekmatris[uba][vektor])(vektor,level,uba,interinfo[uba][vektor]); -} - +#endif /* * Stray interrupt vector handler, used when nowhere else to * go to. */ -ubastray(vektor, level,uba){ +void +ubastray(arg) + int arg; +{ + struct callsframe *cf = FRAMEOFFSET(arg); + struct uba_softc *sc = ubacd.cd_devs[arg]; + int vektor; + + vektor = (cf->ca_pc - (unsigned)&sc->uh_idsp[0]) >> 4; + if(cold){ - rbr=level; - rcvec=vektor; + rbr = mfpr(PR_IPL); + rcvec = vektor; } else { - printf("uba%d: unexpected interrupt at vector %d on level %d", - uba, vektor, level); + printf("uba%d: unexpected interrupt, vector %o, level %d", + arg, vektor << 2, mfpr(PR_IPL)); } } @@ -153,28 +136,25 @@ ubastray(vektor, level,uba){ * Uses per-driver routine to set <br,cvec> into <r11,r10>, * and then fills in the tables, with help from a per-driver * slave initialization routine. - * - * Changed this ugly written code assuming special registers - * from the C compiler :( 940516/ragge */ unifind(uhp0, pumem) - struct uba_hd *uhp0; + struct uba_softc *uhp0; caddr_t pumem; { register struct uba_device *ui; register struct uba_ctlr *um; - register struct uba_hd *uhp = uhp0; + register struct uba_softc *uhp = uhp0; u_short *reg, *ap, addr; struct uba_driver *udp; - int i, (*ivec)(); + int i; caddr_t ualloc; volatile extern int br, cvec; volatile extern int rbr, rcvec; #if DW780 || DWBUA struct uba_regs *vubp = uhp->uh_uba; #endif - +#if 0 /* * Initialize the UNIBUS, by freeing the map * registers and the buffered data path registers @@ -188,21 +168,6 @@ unifind(uhp0, pumem) ubainitmaps(uhp); /* - * Initialize space for the UNIBUS interrupt vectors. - * On the 8600, can't use first slot in UNIvec - * (the vectors for the second SBI overlap it); - * move each set of vectors forward. - */ -#if VAX8600 - if (cpu == VAX_8600) - uhp->uh_vec = UNIvec[numuba + 1]; - else -#endif - uhp->Nuh_vec = vekmatris[numuba]; - for (i = 0; i < 128; i++) - uhp->Nuh_vec[i] = ubastray; - - /* * Set last free interrupt vector for devices with * programmable interrupt vectors. Use is to decrement * this number and use result as interrupt vector. @@ -224,7 +189,7 @@ unifind(uhp0, pumem) * First configure devices that have unibus memory, * allowing them to allocate the correct map registers. */ - ubameminit(numuba); + ubameminit(uhp->uh_dev.dv_unit); /* * Grab some memory to record the umem address space we allocate, * so we can be sure not to place two devices at the same address. @@ -248,7 +213,7 @@ unifind(uhp0, pumem) * output to produce an interrupt. */ *(int *)(&uhp->uh_mr[0]) = UBAMR_MRV; - +#endif #define ubaddr(uhp, off) (u_short *)((int)(uhp)->uh_iopage + ubdevreg(off)) /* * Check each unibus mass storage controller. @@ -257,8 +222,8 @@ unifind(uhp0, pumem) * then go looking for slaves. */ for (um = ubminit; udp = um->um_driver; um++) { - if (um->um_ubanum != numuba && um->um_ubanum != '?' || - um->um_alive) + if (um->um_ubanum != uhp->uh_dev.dv_unit && + um->um_ubanum != '?' || um->um_alive) continue; addr = (u_short)(u_long)um->um_addr; /* @@ -268,9 +233,10 @@ unifind(uhp0, pumem) * in the driver til we find it */ for (ap = udp->ud_addr; addr || (addr = *ap++); addr = 0) { - +#if 0 if (ualloc[ubdevreg(addr)]) continue; +#endif reg = ubaddr(uhp, addr); if (badaddr((caddr_t)reg, 2)) @@ -282,7 +248,6 @@ unifind(uhp0, pumem) continue; } #endif - cvec = 0x200; rcvec = 0x200; i = (*udp->ud_probe)(reg, um->um_ctlr, um); #ifdef DW780 @@ -294,7 +259,7 @@ unifind(uhp0, pumem) if (i == 0) continue; printf("%s%d at uba%d csr %o ", - udp->ud_mname, um->um_ctlr, numuba, addr); + udp->ud_mname, um->um_ctlr, uhp->uh_dev.dv_unit, addr); if (rcvec == 0) { printf("zero vector\n"); continue; @@ -303,21 +268,24 @@ unifind(uhp0, pumem) printf("didn't interrupt\n"); continue; } - interinfo[numuba][rcvec]=um->um_ctlr; - printf("vec %o, ipl %x\n", rcvec, rbr); + printf("vec %o, ipl %x\n", rcvec << 2, rbr); +#if 0 csralloc(ualloc, addr, i); +#endif um->um_alive = 1; - um->um_ubanum = numuba; + um->um_ubanum = uhp->uh_dev.dv_unit; um->um_hd = uhp; um->um_addr = (caddr_t)reg; udp->ud_minfo[um->um_ctlr] = um; - uhp->Nuh_vec[rcvec] = um->um_intr; + uhp->uh_idsp[rcvec].hoppaddr = um->um_intr; + uhp->uh_idsp[rcvec].pushlarg = um->um_ctlr; for (ui = ubdinit; ui->ui_driver; ui++) { int t; if (ui->ui_driver != udp || ui->ui_alive || ui->ui_ctlr != um->um_ctlr && ui->ui_ctlr != '?' || - ui->ui_ubanum != numuba && ui->ui_ubanum != '?') + ui->ui_ubanum != uhp->uh_dev.dv_unit && + ui->ui_ubanum != '?') continue; t = ui->ui_ctlr; ui->ui_ctlr = um->um_ctlr; @@ -325,7 +293,7 @@ unifind(uhp0, pumem) ui->ui_ctlr = t; else { ui->ui_alive = 1; - ui->ui_ubanum = numuba; + ui->ui_ubanum = uhp->uh_dev.dv_unit; ui->ui_hd = uhp; ui->ui_addr = (caddr_t)reg; ui->ui_physaddr = pumem + ubdevreg(addr); @@ -346,100 +314,9 @@ unifind(uhp0, pumem) break; } } - /* - * Now look for non-mass storage peripherals. - */ - for (ui = ubdinit; udp = ui->ui_driver; ui++) { - if (ui->ui_ubanum != numuba && ui->ui_ubanum != '?' || - ui->ui_alive || ui->ui_slave != -1) - continue; - addr = (u_short)(u_long)ui->ui_addr; - - for (ap = udp->ud_addr; addr || (addr = *ap++); addr = 0) { - - if (ualloc[ubdevreg(addr)]) - continue; - reg = ubaddr(uhp, addr); - if (badaddr((caddr_t)reg, 2)) - continue; -#ifdef DW780 - if (uhp->uh_type == DW780 && vubp->uba_sr) { - vubp->uba_sr = vubp->uba_sr; - continue; - } -#endif - rcvec = 0x200; - cvec = 0x200; - i = (*udp->ud_probe)(reg, ui); -#ifdef DW780 - if (uhp->uh_type == DW780 && vubp->uba_sr) { - vubp->uba_sr = vubp->uba_sr; - continue; - } -#endif - if (i == 0) - continue; - printf("%s%d at uba%d csr %o ", - ui->ui_driver->ud_dname, ui->ui_unit, numuba, addr); - if (rcvec == 0) { - printf("zero vector\n"); - continue; - } - if (rcvec == 0x200) { - printf("didn't interrupt\n"); - continue; - } - interinfo[numuba][rcvec]=ui->ui_unit; - printf("vec %o, ipl %x\n", rcvec, rbr); - csralloc(ualloc, addr, i); - ui->ui_hd = uhp; - uhp->Nuh_vec[rcvec] = ui->ui_intr; - ui->ui_alive = 1; - ui->ui_ubanum = numuba; - ui->ui_addr = (caddr_t)reg; - ui->ui_physaddr = pumem + ubdevreg(addr); - ui->ui_dk = -1; - /* ui_type comes from driver */ - udp->ud_dinfo[ui->ui_unit] = ui; - (*udp->ud_attach)(ui); - break; - } - } - -#ifdef DW780 - if (uhp->uh_type == DW780) - uhp->uh_uba->uba_cr = UBACR_IFS | UBACR_BRIE | - UBACR_USEFIE | UBACR_SUEFIE | - (uhp->uh_uba->uba_cr & 0x7c000000); -#endif - numuba++; - -#ifdef AUTO_DEBUG - printf("Unibus allocation map"); - for (i = 0; i < 8*1024; ) { - register n, m; - - if ((i % 128) == 0) { - printf("\n%6o:", i); - for (n = 0; n < 128; n++) - if (ualloc[i+n]) - break; - if (n == 128) { - i += 128; - continue; - } - } - - for (n = m = 0; n < 16; n++) { - m <<= 1; - m |= ualloc[i++]; - } - - printf(" %4x", m); - } - printf("\n"); -#endif +#if 0 free(ualloc, M_TEMP); +#endif } @@ -470,11 +347,11 @@ ubaqueue(ui, onq) int onq; { register struct uba_ctlr *um = ui->ui_mi; - register struct uba_hd *uh; + register struct uba_softc *uh; register struct uba_driver *ud; register int s, unit; - uh = &uba_hd[um->um_ubanum]; + uh = ubacd.cd_devs[um->um_ubanum]; ud = um->um_driver; s = spluba(); /* @@ -530,9 +407,9 @@ rwait: } ubadone(um) - register struct uba_ctlr *um; + struct uba_ctlr *um; { - register struct uba_hd *uh = &uba_hd[um->um_ubanum]; + struct uba_softc *uh = ubacd.cd_devs[um->um_ubanum]; if (um->um_driver->ud_xclu) uh->uh_xclu = 0; @@ -549,8 +426,11 @@ ubadone(um) * Return value encodes map register plus page offset, * bdp number and number of map registers. */ -ubasetup(int uban,struct buf *bp,int flags) { - struct uba_hd *uh = &uba_hd[uban]; +ubasetup(uban, bp, flags) + struct buf *bp; + int uban, flags; +{ + struct uba_softc *uh = ubacd.cd_devs[uban]; struct pte *pte, *io; int npf; int pfnum, temp; @@ -611,32 +491,33 @@ ubasetup(int uban,struct buf *bp,int flags) { temp |= UBAMR_BO; if ((bp->b_flags & B_PHYS) == 0) pte = (struct pte *)kvtopte(bp->b_un.b_addr); - else if (bp->b_flags & B_PAGET) { - panic("ubasetup: B_PAGET"); - } else { - if( bp->b_flags&B_DIRTY){ - rp=&pageproc[2]; - panic("ubasetup: B_DIRTY"); - } else { - rp =bp->b_proc; - } - v = vax_btop((u_int)bp->b_un.b_addr&0x3fffffff); - if (bp->b_flags & B_UAREA){ - panic("ubasetup: B_UAREA"); - } else { -/* - * It may be better to use pmap_extract() here somewhere, - * but so far we do it "the hard way" :) - */ - u_int *hej; + else { + u_int *hej, i; - if(((u_int)bp->b_un.b_addr<0x40000000)|| - ((u_int)bp->b_un.b_addr>0x7fffffff)){ - hej=rp->p_vmspace->vm_pmap.pm_pcb->P0BR; - } else { - hej=rp->p_vmspace->vm_pmap.pm_pcb->P1BR; + rp = bp->b_proc; + v = btop((u_int)bp->b_un.b_addr&0x3fffffff); + + /* + * It may be better to use pmap_extract() here + * somewhere, but so far we do it "the hard way" :) + */ + if (((u_int)bp->b_un.b_addr < 0x40000000) || + ((u_int)bp->b_un.b_addr > 0x7fffffff)) + hej = rp->p_vmspace->vm_pmap.pm_pcb->P0BR; + else + hej = rp->p_vmspace->vm_pmap.pm_pcb->P1BR; + + pte = (struct pte *)&hej[v]; + for (i = 0; i < (npf - 1); i++) { + if ((pte + i)->pg_pfn == 0) { + int rv; + + rv = vm_fault(&rp->p_vmspace->vm_map, + (u_int)bp->b_un.b_addr + i * NBPG, + VM_PROT_READ, FALSE); + if (rv) + panic("DMA to nonexistent page"); } - pte=(struct pte*)&hej[v]; } } io = &uh->uh_mr[reg]; @@ -654,7 +535,10 @@ ubasetup(int uban,struct buf *bp,int flags) { /* * Non buffer setup interface... set up a buffer and call ubasetup. */ -uballoc(int uban,caddr_t addr,int bcnt,int flags) { +uballoc(uban, addr, bcnt, flags) + caddr_t addr; + int uban, bcnt, flags; +{ struct buf ubabuf; ubabuf.b_un.b_addr = addr; @@ -670,9 +554,9 @@ uballoc(int uban,caddr_t addr,int bcnt,int flags) { * against uba resets on 11/780's. */ ubarelse(uban, amr) - int *amr; + int uban, *amr; { - register struct uba_hd *uh = &uba_hd[uban]; + register struct uba_softc *uh = ubacd.cd_devs[uban]; register int bdp, reg, npf, s; int mr; @@ -747,7 +631,7 @@ sdjhfgsadjkfhgasj ubapurge(um) register struct uba_ctlr *um; { - register struct uba_hd *uh = um->um_hd; + register struct uba_softc *uh = um->um_hd; register int bdp = UBAI_BDP(um->um_ubinfo); switch (uh->uh_type) { @@ -772,7 +656,7 @@ ubapurge(um) } ubainitmaps(uhp) - register struct uba_hd *uhp; + register struct uba_softc *uhp; { if (uhp->uh_memsize > UBA_MAXMR) @@ -808,7 +692,7 @@ ubareset(uban) int uban; { register struct cdevsw *cdp; - register struct uba_hd *uh = &uba_hd[uban]; + register struct uba_softc *uh = ubacd.cd_devs[uban]; int s; s = spluba(); @@ -822,14 +706,18 @@ ubareset(uban) wakeup((caddr_t)&uh->uh_bdpwant); wakeup((caddr_t)&uh->uh_mrwant); printf("uba%d: reset", uban); - ubainit(uh->uh_uba); + ubainit(uh); +#ifdef notyet ubameminit(uban); -/* XXX Intressant, vi m}ste l|sa det h{r med ubareset() p} n}t smart - * s{tt. En l{nkad lista som s{tts upp vid autoconfiggen? Kanske. - * N{r anv{nds dom? Jag vet faktiskt inte; det verkar vara en - * ren sm|rja den gamla koden. F}r peturba lite mer docs... - * 950428/Ragge - */ +#endif + /* XXX - ??? + * Intressant, vi m}ste l|sa det h{r med ubareset() p} n}t smart + * s{tt. En l{nkad lista som s{tts upp vid autoconfiggen? Kanske. + * N{r anv{nds dom? Jag vet faktiskt inte; det verkar vara en + * ren sm|rja den gamla koden. F}r peturba lite mer docs... + * 950428/Ragge + */ + udareset(0); /* XXX */ /* for (cdp = cdevsw; cdp < cdevsw + nchrdev; cdp++) (*cdp->d_reset)(uban); ifubareset(uban); @@ -845,37 +733,17 @@ ubareset(uban) * In these cases we really don't need the interrupts * enabled, but since we run with ipl high, we don't care * if they are, they will never happen anyways. - * SHOULD GET POINTER TO UBA_HD INSTEAD OF UBA. */ -ubainit(uba) - register struct uba_regs *uba; +void +ubainit(uhp) + struct uba_softc *uhp; { - register struct uba_hd *uhp; -#ifdef QBA - int isphys = 0; -#endif - - for (uhp = uba_hd; uhp < uba_hd + numuba; uhp++) { - if (uhp->uh_uba == uba) - break; - if (uhp->uh_physuba == uba) { -#ifdef QBA - isphys++; -#endif - break; - } - } - if (uhp >= uba_hd + numuba) { - printf("init unknown uba\n"); - return; - } - switch (uhp->uh_type) { #ifdef DWBUA case DWBUA: BUA(uba)->bua_csr |= BUACSR_UPI; /* give devices time to recover from power fail */ - waitabit(500); + DELAY(500000); break; #endif #ifdef DW780 @@ -898,22 +766,18 @@ ubainit(uba) #if DW750 || DW730 || QBA mtpr(0, PR_IUR); /* give devices time to recover from power fail */ -#if 0 + /* THIS IS PROBABLY UNNECESSARY */ - waitabit(50); + DELAY(500000); /* END PROBABLY UNNECESSARY */ -#endif + #ifdef QBA /* * Re-enable local memory access * from the Q-bus. */ - if (uhp->uh_type == QBA) { - if (isphys) - *((char *)QIOPAGE630 + QIPCR) = Q_LMEAE; - else - *(uhp->uh_iopage + QIPCR) = Q_LMEAE; - } + if (uhp->uh_type == QBA) + *((u_short *)(uhp->uh_iopage + QIPCR)) = Q_LMEAE; #endif QBA break; #endif DW750 || DW730 || QBA @@ -933,6 +797,8 @@ qbgetpri() int pri; extern int cvec; + panic("qbgetpri"); +#if 0 for (pri = 0x17; pri > 0x14; ) { if (cvec && cvec != 0x200) /* interrupted at pri */ break; @@ -941,6 +807,7 @@ qbgetpri() } (void) spl0(); return (pri); +#endif } #endif @@ -959,7 +826,7 @@ int zvcnt_max = 5000; /* in 8 sec */ /*ARGSUSED*/ ubaerror(uban, uh, ipl, uvec, uba) register int uban; - register struct uba_hd *uh; + register struct uba_softc *uh; int ipl, uvec; register struct uba_regs *uba; { @@ -1024,13 +891,15 @@ ubaerror(uban, uh, ipl, uvec, uba) * configured (has no csr or interrupt, so doesn't need to be probed), * and -1 on failure. */ +#ifdef notyet ubameminit(uban) { register struct uba_device *ui; - register struct uba_hd *uh = &uba_hd[uban]; - caddr_t umembase = Tumem(uban) + 0x3e000, addr; + register struct uba_softc *uh = ubacd.cd_devs[uban]; + caddr_t umembase, addr; #define ubaoff(off) ((int)(off) & 0x1fff) + umembase = uh->uh_iopage; uh->uh_lastmem = 0; for (ui = ubdinit; ui->ui_driver; ui++) { if (ui->ui_ubanum != uban && ui->ui_ubanum != '?') @@ -1062,12 +931,13 @@ jdhfgsjdkfhgsdjkfghak if (uh->uh_type == DW780) { register i; - i = vax_btop(((uh->uh_lastmem + 8191) / 8192) * 8192); + i = btop(((uh->uh_lastmem + 8191) / 8192) * 8192); while (i) (void) rmget(uh->uh_map, 1, i--); } #endif } +#endif rmget(){ showstate(curproc); @@ -1088,7 +958,7 @@ rmget(){ ubamem(uban, addr, npg, doalloc) int uban, addr, npg, doalloc; { - register struct uba_hd *uh = &uba_hd[uban]; + register struct uba_softc *uh = ubacd.cd_devs[uban]; register int a; int s; @@ -1158,39 +1028,34 @@ resuba() } int -uba_match(parent, cf, aux) +uba_match(parent, vcf, aux) struct device *parent; - struct cfdata *cf; - void *aux; + void *vcf, *aux; { - struct sbi_attach_args *sa=(struct sbi_attach_args *)aux; - extern int numuba; - int ubanr; + struct sbi_attach_args *sa = (struct sbi_attach_args *)aux; + struct cfdata *cf = vcf; -#if VAX630 - /* - * The MicroVAXII always has a single QBA. - */ - if (cpu_type == VAX_630) - if (numuba == 0) - return 1; - else - return 0; -#endif - if(numuba) return 0; - if((cf->cf_loc[0]!=sa->nexnum)&&(cf->cf_loc[0]>-1)) - return 0; /* UBA doesn't match spec's */ + if ((cf->cf_loc[0] != sa->nexnum) && (cf->cf_loc[0] > -1 )) + return 0; - switch(sa->type){ + switch (sa->type) { case NEX_UBA0: + sa->nexinfo = 0; + break; case NEX_UBA1: + sa->nexinfo = 1; + break; case NEX_UBA2: + sa->nexinfo = 2; + break; case NEX_UBA3: - return 1; + sa->nexinfo = 3; + break; default: return 0; } + return 1; } void @@ -1198,97 +1063,207 @@ uba_attach(parent, self, aux) struct device *parent, *self; void *aux; { - struct sbi_attach_args *sa=(struct sbi_attach_args *)aux; - extern struct uba_hd uba_hd[]; - struct uba_regs *ubar=(struct uba_regs *)sa->nexaddr; - struct uba_hd *uhp = &uba_hd[numuba]; + struct sbi_attach_args *sa = (struct sbi_attach_args *)aux; + struct uba_regs *ubar = (struct uba_regs *)sa->nexaddr; + struct uba_softc *sc = (struct uba_softc *)self; + vm_offset_t min, max, ubaphys, ubaiophys; +#if DW780 || DWBUA + struct uba_regs *vubp = sc->uh_uba; +#endif void ubascan(); printf("\n"); + /* + * Allocate place for unibus memory in virtual space. + * This is done with kmem_suballoc() but after that + * never used in the vm system. Is it OK to do so? + */ + (void)kmem_suballoc(kernel_map, &min, &max, + (UBAPAGES + UBAIOPAGES) * NBPG, FALSE); + sc->uh_mem = (caddr_t)min; + sc->uh_uba = (void*)ubar; + sc->uh_memsize = UBAPAGES; + sc->uh_iopage = (void *)min + (sc->uh_memsize * NBPG); + sc->uh_iarea = (void *)scb + NBPG + sa->nexinfo * NBPG; + /* + * Create interrupt dispatchers for this uba. + */ +#define NO_IVEC 128 + { + vm_offset_t iarea; + extern struct ivec_dsp idsptch; + int i; + + iarea = kmem_alloc(kernel_map, + NO_IVEC * sizeof(struct ivec_dsp)); + sc->uh_idsp = (struct ivec_dsp *)iarea; + + for (i = 0; i < NO_IVEC; i++) { + bcopy(&idsptch, &sc->uh_idsp[i], + sizeof(struct ivec_dsp)); + sc->uh_idsp[i].pushlarg = sa->nexinfo; + sc->uh_idsp[i].hoppaddr = ubastray; + sc->uh_iarea[i] = (unsigned int)&sc->uh_idsp[i]; + } + } + switch (cpunumber) { #if VAX750 case VAX_750: - uhp->uh_mr = (void *)ubar->uba_map; - uhp->uh_type = DW750; - uhp->uh_uba = (void*)ubar; - uhp->uh_physuba = (void*)0xf20000+sa->nexnum*0x2000; - uhp->uh_memsize = UBAPAGES; - uhp->uh_mem = Tumem(numuba); - uhp->uh_iopage = Tumem(numuba) + (uhp->uh_memsize * NBPG); - ioaccess(UMEM750(numuba), UMEMmap[numuba], (UBAPAGES+UBAIOPAGES)*NBPG); -/* Now everything should be set up (I hope...) */ -#ifdef notyet - config_scan(ubascan,self); - -#else - unifind(uhp, UMEM750(numuba) + (uhp->uh_memsize * NBPG)); -#endif - break; + sc->uh_mr = (void *)ubar->uba_map; + sc->uh_type = DW750; + sc->uh_physuba = (struct uba_regs *)kvtophys(sa->nexaddr); + ubaphys = UMEM750(sa->nexinfo); + ubaiophys = UMEM750(sa->nexinfo) + (UBAPAGES * NBPG); + break; #endif #if VAX630 || VAX410 case VAX_78032: - switch (cpu_type) { + switch (cpu_type) { #if VAX630 - case VAX_630: - uhp->uh_mr = (void *)sa->nexaddr; - uhp->uh_type = QBA; - uhp->uh_uba = (void*)ubar; - uhp->uh_physuba = (void*)QBAMAP630; - uhp->uh_memsize = QBAPAGES; - uhp->uh_mem = Numem; - uhp->uh_iopage = Numem + (uhp->uh_memsize * NBPG); - - /* - * For the MicroVAXII, the qbus address space is not contiguous - * in physical address space. I also map the page that has the - * memory error registers and the watch chip here and init them, - * for want of a better place to do it. - */ - ioaccess(QMEM630, UMEMmap[0], QBAPAGES * NBPG); - ioaccess(QIOPAGE630, UMEMmap[0] + QBAPAGES, UBAIOPAGES * NBPG); - ioaccess(UVAXIICPU, UMEMmap[0] + QBAPAGES + UBAIOPAGES, NBPG); - uvaxIIcpu_ptr = - (struct uvaxIIcpu *)(Numem+(QBAPAGES+UBAIOPAGES)*NBPG); - ioaccess(KA630CLK,UMEMmap[0] + QBAPAGES + UBAIOPAGES + 1,NBPG); - ka630clk_ptr = - (struct ka630clock *)(Numem+(QBAPAGES+UBAIOPAGES+1)*NBPG); + case VAX_630: + sc->uh_mr = (void *)sa->nexaddr; + sc->uh_type = QBA; + sc->uh_physuba = (void*)QBAMAP630; + ubaphys = QMEM630; + ubaiophys = QIOPAGE630; + break; +#endif + }; + break; +#endif + }; + /* + * Map uba space in kernel virtual; especially i/o space. + */ + pmap_map(min, ubaphys, ubaphys + (UBAPAGES * NBPG), + VM_PROT_READ|VM_PROT_WRITE); + pmap_map(min + (UBAPAGES * NBPG), ubaiophys, ubaiophys + + (UBAIOPAGES * NBPG), VM_PROT_READ|VM_PROT_WRITE); +#if VAX630 + /* Enable access to local memory. */ + if (cpu_type == VAX_630) + *((u_short *)(sc->uh_iopage + QIPCR)) = Q_LMEAE; +#endif + /* + * Initialize the UNIBUS, by freeing the map + * registers and the buffered data path registers + */ + sc->uh_map = (struct map *)malloc((u_long) + (UAMSIZ * sizeof(struct map)), M_DEVBUF, M_NOWAIT); + bzero((caddr_t)sc->uh_map, (unsigned)(UAMSIZ * sizeof (struct map))); + ubainitmaps(sc); - /* - * Clear restart and boot in progress flags in the CPMBX. - */ - ka630clk_ptr->cpmbx = (ka630clk_ptr->cpmbx & KA630CLK_LANG); + /* + * Set last free interrupt vector for devices with + * programmable interrupt vectors. Use is to decrement + * this number and use result as interrupt vector. + */ + sc->uh_lastiv = 0x200; - /* - * Enable memory parity error detection and clear error bits. - */ - uvaxIIcpu_ptr->uvaxII_mser = (UVAXIIMSER_PEN|UVAXIIMSER_MERR| - UVAXIIMSER_LEB); +#ifdef DWBUA + if (uhp->uh_type == DWBUA) + BUA(vubp)->bua_offset = (int)uhp->uh_vec - (int)&scb[0]; +#endif - /* - * Now that QBus space is mapped, set the local memory external - * access enable. - */ - *((u_short *)(uhp->uh_iopage + QIPCR)) = Q_LMEAE; -/* Now everything should be set up (I hope...) */ +#ifdef DW780 + if (uhp->uh_type == DW780) { + vubp->uba_sr = vubp->uba_sr; + vubp->uba_cr = UBACR_IFS|UBACR_BRIE; + } +#endif #ifdef notyet - config_scan(ubascan,self); + /* + * First configure devices that have unibus memory, + * allowing them to allocate the correct map registers. + */ + ubameminit(uhp->uh_dev.dv_unit); +#endif + /* + * Map the first page of UNIBUS i/o space to the first page of memory + * for devices which will need to dma output to produce an interrupt. + * ??? - Why? This is rpb page... /ragge + */ + *(int *)(&sc->uh_mr[0]) = UBAMR_MRV; + + /* + * Now start searching for devices. + */ + unifind(sc, ubaiophys); /* Some devices are not yet converted */ + config_scan(ubascan,self); -#else - unifind(uhp, QIOPAGE630); +#ifdef DW780 + if (uhp->uh_type == DW780) + uhp->uh_uba->uba_cr = UBACR_IFS | UBACR_BRIE | + UBACR_USEFIE | UBACR_SUEFIE | + (uhp->uh_uba->uba_cr & 0x7c000000); #endif - break; + +} + +void +ubascan(parent, match) + struct device *parent; + void *match; +{ + struct device *dev = match; + struct cfdata *cf = dev->dv_cfdata; + struct uba_softc *sc = (struct uba_softc *)parent; + struct uba_attach_args ua; + int i; + + ua.ua_addr = (caddr_t)ubaddr(sc, cf->cf_loc[0]); + + if (badaddr(ua.ua_addr, 2)) + goto forgetit; + +#ifdef DW780 + if (uhp->uh_type == DW780 && vubp->uba_sr) { + vubp->uba_sr = vubp->uba_sr; + continue; + } #endif - }; - break; + rcvec = 0x200; + i = (*cf->cf_driver->cd_match) (parent, dev, &ua); + +#ifdef DW780 + if (uhp->uh_type == DW780 && vubp->uba_sr) { + vubp->uba_sr = vubp->uba_sr; + continue; + } #endif - }; - numuba++; -} + if (i == 0) + goto forgetit; + if (rcvec == 0 || rcvec == 0x200) + goto fail; + + sc->uh_idsp[rcvec].hoppaddr = ua.ua_ivec; + sc->uh_idsp[rcvec].pushlarg = ua.ua_iarg; + ua.ua_br = rbr; + ua.ua_cvec = rcvec; + ua.ua_iaddr = dev->dv_cfdata->cf_loc[0]; + config_attach(parent, dev, &ua, ubaprint); + return; -struct cfdriver ubacd= - { NULL, "uba", uba_match, uba_attach, DV_CPU, sizeof(struct device),1,0}; +fail: + printf("%s at %s csr %o %s\n", dev->dv_cfdata->cf_driver->cd_name, + parent->dv_xname, dev->dv_cfdata->cf_loc[0] << 2, + rcvec ? "didn't interrupt\n" : "zero vector\n"); +forgetit: + free(dev, M_DEVBUF); +} +int +ubaprint(aux, uba) + void *aux; + char *uba; +{ + struct uba_attach_args *ua = aux; + printf(" csr %o vec %o ipl %x", ua->ua_iaddr, + ua->ua_cvec << 2, ua->ua_br); + return UNCONF; +} diff --git a/sys/arch/vax/uba/ubareg.h b/sys/arch/vax/uba/ubareg.h index dbd133554a6..f654615f127 100644 --- a/sys/arch/vax/uba/ubareg.h +++ b/sys/arch/vax/uba/ubareg.h @@ -1,4 +1,4 @@ -/* $NetBSD: ubareg.h,v 1.3 1995/02/13 00:44:23 ragge Exp $ */ +/* $NetBSD: ubareg.h,v 1.4 1995/11/10 19:25:50 ragge Exp $ */ /*- * Copyright (c) 1982, 1986 The Regents of the University of California. @@ -81,14 +81,17 @@ * address space, and the return from the allocation routine * can accommodate at most 2047 (ubavar.h: UBA_MAXMR); * QBAPAGES must be at least UBAPAGES. Choose pragmatically. + * + * Is there ever any need to have QBAPAGES != UBAPAGES??? + * Wont work now anyway, QBAPAGES _must_ be .eq. UBAPAGES. */ #define UBAPAGES 496 #define NUBMREG 496 -#if defined(GATEWAY) && !defined(QNIVERT) -#define QBAPAGES 1024 -#else +/* #if defined(GATEWAY) && !defined(QNIVERT) */ +/* #define QBAPAGES 1024 */ +/* #else */ #define QBAPAGES UBAPAGES -#endif +/* #endif */ #define UBAIOADDR 0760000 /* start of I/O page */ #define UBAIOPAGES 16 diff --git a/sys/arch/vax/uba/ubavar.h b/sys/arch/vax/uba/ubavar.h index 24052ad19b6..23d190ebcc6 100644 --- a/sys/arch/vax/uba/ubavar.h +++ b/sys/arch/vax/uba/ubavar.h @@ -1,4 +1,4 @@ -/* $NetBSD: ubavar.h,v 1.6 1995/05/11 16:53:17 jtc Exp $ */ +/* $NetBSD: ubavar.h,v 1.8 1995/12/01 19:23:01 ragge Exp $ */ /* * Copyright (c) 1982, 1986 Regents of the University of California. @@ -39,14 +39,13 @@ * This file contains definitions related to the kernel structures * for dealing with the unibus adapters. * - * Each uba has a uba_hd structure. + * Each uba has a uba_softc structure. * Each unibus controller which is not a device has a uba_ctlr structure. * Each unibus device has a uba_device structure. */ -#ifndef LOCORE - #include "sys/buf.h" +#include "sys/device.h" /* * Per-uba structure. * @@ -68,7 +67,8 @@ * the unibus driver in resource wait (mrwant, bdpwant); these * wait states are also recorded here. */ -struct uba_hd { +struct uba_softc { + struct device uh_dev; /* Device struct, autoconfig */ int uh_type; /* type of adaptor */ struct uba_regs *uh_uba; /* virt addr of uba adaptor regs */ struct uba_regs *uh_physuba; /* phys addr of uba adaptor regs */ @@ -76,7 +76,9 @@ struct uba_hd { int uh_memsize; /* size of uba memory, pages */ caddr_t uh_mem; /* start of uba memory address space */ caddr_t uh_iopage; /* start of uba io page */ - int (**Nuh_vec)(); /* interrupt vector */ + void (**Nuh_vec)(); /* interrupt vector */ + struct ivec_dsp *uh_idsp; /* Interrupt dispatch area */ + u_int *uh_iarea; /* Interrupt vector array */ struct uba_device *uh_actf; /* head of queue to transfer */ struct uba_device *uh_actl; /* tail of queue to transfer */ short uh_mrwant; /* someone is waiting for map reg */ @@ -96,7 +98,7 @@ struct uba_hd { }; /* given a pointer to uba_regs, find DWBUA registers */ -/* this should be replaced with a union in uba_hd */ +/* this should be replaced with a union in uba_softc */ #define BUA(uba) ((struct dwbua_regs *)(uba)) /* @@ -115,9 +117,9 @@ struct uba_ctlr { short um_ctlr; /* controller index in driver */ short um_ubanum; /* the uba it is on */ short um_alive; /* controller exists */ - int (*um_intr)(); /* interrupt handler(s) */ + void (*um_intr)(); /* interrupt handler(s) */ caddr_t um_addr; /* address of device in i/o space */ - struct uba_hd *um_hd; + struct uba_softc *um_hd; /* the driver saves the prototype command here for use in its go routine */ int um_cmd; /* communication to dgo() */ int um_ubinfo; /* save unibus registers, etc */ @@ -147,7 +149,7 @@ struct uba_device { short ui_ctlr; /* mass ctlr number; -1 if none */ short ui_ubanum; /* the uba it is on */ short ui_slave; /* slave on controller */ - int (*ui_intr)(); /* interrupt handler(s) */ + void (*ui_intr)(); /* interrupt handler(s) */ caddr_t ui_addr; /* address of device in i/o space */ short ui_dk; /* if init 1 set to number for iostat */ int ui_flags; /* parameter from system specification */ @@ -158,7 +160,7 @@ struct uba_device { struct uba_device *ui_forw; /* if the device is connected to a controller, this is the controller */ struct uba_ctlr *ui_mi; - struct uba_hd *ui_hd; + struct uba_softc *ui_hd; }; /* @@ -182,7 +184,19 @@ struct uba_driver { short ud_keepbdp; /* hang on to bdp's once allocated */ int (*ud_ubamem)(); /* see if dedicated memory is present */ }; -#endif + +/* + * uba_attach_args is used during autoconfiguration. It is sent + * from ubascan() to each (possible) device. + */ +struct uba_attach_args { + caddr_t ua_addr; + void (*ua_ivec)(); + int ua_iarg; + int ua_iaddr; + int ua_br; + int ua_cvec; +}; /* * Flags to UBA map/bdp allocation routines @@ -222,45 +236,15 @@ struct ubinfo { #define ubago(ui) ubaqueue(ui, 0) /* - * UBA related kernel variables - */ -int numuba; /* number of uba's */ -struct uba_hd uba_hd[]; - -/* * Ubminit and ubdinit initialize the mass storage controller and * device tables specifying possible devices. */ extern struct uba_ctlr ubminit[]; extern struct uba_device ubdinit[]; -/* - * UNIBUS device address space is mapped by UMEMmap - * into virtual address umem[][]. - * The IO page is mapped to the last 8K of each. - * This should be enlarged for the Q22 bus. - */ -extern struct pte *UMEMmap[]; /* uba device addr pte's */ -/* extern char umem[][512*NBPG]; /* uba device addr space */ -extern char *Numem; -#define Tumem(x) (Numem+(UBAPAGES+UBAIOPAGES)*NBPG*x) +extern struct cfdriver ubacd; -/* - * Since some VAXen vector their unibus interrupts - * just adjacent to the system control block, we must - * allocate space there when running on ``any'' cpu. This space is - * used for the vectors for all ubas. - */ -extern int (*UNIvec[][128])(); /* unibus vec for ubas */ -extern int (*eUNIvec)(); /* end of unibus vec */ +void ubainit __P((struct uba_softc *)); -#if defined(VAX780) || defined(VAX8600) -/* - * On DW780's, we must set the scb vectors for the nexus of the - * UNIbus adaptors to vector to locore unibus adaptor interrupt dispatchers - * which make 780's look like the other VAXen. - */ -extern Xua0int(), Xua1int(), Xua2int(), Xua3int(); -#endif VAX780 #endif /* _KERNEL */ #endif !LOCORE diff --git a/sys/arch/vax/uba/ubavec.s b/sys/arch/vax/uba/ubavec.s deleted file mode 100644 index 7d388d3f920..00000000000 --- a/sys/arch/vax/uba/ubavec.s +++ /dev/null @@ -1,112 +0,0 @@ -/* $NetBSD: ubavec.s,v 1.2 1995/02/23 17:53:22 ragge Exp $ */ -/* - * Copyright (c) 1994 Ludd, University of Lule}, Sweden. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed at Ludd, University of Lule}. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - /* All bugs are subject to removal without further notice */ - - -/* - * Interrupt vectors for Unibus; already at the right place at boot. - * This allocation should be done in some other way, 8600 has its - * second SCB at the same place as 750's first UBA vector... foolish. - */ - -#define UBAVEC(lab,off) .long lab+(off)*8+1; -#define UBAVEC2(lab,off) UBAVEC(lab,off);UBAVEC(lab,off+1) -#define UBAVEC4(lab,off) UBAVEC2(lab,off);UBAVEC2(lab,off+2) -#define UBAVEC8(lab,off) UBAVEC4(lab,off);UBAVEC4(lab,off+4) -#define UBAVEC16(lab,off) UBAVEC8(lab,off);UBAVEC8(lab,off+8) - -.globl _UNIvec, _eUNIvec, ubaett - -_UNIvec: - UBAVEC16(ubaett,0);UBAVEC16(ubaett,16); - UBAVEC16(ubaett,32);UBAVEC16(ubaett,48); - UBAVEC16(ubaett,64);UBAVEC16(ubaett,80); - UBAVEC16(ubaett,96);UBAVEC16(ubaett,112); - UBAVEC16(ubatva,0);UBAVEC16(ubatva,16); - UBAVEC16(ubatva,32);UBAVEC16(ubatva,48); - UBAVEC16(ubatva,64);UBAVEC16(ubatva,80); - UBAVEC16(ubatva,96);UBAVEC16(ubatva,112); - UBAVEC16(ubatre,0);UBAVEC16(ubatre,16); - UBAVEC16(ubatre,32);UBAVEC16(ubatre,48); - UBAVEC16(ubatre,64);UBAVEC16(ubatre,80); - UBAVEC16(ubatre,96);UBAVEC16(ubatre,112); - UBAVEC16(ubafyra,0);UBAVEC16(ubafyra,16); - UBAVEC16(ubafyra,32);UBAVEC16(ubafyra,48); - UBAVEC16(ubafyra,64);UBAVEC16(ubafyra,80); - UBAVEC16(ubafyra,96);UBAVEC16(ubafyra,112); -_eUNIvec: - -#define PR(uba) .align 2;pushr $0x3f;jsb uba ; -#define UBAJSB4(uba) PR(uba);PR(uba);PR(uba);PR(uba); -#define UBAJSB16(uba) UBAJSB4(uba);UBAJSB4(uba);UBAJSB4(uba);UBAJSB4(uba); -#define UBAJSB64(uba) UBAJSB16(uba);UBAJSB16(uba);UBAJSB16(uba);UBAJSB16(uba) - -ubaett: - UBAJSB64(ett);UBAJSB64(ett);UBAJSB64(ett);UBAJSB64(ett); -ubatva: - UBAJSB64(tva);UBAJSB64(tva);UBAJSB64(tva);UBAJSB64(tva); -ubatre: - UBAJSB64(tre);UBAJSB64(tre);UBAJSB64(tre);UBAJSB64(tre); -ubafyra: - UBAJSB64(fyra);UBAJSB64(fyra);UBAJSB64(fyra);UBAJSB64(fyra); - - -ett: subl3 $ubaett, (sp), r0 - ashl $-3, r0, (sp) - pushl $0 - brb 1f - -tva: subl3 $ubatva, (sp), r0 - ashl $-3, r0, (sp) - pushl $1 - brb 1f - -tre: subl3 $ubatre, (sp), r0 - ashl $-3, r0, (sp) - pushl $2 - brb 1f - - .globl ett,tva,tre,fyra -fyra: subl3 $ubafyra, (sp), r0 - ashl $-3, r0, (sp) - pushl $3 - -1: mfpr $PR_IPL, -(sp) - calls $3, _ubainterrupt - popr $0x3f - rei - - - - - - diff --git a/sys/arch/vax/uba/uda.c b/sys/arch/vax/uba/uda.c index fcf8f57e0ec..8ee02b6338f 100644 --- a/sys/arch/vax/uba/uda.c +++ b/sys/arch/vax/uba/uda.c @@ -1,4 +1,4 @@ -/* $NetBSD: uda.c,v 1.8 1995/08/31 22:24:39 ragge Exp $ */ +/* $NetBSD: uda.c,v 1.9 1995/11/10 19:25:53 ragge Exp $ */ /* * Copyright (c) 1988 Regents of the University of California. @@ -282,6 +282,7 @@ void udawatch(); /* watchdog timer */ * Externals */ int hz; +extern struct cfdriver ubacd; /* * Poke at a supposed UDA50 to see if it is there. @@ -298,6 +299,7 @@ udaprobe(reg, ctlr, um) struct uda_softc *sc; volatile struct udadevice *udaddr; struct mscp_info *mi; + struct uba_softc *ubasc; extern int cpu_type; int timeout, tries, count; #ifdef notyet @@ -354,7 +356,9 @@ udaprobe(reg, ctlr, um) * problem; but it would be easily fixed if we had a controller * attach routine. Sigh. */ - sc->sc_ivec = (uba_hd[numuba].uh_lastiv -= 4); + ubasc = ubacd.cd_devs[0]; /* XXX */ + sc->sc_ivec = ubasc->uh_lastiv -= 4; +/* sc->sc_ivec = (uba_hd[numuba].uh_lastiv -= 4); */ udaddr = (struct udadevice *) reg; /* @@ -1385,7 +1389,7 @@ udasaerror(um, doreset) * continue initialisation, or acknowledge command and response * interrupts, and process responses. */ -udaintr(vektor,level,uba,ctlr) +udaintr(ctlr) { struct uba_ctlr *um = udaminfo[ctlr]; volatile struct uda_softc *sc = &uda_softc[ctlr]; @@ -1966,7 +1970,7 @@ udadump(dev) * device registers, and of communications area and command and * response packet. */ - uba = phys(struct uba_hd *, ui->ui_hd)->uh_physuba; + uba = phys(struct uba_softc *, ui->ui_hd)->uh_physuba; ubainit(uba); udaddr = (struct udadevice *)ui->ui_physaddr; ud = phys(struct uda1 *, &uda1); @@ -1981,7 +1985,7 @@ printf("H{r.\n"); reg = NUBMREG - num; io = (void *)&uba->uba_map[reg]; for (i = 0; i < num; i++) - *(int *)io++ = UBAMR_MRV | (vax_btop(ud) + i); + *(int *)io++ = UBAMR_MRV | (btop(ud) + i); ud_ubaddr = (struct uda1 *)(((int)ud & PGOFSET) | (reg << 9)); /* @@ -2049,10 +2053,10 @@ printf("H{r.\n"); * Then do the write. */ for (i = 0; i < blk; i++) - *(int *)io++ = UBAMR_MRV | (vax_btop(start) + i); + *(int *)io++ = UBAMR_MRV | (btop(start) + i); *(int *)io = 0; ud->uda1_cmd.mscp_unit = ui->ui_slave; - ud->uda1_cmd.mscp_seq.seq_lbn = vax_btop(start) + blkoff; + ud->uda1_cmd.mscp_seq.seq_lbn = btop(start) + blkoff; ud->uda1_cmd.mscp_seq.seq_bytecount = blk << PGSHIFT; if (udadumpcmd(M_OP_WRITE, ud, ui)) return (EIO); diff --git a/sys/arch/vax/vax/clock.c b/sys/arch/vax/vax/clock.c index 96539e5c4db..a45f1f5d400 100644 --- a/sys/arch/vax/vax/clock.c +++ b/sys/arch/vax/vax/clock.c @@ -1,4 +1,4 @@ -/* $NetBSD: clock.c,v 1.7.2.1 1995/10/15 14:17:17 ragge Exp $ */ +/* $NetBSD: clock.c,v 1.8 1995/11/30 00:59:32 jtc Exp $ */ /* * Copyright (c) 1995 Ludd, University of Lule}, Sweden. * All rights reserved. diff --git a/sys/arch/vax/vax/db_disasm.c b/sys/arch/vax/vax/db_disasm.c index 15af9247e5a..06728df5f79 100644 --- a/sys/arch/vax/vax/db_disasm.c +++ b/sys/arch/vax/vax/db_disasm.c @@ -1,4 +1,4 @@ -/* $NetBSD: db_disasm.c,v 1.1.2.1 1995/10/28 15:30:22 ragge Exp $ */ +/* $NetBSD: db_disasm.c,v 1.2 1995/11/30 00:59:34 jtc Exp $ */ /* * Copyright (c) 1995 Ludd, University of Lule}, Sweden. * All rights reserved. diff --git a/sys/arch/vax/vax/intvec.s b/sys/arch/vax/vax/intvec.s index 997d93ec959..4dc2c181fb8 100644 --- a/sys/arch/vax/vax/intvec.s +++ b/sys/arch/vax/vax/intvec.s @@ -1,4 +1,4 @@ -/* $NetBSD: intvec.s,v 1.11 1995/06/16 15:36:40 ragge Exp $ */ +/* $NetBSD: intvec.s,v 1.12 1995/11/10 19:05:46 ragge Exp $ */ /* * Copyright (c) 1994 Ludd, University of Lule}, Sweden. @@ -34,10 +34,9 @@ -#include "vax/include/mtpr.h" -#include "vax/include/pte.h" -#include "vax/include/trap.h" -#include "uba.h" +#include "machine/mtpr.h" +#include "machine/pte.h" +#include "machine/trap.h" #define TRAPCALL(namn, typ) \ .align 2; namn ## :;.globl namn ;pushl $0; pushl $typ; jbr trap; @@ -61,11 +60,11 @@ _kernbase: _rpb: /* - * First page in memory we have rpb; so that we know where :-) - * Second page contain scb, and thereafter uba vectors. - * Virtual adress is 0x80000000. + * First page in memory we have rpb; so that we know where + * (must be on a 64k page boundary, easiest here). We use it + * to store SCB vectors generated when compiling the kernel, + * and move the SCB later to somewhere else. */ - .space 512 /* rpb takes one page */ INTVEC(stray00, ISTACK) # Unused., 0 INTVEC(mcheck, ISTACK) # Machine Check., 4 @@ -88,7 +87,7 @@ _rpb: INTVEC(resopflt, KSTACK) # chms, 48 INTVEC(resopflt, KSTACK) # chmu, 4C INTVEC(stray50, ISTACK) # System Backplane Exception, 50 - INTVEC(stray54, ISTACK) # Corrected Memory Read, 54 + INTVEC(cmrerr, ISTACK) # Corrected Memory Read, 54 INTVEC(stray58, ISTACK) # System Backplane Alert, 58 INTVEC(stray5C, ISTACK) # System Backplane Fault, 5C INTVEC(stray60, ISTACK) # Memory Write Timeout, 60 @@ -127,22 +126,18 @@ _rpb: INTVEC(strayE4, ISTACK) # Unused, E4 INTVEC(strayE8, ISTACK) # Unused, E8 INTVEC(strayEC, ISTACK) # Unused, EC - INTVEC(strayF0, ISTACK) # Console Storage Recieve Interrupt - INTVEC(strayF4, ISTACK) # Console Storage Transmit Interrupt +#ifdef VAX750 + INTVEC(cstrint, ISTACK) # Console Storage Recieve Interrupt + INTVEC(csttint, ISTACK) # Console Storage Transmit Interrupt +#else + INTVEC(strayF0, ISTACK) + INTVEC(strayF4, ISTACK) +#endif INTVEC(consrint, ISTACK) # Console Terminal Recieve Interrupt INTVEC(constint, ISTACK) # Console Terminal Transmit Interrupt - - .globl _V_DEVICE_VEC -_V_DEVICE_VEC: .space 0x100 - -#if NUBA -#include "vax/uba/ubavec.s" -#endif - -#if NUBA>4 /* Safety belt */ -#error "Number of bus adapters must be increased in ubavec.s" -#endif + /* space for adapter vectors */ + .space 0x100 STRAY(0, 00) @@ -232,7 +227,7 @@ syscall: STRAY(0, 48) STRAY(0, 4C) STRAY(0, 50) - STRAY(0, 54) + FASTINTR(cmrerr, cmrerr) STRAY(0, 58) STRAY(0, 5C) STRAY(0, 60) @@ -286,8 +281,14 @@ hardclock: mtpr $0xc1,$PR_ICCS # Reset interrupt flag STRAY(0, E4) STRAY(0, E8) STRAY(0, EC) + +#ifdef VAX750 + FASTINTR(cstrint, cturintr) + FASTINTR(csttint, ctutintr) +#else STRAY(0, F0) STRAY(0, F4) +#endif FASTINTR(consrint, gencnrint) FASTINTR(constint, gencntint) @@ -396,3 +397,7 @@ _intrcnt: .long 0 _eintrcnt: + .data +_scb: .long 0 + .globl _scb + diff --git a/sys/arch/vax/vax/ka750.c b/sys/arch/vax/vax/ka750.c index 4dc30a4dafc..49853a8fa42 100644 --- a/sys/arch/vax/vax/ka750.c +++ b/sys/arch/vax/vax/ka750.c @@ -1,4 +1,4 @@ -/* $NetBSD: ka750.c,v 1.5.2.1 1995/10/15 14:18:49 ragge Exp $ */ +/* $NetBSD: ka750.c,v 1.7 1995/11/30 00:59:35 jtc Exp $ */ /*- * Copyright (c) 1982, 1986, 1988 The Regents of the University of California. @@ -37,15 +37,12 @@ * @(#)autoconf.c 7.20 (Berkeley) 5/9/91 */ -/* All bugs are subject to removal without further notice */ - -#if VAX750 - #include "sys/param.h" #include "sys/types.h" #include "sys/device.h" +#include "vm/vm.h" +#include "vm/vm_kern.h" #include "machine/ka750.h" -#include "machine/nexus.h" #include "machine/pte.h" #include "machine/mtpr.h" #include "vax/uba/ubavar.h" @@ -54,12 +51,6 @@ #include "mba.h" #include "uba.h" -#include "vm/vm.h" -#include "vm/vm_kern.h" -#include "vax/include/pmap.h" - -struct nexus *nexus; - int ka750_conf() { @@ -71,26 +62,27 @@ ka750_conf() int conf_750(){ - extern int cpu_type, nmba, numuba; + extern int cpu_type; printf(": 11/750, hardware rev %d, ucode rev %d\n", V750HARDW(cpu_type), V750UCODE(cpu_type)); } -ka750_clock(){ - u_int i; /* - * It's time to start clocks in system... + * ka750_clock() makes the 11/750 interrupt clock and todr + * register start counting. */ - i=~10000; /* Complement of 10000 milliseconds */ - mtpr(i,PR_NICR); /* Load in count register */ - mtpr(0x51,PR_ICCS); /* Start clock and enable interrupt */ - if(mfpr(PR_TODR)){ +int +ka750_clock() { + + mtpr(-10000, PR_NICR); /* Load in count register */ + mtpr(0x800000d1, PR_ICCS); /* Start clock and enable interrupt */ + if (mfpr(PR_TODR)) { /* todr running */ return 0; } else { /* Start TODR register. */ - mtpr(1,PR_TODR); + mtpr(1, PR_TODR); return 1; } @@ -105,15 +97,8 @@ mbainterrupt(){return;} #endif -/* - * 750-specific code. - */ - - #include "sys/param.h" -/* #include "mem.h" */ - extern volatile caddr_t mcraddr[]; struct mcr750 { @@ -233,4 +218,23 @@ ka750_mchk(cmcf) } return (-1); } -#endif + +ka750_steal_pages() +{ + extern vm_offset_t avail_start, virtual_avail; + extern struct nexus *nexus; + int junk; + + /* + * We take away the pages we need, one for SCB and the rest + * for UBA vectors == 1 + 2 will alloc all needed space. + * We also set up virtual area for SBI. + */ + MAPPHYS(junk, V750PGS, VM_PROT_READ|VM_PROT_WRITE); + MAPVIRT(nexus, btoc(NEX750SZ)); + pmap_map((vm_offset_t)nexus, NEX750, NEX750 + NEX750SZ, + VM_PROT_READ|VM_PROT_WRITE); + + return 0; +} + diff --git a/sys/arch/vax/vax/locore.c b/sys/arch/vax/vax/locore.c index ffb7b9b42f9..9fd74dc89ff 100644 --- a/sys/arch/vax/vax/locore.c +++ b/sys/arch/vax/vax/locore.c @@ -1,4 +1,4 @@ -/* $NetBSD: locore.c,v 1.8 1995/06/16 15:36:42 ragge Exp $ */ +/* $NetBSD: locore.c,v 1.9 1995/11/10 19:05:47 ragge Exp $ */ /* * Copyright (c) 1994 Ludd, University of Lule}, Sweden. @@ -47,8 +47,6 @@ #include "machine/vmparam.h" #include "machine/pcb.h" -#define ROUND_PAGE(x) (((uint)(x)+PAGE_SIZE-1)& ~(PAGE_SIZE-1)) - u_int proc0paddr; volatile int cpunumber, *Sysmap, boothowto, cpu_type; volatile char *esym; @@ -69,7 +67,12 @@ start(how, dev) register curtop; mtpr(0x1f,PR_IPL); /* No interrupts before istack is ok, please */ -#ifdef COMPAT_RENO + + /* + * We can be running either in system or user space when + * getting here. Need to figure out which and take care + * of it. + */ asm(" movl r9,_esym movl r10,_bootdev @@ -84,15 +87,11 @@ tvo: movl (sp)+,_boothowto movl (sp)+,_bootdev to_kmem: "); -#else - bootdev=dev; - boothowto=how; -#endif -/* - * FIRST we must set up kernel stack, directly after end. - * This is the only thing we have to setup here, rest in pmap. - */ + /* + * FIRST we must set up kernel stack, directly after end. + * This is the only thing we have to setup here, rest in pmap. + */ PAGE_SIZE = NBPG*2; /* Set logical page size */ #ifdef DDB @@ -121,7 +120,7 @@ to_kmem: mtpr(0,PR_P1LR); mtpr(0x80000000,PR_P1BR); - mtpr(512,PR_SCBB); /* SCB at physical addr 512 */ + mtpr(0, PR_SCBB); /* SCB at physical addr */ mtpr(0,PR_ESP); /* Must be zero, used in page fault routine */ mtpr(AST_NO,PR_ASTLVL); diff --git a/sys/arch/vax/vax/machdep.c b/sys/arch/vax/vax/machdep.c index b50c1a9bd8f..7bc86a260eb 100644 --- a/sys/arch/vax/vax/machdep.c +++ b/sys/arch/vax/vax/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.19.2.1 1995/10/15 14:06:18 ragge Exp $ */ +/* $NetBSD: machdep.c,v 1.20 1995/11/10 19:05:49 ragge Exp $ */ /* * Copyright (c) 1994 Ludd, University of Lule}, Sweden. @@ -713,3 +713,11 @@ ns_cksum() { panic("ns_cksum"); } + +cmrerr() +{ + switch (cpunumber) { + case VAX_750: + ka750_memerr(); + } +} diff --git a/sys/arch/vax/vax/mem.c b/sys/arch/vax/vax/mem.c index 645007fb8fe..66fbd913205 100644 --- a/sys/arch/vax/vax/mem.c +++ b/sys/arch/vax/vax/mem.c @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.7 1995/04/10 16:49:25 mycroft Exp $ */ +/* $NetBSD: mem.c,v 1.8 1995/10/30 16:27:56 ragge Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -121,16 +121,16 @@ mmrw(dev, uio, flags) error = EFAULT; goto unlock; } + pmap_enter(pmap_kernel(), (vm_offset_t)vmmap, trunc_page(v), uio->uio_rw == UIO_READ ? VM_PROT_READ : VM_PROT_WRITE, TRUE); - o = uio->uio_offset & PGOFSET; - c = min(uio->uio_resid, (int)(NBPG - o)); + o = uio->uio_offset & PAGE_MASK; + c = min(uio->uio_resid, (int)(PAGE_SIZE - o)); error = uiomove((caddr_t)vmmap + o, c, uio); pmap_remove(pmap_kernel(), (vm_offset_t)vmmap, - (vm_offset_t)vmmap + NBPG); + (vm_offset_t)vmmap + PAGE_SIZE); continue; - /* minor device 1 is kernel memory */ case 1: v = uio->uio_offset; diff --git a/sys/arch/vax/vax/mscp.c b/sys/arch/vax/vax/mscp.c index a4af2b4bc08..7ee2c2265bd 100644 --- a/sys/arch/vax/vax/mscp.c +++ b/sys/arch/vax/vax/mscp.c @@ -1,4 +1,4 @@ -/* $NetBSD: mscp.c,v 1.4.2.1 1995/10/15 14:18:52 ragge Exp $ */ +/* $NetBSD: mscp.c,v 1.6 1995/11/30 00:59:37 jtc Exp $ */ /* * Copyright (c) 1988 Regents of the University of California. diff --git a/sys/arch/vax/vax/mscpvar.h b/sys/arch/vax/vax/mscpvar.h index 8b9a63a6ce3..f9f3f4706e4 100644 --- a/sys/arch/vax/vax/mscpvar.h +++ b/sys/arch/vax/vax/mscpvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: mscpvar.h,v 1.5.2.1 1995/10/15 14:18:53 ragge Exp $ */ +/* $NetBSD: mscpvar.h,v 1.6 1995/11/10 19:09:58 ragge Exp $ */ /* * Copyright (c) 1988 Regents of the University of California. diff --git a/sys/arch/vax/vax/pmap.c b/sys/arch/vax/vax/pmap.c index b113a553f67..a0d93b279ad 100644 --- a/sys/arch/vax/vax/pmap.c +++ b/sys/arch/vax/vax/pmap.c @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.17 1995/08/22 04:34:17 ragge Exp $ */ +/* $NetBSD: pmap.c,v 1.18 1995/11/10 18:52:54 ragge Exp $ */ #define DEBUG /* * Copyright (c) 1994 Ludd, University of Lule}, Sweden. @@ -30,8 +30,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - /* All bugs are subject to removal without further notice */ - #include "sys/types.h" #include "sys/param.h" #include "sys/queue.h" @@ -39,28 +37,32 @@ #include "sys/proc.h" #include "sys/user.h" #include "sys/msgbuf.h" + #include "vm/vm.h" #include "vm/vm_page.h" #include "vm/vm_kern.h" -#include "vax/include/pte.h" -#include "vax/include/pcb.h" -#include "vax/include/mtpr.h" -#include "vax/include/loconf.h" -#include "vax/include/macros.h" -#include "vax/include/sid.h" -#include "uba.h" +#include "machine/pte.h" +#include "machine/pcb.h" +#include "machine/mtpr.h" +#include "machine/macros.h" +#include "machine/sid.h" +#include "machine/uvaxII.h" +#include "machine/cpu.h" +#include "machine/scb.h" + pt_entry_t *pmap_virt2pte(pmap_t, u_int); +static pv_entry_t alloc_pv_entry(); +static void free_pv_entry(); -#define PTE_TO_PV(pte) (PHYS_TO_PV((pte&PG_FRAME)<<PG_SHIFT)) +#define ISTACK_SIZE (4 * NBPG) +#define PTE_TO_PV(pte) (PHYS_TO_PV((pte&PG_FRAME)<<PGSHIFT)) -struct pmap kernel_pmap_store; -unsigned int gurkskit[50],istack; -static pv_entry_t alloc_pv_entry(); -static void free_pv_entry(); + +struct pmap kernel_pmap_store; static int prot_array[]={ PG_NONE, PG_RO, PG_RW, PG_RW, PG_RO, PG_RO, PG_RW, PG_RW }; @@ -68,28 +70,21 @@ static int prot_array[]={ PG_NONE, PG_RO, PG_RW, PG_RW, static int kernel_prot[]={ PG_NONE, PG_KR, PG_KW, PG_KW, PG_RO,PG_KR,PG_KW,PG_URKW}; -static pv_entry_t pv_head =NULL; -static unsigned int pv_count=0; -vm_offset_t ptemapstart,ptemapend; - -extern uint etext; -extern u_int *pte_cmap; -extern int maxproc; -extern struct vmspace vmspace0; -extern int edata, end; -uint* UMEMmap; -void* Numem; -void *scratch; -uint sigsida; +static pv_entry_t pv_head = NULL; +static unsigned int pv_count = 0; + +unsigned *pte_cmap; +void *scratch; + #ifdef DEBUG -int startpmapdebug=0; -extern int startsysc, faultdebug; +int startpmapdebug = 0; +extern int startsysc, faultdebug; #endif -unsigned int *valueptr=gurkskit, vmmap; -pt_entry_t *Sysmap; -vm_map_t pte_map; -vm_offset_t avail_start, avail_end; +unsigned int vmmap; +vm_map_t pte_map; + +vm_offset_t avail_start, avail_end; vm_offset_t virtual_avail, virtual_end; /* Available virtual memory */ /* @@ -98,143 +93,148 @@ vm_offset_t virtual_avail, virtual_end; /* Available virtual memory */ * Assumes that nothing is mapped, and that kernel stack is located * immediately after end. */ - -void +void pmap_bootstrap() { - uint i; - extern u_int sigcode, esigcode, proc0paddr; - extern char *esym; - struct pmap *p0pmap=&vmspace0.vm_pmap; - vm_offset_t pend=0; -#define ROUND_PAGE(x) (((uint)(x) + PAGE_SIZE-1)& ~(PAGE_SIZE - 1)) - - /* These are in phys memory */ - istack = ROUND_PAGE((uint)Sysmap + SYSPTSIZE * 4); - (u_int)scratch = istack + ISTACK_SIZE; - mtpr(scratch, PR_ISP); /* set interrupt stack pointer */ - msgbufp = (void *)(scratch + NBPG * 4); - (u_int)pv_table = (int)ROUND_PAGE(sizeof(struct msgbuf)) + - (u_int)msgbufp; - -/* Count up phys memory */ - while (!badaddr(pend, 4)) - pend += NBPG * 128; - + unsigned int junk, sysptsize, istack; + extern unsigned int proc0paddr, sigcode, esigcode, etext; + extern struct vmspace vmspace0; + struct pmap *p0pmap; + + p0pmap = &vmspace0.vm_pmap; + + sysptsize = SYSPTSIZE; + /* + * Virtual_* and avail_* is used for mapping of system page table. + * First set them to their max values and then decrement them. + */ + virtual_avail = KERNBASE; + virtual_end = KERNBASE + sysptsize * NBPG; + avail_start = 0; + while (!badaddr(avail_end, 4)) /* Memory is in 64K hunks */ + avail_end += NBPG * 128; + + blkclr(Sysmap, sysptsize * 4); /* clear SPT before using it */ + /* + * Map kernel. Kernel code is always readable for user, + * it must be because of the emulation code that is somewhere + * in there. And it doesn't hurt, /netbsd is also public readable. + * There are also a couple of other things that must be in + * physical memory and that isn't managed by the vm system. + */ +#ifdef DDB + MAPPHYS(junk, ((ROUND_PAGE(&etext) - KERNBASE) >> PGSHIFT), + VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); +#else + MAPPHYS(junk, ((ROUND_PAGE(&etext) - KERNBASE) >> PGSHIFT), + VM_PROT_EXECUTE); +#endif + MAPPHYS(junk, (((u_int)Sysmap - ROUND_PAGE(&etext)) >> PGSHIFT), + VM_PROT_READ|VM_PROT_WRITE); + + /* Map System Page Table and zero it, Sysmap already set. */ + mtpr(avail_start, PR_SBR); + MAPPHYS(junk, (ROUND_PAGE(sysptsize * 4) >> PGSHIFT), + VM_PROT_READ|VM_PROT_WRITE); + + /* Map Interrupt stack and set red zone */ + MAPPHYS(istack, (ISTACK_SIZE >> PGSHIFT), VM_PROT_READ|VM_PROT_WRITE); + mtpr(istack + ISTACK_SIZE, PR_ISP); + kvtopte(istack)->pg_v = 0; + + /* Take four pages for scratch use */ + MAPPHYS(scratch, 4, VM_PROT_READ|VM_PROT_WRITE); + + /* Kernel message buffer */ + MAPPHYS(msgbufp, ((u_int)ROUND_PAGE(sizeof(struct msgbuf)) >> PGSHIFT), + VM_PROT_READ|VM_PROT_WRITE); + + /* Physical-to-virtual translation table */ + MAPPHYS(pv_table, ((avail_end / PAGE_SIZE ) * sizeof(struct pv_entry)) + >> PGSHIFT, VM_PROT_READ|VM_PROT_WRITE); + + /* zero all mapped physical memory from Sysmap to here */ + blkclr((void *)istack, (avail_start | 0x80000000) - istack); + + /* Now map up what is only needed in virtual memory. */ + MAPVIRT(vmmap, 2); + (pt_entry_t *)pte_cmap = kvtopte(vmmap); + +#ifdef VAX750 + /* + * We move SCB here from physical address 0 to an address + * somewhere else, so that we can dynamically allocate + * space for interrupt vectors and other machine-specific + * things. We move it here, but the rest of the allocation + * is done in a cpu-specific routine. + * avail_start is modified in the cpu-specific routine. + */ + scb = (struct scb *)virtual_avail; + bcopy(0, (void *)avail_start, NBPG >> 1); + mtpr(avail_start, PR_SCBB); + bzero(0, NBPG >> 1); + (cpu_calls[cpunumber].cpu_steal_pages)(); +#else #if VAX630 - if (cpu_type == VAX_630) - pend -= 8 * NBPG; /* Avoid console scratchpad */ + if (cpu_type == VAX_630) + avail_end -= 8 * NBPG; /* Avoid console scratchpad */ #endif -#if VAX650 - if (cpu_type == VAX_650) - pend -= 64 * NBPG; #endif -/* These are virt only */ - vmmap = ROUND_PAGE(pv_table + (pend / PAGE_SIZE)); - (u_int)Numem = vmmap + NBPG * 2; - - (pt_entry_t *)UMEMmap=kvtopte(Numem); - (pt_entry_t *)pte_cmap=kvtopte(vmmap); - - avail_start=ROUND_PAGE(vmmap)&0x7fffffff; - avail_end=pend-ROUND_PAGE(sizeof(struct msgbuf)); - virtual_avail=ROUND_PAGE((uint)Numem+NUBA*NBPG*NBPG); - virtual_end=SYSPTSIZE*NBPG+KERNBASE; #ifdef DEBUG - printf("Sysmap %x, istack %x, scratch %x\n",Sysmap,istack,scratch); - printf("etext %x, edata %x, end %x, esym %x\n", - &etext,&edata, &end, esym); - printf("SYSPTSIZE %x, USRPTSIZE %x\n",SYSPTSIZE,USRPTSIZE); - printf("pv_table %x, vmmap %x, Numem %x, pte_cmap %x\n", - pv_table,vmmap,Numem,pte_cmap); - printf("avail_start %x, avail_end %x\n",avail_start,avail_end); - printf("virtual_avail %x,virtual_end %x\n",virtual_avail,virtual_end); - printf("clearomr: %x \n",(uint)vmmap-(uint)Sysmap); - printf("faultdebug %x, startsysc %x\n",&faultdebug, &startsysc); - printf("startpmapdebug %x\n",&startpmapdebug); + printf("Sysmap %x, istack %x, scratch %x\n",Sysmap,istack,scratch); + printf("etext %x\n", &etext); + printf("SYSPTSIZE %x, USRPTSIZE %x\n",sysptsize,USRPTSIZE); + printf("pv_table %x, vmmap %x, pte_cmap %x\n", + pv_table,vmmap,pte_cmap); + printf("avail_start %x, avail_end %x\n",avail_start,avail_end); + printf("virtual_avail %x,virtual_end %x\n",virtual_avail,virtual_end); + printf("clearomr: %x \n",(uint)vmmap-(uint)Sysmap); + printf("faultdebug %x, startsysc %x\n",&faultdebug, &startsysc); + printf("startpmapdebug %x\n",&startpmapdebug); #endif - blkclr(Sysmap,(uint)vmmap-(uint)Sysmap); - pmap_map(0x80000000,0,2*NBPG,VM_PROT_READ|VM_PROT_WRITE); -#ifdef DDB - pmap_map(0x80000400,2*NBPG,(vm_offset_t)(&etext), - VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); -#else - pmap_map(0x80000400,2*NBPG,(vm_offset_t)(&etext),VM_PROT_EXECUTE); -#endif - pmap_map((vm_offset_t)(&etext),(vm_offset_t)&etext, - (vm_offset_t)Sysmap,VM_PROT_READ|VM_PROT_WRITE); - pmap_map((vm_offset_t)Sysmap,(vm_offset_t)Sysmap,istack, - VM_PROT_READ|VM_PROT_WRITE); - pmap_map(istack,istack,istack+NBPG,VM_PROT_NONE);/* Red zone */ - pmap_map(istack+NBPG,istack+NBPG,(vm_offset_t)scratch, - VM_PROT_READ|VM_PROT_WRITE); - pmap_map((vm_offset_t)scratch,(vm_offset_t)scratch, - (vm_offset_t)msgbufp, VM_PROT_READ|VM_PROT_WRITE); - pmap_map((vm_offset_t)msgbufp, (vm_offset_t)msgbufp, - (vm_offset_t)pv_table, VM_PROT_ALL); - pmap_map((vm_offset_t)pv_table,(vm_offset_t)pv_table,vmmap, - VM_PROT_READ|VM_PROT_WRITE); - - /* Init kernel pmap */ - pmap_kernel()->ref_count = 1; - simple_lock_init(&pmap_kernel()->pm_lock); - p0pmap->pm_pcb=(struct pcb *)proc0paddr; - - /* used for signal trampoline code */ - sigsida=(u_int)(scratch+NBPG)&0x7fffffff; - bcopy(&sigcode, (void *)sigsida, (u_int)&esigcode-(u_int)&sigcode); - - p0pmap->pm_pcb->P1BR = (void *)0x80000000; - p0pmap->pm_pcb->P0BR = 0; - p0pmap->pm_pcb->P1LR = 0x200000; - p0pmap->pm_pcb->P0LR = AST_PCB; - mtpr(0x80000000, PR_P1BR); - mtpr(0, PR_P0BR); - mtpr(0x200000, PR_P1LR); - mtpr(AST_PCB, PR_P0LR); + + /* Init kernel pmap */ + pmap_kernel()->ref_count = 1; + simple_lock_init(&pmap_kernel()->pm_lock); + p0pmap->pm_pcb = (struct pcb *)proc0paddr; + + p0pmap->pm_pcb->P1BR = (void *)0x80000000; + p0pmap->pm_pcb->P0BR = 0; + p0pmap->pm_pcb->P1LR = 0x200000; + p0pmap->pm_pcb->P0LR = AST_PCB; + mtpr(0x80000000, PR_P1BR); + mtpr(0, PR_P0BR); + mtpr(0x200000, PR_P1LR); + mtpr(AST_PCB, PR_P0LR); /* * Now everything should be complete, start virtual memory. */ - mtpr((uint)Sysmap&0x7fffffff,PR_SBR); /* Where is SPT? */ - mtpr(SYSPTSIZE,PR_SLR); - mtpr(1,PR_MAPEN); - bzero(valueptr, 200); + mtpr(SYSPTSIZE, PR_SLR); + mtpr(1, PR_MAPEN); } -/****************************************************************************** * - * pmap_init() - * - ****************************************************************************** - * - * Called as part of vm init. - * - */ +/* + * pmap_init() is called as part of vm init after memory management + * is enabled. It is meant to do machine-specific allocations. + * Here we allocate virtual memory for user page tables. + */ void -pmap_init(s, e) - vm_offset_t s,e; +pmap_init(start, end) + vm_offset_t start, end; { + vm_offset_t ptemapstart,ptemapend; /* reserve place on SPT for UPT */ pte_map = kmem_suballoc(kernel_map, &ptemapstart, &ptemapend, USRPTSIZE * 4, TRUE); } -/****************************************************************************** - * - * pmap_create() - * - ****************************************************************************** - * - * pmap_t pmap_create(phys_size) - * - * Create a pmap for a new task. - * - * Allocate a pmap form kernel memory with malloc. - * Clear the pmap. - * Allocate a ptab for the pmap. - * + +/* + * pmap_create() creates a pmap for a new task. + * If not already allocated, malloc space for one. */ pmap_t pmap_create(phys_size) @@ -245,9 +245,8 @@ pmap_create(phys_size) #ifdef DEBUG if(startpmapdebug)printf("pmap_create: phys_size %x\n",phys_size); #endif - if(phys_size) return NULL; - -/* Malloc place for pmap struct */ + if (phys_size) + return NULL; pmap = (pmap_t) malloc(sizeof(struct pmap), M_VMPMAP, M_WAITOK); pmap_pinit(pmap); @@ -337,18 +336,18 @@ printf("pmap_enter: pmap: %x,virt %x, phys %x,pv %x prot %x\n", if (v < 0x40000000) { patch = (int *)pmap->pm_pcb->P0BR; - i = (v >> PG_SHIFT); + i = (v >> PGSHIFT); if (i >= (pmap->pm_pcb->P0LR&~AST_MASK)) pmap_expandp0(pmap, i); patch = (int *)pmap->pm_pcb->P0BR; } else if (v < (u_int)0x80000000) { patch = (int *)pmap->pm_pcb->P1BR; - i = (v - 0x40000000) >> PG_SHIFT; + i = (v - 0x40000000) >> PGSHIFT; if (i < pmap->pm_pcb->P1LR) panic("pmap_enter: must expand P1"); } else { patch = (int *)Sysmap; - i = (v - (u_int)0x80000000) >> PG_SHIFT; + i = (v - (u_int)0x80000000) >> PGSHIFT; } if ((patch[i] & PG_FRAME) == (pte & PG_FRAME)) { /* no map change */ @@ -419,7 +418,9 @@ pmap_map(virtuell, pstart, pend, prot) int *pentry; #ifdef DEBUG -if(startpmapdebug)printf("pmap_map: virt %x, pstart %x, pend %x\n",virtuell, pstart, pend); +if(startpmapdebug) + printf("pmap_map: virt %x, pstart %x, pend %x, Sysmap %x\n", + virtuell, pstart, pend, Sysmap); #endif pstart=(uint)pstart &0x7fffffff; @@ -445,7 +446,7 @@ if(startpmapdebug)printf("pmap_extract: pmap %x, va %x\n",pmap, va); #endif pte=(int *)pmap_virt2pte(pmap,va); - if(pte) return(((*pte&PG_FRAME)<<PG_SHIFT)+((u_int)va&PGOFSET)); + if(pte) return(((*pte&PG_FRAME)<<PGSHIFT)+((u_int)va&PGOFSET)); else return 0; } @@ -471,14 +472,14 @@ if(startpmapdebug) printf("pmap_protect: pmap %x, start %x, end %x, prot %x\n", else pte=prot_array[prot]; if(end<0x40000000){ - while((end>>PG_SHIFT)>(pmap->pm_pcb->P0LR&~AST_MASK)) - pmap_expandp0(pmap,(end>>PG_SHIFT)); + while((end>>PGSHIFT)>(pmap->pm_pcb->P0LR&~AST_MASK)) + pmap_expandp0(pmap,(end>>PGSHIFT)); } else if(end<(u_int)0x80000000){ u_int i; - i=(start&0x3fffffff)>>PG_SHIFT; + i=(start&0x3fffffff)>>PGSHIFT; if(i<pmap->pm_pcb->P1LR) - start=((pmap->pm_pcb->P1LR)<<PG_SHIFT)+0x40000000; - i=(end&0x3fffffff)>>PG_SHIFT; + start=((pmap->pm_pcb->P1LR)<<PGSHIFT)+0x40000000; + i=(end&0x3fffffff)>>PGSHIFT; if(i<pmap->pm_pcb->P1LR) return; } while (start < end) { @@ -519,17 +520,17 @@ if(startpmapdebug) printf("pmap_remove: pmap=0x %x, start=0x %x, slut=0x %x\n", /* First, get pte first address */ if(start<0x40000000){ /* P0 */ if(!(temp=pmap->pm_pcb->P0BR)) return; /* No page table */ - ptestart=&temp[start>>PG_SHIFT]; - pteslut=&temp[slut>>PG_SHIFT]; + ptestart=&temp[start>>PGSHIFT]; + pteslut=&temp[slut>>PGSHIFT]; if(pteslut>&temp[(pmap->pm_pcb->P0LR&~AST_MASK)]) pteslut=&temp[(pmap->pm_pcb->P0LR&~AST_MASK)]; } else if(start>0x7fffffff){ /* System region */ - ptestart=(u_int *)&Sysmap[(start&0x3fffffff)>>PG_SHIFT]; - pteslut=(u_int *)&Sysmap[(slut&0x3fffffff)>>PG_SHIFT]; + ptestart=(u_int *)&Sysmap[(start&0x3fffffff)>>PGSHIFT]; + pteslut=(u_int *)&Sysmap[(slut&0x3fffffff)>>PGSHIFT]; } else { /* P1 (stack) region */ if(!(temp=pmap->pm_pcb->P1BR)) return; /* No page table */ - pteslut=&temp[(slut&0x3fffffff)>>PG_SHIFT]; - ptestart=&temp[(start&0x3fffffff)>>PG_SHIFT]; + pteslut=&temp[(slut&0x3fffffff)>>PGSHIFT]; + ptestart=&temp[(start&0x3fffffff)>>PGSHIFT]; if(ptestart<&temp[pmap->pm_pcb->P1LR]) ptestart=&temp[pmap->pm_pcb->P1LR]; } @@ -592,6 +593,7 @@ remove_pmap_from_mapping(pv, pmap) return 1; } +#ifndef notyet void pmap_copy_page(src, dst) vm_offset_t src; @@ -616,6 +618,37 @@ if(startpmapdebug)printf("pmap_copy_page: src %x, dst %x\n",src, dst); bcopy((void *)vmmap, (void *)vmmap+NBPG, NBPG); splx(s); } +#else + asm(" + +_pmap_copy_page:.globl _pmap_copy_page + + .word 64 + mfpr $0x12, r6 + mtpr $0x16, $0x12 # splimp(); + movl _vmmap, r0 + movl _pte_cmap, r1 + + ashl $-9, 4(ap), r2 # pte_cmap[0]=(src>>PGSHIFT)|PG_V|PG_RO; + bisl3 $0xf8000000, r2, (r1) + addl2 $4, r1 + addl3 $1, r2, (r1)+ + + ashl $-9, 8(ap), r2 # pte_cmap[1]=(dst>>PGSHIFT)|PG_V|PG_KW; + bisl3 $0xa0000000, r2, (r1) + addl2 $4, r1 + addl3 $1, r2, (r1) + + mtpr $0, $57 # mtpr(0, PR_TBIA); + + addl3 $1024, r0, r1 # bcopy(vmmap, vmmap + 2 * NBPG, 2 * NBPG); + movc3 $1024, (r0), (r1) + + mtpr r6, $0x12 + ret + + "); +#endif pv_entry_t alloc_pv_entry() @@ -625,6 +658,10 @@ alloc_pv_entry() if(!pv_head) { temporary=(pv_entry_t)malloc(sizeof(struct pv_entry), M_VMPVENT, M_NOWAIT); +#ifdef DIAGNOSTIC + if (temporary == 0) + panic("alloc_pv_entry"); +#endif #ifdef DEBUG if(startpmapdebug) printf("alloc_pv_entry: %x\n",temporary); #endif @@ -837,7 +874,7 @@ if(startpmapdebug)printf("pmap_zero_page(phys %x, vmmap %x, pte_cmap %x\n", phys,vmmap,pte_cmap); #endif s=splimp(); - pte_cmap[0]=(phys>>PG_SHIFT)|PG_V|PG_KW; + pte_cmap[0]=(phys>>PGSHIFT)|PG_V|PG_KW; pte_cmap[1]=pte_cmap[0]+1; mtpr(vmmap,PR_TBIS); mtpr(vmmap+NBPG,PR_TBIS); @@ -857,17 +894,17 @@ pmap_virt2pte(pmap,vaddr) if(vaddr<0x40000000){ pte=pmap->pm_pcb->P0BR; - if((vaddr>>PG_SHIFT)>(pmap->pm_pcb->P0LR&~AST_MASK)) return 0; + if((vaddr>>PGSHIFT)>(pmap->pm_pcb->P0LR&~AST_MASK)) return 0; } else if(vaddr<(u_int)0x80000000){ pte=pmap->pm_pcb->P1BR; - if(((vaddr&0x3fffffff)>>PG_SHIFT)<pmap->pm_pcb->P1LR) return 0; + if(((vaddr&0x3fffffff)>>PGSHIFT)<pmap->pm_pcb->P1LR) return 0; } else { pte=(u_int *)Sysmap; } vaddr&=(u_int)0x3fffffff; - return((pt_entry_t *)&pte[vaddr>>PG_SHIFT]); + return((pt_entry_t *)&pte[vaddr>>PGSHIFT]); } pmap_expandp0(pmap,ny_storlek) diff --git a/sys/arch/vax/vax/sbi.c b/sys/arch/vax/vax/sbi.c index 5306145e1a0..84e4e5c9f1c 100644 --- a/sys/arch/vax/vax/sbi.c +++ b/sys/arch/vax/vax/sbi.c @@ -1,4 +1,4 @@ -/* $NetBSD: sbi.c,v 1.2 1995/02/23 17:54:03 ragge Exp $ */ +/* $NetBSD: sbi.c,v 1.3 1995/11/10 19:14:43 ragge Exp $ */ /* * Copyright (c) 1994 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -29,20 +29,19 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - /* All bugs are subject to removal without further notice */ - - #include "sys/types.h" #include "sys/param.h" #include "sys/device.h" #include "vm/vm.h" #include "vm/vm_kern.h" #include "vm/vm_page.h" -#include "machine/nexus.h" +#include "machine/ka750.h" #include "machine/pmap.h" #include "machine/sid.h" -static int sbi_attached=0; +struct nexus *nexus; + +static int sbi_attached = 0; struct bp_conf { char *type; @@ -55,23 +54,23 @@ sbi_print(aux, name) void *aux; char *name; { - struct sbi_attach_args *sa=(struct sbi_attach_args *)aux; - int unsupp=0; + struct sbi_attach_args *sa = (struct sbi_attach_args *)aux; + int unsupp = 0; extern int nmba; - if(name){ - switch(sa->type){ + if (name) { + switch (sa->type) { case NEX_MBA: printf("mba%d at %s",nmba++, name); unsupp++; break; default: - printf("unknown device 0x%x at %s",sa->type,name); + printf("unknown device 0x%x at %s", sa->type, name); unsupp++; } } - printf(" tr%d",sa->nexnum); - return(unsupp?UNSUPP:UNCONF); + printf(" tr%d", sa->nexnum); + return (unsupp ? UNSUPP : UNCONF); } int @@ -80,9 +79,9 @@ sbi_match(parent, cf, aux) struct cfdata *cf; void *aux; { - struct bp_conf *bp=aux; + struct bp_conf *bp = aux; - if(strcmp(bp->type,"sbi")) + if (strcmp(bp->type, "sbi")) return 1; return 0; } @@ -93,69 +92,64 @@ sbi_attach(parent, self, aux) void *aux; { void *nisse; - struct nexus *nexus; u_int nextype, nexnum, maxnex; struct sbi_attach_args sa; - /* SBI space should be alloc'ed in SYSPT instead */ - kmem_suballoc(kernel_map, (void*)&nexus, (void*)&nisse, - (NNEXSBI*sizeof(struct nexus)), FALSE); - switch(cpunumber){ + switch (cpunumber) { #ifdef VAX730 case VAX_730: - pmap_map((int)nexus, 0xf20000, 0xf40000, VM_PROT_READ|VM_PROT_WRITE); - maxnex = NNEX730; - printf(": BL[730\n"); - break; + maxnex = NNEX730; + printf(": BL[730\n"); + break; #endif #ifdef VAX750 case VAX_750: - pmap_map((int)nexus, 0xf20000, 0xf40000, VM_PROT_READ|VM_PROT_WRITE); - maxnex = NNEX750; - printf(": CMI750\n"); - break; + maxnex = NNEX750; + printf(": CMI750\n"); + break; #endif #ifdef VAX630 case VAX_78032: - switch (cpu_type) { - case VAX_630: - pmap_map((int)nexus, 0x20088000, 0x200a8000, - VM_PROT_READ|VM_PROT_WRITE); - maxnex = NNEX630; - printf(": Q22\n"); + switch (cpu_type) { + case VAX_630: + maxnex = NNEX630; + printf(": Q22\n"); + break; + default: + panic("Microvax not supported"); + }; break; - default: - panic("Microvax not supported"); - }; - break; #endif - +#if VAX780 || VAX8600 case VAX_780: case VAX_8600: - maxnex = NNEXSBI; - printf(": SBI780\n"); + maxnex = NNEXSBI; + printf(": SBI780\n"); + break; +#endif } -/* - * Now a problem: on different machines with SBI units identifies - * in different ways (if they identifies themselves at all). - * We have to fake identifying depending on different CPUs. - */ - for(nexnum=0;nexnum<maxnex;nexnum++){ - if(badaddr((caddr_t)&nexus[nexnum],4))continue; + /* + * Now a problem: on different machines with SBI units identifies + * in different ways (if they identifies themselves at all). + * We have to fake identifying depending on different CPUs. + */ + for (nexnum = 0; nexnum < maxnex; nexnum++) { + if (badaddr((caddr_t)&nexus[nexnum], 4)) + continue; switch(cpunumber){ #ifdef VAX750 case VAX_750: { extern int nexty750[]; - sa.type=nexty750[nexnum]; + sa.type = nexty750[nexnum]; break; } #endif #ifdef VAX730 case VAX_730: { extern int nexty730[]; - sa.type=nexty730[nexnum]; + sa.type = nexty730[nexnum]; break; } #endif @@ -165,10 +159,10 @@ sbi_attach(parent, self, aux) break; #endif default: - sa.type=nexus[nexnum].nexcsr.nex_type; + sa.type = nexus[nexnum].nexcsr.nex_type; } - sa.nexnum=nexnum; - sa.nexaddr=nexus+nexnum; + sa.nexnum = nexnum; + sa.nexaddr = nexus + nexnum; config_found(self, (void*)&sa, sbi_print); } } diff --git a/sys/arch/vax/vax/subr.s b/sys/arch/vax/vax/subr.s index a0d9d5d6b73..34692c377f8 100644 --- a/sys/arch/vax/vax/subr.s +++ b/sys/arch/vax/vax/subr.s @@ -1,4 +1,4 @@ -/* $NetBSD: subr.s,v 1.11 1995/06/16 15:36:50 ragge Exp $ */ +/* $NetBSD: subr.s,v 1.12 1995/11/10 19:08:59 ragge Exp $ */ /* * Copyright (c) 1994 Ludd, University of Lule}, Sweden. @@ -33,16 +33,14 @@ /* All bugs are subject to removal without further notice */ - -#include "vax/include/mtpr.h" -#include "vax/include/param.h" -#include "vax/include/loconf.h" -#include "vax/include/vmparam.h" -#include "vax/include/pte.h" -#include "vax/include/nexus.h" #include "sys/syscall.h" #include "sys/errno.h" +#include "machine/mtpr.h" +#include "machine/vmparam.h" +#include "machine/pte.h" +#include "machine/nexus.h" + .text @@ -57,6 +55,15 @@ _sigcode: pushr $0x3f .align 2 _esigcode: + .globl _idsptch, _eidsptch +_idsptch: pushr $0x3f + pushl $1 + nop + calls $1, *$0x12345678 + popr $0x3f + rei +_eidsptch: + .globl _subyte _subyte: .word 0x0 movl 4(ap),r0 @@ -78,36 +85,6 @@ _fubyte: .word 0x0 ret - - - - - - .globl _physcopypage -_physcopypage: .word 0x7 - movl 4(ap),r0 - ashl $-PGSHIFT,r0,r0 - bisl2 $(PG_V|PG_RO),r0 - - movl 8(ap),r1 - ashl $-PGSHIFT,r1,r1 - bisl2 $(PG_V|PG_KW),r1 - - movl r0,*(_pte_cmap) - movl r1,*$4+(_pte_cmap) - - movl _vmmap,r2 - addl3 $0x200,r2,r1 - mtpr r1,$PR_TBIS - mtpr r2,$PR_TBIS - - movl r1,r0 -1: movl (r2)+,(r1)+ - cmpl r0,r2 - bneq 1b - ret - - .globl _badaddr _badaddr: .word 0x0 # Called with addr,b/w/l @@ -243,16 +220,6 @@ _rei: rei .data -mbanum: .long 0 - - -/*** DATA ********************************************************************/ - - - -_pte_cmap: .long 0 ; .globl _pte_cmap /* Address of PTE - corresponding to cmap */ - _memtest: .long 0 ; .globl _memtest # Memory test in progress. #ifdef DDB diff --git a/sys/arch/vax/vax/trap.c b/sys/arch/vax/vax/trap.c index 3db706dee09..8961109a762 100644 --- a/sys/arch/vax/vax/trap.c +++ b/sys/arch/vax/vax/trap.c @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.13 1995/07/05 08:39:48 ragge Exp $ */ +/* $NetBSD: trap.c,v 1.14 1995/11/12 14:33:13 ragge Exp $ */ /* * Copyright (c) 1994 Ludd, University of Lule}, Sweden. @@ -140,6 +140,10 @@ faulter: if (kdb_trap(frame)) return; #endif + printf("Trap: type %x, code %x, pc %x, psl %x\n", + frame->trap, frame->code, frame->pc, frame->psl); + showregs(frame); +asm("halt"); panic("trap: adr %x",frame->code); case T_KSPNOTVAL: goto faulter; @@ -154,8 +158,8 @@ faulter: else ptep=(u_int *)p->p_addr->u_pcb.P1BR; pte1=(u_int *)trunc_page(&ptep[(frame->code - &0x3fffffff)>>PG_SHIFT]); - pte=(u_int*)&Sysmap[((u_int)pte1&0x3fffffff)>>PG_SHIFT]; + &0x3fffffff)>>PGSHIFT]); + pte=(u_int*)&Sysmap[((u_int)pte1&0x3fffffff)>>PGSHIFT]; if(*pte&PG_SREF){ /* Yes, simulated */ s=splhigh(); @@ -171,13 +175,13 @@ faulter: frame->code=trunc_page(frame->code); if(frame->code<0x40000000){ ptep=(u_int *)p->p_addr->u_pcb.P0BR; - pte=&ptep[(frame->code>>PG_SHIFT)]; + pte=&ptep[(frame->code>>PGSHIFT)]; } else if(frame->code>0x7fffffff){ pte=(u_int *)&Sysmap[((u_int)frame->code& - 0x3fffffff)>>PG_SHIFT]; + 0x3fffffff)>>PGSHIFT]; } else { ptep=(u_int *)p->p_addr->u_pcb.P1BR; - pte=&ptep[(frame->code&0x3fffffff)>>PG_SHIFT]; + pte=&ptep[(frame->code&0x3fffffff)>>PGSHIFT]; } if(*pte&PG_SREF){ s=splhigh(); @@ -208,10 +212,10 @@ if(faultdebug)printf("trap accflt type %x, code %x, pc %x, psl %x\n", if(P0){ faultaddr=(u_int)pm->pm_pcb->P0BR+ - ((testaddr>>PG_SHIFT)<<2); + ((testaddr>>PGSHIFT)<<2); } else if(P1){ faultaddr=(u_int)pm->pm_pcb->P1BR+ - ((testaddr>>PG_SHIFT)<<2); + ((testaddr>>PGSHIFT)<<2); } else panic("pageflt: PTE fault in SPT\n"); faultaddr&=~PAGE_MASK; @@ -413,31 +417,6 @@ stray(scb, vec){ printf("stray interrupt scb %d, vec 0x%x\n", scb, vec); } -struct inta { - char pushr[2]; /* pushr $3f */ - char pushl[2]; /* pushl $? */ - char nop; /* nop, for foolish gcc */ - char calls[3]; /* $1,? */ - u_int hoppaddr; /* jump for calls */ - char popr[2]; /* popr $0x3f */ - char rei; /* rei */ -} intasm = {0xbb, 0x3f, 0xdd, 0, 1, 0xfb, 1, 0xef, 0, 0xba, 0x3f, 2}; - -u_int -settrap(plats, nyrut,arg) - u_int plats; /* Pointer to place to copy interrupt routine */ - u_int nyrut; /* Pointer to new routine to jump to */ - u_int arg; /* arg number to pass to routine. */ -{ - struct inta *introut; - - introut=(void *)((plats&0xfffffffc)+4); - bcopy(&intasm, introut, sizeof(struct inta)); - introut->pushl[1]=arg; - introut->hoppaddr=nyrut-(u_int)&introut->popr[0]; - return (u_int)introut; -} - printstack(loaddr, highaddr) u_int *loaddr, *highaddr; { diff --git a/sys/arch/vax/vax/uvaxII.c b/sys/arch/vax/vax/uvaxII.c index 3b617d2dc36..f3f1053d441 100644 --- a/sys/arch/vax/vax/uvaxII.c +++ b/sys/arch/vax/vax/uvaxII.c @@ -1,4 +1,4 @@ -/* $NetBSD: uvaxII.c,v 1.2 1995/04/18 22:08:25 ragge Exp $ */ +/* $NetBSD: uvaxII.c,v 1.3 1995/11/10 18:52:58 ragge Exp $ */ /*- * Copyright (c) 1988 The Regents of the University of California. @@ -37,34 +37,28 @@ /* All bugs are subject to removal without further notice */ -#if VAX630 || VAX410 - #include "sys/param.h" #include "sys/types.h" #include "sys/device.h" +#include "vm/vm.h" +#include "vm/vm_kern.h" + #include "machine/uvaxII.h" -#include "machine/nexus.h" #include "machine/pte.h" #include "machine/mtpr.h" #include "machine/sid.h" -#include "vax/uba/ubavar.h" -#include "vax/uba/ubareg.h" - -#include "mba.h" -#include "uba.h" - -#include "vm/vm.h" -#include "vm/vm_kern.h" -#include "vax/include/pmap.h" +#include "machine/pmap.h" +#include "machine/nexus.h" -struct nexus *nexus; struct uvaxIIcpu *uvaxIIcpu_ptr; + #if VAX630 -struct ka630clock *ka630clk_ptr; -u_long ka630_clkread(); -void ka630_clkwrite(); +struct ka630clock *ka630clk_ptr; +u_long ka630_clkread(); +void ka630_clkwrite(); #endif -extern int cpu_type, nmba, numuba; + +extern int cpu_type; int uvaxII_conf() @@ -251,12 +245,48 @@ ka630_clkwrite(year_secs) claddr->min = t / MINSEC; claddr->sec = t % MINSEC; #ifndef lint - { int t = claddr->csr2; } /* ??? */ - { int t = claddr->csr3; } /* ??? */ + { volatile int t = claddr->csr2; } /* ??? */ + { volatile int t = claddr->csr3; } /* ??? */ #endif claddr->csr0 = KA630CLK_RATE; claddr->csr1 = KA630CLK_ENABLE; splx(s); } #endif -#endif + +uvaxII_steal_pages() +{ + extern vm_offset_t avail_start, virtual_avail, avail_end; + int junk; + + /* + * MicroVAX II: get 10 pages from top of memory, + * map in Qbus map registers, cpu and clock registers. + */ + avail_end -= 10; + + MAPPHYS(junk, 2, VM_PROT_READ|VM_PROT_WRITE); + MAPVIRT(nexus, btoc(0x400000)); + pmap_map((vm_offset_t)nexus, 0x20088000, 0x20090000, + VM_PROT_READ|VM_PROT_WRITE); + + MAPVIRT(uvaxIIcpu_ptr, 1); + pmap_map((vm_offset_t)uvaxIIcpu_ptr, (vm_offset_t)UVAXIICPU, + (vm_offset_t)UVAXIICPU + NBPG, VM_PROT_READ|VM_PROT_WRITE); + + MAPVIRT(ka630clk_ptr, 1); + pmap_map((vm_offset_t)ka630clk_ptr, (vm_offset_t)KA630CLK, + (vm_offset_t)KA630CLK + NBPG, VM_PROT_READ|VM_PROT_WRITE); + + /* + * Clear restart and boot in progress flags + * in the CPMBX. + / + ka630clk_ptr->cpmbx = (ka630clk_ptr->cpmbx & KA630CLK_LANG); + + /* + * Enable memory parity error detection and clear error bits. + */ + uvaxIIcpu_ptr->uvaxII_mser = (UVAXIIMSER_PEN | UVAXIIMSER_MERR | + UVAXIIMSER_LEB); +} diff --git a/sys/arch/vax/vax/vm_machdep.c b/sys/arch/vax/vax/vm_machdep.c index a33f58daa38..78bb452bb1b 100644 --- a/sys/arch/vax/vax/vm_machdep.c +++ b/sys/arch/vax/vax/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.16.2.1 1995/10/15 14:01:06 ragge Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.17 1995/11/10 19:07:16 ragge Exp $ */ #undef SWDEBUG /* |