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
Dynamic IDT (how to implement?)
Dynamic IDT (how to implement?)
Last edited by hyperzap on Tue May 17, 2011 3:21 pm, edited 1 time in total.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Dynamic IDT (how to implement?)
I didn't knew modifying the idt was that difficult?
Re: Dynamic IDT (how to implement?)
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.modify existing entries in the IDT (on already exists thanks to aeBIOS)
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.
Re: Dynamic IDT (how to implement?)
Hi,
Cheers,
Brendan
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)...bluemoon wrote:You usually can't use the BIOS and the real-mode IDT under protected mode.modify existing entries in the IDT (on already exists thanks to aeBIOS)
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.
Re: Dynamic IDT (how to implement?)
Well, I actually don't know such project :p Thanks for noticing.
Re: Dynamic IDT (how to implement?)
Sorry everyone for the confusion. My expression is terrible.bluemoon wrote: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.modify existing entries in the IDT (on already exists thanks to aeBIOS)
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.
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.
Re: Dynamic IDT (how to implement?)
Hi,
Cheers,
Brendan
In order of my personal preference, the options are: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???
- Use paging so that everything can run at its "org" and there's no problem
- Use segmentation so that everything can run at its "org" and there's no problem
- Write/generate position independent code (requires special support in the toolchain)
- 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.
Re: Dynamic IDT (how to implement?)
do you have any information/links about the flat binary format? (ie what is made by the assembler for os dev)Brendan wrote:Hi,
In order of my personal preference, the options are: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???
- Use paging so that everything can run at its "org" and there's no problem
- Use segmentation so that everything can run at its "org" and there's no problem
- Write/generate position independent code (requires special support in the toolchain)
- 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
- NickJohnson
- Member
- Posts: 1249
- Joined: Tue Mar 24, 2009 8:11 pm
- Location: Sunnyvale, California
Re: Dynamic IDT (how to implement?)
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.hyperzap wrote:do you have any information/links about the flat binary format? (ie what is made by the assembler for os dev)