]> git.proxmox.com Git - mirror_edk2.git/commitdiff
CorebootModulePkg/SecCore: Adding NASM files in SecCore module
authorMa, Maurice <maurice.ma@intel.com>
Tue, 2 Aug 2016 19:56:56 +0000 (12:56 -0700)
committerMaurice Ma <maurice.ma@intel.com>
Thu, 4 Aug 2016 00:20:17 +0000 (17:20 -0700)
Ported MASM/GAS assembly files into NASM files and updated the inf
file to refer to NASM files.

This change has been tested with GCC 4.8 and VS2013 build.

Cc: Prince Agyeman <prince.agyeman@intel.com>
Cc: Lee Leahy <leroy.p.leahy@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Maurice Ma <maurice.ma@intel.com>
Reviewed-by: Prince Agyeman <prince.agyeman@intel.com>
CorebootModulePkg/SecCore/Ia32/SecEntry.nasm [new file with mode: 0644]
CorebootModulePkg/SecCore/Ia32/Stack.nasm [new file with mode: 0644]
CorebootModulePkg/SecCore/SecCore.inf

diff --git a/CorebootModulePkg/SecCore/Ia32/SecEntry.nasm b/CorebootModulePkg/SecCore/Ia32/SecEntry.nasm
new file mode 100644 (file)
index 0000000..d3fab89
--- /dev/null
@@ -0,0 +1,72 @@
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2015 - 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
+; Abstract:\r
+;\r
+;   Entry point for the coreboot UEFI payload.\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+SECTION .text\r
+\r
+; C Functions\r
+extern  ASM_PFX(SecStartup)\r
+\r
+; Pcds\r
+extern  ASM_PFX(PcdGet32 (PcdPayloadFdMemBase))\r
+\r
+;\r
+; SecCore Entry Point\r
+;\r
+; Processor is in flat protected mode\r
+;\r
+; @param[in]  EAX   Initial value of the EAX register (BIST: Built-in Self Test)\r
+; @param[in]  DI    'BP': boot-strap processor, or 'AP': application processor\r
+; @param[in]  EBP   Pointer to the start of the Boot Firmware Volume\r
+;\r
+; @return     None  This routine does not return\r
+;\r
+global ASM_PFX(_ModuleEntryPoint)\r
+ASM_PFX(_ModuleEntryPoint):\r
+  ;\r
+  ; Disable all the interrupts\r
+  ;\r
+  cli\r
+  ;\r
+  ; Construct the temporary memory at 0x80000, length 0x10000\r
+  ;\r
+  mov     esp, (BASE_512KB + SIZE_64KB)\r
+\r
+  ;\r
+  ; Pass BFV into the PEI Core\r
+  ;\r
+  push    DWORD [ASM_PFX(PcdGet32 (PcdPayloadFdMemBase))]\r
+\r
+  ;\r
+  ; Pass stack base into the PEI Core\r
+  ;\r
+  push    BASE_512KB\r
+\r
+  ;\r
+  ; Pass stack size into the PEI Core\r
+  ;\r
+  push    SIZE_64KB\r
+\r
+  ;\r
+  ; Pass Control into the PEI Core\r
+  ;\r
+  call    ASM_PFX(SecStartup)\r
+\r
+  ;\r
+  ; Should never return\r
+  ;\r
+  jmp     $\r
+\r
diff --git a/CorebootModulePkg/SecCore/Ia32/Stack.nasm b/CorebootModulePkg/SecCore/Ia32/Stack.nasm
new file mode 100644 (file)
index 0000000..f3362f6
--- /dev/null
@@ -0,0 +1,78 @@
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2015 - 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
+; Abstract:\r
+;\r
+;   Switch the stack from temporary memory to permanent memory.\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+SECTION .text\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; SecSwitchStack (\r
+;   UINT32   TemporaryMemoryBase,\r
+;   UINT32   PermenentMemoryBase\r
+;   );\r
+;------------------------------------------------------------------------------\r
+global ASM_PFX(SecSwitchStack)\r
+ASM_PFX(SecSwitchStack):\r
+    ;\r
+    ; Save three register: eax, ebx, ecx\r
+    ;\r
+    push  eax\r
+    push  ebx\r
+    push  ecx\r
+    push  edx\r
+\r
+    ;\r
+    ; !!CAUTION!! this function address's is pushed into stack after\r
+    ; migration of whole temporary memory, so need save it to permanent\r
+    ; memory at first!\r
+    ;\r
+\r
+    mov   ebx,  [esp + 20]          ; Save the first parameter\r
+    mov   ecx,  [esp + 24]          ; Save the second parameter\r
+\r
+    ;\r
+    ; Save this function's return address into permanent memory at first.\r
+    ; Then, Fixup the esp point to permanent memory\r
+    ;\r
+    mov   eax,  esp\r
+    sub   eax,  ebx\r
+    add   eax,  ecx\r
+    mov   edx,  [esp]               ; copy pushed register's value to permanent memory\r
+    mov   [eax], edx\r
+    mov   edx,  [esp + 4]\r
+    mov   [eax + 4], edx\r
+    mov   edx,  [esp + 8]\r
+    mov   [eax + 8], edx\r
+    mov   edx,  [esp + 12]\r
+    mov   [eax + 12], edx\r
+    mov   edx,  [esp + 16]          ; Update return address into permanent memory\r
+    mov   [eax + 16], edx\r
+    mov   esp,  eax                 ; From now, esp is pointed to permanent memory\r
+\r
+    ;\r
+    ; Fixup the ebp point to permenent memory\r
+    ;\r
+    mov   eax,  ebp\r
+    sub   eax,  ebx\r
+    add   eax,  ecx\r
+    mov   ebp,  eax                 ; From now, ebp is pointed to permanent memory\r
+\r
+    pop   edx\r
+    pop   ecx\r
+    pop   ebx\r
+    pop   eax\r
+    ret\r
index f8468f4c24afcef8ccd1522284adf4965c1cea5b..3eb8aa029b6427927886edf0b2209ee0122fa8fc 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This is the first module taking control from the coreboot.\r
 #\r
 ## @file\r
 # This is the first module taking control from the coreboot.\r
 #\r
-#  Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
   FindPeiCore.c\r
 \r
 [Sources.IA32]\r
   FindPeiCore.c\r
 \r
 [Sources.IA32]\r
-  Ia32/Stack.asm     | MSFT\r
-  Ia32/Stack.S       | GCC\r
-  Ia32/SecEntry.asm  | MSFT\r
-  Ia32/SecEntry.S    | GCC\r
+  Ia32/Stack.nasm\r
+  Ia32/SecEntry.nasm\r
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r