Jump protect error when trying to get into protected mode
- 343GuiltySpark
- Posts: 4
- Joined: Sat Sep 24, 2022 5:42 pm
- Location: Canada
Jump protect error when trying to get into protected mode
when I boot into protected mode (or try to rather), Bochs gives me the following error.
jump_protected: gate type 13 unsupported
I'm not sure why it's doing this, I've searched everywhere for info but can't find anything on type 13 specifically.
here's the code repo
https://github.com/343GuiltySpark-04/Vo ... ter/kernel
I'm really loving OS development and thanks for the amazing wiki resources to help aspiring hobbyists.
jump_protected: gate type 13 unsupported
I'm not sure why it's doing this, I've searched everywhere for info but can't find anything on type 13 specifically.
here's the code repo
https://github.com/343GuiltySpark-04/Vo ... ter/kernel
I'm really loving OS development and thanks for the amazing wiki resources to help aspiring hobbyists.
"If this code is not enough I must put my soul into it."
- Me
-
- Member
- Posts: 5563
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Jump protect error when trying to get into protected mod
If you dump your registers, you'll see that there's garbage in GDTR because the limit is a word, not a byte.
You'll still have problems after you fix that because your jump destination is nonsense.
It looks like you've adapted a lot of your startup code from a real mode bootloader. GRUB switches to protected mode and enables A20, so you don't need to do either of those things.
You'll still have problems after you fix that because your jump destination is nonsense.
It looks like you've adapted a lot of your startup code from a real mode bootloader. GRUB switches to protected mode and enables A20, so you don't need to do either of those things.
- 343GuiltySpark
- Posts: 4
- Joined: Sat Sep 24, 2022 5:42 pm
- Location: Canada
Re: Jump protect error when trying to get into protected mod
I had some help from the discord server before the post was approved, thanks anyway though (I wasn't sure how or if I could cancel the post, I'm not used to using forums).
my apologies.
my apologies.
"If this code is not enough I must put my soul into it."
- Me
- 343GuiltySpark
- Posts: 4
- Joined: Sat Sep 24, 2022 5:42 pm
- Location: Canada
Re: Jump protect error when trying to get into protected mod
how do I dump them? (I'm using Bochs)Octocontrabass wrote:If you dump your registers, you'll see that there's garbage in GDTR because the limit is a word, not a byte.
You'll still have problems after you fix that because your jump destination is nonsense.
It looks like you've adapted a lot of your startup code from a real mode bootloader. GRUB switches to protected mode and enables A20, so you don't need to do either of those things.
and yes this was a carried-over project from when I barely knew ASM, I'm actually considering starting from scratch.
"If this code is not enough I must put my soul into it."
- Me
-
- Member
- Posts: 5563
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Jump protect error when trying to get into protected mod
Use the debugger. I think the "regs" command will show it, but I haven't used Bochs in a while so I might be remembering wrong.343GuiltySpark wrote:how do I dump them? (I'm using Bochs)
- 343GuiltySpark
- Posts: 4
- Joined: Sat Sep 24, 2022 5:42 pm
- Location: Canada
Re: Jump protect error when trying to get into protected mod
Octocontrabass wrote:Use the debugger. I think the "regs" command will show it, but I haven't used Bochs in a while so I might be remembering wrong.343GuiltySpark wrote:how do I dump them? (I'm using Bochs)
yeah that's the right command, but when the fault occurs it locks up and I cant dump the regs while its showing the error message.
"If this code is not enough I must put my soul into it."
- Me
Re: Jump protect error when trying to get into protected mod
In your repo, kernel.c, the function init_idt()
You are declaring the IDTR in the stack, and soon it will be overwritten. You should declare it as a global variable instead.
The stack is a temporal store of informations and when you exit a function it gets cleared and overwritten by other functions.
Gate 13 may be an interrupt, and your corrupt IDTR does no longer reference your IDT.
Try this fix and tell me if it has an effect.
I am still looking for problems in your code.
Code: Select all
struct IDT_pointer idt_ptr;
idt_ptr.limit = (sizeof(struct IDT_entry) * IDT_SIZE) - 1;
idt_ptr.base = (unsigned int)&IDT;
// Now load this IDT
load_idt(&idt_ptr);
The stack is a temporal store of informations and when you exit a function it gets cleared and overwritten by other functions.
Gate 13 may be an interrupt, and your corrupt IDTR does no longer reference your IDT.
Try this fix and tell me if it has an effect.
I am still looking for problems in your code.
Re: Jump protect error when trying to get into protected mod
What is this ?
Can you explain this line of code to me ?
Code: Select all
pmodeinit:
cli
lgdt [gdt_desc]
mov eax,cr0
or eax,0x1
mov cr0,eax
jmp dword 0x8:0x18
Code: Select all
jmp dword 0x8:0x18
Re: Jump protect error when trying to get into protected mod
This code is not declaring the IDTR in the stack -- it's a hardware register, after all. It just constructs the IDT descriptor to be loaded into that register, then loads it, after which point it's no longer needed. This is not a problem, and there's no need to keep the descriptor around in a global variable.devc1 wrote:In your repo, kernel.c, the function init_idt()You are declaring the IDTR in the stack, and soon it will be overwritten. You should declare it as a global variable instead.Code: Select all
struct IDT_pointer idt_ptr; idt_ptr.limit = (sizeof(struct IDT_entry) * IDT_SIZE) - 1; idt_ptr.base = (unsigned int)&IDT; // Now load this IDT load_idt(&idt_ptr);
Those who understand Unix are doomed to copy it, poorly.
Re: Jump protect error when trying to get into protected mod
You are right, however he should fix his jump and replace it with :
Code: Select all
jmp dword 0x08:_start