Page 1 of 1
Strange behaviour, fetch_raw_descriptor
Posted: Sun Mar 01, 2009 11:51 am
by mangaluve
My OS behaves really weird some times. For instance, I just wrote a function (as a helper to printf) to print hex numbers. When I added the following line
in my code, the OS crashes when I runit in bochs. I got something like
Event type: PANIC
Dvice: [CPU ]
Message: fetch_raw_descriptor: LDTR.valid=0
what can this be?
Re: Strange behaviour, fetch_raw_descriptor
Posted: Sun Mar 01, 2009 1:02 pm
by mangaluve
What is the LDTR, I never use that as far as I know?
Well I have the following code
Code: Select all
void read_hdd_blocks(u8int count, u8int sector, u16int cylinder, u8int *buffer);
void read_hdd_blocks(u8int count, u8int sector, u16int cylinder, u8int *buffer) {
u16int i, tmpword;
outb(0x1f6, 0x0);
outb(0x1f2, count);
outb(0x1f3, sector);
outb(0x1f4, 0);
outb(0x1f5, 0);
outb(0x1f7, 0x20);
};
[code]
i NEVER call it. It doesn't work. But if I remove that last outb-call, it works perfectly (the other code, Im still not invoking the function above).
Re: Strange behaviour, fetch_raw_descriptor
Posted: Sun Mar 01, 2009 1:04 pm
by neon
The LDTR is most likely not the problem if you never use it. Best recommendation I can give is to post your crash log here (more info is always better) and single step through the routine that is failing to see when it crashes.
Re: Strange behaviour, fetch_raw_descriptor
Posted: Sun Mar 01, 2009 1:06 pm
by JohnnyTheDon
Either your code is corrupted, or you're jumping to the middle of an instruction. How are you loading your kernel (GRUB, custom bootloader, etc.)?
Re: Strange behaviour, fetch_raw_descriptor
Posted: Sun Mar 01, 2009 1:16 pm
by mangaluve
I've written my own bootloader. I don't know if something get's wrong when Im loading the kernel, Im doing that in protected mode now instead of using bios interrupts.. I could post the code for the loading here, if anyone has time to look through it. I changed a little thing (removed a HLT or something after my main-function) and now I get "running in bogus memory" instead. So, by just adding the line
to a function that is never called, I get "running in bogus memory"
Edit: this is embarassing but I think I found it. When I copy the kernel to memory, I didn't copy the entire kernel, since it has grown since I wrote the bootloader. So sorry to bother you with my stupidity!