Add initial version of Open Virtual Machine Firmware (OVMF) platform.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8398 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
51
OvmfPkg/ResetVector/Ia32/32FlatTo64Flat.asm
Normal file
51
OvmfPkg/ResetVector/Ia32/32FlatTo64Flat.asm
Normal file
@@ -0,0 +1,51 @@
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; Copyright (c) 2008, Intel Corporation
|
||||
; All rights reserved. This program and the accompanying materials
|
||||
; are licensed and made available under the terms and conditions of the BSD License
|
||||
; which accompanies this distribution. The full text of the license may be found at
|
||||
; http://opensource.org/licenses/bsd-license.php
|
||||
;
|
||||
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; 32FlatTo64Flat.asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; Transition from 32 bit flat protected mode into 64 bit flat protected mode
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
BITS 32
|
||||
|
||||
Transition32FlatTo64Flat:
|
||||
|
||||
mov eax, ((ADDR_OF_START_OF_RESET_CODE & ~0xfff) - 0x1000)
|
||||
mov cr3, eax
|
||||
|
||||
mov eax, cr4
|
||||
bts eax, 5 ; enable PAE
|
||||
mov cr4, eax
|
||||
|
||||
mov ecx, 0xc0000080
|
||||
rdmsr
|
||||
bts eax, 8 ; set LME
|
||||
wrmsr
|
||||
|
||||
mov eax, cr0
|
||||
bts eax, 31 ; set PG
|
||||
mov cr0, eax ; enable paging
|
||||
|
||||
jmp LINEAR_CODE64_SEL:ADDR_OF(jumpTo64BitAndLandHere)
|
||||
BITS 64
|
||||
jumpTo64BitAndLandHere:
|
||||
|
||||
writeToSerialPort '6'
|
||||
writeToSerialPort '4'
|
||||
writeToSerialPort ' '
|
||||
|
||||
OneTimeCallRet Transition32FlatTo64Flat
|
||||
|
88
OvmfPkg/ResetVector/Ia32/SearchForBfvBase.asm
Normal file
88
OvmfPkg/ResetVector/Ia32/SearchForBfvBase.asm
Normal file
@@ -0,0 +1,88 @@
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; Copyright (c) 2008, Intel Corporation
|
||||
; All rights reserved. This program and the accompanying materials
|
||||
; are licensed and made available under the terms and conditions of the BSD License
|
||||
; which accompanies this distribution. The full text of the license may be found at
|
||||
; http://opensource.org/licenses/bsd-license.php
|
||||
;
|
||||
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; SearchForBfvBase.asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; Search for the Boot FV Base Address
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
;#define EFI_FIRMWARE_FILE_SYSTEM2_GUID \
|
||||
; { 0x8c8ce578, 0x8a3d, 0x4f1c, { 0x99, 0x35, 0x89, 0x61, 0x85, 0xc3, 0x2d, 0xd3 } }
|
||||
%define FFS_GUID_DWORD0 0x8c8ce578
|
||||
%define FFS_GUID_DWORD1 0x4f1c8a3d
|
||||
%define FFS_GUID_DWORD2 0x61893599
|
||||
%define FFS_GUID_DWORD3 0xd32dc385
|
||||
|
||||
BITS 32
|
||||
|
||||
;
|
||||
; Input:
|
||||
; None
|
||||
;
|
||||
; Output:
|
||||
; EBP - BFV Base Address
|
||||
;
|
||||
; Modified:
|
||||
; EAX, EBX
|
||||
;
|
||||
Flat32SearchForBfvBase:
|
||||
|
||||
xor eax, eax
|
||||
searchingForBfvHeaderLoop:
|
||||
sub eax, 0x1000
|
||||
cmp eax, 0xff800000
|
||||
jb searchedForBfvHeaderButNotFound
|
||||
|
||||
;
|
||||
; Check FFS GUID
|
||||
;
|
||||
cmp dword [eax + 0x10], FFS_GUID_DWORD0
|
||||
jne searchingForBfvHeaderLoop
|
||||
cmp dword [eax + 0x14], FFS_GUID_DWORD1
|
||||
jne searchingForBfvHeaderLoop
|
||||
cmp dword [eax + 0x18], FFS_GUID_DWORD2
|
||||
jne searchingForBfvHeaderLoop
|
||||
cmp dword [eax + 0x1c], FFS_GUID_DWORD3
|
||||
jne searchingForBfvHeaderLoop
|
||||
|
||||
;
|
||||
; Check FV Length
|
||||
;
|
||||
cmp dword [eax + 0x24], 0
|
||||
jne searchingForBfvHeaderLoop
|
||||
mov ebx, eax
|
||||
add ebx, dword [eax + 0x20]
|
||||
jnz searchingForBfvHeaderLoop
|
||||
|
||||
jmp searchedForBfvHeaderAndItWasFound
|
||||
|
||||
searchedForBfvHeaderButNotFound:
|
||||
writeToSerialPort '!'
|
||||
xor eax, eax
|
||||
|
||||
searchedForBfvHeaderAndItWasFound:
|
||||
mov ebp, eax
|
||||
|
||||
writeToSerialPort 'B'
|
||||
writeToSerialPort 'F'
|
||||
writeToSerialPort 'V'
|
||||
writeToSerialPort ' '
|
||||
|
||||
or ebp, ebp
|
||||
jz $
|
||||
|
||||
OneTimeCallRet Flat32SearchForBfvBase
|
||||
|
199
OvmfPkg/ResetVector/Ia32/SearchForSecAndPeiEntries.asm
Normal file
199
OvmfPkg/ResetVector/Ia32/SearchForSecAndPeiEntries.asm
Normal file
@@ -0,0 +1,199 @@
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; Copyright (c) 2008, Intel Corporation
|
||||
; All rights reserved. This program and the accompanying materials
|
||||
; are licensed and made available under the terms and conditions of the BSD License
|
||||
; which accompanies this distribution. The full text of the license may be found at
|
||||
; http://opensource.org/licenses/bsd-license.php
|
||||
;
|
||||
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; SearchForSecAndPeiEntry.asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; Search for the SEC Core and PEI Core entry points
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
BITS 32
|
||||
|
||||
%define EFI_FV_FILETYPE_SECURITY_CORE 0x03
|
||||
%define EFI_FV_FILETYPE_PEI_CORE 0x04
|
||||
|
||||
;
|
||||
; Input:
|
||||
; EBP - BFV Base Address
|
||||
;
|
||||
; Output:
|
||||
; ESI - SEC Core Entry Point Address (or 0 if not found)
|
||||
; EDI - PEI Core Entry Point Address (or 0 if not found)
|
||||
;
|
||||
; Modified:
|
||||
; EAX, EBX, ECX
|
||||
;
|
||||
Flat32SearchForSecAndPeiEntries:
|
||||
|
||||
;
|
||||
; Initialize EBP and ESI to 0
|
||||
;
|
||||
xor ebx, ebx
|
||||
mov esi, ebx
|
||||
mov edi, ebx
|
||||
|
||||
;
|
||||
; Pass over the BFV header
|
||||
;
|
||||
mov eax, ebp
|
||||
mov bx, [ebp + 0x30]
|
||||
add eax, ebx
|
||||
jc doneSeachingForSecAndPeiEntries
|
||||
|
||||
jmp searchingForFfsFileHeaderLoop
|
||||
|
||||
moveForwardWhileSearchingForFfsFileHeaderLoop:
|
||||
;
|
||||
; Make forward progress in the search
|
||||
;
|
||||
inc eax
|
||||
jc doneSeachingForSecAndPeiEntries
|
||||
|
||||
searchingForFfsFileHeaderLoop:
|
||||
test eax, eax
|
||||
jz doneSeachingForSecAndPeiEntries
|
||||
|
||||
;
|
||||
; Ensure 8 byte alignment
|
||||
;
|
||||
add eax, 7
|
||||
jc doneSeachingForSecAndPeiEntries
|
||||
and al, 0xf8
|
||||
|
||||
;
|
||||
; Look to see if there is an FFS file at eax
|
||||
;
|
||||
mov bl, [eax + 0x17]
|
||||
test bl, 0x20
|
||||
jz moveForwardWhileSearchingForFfsFileHeaderLoop
|
||||
mov ecx, [eax + 0x14]
|
||||
and ecx, 0x00ffffff
|
||||
or ecx, ecx
|
||||
jz moveForwardWhileSearchingForFfsFileHeaderLoop
|
||||
; jmp $
|
||||
add ecx, eax
|
||||
jz jumpSinceWeFoundTheLastFfsFile
|
||||
jc moveForwardWhileSearchingForFfsFileHeaderLoop
|
||||
jumpSinceWeFoundTheLastFfsFile:
|
||||
|
||||
;
|
||||
; There seems to be a valid file at eax
|
||||
;
|
||||
mov bl, [eax + 0x12] ; BL - File Type
|
||||
cmp bl, EFI_FV_FILETYPE_PEI_CORE
|
||||
je fileTypeIsPeiCore
|
||||
cmp bl, EFI_FV_FILETYPE_SECURITY_CORE
|
||||
jne readyToTryFfsFileAtEcx
|
||||
|
||||
fileTypeIsSecCore:
|
||||
callEdx GetEntryPointOfFfsFileReturnEdx
|
||||
test eax, eax
|
||||
jz readyToTryFfsFileAtEcx
|
||||
|
||||
mov esi, eax
|
||||
jmp readyToTryFfsFileAtEcx
|
||||
|
||||
fileTypeIsPeiCore:
|
||||
callEdx GetEntryPointOfFfsFileReturnEdx
|
||||
test eax, eax
|
||||
jz readyToTryFfsFileAtEcx
|
||||
|
||||
mov edi, eax
|
||||
|
||||
readyToTryFfsFileAtEcx:
|
||||
mov eax, ecx
|
||||
jmp searchingForFfsFileHeaderLoop
|
||||
|
||||
doneSeachingForSecAndPeiEntries:
|
||||
|
||||
test esi, esi
|
||||
jnz secCoreEntryPointWasFound
|
||||
writeToSerialPort '!'
|
||||
secCoreEntryPointWasFound:
|
||||
writeToSerialPort 'S'
|
||||
writeToSerialPort 'E'
|
||||
writeToSerialPort 'C'
|
||||
writeToSerialPort ' '
|
||||
|
||||
test edi, edi
|
||||
jnz peiCoreEntryPointWasFound
|
||||
writeToSerialPort '!'
|
||||
peiCoreEntryPointWasFound:
|
||||
writeToSerialPort 'P'
|
||||
writeToSerialPort 'E'
|
||||
writeToSerialPort 'I'
|
||||
writeToSerialPort ' '
|
||||
|
||||
OneTimeCallRet Flat32SearchForSecAndPeiEntries
|
||||
|
||||
|
||||
%define EFI_SECTION_PE32 0x10
|
||||
|
||||
;
|
||||
; Input:
|
||||
; EAX - Start of FFS file
|
||||
;
|
||||
; Output:
|
||||
; EAX - Entry point of PE32 (or 0 if not found)
|
||||
;
|
||||
; Modified:
|
||||
; EBX
|
||||
;
|
||||
GetEntryPointOfFfsFileReturnEdx:
|
||||
test eax, eax
|
||||
jz getEntryPointOfFfsFileErrorReturn
|
||||
|
||||
cmp byte [eax + 0x1b], EFI_SECTION_PE32
|
||||
jne getEntryPointOfFfsFileErrorReturn
|
||||
|
||||
add eax, 0x1c ; EAX = Start of PE32 image
|
||||
|
||||
mov ebx, eax
|
||||
cmp word [eax], 'MZ'
|
||||
jne thereIsNotAnMzSignature
|
||||
movzx ebx, word [eax + 0x3c]
|
||||
add ebx, eax
|
||||
thereIsNotAnMzSignature:
|
||||
|
||||
; if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE)
|
||||
cmp word [ebx], 'VZ'
|
||||
jne thereIsNoVzSignature
|
||||
; *EntryPoint = (VOID *)((UINTN)Pe32Data +
|
||||
; (UINTN)(Hdr.Te->AddressOfEntryPoint & 0x0ffffffff) +
|
||||
; sizeof(EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize);
|
||||
add eax, [ebx + 0x8]
|
||||
add eax, 0x28
|
||||
movzx ebx, word [ebx + 0x6]
|
||||
sub eax, ebx
|
||||
jmp getEntryPointOfFfsFileReturn
|
||||
|
||||
thereIsNoVzSignature:
|
||||
|
||||
; if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE)
|
||||
cmp dword [ebx], `PE\x00\x00`
|
||||
jne getEntryPointOfFfsFileErrorReturn
|
||||
|
||||
; *EntryPoint = (VOID *)((UINTN)Pe32Data +
|
||||
; (UINTN)(Hdr.Pe32->OptionalHeader.AddressOfEntryPoint & 0x0ffffffff));
|
||||
add eax, [ebx + 0x4 + 0x14 + 0x10]
|
||||
jmp getEntryPointOfFfsFileReturn
|
||||
|
||||
getEntryPointOfFfsFileErrorReturn:
|
||||
mov eax, 0
|
||||
|
||||
getEntryPointOfFfsFileReturn:
|
||||
jmp edx
|
||||
|
||||
|
Reference in New Issue
Block a user