]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Compatibility/MpServicesOnFrameworkMpServicesThunk/IA32/MpFuncs.asm
1.Restore BSP IDT table to AP when AP wakeup.
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / MpServicesOnFrameworkMpServicesThunk / IA32 / MpFuncs.asm
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.686p\r
16.model flat \r
17.code \r
18\r
19include AsmInclude.inc\r
20;-------------------------------------------------------------------------------------\r
21FJMP32 MACRO Selector, Offset\r
22 DB 066h\r
23 DB 067h\r
24 DB 0EAh ; far jump\r
25 DD Offset ; 32-bit offset\r
26 DW Selector ; 16-bit selector\r
27 ENDM\r
28\r
29;-------------------------------------------------------------------------------------\r
30;RendezvousFunnelProc procedure follows. All APs execute their procedure. This\r
31;procedure serializes all the AP processors through an Init sequence. It must be\r
32;noted that APs arrive here very raw...ie: real mode, no stack.\r
33;ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC\r
34;IS IN MACHINE CODE.\r
35;-------------------------------------------------------------------------------------\r
36;RendezvousFunnelProc (&WakeUpBuffer,MemAddress);\r
37\r
38RendezvousFunnelProc PROC near C PUBLIC\r
39RendezvousFunnelProcStart::\r
40\r
41\r
42; At this point CS = 0x(vv00) and ip= 0x0.\r
43\r
44 db 8ch, 0c8h ; mov ax, cs\r
45 db 8eh, 0d8h ; mov ds, ax\r
46 db 8eh, 0c0h ; mov es, ax\r
47 db 8eh, 0d0h ; mov ss, ax \r
48 db 33h, 0c0h ; xor ax, ax\r
49 db 8eh, 0e0h ; mov fs, ax\r
50 db 8eh, 0e8h ; mov gs, ax\r
51\r
52; Switch to flat mode.\r
53\r
54 db 0BEh\r
55 dw BufferStart ; mov si, BufferStart\r
56 db 66h, 8Bh, 0Ch ; mov ecx,dword ptr [si] ; ECX is keeping the start address of wakeup buffer\r
57\r
58 db 0FAh ; cli\r
59 db 0BEh\r
60 dw GdtrProfile ; mov si, GdtrProfile\r
61 db 66h ; db 66h\r
62 db 2Eh,0Fh, 01h, 14h ; lgdt fword ptr cs:[si]\r
de243ee4 63\r
64 db 0BEh\r
65 dw IdtrProfile ; mov si, IdtrProfile\r
66 db 66h ; db 66h\r
67 db 2Eh,0Fh, 01h, 1Ch ; lidt fword ptr cs:[si]\r
768e2a90 68 \r
69 db 33h, 0C0h ; xor ax, ax\r
70 db 8Eh, 0D8h ; mov ds, ax\r
71 db 0Fh, 20h, 0C0h ; mov eax, cr0 ; Get control register 0\r
72 db 66h, 83h, 0C8h, 01h ; or eax, 000000001h ; Set PE bit (bit #0)\r
73 db 0Fh, 22h, 0C0h ; mov cr0, eax\r
74\r
75\r
76FLAT32_JUMP::\r
77 FJMP32 010h,0h ; Far jmp using code segment descriptor\r
78\r
79ProtectedModeStart:: ; protected mode entry point\r
80\r
81 mov ax, 8h\r
82 mov ds, ax\r
83 mov es, ax\r
84 mov fs, ax\r
85 mov gs, ax\r
86 mov ss, ax ; Flat mode setup.\r
87\r
88\r
89 mov edi, esi\r
90 add edi, LockLocation\r
91 mov al, NotVacantFlag\r
92TestLock::\r
93 xchg byte ptr [edi], al\r
94 cmp al, NotVacantFlag\r
95 jz TestLock\r
96\r
97ProgramStack::\r
98\r
99 mov edi, esi\r
100 add edi, StackSize\r
101 mov eax, dword ptr [edi]\r
102 mov edi, esi\r
103 add edi, StackStart\r
104 add eax, dword ptr [edi]\r
105 mov esp, eax\r
106 mov dword ptr [edi], eax\r
107\r
108Releaselock::\r
109 mov al, VacantFlag\r
110 mov edi, esi\r
111 add edi, LockLocation\r
112 xchg byte ptr [edi], al\r
113\r
114 ;\r
115 ; Call C Function\r
116 ;\r
117 mov edi, esi\r
118 add edi, RendezvousProc\r
119 mov ebx, dword ptr [edi]\r
120\r
121 test ebx, ebx\r
122 jz GoToSleep\r
123 call ebx ; Call C function\r
124\r
125GoToSleep::\r
126\r
127 cli\r
128 hlt\r
129 jmp $-2\r
130 \r
131RendezvousFunnelProc ENDP\r
132RendezvousFunnelProcEnd::\r
133;-------------------------------------------------------------------------------------\r
134; AsmGetAddressMap (&AddressMap);\r
135;-------------------------------------------------------------------------------------\r
136AsmGetAddressMap PROC near C PUBLIC\r
137\r
138 pushad\r
139 mov ebp,esp\r
140 \r
141 mov ebx, dword ptr [ebp+24h]\r
142 mov dword ptr [ebx], RendezvousFunnelProcStart\r
143 mov dword ptr [ebx+4h], ProtectedModeStart - RendezvousFunnelProcStart\r
144 mov dword ptr [ebx+8h], FLAT32_JUMP - RendezvousFunnelProcStart\r
145 mov dword ptr [ebx+0ch], 0\r
146 mov dword ptr [ebx+10h], 0\r
147 mov dword ptr [ebx+14h], RendezvousFunnelProcEnd - RendezvousFunnelProcStart\r
148 \r
149 popad\r
150 ret\r
151AsmGetAddressMap ENDP\r
152\r
153END\r