1: /* 2: * Copyright (c) 1988 Regents of the University of California. 3: * All rights reserved. The Berkeley software License Agreement 4: * specifies the terms and conditions for redistribution. 5: * 6: * @(#)net_trap.s 1.1 (2.10BSD Berkeley) 4/3/88 7: */ 8: 9: #include "DEFS.h" 10: #include "../machine/mch_iopage.h" 11: 12: /* 13: * All interrupts to the network kernel are vectored through this routine. 14: * No attempt is made to force rescheduling of the cpu. 15: * 16: * Since the network kernel does not use overlays, we don't have to 17: * worry about them here. If a network interrupt service routine makes 18: * a call to the kernel, then Kretu over on the kernel side will take 19: * care of saving and restoring the overlay number. 20: */ 21: 22: ASENTRY(call) 23: mov PS, -(sp) / save new PS 24: mov r1,-(sp) / save r1 25: mfpd sp / save old sp 26: mov 4(sp), -(sp) / copy of new PS 27: bic $!37,(sp) / extract dev or unit 28: jsr pc,(r0)+ / and execute trap handler 29: cmp (sp)+,(sp)+ / discard dev and sp 30: /* 31: * An 'rtt' here might not work since supervisor can't rtt to the 32: * kernel, instead, we use the "iot" mechanism to schedule a rtt 33: * from kernel mode to the PS, PC pair we push on the kernel stack. 34: * 35: * Transfer our saved <PS, PC> pair to the kernel stack. The spl7 36: * below is pure paranoia, BUT while we're at it let's bump the 37: * interrupt count - it's a mere two instructions of overhead (the 38: * increment would have been done anyhow)! 39: */ 40: mov PS,-(sp) 41: mov $40340,PS / current mode SUPV, prev KERN, BR7 42: #ifdef UCB_METER 43: mfpd *$_cnt+V_INTR / fetch interrupt count 44: inc (sp) / bump it 45: mtpd *$_cnt+V_INTR / put it back 46: #endif 47: mfpd sp / old kernel stack pointer 48: mov (sp),r1 49: sub $4,(sp) / grow the kernel stack 50: mtpd sp 51: 52: /* 53: * Can't assume kernel stack in seg6, this is slower but safe. 54: */ 55: mov 12(sp),-(sp) / push PS for iothndlr 56: mtpd -(r1) 57: mov 10(sp),-(sp) / push PC for iothndlr 58: mtpd -(r1) 59: mov (sp)+,PS 60: 61: mov (sp)+,r1 / restore r1, 62: tst (sp)+ / discard new PS, 63: mov (sp)+,r0 / restore r0, 64: cmp (sp)+,(sp)+ / discard PS and PC 65: iot / have the kernel do our rtt for us 66: 67: /* 68: * Scan net interrupt status register (netisr) for service requests. 69: */ 70: ENTRY(netintr) 71: mov r2,-(sp) / use r2 for scan of netisr 72: 1: 73: SPL7 74: mov _netisr,r2 / get copy of netisr 75: clr _netisr / and clear it, atomically 76: SPLNET 77: #ifdef INET 78: bit $1\<NETISR_IP,r2 / IP scheduled? 79: beq 2f 80: jsr pc,_ipintr 81: 2: 82: #endif 83: #ifdef NS 84: bit $1\<NETISR_NS,r2 / NS scheduled? 85: beq 3f 86: jsr pc,_nsintr 87: 3: 88: #endif 89: #ifdef IMP 90: bit $1\<NETISR_IMP,r2 / IMP scheduled? 91: beq 4f 92: jsr pc,_impintr 93: 4: 94: #endif 95: bit $1\<NETISR_RAW,r2 / RAW scheduled? 96: beq 5f / (checked last since other 97: jsr pc,_rawintr / interrupt routines schedule it) 98: 5: 99: tst _netisr / see if any new scheduled events 100: bne 1b / if so, handle them 101: mov (sp)+,r2 / restore r2, 102: rts pc / and return