Help with activating pmode

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.
tadada
Member
Member
Posts: 42
Joined: Sun Apr 20, 2008 5:32 pm
Location: Index 0 of the nearest Array

Post by tadada »

My kernel is loaded into 0x500.

Before the first jump cx contains 0x3.
After the first jump it contains 0x0.
After the second jump it contains 0x0
My OS: SOS (Simple Operating System).
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

JMP/CALL do not change CX (although SYSCALL does). If CX changes just due to a JMP, you should seriously check whether:

1) EIP is where you would expect.
2) The code you want to run is where you expect it to be.

Is the entry point of your kernel in the same place as the start of the kernel's memory image? If not, you need to either ensure that it is, or know the offset of the kernel entry point.

Oh - and about that GPF:

Code: Select all

00002626616e[CPU0 ] fetch_raw_descriptor: GDT: index (f)1 > limit (0)
indicates that your GDT has no entries (limit (0)) and you therefore need to load GDTR with the correct value.

Cheers,
Adam
tadada
Member
Member
Posts: 42
Joined: Sun Apr 20, 2008 5:32 pm
Location: Index 0 of the nearest Array

Post by tadada »

Finally got it working =]. Now it will go into pmode happily. The thing now is I want my OS to be loaded to the 1 Mib mark. The actual loading it is easy. The problem is with the GDT. I believe the GDT entry for the CodeEntry should have its Base changed but there is 3 different bases (low middle and high) and I don't know which ones to change.
My OS: SOS (Simple Operating System).
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Post by neon »

There is only one base, they just represent the low, middle, and high bits of the base address. This represents the lowest physical address that you can access.

You shouldn't need to change it at all. If you do decide to, just create a new GDT in your kernel once you load and execute it.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Post Reply