]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Compatibility/MpServicesOnFrameworkMpServicesThunk/IA32/MpFuncs.S
Maintainers.txt: Remove EdkCompatibilityPkg information
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / MpServicesOnFrameworkMpServicesThunk / IA32 / MpFuncs.S
CommitLineData
768e2a90 1#------------------------------------------------------------------------------\r
2# IA32 assembly file for AP startup vector.\r
3#\r
6d896ff1 4# Copyright (c) 2009 - 2012, 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
830db412 15#define VacantFlag 0x0\r
16#define NotVacantFlag 0xff\r
768e2a90 17\r
830db412 18#define LockLocation RendezvousFunnelProcEnd - RendezvousFunnelProcStart\r
19#define StackStart RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x04\r
20#define StackSize RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x08\r
21#define RendezvousProc RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x0C\r
22#define GdtrProfile RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x10\r
23#define IdtrProfile RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x16\r
24#define BufferStart RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x1C\r
133238cb 25#define ProcessorNumber RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x20\r
768e2a90 26\r
27#-------------------------------------------------------------------------------------\r
28#RendezvousFunnelProc procedure follows. All APs execute their procedure. This\r
29#procedure serializes all the AP processors through an Init sequence. It must be\r
30#noted that APs arrive here very raw...ie: real mode, no stack.\r
31#ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC\r
32#IS IN MACHINE CODE.\r
33#-------------------------------------------------------------------------------------\r
34#RendezvousFunnelProc (&WakeUpBuffer,MemAddress);\r
35\r
36ASM_GLOBAL ASM_PFX(RendezvousFunnelProc)\r
37ASM_PFX(RendezvousFunnelProc):\r
38RendezvousFunnelProcStart:\r
39\r
40\r
41# At this point CS = 0x(vv00) and ip= 0x0.\r
42\r
43 .byte 0x8c,0xc8 # mov ax, cs\r
44 .byte 0x8e,0xd8 # mov ds, ax\r
45 .byte 0x8e,0xc0 # mov es, ax\r
46 .byte 0x8e,0xd0 # mov ss, ax \r
47 .byte 0x33,0xc0 # xor ax, ax\r
48 .byte 0x8e,0xe0 # mov fs, ax\r
49 .byte 0x8e,0xe8 # mov gs, ax\r
50\r
51# Switch to flat mode.\r
52\r
53 .byte 0xBE\r
54 .word BufferStart\r
55 .byte 0x66,0x8B,0xC # mov ecx,dword ptr [si] ; ECX is keeping the start address of wakeup buffer\r
56\r
57 .byte 0xFA # cli\r
58 .byte 0xBE\r
59 .word GdtrProfile\r
60 .byte 0x66 # db 66h\r
61 .byte 0x2E,0xF,0x1,0x14 # lgdt fword ptr cs:[si]\r
62\r
de243ee4 63 .byte 0xBE\r
64 .word IdtrProfile\r
65 .byte 0x66 # db 66h\r
66 .byte 0x2E,0xF,0x1,0x1C # lidt fword ptr cs:[si]\r
67\r
768e2a90 68 .byte 0x33,0xC0 # xor ax, ax\r
69 .byte 0x8E,0xD8 # mov ds, ax\r
70 .byte 0xF,0x20,0xC0 # mov eax, cr0 ; Get control register 0\r
71 .byte 0x66,0x83,0xC8,0x1 # or eax, 000000001h ; Set PE bit (bit #0)\r
72 .byte 0xF,0x22,0xC0 # mov cr0, eax\r
73\r
74\r
75#step-4:\r
76\r
77FLAT32_JUMP:\r
78 .byte 0x66\r
79 .byte 0x67\r
80 .byte 0xEA # far jump\r
81 .long 0x0\r
82 .word 0x10\r
83\r
84ProtectedModeStart: # protected mode entry point\r
85\r
86 movw $0x8,%ax\r
87 .byte 0x66\r
88 movw %ax,%ds\r
89 .byte 0x66\r
90 movw %ax,%es\r
91 .byte 0x66\r
92 movw %ax,%fs\r
93 .byte 0x66\r
94 movw %ax,%gs\r
95 .byte 0x66\r
96 movw %ax,%ss # Flat mode setup.\r
97\r
d6d858c4 98 #\r
99 # ProgramStack\r
100 #\r
101 movl $0x1b, %ecx\r
102 rdmsr\r
6d896ff1 103\r
104 btl $10, %eax # Check for x2apic mode\r
105 jnc LegacyApicMode\r
106 movl $0x802, %ecx # Read APIC_ID\r
107 rdmsr\r
108 movl %eax, %ebx # ebx == apicid\r
109 jmp GetCpuNumber\r
110\r
111LegacyApicMode:\r
d6d858c4 112 andl $0xfffff000, %eax\r
113 addl $0x20, %eax\r
114 movl (%eax), %ebx\r
6d896ff1 115 shrl $24, %ebx # ebx == apicid\r
116\r
117GetCpuNumber: \r
d6d858c4 118 xorl %ecx, %ecx\r
768e2a90 119 movl %esi,%edi\r
d6d858c4 120 addl $ProcessorNumber, %edi\r
121 movl (%edi, %ebx, 4), %ecx\r
122\r
768e2a90 123 movl %esi,%edi\r
124 addl $StackSize, %edi\r
125 movl (%edi), %eax\r
d6d858c4 126 incl %ecx\r
127 mull %ecx\r
128\r
768e2a90 129 movl %esi,%edi\r
130 addl $StackStart, %edi\r
d6d858c4 131 movl (%edi), %ebx\r
132 addl %ebx, %eax\r
768e2a90 133\r
d6d858c4 134 movl %eax, %esp\r
768e2a90 135\r
136 #\r
137 # Call C Function\r
138 #\r
139 movl %esi,%edi\r
140 addl $RendezvousProc, %edi\r
141 movl (%edi), %ebx\r
142\r
143 testl %ebx,%ebx\r
144 jz GoToSleep\r
145 call *%ebx # Call C function\r
146\r
147#Step-6: Sleep\r
148\r
149GoToSleep:\r
150\r
151 cli\r
152 hlt\r
153 jmp GoToSleep\r
154\r
155RendezvousFunnelProcEnd:\r
156#-------------------------------------------------------------------------------------\r
157# AsmGetAddressMap (&AddressMap);\r
158#-------------------------------------------------------------------------------------\r
159ASM_GLOBAL ASM_PFX(AsmGetAddressMap)\r
160ASM_PFX(AsmGetAddressMap):\r
161\r
162 pushal\r
163 movl %esp,%ebp\r
164\r
165 movl 0x24(%ebp), %ebx\r
166 movl $RendezvousFunnelProcStart, (%ebx)\r
167 movl $(ProtectedModeStart - RendezvousFunnelProcStart), 0x4(%ebx)\r
168 movl $(FLAT32_JUMP - RendezvousFunnelProcStart), 0x8(%ebx)\r
169 movl $0, 0x0c(%ebx)\r
170 movl $0, 0x10(%ebx)\r
171 movl $(RendezvousFunnelProcEnd - RendezvousFunnelProcStart), 0x14(%ebx)\r
172\r
173 popal\r
174 ret\r