How does my IDT and entry encoder look?

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
User avatar
beauhefley
Posts: 13
Joined: Mon Feb 20, 2017 1:01 am
Location: The Moon
Contact:

How does my IDT and entry encoder look?

Post by beauhefley »

Working on my IDT, haven't written any ISRs though.
How does my code look? I want to make sure I'm doing this right.
idt.h:
https://github.com/beauhefley/beauos/bl ... upts/idt.h
idt.c:
https://github.com/beauhefley/beauos/bl ... upts/idt.c
Of course I do not have loadIdt() set up yet.
Developing an OS that is so early in development, it can't do anything because stupid me can't figure out interrupts
Image
User avatar
TheCool1Kevin
Posts: 24
Joined: Fri Oct 14, 2016 7:37 pm
Location: Canada
Contact:

Re: How does my IDT and entry encoder look?

Post by TheCool1Kevin »

It's not terribly bad, however, there are 2 things I would like to mention:
1. Your IDT base high value on line 14 is this:

Code: Select all

idt[entry].hOffset = functionPointer >> 16;
However, it should really be this:

Code: Select all

idt[entry].hOffset = (functionPointer >> 16) & 0xFFFF;
2. The "gateType" data type will cause you some level of headaches when you implement user mode and rings.
Personally, I recommend you leave it as "uint8_t flags", and then set the idt[entry].attributes to flags. This way, when time comes for you to implement user mode, you can set the value idt[entry].attributes to flags | 0x60.
I dunno, just some opinions.
LiquiDOS, my weird hobbyist OS.
"Strive for progress, not perfection" - Anonymous
mikegonta
Member
Member
Posts: 229
Joined: Thu May 19, 2011 5:13 am
Contact:

Re: How does my IDT and entry encoder look?

Post by mikegonta »

TheCool1Kevin wrote:It's not terribly bad, however, there are 2 things I would like to mention:
1. Your IDT base high value on line 14 is this:

Code: Select all

idt[entry].hOffset = functionPointer >> 16;
However, it should really be this:

Code: Select all

idt[entry].hOffset = (functionPointer >> 16) & 0xFFFF;
This one is fine as it was, the & 0xFFFF is redundant and not required as the hOffset is uint16_t
line 13:

Code: Select all

idt[entry].lOffset = functionPointer & 0xFFFF;
Here, the & 0xFFFF is also redundant and not required as the lOffset is also uint16_t
Mike Gonta
look and see - many look but few see

https://mikegonta.com
User avatar
osdever
Member
Member
Posts: 492
Joined: Fri Apr 03, 2015 9:41 am
Contact:

Re: How does my IDT and entry encoder look?

Post by osdever »

Welp, looks very organized, it's easy to read, let's forget about more than a half of code being non-present at now because, as you previously stated, it's still WIP. Look at the issues previous poster mentioned though.
Developing U365.
Source:
only testing: http://gitlab.com/bps-projs/U365/tree/testing

OSDev newbies can copy any code from my repositories, just leave a notice that this code was written by U365 development team, not by you.
LtG
Member
Member
Posts: 384
Joined: Thu Aug 13, 2015 4:57 pm

Re: How does my IDT and entry encoder look?

Post by LtG »

You do realize this is a two month old thread, right?

I don't have a problem with replying to old posts but the OP _might_ not be waiting this long =)
User avatar
osdever
Member
Member
Posts: 492
Joined: Fri Apr 03, 2015 9:41 am
Contact:

Re: How does my IDT and entry encoder look?

Post by osdever »

Didn't notice it, LOL.
Developing U365.
Source:
only testing: http://gitlab.com/bps-projs/U365/tree/testing

OSDev newbies can copy any code from my repositories, just leave a notice that this code was written by U365 development team, not by you.
Post Reply