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"
53 /* 16bit protected mode code here */
62 movl %eax, saved_protected_mode_esp
73 movl %cr0, %eax /* Go back into real mode by */
74 andl $0x7ffffffe, %eax /* clearing PE to 0 */
76 ljmp $0x0,$do_realmode /* switch to real mode */
78 do_realmode: /* realmode code from here */
85 /* create a temporary stack */
108 popl %eax /* orig_eax */
117 cs movl temp_eax, %eax
118 wbinvd /* self-modifying code,
119 * better flush the cache */
121 .byte 0x9a /* lcall */
127 /* save eax, esp and ss */
128 cs movl %eax, saved_eax
130 cs movl %eax, saved_esp
132 cs movw %ax, saved_ss
134 /* restore the stack, note that we set sp to 0x244;
135 * pt_regs is 0x44 bytes long and we push the structure
136 * backwards on to the stack, bottom first */
144 cs movw saved_ss, %ax
146 cs movl saved_esp, %eax
172 o32 cs lidt saved_idt
173 o32 cs lgdt saved_gdt /* Set GDTR */
175 movl %cr0, %eax /* Go back into protected mode */
176 orl $1,%eax /* reset PE to 1 */
178 jmp next_line /* flush prefetch queue */
180 movw $return_ptr, %ax
186 movl $0x18,%eax /* reload GDT[3] */
187 movw %ax,%fs /* reset FS */
188 movw %ax,%ds /* reset DS */
189 movw %ax,%gs /* reset GS */
190 movw %ax,%es /* reset ES */
191 movw %ax,%ss /* reset SS */
192 movl saved_protected_mode_esp, %eax
217 saved_protected_mode_esp: