]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Compatibility/MpServicesOnFrameworkMpServicesThunk/IA32/MpFuncs.asm
Check in thunk driver to produce PI MP Services Protocol based on Framework MP Servic...
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / MpServicesOnFrameworkMpServicesThunk / IA32 / MpFuncs.asm
1 ;------------------------------------------------------------------------------
2 ; IA32 assembly file for AP startup vector.
3 ;
4 ; Copyright (c) 2009, Intel Corporation
5 ; All rights reserved. This program and the accompanying materials
6 ; are licensed and made available under the terms and conditions of the BSD License
7 ; which accompanies this distribution. The full text of the license may be found at
8 ; http://opensource.org/licenses/bsd-license.php
9 ;
10 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 ;
13 ;------------------------------------------------------------------------------
14
15 .686p
16 .model flat
17 .code
18
19 include AsmInclude.inc
20 ;-------------------------------------------------------------------------------------
21 FJMP32 MACRO Selector, Offset
22 DB 066h
23 DB 067h
24 DB 0EAh ; far jump
25 DD Offset ; 32-bit offset
26 DW Selector ; 16-bit selector
27 ENDM
28
29 ;-------------------------------------------------------------------------------------
30 ;RendezvousFunnelProc procedure follows. All APs execute their procedure. This
31 ;procedure serializes all the AP processors through an Init sequence. It must be
32 ;noted that APs arrive here very raw...ie: real mode, no stack.
33 ;ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC
34 ;IS IN MACHINE CODE.
35 ;-------------------------------------------------------------------------------------
36 ;RendezvousFunnelProc (&WakeUpBuffer,MemAddress);
37
38 RendezvousFunnelProc PROC near C PUBLIC
39 RendezvousFunnelProcStart::
40
41
42 ; At this point CS = 0x(vv00) and ip= 0x0.
43
44 db 8ch, 0c8h ; mov ax, cs
45 db 8eh, 0d8h ; mov ds, ax
46 db 8eh, 0c0h ; mov es, ax
47 db 8eh, 0d0h ; mov ss, ax
48 db 33h, 0c0h ; xor ax, ax
49 db 8eh, 0e0h ; mov fs, ax
50 db 8eh, 0e8h ; mov gs, ax
51
52 ; Switch to flat mode.
53
54 db 0BEh
55 dw BufferStart ; mov si, BufferStart
56 db 66h, 8Bh, 0Ch ; mov ecx,dword ptr [si] ; ECX is keeping the start address of wakeup buffer
57
58 db 0FAh ; cli
59 db 0BEh
60 dw GdtrProfile ; mov si, GdtrProfile
61 db 66h ; db 66h
62 db 2Eh,0Fh, 01h, 14h ; lgdt fword ptr cs:[si]
63
64 db 33h, 0C0h ; xor ax, ax
65 db 8Eh, 0D8h ; mov ds, ax
66 db 0Fh, 20h, 0C0h ; mov eax, cr0 ; Get control register 0
67 db 66h, 83h, 0C8h, 01h ; or eax, 000000001h ; Set PE bit (bit #0)
68 db 0Fh, 22h, 0C0h ; mov cr0, eax
69
70
71 FLAT32_JUMP::
72 FJMP32 010h,0h ; Far jmp using code segment descriptor
73
74 ProtectedModeStart:: ; protected mode entry point
75
76 mov ax, 8h
77 mov ds, ax
78 mov es, ax
79 mov fs, ax
80 mov gs, ax
81 mov ss, ax ; Flat mode setup.
82
83
84 mov edi, esi
85 add edi, LockLocation
86 mov al, NotVacantFlag
87 TestLock::
88 xchg byte ptr [edi], al
89 cmp al, NotVacantFlag
90 jz TestLock
91
92 ProgramStack::
93
94 mov edi, esi
95 add edi, StackSize
96 mov eax, dword ptr [edi]
97 mov edi, esi
98 add edi, StackStart
99 add eax, dword ptr [edi]
100 mov esp, eax
101 mov dword ptr [edi], eax
102
103 Releaselock::
104 mov al, VacantFlag
105 mov edi, esi
106 add edi, LockLocation
107 xchg byte ptr [edi], al
108
109 ;
110 ; Call C Function
111 ;
112 mov edi, esi
113 add edi, RendezvousProc
114 mov ebx, dword ptr [edi]
115
116 test ebx, ebx
117 jz GoToSleep
118 call ebx ; Call C function
119
120 GoToSleep::
121
122 cli
123 hlt
124 jmp $-2
125
126 RendezvousFunnelProc ENDP
127 RendezvousFunnelProcEnd::
128 ;-------------------------------------------------------------------------------------
129 ; AsmGetAddressMap (&AddressMap);
130 ;-------------------------------------------------------------------------------------
131 AsmGetAddressMap PROC near C PUBLIC
132
133 pushad
134 mov ebp,esp
135
136 mov ebx, dword ptr [ebp+24h]
137 mov dword ptr [ebx], RendezvousFunnelProcStart
138 mov dword ptr [ebx+4h], ProtectedModeStart - RendezvousFunnelProcStart
139 mov dword ptr [ebx+8h], FLAT32_JUMP - RendezvousFunnelProcStart
140 mov dword ptr [ebx+0ch], 0
141 mov dword ptr [ebx+10h], 0
142 mov dword ptr [ebx+14h], RendezvousFunnelProcEnd - RendezvousFunnelProcStart
143
144 popad
145 ret
146 AsmGetAddressMap ENDP
147
148 END