+/*
+ * 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
+ inb $0x84,%al
+
+ 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
+ inb $0x84,%al
+
+ # 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
+ */