Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 06 Dec 2001 09:24:58 -0800 (PST)
From:      John Baldwin <jhb@FreeBSD.org>
To:        Dmitry Konyshev <daemon@agava.com>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   RE: switching to real mode
Message-ID:  <XFMail.011206092458.jhb@FreeBSD.org>
In-Reply-To: <3972603197.20011206170402@agava.com>

next in thread | previous in thread | raw e-mail | index | archive | help

On 06-Dec-01 Dmitry Konyshev wrote:
> Hello!
> 
> For some odd reason I need to load another OS (no matter which one,
> everything that known about it is its boot sector number)
> at the end of the reboot syscall. Could someone please explain how to
> switch processor to real mode and continue program execution from some
> point in low memory?
> 
> Thanks in advance.

Go get the IA32 books. :)

The short form is htat you need to hack the cpu_halt to call a function that
puts a stub down in low memory, and calls it.  This code needs to be mapped 1:1
so that the logical address == physical address.  The first thing you will
want to do is disable interrupts.  Then you will want to reset the IDT to the
defauot IDT.  Next, you will want to turn off paging.  Then you will want
to create a new GDT with USE16 selectors, load it, and switch to a 16-bit
protected mode by doing a far jump to your new %cs.  You also need to set all
your selectors to descriptors which have 64k limits.  Finally, you can clear
bit 0 of %cr0 to leave protected mode and do another far jmp to reload %cs. 
Now you are free to call the BIOS.  However, I'm not sure if the old interrupt
vector table will be completely valid if you do this, but it might be.  In any
rate, you can then take appropriate actions to start up your other OS.  

-- 

John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.011206092458.jhb>