direct-io.hg

view tools/firmware/vmxassist/trap.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 999293916aa7
children 60071beccf18
line source
1 /*
2 * trap.S: Trap and world switch handlers
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 "machine.h"
21 #include "offsets.h"
23 /*
24 * All processor exception/faults/interrupts end up here.
25 *
26 * On an exception/fault, the processor pushes CS:EIP, SS, ESP and an
27 * optional error code onto the stack. The common_trap routine
28 * below saves the processor context and transfers control to trap()
29 * whose job it is to virtualize and pass on the trap.
30 */
31 .macro TRAP_HANDLER trapno error
32 .text
33 .align 16
34 1: .if \error == 0
35 pushl $0 /* dummy error code */
36 .endif
37 pushl $\trapno
38 jmp common_trap
39 .section .rodata
40 .long 1b
41 .text
42 .endm
44 .section .rodata
45 .code32
46 .align 4
47 .global trap_handlers
48 trap_handlers:
49 TRAP_HANDLER 0, 0 /* divide error */
50 TRAP_HANDLER 1, 0 /* debug */
51 TRAP_HANDLER 2, 0 /* NMI interrupt */
52 TRAP_HANDLER 3, 0 /* breakpoint */
53 TRAP_HANDLER 4, 0 /* overflow */
54 TRAP_HANDLER 5, 0 /* BOUND range exceeded */
55 TRAP_HANDLER 6, 0 /* invalid opcode */
56 TRAP_HANDLER 7, 0 /* device not available */
57 TRAP_HANDLER 8, 1 /* double fault */
58 TRAP_HANDLER 9, 0 /* coprocessor segment overrun */
59 TRAP_HANDLER 10, 1 /* invalid TSS */
60 TRAP_HANDLER 11, 1 /* segment not present */
61 TRAP_HANDLER 12, 1 /* stack-segment fault */
62 TRAP_HANDLER 13, 1 /* general protection */
63 TRAP_HANDLER 14, 1 /* page fault */
64 TRAP_HANDLER 15, 0 /* reserved */
65 TRAP_HANDLER 16, 0 /* FPU floating-point error */
66 TRAP_HANDLER 17, 1 /* alignment check */
67 TRAP_HANDLER 18, 0 /* machine check */
68 TRAP_HANDLER 19, 0 /* SIMD floating-point error */
69 TRAP_HANDLER 20, 0 /* reserved */
70 TRAP_HANDLER 21, 0 /* reserved */
71 TRAP_HANDLER 22, 0 /* reserved */
72 TRAP_HANDLER 23, 0 /* reserved */
73 TRAP_HANDLER 24, 0 /* reserved */
74 TRAP_HANDLER 25, 0 /* reserved */
75 TRAP_HANDLER 26, 0 /* reserved */
76 TRAP_HANDLER 27, 0 /* reserved */
77 TRAP_HANDLER 28, 0 /* reserved */
78 TRAP_HANDLER 29, 0 /* reserved */
79 TRAP_HANDLER 30, 0 /* reserved */
80 TRAP_HANDLER 31, 0 /* reserved */
81 TRAP_HANDLER 32, 0 /* irq 0 */
82 TRAP_HANDLER 33, 0 /* irq 1 */
83 TRAP_HANDLER 34, 0 /* irq 2 */
84 TRAP_HANDLER 35, 0 /* irq 3 */
85 TRAP_HANDLER 36, 0 /* irq 4 */
86 TRAP_HANDLER 37, 0 /* irq 5 */
87 TRAP_HANDLER 38, 0 /* irq 6 */
88 TRAP_HANDLER 39, 0 /* irq 7 */
89 TRAP_HANDLER 40, 0 /* irq 8 */
90 TRAP_HANDLER 41, 0 /* irq 9 */
91 TRAP_HANDLER 42, 0 /* irq 10 */
92 TRAP_HANDLER 43, 0 /* irq 11 */
93 TRAP_HANDLER 44, 0 /* irq 12 */
94 TRAP_HANDLER 45, 0 /* irq 13 */
95 TRAP_HANDLER 46, 0 /* irq 14 */
96 TRAP_HANDLER 47, 0 /* irq 15 */
98 .text
99 .code32
100 .align 16
101 common_trap: /* common trap handler */
102 pushl %gs
103 pushl %fs
104 pushl %ds
105 pushl %es
106 pushal
108 movl $DATA_SELECTOR, %eax /* make sure these are sane */
109 movl %eax, %ds
110 movl %eax, %es
111 movl %eax, %fs
112 movl %eax, %gs
113 movl %esp, %ebp
115 pushl %ebp
116 pushl 52(%ebp)
117 pushl 48(%ebp)
118 call trap /* trap(trapno, errno, regs) */
119 addl $12, %esp
121 trap_return:
122 popal
123 popl %es
124 popl %ds
125 popl %fs
126 popl %gs
127 addl $8, %esp /* skip trapno, errno */
128 iret
129 /* NOT REACHED */
132 /*
133 * A world switch to real mode occured. The hypervisor saved the
134 * executing context into "oldctx" and instantiated "newctx", which
135 * gets us here. Here we push a stack frame that is compatible with
136 * a trap frame (see above) so that we can handle this event as a
137 * regular trap.
138 */
139 .text
140 .align 16
141 .globl switch_to_real_mode
142 switch_to_real_mode:
143 pushl oldctx+VMX_ASSIST_CTX_GS_SEL /* 16 to 32-bit transition */
144 pushl oldctx+VMX_ASSIST_CTX_FS_SEL
145 pushl oldctx+VMX_ASSIST_CTX_DS_SEL
146 pushl oldctx+VMX_ASSIST_CTX_ES_SEL
147 pushl oldctx+VMX_ASSIST_CTX_SS_SEL
148 pushl oldctx+VMX_ASSIST_CTX_ESP
149 pushl oldctx+VMX_ASSIST_CTX_EFLAGS
150 pushl oldctx+VMX_ASSIST_CTX_CS_SEL
151 pushl oldctx+VMX_ASSIST_CTX_EIP
152 pushl $-1 /* trapno, errno */
153 pushl $-1
154 pushl %gs
155 pushl %fs
156 pushl %ds
157 pushl %es
158 pushal
160 movl %esp, %ebp
161 pushl %ebp
162 call enter_real_mode
163 addl $4, %esp
165 jmp trap_return
166 /* NOT REACHED */
169 /*
170 * Switch to protected mode. At this point all the registers have
171 * been reloaded by trap_return and all we have to do is cause a
172 * world switch by turning on CR0.PE.
173 */
174 .text
175 .align 16
176 .globl switch_to_protected_mode
177 switch_to_protected_mode:
178 movl oldctx+VMX_ASSIST_CTX_CR0, %esp
179 movl %esp, %cr0 /* actual world switch ! */
181 /* NOT REACHED */
182 pushl $switch_failed
183 call panic
184 jmp .
186 .data
187 .align 4
188 switch_failed:
189 .asciz "World switch to protected mode failed\n"