os

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

int.asm (3159B)


      1 ; Defined in `idt.h`.
      2 [extern int_handler]
      3 
      4 ; Exceptions
      5 global ex0
      6 global ex1
      7 global ex2
      8 global ex3
      9 global ex4
     10 global ex5
     11 global ex6
     12 global ex7
     13 global ex8
     14 global ex9
     15 global ex10
     16 global ex11
     17 global ex12
     18 global ex13
     19 global ex14
     20 global ex15
     21 global ex16
     22 global ex17
     23 global ex18
     24 global ex19
     25 global ex20
     26 global ex21
     27 global ex22
     28 global ex23
     29 global ex24
     30 global ex25
     31 global ex26
     32 global ex27
     33 global ex28
     34 global ex29
     35 global ex30
     36 global ex31
     37 
     38 ; IRQs
     39 global irq0
     40 global irq1
     41 global irq2
     42 global irq3
     43 global irq4
     44 global irq5
     45 global irq6
     46 global irq7
     47 global irq8
     48 global irq9
     49 global irq10
     50 global irq11
     51 global irq12
     52 global irq13
     53 global irq14
     54 global irq15
     55 
     56 %macro int_noerr 1
     57 	cli
     58 	push	byte 0
     59 	push	byte %1
     60 	jmp	int_common_stub
     61 %endmacro
     62 
     63 %macro int_err 1
     64 	cli
     65 	push	byte 0
     66 	push	byte %1
     67 	jmp	int_common_stub
     68 %endmacro
     69 
     70 ; Exceptions
     71 ex0:	int_noerr	0  ; Division By Zero
     72 ex1:	int_noerr	1  ; Debug
     73 ex2:	int_noerr	2  ; Non Maskable Interrupt
     74 ex3:	int_noerr	3  ; Breakpoint
     75 ex4:	int_noerr	4  ; Into Detected Overflow
     76 ex5:	int_noerr	5  ; Out of Bounds
     77 ex6:	int_noerr	6  ; Invalid Opcode
     78 ex7:	int_noerr	7  ; No Coprocessor
     79 ex8:	int_err		8  ; Double Fault (with error code)
     80 ex9:	int_noerr	9  ; Coprocessor Segment Overrrun
     81 ex10:	int_err		10 ; Bad TSS (with error code)
     82 ex11:	int_err		11 ; Segment Not Present (with error code)
     83 ex12:	int_err		12 ; Stack Fault (with error code)
     84 ex13:	int_err		13 ; General Protection Fault (with error code)
     85 ex14:	int_err		14 ; Page Fault (with error code)
     86 ex15:	int_noerr	15 ; Unkown Interrupt
     87 ex16:	int_noerr	16 ; Coprocessor Fault
     88 ex17:	int_noerr	17 ; Alignment Check (486+)
     89 ex18:	int_noerr	18 ; Machine Check (Pentium/586+)
     90 ex19:	int_noerr	19 ; Reserved
     91 ex20:	int_noerr	20 ; Reserved
     92 ex21:	int_noerr	21 ; Reserved
     93 ex22:	int_noerr	22 ; Reserved
     94 ex23:	int_noerr	23 ; Reserved
     95 ex24:	int_noerr	24 ; Reserved
     96 ex25:	int_noerr	25 ; Reserved
     97 ex26:	int_noerr	26 ; Reserved
     98 ex27:	int_noerr	27 ; Reserved
     99 ex28:	int_noerr	28 ; Reserved
    100 ex29:	int_noerr	29 ; Reserved
    101 ex30:	int_noerr	30 ; Reserved
    102 ex31:	int_noerr	31 ; Reserved
    103 ; IRQs
    104 irq0:	int_noerr	32 ; Programmable Interrupt Timer
    105 irq1:	int_noerr	33 ; Keyboard
    106 irq2:	int_noerr	34 ; Cascade (used internally by the two PICs, never raised)
    107 irq3:	int_noerr	35 ; COM2 (if enabled)
    108 irq4:	int_noerr	36 ; COM1 (if enabled)
    109 irq5:	int_noerr	37 ; LPT2 (if enabled)
    110 irq6:	int_noerr	38 ; Floppy Disk
    111 irq7:	int_noerr	39 ; LPT1
    112 irq8:	int_noerr	40 ; CMOS real-time clock (if enabled)
    113 irq9:	int_noerr	41 ; Peripherals / Legacy SCSI / NIC
    114 irq10:	int_noerr	42 ; Peripherals / SCSI / NIC
    115 irq11:	int_noerr	43 ; Peripherals / SCSI / NIC
    116 irq12:	int_noerr	44 ; PS2 Mouse
    117 irq13:	int_noerr	45 ; FPU / Coprocessor / Inter-processor
    118 irq14:	int_noerr	46 ; Primary ATA Hard Disk
    119 irq15:	int_noerr	47 ; Secondary ATA Hard Disk
    120 
    121 ; Save the processor state, call the C interrupt handler and restore the
    122 ; stack frame.
    123 int_common_stub:
    124 	pusha
    125 	push	ds
    126 	push	es
    127 	push	fs
    128 	push	gs
    129 	mov	ax, 0x10	; Kernel data segment descriptor.
    130 	mov	ds, ax
    131 	mov	es, ax
    132 	mov	fs, ax
    133 	mov	gs, ax
    134 	mov	eax, esp	; Push the stack.
    135 	push	eax
    136 	mov	eax, int_handler 
    137 	call	eax
    138 	pop	eax
    139 	pop	gs
    140 	pop	fs
    141 	pop	es
    142 	pop	ds
    143 	popa
    144 	add	esp, 8		; Clean up ISR info.
    145 	sti
    146 	iret