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