[Prev][Next][Index][Thread]

Re: switching to real mode



On Tue, Dec 21, 1999 at 08:44:04AM +0100, Klaus Espenlaub wrote:

> a macro do_16bit() in oskit/x86/i16.h which does that.  An example for its
> use is in kern/x86/pc/i16/raw_real_int.c.  This is used in the oskit boot
> loaders to call 16 bit software interrupts (like BIOS functions).  If you
> never want to return to protected mode again, then you can use the other

  Ok, I tried a simple test of this, based on the code in raw_real_int.c, but
I get a ton of link-time error messages. Right now I'm linking to 0x3000000
(like OSKit's netboot does) so I can use GDB. I relocate the 16bit boot code
from 0x300000 to 0x7c00. (where an NBP image is supposed to go)

    do_16bit(KERNEL_CS, KERNEL_16_CS,
             i16_raw_switch_to_real_mode();
             _prnchr('#');			// a 16bit output routine
             i16_raw_switch_to_pmode();
        );

> Now a few words about the "at least in theory" above: all of the switching
> code assumes that EIP < 65536 and ESP < 65536.  This basically means that
> you are restricted to 64K.  This is not entirely true, as only the stack,
> the switching code and all the 16 bit code needs to be below that line.
> This can be achieved  by using the right order of object files when linking.

  So I assume this means I need to link to an address below 65536, even though
that's where the 16 bit code is executed ?

main.o: In function `main':
/home/rob/projbase/gnu/nilo/main.c:766: relocation truncated to fit: R_386_PC16 i16_raw_switch_to_real_mode
/home/rob/projbase/gnu/nilo/main.c:767: relocation truncated to fit: R_386_PC16 i16_real_int
/home/rob/projbase/gnu/nilo/main.c:769: relocation truncated to fit: R_386_16 text
/usr/local/lib/liboskit_kern.a(i16_raw.o): In function `raw_atexit':
i16_raw.o(.text+0x10): relocation truncated to fit: R_386_PC16 i16_exit
/usr/local/lib/liboskit_kern.a(i16_raw.o): In function `i16_raw_switch_to_pmode':
i16_raw.o(.text+0x7f): relocation truncated to fit: R_386_16 text
/usr/local/lib/liboskit_kern.a(i16_raw.o): In function `i16_raw_switch_to_real_mode':

	etc...

	- rob -

References: