From owner-freebsd-hackers Thu Dec 6 9:25:13 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from mail6.speakeasy.net (mail6.speakeasy.net [216.254.0.206]) by hub.freebsd.org (Postfix) with ESMTP id 3557937B41C for ; Thu, 6 Dec 2001 09:25:03 -0800 (PST) Received: (qmail 20585 invoked from network); 6 Dec 2001 17:25:02 -0000 Received: from unknown (HELO laptop.baldwin.cx) ([64.81.54.73]) (envelope-sender ) by mail6.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 6 Dec 2001 17:25:02 -0000 Message-ID: X-Mailer: XFMail 1.4.0 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <3972603197.20011206170402@agava.com> Date: Thu, 06 Dec 2001 09:24:58 -0800 (PST) From: John Baldwin To: Dmitry Konyshev Subject: RE: switching to real mode Cc: freebsd-hackers@FreeBSD.ORG Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 <>< 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