3 * Daniel Engström, Omicron Ceti AB, daniel@omicron.se
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
26 #include <asm/ptrace.h>
27 #include <asm/realmode.h>
30 #define REALMODE_BASE ((char*)0x7c0)
31 #define REALMODE_MAILBOX ((char*)0xe00)
34 extern ulong _i386boot_realmode;
35 extern ulong _i386boot_realmode_size;
36 extern char realmode_enter;
38 int realmode_setup(void)
40 ulong i386boot_realmode = (ulong)&_i386boot_realmode;
41 ulong i386boot_realmode_size = (ulong)&_i386boot_realmode_size;
43 /* copy the realmode switch code */
44 if (i386boot_realmode_size > (REALMODE_MAILBOX-REALMODE_BASE)) {
45 printf("realmode switch too large (%ld bytes, max is %d)\n",
46 i386boot_realmode_size, (REALMODE_MAILBOX-REALMODE_BASE));
50 memcpy(REALMODE_BASE, (void*)i386boot_realmode, i386boot_realmode_size);
56 int enter_realmode(u16 seg, u16 off, struct pt_regs *in, struct pt_regs *out)
59 /* setup out thin bios emulation */
64 if (realmode_setup()) {
70 if (3>(in->esp & 0xffff)) {
71 printf("Warning: entering realmode with sp < 4 will fail\n");
74 memcpy(REALMODE_MAILBOX, in, sizeof(struct pt_regs));
78 "lcall $0x20,%0\n" : : "i" (&realmode_enter) );
81 memcpy(out, REALMODE_MAILBOX, sizeof(struct pt_regs));
87 /* This code is supposed to access a realmode interrupt
88 * it does currently not work for me */
89 int enter_realmode_int(u8 lvl, struct pt_regs *in, struct pt_regs *out)
91 /* place two instructions at 0x700 */
92 writeb(0xcd, 0x700); /* int $lvl */
94 writeb(0xcb, 0x702); /* lret */
97 enter_realmode(0x00, 0x700, in, out);