I try to run my OS in bochs but it crashes when I do:
Code: Select all
asm("sti");
On VMware I get:00001915515p[CPU ] >>PANIC<< int_trap_gate(): selector null
I have a simple idt for now:"Virtual machine kernel stack fault (hardware reset)"
Code: Select all
loadIDT:
lidt[idt_ptr]
ret
[section .data]
idt:
%rep 256
dw 0
dw 0x10 ;data selec
db 0
db 0
db 8Eh
dw 0
%endrep
idt_end:
idt_ptr:
dw idt_end - idt - 1
dd idt
Code: Select all
[section .text]
loadGDT:
lgdt [gdt_ptr]
; set segment registers
mov ax, dataSel ;0x10
mov ds,ax
mov es,ax
mov ss,ax
mov fs,ax
mov gs,ax
ret ; return back to the kernel
[section .data]
gdt:
; NULL descriptor ; 00000h
dw 0 ; limit 15:0
dw 0 ; base 15:0
db 0 ; base 23:16
db 0 ; type
db 0 ; limit 19:16, flags
db 0 ; base 31:24
; unused descriptor ; 0008h
dw 0
dw 0
db 0
db 0
db 0
db 0
dataSel equ $-gdt ;0010h, points to base address 0
dw 0FFFFh
dw 0
db 0
db 92h ; present, ring 0, data, expand-up, writable
db 0CFh ; page-granular (4 gig limit), 32-bit
db 0
codeSel equ $-gdt ; 0018h
dw 0FFFFh
dw 0
db 0
db 9Ah ; present,ring 0,code,non-conforming,readable
db 0CFh ; page-granular (4 gig limit), 32-bit
db 0
videoSel equ $-gdt
dw 0FFFFh
dw 0x8000
db 0x000b
db 92h
db 0CFh
db 0
gdt_end:
gdt_ptr:
dw gdt_end - gdt - 1
dd gdt ; linear, physical address of GDT
Can anyone please shed some light on this... Do I even need the 'unused descriptor' ?
Thanks for all the help!