Page 1 of 1

IDT Problem when the binary is of more than 80 KB

Posted: Sat Oct 31, 2009 1:17 pm
by spderosso
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!

Re: IDT Problem when the binary is of more than 80 KB

Posted: Sat Oct 31, 2009 2:26 pm
by NickJohnson
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

Posted: Sat Oct 31, 2009 3:14 pm
by spderosso
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.
Thanks for the quick answer!
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 = .;
    }
}
The problem occurs when the binary exceeds 80K.

Thanks very much!

Re: IDT Problem when the binary is of more than 80 KB

Posted: Sat Oct 31, 2009 5:03 pm
by Combuster
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)?

Re: IDT Problem when the binary is of more than 80 KB

Posted: Sat Oct 31, 2009 5:15 pm
by spderosso
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)?
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".

Thank you!

Re: IDT Problem when the binary is of more than 80 KB

Posted: Sat Oct 31, 2009 5:17 pm
by Combuster
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)

Re: IDT Problem when the binary is of more than 80 KB

Posted: Sat Oct 31, 2009 6:56 pm
by spderosso
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:

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
The call to the function was something like this:

Code: Select all

	/* loads the IDTR */
	idtr.base = 0;  
	idtr.base +=(dword) &idt;
	idtr.limit = sizeof(idt)-1;
	
	_lidt (&idtr);	
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!