How can i load the IDT?
Re: How can i load the IDT?
Tell us what you understand an interrupt to be, how one is triggered, and how the processor responds. That may help us to understand what your problem is.
-
- Member
- Posts: 273
- Joined: Sun Oct 09, 2016 4:38 am
- Libera.chat IRC: NunoLava1998
Re: How can i load the IDT?
An interrupt is a piece of data between the 0x0000 - 0x00FF sections of memory that points to a specific address, also called the "interrupt handler".iansjack wrote:Tell us what you understand an interrupt to be, how one is triggered, and how the processor responds. That may help us to understand what your problem is.
It is triggered using the "int (00-FF)" command.
The processor responds by seeing what the specified interrupt points to, and "calls" that location.
I know how interrupts know, i just want to know how to load the interrupt descriptor table, which i don't know.
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.
https://github.com/NunoLava1998/DixiumOS
https://github.com/NunoLava1998/DixiumOS
Re: How can i load the IDT?
The wiki page seems quite clear to me. It provides the structure that you need:NunoLava1998 wrote:An interrupt is a piece of data between the 0x0000 - 0x00FF sections of memory that points to a specific address, also called the "interrupt handler".iansjack wrote:Tell us what you understand an interrupt to be, how one is triggered, and how the processor responds. That may help us to understand what your problem is.
It is triggered using the "int (00-FF)" command.
The processor responds by seeing what the specified interrupt points to, and "calls" that location.
I know how interrupts know, i just want to know how to load the interrupt descriptor table, which i don't know.
Code: Select all
struct IDTDescr {
uint16_t offset_1; // offset bits 0..15
uint16_t selector; // a code segment selector in GDT or LDT
uint8_t zero; // unused, set to 0
uint8_t type_attr; // type and attributes, see below
uint16_t offset_2; // offset bits 16..31
};
Because the address is split into two parts (offset_1 and offset_2), you need to split it up yourself too, like so:
Code: Select all
offset_1 = base_address & 0xFFFF;
offset_2 = (base_address >> 16) & 0xFFFF;
com.sun.java.swing.plaf.nimbus.InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowNotFocusedState
Compiler Development Forum
Compiler Development Forum
Re: How can i load the IDT?
OK.NunoLava1998 wrote:An interrupt is a piece of data between the 0x0000 - 0x00FF sections of memory that points to a specific address, also called the "interrupt handler".iansjack wrote:Tell us what you understand an interrupt to be, how one is triggered, and how the processor responds. That may help us to understand what your problem is.
It is triggered using the "int (00-FF)" command.
The processor responds by seeing what the specified interrupt points to, and "calls" that location.
I know how interrupts know, i just want to know how to load the interrupt descriptor table, which i don't know.
That confirms what has been pretty obvious all along. You don't understand interrupts and you don't really know why you are trying to use them.
I'd suggest, as has already been done, that you go back and do some more reading before trying to leap into waters that are too deep for you.
This site is not really intended to teach basic concepts, but a little research on your part should turn up plenty of information. As long as you are prepared to do the work.
Here's a starting point for you: http://wiki.osdev.org/Interrupts
-
- Member
- Posts: 273
- Joined: Sun Oct 09, 2016 4:38 am
- Libera.chat IRC: NunoLava1998
Re: How can i load the IDT?
I still don't understand a few things:zenzizenzicube wrote:The wiki page seems quite clear to me. It provides the structure that you need:NunoLava1998 wrote:An interrupt is a piece of data between the 0x0000 - 0x00FF sections of memory that points to a specific address, also called the "interrupt handler".iansjack wrote:Tell us what you understand an interrupt to be, how one is triggered, and how the processor responds. That may help us to understand what your problem is.
It is triggered using the "int (00-FF)" command.
The processor responds by seeing what the specified interrupt points to, and "calls" that location.
I know how interrupts know, i just want to know how to load the interrupt descriptor table, which i don't know.You need to create an array of 256 of these, and you pass the address in of the first one to the lidt instruction.Code: Select all
struct IDTDescr { uint16_t offset_1; // offset bits 0..15 uint16_t selector; // a code segment selector in GDT or LDT uint8_t zero; // unused, set to 0 uint8_t type_attr; // type and attributes, see below uint16_t offset_2; // offset bits 16..31 };
Because the address is split into two parts (offset_1 and offset_2), you need to split it up yourself too, like so:Hopefully that clears a little bit up.Code: Select all
offset_1 = base_address & 0xFFFF; offset_2 = (base_address >> 16) & 0xFFFF;
"an array of 256 of these", what? Do you mean 256 of the struct, or 256 of the address?
What do i put in the lidt instruction, the inline assembly example needs 2 (void* base and uint16_t size)?
That's literally it.
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.
https://github.com/NunoLava1998/DixiumOS
https://github.com/NunoLava1998/DixiumOS
-
- Member
- Posts: 273
- Joined: Sun Oct 09, 2016 4:38 am
- Libera.chat IRC: NunoLava1998
Re: How can i load the IDT?
Ahh, i seem to understand it a bit.
Should "do_lidt" in this case load the IDT at 0xFFFF00-0xFFFFFF? (EDIT: Changed to later, this is in the ISA Memory Hole region!)
EDIT:
I got it working perfectly with:
Should "do_lidt" in this case load the IDT at 0xFFFF00-0xFFFFFF? (EDIT: Changed to later, this is in the ISA Memory Hole region!)
Code: Select all
static inline void lidt(void* base, uint16_t size)
{ // This function works in 32 and 64bit mode
struct {
uint16_t length;
void* base;
} __attribute__((packed)) IDTR = { size, base };
asm ( "lidt %0" : : "m"(IDTR) ); // let the compiler choose an addressing mode
}
void do_lidt(void) {
void *base = (void *)0x10000FF;
uint16_t size = 0x00FF;
lidt(void* base, uint16_t size);
}
I got it working perfectly with:
Code: Select all
static inline void lidt(void* base, uint16_t size)
{ // This function works in 32 and 64bit mode
struct {
uint16_t length;
void* base;
} __attribute__((packed)) IDTR = { size, base };
asm ( "lidt %0" : : "m"(IDTR) ); // let the compiler choose an addressing mode
}
void do_lidt(void) {
void *base = (void *)0x10000FF;
uint16_t size = 0x00FF;
lidt(base, size);
}
Last edited by NunoLava1998 on Mon Jan 02, 2017 9:29 am, edited 1 time in total.
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.
https://github.com/NunoLava1998/DixiumOS
https://github.com/NunoLava1998/DixiumOS
-
- Member
- Posts: 273
- Joined: Sun Oct 09, 2016 4:38 am
- Libera.chat IRC: NunoLava1998
Re: How can i load the IDT?
did i cause a M7.5 earthquake or what (sarcasm)alexfru wrote:
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.
https://github.com/NunoLava1998/DixiumOS
https://github.com/NunoLava1998/DixiumOS
-
- Member
- Posts: 501
- Joined: Wed Jun 17, 2015 9:40 am
- Libera.chat IRC: glauxosdever
- Location: Athens, Greece
Re: How can i load the IDT?
Hi,
Your post count overflowed!
Regards,
glauxosdever
Your post count overflowed!
Regards,
glauxosdever
-
- Member
- Posts: 273
- Joined: Sun Oct 09, 2016 4:38 am
- Libera.chat IRC: NunoLava1998
Re: How can i load the IDT?
glauxosdever wrote:Hi,
Your post count overflowed!
Regards,
glauxosdever
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.
https://github.com/NunoLava1998/DixiumOS
https://github.com/NunoLava1998/DixiumOS
-
- Member
- Posts: 273
- Joined: Sun Oct 09, 2016 4:38 am
- Libera.chat IRC: NunoLava1998
Re: How can i load the IDT?
I just realized the code above is completely wrong (triple faults). Can someone show what to put in? Nothing in the IDT page is clear to me.
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.
https://github.com/NunoLava1998/DixiumOS
https://github.com/NunoLava1998/DixiumOS
-
- Member
- Posts: 501
- Joined: Wed Jun 17, 2015 9:40 am
- Libera.chat IRC: glauxosdever
- Location: Athens, Greece
Re: How can i load the IDT?
Hi,
If nothing is clear to you on the IDT page, then you probably should learn the computer science basics first.
Regards,
glauxosdever
If nothing is clear to you on the IDT page, then you probably should learn the computer science basics first.
Regards,
glauxosdever
Re: How can i load the IDT?
What did you think it was going to do? You point the IDT to a random bit of memory.NunoLava1998 wrote:I just realized the code above is completely wrong (triple faults). Can someone show what to put in? Nothing in the IDT page is clear to me.
-
- Member
- Posts: 273
- Joined: Sun Oct 09, 2016 4:38 am
- Libera.chat IRC: NunoLava1998
Re: How can i load the IDT?
So? I wanted to put the IDT in that "random bit of memory" (unused space). I don't need to make space, as it is unused (assuming you always do cold reboots to reset the RAM)iansjack wrote:What did you think it was going to do? You point the IDT to a random bit of memory.NunoLava1998 wrote:I just realized the code above is completely wrong (triple faults). Can someone show what to put in? Nothing in the IDT page is clear to me.
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.
https://github.com/NunoLava1998/DixiumOS
https://github.com/NunoLava1998/DixiumOS
Re: How can i load the IDT?
And have you created a table at that location?