1993-03-21 12:45:37 +03:00
|
|
|
/*-
|
1994-02-23 02:36:09 +03:00
|
|
|
* Copyright (c) 1993, 1994 Charles Hannum.
|
1993-03-21 12:45:37 +03:00
|
|
|
* Copyright (c) 1989, 1990 William F. Jolitz.
|
|
|
|
* Copyright (c) 1990 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* William Jolitz.
|
|
|
|
*
|
|
|
|
* 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
|
1993-06-06 08:14:01 +04:00
|
|
|
* notice, this list of conditions and the following disclaimer.
|
1993-03-21 12:45:37 +03:00
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
1993-06-06 08:14:01 +04:00
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
1993-03-21 12:45:37 +03:00
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
1993-06-06 08:14:01 +04:00
|
|
|
* must display the following acknowledgement:
|
1993-03-21 12:45:37 +03:00
|
|
|
* 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
|
1993-06-06 08:14:01 +04:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
1993-03-21 12:45:37 +03:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
1993-05-22 11:56:12 +04:00
|
|
|
* from: @(#)icu.s 7.2 (Berkeley) 5/21/91
|
1994-03-08 16:24:46 +03:00
|
|
|
* $Id: icu.s,v 1.24 1994/03/08 13:24:56 mycroft Exp $
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* AT/386
|
|
|
|
* Vector interrupt control section
|
|
|
|
*/
|
|
|
|
|
1993-12-17 03:10:06 +03:00
|
|
|
#include <net/netisr.h>
|
1994-03-08 16:24:46 +03:00
|
|
|
#include <machine/psl.h>
|
1993-12-17 03:10:06 +03:00
|
|
|
|
1993-06-06 08:14:01 +04:00
|
|
|
/*
|
1993-12-17 03:10:06 +03:00
|
|
|
* All spl levels include astmask; this forces cpl to be non-zero when
|
|
|
|
* splx()ing from nested spl levels, and thus soft interrupts do not
|
|
|
|
* get executed. Logically, all spl levels are `above' soft interupts.
|
1993-06-06 08:14:01 +04:00
|
|
|
*/
|
|
|
|
|
1993-06-27 08:59:47 +04:00
|
|
|
#ifdef notyet
|
1993-06-06 09:06:50 +04:00
|
|
|
#include "sio.h"
|
1993-06-27 08:59:47 +04:00
|
|
|
#else
|
|
|
|
#define NSIO 0
|
|
|
|
#endif
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
.data
|
1993-12-17 03:10:06 +03:00
|
|
|
.globl _ipending
|
|
|
|
_ipending:
|
|
|
|
.long 0
|
|
|
|
.globl _imen
|
|
|
|
_imen:
|
|
|
|
.long 0xffff # interrupt mask enable (all off)
|
1994-03-08 16:24:46 +03:00
|
|
|
|
|
|
|
#if 1 /* XXXX temporary */
|
|
|
|
.globl _imask
|
|
|
|
.globl _astmask
|
|
|
|
_astmask:
|
|
|
|
.long 0
|
|
|
|
.globl _netmask
|
|
|
|
_netmask:
|
|
|
|
.long 0
|
1993-03-21 12:45:37 +03:00
|
|
|
.globl _ttymask
|
1993-12-17 03:10:06 +03:00
|
|
|
_ttymask:
|
|
|
|
.long 0
|
1993-03-21 12:45:37 +03:00
|
|
|
.globl _biomask
|
1993-12-17 03:10:06 +03:00
|
|
|
_biomask:
|
|
|
|
.long 0
|
1994-03-08 16:24:46 +03:00
|
|
|
.globl _clockmask
|
|
|
|
_clockmask:
|
|
|
|
.long 1
|
|
|
|
#endif
|
1993-12-17 03:10:06 +03:00
|
|
|
|
1993-06-06 09:06:50 +04:00
|
|
|
vec:
|
1993-07-03 13:43:11 +04:00
|
|
|
.long INTRLOCAL(vec0), INTRLOCAL(vec1), INTRLOCAL(vec2)
|
|
|
|
.long INTRLOCAL(vec3), INTRLOCAL(vec4), INTRLOCAL(vec5)
|
|
|
|
.long INTRLOCAL(vec6), INTRLOCAL(vec7), INTRLOCAL(vec8)
|
|
|
|
.long INTRLOCAL(vec9), INTRLOCAL(vec10), INTRLOCAL(vec11)
|
|
|
|
.long INTRLOCAL(vec12), INTRLOCAL(vec13), INTRLOCAL(vec14)
|
|
|
|
.long INTRLOCAL(vec15)
|
1993-06-06 08:14:01 +04:00
|
|
|
|
|
|
|
#define FASTSPL(mask) \
|
1993-12-17 03:10:06 +03:00
|
|
|
movl mask,_cpl
|
1993-06-06 08:14:01 +04:00
|
|
|
|
|
|
|
#define FASTSPL_VARMASK(varmask) \
|
|
|
|
movl varmask,%eax ; \
|
1993-12-17 03:10:06 +03:00
|
|
|
movl %eax,_cpl
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
.text
|
1993-06-06 08:14:01 +04:00
|
|
|
|
|
|
|
ALIGN_TEXT
|
1993-07-03 13:43:11 +04:00
|
|
|
INTRLOCAL(unpend_v):
|
1993-06-06 09:06:50 +04:00
|
|
|
bsfl %eax,%eax # slow, but not worth optimizing
|
|
|
|
btrl %eax,_ipending
|
1993-07-03 13:43:11 +04:00
|
|
|
jnc INTRLOCAL(unpend_v_next) # some intr cleared the in-memory bit
|
1993-06-06 09:06:50 +04:00
|
|
|
movl Vresume(,%eax,4),%eax
|
|
|
|
testl %eax,%eax
|
1993-12-17 03:10:06 +03:00
|
|
|
jz INTRLOCAL(noresume)
|
1993-06-06 09:06:50 +04:00
|
|
|
jmp %eax
|
|
|
|
|
|
|
|
ALIGN_TEXT
|
1993-06-06 08:14:01 +04:00
|
|
|
/*
|
1993-06-06 09:06:50 +04:00
|
|
|
* XXX - must be some fastintr, need to register those too.
|
1993-06-06 08:14:01 +04:00
|
|
|
*/
|
1993-07-03 13:43:11 +04:00
|
|
|
INTRLOCAL(noresume):
|
1993-06-06 09:06:50 +04:00
|
|
|
#if NSIO > 0
|
|
|
|
call _softsio1
|
|
|
|
#endif
|
1993-07-03 13:43:11 +04:00
|
|
|
INTRLOCAL(unpend_v_next):
|
1993-06-06 08:14:01 +04:00
|
|
|
movl _cpl,%eax
|
|
|
|
movl %eax,%edx
|
|
|
|
notl %eax
|
|
|
|
andl _ipending,%eax
|
1993-12-17 03:10:06 +03:00
|
|
|
jz INTRLOCAL(none_to_unpend)
|
1993-07-03 13:43:11 +04:00
|
|
|
jmp INTRLOCAL(unpend_v)
|
1993-06-06 08:14:01 +04:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
|
|
|
* Handle return from interrupt after device handler finishes
|
|
|
|
*/
|
1993-06-06 08:14:01 +04:00
|
|
|
ALIGN_TEXT
|
1993-03-21 12:45:37 +03:00
|
|
|
doreti:
|
1993-06-06 08:14:01 +04:00
|
|
|
addl $4,%esp # discard unit arg
|
|
|
|
popl %eax # get previous priority
|
|
|
|
/*
|
|
|
|
* Now interrupt frame is a trap frame!
|
|
|
|
*
|
|
|
|
* XXX - setting up the interrupt frame to be almost a stack frame is mostly
|
|
|
|
* a waste of time.
|
|
|
|
*/
|
|
|
|
movl %eax,_cpl
|
|
|
|
movl %eax,%edx
|
|
|
|
notl %eax
|
|
|
|
andl _ipending,%eax
|
1993-12-17 03:10:06 +03:00
|
|
|
jnz INTRLOCAL(unpend_v)
|
1993-07-03 13:43:11 +04:00
|
|
|
INTRLOCAL(none_to_unpend):
|
1993-06-06 08:14:01 +04:00
|
|
|
testl %edx,%edx # returning to zero priority?
|
1993-12-17 03:10:06 +03:00
|
|
|
jz 2f
|
1993-06-06 08:14:01 +04:00
|
|
|
popl %es
|
|
|
|
popl %ds
|
|
|
|
popal
|
1993-03-21 12:45:37 +03:00
|
|
|
addl $8,%esp
|
|
|
|
iret
|
|
|
|
|
1993-12-17 03:10:06 +03:00
|
|
|
|
|
|
|
.globl _netisr,_sir
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1993-06-06 08:14:01 +04:00
|
|
|
#define DONET(s, c, event) ; \
|
|
|
|
.globl c ; \
|
|
|
|
btrl $s,_netisr ; \
|
|
|
|
jnc 1f ; \
|
1993-03-21 12:45:37 +03:00
|
|
|
call c ; \
|
|
|
|
1:
|
|
|
|
|
1993-06-06 08:14:01 +04:00
|
|
|
ALIGN_TEXT
|
|
|
|
2:
|
|
|
|
/*
|
|
|
|
* XXX - might need extra locking while testing reg copy of netisr, but
|
|
|
|
* interrupt routines setting it would not cause any new problems (since we
|
|
|
|
* don't loop, fresh bits will not be processed until the next doreti or spl0)
|
|
|
|
*/
|
1993-12-17 03:10:06 +03:00
|
|
|
btrl $SIR_NET,_sir
|
|
|
|
jnc test_clock
|
1993-06-06 08:14:01 +04:00
|
|
|
FASTSPL_VARMASK(_netmask)
|
|
|
|
DONET(NETISR_RAW, _rawintr, 5)
|
1993-03-21 12:45:37 +03:00
|
|
|
#ifdef INET
|
1993-06-06 08:14:01 +04:00
|
|
|
DONET(NETISR_IP, _ipintr, 6)
|
1993-03-21 12:45:37 +03:00
|
|
|
#endif
|
|
|
|
#ifdef IMP
|
1993-06-06 08:14:01 +04:00
|
|
|
DONET(NETISR_IMP, _impintr, 7)
|
1993-03-21 12:45:37 +03:00
|
|
|
#endif
|
|
|
|
#ifdef NS
|
1993-06-06 08:14:01 +04:00
|
|
|
DONET(NETISR_NS, _nsintr, 8)
|
1993-06-14 23:29:30 +04:00
|
|
|
#endif
|
|
|
|
#ifdef ISO
|
1993-06-14 23:35:59 +04:00
|
|
|
DONET(NETISR_ISO, _clnlintr, 25)
|
1993-03-21 12:45:37 +03:00
|
|
|
#endif
|
1993-06-06 08:14:01 +04:00
|
|
|
FASTSPL($0)
|
1993-12-17 03:10:06 +03:00
|
|
|
test_clock:
|
|
|
|
btrl $SIR_CLOCK,_sir
|
|
|
|
jnc test_ast
|
|
|
|
FASTSPL_VARMASK(_astmask)
|
1994-02-01 04:50:38 +03:00
|
|
|
pushl $0 # XXX previous cpl (probably not used)
|
|
|
|
pushl $0x7f # XXX dummy unit number
|
|
|
|
pushl %esp
|
1993-03-21 12:45:37 +03:00
|
|
|
call _softclock
|
1994-02-01 04:50:38 +03:00
|
|
|
addl $12,%esp # XXX discard dummies
|
1993-06-06 08:14:01 +04:00
|
|
|
FASTSPL($0)
|
1993-12-17 03:10:06 +03:00
|
|
|
test_ast:
|
|
|
|
btrl $SIR_AST,_sir # signal handling, rescheduling, ...
|
1993-06-06 08:14:01 +04:00
|
|
|
jnc 2f
|
1993-12-14 08:31:17 +03:00
|
|
|
testb $SEL_RPL_MASK,TF_CS(%esp)
|
1993-06-06 08:14:01 +04:00
|
|
|
# to non-kernel (i.e., user)?
|
1993-12-17 03:10:06 +03:00
|
|
|
jz 2f # nope, leave
|
1993-03-21 12:45:37 +03:00
|
|
|
call _trap
|
1993-06-06 08:14:01 +04:00
|
|
|
2:
|
|
|
|
popl %es
|
|
|
|
popl %ds
|
1993-03-21 12:45:37 +03:00
|
|
|
popal
|
|
|
|
addl $8,%esp
|
|
|
|
iret
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Interrupt priority mechanism
|
1993-06-06 08:14:01 +04:00
|
|
|
* -- soft splXX masks with group mechanism (cpl)
|
|
|
|
* -- h/w masks for currently active or unused interrupts (imen)
|
|
|
|
* -- ipending = active interrupts currently masked by cpl
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
.globl _spl0
|
1993-06-06 08:14:01 +04:00
|
|
|
ALIGN_TEXT
|
1993-03-21 12:45:37 +03:00
|
|
|
_spl0:
|
1993-06-06 08:14:01 +04:00
|
|
|
in_spl0:
|
|
|
|
movl _cpl,%eax
|
|
|
|
pushl %eax # save old priority
|
1993-12-17 03:10:06 +03:00
|
|
|
btrl $SIR_NET,_sir
|
|
|
|
jnc INTRLOCAL(over_net_stuff_for_spl0)
|
|
|
|
FASTSPL_VARMASK(_netmask)
|
1993-06-06 08:14:01 +04:00
|
|
|
DONET(NETISR_RAW, _rawintr, 20)
|
1993-03-21 12:45:37 +03:00
|
|
|
#ifdef INET
|
1993-06-06 08:14:01 +04:00
|
|
|
DONET(NETISR_IP, _ipintr, 21)
|
1993-05-03 12:44:06 +04:00
|
|
|
#endif
|
1993-06-14 23:29:30 +04:00
|
|
|
#ifdef IMP
|
|
|
|
DONET(NETISR_IMP, _impintr, 26)
|
|
|
|
#endif
|
|
|
|
#ifdef NS
|
|
|
|
DONET(NETISR_NS, _nsintr, 27)
|
|
|
|
#endif
|
|
|
|
#ifdef ISO
|
1993-06-14 23:35:59 +04:00
|
|
|
DONET(NETISR_ISO, _clnlintr, 28)
|
1993-06-14 23:29:30 +04:00
|
|
|
#endif
|
1993-07-03 17:13:34 +04:00
|
|
|
INTRLOCAL(over_net_stuff_for_spl0):
|
1993-12-17 03:10:06 +03:00
|
|
|
FASTSPL($0)
|
1993-06-06 08:14:01 +04:00
|
|
|
movl _ipending,%eax
|
|
|
|
testl %eax,%eax
|
1993-12-17 03:10:06 +03:00
|
|
|
jnz INTRLOCAL(unpend_V)
|
|
|
|
popl %eax # return old priority
|
1993-03-21 12:45:37 +03:00
|
|
|
ret
|
1993-06-06 08:14:01 +04:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
.globl _splx
|
1993-06-06 08:14:01 +04:00
|
|
|
ALIGN_TEXT
|
1993-03-21 12:45:37 +03:00
|
|
|
_splx:
|
1993-06-06 08:14:01 +04:00
|
|
|
movl 4(%esp),%eax # new priority
|
|
|
|
testl %eax,%eax
|
1993-12-17 03:10:06 +03:00
|
|
|
jz in_spl0 # going to "zero level" is special
|
|
|
|
pushl _cpl # save old priority
|
1993-06-06 08:14:01 +04:00
|
|
|
movl %eax,_cpl # set new priority
|
|
|
|
notl %eax
|
|
|
|
andl _ipending,%eax
|
1993-12-17 03:10:06 +03:00
|
|
|
jnz INTRLOCAL(unpend_V)
|
|
|
|
popl %eax # return old priority
|
1993-03-21 12:45:37 +03:00
|
|
|
ret
|
|
|
|
|
1993-06-06 08:14:01 +04:00
|
|
|
ALIGN_TEXT
|
1993-07-03 13:43:11 +04:00
|
|
|
INTRLOCAL(unpend_V):
|
1993-06-06 09:06:50 +04:00
|
|
|
bsfl %eax,%eax
|
|
|
|
btrl %eax,_ipending
|
1993-07-03 13:43:11 +04:00
|
|
|
jnc INTRLOCAL(unpend_V_next)
|
1993-06-06 09:06:50 +04:00
|
|
|
movl Vresume(,%eax,4),%edx
|
|
|
|
testl %edx,%edx
|
1993-12-17 03:10:06 +03:00
|
|
|
jz INTRLOCAL(noresumeV)
|
1993-06-06 09:06:50 +04:00
|
|
|
/*
|
|
|
|
* We would prefer to call the intr handler directly here but that doesn't
|
|
|
|
* work for badly behaved handlers that want the interrupt frame. Also,
|
|
|
|
* there's a problem determining the unit number. We should change the
|
|
|
|
* interface so that the unit number is not determined at config time.
|
|
|
|
*/
|
|
|
|
jmp *vec(,%eax,4)
|
1993-06-06 08:14:01 +04:00
|
|
|
|
|
|
|
ALIGN_TEXT
|
1993-06-06 09:06:50 +04:00
|
|
|
/*
|
|
|
|
* XXX - must be some fastintr, need to register those too.
|
|
|
|
*/
|
1993-07-03 13:43:11 +04:00
|
|
|
INTRLOCAL(noresumeV):
|
1993-06-06 09:06:50 +04:00
|
|
|
#if NSIO > 0
|
|
|
|
call _softsio1
|
|
|
|
#endif
|
1993-07-03 13:43:11 +04:00
|
|
|
INTRLOCAL(unpend_V_next):
|
1993-06-06 08:14:01 +04:00
|
|
|
movl _cpl,%eax
|
|
|
|
notl %eax
|
|
|
|
andl _ipending,%eax
|
1993-12-17 03:10:06 +03:00
|
|
|
jnz INTRLOCAL(unpend_V)
|
1993-06-06 08:14:01 +04:00
|
|
|
popl %eax
|
|
|
|
ret
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1993-06-06 09:06:50 +04:00
|
|
|
#define BUILD_VEC(irq_num) \
|
1993-06-06 08:14:01 +04:00
|
|
|
ALIGN_TEXT ; \
|
1993-07-03 13:43:11 +04:00
|
|
|
INTRLOCAL(vec/**/irq_num): ; \
|
1993-12-17 03:10:06 +03:00
|
|
|
int $(ICU_OFFSET + irq_num) ; \
|
1993-06-06 08:14:01 +04:00
|
|
|
popl %eax ; \
|
|
|
|
ret
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1993-06-06 09:06:50 +04:00
|
|
|
BUILD_VEC(0)
|
|
|
|
BUILD_VEC(1)
|
|
|
|
BUILD_VEC(2)
|
|
|
|
BUILD_VEC(3)
|
|
|
|
BUILD_VEC(4)
|
|
|
|
BUILD_VEC(5)
|
|
|
|
BUILD_VEC(6)
|
|
|
|
BUILD_VEC(7)
|
|
|
|
BUILD_VEC(8)
|
|
|
|
BUILD_VEC(9)
|
|
|
|
BUILD_VEC(10)
|
|
|
|
BUILD_VEC(11)
|
|
|
|
BUILD_VEC(12)
|
|
|
|
BUILD_VEC(13)
|
|
|
|
BUILD_VEC(14)
|
|
|
|
BUILD_VEC(15)
|
|
|
|
|