can anyone help me

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
k_nil

can anyone help me

Post by k_nil »

hello,
i have written simple kernel which display "hello" using the grub
but when i trying to add the gdt it restarted
as i set section of gdt  {0x0:null,0x08:code and 0x10:data} as well as
set cr0 [with or without] but still it restarted
please solve my problem

[email protected]
[nil]
ASHLEY4

RE:can anyone help me

Post by ASHLEY4 »

Hi
The restart is caused by a triple falt, there is a number of reasons for this so i would have to see your code to be of any help.
When ever i run boot code of anybodys from a boot loader like grub (not that i have used grub)i get the same problem, this is because the sample codes that you get to go into protective mode set's the base of the code and data descriptors to zero, I find that the only way to get the code to not triple falt is at run time to set the code and data descriptors base to DS x 16 and then add a linear data descriptor.
this could be the cause of your problem
hope this helps
ASHLEY4
Moose

RE:can anyone help me

Post by Moose »

The raw reason why you're pc is triple faulting, is because your pc is not switching to pmode (protected mode) correctly.

It does not matter if the segments begin at 0bytes are 50mb, providing the kernel is not outside of the segment.

Check your gdt code and more importantly, your descriptors. Computers dont lie so the biggest chance of your problem is down to incorrect gdt descriptor entries within your gdt. If your absolutely sure 100% that the descriptors are perfect, then check your code, are you doing it right, something is definately wrong.

And another thing. Grub, the bootloader, will load your kernel into pmode automatically. Thats because its apart of the multiboot standard (which grub is based on). So you dont need to set the cr0 bits to enable pmode. Just re-init the gdt table, run lgdt with the correct details and jump to cs:jump_point reset cs to that of your new gdt and you're done.

Moose.
Post Reply