os

Toy OS
git clone git://git.margiolis.net/os.git
Log | Files | Refs | README | LICENSE

intr.s (2292B)


      1 ; Defined in `idt.h`.
      2 [extern intr_handler]
      3 
      4 %macro intr_noerr 2
      5 global intr_%1
      6 intr_%1:
      7 	push	byte 0
      8 	push	byte %2
      9 	jmp	intr_common_stub
     10 %endmacro
     11 
     12 %macro intr_err 2
     13 global intr_%1
     14 intr_%1:
     15 	push	byte %2
     16 	jmp	intr_common_stub
     17 %endmacro
     18 
     19 ; Exceptions
     20 intr_noerr	div,	0  ; Division By Zero
     21 intr_noerr	dbg,	1  ; Debug
     22 intr_noerr	nmsk,	2  ; Non Maskable Interrupt
     23 intr_noerr	bpt,	3  ; Breakpoint
     24 intr_noerr	ofl,	4  ; Into Detected Overflow
     25 intr_noerr	bnd,	5  ; Out of Bounds
     26 intr_noerr	ill,	6  ; Invalid Opcode
     27 intr_noerr	dna,	7  ; No Coprocessor
     28 intr_err	dbl,	8  ; Double Fault (with error code)
     29 intr_noerr	fpusegm,9  ; Coprocessor Segment Overrrun
     30 intr_err	tss,	10 ; Bad TSS (with error code)
     31 intr_err	missing,11 ; Segment Not Present (with error code)
     32 intr_err	stk,	12 ; Stack Fault (with error code)
     33 intr_err	prot,	13 ; General Protection Fault (with error code)
     34 intr_err	page,	14 ; Page Fault (with error code)
     35 intr_noerr	rsvd,	15 ; Unkown Interrupt
     36 intr_noerr	fpu,	16 ; Coprocessor Fault
     37 intr_noerr	align,	17 ; Alignment Check (486+)
     38 intr_noerr	mchk,	18 ; Machine Check (Pentium/586+)
     39 intr_noerr	simd,	19 ; Reserved ; FIXME: ??
     40 
     41 ; IRQs
     42 intr_noerr	irq0,	32 ; Programmable Interrupt Timer
     43 intr_noerr	irq1,	33 ; Keyboard
     44 intr_noerr	irq2,	34 ; Cascade (used internally by the two PICs, never raised)
     45 intr_noerr	irq3,	35 ; COM2 (if enabled)
     46 intr_noerr	irq4,	36 ; COM1 (if enabled)
     47 intr_noerr	irq5,	37 ; LPT2 (if enabled)
     48 intr_noerr	irq6,	38 ; Floppy Disk
     49 intr_noerr	irq7,	39 ; LPT1
     50 intr_noerr	irq8,	40 ; CMOS real-time clock (if enabled)
     51 intr_noerr	irq9,	41 ; Peripherals / Legacy SCSI / NIC
     52 intr_noerr	irq10,	42 ; Peripherals / SCSI / NIC
     53 intr_noerr	irq11,	43 ; Peripherals / SCSI / NIC
     54 intr_noerr	irq12,	44 ; PS2 Mouse
     55 intr_noerr	irq13,	45 ; FPU / Coprocessor / Inter-processor
     56 intr_noerr	irq14,	46 ; Primary ATA Hard Disk
     57 intr_noerr	irq15,	47 ; Secondary ATA Hard Disk
     58 
     59 ; Save the processor state, call the C interrupt handler and restore the
     60 ; stack frame.
     61 intr_common_stub:
     62 	pusha
     63 	push	ds
     64 	push	es
     65 	push	fs
     66 	push	gs
     67 
     68 	mov	ax, 0x10	; Kernel data segment descriptor.
     69 	mov	ds, ax
     70 	mov	es, ax
     71 	mov	fs, ax
     72 	mov	gs, ax
     73 	cld	
     74 
     75 	push	esp
     76 	call	intr_handler
     77 	add	esp, 4
     78 
     79 	pop	gs
     80 	pop	fs
     81 	pop	es
     82 	pop	ds
     83 	popa
     84 	add	esp, 8
     85 	iret			; I spent many hours debugging this...
     86 
     87 ; TODO: irq_common_stub bx?