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"
52 /* 16bit protected mode code here */
61 movl %eax, saved_protected_mode_esp
72 movl %cr0, %eax /* Go back into real mode by */
73 andl $0x7ffffffe, %eax /* clearing PE to 0 */
75 ljmp $0x0,$do_realmode /* switch to real mode */
77 do_realmode: /* realmode code from here */
84 /* create a temporary stack */
107 popl %eax /* orig_eax */
116 cs movl temp_eax, %eax
117 wbinvd /* self-modifying code,
118 * better flush the cache */
120 .byte 0x9a /* lcall */
126 /* save eax, esp and ss */
127 cs movl %eax, saved_eax
129 cs movl %eax, saved_esp
131 cs movw %ax, saved_ss
133 /* restore the stack, note that we set sp to 0x244;
134 * pt_regs is 0x44 bytes long and we push the structure
135 * backwards on to the stack, bottom first */
143 cs movw saved_ss, %ax
145 cs movl saved_esp, %eax
171 o32 cs lidt saved_idt
172 o32 cs lgdt saved_gdt /* Set GDTR */
174 movl %cr0, %eax /* Go back into protected mode */
175 orl $1,%eax /* reset PE to 1 */
177 jmp next_line /* flush prefetch queue */
179 movw $return_ptr, %ax
185 movl $0x18,%eax /* reload GDT[3] */
186 movw %ax,%fs /* reset FS */
187 movw %ax,%ds /* reset DS */
188 movw %ax,%gs /* reset GS */
189 movw %ax,%es /* reset ES */
190 movw %ax,%ss /* reset SS */
191 movl saved_protected_mode_esp, %eax
216 saved_protected_mode_esp: