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