Ok, I changed somrthing:
I added a new GDT after the Bootlaoder loaded the Kernel.bin, and if I comment enable_irqs(0x0 ,0x0); STI works! But if I do not comment it, the exeptionhandler doesnt react, and VMware says: kernel stack fault!
Oh now I just see, with the new GDT, the interrupthandler doesnt react at alll! Heres my new code:
kmain() // first function
{
mov_cursor(80,25);
init_pics(0x20, 0x28);
enable_irqs(0xFF,0xFF);
create_idt();
loadIDTR();
enable_irqs(0x0,0x0);
STI();
int i=5/0;
cls();
printf("hi");
while(1) {}
};
And my entry.asm:
[BITS 32]
[global start]
[extern _kmain] ; this is in the c file
start:
; stop using bootloader GDT, and load new GDT
lgdt [gdt_ptr]
mov ax,LINEAR_DATA_SEL
mov ds,ax
mov es,ax
mov ss,ax
mov fs,ax
mov gs,ax
call _kmain
jmp start
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SECTION .data
gdt:
; NULL descriptor
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
dw 0
dw 0
db 0
db 0
db 0
db 0
LINEAR_DATA_SEL equ $-gdt
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
LINEAR_CODE_SEL equ $-gdt
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
gdt_end:
gdt_ptr:
dw gdt_end - gdt - 1
dd gdt
That was very much....
Thank you for reading!!!!!
