1 ; vi:filetype=nasm ts=8 sts=8 sw=8:
10 GATE_PRESENT equ 8000h
25 cmp ebx, 32 ; determine if it's an IRQ or an exception (trap)
30 lea ebx, [ebx * 8 + idt] ; ebx <- pointer to gate descriptor
31 ; type|dpl goes to the 3rd dword of the descriptor (dpl is 0)
32 or eax, (GATE_DEFAULT | GATE_PRESENT)
34 ; address low 16bits go to the first dword of the descriptor
37 ; address high 16bits go to the last dword of the descriptor
40 ; selector (kcode:1) goes to the second dword of the descriptor
41 mov dword [ebx + 4], 08h
52 ; PIC initialization command word 1 bits
53 ICW1_ICW4_NEEDED equ 01h
55 ICW1_INTERVAL4 equ 04h
58 ; PIC initialization command word 4 bits
61 ICW4_BUF_SLAVE equ 08h
62 ICW4_BUF_MASTER equ 0ch
64 ; PIC operation command word 2 bits
68 ; send ICW1 saying we'll follow with ICW4 later on
69 mov al, ICW1_INIT | ICW1_ICW4_NEEDED
72 ; send ICW2 with IRQ remapping
77 ; send ICW3 to setup the master/slave relationship
78 ; ... set bit3 = 3rd interrupt input has a slave
81 ; ... set slave ID to 2
84 ; send ICW4 to set 8086 mode (no calls generated)
88 ; done, reset the data port to 0