]>
Commit | Line | Data |
---|---|---|
6997711e LG |
1 | ;------------------------------------------------------------------------------ ;\r |
2 | ; Copyright (c) 2016, 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.nasm\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 | SECTION .text\r | |
22 | \r | |
23 | extern ASM_PFX(InitializeFloatingPointUnits)\r | |
24 | \r | |
25 | %define VacantFlag 0x0\r | |
26 | %define NotVacantFlag 0xff\r | |
27 | \r | |
28 | %define LockLocation RendezvousFunnelProcEnd - RendezvousFunnelProcStart\r | |
29 | %define StackStart LockLocation + 0x4\r | |
30 | %define StackSize LockLocation + 0x8\r | |
31 | %define RendezvousProc LockLocation + 0xC\r | |
32 | %define GdtrProfile LockLocation + 0x10\r | |
33 | %define IdtrProfile LockLocation + 0x16\r | |
34 | %define BufferStart LockLocation + 0x1C\r | |
35 | \r | |
36 | ;-------------------------------------------------------------------------------------\r | |
37 | ;RendezvousFunnelProc procedure follows. All APs execute their procedure. This\r | |
38 | ;procedure serializes all the AP processors through an Init sequence. It must be\r | |
39 | ;noted that APs arrive here very raw...ie: real mode, no stack.\r | |
40 | ;ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC\r | |
41 | ;IS IN MACHINE CODE.\r | |
42 | ;-------------------------------------------------------------------------------------\r | |
43 | ;RendezvousFunnelProc (&WakeUpBuffer,MemAddress);\r | |
44 | \r | |
55c6d546 | 45 | BITS 16\r |
6997711e LG |
46 | global ASM_PFX(RendezvousFunnelProc)\r |
47 | ASM_PFX(RendezvousFunnelProc):\r | |
48 | RendezvousFunnelProcStart:\r | |
49 | \r | |
50 | ; At this point CS = 0x(vv00) and ip= 0x0.\r | |
51 | \r | |
55c6d546 LG |
52 | mov ax, cs\r |
53 | mov ds, ax\r | |
54 | mov es, ax\r | |
55 | mov ss, ax\r | |
56 | xor ax, ax\r | |
57 | mov fs, ax\r | |
58 | mov gs, ax\r | |
6997711e LG |
59 | \r |
60 | flat32Start:\r | |
61 | \r | |
55c6d546 LG |
62 | mov si, BufferStart\r |
63 | mov edx,dword [si] ; EDX is keeping the start address of wakeup buffer\r | |
6997711e | 64 | \r |
55c6d546 LG |
65 | mov si, GdtrProfile\r |
66 | o32 lgdt [cs:si]\r | |
6997711e | 67 | \r |
55c6d546 LG |
68 | mov si, IdtrProfile\r |
69 | o32 lidt [cs:si]\r | |
6997711e | 70 | \r |
55c6d546 LG |
71 | xor ax, ax\r |
72 | mov ds, ax\r | |
6997711e | 73 | \r |
55c6d546 LG |
74 | mov eax, cr0 ; Get control register 0\r |
75 | or eax, 0x000000001 ; Set PE bit (bit #0)\r | |
76 | mov cr0, eax\r | |
6997711e LG |
77 | \r |
78 | FLAT32_JUMP:\r | |
79 | \r | |
55c6d546 | 80 | a32 jmp dword 0x20:0x0\r |
6997711e | 81 | \r |
55c6d546 | 82 | BITS 32\r |
6997711e LG |
83 | PMODE_ENTRY: ; protected mode entry point\r |
84 | \r | |
85 | mov ax, 0x8\r | |
86 | o16 mov ds, ax\r | |
87 | o16 mov es, ax\r | |
88 | o16 mov fs, ax\r | |
89 | o16 mov gs, ax\r | |
90 | o16 mov ss, ax ; Flat mode setup.\r | |
91 | \r | |
92 | mov esi, edx\r | |
93 | \r | |
94 | mov edi, esi\r | |
95 | add edi, LockLocation\r | |
96 | mov al, NotVacantFlag\r | |
97 | TestLock:\r | |
98 | xchg byte [edi], al\r | |
99 | cmp al, NotVacantFlag\r | |
100 | jz TestLock\r | |
101 | \r | |
102 | ProgramStack:\r | |
103 | \r | |
104 | mov edi, esi\r | |
105 | add edi, StackSize\r | |
106 | mov eax, dword [edi]\r | |
107 | mov edi, esi\r | |
108 | add edi, StackStart\r | |
109 | add eax, dword [edi]\r | |
110 | mov esp, eax\r | |
111 | mov dword [edi], eax\r | |
112 | \r | |
113 | Releaselock:\r | |
114 | \r | |
115 | mov al, VacantFlag\r | |
116 | mov edi, esi\r | |
117 | add edi, LockLocation\r | |
118 | xchg byte [edi], al\r | |
119 | \r | |
120 | ;\r | |
121 | ; Call assembly function to initialize FPU.\r | |
122 | ;\r | |
123 | mov ebx, ASM_PFX(InitializeFloatingPointUnits)\r | |
124 | call ebx\r | |
125 | ;\r | |
126 | ; Call C Function\r | |
127 | ;\r | |
128 | mov edi, esi\r | |
129 | add edi, RendezvousProc\r | |
130 | mov eax, dword [edi]\r | |
131 | \r | |
132 | test eax, eax\r | |
133 | jz GoToSleep\r | |
134 | call eax ; Call C function\r | |
135 | \r | |
136 | GoToSleep:\r | |
137 | cli\r | |
138 | hlt\r | |
139 | jmp $-2\r | |
140 | \r | |
141 | RendezvousFunnelProcEnd:\r | |
142 | ;-------------------------------------------------------------------------------------\r | |
143 | ; AsmGetAddressMap (&AddressMap);\r | |
144 | ;-------------------------------------------------------------------------------------\r | |
145 | global ASM_PFX(AsmGetAddressMap)\r | |
146 | ASM_PFX(AsmGetAddressMap):\r | |
147 | \r | |
148 | pushad\r | |
149 | mov ebp,esp\r | |
150 | \r | |
151 | mov ebx, dword [ebp+0x24]\r | |
152 | mov dword [ebx], RendezvousFunnelProcStart\r | |
153 | mov dword [ebx+0x4], PMODE_ENTRY - RendezvousFunnelProcStart\r | |
154 | mov dword [ebx+0x8], FLAT32_JUMP - RendezvousFunnelProcStart\r | |
155 | mov dword [ebx+0xc], RendezvousFunnelProcEnd - RendezvousFunnelProcStart\r | |
156 | \r | |
157 | popad\r | |
158 | ret\r | |
159 | \r |