OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Apr 23, 2024 10:51 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Dynamic IDT (how to implement?)
PostPosted: Tue May 17, 2011 7:08 am 
Offline

Joined: Tue May 17, 2011 6:59 am
Posts: 5
Hi all, I am building a kernel, and need to build a simple IDT loader system.
I am coding in pure ASM. (protected mode, 32 bit)

The idea is that...

1. I load a file from the root directory defining what files need to be loaded into memory, and what IDT's correspond to which binary which is now in memory. (Not coded, but I can do this)
2. Based on the instructions in this file, modify existing entries in the IDT (on already exists thanks to aeBIOS) to point to the new file which we loaded into memory.

The idea is a system that can load an interrupt handler from a file, and register it with an IDT, to handle that interrupt.
How would you do Step 2??? Im talking writing to the IDT, with the correct infromation.

Thankyou very much in advance.

-Hyperzap


Last edited by hyperzap on Tue May 17, 2011 3:21 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Dynamic IDT (how to implement?)
PostPosted: Tue May 17, 2011 8:14 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
I didn't knew modifying the idt was that difficult?

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject: Re: Dynamic IDT (how to implement?)
PostPosted: Tue May 17, 2011 10:15 am 
Offline
Member
Member
User avatar

Joined: Wed Dec 01, 2010 3:41 am
Posts: 1761
Location: Hong Kong
Quote:
modify existing entries in the IDT (on already exists thanks to aeBIOS)

You usually can't use the BIOS and the real-mode IDT under protected mode. Setting up your own IDT is a one of thing you'd do after enter to protected mode.
If you're unsure how to manipulate IDT, you should take a look on babystep examples on the wiki;
and it sounds too early to actually implement fancy things (ie. loadable module) before you have an IDT work.

Furthermore, it's not recommended to have loadable module to directly be an INT handler,
since one module could be interested on multiple INT, or multiple drivers may share the same INT.

your kernel could have managed it and allow chains, etc.


Top
 Profile  
 
 Post subject: Re: Dynamic IDT (how to implement?)
PostPosted: Tue May 17, 2011 10:27 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

bluemoon wrote:
Quote:
modify existing entries in the IDT (on already exists thanks to aeBIOS)

You usually can't use the BIOS and the real-mode IDT under protected mode.


aeBIOS is a project that tries to make all the broken ugly mess from the 1970's "real mode BIOS" available in protected mode, so it's easy to make broken and ugly protected mode software (rather than broken and ugly real mode software)... :)


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.


Top
 Profile  
 
 Post subject: Re: Dynamic IDT (how to implement?)
PostPosted: Tue May 17, 2011 10:36 am 
Offline
Member
Member
User avatar

Joined: Wed Dec 01, 2010 3:41 am
Posts: 1761
Location: Hong Kong
Well, I actually don't know such project :p Thanks for noticing.


Top
 Profile  
 
 Post subject: Re: Dynamic IDT (how to implement?)
PostPosted: Tue May 17, 2011 6:25 pm 
Offline

Joined: Tue May 17, 2011 6:59 am
Posts: 5
bluemoon wrote:
Quote:
modify existing entries in the IDT (on already exists thanks to aeBIOS)

You usually can't use the BIOS and the real-mode IDT under protected mode. Setting up your own IDT is a one of thing you'd do after enter to protected mode.
If you're unsure how to manipulate IDT, you should take a look on babystep examples on the wiki;
and it sounds too early to actually implement fancy things (ie. loadable module) before you have an IDT work.

Furthermore, it's not recommended to have loadable module to directly be an INT handler,
since one module could be interested on multiple INT, or multiple drivers may share the same INT.

your kernel could have managed it and allow chains, etc.

Sorry everyone for the confusion. My expression is terrible.

I looked at the info and I now have a grasp of manipulating the IDT. This issue now is this:

When I write code in assembly, I normally have to specify where it will be loaded (using 'org').
But with a dynamic loader, it could go in many locations.
So how do you deal with this???
Thankyou in advance.


Top
 Profile  
 
 Post subject: Re: Dynamic IDT (how to implement?)
PostPosted: Tue May 17, 2011 6:35 pm 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

hyperzap wrote:
When I write code in assembly, I normally have to specify where it will be loaded (using 'org').
But with a dynamic loader, it could go in many locations.
So how do you deal with this???


In order of my personal preference, the options are:
  1. Use paging so that everything can run at its "org" and there's no problem
  2. Use segmentation so that everything can run at its "org" and there's no problem
  3. Write/generate position independent code (requires special support in the toolchain)
  4. Keep track of offsets, etc and patch the code to set/correct offsets during loading (requires special support in the toolchain and loader)


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.


Top
 Profile  
 
 Post subject: Re: Dynamic IDT (how to implement?)
PostPosted: Tue May 17, 2011 8:03 pm 
Offline

Joined: Tue May 17, 2011 6:59 am
Posts: 5
Brendan wrote:
Hi,

hyperzap wrote:
When I write code in assembly, I normally have to specify where it will be loaded (using 'org').
But with a dynamic loader, it could go in many locations.
So how do you deal with this???


In order of my personal preference, the options are:
  1. Use paging so that everything can run at its "org" and there's no problem
  2. Use segmentation so that everything can run at its "org" and there's no problem
  3. Write/generate position independent code (requires special support in the toolchain)
  4. Keep track of offsets, etc and patch the code to set/correct offsets during loading (requires special support in the toolchain and loader)


Cheers,

Brendan

do you have any information/links about the flat binary format? (ie what is made by the assembler for os dev)


Top
 Profile  
 
 Post subject: Re: Dynamic IDT (how to implement?)
PostPosted: Tue May 17, 2011 8:58 pm 
Offline
Member
Member
User avatar

Joined: Tue Mar 24, 2009 8:11 pm
Posts: 1249
Location: Sunnyvale, California
hyperzap wrote:
do you have any information/links about the flat binary format? (ie what is made by the assembler for os dev)


Flat binary format is a non-format. The contents are simply the opcodes and data specified in the assembly file, in the order in which they appear (unless you reorder them somehow.) There are no metadata whatsoever.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: bradbobak, Majestic-12 [Bot] and 119 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