debuggers.hg

view xen/arch/x86/boot/wakeup.S @ 0:7d21f7218375

Exact replica of unstable on 051908 + README-this
author Mukesh Rathor
date Mon May 19 15:34:57 2008 -0700 (2008-05-19)
parents
children f875aaa791f0
line source
1 .code16
3 #define wakesym(sym) (sym - wakeup_start)
5 .align 16
6 ENTRY(wakeup_start)
7 cli
8 cld
10 # setup data segment
11 movw %cs, %ax
12 movw %ax, %ds
13 movw %ax, %ss # A stack required for BIOS call
14 movw $wakesym(early_stack), %sp
16 pushl $0 # Kill dangerous flag early
17 popfl
19 # check magic number
20 movl wakesym(real_magic), %eax
21 cmpl $0x12345678, %eax
22 jne bogus_real_magic
24 # for acpi_sleep=s3_bios
25 testl $1, wakesym(video_flags)
26 jz 1f
27 lcall $0xc000, $3
28 movw %cs, %ax # In case messed by BIOS
29 movw %ax, %ds
30 movw %ax, %ss # Need this? How to ret if clobbered?
32 1: # for acpi_sleep=s3_mode
33 testl $2, wakesym(video_flags)
34 jz 1f
35 movl wakesym(video_mode), %eax
36 call mode_setw
38 1: # Show some progress if VGA is resumed
39 movw $0xb800, %ax
40 movw %ax, %fs
41 movw $0x0e00 + 'L', %fs:(0x10)
43 # boot trampoline is under 1M, and shift its start into
44 # %fs to reference symbols in that area
45 movl $BOOT_TRAMPOLINE, %eax
46 shrl $4, %eax
47 movl %eax, %fs
48 lidt %fs:bootsym(idt_48)
49 lgdt %fs:bootsym(gdt_48)
51 movw $1, %ax
52 lmsw %ax # Turn on CR0.PE
53 jmp 1f
54 1: ljmpl $BOOT_CS32, $bootsym_phys(wakeup_32)
56 /* This code uses an extended set of video mode numbers. These include:
57 * Aliases for standard modes
58 * NORMAL_VGA (-1)
59 * EXTENDED_VGA (-2)
60 * ASK_VGA (-3)
61 * Video modes numbered by menu position -- NOT RECOMMENDED because of lack
62 * of compatibility when extending the table. These are between 0x00 and 0xff.
63 */
64 #define VIDEO_FIRST_MENU 0x0000
66 /* Standard BIOS video modes (BIOS number + 0x0100) */
67 #define VIDEO_FIRST_BIOS 0x0100
69 /* VESA BIOS video modes (VESA number + 0x0200) */
70 #define VIDEO_FIRST_VESA 0x0200
72 /* Video7 special modes (BIOS number + 0x0900) */
73 #define VIDEO_FIRST_V7 0x0900
75 # Setting of user mode (AX=mode ID) => CF=success
76 mode_setw:
77 movw %ax, %bx
78 cmpb $VIDEO_FIRST_VESA>>8, %ah
79 jnc check_vesaw
80 decb %ah
82 setbadw: clc
83 ret
85 check_vesaw:
86 subb $VIDEO_FIRST_VESA>>8, %bh
87 orw $0x4000, %bx # Use linear frame buffer
88 movw $0x4f02, %ax # VESA BIOS mode set call
89 int $0x10
90 cmpw $0x004f, %ax # AL=4f if implemented
91 jnz _setbadw # AH=0 if OK
93 stc
94 ret
96 _setbadw: jmp setbadw
98 bogus_real_magic:
99 movw $0x0e00 + 'B', %fs:(0x12)
100 jmp bogus_real_magic
102 .align 4
103 real_magic: .long 0x12345678
104 .globl video_mode, video_flags
105 video_mode: .long 0
106 video_flags: .long 0
108 .code32
110 # Now in protect mode, with paging disabled
111 # Add offset for any reference to xen specific symbols
113 wakeup_32:
114 mov $BOOT_DS, %eax
115 mov %eax, %ds
116 mov %eax, %ss
117 mov $bootsym_phys(early_stack), %esp
119 # check saved magic again
120 mov $sym_phys(saved_magic), %eax
121 add bootsym_phys(trampoline_xen_phys_start), %eax
122 mov (%eax), %eax
123 cmp $0x9abcdef0, %eax
124 jne bogus_saved_magic
126 /* fpu init? */
128 /* Initialise CR4. */
129 mov $X86_CR4_PAE, %ecx
130 mov %ecx, %cr4
132 /* Load pagetable base register */
133 mov $sym_phys(idle_pg_table),%eax
134 add bootsym_phys(trampoline_xen_phys_start),%eax
135 mov %eax,%cr3
137 /* Will cpuid feature change after resume? */
138 /* Set up EFER (Extended Feature Enable Register). */
139 mov bootsym_phys(cpuid_ext_features),%edi
140 test $0x20100800,%edi /* SYSCALL/SYSRET, No Execute, Long Mode? */
141 jz .Lskip_eferw
142 movl $MSR_EFER,%ecx
143 rdmsr
144 #if CONFIG_PAGING_LEVELS == 4
145 btsl $_EFER_LME,%eax /* Long Mode */
146 btsl $_EFER_SCE,%eax /* SYSCALL/SYSRET */
147 #endif
148 btl $20,%edi /* No Execute? */
149 jnc 1f
150 btsl $_EFER_NX,%eax /* No Execute */
151 1: wrmsr
152 .Lskip_eferw:
154 wbinvd
156 mov $0x80050033,%eax /* hi-to-lo: PG,AM,WP,NE,ET,MP,PE */
157 mov %eax,%cr0
158 jmp 1f
159 1:
161 #if defined(__x86_64__)
163 /* Now in compatibility mode. Long-jump to 64-bit mode */
164 ljmp $BOOT_CS64, $bootsym_phys(wakeup_64)
166 .code64
167 .align 8
168 .word 0,0,0
169 lgdt_descr:
170 .word LAST_RESERVED_GDT_BYTE
171 .quad gdt_table - FIRST_RESERVED_GDT_BYTE
173 wakeup_64:
174 lgdt lgdt_descr(%rip)
175 mov $(__HYPERVISOR_DS64), %eax
176 mov %eax, %ds
178 # long jump to return point, with cs reload
179 rex64 ljmp *ret_point(%rip)
181 .align 8
182 ret_point:
183 .quad __ret_point
184 .word __HYPERVISOR_CS64
186 #else /* !defined(__x86_64__) */
187 lgdt gdt_descr
188 mov $(__HYPERVISOR_DS), %eax
189 mov %eax, %ds
191 ljmp $(__HYPERVISOR_CS), $__ret_point
192 #endif
194 bogus_saved_magic:
195 movw $0x0e00 + 'S', 0xb8014
196 jmp bogus_saved_magic