Hello!
I have the following problem, my os worked more or less ok up to the moment when the binary of my os became bigger than 80 KB. Now, i can't even do like "int 80h" because it generates a "jump far" even though i am able to access the handler function "call _int_80_hand" directly when not going through the interrupt table. Suppose that the code is ok, could these be a linking or compiling issue? what could be happening?
Thank you very much!
IDT Problem when the binary is of more than 80 KB
- NickJohnson
- Member
- Posts: 1249
- Joined: Tue Mar 24, 2009 8:11 pm
- Location: Sunnyvale, California
Re: IDT Problem when the binary is of more than 80 KB
I'm guessing your problem is that the actual loadable size of the kernel has exceeded 64 KB, which may make some primitive bootloaders choke. What bootloader are you using? Other general information would probably be useful too.
Re: IDT Problem when the binary is of more than 80 KB
Thanks for the quick answer!NickJohnson wrote:I'm guessing your problem is that the actual loadable size of the kernel has exceeded 64 KB, which may make some primitive bootloaders choke. What bootloader are you using? Other general information would probably be useful too.
This is the situation: i'm using grub 0.96 and the link.ld i'm using is the following:
Code: Select all
ENTRY (_loader)
SECTIONS{
. = 0x00100000;
.text :{
*(.text)
}
.rodata ALIGN (0x1000) : {
*(.rodata)
}
.data ALIGN (0x1000) : {
*(.data)
}
.bss : {
_sbss = .;
*(COMMON)
*(.bss)
_ebss = .;
}
}
Thanks very much!
- 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: IDT Problem when the binary is of more than 80 KB
Since you are using GRUB and ld, the chance that the toolchain is involved in the error is virtually absent.
Have you tried running your code in bochs? What are the error messages there (if any)?
Have you tried running your code in bochs? What are the error messages there (if any)?
Re: IDT Problem when the binary is of more than 80 KB
I'm using bochs, the error is number 13 and goes something like "Invalid Executable format" though the format seems to be ok. I've been trying out some stuff and if i compile it in a different order it works but is not possible to do "int XXh".Combuster wrote:Since you are using GRUB and ld, the chance that the toolchain is involved in the error is virtually absent.
Have you tried running your code in bochs? What are the error messages there (if any)?
Thank you!
- 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: IDT Problem when the binary is of more than 80 KB
For the first problem, read the FAQ.
For the second problem, please read my previous post again: what does bochs say (= what does the log show)
For the second problem, please read my previous post again: what does bochs say (= what does the log show)
Re: IDT Problem when the binary is of more than 80 KB
I found the problem..thank you very much!
The idtr loading-code had a bug. The problem was the way the function recovered the parameter from the stack:
The call to the function was something like this:
So, when the code was small the high part of ebp+6 was the same as the high part of ebp +8 then no problem occurred. But when the code got bigger this was not the same and that was the reason why when the binary got bigger than 80 K the problem appeared.
Thank you all!
The idtr loading-code had a bug. The problem was the way the function recovered the parameter from the stack:
Code: Select all
_lidt: ; loads IDTR
push ebp
mov ebp, esp
push ebx
mov ebx, [ss: ebp + 6] ; HERE IS THE BUG!! it should be ebp + 8 and the rol shouldn't go
rol ebx,16 ;
lidt [ds: ebx] ; loads IDTR
pop ebx
pop ebp
retn
Code: Select all
/* loads the IDTR */
idtr.base = 0;
idtr.base +=(dword) &idt;
idtr.limit = sizeof(idt)-1;
_lidt (&idtr);
Thank you all!