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