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.
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?
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).
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();}
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!