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