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,
25 /* 32bit -> 16bit -> 32bit mode switch code */
28 * Stack frame at 0xe00
48 #define a32 .byte 0x67; /* address size prefix 32 */
49 #define o32 .byte 0x66; /* operand size prefix 32 */
51 .section .realmode, "ax"
54 /* 16bit protected mode code here */
63 movl %eax, saved_protected_mode_esp
74 movl %cr0, %eax /* Go back into real mode by */
75 andl $0x7ffffffe, %eax /* clearing PE to 0 */
77 ljmp $0x0,$do_realmode /* switch to real mode */
79 do_realmode: /* realmode code from here */
86 /* create a temporary stack */
109 popl %eax /* orig_eax */
118 cs movl temp_eax, %eax
119 wbinvd /* self-modifying code,
120 * better flush the cache */
122 .byte 0x9a /* lcall */
128 /* save eax, esp and ss */
129 cs movl %eax, saved_eax
131 cs movl %eax, saved_esp
133 cs movw %ax, saved_ss
135 /* restore the stack, note that we set sp to 0x244;
136 * pt_regs is 0x44 bytes long and we push the structure
137 * backwards on to the stack, bottom first */
145 cs movw saved_ss, %ax
147 cs movl saved_esp, %eax
173 o32 cs lidt saved_idt
174 o32 cs lgdt saved_gdt /* Set GDTR */
176 movl %cr0, %eax /* Go back into protected mode */
177 orl $1,%eax /* reset PE to 1 */
179 jmp next_line /* flush prefetch queue */
181 movw $return_ptr, %ax
187 movl $0x18,%eax /* reload GDT[3] */
188 movw %ax,%fs /* reset FS */
189 movw %ax,%ds /* reset DS */
190 movw %ax,%gs /* reset GS */
191 movw %ax,%es /* reset ES */
192 movw %ax,%ss /* reset SS */
193 movl saved_protected_mode_esp, %eax
218 saved_protected_mode_esp: