Code: Select all
GDTDESC struc
limit_0_15 dw 0 ; low word of the segment length
base_addr0_15 dw 0 ; low word of base address
base_addr16_23 db 0 ; low byte of high word of base addr.
access db 0
limit_H db 0
base_addr24_31 db 0 ; highest byte of base address
GDTDESC ends
IDTDESC struc
offset0_15 dw ? ; low word of handler offset
selector0_15 dw ? ; segment selector
zero_byte db 0 ; unused in this descriptor format
access1 db ? ; flag-byte
offset16_31 dw ? ; high word of handler offset
IDTDESC ends
GDT_Ptr dw gdt_size,0,0
null_dscr dw 0,0,0,0,0
code32_SEL equ $-null_dscr
code32_dscr GDTDESC <-1,0,10,9ah,0cfh,0>
data32_SEL equ $-null_dscr
data32_dscr GDTDESC <-1,0,10,92h,0cfh,0>
video_SEL equ $-null_dscr
videosel_dscr GDTDESC <-1,8000h,0bh,92h,0,0>
code16_SEL equ $-null_dscr
code16_dscr GDTDESC <-1,0,0,9ah,0,0>
data16_SEL equ $-null_dscr
data16_dscr GDTDESC <-1,0,0,92h,0,0>
TSS1_SEL equ $-null_dscr
TS1 GDTDESC <-1,0,0,89h,0cfh,0>
TSS2_SEL equ $-null_dscr
TS2 GDTDESC <-1,0,0,89h,0cfh,0>
gdt_size=$-(offset null_dscr)
IDT_Ptr dw idt_size,0,0
interrupt0 IDTDESC <int0h,code32_SEL,0,8fh,0>
interrupt1 IDTDESC <int1h,code32_SEL,0,8fh,0>
interrupt2 IDTDESC <int2h,code32_SEL,0,8fh,0>
interrupt3 IDTDESC <int3h,code32_SEL,0,8fh,0>
interrupt4 IDTDESC <int4h,code32_SEL,0,8fh,0>
interrupt5 IDTDESC <int5h,code32_SEL,0,8fh,0>
interrupt6 IDTDESC <int6h,code32_SEL,0,8fh,0>
interrupt7 IDTDESC <int7h,code32_SEL,0,8fh,0>
interrupt8 IDTDESC <int8h,code32_SEL,0,8fh,0>
interrupt9 IDTDESC <int9h,code32_SEL,0,8fh,0>
interruptA IDTDESC <intAh,code32_SEL,0,8fh,0>
interruptB IDTDESC <intBh,code32_SEL,0,8fh,0>
interruptC IDTDESC <intCh,code32_SEL,0,8fh,0>
interruptD IDTDESC <intDh,code32_SEL,0,8fh,0>
interruptE IDTDESC <intEh,code32_SEL,0,8fh,0>
interruptF IDTDESC <intFh,code32_SEL,0,8fh,0>
interrupt10 IDTDESC <int10h,code32_SEL,0,8fh,0>
interrupt11 IDTDESC <int11h,code32_SEL,0,8fh,0>
interrupt12 IDTDESC <int12h,code32_SEL,0,8fh,0>
interrupt13 IDTDESC <int13h,code32_SEL,0,8fh,0>
interrupt14 IDTDESC <int14h,code32_SEL,0,8fh,0>
interrupt15 IDTDESC <int15h,code32_SEL,0,8fh,0>
interrupt16 IDTDESC <int16h,code32_SEL,0,8fh,0>
interrupt17 IDTDESC <int17h,code32_SEL,0,8fh,0>
interrupt18 IDTDESC <int18h,code32_SEL,0,8fh,0>
interrupt19 IDTDESC <int19h,code32_SEL,0,8fh,0>
interrupt1A IDTDESC <int1Ah,code32_SEL,0,8fh,0>
interrupt1B IDTDESC <int1Bh,code32_SEL,0,8fh,0>
interrupt1C IDTDESC <int1Ch,code32_SEL,0,8fh,0>
interrupt1D IDTDESC <int1Dh,code32_SEL,0,8fh,0>
interrupt1E IDTDESC <int1Eh,code32_SEL,0,8fh,0>
interrupt1F IDTDESC <int1Fh,code32_SEL,0,8fh,0>
interrupt20 IDTDESC <int20h,code32_SEL,0,8eh,0>
interrupt21 IDTDESC <int21h,code32_SEL,0,8eh,0>
interrupt22 IDTDESC <int22h,code32_SEL,0,8eh,0>
interrupt23 IDTDESC <int23h,code32_SEL,0,8eh,0>
interrupt24 IDTDESC <int24h,code32_SEL,0,8eh,0>
interrupt25 IDTDESC <int25h,code32_SEL,0,8eh,0>
interrupt26 IDTDESC <int26h,code32_SEL,0,8eh,0>
interrupt27 IDTDESC <int27h,code32_SEL,0,8eh,0>
interrupt28 IDTDESC <int28h,code32_SEL,0,8eh,0>
interrupt29 IDTDESC <int29h,code32_SEL,0,8eh,0>
interrupt2A IDTDESC <int2Ah,code32_SEL,0,8eh,0>
interrupt2B IDTDESC <int2Bh,code32_SEL,0,8eh,0>
interrupt2C IDTDESC <int2Ch,code32_SEL,0,8eh,0>
interrupt2D IDTDESC <int2Dh,code32_SEL,0,8eh,0>
interrupt2E IDTDESC <int2Eh,code32_SEL,0,8eh,0>
interrupt2F IDTDESC <int2Fh,code32_SEL,0,8eh,0>
interrupt30 IDTDESC <int30h,code32_SEL,0,8eh,0>
interrupt31 IDTDESC <int31h,code32_SEL,0,8eh,0>
interrupt32 IDTDESC <int32h,0,0,8eh,0>
idt_size=$-(offset IDT_Ptr)
call convr_addr
cli ; Clear or disable interrupts
lgdt fword ptr cs:[GDT_Ptr] ; Load GDT
lidt fword ptr cs:[IDT_Ptr] ; load IDT
;call remap_pic
mov eax,cr0
or al,01h ; Set protected mode bit
mov cr0,eax
db 0eah
dw enter_pm
dw 8
enter_pm : mov ax,video_SEL
mov es,ax
mov ax,data32_SEL
mov ds,ax
mov fs,ax
mov ss,ax
mov gs,ax
sti