1;------------------------------------------------------------------------------ ; 2; Copyright (c) 2009 - 2015, 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.Asm 14; 15; Abstract: 16; 17; Functions for relocating SMBASE's for all processors 18; 19;------------------------------------------------------------------------------- 20 21 .686p 22 .xmm 23 .model flat,C 24 25SmmInitHandler PROTO C 26 27EXTERNDEF C gSmmCr0:DWORD 28EXTERNDEF C gSmmCr3:DWORD 29EXTERNDEF C gSmmCr4:DWORD 30EXTERNDEF C gcSmmInitTemplate:BYTE 31EXTERNDEF C gcSmmInitSize:WORD 32EXTERNDEF C gSmmJmpAddr:QWORD 33EXTERNDEF C mRebasedFlag:PTR BYTE 34EXTERNDEF C mSmmRelocationOriginalAddress:DWORD 35EXTERNDEF C gSmmInitStack:DWORD 36EXTERNDEF C gcSmiInitGdtr:FWORD 37 38PROTECT_MODE_CS EQU 08h 39PROTECT_MODE_DS EQU 20h 40 41 .code 42 43gcSmiInitGdtr LABEL FWORD 44 DW 0 45 DQ 0 46 47SmmStartup PROC 48 DB 66h, 0b8h 49gSmmCr3 DD ? 50 mov cr3, eax 51 DB 67h, 66h 52 lgdt fword ptr cs:[ebp + (offset gcSmiInitGdtr - SmmStartup)] 53 DB 66h, 0b8h 54gSmmCr4 DD ? 55 mov cr4, eax 56 DB 66h, 0b8h 57gSmmCr0 DD ? 58 DB 0bfh, PROTECT_MODE_DS, 0 ; mov di, PROTECT_MODE_DS 59 mov cr0, eax 60 DB 66h, 0eah ; jmp far [ptr48] 61gSmmJmpAddr LABEL QWORD 62 DD @32bit 63 DW PROTECT_MODE_CS 64@32bit: 65 mov ds, edi 66 mov es, edi 67 mov fs, edi 68 mov gs, edi 69 mov ss, edi 70 DB 0bch ; mov esp, imm32 71gSmmInitStack DD ? 72 call SmmInitHandler 73 rsm 74SmmStartup ENDP 75 76gcSmmInitTemplate LABEL BYTE 77 78_SmmInitTemplate PROC 79 DB 66h 80 mov ebp, SmmStartup 81 DB 66h, 81h, 0edh, 00h, 00h, 03h, 00 ; sub ebp, 30000h 82 jmp bp ; jmp ebp actually 83_SmmInitTemplate ENDP 84 85gcSmmInitSize DW $ - gcSmmInitTemplate 86 87SmmRelocationSemaphoreComplete PROC 88 push eax 89 mov eax, mRebasedFlag 90 mov byte ptr [eax], 1 91 pop eax 92 jmp [mSmmRelocationOriginalAddress] 93SmmRelocationSemaphoreComplete ENDP 94 END 95