ia64/xen-unstable

view extras/mini-os/x86_64.S @ 7238:971e7c7411b3

Raise an exception if an error appears on the pipes to our children, and make
sure that the child's pipes are closed even under that exception. Move the
handling of POLLHUP to the end of the loop, so that we guarantee to read any
remaining data from the child if POLLHUP and POLLIN appear at the same time.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@ewan
date Thu Oct 06 10:13:11 2005 +0100 (2005-10-06)
parents a6914c2c15cf
children 323d40eefbce
line source
1 #include <os.h>
3 .section __xen_guest
4 .asciz "XEN_VER=3.0,LOADER=generic,PT_MODE_WRITABLE"
5 .text
7 #define ENTRY(X) .globl X ; X :
8 .globl _start, shared_info
10 #define SAVE_ALL \
11 cld; \
12 pushq %rdi; \
13 pushq %rsi; \
14 pushq %rdx; \
15 pushq %rcx; \
16 pushq %rax; \
17 pushq %r8; \
18 pushq %r9; \
19 pushq %r10; \
20 pushq %r11; \
21 pushq %rbx; \
22 pushq %rbp; \
23 pushq %r12; \
24 pushq %r13; \
25 pushq %r14; \
26 pushq %r15;
28 #define RESTORE_ALL \
29 popq %r15; \
30 popq %r14; \
31 popq %r13; \
32 popq %r12; \
33 popq %rbp; \
34 popq %rbx; \
35 popq %r11; \
36 popq %r10; \
37 popq %r9; \
38 popq %r8; \
39 popq %rax; \
40 popq %rcx; \
41 popq %rdx; \
42 popq %rsi; \
43 popq %rdi
45 _start:
46 cld
47 movq stack_start(%rip),%rsp
48 movq %rsi,%rdi
49 call start_kernel
51 stack_start:
52 .quad stack+8192
54 /* Unpleasant -- the PTE that maps this page is actually overwritten */
55 /* to map the real shared-info page! :-) */
56 .org 0x1000
57 shared_info:
58 .org 0x2000
60 ENTRY(hypervisor_callback)
61 popq %rcx
62 popq %r11
63 iretq
65 ENTRY(failsafe_callback)
66 popq %rcx
67 popq %r11
68 iretq
70 error_code:
71 SAVE_ALL
72 movq %rsp,%rdi
73 movl 15*8+4(%rsp),%eax
74 leaq exception_table(%rip),%rdx
75 callq *(%rdx,%rax,8)
76 RESTORE_ALL
77 addq $8,%rsp
78 iretq
80 ENTRY(divide_error)
81 popq %rcx
82 popq %r11
83 pushq $0
84 movl $TRAP_divide_error,4(%rsp)
85 jmp error_code
87 ENTRY(coprocessor_error)
88 popq %rcx
89 popq %r11
90 pushq $0
91 movl $TRAP_copro_error,4(%rsp)
92 jmp error_code
94 ENTRY(simd_coprocessor_error)
95 popq %rcx
96 popq %r11
97 pushq $0
98 movl $TRAP_simd_error,4(%rsp)
99 jmp error_code
101 ENTRY(device_not_available)
102 popq %rcx
103 popq %r11
104 movl $TRAP_no_device,4(%rsp)
105 jmp error_code
107 ENTRY(debug)
108 popq %rcx
109 popq %r11
110 pushq $0
111 movl $TRAP_debug,4(%rsp)
112 jmp error_code
114 ENTRY(int3)
115 popq %rcx
116 popq %r11
117 pushq $0
118 movl $TRAP_int3,4(%rsp)
119 jmp error_code
121 ENTRY(overflow)
122 popq %rcx
123 popq %r11
124 pushq $0
125 movl $TRAP_overflow,4(%rsp)
126 jmp error_code
128 ENTRY(bounds)
129 popq %rcx
130 popq %r11
131 pushq $0
132 movl $TRAP_bounds,4(%rsp)
133 jmp error_code
135 ENTRY(invalid_op)
136 popq %rcx
137 popq %r11
138 pushq $0
139 movl $TRAP_invalid_op,4(%rsp)
140 jmp error_code
142 ENTRY(coprocessor_segment_overrun)
143 popq %rcx
144 popq %r11
145 pushq $0
146 movl $TRAP_copro_seg,4(%rsp)
147 jmp error_code
149 ENTRY(invalid_TSS)
150 popq %rcx
151 popq %r11
152 movl $TRAP_invalid_tss,4(%rsp)
153 jmp error_code
155 ENTRY(segment_not_present)
156 popq %rcx
157 popq %r11
158 movl $TRAP_no_segment,4(%rsp)
159 jmp error_code
161 ENTRY(stack_segment)
162 popq %rcx
163 popq %r11
164 movl $TRAP_stack_error,4(%rsp)
165 jmp error_code
167 ENTRY(general_protection)
168 popq %rcx
169 popq %r11
170 movl $TRAP_gp_fault,4(%rsp)
171 jmp error_code
173 ENTRY(alignment_check)
174 popq %rcx
175 popq %r11
176 movl $TRAP_alignment_check,4(%rsp)
177 jmp error_code
179 ENTRY(virt_cr2)
180 .quad 0
181 ENTRY(page_fault)
182 popq %rcx
183 popq %r11
184 popq virt_cr2(%rip)
185 movl $TRAP_page_fault,4(%rsp)
186 jmp error_code
188 ENTRY(machine_check)
189 popq %rcx
190 popq %r11
191 pushq $0
192 movl $TRAP_machine_check,4(%rsp)
193 jmp error_code
195 ENTRY(spurious_interrupt_bug)
196 popq %rcx
197 popq %r11
198 pushq $0
199 movl $TRAP_spurious_int,4(%rsp)
200 jmp error_code
202 ENTRY(exception_table)
203 .quad do_divide_error
204 .quad do_debug
205 .quad 0 # nmi
206 .quad do_int3
207 .quad do_overflow
208 .quad do_bounds
209 .quad do_invalid_op
210 .quad 0
211 .quad 0
212 .quad do_coprocessor_segment_overrun
213 .quad do_invalid_TSS
214 .quad do_segment_not_present
215 .quad do_stack_segment
216 .quad do_general_protection
217 .quad do_page_fault
218 .quad do_spurious_interrupt_bug
219 .quad do_coprocessor_error
220 .quad do_alignment_check
221 .quad do_machine_check
222 .quad do_simd_coprocessor_error