From 4686adac0c93cd95157efe400c132c390128fa4d Mon Sep 17 00:00:00 2001 From: Bill Joy Date: Sun, 18 Nov 1990 19:32:13 -0800 Subject: [PATCH] auto conf, bus control, conventions, interrupt control, per host config SCCS-vsn: sys/i386/isa/clock.c 5.4 SCCS-vsn: sys/i386/isa/pccons.c 5.4 SCCS-vsn: sys/i386/isa/fd.c 5.3 SCCS-vsn: sys/i386/isa/if_ne.c 1.5 SCCS-vsn: sys/i386/isa/if_we.c 5.4 SCCS-vsn: sys/i386/isa/isa.c 1.2 SCCS-vsn: sys/i386/isa/npx.c 1.2 SCCS-vsn: sys/i386/isa/wd.c 5.8 SCCS-vsn: sys/i386/isa/wt.c 1.2 SCCS-vsn: sys/i386/isa/icu.h 5.4 SCCS-vsn: sys/i386/isa/icu.s 5.4 SCCS-vsn: sys/i386/isa/isa.h 5.5 --- usr/src/sys/i386/isa/clock.c | 16 +- usr/src/sys/i386/isa/fd.c | 4 +- usr/src/sys/i386/isa/icu.h | 98 ++++++++- usr/src/sys/i386/isa/icu.s | 394 +++++++++++++++++++++++----------- usr/src/sys/i386/isa/if_ne.c | 4 +- usr/src/sys/i386/isa/if_we.c | 4 +- usr/src/sys/i386/isa/isa.c | 134 +++++++++++- usr/src/sys/i386/isa/isa.h | 41 ++-- usr/src/sys/i386/isa/npx.c | 64 +++--- usr/src/sys/i386/isa/pccons.c | 4 +- usr/src/sys/i386/isa/wd.c | 4 +- usr/src/sys/i386/isa/wt.c | 4 +- 12 files changed, 579 insertions(+), 192 deletions(-) diff --git a/usr/src/sys/i386/isa/clock.c b/usr/src/sys/i386/isa/clock.c index dfc401b663..fa140324d0 100644 --- a/usr/src/sys/i386/isa/clock.c +++ b/usr/src/sys/i386/isa/clock.c @@ -9,7 +9,7 @@ * * %sccs.include.386.c% * - * @(#)clock.c 5.3 (Berkeley) %G% + * @(#)clock.c 5.4 (Berkeley) %G% */ /* @@ -18,8 +18,9 @@ #include "param.h" #include "time.h" #include "kernel.h" -#include "icu.h" -#include "isa.h" +#include "machine/segments.h" +#include "machine/isa/icu.h" +#include "machine/isa/isa.h" #define DAYST 119 #define DAYEN 303 @@ -27,9 +28,9 @@ startrtclock() { /* initialize 8253 clock */ - outb (IO_TIMER0+3, 0x36); - outb (IO_TIMER0, 1193182/hz); - outb (IO_TIMER0, (1193182/hz)/256); + outb (IO_TIMER1+3, 0x36); + outb (IO_TIMER1, 1193182/hz); + outb (IO_TIMER1, (1193182/hz)/256); } /* convert 2 digit BCD number */ @@ -153,7 +154,10 @@ resettodr() { } +#define V(s) V/**/s +extern V(clk)(); enablertclock() { INTREN(IRQ0); + setidt(ICU_OFFSET+0, &V(clk), SDT_SYS386IGT, SEL_KPL); splnone(); } diff --git a/usr/src/sys/i386/isa/fd.c b/usr/src/sys/i386/isa/fd.c index 39adfccf1c..d0fd7a9a9b 100644 --- a/usr/src/sys/i386/isa/fd.c +++ b/usr/src/sys/i386/isa/fd.c @@ -9,7 +9,7 @@ * * %sccs.include.386.c% * - * @(#)fd.c 5.2 (Berkeley) %G% + * @(#)fd.c 5.3 (Berkeley) %G% */ /****************************************************************************/ @@ -28,7 +28,7 @@ #include "vm.h" #include "uio.h" #include "machine/pte.h" -#include "machine/isa/device.h" +#include "machine/isa/isa_device.h" #include "machine/isa/fdreg.h" #include "icu.h" diff --git a/usr/src/sys/i386/isa/icu.h b/usr/src/sys/i386/isa/icu.h index 5a29a9fb87..8b7fd7f12e 100644 --- a/usr/src/sys/i386/isa/icu.h +++ b/usr/src/sys/i386/isa/icu.h @@ -7,7 +7,7 @@ * * %sccs.include.386.c% * - * @(#)icu.h 5.3 (Berkeley) %G% + * @(#)icu.h 5.4 (Berkeley) %G% */ /* @@ -19,19 +19,99 @@ #define __ICU__ #ifndef LOCORE + +/* + * Interrupt "level" mechanism variables, masks, and macros + */ extern unsigned short imen; /* interrupt mask enable */ -extern unsigned short cpl; /* current priority level */ +extern unsigned short cpl; /* current priority level mask */ -extern unsigned short ttymask; /* things that get masked with spltty() */ -extern unsigned short biomask; /* things that get masked with splbio() */ -extern unsigned short netmask; /* things that get masked with splimp() */ +extern unsigned short highmask; /* group of interrupts masked with splhigh() */ +extern unsigned short ttymask; /* group of interrupts masked with spltty() */ +extern unsigned short biomask; /* group of interrupts masked with splbio() */ +extern unsigned short netmask; /* group of interrupts masked with splimp() */ #define INTREN(s) imen &= ~(s) #define INTRDIS(s) imen |= (s) #define INTRMASK(msk,s) msk |= (s) + +#else + +/* + * Macro's for interrupt level priority masks (used in interrupt vector entry) + */ + +/* Just mask this interrupt only */ +#define INTR(a) \ + pushl $0 ; \ + pushl $ T_ASTFLT ; \ + pushal ; \ + push %ds ; \ + push %es ; \ + movw $0x10, %ax ; \ + movw %ax, %ds ; \ + movw %ax,%es ; \ + incl _cnt+V_INTR ; \ + movzwl _cpl,%eax ; \ + pushl %eax ; \ + pushl $ a ; \ + orw $ IRQ/**/a ,%ax ; \ + movw %ax,_cpl ; \ + orw _imen,%ax ; \ + NOP ; \ + outb %al,$ IO_ICU1+1 ; \ + NOP ; \ + movb %ah,%al ; \ + outb %al,$ IO_ICU2+1 ; \ + NOP ; \ + sti + +/* Mask a group of interrupts atomically */ +#define INTRN(a,b) \ + pushl $0 ; \ + pushl $ T_ASTFLT ; \ + pushal ; \ + push %ds ; \ + push %es ; \ + movw $0x10, %ax ; \ + movw %ax, %ds ; \ + movw %ax,%es ; \ + incl _cnt+V_INTR ; \ + movzwl _cpl,%eax ; \ + pushl %eax ; \ + pushl $ a ; \ + orw $ IRQ/**/a ,%ax ; \ + orw b ,%ax ; \ + movw %ax,_cpl ; \ + orw _imen,%ax ; \ + NOP ; \ + outb %al,$ IO_ICU1+1 ; \ + NOP ; \ + movb %ah,%al ; \ + outb %al,$ IO_ICU2+1 ; \ + NOP ; \ + sti + +/* Interrupt vector exit macros */ + +/* First eight interrupts (ICU1) */ +#define INTREXT1 \ + movb $0x20,%al ; \ + outb %al,$ IO_ICU1 ; \ + jmp doreti + +/* Second eight interrupts (ICU2) */ +#define INTREXT2 \ + movb $0x20,%al ; \ + outb %al,$ IO_ICU1 ; \ + outb %al,$ IO_ICU2 ; \ + jmp doreti + #endif -/* Interrupt enable bits -- in order of priority */ +/* + * Interrupt enable bits -- in order of priority + */ #define IRQ0 0x0001 /* highest priority - timer */ #define IRQ1 0x0002 #define IRQ_SLAVE 0x0004 @@ -50,4 +130,10 @@ extern unsigned short netmask; /* things that get masked with splimp() */ #define IRQ6 0x0040 #define IRQ7 0x0080 /* lowest - parallel printer */ +/* + * Interrupt Control offset into Interrupt descriptor table (IDT) + */ +#define ICU_OFFSET 32 /* 0-31 are processor exceptions */ +#define ICU_LEN 16 /* 32-47 are ISA interrupts */ + #endif __ICU__ diff --git a/usr/src/sys/i386/isa/icu.s b/usr/src/sys/i386/isa/icu.s index 37dde52d4a..42a1880414 100644 --- a/usr/src/sys/i386/isa/icu.s +++ b/usr/src/sys/i386/isa/icu.s @@ -7,7 +7,7 @@ * * %sccs.include.386.c% * - * @(#)icu.s 5.3 (Berkeley) %G% + * @(#)icu.s 5.4 (Berkeley) %G% */ /* @@ -21,20 +21,130 @@ .globl _cpl _cpl: .long 0xffff # current priority level (all off) _imen: .long 0xffff # interrupt mask enable (all off) + .globl _highmask +_highmask: .long 0xffff .globl _ttymask _ttymask: .long 0 .globl _biomask _biomask: .long 0 .globl _netmask _netmask: .long 0 + .text +/* + * Handle return from interrupt after device handler finishes + */ +doreti: + cli + popl %ebx # remove intr number + popl %eax # get previous priority + # now interrupt frame is a trap frame! + movw %ax,%cx + movw %ax,_cpl + orw _imen,%ax + NOP + outb %al,$ IO_ICU1+1 # re-enable intr? + NOP + movb %ah,%al + NOP + outb %al,$ IO_ICU2+1 + NOP + + andw $0xffff,%cx + cmpw $0,%cx # returning to zero? + je 1f + + pop %es # nope, going to non-zero level + pop %ds + popa + addl $8,%esp + iret + +1: cmpl $0,_netisr # check for softint s/traps + jne 1f + + pop %es # none, going back to base pri + pop %ds + popa + addl $8,%esp + iret + +#include "../net/netisr.h" + +1: + +#define DONET(s, c) ; \ + .globl c ; \ + movl $ s ,%eax ; \ + btrl %eax,_netisr ; \ + jnb 1f ; \ + call c ; \ +1: + + call _splnet + pushl %eax + + DONET(NETISR_RAW,_rawintr) +#ifdef INET + DONET(NETISR_IP,_ipintr) +#endif +#ifdef IMP + DONET(NETISR_IMP,_impintr) +#endif +#ifdef NS + DONET(NETISR_NS,_nsintr) +#endif + + popl %eax + movw %ax,_cpl + orw _imen,%ax + NOP + outb %al,$ IO_ICU1+1 # re-enable intr? + NOP + movb %ah,%al + NOP + outb %al,$ IO_ICU2+1 + NOP + + # btrl $ NETISR_SCLK,_netisr + movl $ NETISR_SCLK,%eax # stupid assembler, as usual + btrl %eax,_netisr + jnb 1f + # back to an interrupt frame for a moment + call _splsoftclock + pushl %eax + pushl $0xff # dummy intr + call _softclock + popl %eax + call _splx + popl %eax + + jmp 2f + + /* 1: btrl $NETISR_AST,_netisr*/ +1: + cmpw $0x1f,13*4(%esp) # to user? + jne 2f # nope, leave + movl $ NETISR_AST,%eax # stupid assembler, as usual + btrl %eax,_netisr + jnb 2f + call _trap + +2: pop %es + pop %ds + popal + addl $8,%esp + iret + +/* + * Interrupt priority mechanism + * + * Two flavors -- imlXX masks relative to ISA noemenclature (for PC compat sw) + * -- splXX masks with group mechanism for BSD purposes + */ - .globl _iml0 # masks off all interrupts .globl _splhigh .globl _splclock - .globl _spl6 -_iml0: -_spl6: _splhigh: _splclock: cli # disable interrupts @@ -43,20 +153,18 @@ _splclock: # orw _imen,%ax # mask off those not enabled yet movw %ax,%cx NOP - outb %al,$0x21 /* update icu's */ + outb %al,$ IO_ICU1+1 /* update icu's */ NOP movb %ah,%al NOP - outb %al,$0xA1 + outb %al,$ IO_ICU2+1 NOP movzwl _cpl,%eax # return old priority movw %dx,_cpl # set new priority level sti # enable interrupts ret - .globl _iml1 # mask off all but irq0 .globl _spltty # block clists -_iml1: _spltty: cli # disable interrupts movw _cpl,%ax @@ -65,338 +173,384 @@ _spltty: orw _imen,%ax # mask off those not enabled yet movw %ax,%cx NOP - outb %al,$0x21 /* update icu's */ + outb %al,$ IO_ICU1+1 /* update icu's */ NOP movb %ah,%al NOP - outb %al,$0xA1 + outb %al,$ IO_ICU2+1 NOP movzwl _cpl,%eax # return old priority movw %dx,_cpl # set new priority level sti # enable interrupts ret - .globl _iml8 # mask off all but irq0-1 -_iml8: + .globl _splimp + .globl _splnet +_splimp: +_splnet: cli # disable interrupts - movw $0xfffc,%ax # set new priority level + movw _cpl,%ax + orw _netmask,%ax movw %ax,%dx orw _imen,%ax # mask off those not enabled yet movw %ax,%cx NOP - outb %al,$0x21 /* update icu's */ + outb %al,$ IO_ICU1+1 /* update icu's */ NOP movb %ah,%al NOP - outb %al,$0xA1 + outb %al,$ IO_ICU2+1 NOP movzwl _cpl,%eax # return old priority movw %dx,_cpl # set new priority level sti # enable interrupts ret - .globl _iml9 # mask off all but irq0-1,8 - .globl _iml2 # alias for PC hardware level 2 - .globl _splimp - .globl _splnet -_iml9: -_iml2: -_splimp: -_splnet: + .globl _splbio +_splbio: cli # disable interrupts movw _cpl,%ax - orw _netmask,%ax + orw _biomask,%ax movw %ax,%dx orw _imen,%ax # mask off those not enabled yet movw %ax,%cx NOP - outb %al,$0x21 /* update icu's */ + outb %al,$ IO_ICU1+1 /* update icu's */ NOP movb %ah,%al NOP - outb %al,$0xA1 + outb %al,$ IO_ICU2+1 NOP movzwl _cpl,%eax # return old priority movw %dx,_cpl # set new priority level sti # enable interrupts ret - .globl _iml10 # mask off all but irq0-1,8-9 -_iml10: + .globl _splsoftclock +_splsoftclock: cli # disable interrupts - movw $0xfcf8,%ax # set new priority level + movw _cpl,%ax + orw $0x8000,%ax # set new priority level movw %ax,%dx orw _imen,%ax # mask off those not enabled yet movw %ax,%cx NOP - outb %al,$0x21 /* update icu's */ + outb %al,$ IO_ICU1+1 /* update icu's */ NOP movb %ah,%al NOP - outb %al,$0xA1 + outb %al,$ IO_ICU2+1 NOP movzwl _cpl,%eax # return old priority movw %dx,_cpl # set new priority level sti # enable interrupts ret - .globl _iml11 # mask off all but irq0-1,8-10 -_iml11: + .globl _splnone + .globl _spl0 +_splnone: +_spl0: cli # disable interrupts - movw $0xf8f8,%ax # set new priority level - movw %ax,%dx + pushl _cpl # save old priority + movw _cpl,%ax + orw _netmask,%ax # mask off those network devices + movw %ax,_cpl # set new priority level orw _imen,%ax # mask off those not enabled yet - movw %ax,%cx NOP - outb %al,$0x21 /* update icu's */ + outb %al,$ IO_ICU1+1 /* update icu's */ NOP movb %ah,%al NOP - outb %al,$0xA1 + outb %al,$ IO_ICU2+1 NOP - movzwl _cpl,%eax # return old priority - movw %dx,_cpl # set new priority level sti # enable interrupts - ret - .globl _iml12 # mask off all but irq0-1,8-11 -_iml12: + DONET(NETISR_RAW,_rawintr) +#ifdef INET + DONET(NETISR_IP,_ipintr) +#endif cli # disable interrupts - movw $0xf0f8,%ax # set new priority level + popl _cpl # save old priority + movw $0,%ax # set new priority level movw %ax,%dx orw _imen,%ax # mask off those not enabled yet movw %ax,%cx NOP - outb %al,$0x21 /* update icu's */ + outb %al,$ IO_ICU1+1 /* update icu's */ NOP movb %ah,%al NOP - outb %al,$0xA1 + outb %al,$ IO_ICU2+1 NOP movzwl _cpl,%eax # return old priority movw %dx,_cpl # set new priority level sti # enable interrupts ret - .globl _iml13 # mask off all but irq0-1,8-12 -_iml13: + .globl _splx +_splx: cli # disable interrupts - movw $0xe0f8,%ax # set new priority level + movw 4(%esp),%ax # new priority level movw %ax,%dx + cmpw $0,%dx + je _spl0 # going to "zero level" is special + orw _imen,%ax # mask off those not enabled yet movw %ax,%cx NOP - outb %al,$0x21 /* update icu's */ + outb %al,$ IO_ICU1+1 /* update icu's */ NOP movb %ah,%al NOP - outb %al,$0xA1 + outb %al,$ IO_ICU2+1 NOP movzwl _cpl,%eax # return old priority movw %dx,_cpl # set new priority level sti # enable interrupts ret - .globl _iml14 # mask off all but irq0-1,8-13 - .globl _splbio -_iml14: -_splbio: +#ifdef notyet + .globl _iml8 # mask off all but irq0-1 +_iml8: cli # disable interrupts - movw _cpl,%ax - orw _biomask,%ax + movw $0xfffc,%ax # set new priority level movw %ax,%dx orw _imen,%ax # mask off those not enabled yet movw %ax,%cx NOP - outb %al,$0x21 /* update icu's */ + outb %al,$ IO_ICU1+1 /* update icu's */ NOP movb %ah,%al NOP - outb %al,$0xA1 + outb %al,$ IO_ICU2+1 NOP movzwl _cpl,%eax # return old priority movw %dx,_cpl # set new priority level sti # enable interrupts ret - .globl _iml15 # mask off all but irq0-1,8-14 -_iml15: + .globl _iml10 # mask off all but irq0-1,8-9 +_iml10: cli # disable interrupts - movw $0x80f8,%ax # set new priority level + movw $0xfcf8,%ax # set new priority level movw %ax,%dx orw _imen,%ax # mask off those not enabled yet movw %ax,%cx NOP - outb %al,$0x21 /* update icu's */ + outb %al,$ IO_ICU1+1 /* update icu's */ NOP movb %ah,%al NOP - outb %al,$0xA1 + outb %al,$ IO_ICU2+1 NOP movzwl _cpl,%eax # return old priority movw %dx,_cpl # set new priority level sti # enable interrupts ret - .globl _iml3 # mask off all but irq0-1,8-15 -_iml3: + .globl _iml11 # mask off all but irq0-1,8-10 +_iml11: cli # disable interrupts - movw $0x00f8,%ax # set new priority level + movw $0xf8f8,%ax # set new priority level movw %ax,%dx orw _imen,%ax # mask off those not enabled yet movw %ax,%cx NOP - outb %al,$0x21 /* update icu's */ + outb %al,$ IO_ICU1+1 /* update icu's */ NOP movb %ah,%al NOP - outb %al,$0xA1 + outb %al,$ IO_ICU2+1 NOP movzwl _cpl,%eax # return old priority movw %dx,_cpl # set new priority level sti # enable interrupts ret - .globl _iml4 # mask off all but irq0-1,8-15,3 -_iml4: + .globl _iml12 # mask off all but irq0-1,8-11 +_iml12: cli # disable interrupts - movw $0x00f0,%ax # set new priority level + movw $0xf0f8,%ax # set new priority level movw %ax,%dx orw _imen,%ax # mask off those not enabled yet movw %ax,%cx NOP - outb %al,$0x21 /* update icu's */ + outb %al,$ IO_ICU1+1 /* update icu's */ NOP movb %ah,%al NOP - outb %al,$0xA1 + outb %al,$ IO_ICU2+1 NOP movzwl _cpl,%eax # return old priority movw %dx,_cpl # set new priority level sti # enable interrupts ret - .globl _iml5 # mask off all but irq0-1,8-15,3-4 -_iml5: + .globl _iml13 # mask off all but irq0-1,8-12 +_iml13: cli # disable interrupts - movw $0x00e0,%ax # set new priority level + movw $0xe0f8,%ax # set new priority level movw %ax,%dx orw _imen,%ax # mask off those not enabled yet movw %ax,%cx NOP - outb %al,$0x21 /* update icu's */ + outb %al,$ IO_ICU1+1 /* update icu's */ NOP movb %ah,%al NOP - outb %al,$0xA1 + outb %al,$ IO_ICU2+1 NOP movzwl _cpl,%eax # return old priority movw %dx,_cpl # set new priority level sti # enable interrupts ret - .globl _iml6 # mask off all but irq0-1,8-15,3-5 -_iml6: + .globl _iml15 # mask off all but irq0-1,8-14 +_iml15: cli # disable interrupts - movw $0x00c0,%ax # set new priority level + movw $0x80f8,%ax # set new priority level movw %ax,%dx orw _imen,%ax # mask off those not enabled yet movw %ax,%cx NOP - outb %al,$0x21 /* update icu's */ + outb %al,$ IO_ICU1+1 /* update icu's */ NOP movb %ah,%al NOP - outb %al,$0xA1 + outb %al,$ IO_ICU2+1 NOP movzwl _cpl,%eax # return old priority movw %dx,_cpl # set new priority level sti # enable interrupts ret - .globl _iml7,_splsoftclock # mask off all but irq0-1,8-15,3-7 -_iml7: -_splsoftclock: + .globl _iml3 # mask off all but irq0-1,8-15 +_iml3: cli # disable interrupts - movw _cpl,%ax - orw $0x8000,%ax # set new priority level + movw $0x00f8,%ax # set new priority level movw %ax,%dx orw _imen,%ax # mask off those not enabled yet movw %ax,%cx NOP - outb %al,$0x21 /* update icu's */ + outb %al,$ IO_ICU1+1 /* update icu's */ NOP movb %ah,%al NOP - outb %al,$0xA1 + outb %al,$ IO_ICU2+1 NOP movzwl _cpl,%eax # return old priority movw %dx,_cpl # set new priority level sti # enable interrupts ret - .globl _imlnone # masks off no interrupts - .globl _splnone - .globl _spl0 -_imlnone: -_splnone: -_spl0: + .globl _iml4 # mask off all but irq0-1,8-15,3 +_iml4: cli # disable interrupts - pushl _cpl # save old priority - movw _cpl,%ax - orw _netmask,%ax # mask off those network devices - movw %ax,_cpl # set new priority level + movw $0x00f0,%ax # set new priority level + movw %ax,%dx orw _imen,%ax # mask off those not enabled yet + movw %ax,%cx NOP - outb %al,$0x21 /* update icu's */ + outb %al,$ IO_ICU1+1 /* update icu's */ NOP movb %ah,%al NOP - outb %al,$0xA1 + outb %al,$ IO_ICU2+1 NOP + movzwl _cpl,%eax # return old priority + movw %dx,_cpl # set new priority level sti # enable interrupts + ret - DONET(NETISR_RAW,_rawintr) -#ifdef INET - DONET(NETISR_IP,_ipintr) -#endif + .globl _iml5 # mask off all but irq0-1,8-15,3-4 +_iml5: cli # disable interrupts - popl _cpl # save old priority - movw $0,%ax # set new priority level + movw $0x00e0,%ax # set new priority level movw %ax,%dx orw _imen,%ax # mask off those not enabled yet movw %ax,%cx NOP - outb %al,$0x21 /* update icu's */ + outb %al,$ IO_ICU1+1 /* update icu's */ NOP movb %ah,%al NOP - outb %al,$0xA1 + outb %al,$ IO_ICU2+1 NOP movzwl _cpl,%eax # return old priority movw %dx,_cpl # set new priority level sti # enable interrupts ret - .globl _splx -_splx: + .globl _iml6 # mask off all but irq0-1,8-15,3-5 +_iml6: cli # disable interrupts - movw 4(%esp),%ax # new priority level + movw $0x00c0,%ax # set new priority level movw %ax,%dx - cmpw $0,%dx - je _spl0 - orw _imen,%ax # mask off those not enabled yet movw %ax,%cx NOP - outb %al,$0x21 /* update icu's */ + outb %al,$ IO_ICU1+1 /* update icu's */ NOP movb %ah,%al NOP - outb %al,$0xA1 + outb %al,$ IO_ICU2+1 NOP movzwl _cpl,%eax # return old priority movw %dx,_cpl # set new priority level sti # enable interrupts ret +#endif notyet + + /* hardware interrupt catcher (IDT 32 - 47) */ + .globl _isa_strayintr + +IDTVEC(intr0) + INTR(0) ; call _isa_strayintr ; INTREXT1 + +IDTVEC(intr1) + INTR(1) ; call _isa_strayintr ; INTREXT1 + +IDTVEC(intr2) + INTR(2) ; call _isa_strayintr ; INTREXT1 + +IDTVEC(intr3) + INTR(3) ; call _isa_strayintr ; INTREXT1 + +IDTVEC(intr4) + INTR(4) ; call _isa_strayintr ; INTREXT1 + +IDTVEC(intr5) + INTR(5) ; call _isa_strayintr ; INTREXT1 + +IDTVEC(intr6) + INTR(6) ; call _isa_strayintr ; INTREXT1 + +IDTVEC(intr7) + INTR(7) ; call _isa_strayintr ; INTREXT1 + + +IDTVEC(intr8) + INTR(8) ; call _isa_strayintr ; INTREXT2 + +IDTVEC(intr9) + INTR(9) ; call _isa_strayintr ; INTREXT2 + +IDTVEC(intr10) + INTR(10) ; call _isa_strayintr ; INTREXT2 + +IDTVEC(intr11) + INTR(11) ; call _isa_strayintr ; INTREXT2 + +IDTVEC(intr12) + INTR(12) ; call _isa_strayintr ; INTREXT2 + +IDTVEC(intr13) + INTR(13) ; call _isa_strayintr ; INTREXT2 + +IDTVEC(intr14) + INTR(14) ; call _isa_strayintr ; INTREXT2 + +IDTVEC(intr15) + INTR(15) ; call _isa_strayintr ; INTREXT2 + diff --git a/usr/src/sys/i386/isa/if_ne.c b/usr/src/sys/i386/isa/if_ne.c index c8c18e0e03..f3dbcb8a87 100644 --- a/usr/src/sys/i386/isa/if_ne.c +++ b/usr/src/sys/i386/isa/if_ne.c @@ -3,7 +3,7 @@ /* * NE2000 Ethernet driver * Copyright (C) 1990 W. Jolitz - * @(#)if_ne.c 1.4 (Berkeley) %G% + * @(#)if_ne.c 1.5 (Berkeley) %G% * * Parts inspired from Tim Tucker's if_wd driver for the wd8003, * insight on the ne2000 gained from Robert Clements PC/FTP driver. @@ -36,7 +36,7 @@ #include "../netns/ns_if.h" #endif -#include "machine/isa/device.h" +#include "machine/isa/isa_device.h" #include "if_nereg.h" #include "icu.h" diff --git a/usr/src/sys/i386/isa/if_we.c b/usr/src/sys/i386/isa/if_we.c index 4e0bb9e104..1d02b0231f 100644 --- a/usr/src/sys/i386/isa/if_we.c +++ b/usr/src/sys/i386/isa/if_we.c @@ -7,7 +7,7 @@ * * %sccs.include.noredist.c% * - * @(#)if_we.c 5.3 (Berkeley) %G% + * @(#)if_we.c 5.4 (Berkeley) %G% */ /* @@ -51,7 +51,7 @@ #endif #include "machine/isa/if_wereg.h" -#include "machine/isa/device.h" +#include "machine/isa/isa_device.h" /* * This constant should really be 60 because the we adds 4 bytes of crc. diff --git a/usr/src/sys/i386/isa/isa.c b/usr/src/sys/i386/isa/isa.c index 4fd3099570..315b306935 100644 --- a/usr/src/sys/i386/isa/isa.c +++ b/usr/src/sys/i386/isa/isa.c @@ -1,6 +1,6 @@ /* * code to manage AT bus - * @(#)isa.c 1.1 (Berkeley) %G% + * @(#)isa.c 1.2 (Berkeley) %G% */ #include "param.h" @@ -12,7 +12,120 @@ #include "buf.h" #include "vm.h" #include "uio.h" +#include "syslog.h" +#include "machine/segments.h" #include "machine/pte.h" +#include "machine/isa/isa_device.h" +#include "machine/isa/icu.h" + +/* + * Configure all ISA devices + */ +isa_configure() { + struct isa_device *dvp; + struct isa_driver *dp; + + splhigh(); + INTREN(IRQ_SLAVE); + for (dvp = isa_devtab_bio; config_isadev(dvp,&biomask); dvp++); + for (dvp = isa_devtab_tty; config_isadev(dvp,&ttymask); dvp++); + for (dvp = isa_devtab_net; config_isadev(dvp,&netmask); dvp++); + for (dvp = isa_devtab_null; config_isadev(dvp,0); dvp++); +#include "sl.h" +#if NSL > 0 + netmask |= ttymask; + ttymask |= netmask; +#endif + /* biomask |= ttymask ; can some tty devices use buffers? */ + printf("biomask %x ttymask %x netmask %x\n", biomask, ttymask, netmask); + splnone(); +} + +/* + * Configure an ISA device. + */ +config_isadev(isdp, mp) + struct isa_device *isdp; + int *mp; +{ + struct isa_driver *dp; + + if (dp = isdp->id_driver) { + if (isdp->id_maddr) { + extern int atdevbase[]; + + isdp->id_maddr -= 0xa0000; + isdp->id_maddr += (int)&atdevbase; + } + isdp->id_alive = (*dp->probe)(isdp); + if (isdp->id_alive) { + printf("%s%d", dp->name, isdp->id_unit); + (*dp->attach)(isdp); + printf(" at 0x%x ", isdp->id_iobase); + if(isdp->id_irq) { + int intrno; + + intrno = ffs(isdp->id_irq)-1; + printf("irq %d ", intrno); + INTREN(isdp->id_irq); + if(mp)INTRMASK(*mp,isdp->id_irq); + setidt(ICU_OFFSET+intrno, isdp->id_intr, + SDT_SYS386IGT, SEL_KPL); + } + if (isdp->id_drq != -1) printf("drq %d ", isdp->id_drq); + printf("on isa\n"); + } + return (1); + } else return(0); +} + +#define IDTVEC(name) X/**/name +/* default interrupt vector table */ +extern IDTVEC(intr0), IDTVEC(intr1), IDTVEC(intr2), IDTVEC(intr3), + IDTVEC(intr4), IDTVEC(intr5), IDTVEC(intr6), IDTVEC(intr7), + IDTVEC(intr8), IDTVEC(intr9), IDTVEC(intr10), IDTVEC(intr11), + IDTVEC(intr12), IDTVEC(intr13), IDTVEC(intr14), IDTVEC(intr15); + +/* + * Fill in default interrupt table (in case of spuruious interrupt + * during configuration of kernel, setup interrupt control unit + */ +isa_defaultirq() { + +/* first icu */ + setidt(32, &IDTVEC(intr0), SDT_SYS386IGT, SEL_KPL); + setidt(33, &IDTVEC(intr1), SDT_SYS386IGT, SEL_KPL); + setidt(34, &IDTVEC(intr2), SDT_SYS386IGT, SEL_KPL); + setidt(35, &IDTVEC(intr3), SDT_SYS386IGT, SEL_KPL); + setidt(36, &IDTVEC(intr4), SDT_SYS386IGT, SEL_KPL); + setidt(37, &IDTVEC(intr5), SDT_SYS386IGT, SEL_KPL); + setidt(38, &IDTVEC(intr6), SDT_SYS386IGT, SEL_KPL); + setidt(39, &IDTVEC(intr7), SDT_SYS386IGT, SEL_KPL); + +/* second icu */ + setidt(40, &IDTVEC(intr8), SDT_SYS386IGT, SEL_KPL); + setidt(41, &IDTVEC(intr9), SDT_SYS386IGT, SEL_KPL); + setidt(42, &IDTVEC(intr10), SDT_SYS386IGT, SEL_KPL); + setidt(43, &IDTVEC(intr11), SDT_SYS386IGT, SEL_KPL); + setidt(44, &IDTVEC(intr12), SDT_SYS386IGT, SEL_KPL); + setidt(45, &IDTVEC(intr13), SDT_SYS386IGT, SEL_KPL); + setidt(46, &IDTVEC(intr14), SDT_SYS386IGT, SEL_KPL); + setidt(47, &IDTVEC(intr15), SDT_SYS386IGT, SEL_KPL); + + /* initialize 8259's */ + outb(0xf1,0); + outb(0x20,0x11); + outb(0x21,32); + outb(0x21,4); + outb(0x21,1); + outb(0x21,0xff); + + outb(0xa0,0x11); + outb(0xa1,40); + outb(0xa1,2); + outb(0xa1,1); + outb(0xa1,0xff); +} /* stuff needed for virtual to physical calculations */ extern char Sysbase; @@ -76,3 +189,22 @@ int nbytes; /* set channel 2 */ outb(0x0A,chan); } + +/* + * Handle a NMI, possibly a machine check. + * return true to panic system, false to ignore. + */ +isa_nmi(cd) { + + log(LOG_CRIT, "\nNMI port 61 %x, port 70 %x\n", inb(0x61), inb(0x70)); + return(0); +} + +/* + * Caught a stray interrupt, notify + */ +isa_strayintr(d) { + + /* for some reason, we get bursts of intr #7, even if not enabled! */ + log(LOG_ERR,"ISA strayintr %d", ffs(d)-1); +} diff --git a/usr/src/sys/i386/isa/isa.h b/usr/src/sys/i386/isa/isa.h index 57e27b13a7..7c8b4fcd8a 100644 --- a/usr/src/sys/i386/isa/isa.h +++ b/usr/src/sys/i386/isa/isa.h @@ -7,7 +7,7 @@ * * %sccs.include.noredist.c% * - * @(#)isa.h 5.4 (Berkeley) %G% + * @(#)isa.h 5.5 (Berkeley) %G% */ /* @@ -28,52 +28,52 @@ void outb(); #define IO_ISABEGIN 0x000 /* 0x000 - Beginning of I/O Registers */ /* CPU Board */ -#define IO_DMA0 0x000 /* 8237A DMA Controller #1 */ -#define IO_ICU0 0x020 /* 8259A Interrupt Controller #1 */ -#define IO_TIMER0 0x040 /* 8252 Timer #1 */ -#define IO_TIMER1 0x048 /* 8252 Timer #2 */ +#define IO_DMA1 0x000 /* 8237A DMA Controller #1 */ +#define IO_ICU1 0x020 /* 8259A Interrupt Controller #1 */ +#define IO_TIMER1 0x040 /* 8252 Timer #1 */ +#define IO_TIMER2 0x048 /* 8252 Timer #2 */ #define IO_KBD 0x060 /* 8042 Keyboard */ #define IO_RTC 0x070 /* RTC */ #define IO_NMI IO_RTC /* NMI Control */ #define IO_DMAPG 0x080 /* DMA Page Registers */ -#define IO_ICU1 0x0A0 /* 8259A Interrupt Controller #2 */ -#define IO_DMA1 0x0C0 /* 8237A DMA Controller #2 */ +#define IO_ICU2 0x0A0 /* 8259A Interrupt Controller #2 */ +#define IO_DMA2 0x0C0 /* 8237A DMA Controller #2 */ #define IO_NPX 0x0F0 /* Numeric Coprocessor */ /* Cards */ /* 0x100 - 0x16F Open */ -#define IO_WD1 0x170 /* Secondary Fixed Disk Controller */ +#define IO_WD2 0x170 /* Secondary Fixed Disk Controller */ /* 0x178 - 0x1EF Open */ -#define IO_WD0 0x1f0 /* Primary Fixed Disk Controller */ +#define IO_WD1 0x1f0 /* Primary Fixed Disk Controller */ #define IO_GAME 0x200 /* Game Controller */ /* 0x208 - 0x277 Open */ -#define IO_LPT1 0x278 /* Parallel Port #2 */ +#define IO_LPT2 0x278 /* Parallel Port #2 */ /* 0x280 - 0x2F7 Open */ -#define IO_COM1 0x2f8 /* COM2 i/o address */ +#define IO_COM2 0x2f8 /* COM2 i/o address */ /* 0x300 - 0x36F Open */ -#define IO_FD1 0x370 /* secondary base i/o address */ -#define IO_LPT0 0x378 /* Parallel Port #1 */ +#define IO_FD2 0x370 /* secondary base i/o address */ +#define IO_LPT1 0x378 /* Parallel Port #1 */ /* 0x380 - 0x3AF Open */ #define IO_MDA 0x3B0 /* Monochome Adapter */ -#define IO_LPT2 0x3BC /* Monochome Adapter Printer Port */ +#define IO_LPT3 0x3BC /* Monochome Adapter Printer Port */ #define IO_VGA 0x3C0 /* E/VGA Ports */ #define IO_CGA 0x3D0 /* CGA Ports */ /* 0x3E0 - 0x3EF Open */ -#define IO_FD0 0x3f0 /* primary base i/o address */ -#define IO_COM0 0x3f8 /* COM1 i/o address */ +#define IO_FD1 0x3f0 /* primary base i/o address */ +#define IO_COM1 0x3f8 /* COM1 i/o address */ #define IO_ISAEND 0x3FF /* - 0x3FF End of I/O Registers */ #endif IO_ISABEGIN @@ -82,7 +82,7 @@ void outb(); * Input / Output Memory Physical Addresses */ -#ifdef IOM_BEGIN +#ifndef IOM_BEGIN #define IOM_BEGIN 0xa0000 /* Start of I/O Memory "hole" */ #define IOM_END 0xFFFFF /* End of I/O Memory "hole" */ #endif IOM_BEGIN @@ -91,16 +91,17 @@ void outb(); * RAM Physical Address Space (ignoring the above mentioned "hole") */ -#ifdef RAM_BEGIN +#ifndef RAM_BEGIN #define RAM_BEGIN 0x000000 /* Start of RAM Memory */ -#define IOM_END 0xFFFFFF /* End of RAM Memory */ +#define RAM_END 0xFFFFFF /* End of RAM Memory */ #endif IOM_BEGIN /* * Oddball Physical Memory Addresses */ - +#ifndef COMPAQ_RAMRELOC #define COMPAQ_RAMRELOC 0x80c00000 /* Compaq RAM relocation/diag */ #define COMPAQ_RAMSETUP 0x80c00002 /* Compaq RAM setup */ #define WEITEK_FPU 0xC0000000 /* WTL 2167 */ #define CYRIX_EMC 0xC0000000 /* Cyrix EMC */ +#endif COMPAQ_RAMRELOC diff --git a/usr/src/sys/i386/isa/npx.c b/usr/src/sys/i386/isa/npx.c index 8ad028362e..3b56cd0c56 100644 --- a/usr/src/sys/i386/isa/npx.c +++ b/usr/src/sys/i386/isa/npx.c @@ -1,45 +1,59 @@ +/* + * Copyright (c) 1990 W. Jolitz + * @(#)npx.c 1.2 (Berkeley) %G% + */ +#include "npx.h" +#if NNPX > 0 + +#include "param.h" +#include "systm.h" +#include "conf.h" +#include "file.h" +#include "dir.h" +#include "user.h" +#include "ioctl.h" +#include "vm.h" +#include "machine/pte.h" +#include "machine/isa/isa_device.h" +#include "icu.h" /* * 387 and 287 Numeric Coprocessor Extension (NPX) Driver. - * @(#)npx.c 1.1 (Berkeley) %G% */ int npxprobe(), npxattach(), npxintr(); -struct driver npxdriver = { +struct isa_driver npxdriver = { npxprobe, npxattach, "npx", }; struct proc *npxproc; /* process who owns device, otherwise zero */ -struct user *npxutl; /* owners user structure */ -struct pte *Npxmap; /* kernel ptes mapping owner's user structure */ +extern struct user npxutl; /* owners user structure */ +extern struct pte Npxmap[]; /* kernel ptes mapping owner's user structure */ /* * Probe routine - look device, otherwise set emulator bit */ npxprobe(dvp) - struct device *dvp; -{ - register status; + struct isa_device *dvp; +{ static status, control; #ifdef lint npxintr(); #endif -/* insure EM bit off */ - asm(" fninit"); /* put device in known state */ + + /* insure EM bit off */ + asm(" fninit "); /* put device in known state */ /* check for a proper status of zero */ status = 0xa5a5; - asm(" movw %1,%%ax ; fnstsw %%ax ; movw %%ax, %0" - : "=g" (status) : "g" (status) : "ax"); + asm (" fnstsw %0 " : "=m" (status) : "m" (status) ); if (status == 0) { - register control; /* good, now check for a proper control word */ control = 0xa5a5; - asm(" movw %1,%%ax ; fnstcw %%ax ; movw %%ax, %0" - : "=g" (control) : "g" (control) : "ax"); + asm (" fnstcw %0 " : "=m" (control) : "m" (control)); - if (control&0x103f == 0x3f) { + if ((control&0x103f) == 0x3f) { /* then we have a numeric coprocessor */ /* XXX should force an exception here to generate an intr */ return (1); @@ -54,26 +68,21 @@ npxprobe(dvp) * Attach routine - announce which it is, and wire into system */ npxattach(dvp) - struct device *dvp; + struct isa_device *dvp; { - int unit = dvp->unit; - npxinit(); + npxinit(0x262); /* check for ET bit to decide 387/287 */ - INTREN(IRQ13); /*outb(0xb1,0); /* reset processor */ } /* * Initialize floating point unit, usually after an error */ -npxinit() { - register control; +npxinit(control) { asm (" fninit"); - control = XXX; - asm(" movw %0,%%ax ; fldcw %%ax " - : "g" (control) : "ax"); + asm(" fldcw %0" : : "g" (control)); } @@ -85,7 +94,7 @@ npxload() { if (npxproc) panic ("npxload"); npxproc = u.u_procp; uaccess(npxproc, Npxmap, &npxutl); - asm(" frstor %0 " : "g" (u.u_pcb.pcb_savefpu) ); + asm(" frstor %0 " : : "g" (u.u_pcb.pcb_savefpu) ); } /* @@ -94,7 +103,7 @@ npxload() { npxunload() { if (npxproc == 0) panic ("npxunload"); - asm(" fsave %0 " : "g" (npxutl.u_pcb.pcb_savefpu) ); + asm(" fsave %0 " : : "g" (npxutl.u_pcb.pcb_savefpu) ); npxproc = 0 ; } @@ -105,7 +114,7 @@ npxexcept() { /* save state in appropriate user structure */ if (npxproc == 0) panic ("npxexcept"); - asm (" fsave %0 " : "g" (npxutl.u_pcb.pcb_savefpu) ); + asm (" fsave %0 " : : "g" (npxutl.u_pcb.pcb_savefpu) ); /* * encode the appropriate u_code for detailed information @@ -132,3 +141,4 @@ npxintr() { */ npxdna() { } +#endif diff --git a/usr/src/sys/i386/isa/pccons.c b/usr/src/sys/i386/isa/pccons.c index 674ba4e3bf..f05781ee61 100644 --- a/usr/src/sys/i386/isa/pccons.c +++ b/usr/src/sys/i386/isa/pccons.c @@ -9,7 +9,7 @@ * * %sccs.include.386.c% * - * @(#)pccons.c 5.3 (Berkeley) %G% + * @(#)pccons.c 5.4 (Berkeley) %G% */ /* @@ -23,7 +23,7 @@ #include "proc.h" #include "tty.h" #include "uio.h" -#include "machine/isa/device.h" +#include "machine/isa/isa_device.h" #include "callout.h" #include "systm.h" #include "kernel.h" diff --git a/usr/src/sys/i386/isa/wd.c b/usr/src/sys/i386/isa/wd.c index aef8757209..faece5eee9 100644 --- a/usr/src/sys/i386/isa/wd.c +++ b/usr/src/sys/i386/isa/wd.c @@ -7,7 +7,7 @@ * * %sccs.include.386.c% * - * @(#)wd.c 5.7 (Berkeley) %G% + * @(#)wd.c 5.8 (Berkeley) %G% */ #include "wd.h" @@ -26,7 +26,7 @@ #include "vm.h" #include "uio.h" #include "machine/pte.h" -#include "machine/isa/device.h" +#include "machine/isa/isa_device.h" #include "icu.h" #include "wdreg.h" #include "syslog.h" diff --git a/usr/src/sys/i386/isa/wt.c b/usr/src/sys/i386/isa/wt.c index 70ea0e821a..70ec7fadf4 100644 --- a/usr/src/sys/i386/isa/wt.c +++ b/usr/src/sys/i386/isa/wt.c @@ -5,7 +5,7 @@ * Copyright (c) 1989 Carnegie-Mellon University * All rights reserved. The CMU software License Agreement specifies * the terms and conditions for use and redistribution. - * @(#)wt.c 1.1 (Berkeley) %G% + * @(#)wt.c 1.2 (Berkeley) %G% */ /* * HISTORY @@ -1109,7 +1109,7 @@ wtdump() { } -#include "machine/isa/device.h" +#include "machine/isa/isa_device.h" #include "machine/isa/icu.h" int wtprobe(), wtattach(); -- 2.20.1