Problems with PMode
Problems with PMode
Hello. I have PMode problem again. I started new brand OS project and something don't work. I attached my source code of my bootloader. When i emulate it with bochs, it writes me an error:
Bochs is exiting with the following message:
[CPU ] jump_protected: cs == 0
Can you help me? Can you tell me what i need to correct in my code?
Bochs is exiting with the following message:
[CPU ] jump_protected: cs == 0
Can you help me? Can you tell me what i need to correct in my code?
Re:Problems with PMode
First you switch to Pmode
Then you immediately try to load CS with the NULL selector.
You have something totally confused here, I'm not surprised Bochs doesn't like it.
Code: Select all
mov eax, cr0
or eax, 1
mov cr0, eax
jmp code_selector:flush_pipe
Code: Select all
jmp 0:0x8000
Re:Problems with PMode
Now i written my simple kernel that just shoud write a letter on the screen, but it does not do that. It just reboots.
There is my boot and kernel:
http://avnet.sytes.net/~vladas/boot.asm
http://avnet.sytes.net/~vladas/kernel.asm
can someone help me, please? ???
There is my boot and kernel:
http://avnet.sytes.net/~vladas/boot.asm
http://avnet.sytes.net/~vladas/kernel.asm
can someone help me, please? ???
Re:Problems with PMode
In boot.asm:
and
In the first, you are loading the kernel to 0000:8000 (0x00008000) and in pmode you are jumping to 0x000800000. Big difference!
Overall it looks pretty good. Everything else seems fine.
Good luck
Code: Select all
SectorLoader:
xor bx, bx
mov es, bx
mov bx, 0x8000
Code: Select all
flush_pipe:
jmp code_selector:0x80000
Overall it looks pretty good. Everything else seems fine.
Good luck
Re:Problems with PMode
In boot.asm:
For the GDT, the limit must be gdt_end-gdt-1. It doesn't make too much sense, except that this allows a GDT with length 0xFFFF, really meaning 0x10000, but small enough to fit within a 16-bit word. I don't know if this would be enough to cause a reboot, though.
Good Luck
Code: Select all
gdtr:
dw gdt_end-gdt
dd gdt
Good Luck
Re:Problems with PMode
From the NASM manual:
For example, the following code will generate the longword 0x00000104:
org 0x100
dd label
label:
Umm... if "gdtr" is equal to ORG+offset, wouldn't "lgdt [gdtr]" load from DS:ORG+offset, or 0000:7C00+offset? The bootloader I wrote has "org 0" with a CS and DS of 0x07C0, so a bootloader with CS and DS equal to 0x0000, the ORG would have to be 0x7C00.Here the assembler will decide that the label "gdtr" is equal to ORG + offset, or 0x7C??. Because you set DS to 0 the instruction "lgdt [gdtr]" will try to load from DS base + offset, or 0x00?? (which is definately not where it should be).
Re:Problems with PMode
Hi,
I should be more careful - thanks for noticing my mistake. I'll edit my last post so no-one tries to use it..
Cheers,
Brendan
Ooops - you're right. I made the mistake that I thought Vladaz was making, and messed everything up. There was no problem with the boot code, and my examples are wrong too :'(.Mike wrote: Umm... if "gdtr" is equal to ORG+offset, wouldn't "lgdt [gdtr]" load from DS:ORG+offset, or 0000:7C00+offset? The bootloader I wrote has "org 0" with a CS and DS of 0x07C0, so a bootloader with CS and DS equal to 0x0000, the ORG would have to be 0x7C00.
I should be more careful - thanks for noticing my mistake. I'll edit my last post so no-one tries to use it..
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.