++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/kernel/mpx386.s ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 05908 ! Every transition to the kernel goes through this file. Transitions are 05909 ! caused by sending/receiving messages and by most interrupts. (RS232 05910 ! interrupts may be handled in the file "rs2.s" and then they rarely enter 05911 ! the kernel.) 05912 05913 ! Transitions to the kernel may be nested. The initial entry may be with a 05914 ! system call, exception or hardware interrupt; reentries may only be made 05915 ! by hardware interrupts. The count of reentries is kept in "k_reenter". 05916 ! It is important for deciding whether to switch to the kernel stack and 05917 ! for protecting the message passing code in "proc.c". 05918 05919 ! For the message passing trap, most of the machine state is saved in the 05920 ! proc table. (Some of the registers need not be saved.) Then the stack is 05921 ! switched to "k_stack", and interrupts are reenabled. Finally, the system 05922 ! call handler (in C) is called. When it returns, interrupts are disabled 05923 ! again and the code falls into the restart routine, to finish off held-up 05924 ! interrupts and run the process or task whose pointer is in "proc_ptr". 05925 05926 ! Hardware interrupt handlers do the same, except (1) The entire state must 05927 ! be saved. (2) There are too many handlers to do this inline, so the save 05928 ! routine is called. A few cycles are saved by pushing the address of the 05929 ! appropiate restart routine for a return later. (3) A stack switch is 05930 ! avoided when the stack is already switched. (4) The (master) 8259 interrupt 05931 ! controller is reenabled centrally in save(). (5) Each interrupt handler 05932 ! masks its interrupt line using the 8259 before enabling (other unmasked) 05933 ! interrupts, and unmasks it after servicing the interrupt. This limits the 05934 ! nest level to the number of lines and protects the handler from itself. 05935 05936 ! For communication with the boot monitor at startup time some constant 05937 ! data are compiled into the beginning of the text segment. This facilitates 05938 ! reading the data at the start of the boot process, since only the first 05939 ! sector of the file needs to be read. 05940 05941 ! Some data storage is also allocated at the end of this file. This data 05942 ! will be at the start of the data segment of the kernel and will be read 05943 ! and modified by the boot monitor before the kernel starts. 06134 !*===========================================================================* 06135 !* interrupt handlers * 06136 !* interrupt handlers for 386 32-bit protected mode * 06137 !*===========================================================================* 06138 06139 !*===========================================================================* 06140 !* hwint00 - 07 * 06141 !*===========================================================================* 06142 ! Note this is a macro, it looks like a subroutine. 06143 #define hwint_master(irq) \ 06144 call save /* save interrupted process state */;\ 06145 inb INT_CTLMASK ;\ 06146 orb al, [1<