Strange behaviour, fetch_raw_descriptor

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
mangaluve
Member
Member
Posts: 110
Joined: Mon Feb 23, 2009 6:53 am

Strange behaviour, fetch_raw_descriptor

Post 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

Code: Select all

unsigned char test = 5;
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?
mangaluve
Member
Member
Posts: 110
Joined: Mon Feb 23, 2009 6:53 am

Re: Strange behaviour, fetch_raw_descriptor

Post 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).
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Strange behaviour, fetch_raw_descriptor

Post 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.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
JohnnyTheDon
Member
Member
Posts: 524
Joined: Sun Nov 09, 2008 2:55 am
Location: Pennsylvania, USA

Re: Strange behaviour, fetch_raw_descriptor

Post 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.)?
mangaluve
Member
Member
Posts: 110
Joined: Mon Feb 23, 2009 6:53 am

Re: Strange behaviour, fetch_raw_descriptor

Post 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

Code: Select all

outb(0x1f5, 0);
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!
Post Reply