1#------------------------------------------------------------------------------ 2# 3# Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR> 4# This program and the accompanying materials 5# are licensed and made available under the terms and conditions of the BSD License 6# which accompanies this distribution. The full text of the license may be found at 7# http://opensource.org/licenses/bsd-license.php. 8# 9# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 10# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 11# 12# Module Name: 13# 14# SmmInit.S 15# 16# Abstract: 17# 18# Functions for relocating SMBASE's for all processors 19# 20#------------------------------------------------------------------------------ 21 22ASM_GLOBAL ASM_PFX(gSmmCr0) 23ASM_GLOBAL ASM_PFX(gSmmCr3) 24ASM_GLOBAL ASM_PFX(gSmmCr4) 25ASM_GLOBAL ASM_PFX(gcSmmInitTemplate) 26ASM_GLOBAL ASM_PFX(gcSmmInitSize) 27ASM_GLOBAL ASM_PFX(gSmmJmpAddr) 28ASM_GLOBAL ASM_PFX(SmmRelocationSemaphoreComplete) 29ASM_GLOBAL ASM_PFX(gSmmInitStack) 30ASM_GLOBAL ASM_PFX(gcSmiInitGdtr) 31 32.equ PROTECT_MODE_CS, 0x08 33.equ PROTECT_MODE_DS, 0x20 34 35 .text 36 37ASM_PFX(gcSmiInitGdtr): 38 .word 0 39 .quad 0 40 41SmmStartup: 42 .byte 0x66,0xb8 43ASM_PFX(gSmmCr3): .space 4 44 movl %eax, %cr3 45 .byte 0x67,0x66 46 lgdt %cs:(ASM_PFX(gcSmiInitGdtr) - SmmStartup)(%ebp) 47 .byte 0x66,0xb8 48ASM_PFX(gSmmCr4): .space 4 49 movl %eax, %cr4 50 .byte 0x66,0xb8 51ASM_PFX(gSmmCr0): .space 4 52 .byte 0xbf, PROTECT_MODE_DS, 0 # mov di, PROTECT_MODE_DS 53 movl %eax, %cr0 54 .byte 0x66,0xea # jmp far [ptr48] 55ASM_PFX(gSmmJmpAddr): .long Start32bit 56 .word PROTECT_MODE_CS 57Start32bit: 58 movl %edi,%ds 59 movl %edi,%es 60 movl %edi,%fs 61 movl %edi,%gs 62 movl %edi,%ss 63 .byte 0xbc # mov esp, imm32 64ASM_PFX(gSmmInitStack): .space 4 65 call ASM_PFX(SmmInitHandler) 66 rsm 67 68ASM_PFX(gcSmmInitTemplate): 69 70_SmmInitTemplate: 71 .byte 0x66 72 movl $SmmStartup, %ebp 73 .byte 0x66, 0x81, 0xed, 0, 0, 3, 0 # sub ebp, 0x30000 74 jmp *%bp # jmp ebp actually 75 76ASM_PFX(gcSmmInitSize): .word . - ASM_PFX(gcSmmInitTemplate) 77 78 79ASM_PFX(SmmRelocationSemaphoreComplete): 80 pushl %eax 81 movl ASM_PFX(mRebasedFlag), %eax 82 movb $1, (%eax) 83 popl %eax 84 jmp *ASM_PFX(mSmmRelocationOriginalAddress) 85