3
#define wakesym(sym) (sym - wakeup_start)
13
movw %ax, %ss # A stack required for BIOS call
14
movw $wakesym(early_stack), %sp
16
pushl $0 # Kill dangerous flag early
20
movl wakesym(real_magic), %eax
21
cmpl $0x12345678, %eax
24
# for acpi_sleep=s3_bios
25
testl $1, wakesym(video_flags)
28
movw %cs, %ax # In case messed by BIOS
30
movw %ax, %ss # Need this? How to ret if clobbered?
32
1: # for acpi_sleep=s3_mode
33
testl $2, wakesym(video_flags)
35
movl wakesym(video_mode), %eax
38
1: # Show some progress if VGA is resumed
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
48
lidt %fs:bootsym(idt_48)
49
lgdt %fs:bootsym(gdt_48)
52
lmsw %ax # Turn on CR0.PE
53
ljmpl $BOOT_CS32, $bootsym_phys(wakeup_32)
55
/* This code uses an extended set of video mode numbers. These include:
56
* Aliases for standard modes
60
* Video modes numbered by menu position -- NOT RECOMMENDED because of lack
61
* of compatibility when extending the table. These are between 0x00 and 0xff.
63
#define VIDEO_FIRST_MENU 0x0000
65
/* Standard BIOS video modes (BIOS number + 0x0100) */
66
#define VIDEO_FIRST_BIOS 0x0100
68
/* VESA BIOS video modes (VESA number + 0x0200) */
69
#define VIDEO_FIRST_VESA 0x0200
71
/* Video7 special modes (BIOS number + 0x0900) */
72
#define VIDEO_FIRST_V7 0x0900
74
# Setting of user mode (AX=mode ID) => CF=success
77
cmpb $VIDEO_FIRST_VESA>>8, %ah
85
subb $VIDEO_FIRST_VESA>>8, %bh
86
orw $0x4000, %bx # Use linear frame buffer
87
movw $0x4f02, %ax # VESA BIOS mode set call
89
cmpw $0x004f, %ax # AL=4f if implemented
90
jnz _setbadw # AH=0 if OK
98
movw $0x0e00 + 'B', %fs:(0x12)
102
real_magic: .long 0x12345678
103
.globl video_mode, video_flags
109
# Now in protect mode, with paging disabled
110
# Add offset for any reference to xen specific symbols
113
/* Set up segment registers and initial stack for protected mode */
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
123
cmp $0x9abcdef0, %eax
124
jne bogus_saved_magic
128
/* Initialise CR4. */
129
mov $X86_CR4_PAE, %ecx
132
/* Load pagetable base register */
133
mov $sym_phys(idle_pg_table),%eax
134
add bootsym_phys(trampoline_xen_phys_start),%eax
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? */
144
#if CONFIG_PAGING_LEVELS == 4
145
btsl $_EFER_LME,%eax /* Long Mode */
146
btsl $_EFER_SCE,%eax /* SYSCALL/SYSRET */
148
btl $20,%edi /* No Execute? */
150
btsl $_EFER_NX,%eax /* No Execute */
156
/* Enable paging and flush prefetch queue */
157
mov $0x80050033,%eax /* hi-to-lo: PG,AM,WP,NE,ET,MP,PE */
162
#if defined(__x86_64__)
164
/* Now in compatibility mode. Long-jump to 64-bit mode */
165
ljmp $BOOT_CS64, $bootsym_phys(wakeup_64)
169
/* Jump to high mappings and the higher-level wakeup code. */
170
movq ret_point(%rip), %rbx
176
#else /* !defined(__x86_64__) */
179
mov $(__HYPERVISOR_DS), %eax
182
ljmp $(__HYPERVISOR_CS), $__ret_point
187
movw $0x0e00 + 'S', 0xb8014
188
jmp bogus_saved_magic