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; SmmInit.nasm 14; 15; Abstract: 16; 17; Functions for relocating SMBASE's for all processors 18; 19;------------------------------------------------------------------------------- 20 21extern ASM_PFX(SmmInitHandler) 22extern ASM_PFX(mRebasedFlag) 23extern ASM_PFX(mSmmRelocationOriginalAddress) 24 25global ASM_PFX(gSmmCr3) 26global ASM_PFX(gSmmCr4) 27global ASM_PFX(gSmmCr0) 28global ASM_PFX(gSmmJmpAddr) 29global ASM_PFX(gSmmInitStack) 30global ASM_PFX(gcSmiInitGdtr) 31global ASM_PFX(gcSmmInitSize) 32global ASM_PFX(gcSmmInitTemplate) 33 34%define PROTECT_MODE_CS 0x8 35%define PROTECT_MODE_DS 0x20 36 37 SECTION .text 38 39ASM_PFX(gcSmiInitGdtr): 40 DW 0 41 DQ 0 42 43global ASM_PFX(SmmStartup) 44ASM_PFX(SmmStartup): 45 DB 0x66, 0xb8 46ASM_PFX(gSmmCr3): DD 0 47 mov cr3, eax 48 DB 0x67, 0x66 49 lgdt [cs:ebp + (ASM_PFX(gcSmiInitGdtr) - ASM_PFX(SmmStartup))] 50 DB 0x66, 0xb8 51ASM_PFX(gSmmCr4): DD 0 52 mov cr4, eax 53 DB 0x66, 0xb8 54ASM_PFX(gSmmCr0): DD 0 55 DB 0xbf, PROTECT_MODE_DS, 0 ; mov di, PROTECT_MODE_DS 56 mov cr0, eax 57 DB 0x66, 0xea ; jmp far [ptr48] 58ASM_PFX(gSmmJmpAddr): 59 DD @32bit 60 DW PROTECT_MODE_CS 61@32bit: 62 mov ds, edi 63 mov es, edi 64 mov fs, edi 65 mov gs, edi 66 mov ss, edi 67 DB 0xbc ; mov esp, imm32 68ASM_PFX(gSmmInitStack): DD 0 69 call ASM_PFX(SmmInitHandler) 70 rsm 71 72BITS 16 73ASM_PFX(gcSmmInitTemplate): 74 mov ebp, ASM_PFX(SmmStartup) 75 sub ebp, 0x30000 76 jmp ebp 77 78ASM_PFX(gcSmmInitSize): DW $ - ASM_PFX(gcSmmInitTemplate) 79 80BITS 32 81global ASM_PFX(SmmRelocationSemaphoreComplete) 82ASM_PFX(SmmRelocationSemaphoreComplete): 83 push eax 84 mov eax, [ASM_PFX(mRebasedFlag)] 85 mov byte [eax], 1 86 pop eax 87 jmp [ASM_PFX(mSmmRelocationOriginalAddress)] 88