]>
Commit | Line | Data |
---|---|---|
f9d30595 JF |
1 | ;------------------------------------------------------------------------------ ; |
2 | ; Copyright (c) 2015, Intel Corporation. All rights reserved.<BR> | |
3 | ; This program and the accompanying materials | |
4 | ; are licensed and made available under the terms and conditions of the BSD License | |
5 | ; which accompanies this distribution. The full text of the license may be found at | |
6 | ; http://opensource.org/licenses/bsd-license.php. | |
7 | ; | |
8 | ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, | |
9 | ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. | |
10 | ; | |
11 | ; Module Name: | |
12 | ; | |
13 | ; MpFuncs.nasm | |
14 | ; | |
15 | ; Abstract: | |
16 | ; | |
17 | ; This is the assembly code for MP support | |
18 | ; | |
19 | ;------------------------------------------------------------------------------- | |
20 | ||
21 | %include "MpEqu.inc" | |
22 | ||
23 | SECTION .text | |
24 | ||
da1475e0 JF |
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 | global ASM_PFX(RendezvousFunnelProc) | |
33 | ASM_PFX(RendezvousFunnelProc): | |
34 | RendezvousFunnelProcStart: | |
35 | ; At this point CS = 0x(vv00) and ip= 0x0. | |
36 | BITS 16 | |
37 | mov ebp, eax ; save BIST information | |
38 | ||
39 | mov ax, cs | |
40 | mov ds, ax | |
41 | mov es, ax | |
42 | mov ss, ax | |
43 | xor ax, ax | |
44 | mov fs, ax | |
45 | mov gs, ax | |
46 | ||
47 | mov si, BufferStartLocation | |
48 | mov ebx, [si] | |
49 | ||
50 | mov di, PmodeOffsetLocation | |
51 | mov eax, [di] | |
52 | mov di, ax | |
53 | sub di, 06h | |
54 | add eax, ebx | |
55 | mov [di],eax | |
56 | ||
57 | mov si, GdtrLocation | |
58 | o32 lgdt [cs:si] | |
59 | ||
60 | mov si, IdtrLocation | |
61 | o32 lidt [cs:si] | |
62 | ||
63 | xor ax, ax | |
64 | mov ds, ax | |
65 | ||
66 | mov eax, cr0 ;Get control register 0 | |
67 | or eax, 000000003h ;Set PE bit (bit #0) & MP | |
68 | mov cr0, eax | |
69 | ||
70 | jmp PROTECT_MODE_CS:strict dword 0 ; far jump to protected mode | |
71 | BITS 32 | |
72 | Flat32Start: ; protected mode entry point | |
73 | mov ax, PROTECT_MODE_DS | |
74 | mov ds, ax | |
75 | mov es, ax | |
76 | mov fs, ax | |
77 | mov gs, ax | |
78 | mov ss, ax | |
79 | ||
80 | mov esi, ebx | |
81 | mov edi, esi | |
82 | add edi, LockLocation | |
83 | mov eax, NotVacantFlag | |
84 | ||
85 | TestLock: | |
86 | xchg [edi], eax | |
87 | cmp eax, NotVacantFlag | |
88 | jz TestLock | |
89 | ||
90 | mov edi, esi | |
91 | add edi, NumApsExecutingLoction | |
92 | inc dword [edi] | |
93 | mov ebx, [edi] | |
94 | ||
95 | ProgramStack: | |
96 | mov edi, esi | |
97 | add edi, StackSizeLocation | |
98 | mov eax, [edi] | |
99 | mov edi, esi | |
100 | add edi, StackStartAddressLocation | |
101 | add eax, [edi] | |
102 | mov esp, eax | |
103 | mov [edi], eax | |
104 | ||
105 | Releaselock: | |
106 | mov eax, VacantFlag | |
107 | mov edi, esi | |
108 | add edi, LockLocation | |
109 | xchg [edi], eax | |
110 | ||
111 | CProcedureInvoke: | |
112 | push ebp ; push BIST data at top of AP stack | |
113 | xor ebp, ebp ; clear ebp for call stack trace | |
114 | push ebp | |
115 | mov ebp, esp | |
116 | ||
117 | ||
118 | push ebx ; Push NumApsExecuting | |
119 | mov eax, esi | |
120 | add eax, LockLocation | |
121 | push eax ; push address of exchange info data buffer | |
122 | ||
123 | mov edi, esi | |
124 | add edi, ApProcedureLocation | |
125 | mov eax, [edi] | |
126 | ||
127 | call eax ; invoke C function | |
128 | ||
129 | jmp $ ; never reach here | |
130 | RendezvousFunnelProcEnd: | |
131 | ||
f9d30595 JF |
132 | |
133 | global ASM_PFX(AsmInitializeGdt) | |
134 | ASM_PFX(AsmInitializeGdt): | |
135 | push ebp | |
136 | mov ebp, esp | |
137 | pushad | |
138 | mov edi, [ebp + 8] ; Load GDT register | |
139 | ||
140 | lgdt [edi] ; and update the GDTR | |
141 | ||
142 | push PROTECT_MODE_CS | |
143 | mov eax, ASM_PFX(SetCodeSelectorFarJump) | |
144 | push eax | |
145 | retf | |
146 | ASM_PFX(SetCodeSelectorFarJump): | |
147 | mov ax, PROTECT_MODE_DS ; Update the Base for the new selectors, too | |
148 | mov ds, ax | |
149 | mov es, ax | |
150 | mov fs, ax | |
151 | mov gs, ax | |
152 | mov ss, ax | |
153 | ||
154 | popad | |
155 | pop ebp | |
156 | ret |