]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.S
UefiCpuPkg: Add PiSmmCpuDxeSmm module IA32 files
[mirror_edk2.git] / UefiCpuPkg / PiSmmCpuDxeSmm / Ia32 / SmmInit.S
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.S b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.S
new file mode 100644 (file)
index 0000000..e8db33a
--- /dev/null
@@ -0,0 +1,84 @@
+#------------------------------------------------------------------------------\r
+#\r
+# Copyright (c) 2009 - 2015, 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
+#   SmmInit.S\r
+#\r
+# Abstract:\r
+#\r
+#   Functions for relocating SMBASE's for all processors\r
+#\r
+#------------------------------------------------------------------------------\r
+\r
+ASM_GLOBAL   ASM_PFX(gSmmCr0)\r
+ASM_GLOBAL   ASM_PFX(gSmmCr3)\r
+ASM_GLOBAL   ASM_PFX(gSmmCr4)\r
+ASM_GLOBAL   ASM_PFX(gcSmmInitTemplate)\r
+ASM_GLOBAL   ASM_PFX(gcSmmInitSize)\r
+ASM_GLOBAL   ASM_PFX(gSmmJmpAddr)\r
+ASM_GLOBAL   ASM_PFX(SmmRelocationSemaphoreComplete)\r
+ASM_GLOBAL   ASM_PFX(gSmmInitStack)\r
+ASM_GLOBAL   ASM_PFX(gcSmiInitGdtr)\r
+\r
+.equ            PROTECT_MODE_CS, 0x08\r
+.equ            PROTECT_MODE_DS, 0x20\r
+\r
+    .text\r
+\r
+ASM_PFX(gcSmiInitGdtr):\r
+            .word      0\r
+            .quad      0\r
+\r
+SmmStartup:\r
+    .byte   0x66,0xb8\r
+ASM_PFX(gSmmCr3):    .space     4\r
+    movl    %eax, %cr3\r
+    .byte   0x67,0x66\r
+    lgdt    %cs:(ASM_PFX(gcSmiInitGdtr) - SmmStartup)(%ebp)\r
+    .byte   0x66,0xb8\r
+ASM_PFX(gSmmCr4):    .space     4\r
+    movl    %eax, %cr4\r
+    .byte   0x66,0xb8\r
+ASM_PFX(gSmmCr0):    .space     4\r
+    .byte   0xbf, PROTECT_MODE_DS, 0      # mov di, PROTECT_MODE_DS\r
+    movl    %eax, %cr0\r
+    .byte   0x66,0xea                     # jmp far [ptr48]\r
+ASM_PFX(gSmmJmpAddr): .long Start32bit\r
+    .word   PROTECT_MODE_CS\r
+Start32bit:\r
+    movl    %edi,%ds\r
+    movl    %edi,%es\r
+    movl    %edi,%fs\r
+    movl    %edi,%gs\r
+    movl    %edi,%ss\r
+    .byte   0xbc                        # mov esp, imm32\r
+ASM_PFX(gSmmInitStack):  .space  4\r
+    call    ASM_PFX(SmmInitHandler)\r
+    rsm\r
+\r
+ASM_PFX(gcSmmInitTemplate):\r
+\r
+_SmmInitTemplate:\r
+    .byte 0x66\r
+    movl    $SmmStartup, %ebp\r
+    .byte 0x66, 0x81, 0xed, 0, 0, 3, 0  # sub ebp, 0x30000\r
+    jmp     *%bp                        # jmp ebp actually\r
+\r
+ASM_PFX(gcSmmInitSize):   .word  . - ASM_PFX(gcSmmInitTemplate)\r
+\r
+\r
+ASM_PFX(SmmRelocationSemaphoreComplete):\r
+    pushl   %eax\r
+    movl    ASM_PFX(mRebasedFlag), %eax\r
+    movb    $1, (%eax)\r
+    popl    %eax\r
+    jmp     *ASM_PFX(mSmmRelocationOriginalAddress)\r