]>
Commit | Line | Data |
---|---|---|
7947da3c MK |
1 | ;------------------------------------------------------------------------------ ;\r |
2 | ; Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r | |
3 | ; This program and the accompanying materials\r | |
4 | ; are licensed and made available under the terms and conditions of the BSD License\r | |
5 | ; which accompanies this distribution. The full text of the license may be found at\r | |
6 | ; http://opensource.org/licenses/bsd-license.php.\r | |
7 | ;\r | |
8 | ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
9 | ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
10 | ;\r | |
11 | ; Module Name:\r | |
12 | ;\r | |
13 | ; MpFuncs.asm\r | |
14 | ;\r | |
15 | ; Abstract:\r | |
16 | ;\r | |
17 | ; This is the assembly code for Multi-processor S3 support\r | |
18 | ;\r | |
19 | ;-------------------------------------------------------------------------------\r | |
20 | \r | |
21 | .686p\r | |
22 | .model flat,C\r | |
23 | .code\r | |
24 | \r | |
25 | EXTERN InitializeFloatingPointUnits:PROC\r | |
26 | \r | |
27 | VacantFlag Equ 00h\r | |
28 | NotVacantFlag Equ 0ffh\r | |
29 | \r | |
30 | LockLocation equ RendezvousFunnelProcEnd - RendezvousFunnelProcStart\r | |
31 | StackStart equ LockLocation + 4h\r | |
32 | StackSize equ LockLocation + 8h\r | |
33 | RendezvousProc equ LockLocation + 0Ch\r | |
34 | GdtrProfile equ LockLocation + 10h\r | |
35 | IdtrProfile equ LockLocation + 16h\r | |
36 | BufferStart equ LockLocation + 1Ch\r | |
37 | \r | |
38 | ;-------------------------------------------------------------------------------------\r | |
39 | ;RendezvousFunnelProc procedure follows. All APs execute their procedure. This\r | |
40 | ;procedure serializes all the AP processors through an Init sequence. It must be\r | |
41 | ;noted that APs arrive here very raw...ie: real mode, no stack.\r | |
42 | ;ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC\r | |
43 | ;IS IN MACHINE CODE.\r | |
44 | ;-------------------------------------------------------------------------------------\r | |
45 | ;RendezvousFunnelProc (&WakeUpBuffer,MemAddress);\r | |
46 | \r | |
47 | RendezvousFunnelProc PROC near C PUBLIC\r | |
48 | RendezvousFunnelProcStart::\r | |
49 | \r | |
50 | ; At this point CS = 0x(vv00) and ip= 0x0.\r | |
51 | \r | |
52 | db 8ch, 0c8h ; mov ax, cs\r | |
53 | db 8eh, 0d8h ; mov ds, ax\r | |
54 | db 8eh, 0c0h ; mov es, ax\r | |
55 | db 8eh, 0d0h ; mov ss, ax\r | |
56 | db 33h, 0c0h ; xor ax, ax\r | |
57 | db 8eh, 0e0h ; mov fs, ax\r | |
58 | db 8eh, 0e8h ; mov gs, ax\r | |
59 | \r | |
60 | flat32Start::\r | |
61 | \r | |
62 | db 0BEh\r | |
63 | dw BufferStart ; mov si, BufferStart\r | |
64 | db 66h, 8Bh, 14h ; mov edx,dword ptr [si] ; EDX is keeping the start address of wakeup buffer\r | |
65 | \r | |
66 | db 0BEh\r | |
67 | dw GdtrProfile ; mov si, GdtrProfile\r | |
68 | db 66h ; db 66h\r | |
69 | db 2Eh, 0Fh, 01h, 14h ; lgdt fword ptr cs:[si]\r | |
70 | \r | |
71 | db 0BEh\r | |
72 | dw IdtrProfile ; mov si, IdtrProfile\r | |
73 | db 66h ; db 66h\r | |
74 | db 2Eh, 0Fh, 01h, 1Ch ; lidt fword ptr cs:[si]\r | |
75 | \r | |
76 | db 33h, 0C0h ; xor ax, ax\r | |
77 | db 8Eh, 0D8h ; mov ds, ax\r | |
78 | \r | |
79 | db 0Fh, 20h, 0C0h ; mov eax, cr0 ; Get control register 0\r | |
80 | db 66h, 83h, 0C8h, 01h ; or eax, 000000001h ; Set PE bit (bit #0)\r | |
81 | db 0Fh, 22h, 0C0h ; mov cr0, eax\r | |
82 | \r | |
83 | FLAT32_JUMP::\r | |
84 | \r | |
85 | db 66h, 67h, 0EAh ; far jump\r | |
86 | dd 0h ; 32-bit offset\r | |
87 | dw 20h ; 16-bit selector\r | |
88 | \r | |
89 | PMODE_ENTRY:: ; protected mode entry point\r | |
90 | \r | |
91 | mov ax, 8h\r | |
92 | mov ds, ax\r | |
93 | mov es, ax\r | |
94 | mov fs, ax\r | |
95 | mov gs, ax\r | |
96 | mov ss, ax ; Flat mode setup.\r | |
97 | \r | |
98 | mov esi, edx\r | |
99 | \r | |
100 | mov edi, esi\r | |
101 | add edi, LockLocation\r | |
102 | mov al, NotVacantFlag\r | |
103 | TestLock::\r | |
104 | xchg byte ptr [edi], al\r | |
105 | cmp al, NotVacantFlag\r | |
106 | jz TestLock\r | |
107 | \r | |
108 | ProgramStack::\r | |
109 | \r | |
110 | mov edi, esi\r | |
111 | add edi, StackSize\r | |
112 | mov eax, dword ptr [edi]\r | |
113 | mov edi, esi\r | |
114 | add edi, StackStart\r | |
115 | add eax, dword ptr [edi]\r | |
116 | mov esp, eax\r | |
117 | mov dword ptr [edi], eax\r | |
118 | \r | |
119 | Releaselock::\r | |
120 | \r | |
121 | mov al, VacantFlag\r | |
122 | mov edi, esi\r | |
123 | add edi, LockLocation\r | |
124 | xchg byte ptr [edi], al\r | |
125 | \r | |
126 | ;\r | |
127 | ; Call assembly function to initialize FPU.\r | |
128 | ;\r | |
129 | mov ebx, InitializeFloatingPointUnits\r | |
130 | call ebx\r | |
131 | ;\r | |
132 | ; Call C Function\r | |
133 | ;\r | |
134 | mov edi, esi\r | |
135 | add edi, RendezvousProc\r | |
136 | mov eax, dword ptr [edi]\r | |
137 | \r | |
138 | test eax, eax\r | |
139 | jz GoToSleep\r | |
140 | call eax ; Call C function\r | |
141 | \r | |
142 | GoToSleep::\r | |
143 | cli\r | |
144 | hlt\r | |
145 | jmp $-2\r | |
146 | \r | |
147 | RendezvousFunnelProc ENDP\r | |
148 | RendezvousFunnelProcEnd::\r | |
149 | ;-------------------------------------------------------------------------------------\r | |
150 | ; AsmGetAddressMap (&AddressMap);\r | |
151 | ;-------------------------------------------------------------------------------------\r | |
152 | AsmGetAddressMap PROC near C PUBLIC\r | |
153 | \r | |
154 | pushad\r | |
155 | mov ebp,esp\r | |
156 | \r | |
157 | mov ebx, dword ptr [ebp+24h]\r | |
158 | mov dword ptr [ebx], RendezvousFunnelProcStart\r | |
159 | mov dword ptr [ebx+4h], PMODE_ENTRY - RendezvousFunnelProcStart\r | |
160 | mov dword ptr [ebx+8h], FLAT32_JUMP - RendezvousFunnelProcStart\r | |
161 | mov dword ptr [ebx+0ch], RendezvousFunnelProcEnd - RendezvousFunnelProcStart\r | |
162 | \r | |
163 | popad\r | |
164 | ret\r | |
165 | \r | |
166 | AsmGetAddressMap ENDP\r | |
167 | \r | |
168 | END\r |