Page 1 of 1

I got some bug on part 4 of jamesM's tutorial

Posted: Wed Jan 22, 2014 10:01 am
by usernameHere
I've been following Jame's tutorial and it seems ok, however I have hit a bug on part 4. It is probably something simple so I would like a fresh pairs of eyes to have a peek at my code. I did after all I did stop it from compiling with an incorrect letter, however that has been rectified now.
My code is attached below and thank you for reading this, I'm sure it is one of many annoying newbie questions (sorry).

Re: I got some bug on part 4 of jamesM's tutorial

Posted: Wed Jan 22, 2014 10:52 am
by PearOs
usernameHere wrote:I've been following Jame's tutorial and it seems ok, however I have hit a bug on part 4. It is probably something simple so I would like a fresh pairs of eyes to have a peek at my code. I did after all I did stop it from compiling with an incorrect letter, however that has been rectified now.
My code is attached below and thank you for reading this, I'm sure it is one of many annoying newbie questions (sorry).
I'm going to suggest that you "explain" the bug your experiencing because I'm not sure if anyone is going to pick through your code to figure it out.

- Matt

Re: I got some bug on part 4 of jamesM's tutorial

Posted: Wed Jan 22, 2014 10:59 am
by usernameHere
Ah yes, not so much as a bug but it just won't work (I'm quite tired so sorry for not explaining properly). The code compiles fine however running it in bochs will cause it to restart at "int 0x03". There is some interesting stuff in the log which I believe indicates I didn't set up the interrupts properly.

Code: Select all

00050627844e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x03)
00050627844e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x0d)
00050627844e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x08)
I believe the first one is my own issued interrupt and the last two are the CPU trying to send an interrupt because the first one failed.

Re: I got some bug on part 4 of jamesM's tutorial

Posted: Wed Jan 22, 2014 2:08 pm
by PearOs
usernameHere wrote:Ah yes, not so much as a bug but it just won't work (I'm quite tired so sorry for not explaining properly). The code compiles fine however running it in bochs will cause it to restart at "int 0x03". There is some interesting stuff in the log which I believe indicates I didn't set up the interrupts properly.

Code: Select all

00050627844e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x03)
00050627844e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x0d)
00050627844e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x08)
I believe the first one is my own issued interrupt and the last two are the CPU trying to send an interrupt because the first one failed.
I could be wrong, but I have a feeling your IDT entrys are not valid. Make sure your IDT Table is setup properly and that you have interrupts actually mapped. That might have been the bug in JamesMolleys tutorial if I remember right.. Anyways post your IDT code if you don't mind, I have a feeling its something to do with it.

Re: I got some bug on part 4 of jamesM's tutorial

Posted: Wed Jan 22, 2014 2:45 pm
by usernameHere
Ok, I've put the code on pastebin because it would have made this reply gigantic.
Descriptor tables
Descriptor tables (header)
Interupts

Re: I got some bug on part 4 of jamesM's tutorial

Posted: Wed Jan 22, 2014 3:46 pm
by PearOs
Where is your assembly code where you use the "LIDT" instruction? Because if you haven't loaded the IDT that would be the cause.

- Matt

Edit: I looked through your code and found idt_flush, good so you do have that but I don't see it being called in your code as far as I have seen.

Yeah, your not calling "idt_flush" when you init your IDT so its not even being loaded, which is why your getting invalid descriptors. - Matt

Re: I got some bug on part 4 of jamesM's tutorial

Posted: Wed Jan 22, 2014 3:59 pm
by usernameHere
I feel stupid now but sometimes you just need a fresh pair of eyes to point out the obvious. Thank you for helping
Image

Re: I got some bug on part 4 of jamesM's tutorial

Posted: Wed Jan 22, 2014 4:25 pm
by PearOs
usernameHere wrote:I feel stupid now but sometimes you just need a fresh pair of eyes to point out the obvious. Thank you for helping
Image
Hahaha that's alright, glad to see its working. :)

Thanks, Matt

Re: I got some bug on part 4 of jamesM's tutorial

Posted: Wed Jan 22, 2014 6:07 pm
by Nessphoro
Just as a precaution: James' tutorials aren't designed to be copy-pastable but rather to teach a general idea. You will run into this the most during his multithreading implementation which no sound person should utilize.

Re: I got some bug on part 4 of jamesM's tutorial

Posted: Fri Jan 24, 2014 9:54 am
by usernameHere
Yeah I'm using it as my main resource but I have a lot in the background as well, including the OSDev wiki.