2 * head.S: VMXAssist runtime start off.
4 * Leendert van Doorn, leendert@watson.ibm.com
5 * Copyright (c) 2005, International Business Machines Corporation.
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * You should have received a copy of the GNU General Public License along with
17 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
18 * Place - Suite 330, Boston, MA 02111-1307 USA.
24 * When a partition tries to mask off the CR0_PE bit a world
25 * switch happens to the environment below. The magic indicates
26 * that this is a valid context.
39 .long newctx /* new context */
40 .long oldctx /* old context */
44 * We are running in 16-bit. Get into the protected mode as soon as
45 * possible. We use our own (minimal) GDT to get started.
47 * ROM is a misnomer as this code isn't really rommable (although it
48 * only requires a few changes) but it does live in a BIOS ROM segment.
49 * This code allows me to debug vmxassists under (a modified version of)
50 * Bochs and load it as a "optromimage1".
57 /* load our own global descriptor table */
58 data32 addr32 lgdt %cs:(rom_gdtr - TEXTADDR)
60 /* go to protected mode */
64 data32 ljmp $0x08, $1f
69 .word 0, 0 /* 0x00: reserved */
72 .word 0xFFFF, 0 /* 0x08: CS 32-bit */
73 .byte 0, 0x9A, 0xCF, 0
75 .word 0xFFFF, 0 /* 0x10: CS 32-bit */
76 .byte 0, 0x92, 0xCF, 0
82 .word rom_gdt_end - rom_gdt - 1
87 /* welcome to the 32-bit world */
95 /* enable Bochs debug facilities */
104 * This is the real start. Control was transfered to this point
105 * with CR0_PE set and executing in some 32-bit segment. We call
106 * main and setup our own environment.
113 /* save register parameters to C land */
126 movl %edx, booting_cpu
127 movl %ebx, booting_vector
129 /* make sure we are in a sane world */
132 /* setup my own stack */
133 movl $stack_top - 4*4, %esp
141 * Something bad happened, print invoking %eip and loop forever
158 .asciz "Halt called from %%eip 0x%x\n"
166 .globl stack, stack_top