~ubuntu-branches/ubuntu/utopic/xen/utopic

« back to all changes in this revision

Viewing changes to xen/arch/x86/boot/wakeup.S

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2010-05-06 15:47:38 UTC
  • mto: (1.3.1) (15.1.1 sid) (4.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20100506154738-agoz0rlafrh1fnq7
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
        .code16
 
2
 
 
3
#define wakesym(sym) (sym - wakeup_start)
 
4
 
 
5
        .align 16
 
6
ENTRY(wakeup_start)
 
7
        cli
 
8
        cld
 
9
 
 
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
 
15
 
 
16
        pushl   $0              # Kill dangerous flag early
 
17
        popfl
 
18
 
 
19
        # check magic number
 
20
        movl    wakesym(real_magic), %eax
 
21
        cmpl    $0x12345678, %eax
 
22
        jne     bogus_real_magic
 
23
 
 
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?
 
31
 
 
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
 
37
 
 
38
1:      # Show some progress if VGA is resumed
 
39
        movw    $0xb800, %ax
 
40
        movw    %ax, %fs
 
41
        movw    $0x0e00 + 'L', %fs:(0x10)
 
42
 
 
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)
 
50
 
 
51
        movw    $1, %ax
 
52
        lmsw    %ax             # Turn on CR0.PE 
 
53
        ljmpl   $BOOT_CS32, $bootsym_phys(wakeup_32)
 
54
 
 
55
/* This code uses an extended set of video mode numbers. These include:
 
56
 * Aliases for standard modes
 
57
 *      NORMAL_VGA (-1)
 
58
 *      EXTENDED_VGA (-2)
 
59
 *      ASK_VGA (-3)
 
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.
 
62
 */
 
63
#define VIDEO_FIRST_MENU 0x0000
 
64
 
 
65
/* Standard BIOS video modes (BIOS number + 0x0100) */
 
66
#define VIDEO_FIRST_BIOS 0x0100
 
67
 
 
68
/* VESA BIOS video modes (VESA number + 0x0200) */
 
69
#define VIDEO_FIRST_VESA 0x0200
 
70
 
 
71
/* Video7 special modes (BIOS number + 0x0900) */
 
72
#define VIDEO_FIRST_V7 0x0900
 
73
 
 
74
# Setting of user mode (AX=mode ID) => CF=success
 
75
mode_setw:
 
76
        movw    %ax, %bx
 
77
        cmpb    $VIDEO_FIRST_VESA>>8, %ah
 
78
        jnc     check_vesaw
 
79
        decb    %ah
 
80
 
 
81
setbadw: clc
 
82
        ret
 
83
 
 
84
check_vesaw:
 
85
        subb    $VIDEO_FIRST_VESA>>8, %bh
 
86
        orw     $0x4000, %bx                    # Use linear frame buffer
 
87
        movw    $0x4f02, %ax                    # VESA BIOS mode set call
 
88
        int     $0x10
 
89
        cmpw    $0x004f, %ax                    # AL=4f if implemented
 
90
        jnz     _setbadw                        # AH=0 if OK
 
91
 
 
92
        stc
 
93
        ret
 
94
 
 
95
_setbadw: jmp    setbadw
 
96
 
 
97
bogus_real_magic:
 
98
        movw    $0x0e00 + 'B', %fs:(0x12)
 
99
        jmp     bogus_real_magic
 
100
 
 
101
        .align 4
 
102
real_magic:     .long 0x12345678
 
103
         .globl video_mode, video_flags
 
104
video_mode:     .long 0
 
105
video_flags:    .long 0
 
106
 
 
107
        .code32
 
108
 
 
109
        # Now in protect mode, with paging disabled
 
110
        # Add offset for any reference to xen specific symbols
 
111
 
 
112
wakeup_32:
 
113
        /* Set up segment registers and initial stack for protected mode */
 
114
        mov     $BOOT_DS, %eax
 
115
        mov     %eax, %ds
 
116
        mov     %eax, %ss
 
117
        mov     $bootsym_phys(early_stack), %esp
 
118
 
 
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
 
125
        
 
126
        /* fpu init? */
 
127
 
 
128
        /* Initialise CR4. */
 
129
        mov     $X86_CR4_PAE, %ecx
 
130
        mov     %ecx, %cr4
 
131
 
 
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
 
136
 
 
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:
 
153
 
 
154
        wbinvd
 
155
 
 
156
        /* Enable paging and flush prefetch queue */
 
157
        mov     $0x80050033,%eax /* hi-to-lo: PG,AM,WP,NE,ET,MP,PE */
 
158
        mov     %eax,%cr0
 
159
        jmp     1f
 
160
1:
 
161
 
 
162
#if defined(__x86_64__)
 
163
 
 
164
        /* Now in compatibility mode. Long-jump to 64-bit mode */
 
165
        ljmp    $BOOT_CS64, $bootsym_phys(wakeup_64)
 
166
 
 
167
        .code64
 
168
wakeup_64:
 
169
        /* Jump to high mappings and the higher-level wakeup code. */
 
170
        movq    ret_point(%rip), %rbx
 
171
        jmp     *%rbx
 
172
 
 
173
ret_point:
 
174
        .quad   __ret_point
 
175
 
 
176
#else /* !defined(__x86_64__) */
 
177
 
 
178
        lgdt    gdt_descr
 
179
        mov     $(__HYPERVISOR_DS), %eax
 
180
        mov     %eax, %ds
 
181
 
 
182
        ljmp    $(__HYPERVISOR_CS), $__ret_point
 
183
 
 
184
#endif
 
185
 
 
186
bogus_saved_magic:
 
187
        movw    $0x0e00 + 'S', 0xb8014
 
188
        jmp     bogus_saved_magic