]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFsp2Pkg/FspSecCore/X64/FspHelper.nasm
IntelFsp2Pkg: FspSecCore support for X64
[mirror_edk2.git] / IntelFsp2Pkg / FspSecCore / X64 / FspHelper.nasm
diff --git a/IntelFsp2Pkg/FspSecCore/X64/FspHelper.nasm b/IntelFsp2Pkg/FspSecCore/X64/FspHelper.nasm
new file mode 100644 (file)
index 0000000..122fa1d
--- /dev/null
@@ -0,0 +1,34 @@
+;; @file\r
+;  Provide FSP helper function.\r
+;\r
+; Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>\r
+; SPDX-License-Identifier: BSD-2-Clause-Patent\r
+;;\r
+    DEFAULT  REL\r
+    SECTION .text\r
+\r
+global ASM_PFX(AsmGetFspBaseAddress)\r
+ASM_PFX(AsmGetFspBaseAddress):\r
+   call  ASM_PFX(AsmGetFspInfoHeader)\r
+   add   rax, 0x1C\r
+   mov   eax, [rax]\r
+   ret\r
+\r
+global ASM_PFX(AsmGetFspInfoHeader)\r
+ASM_PFX(AsmGetFspInfoHeader):\r
+   lea   rax, [ASM_PFX(AsmGetFspInfoHeader)]\r
+   DB    0x48, 0x2d               ; sub rax, 0x????????\r
+global ASM_PFX(FspInfoHeaderRelativeOff)\r
+ASM_PFX(FspInfoHeaderRelativeOff):\r
+   DD    0x12345678               ; This value must be patched by the build script\r
+   and   rax, 0xffffffff\r
+   ret\r
+\r
+global ASM_PFX(AsmGetFspInfoHeaderNoStack)\r
+ASM_PFX(AsmGetFspInfoHeaderNoStack):\r
+   lea   rax, [ASM_PFX(AsmGetFspInfoHeader)]\r
+   lea   rcx, [ASM_PFX(FspInfoHeaderRelativeOff)]\r
+   mov   ecx, [rcx]\r
+   sub   rax, rcx\r
+   and   rax, 0xffffffff\r
+   jmp   rdi\r