]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg PiSmmCpuDxeSmm: Convert Ia32/MpFuncs.asm to NASM
authorLiming Gao <liming.gao@intel.com>
Tue, 14 Jun 2016 08:24:02 +0000 (16:24 +0800)
committerLiming Gao <liming.gao@intel.com>
Tue, 28 Jun 2016 01:52:13 +0000 (09:52 +0800)
The BaseTools/Scripts/ConvertMasmToNasm.py script was used to convert
Ia32/MpFuncs.asm to Ia32/MpFuncs.nasm.
And, manually update it to pass build.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.nasm [new file with mode: 0644]

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.nasm b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.nasm
new file mode 100644 (file)
index 0000000..fceaaf2
--- /dev/null
@@ -0,0 +1,164 @@
+;------------------------------------------------------------------------------ ;\r
+; Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+; This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution.  The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php.\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+;   MpFuncs.nasm\r
+;\r
+; Abstract:\r
+;\r
+;   This is the assembly code for Multi-processor S3 support\r
+;\r
+;-------------------------------------------------------------------------------\r
+\r
+SECTION .text\r
+\r
+extern ASM_PFX(InitializeFloatingPointUnits)\r
+\r
+%define VacantFlag 0x0\r
+%define NotVacantFlag 0xff\r
+\r
+%define LockLocation RendezvousFunnelProcEnd - RendezvousFunnelProcStart\r
+%define StackStart LockLocation + 0x4\r
+%define StackSize LockLocation + 0x8\r
+%define RendezvousProc LockLocation + 0xC\r
+%define GdtrProfile LockLocation + 0x10\r
+%define IdtrProfile LockLocation + 0x16\r
+%define BufferStart LockLocation + 0x1C\r
+\r
+;-------------------------------------------------------------------------------------\r
+;RendezvousFunnelProc  procedure follows. All APs execute their procedure. This\r
+;procedure serializes all the AP processors through an Init sequence. It must be\r
+;noted that APs arrive here very raw...ie: real mode, no stack.\r
+;ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC\r
+;IS IN MACHINE CODE.\r
+;-------------------------------------------------------------------------------------\r
+;RendezvousFunnelProc (&WakeUpBuffer,MemAddress);\r
+\r
+global ASM_PFX(RendezvousFunnelProc)\r
+ASM_PFX(RendezvousFunnelProc):\r
+RendezvousFunnelProcStart:\r
+\r
+; At this point CS = 0x(vv00) and ip= 0x0.\r
+\r
+        db 0x8c,  0xc8                 ; mov        ax,  cs\r
+        db 0x8e,  0xd8                 ; mov        ds,  ax\r
+        db 0x8e,  0xc0                 ; mov        es,  ax\r
+        db 0x8e,  0xd0                 ; mov        ss,  ax\r
+        db 0x33,  0xc0                 ; xor        ax,  ax\r
+        db 0x8e,  0xe0                 ; mov        fs,  ax\r
+        db 0x8e,  0xe8                 ; mov        gs,  ax\r
+\r
+flat32Start:\r
+\r
+        db 0xBE\r
+        dw BufferStart                ; mov        si, BufferStart\r
+        db 0x66,  0x8B, 0x14             ; mov        edx,dword ptr [si]          ; EDX is keeping the start address of wakeup buffer\r
+\r
+        db 0xBE\r
+        dw GdtrProfile                ; mov        si, GdtrProfile\r
+        db 0x66                        ; db         66h\r
+        db 0x2E,  0xF, 0x1, 0x14        ; lgdt       fword ptr cs:[si]\r
+\r
+        db 0xBE\r
+        dw IdtrProfile                ; mov        si, IdtrProfile\r
+        db 0x66                        ; db         66h\r
+        db 0x2E,  0xF, 0x1, 0x1C        ; lidt       fword ptr cs:[si]\r
+\r
+        db 0x33,  0xC0                 ; xor        ax,  ax\r
+        db 0x8E,  0xD8                 ; mov        ds,  ax\r
+\r
+        db 0xF,  0x20, 0xC0            ; mov        eax, cr0                    ; Get control register 0\r
+        db 0x66,  0x83, 0xC8, 0x1       ; or         eax, 000000001h             ; Set PE bit (bit #0)\r
+        db 0xF,  0x22, 0xC0            ; mov        cr0, eax\r
+\r
+FLAT32_JUMP:\r
+\r
+        db 0x66,  0x67, 0xEA            ; far jump\r
+        dd 0x0                         ; 32-bit offset\r
+        dw 0x20                        ; 16-bit selector\r
+\r
+PMODE_ENTRY:                         ; protected mode entry point\r
+\r
+        mov         ax,  0x8\r
+o16     mov         ds,  ax\r
+o16     mov         es,  ax\r
+o16     mov         fs,  ax\r
+o16     mov         gs,  ax\r
+o16     mov         ss,  ax           ; Flat mode setup.\r
+\r
+        mov         esi, edx\r
+\r
+        mov         edi, esi\r
+        add         edi, LockLocation\r
+        mov         al,  NotVacantFlag\r
+TestLock:\r
+        xchg        byte [edi], al\r
+        cmp         al, NotVacantFlag\r
+        jz          TestLock\r
+\r
+ProgramStack:\r
+\r
+        mov         edi, esi\r
+        add         edi, StackSize\r
+        mov         eax, dword [edi]\r
+        mov         edi, esi\r
+        add         edi, StackStart\r
+        add         eax, dword [edi]\r
+        mov         esp, eax\r
+        mov         dword [edi], eax\r
+\r
+Releaselock:\r
+\r
+        mov         al,  VacantFlag\r
+        mov         edi, esi\r
+        add         edi, LockLocation\r
+        xchg        byte [edi], al\r
+\r
+        ;\r
+        ; Call assembly function to initialize FPU.\r
+        ;\r
+        mov         ebx, ASM_PFX(InitializeFloatingPointUnits)\r
+        call        ebx\r
+        ;\r
+        ; Call C Function\r
+        ;\r
+        mov         edi, esi\r
+        add         edi, RendezvousProc\r
+        mov         eax, dword [edi]\r
+\r
+        test        eax, eax\r
+        jz          GoToSleep\r
+        call        eax                           ; Call C function\r
+\r
+GoToSleep:\r
+        cli\r
+        hlt\r
+        jmp         $-2\r
+\r
+RendezvousFunnelProcEnd:\r
+;-------------------------------------------------------------------------------------\r
+;  AsmGetAddressMap (&AddressMap);\r
+;-------------------------------------------------------------------------------------\r
+global ASM_PFX(AsmGetAddressMap)\r
+ASM_PFX(AsmGetAddressMap):\r
+\r
+        pushad\r
+        mov         ebp,esp\r
+\r
+        mov         ebx, dword [ebp+0x24]\r
+        mov         dword [ebx], RendezvousFunnelProcStart\r
+        mov         dword [ebx+0x4], PMODE_ENTRY - RendezvousFunnelProcStart\r
+        mov         dword [ebx+0x8], FLAT32_JUMP - RendezvousFunnelProcStart\r
+        mov         dword [ebx+0xc], RendezvousFunnelProcEnd - RendezvousFunnelProcStart\r
+\r
+        popad\r
+        ret\r
+\r