direct-io.hg

view tools/firmware/vmxassist/head.S @ 7477:5a7baecb1c70

Fix an issue for passing arguement from control panel to deivce model
for some arguemnt like 'localtime', 'isa', device model need an argument
"-localtime", instead of "-localtime 1"
Signed-off-by: Xiaofeng Ling <xiaofeng.ling@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Sun Oct 23 16:51:47 2005 +0100 (2005-10-23)
parents 61b3b357d827
children f1b361b05bf3
line source
1 /*
2 * head.S: VMXAssist runtime start off.
3 *
4 * Leendert van Doorn, leendert@watson.ibm.com
5 * Copyright (c) 2005, International Business Machines Corporation.
6 *
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.
10 *
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
14 * more details.
15 *
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.
19 */
20 #include "vm86.h"
21 #include "machine.h"
23 /*
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.
27 */
28 #ifdef TEST
29 .byte 0x55, 0xaa
30 .byte 0x80
31 .code16
32 jmp _start16
33 #else
34 jmp _start
35 #endif
37 .align 8
38 .long VMXASSIST_MAGIC
39 .long newctx /* new context */
40 .long oldctx /* old context */
42 #ifdef TEST
43 /*
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.
46 *
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".
51 */
52 .code16
53 .globl _start16
54 _start16:
55 cli
57 /* load our own global descriptor table */
58 data32 addr32 lgdt %cs:(rom_gdtr - TEXTADDR)
60 /* go to protected mode */
61 movl %cr0, %eax
62 orl $CR0_PE, %eax
63 movl %eax, %cr0
64 data32 ljmp $0x08, $1f
66 .align 32
67 .globl rom_gdt
68 rom_gdt:
69 .word 0, 0 /* 0x00: reserved */
70 .byte 0, 0, 0, 0
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
77 rom_gdt_end:
79 .align 4
80 .globl rom_gdtr
81 rom_gdtr:
82 .word rom_gdt_end - rom_gdt - 1
83 .long rom_gdt
85 .code32
86 1:
87 /* welcome to the 32-bit world */
88 movw $0x10, %ax
89 movw %ax, %ds
90 movw %ax, %es
91 movw %ax, %ss
92 movw %ax, %fs
93 movw %ax, %gs
95 /* enable Bochs debug facilities */
96 movw $0x8A00, %dx
97 movw $0x8A00, %ax
98 outw %ax, (%dx)
100 jmp _start
101 #endif /* TEST */
103 /*
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.
107 */
108 .globl _start
109 .code32
110 _start:
111 cli
113 /* save register parameters to C land */
114 movl %edx, booting_cpu
115 movl %ebx, booting_vector
117 /* clear bss */
118 cld
119 xorb %al, %al
120 movl $_bbss, %edi
121 movl $_ebss, %ecx
122 subl %edi, %ecx
123 rep stosb
125 /* make sure we are in a sane world */
126 clts
128 /* setup my own stack */
129 movl $stack_top - 4*4, %esp
130 movl %esp, %ebp
132 /* go ... */
133 call main
134 jmp halt
136 /*
137 * Something bad happened, print invoking %eip and loop forever
138 */
139 .align 4
140 .globl halt
141 halt:
142 push $halt_msg
143 call printf
144 #ifdef TEST
145 movw $0x8A00, %dx
146 movw $0x8AE0, %ax
147 outw %ax, (%dx)
148 #endif
149 cli
150 jmp .
152 .data
153 halt_msg:
154 .asciz "Halt called from %%eip 0x%x\n"
157 /*
158 * Our stack
159 */
160 .bss
161 .align 8
162 .globl stack, stack_top
163 stack:
164 .skip STACK_SIZE
165 stack_top: