STI crashes the OS

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Guest

STI crashes the OS

Post by Guest »

Hi!
I have a problem with my OS, HeliX (www.Helixos.de.vu). After I inizialisized the IDT, and I want to usw IRQs I have to do a STI, but then a General Protection Exeption appears. Perhaps you can download my OS and check whats up... :) Im using the John S. fine Bootloader and the kmain of my OS looks like that:

mov_cursor(80,25);
init_pics(0x20, 0x28);
enable_irqs(0xFF,0xFF);
create_idt();
loadIDTR();   
enable_irqs(0x0,0x0);
cls();
//STI() ARGHHHHH
while(1) {}

please help me, I need IRQs!!!!
::)
Therx

Re:STI crashes the OS

Post by Therx »

It would imply that either your interrupt handlers were faulty or that you hadn't remapped the PICs.

I've had a look at the code on your site. The pic remapping code looks fine but it looks like you've tried to write the ISRs in C.

My advice.
1. Comment the line "enable_irqs(0x0, 0x0);" and uncomment STI. Does it still crash? Shouldn't

2. Then read up on implementing the ISRs in assembly and do that.

Pete
Guest

Re:STI crashes the OS

Post by Guest »

Ok thank you for your fast answer.... Ill try!
guest

Re:STI crashes the OS

Post by guest »

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!!!!! :D :D
Therx

Re:STI crashes the OS

Post by Therx »

In entry.asm insert:

Code: Select all

  jmp LINEAR_CODE_SEL:newgdt
newgdt:
After:-

Code: Select all

  mov ax,LINEAR_DATA_SEL
  mov ds,ax
  mov es,ax
  mov ss,ax
  mov fs,ax
  mov gs,ax
Pete
Happy Guest

Re:STI crashes the OS

Post by Happy Guest »

Jipiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii :D :D :D ;D ;D ;D
IT WORKS!!!!!!!!!!!! Thank you very very much!!!!
You are the best!! ;)
Post Reply