OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 8:41 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Jump protect error when trying to get into protected mode
PostPosted: Wed Sep 28, 2022 3:42 pm 
Offline
User avatar

Joined: Sat Sep 24, 2022 5:42 pm
Posts: 4
Location: Canada
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.

_________________

"If this code is not enough I must put my soul into it."
- Me


Top
 Profile  
 
 Post subject: Re: Jump protect error when trying to get into protected mod
PostPosted: Sat Oct 01, 2022 10:28 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
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.


Top
 Profile  
 
 Post subject: Re: Jump protect error when trying to get into protected mod
PostPosted: Sun Oct 02, 2022 8:17 am 
Offline
User avatar

Joined: Sat Sep 24, 2022 5:42 pm
Posts: 4
Location: Canada
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.

_________________

"If this code is not enough I must put my soul into it."
- Me


Top
 Profile  
 
 Post subject: Re: Jump protect error when trying to get into protected mod
PostPosted: Sun Oct 02, 2022 11:37 am 
Offline
User avatar

Joined: Sat Sep 24, 2022 5:42 pm
Posts: 4
Location: Canada
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.


how do I dump them? (I'm using Bochs)
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


Top
 Profile  
 
 Post subject: Re: Jump protect error when trying to get into protected mod
PostPosted: Sun Oct 02, 2022 12:26 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
343GuiltySpark wrote:
how do I dump them? (I'm using Bochs)

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.


Top
 Profile  
 
 Post subject: Re: Jump protect error when trying to get into protected mod
PostPosted: Sun Oct 02, 2022 12:51 pm 
Offline
User avatar

Joined: Sat Sep 24, 2022 5:42 pm
Posts: 4
Location: Canada
Octocontrabass wrote:
343GuiltySpark wrote:
how do I dump them? (I'm using Bochs)

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.



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


Top
 Profile  
 
 Post subject: Re: Jump protect error when trying to get into protected mod
PostPosted: Fri Oct 07, 2022 6:28 am 
Offline
Member
Member

Joined: Fri Feb 11, 2022 4:55 am
Posts: 435
Location: behind the keyboard
In your repo, kernel.c, the function init_idt()
Code:
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);


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.


Top
 Profile  
 
 Post subject: Re: Jump protect error when trying to get into protected mod
PostPosted: Fri Oct 07, 2022 6:35 am 
Offline
Member
Member

Joined: Fri Feb 11, 2022 4:55 am
Posts: 435
Location: behind the keyboard
What is this ?

Code:
pmodeinit:
   
    cli
    lgdt [gdt_desc]
    mov eax,cr0
    or eax,0x1
    mov cr0,eax
    jmp dword 0x8:0x18


Can you explain this line of code to me ?
Code:
jmp dword 0x8:0x18


Top
 Profile  
 
 Post subject: Re: Jump protect error when trying to get into protected mod
PostPosted: Fri Oct 07, 2022 9:24 am 
Offline
Member
Member
User avatar

Joined: Thu May 12, 2011 7:24 pm
Posts: 89
devc1 wrote:
In your repo, kernel.c, the function init_idt()
Code:
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);


You are declaring the IDTR in the stack, and soon it will be overwritten. You should declare it as a global variable instead.

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.

_________________
Those who understand Unix are doomed to copy it, poorly.


Top
 Profile  
 
 Post subject: Re: Jump protect error when trying to get into protected mod
PostPosted: Fri Oct 07, 2022 10:40 am 
Offline
Member
Member

Joined: Fri Feb 11, 2022 4:55 am
Posts: 435
Location: behind the keyboard
You are right, however he should fix his jump and replace it with :

Code:
jmp dword 0x08:_start


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: SemrushBot [Bot] and 63 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group