]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Compatibility/MpServicesOnFrameworkMpServicesThunk/IA32/MpFuncs.S
ECP MpServicesOnFrameworkMpServicesThunk: Fix build with GCC
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / MpServicesOnFrameworkMpServicesThunk / IA32 / MpFuncs.S
1 #------------------------------------------------------------------------------
2 # IA32 assembly file for AP startup vector.
3 #
4 # Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
5 # This program and the accompanying materials
6 # are licensed and made available under the terms and conditions of the BSD License
7 # which accompanies this distribution. The full text of the license may be found at
8 # http://opensource.org/licenses/bsd-license.php
9 #
10 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 #
13 #------------------------------------------------------------------------------
14
15 .equ VacantFlag, 0x0
16 .equ NotVacantFlag, 0xff
17
18 .equ LockLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart
19 .equ StackStart, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x04
20 .equ StackSize, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x08
21 .equ RendezvousProc, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x0C
22 .equ GdtrProfile, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x10
23 .equ IdtrProfile, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x16
24 .equ BufferStart, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x1C
25
26 #-------------------------------------------------------------------------------------
27 #RendezvousFunnelProc procedure follows. All APs execute their procedure. This
28 #procedure serializes all the AP processors through an Init sequence. It must be
29 #noted that APs arrive here very raw...ie: real mode, no stack.
30 #ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC
31 #IS IN MACHINE CODE.
32 #-------------------------------------------------------------------------------------
33 #RendezvousFunnelProc (&WakeUpBuffer,MemAddress);
34
35 ASM_GLOBAL ASM_PFX(RendezvousFunnelProc)
36 ASM_PFX(RendezvousFunnelProc):
37 RendezvousFunnelProcStart:
38
39
40 # At this point CS = 0x(vv00) and ip= 0x0.
41
42 .byte 0x8c,0xc8 # mov ax, cs
43 .byte 0x8e,0xd8 # mov ds, ax
44 .byte 0x8e,0xc0 # mov es, ax
45 .byte 0x8e,0xd0 # mov ss, ax
46 .byte 0x33,0xc0 # xor ax, ax
47 .byte 0x8e,0xe0 # mov fs, ax
48 .byte 0x8e,0xe8 # mov gs, ax
49
50 # Switch to flat mode.
51
52 .byte 0xBE
53 .word BufferStart
54 .byte 0x66,0x8B,0xC # mov ecx,dword ptr [si] ; ECX is keeping the start address of wakeup buffer
55
56 .byte 0xFA # cli
57 .byte 0xBE
58 .word GdtrProfile
59 .byte 0x66 # db 66h
60 .byte 0x2E,0xF,0x1,0x14 # lgdt fword ptr cs:[si]
61
62 .byte 0xBE
63 .word IdtrProfile
64 .byte 0x66 # db 66h
65 .byte 0x2E,0xF,0x1,0x1C # lidt fword ptr cs:[si]
66
67 .byte 0x33,0xC0 # xor ax, ax
68 .byte 0x8E,0xD8 # mov ds, ax
69 .byte 0xF,0x20,0xC0 # mov eax, cr0 ; Get control register 0
70 .byte 0x66,0x83,0xC8,0x1 # or eax, 000000001h ; Set PE bit (bit #0)
71 .byte 0xF,0x22,0xC0 # mov cr0, eax
72
73
74 #step-4:
75
76 FLAT32_JUMP:
77 .byte 0x66
78 .byte 0x67
79 .byte 0xEA # far jump
80 .long 0x0
81 .word 0x10
82
83 ProtectedModeStart: # protected mode entry point
84
85 movw $0x8,%ax
86 .byte 0x66
87 movw %ax,%ds
88 .byte 0x66
89 movw %ax,%es
90 .byte 0x66
91 movw %ax,%fs
92 .byte 0x66
93 movw %ax,%gs
94 .byte 0x66
95 movw %ax,%ss # Flat mode setup.
96
97
98 movl %esi,%edi
99 addl $LockLocation, %edi
100 movb $NotVacantFlag, %al
101 TestLock:
102 xchgb (%edi), %al
103 cmpb $NotVacantFlag, %al
104 jz TestLock
105
106 ProgramStack:
107 movl %esi,%edi
108 addl $StackSize, %edi
109 movl (%edi), %eax
110 movl %esi,%edi
111 addl $StackStart, %edi
112 addl (%edi), %eax
113 movl %eax,%esp
114 movl %eax, (%edi)
115
116 Releaselock:
117 movb $VacantFlag, %al
118 movl %esi,%edi
119 addl $LockLocation, %edi
120 xchgb (%edi), %al
121
122 #
123 # Call C Function
124 #
125 movl %esi,%edi
126 addl $RendezvousProc, %edi
127 movl (%edi), %ebx
128
129 testl %ebx,%ebx
130 jz GoToSleep
131 call *%ebx # Call C function
132
133 #Step-6: Sleep
134
135 GoToSleep:
136
137 cli
138 hlt
139 jmp GoToSleep
140
141 RendezvousFunnelProcEnd:
142 #-------------------------------------------------------------------------------------
143 # AsmGetAddressMap (&AddressMap);
144 #-------------------------------------------------------------------------------------
145 ASM_GLOBAL ASM_PFX(AsmGetAddressMap)
146 ASM_PFX(AsmGetAddressMap):
147
148 pushal
149 movl %esp,%ebp
150
151 movl 0x24(%ebp), %ebx
152 movl $RendezvousFunnelProcStart, (%ebx)
153 movl $(ProtectedModeStart - RendezvousFunnelProcStart), 0x4(%ebx)
154 movl $(FLAT32_JUMP - RendezvousFunnelProcStart), 0x8(%ebx)
155 movl $0, 0x0c(%ebx)
156 movl $0, 0x10(%ebx)
157 movl $(RendezvousFunnelProcEnd - RendezvousFunnelProcStart), 0x14(%ebx)
158
159 popal
160 ret