]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Compatibility/MpServicesOnFrameworkMpServicesThunk/IA32/MpFuncs.asm
1. Correct File header to ## @file
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / MpServicesOnFrameworkMpServicesThunk / IA32 / MpFuncs.asm
CommitLineData
768e2a90 1;------------------------------------------------------------------------------\r
2; IA32 assembly file for AP startup vector.\r
3;\r
4; Copyright (c) 2009, Intel Corporation\r
5; All rights reserved. This program and the accompanying materials\r
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
63 \r
64 db 33h, 0C0h ; xor ax, ax\r
65 db 8Eh, 0D8h ; mov ds, ax\r
66 db 0Fh, 20h, 0C0h ; mov eax, cr0 ; Get control register 0\r
67 db 66h, 83h, 0C8h, 01h ; or eax, 000000001h ; Set PE bit (bit #0)\r
68 db 0Fh, 22h, 0C0h ; mov cr0, eax\r
69\r
70\r
71FLAT32_JUMP::\r
72 FJMP32 010h,0h ; Far jmp using code segment descriptor\r
73\r
74ProtectedModeStart:: ; protected mode entry point\r
75\r
76 mov ax, 8h\r
77 mov ds, ax\r
78 mov es, ax\r
79 mov fs, ax\r
80 mov gs, ax\r
81 mov ss, ax ; Flat mode setup.\r
82\r
83\r
84 mov edi, esi\r
85 add edi, LockLocation\r
86 mov al, NotVacantFlag\r
87TestLock::\r
88 xchg byte ptr [edi], al\r
89 cmp al, NotVacantFlag\r
90 jz TestLock\r
91\r
92ProgramStack::\r
93\r
94 mov edi, esi\r
95 add edi, StackSize\r
96 mov eax, dword ptr [edi]\r
97 mov edi, esi\r
98 add edi, StackStart\r
99 add eax, dword ptr [edi]\r
100 mov esp, eax\r
101 mov dword ptr [edi], eax\r
102\r
103Releaselock::\r
104 mov al, VacantFlag\r
105 mov edi, esi\r
106 add edi, LockLocation\r
107 xchg byte ptr [edi], al\r
108\r
109 ;\r
110 ; Call C Function\r
111 ;\r
112 mov edi, esi\r
113 add edi, RendezvousProc\r
114 mov ebx, dword ptr [edi]\r
115\r
116 test ebx, ebx\r
117 jz GoToSleep\r
118 call ebx ; Call C function\r
119\r
120GoToSleep::\r
121\r
122 cli\r
123 hlt\r
124 jmp $-2\r
125 \r
126RendezvousFunnelProc ENDP\r
127RendezvousFunnelProcEnd::\r
128;-------------------------------------------------------------------------------------\r
129; AsmGetAddressMap (&AddressMap);\r
130;-------------------------------------------------------------------------------------\r
131AsmGetAddressMap PROC near C PUBLIC\r
132\r
133 pushad\r
134 mov ebp,esp\r
135 \r
136 mov ebx, dword ptr [ebp+24h]\r
137 mov dword ptr [ebx], RendezvousFunnelProcStart\r
138 mov dword ptr [ebx+4h], ProtectedModeStart - RendezvousFunnelProcStart\r
139 mov dword ptr [ebx+8h], FLAT32_JUMP - RendezvousFunnelProcStart\r
140 mov dword ptr [ebx+0ch], 0\r
141 mov dword ptr [ebx+10h], 0\r
142 mov dword ptr [ebx+14h], RendezvousFunnelProcEnd - RendezvousFunnelProcStart\r
143 \r
144 popad\r
145 ret\r
146AsmGetAddressMap ENDP\r
147\r
148END\r