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,
24 /* 32bit -> 16bit -> 32bit mode switch code */
27 * Stack frame at 0xe00
47 #define a32 .byte 0x67; /* address size prefix 32 */
48 #define o32 .byte 0x66; /* operand size prefix 32 */
50 .section .realmode, "ax"
53 /* 16bit protected mode code here */
62 movl %eax, saved_protected_mode_esp
73 /* Go back into real mode by clearing PE to 0 */
75 andl $0x7ffffffe, %eax
78 /* switch to real mode */
79 ljmp $0x0,$do_realmode
82 /* realmode code from here */
89 /* create a temporary stack */
111 popl %eax /* orig_eax */
120 cs movl temp_eax, %eax
122 /* self-modifying code, better flush the cache */
125 .byte 0x9a /* lcall */
132 /* save eax, esp and ss */
133 cs movl %eax, saved_eax
135 cs movl %eax, saved_esp
137 cs movw %ax, saved_ss
140 * restore the stack, note that we set sp to 0x244;
141 * pt_regs is 0x44 bytes long and we push the structure
142 * backwards on to the stack, bottom first
150 cs movw saved_ss, %ax
152 cs movl saved_esp, %eax
178 o32 cs lidt saved_idt
179 o32 cs lgdt saved_gdt
181 /* Go back into protected mode reset PE to 1 */
186 /* flush prefetch queue */
189 movw $return_ptr, %ax
195 /* Reload segment registers */
202 movl saved_protected_mode_esp, %eax
227 saved_protected_mode_esp: