Add BaseMemoryTestDxe in MdeModulePkg.dsc
Add RuntimeDxe in MdeModulePkg.dsc Move Security/SecurityStub/Dxe to SecurityStubDxe. Add EFI_MAX_ADDRESS in Uefi/UefiBaseType.h. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2930 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
98b133cf89
commit
ce2f555794
167
MdeModulePkg/Universal/BaseMemoryTestPei/BaseMemoryTest.c
Normal file
167
MdeModulePkg/Universal/BaseMemoryTestPei/BaseMemoryTest.c
Normal file
@ -0,0 +1,167 @@
|
|||||||
|
/*++
|
||||||
|
|
||||||
|
Copyright (c) 2006 - 2007, 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:
|
||||||
|
|
||||||
|
BaseMemoryTest.c
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
The PEI memory test support
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
|
//
|
||||||
|
// The package level header files this module uses
|
||||||
|
//
|
||||||
|
#include <PiPei.h>
|
||||||
|
#include <FrameworkPei.h>
|
||||||
|
//
|
||||||
|
// The protocols, PPI and GUID defintions for this module
|
||||||
|
//
|
||||||
|
#include <Ppi/BaseMemoryTest.h>
|
||||||
|
//
|
||||||
|
// The Library classes this module consumes
|
||||||
|
//
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/PeimEntryPoint.h>
|
||||||
|
#include <Library/ReportStatusCodeLib.h>
|
||||||
|
|
||||||
|
#include <BaseMemoryTest.h>
|
||||||
|
|
||||||
|
static PEI_BASE_MEMORY_TEST_PPI mPeiBaseMemoryTestPpi = { BaseMemoryTest };
|
||||||
|
|
||||||
|
static EFI_PEI_PPI_DESCRIPTOR PpiListPeiBaseMemoryTest = {
|
||||||
|
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
|
||||||
|
&gPeiBaseMemoryTestPpiGuid,
|
||||||
|
&mPeiBaseMemoryTestPpi
|
||||||
|
};
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
PeiBaseMemoryTestInit (
|
||||||
|
IN EFI_FFS_FILE_HEADER *FfsHeader,
|
||||||
|
IN EFI_PEI_SERVICES **PeiServices
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
Description:
|
||||||
|
|
||||||
|
Entry point function of BaseMemoryTestInit Peim.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
PeiServices - General purpose services available to every PEIM.
|
||||||
|
FfsHeader - Ffs header pointer
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
Status - Result of InstallPpi
|
||||||
|
|
||||||
|
--*/
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
Status = (**PeiServices).InstallPpi (PeiServices, &PpiListPeiBaseMemoryTest);
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
BaseMemoryTest (
|
||||||
|
IN EFI_PEI_SERVICES **PeiServices,
|
||||||
|
IN PEI_BASE_MEMORY_TEST_PPI *This,
|
||||||
|
IN EFI_PHYSICAL_ADDRESS BeginAddress,
|
||||||
|
IN UINT64 MemoryLength,
|
||||||
|
IN PEI_MEMORY_TEST_OP Operation,
|
||||||
|
OUT EFI_PHYSICAL_ADDRESS *ErrorAddress
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
Description:
|
||||||
|
|
||||||
|
Test base memory.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
PeiServices - General purpose services available to every PEIM.
|
||||||
|
This - Pei memory test PPI pointer.
|
||||||
|
BeginAddress - Beginning of the memory address to be checked.
|
||||||
|
MemoryLength - Bytes of memory range to be checked.
|
||||||
|
Operation - Type of memory check operation to be performed.
|
||||||
|
ErrorAddress - Return the address of the error memory address.
|
||||||
|
ErrorAddress - Address which has error when checked.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
Status - Result of InstallPpi
|
||||||
|
|
||||||
|
--*/
|
||||||
|
{
|
||||||
|
UINT32 TestPattern;
|
||||||
|
EFI_PHYSICAL_ADDRESS TempAddress;
|
||||||
|
UINT32 SpanSize;
|
||||||
|
|
||||||
|
REPORT_STATUS_CODE (
|
||||||
|
EFI_PROGRESS_CODE,
|
||||||
|
EFI_COMPUTING_UNIT_MEMORY + EFI_CU_MEMORY_PC_TEST
|
||||||
|
);
|
||||||
|
|
||||||
|
TestPattern = TEST_PATTERN;
|
||||||
|
SpanSize = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Make sure we don't try and test anything above the max physical address range
|
||||||
|
//
|
||||||
|
ASSERT (BeginAddress + MemoryLength < EFI_MAX_ADDRESS);
|
||||||
|
|
||||||
|
switch (Operation) {
|
||||||
|
case Extensive:
|
||||||
|
SpanSize = 0x4;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Sparse:
|
||||||
|
case Quick:
|
||||||
|
SpanSize = COVER_SPAN;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Ignore:
|
||||||
|
goto Done;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Write the test pattern into memory range
|
||||||
|
//
|
||||||
|
TempAddress = BeginAddress;
|
||||||
|
while (TempAddress < BeginAddress + MemoryLength) {
|
||||||
|
(*(UINT32 *) (UINTN) TempAddress) = TestPattern;
|
||||||
|
TempAddress += SpanSize;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Read pattern from memory and compare it
|
||||||
|
//
|
||||||
|
TempAddress = BeginAddress;
|
||||||
|
while (TempAddress < BeginAddress + MemoryLength) {
|
||||||
|
if ((*(UINT32 *) (UINTN) TempAddress) != TestPattern) {
|
||||||
|
*ErrorAddress = TempAddress;
|
||||||
|
REPORT_STATUS_CODE (
|
||||||
|
EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED,
|
||||||
|
EFI_COMPUTING_UNIT_MEMORY | EFI_CU_MEMORY_EC_UNCORRECTABLE
|
||||||
|
);
|
||||||
|
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
TempAddress += SpanSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
Done:
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
87
MdeModulePkg/Universal/BaseMemoryTestPei/BaseMemoryTest.h
Normal file
87
MdeModulePkg/Universal/BaseMemoryTestPei/BaseMemoryTest.h
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
/*++
|
||||||
|
|
||||||
|
Copyright (c) 2006 - 2007, 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:
|
||||||
|
|
||||||
|
BaseMemoryTest.h
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
Tiano PEIM to provide a PEI memory test service.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
|
#ifndef _PEI_BASE_MEMORY_TEST_H_
|
||||||
|
#define _PEI_BASE_MEMORY_TEST_H_
|
||||||
|
|
||||||
|
//
|
||||||
|
// Some global define
|
||||||
|
//
|
||||||
|
#define COVER_SPAN 0x40000
|
||||||
|
#define TEST_PATTERN 0x5A5A5A5A
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
PeiBaseMemoryTestInit (
|
||||||
|
IN EFI_FFS_FILE_HEADER *FfsHeader,
|
||||||
|
IN EFI_PEI_SERVICES **PeiServices
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
TODO: Add function description
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
FfsHeader - TODO: add argument description
|
||||||
|
PeiServices - TODO: add argument description
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
TODO: add return values
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
BaseMemoryTest (
|
||||||
|
IN EFI_PEI_SERVICES **PeiServices,
|
||||||
|
IN PEI_BASE_MEMORY_TEST_PPI *This,
|
||||||
|
IN EFI_PHYSICAL_ADDRESS BeginAddress,
|
||||||
|
IN UINT64 MemoryLength,
|
||||||
|
IN PEI_MEMORY_TEST_OP Operation,
|
||||||
|
OUT EFI_PHYSICAL_ADDRESS *ErrorAddress
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
TODO: Add function description
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
PeiServices - TODO: add argument description
|
||||||
|
This - TODO: add argument description
|
||||||
|
BeginAddress - TODO: add argument description
|
||||||
|
MemoryLength - TODO: add argument description
|
||||||
|
Operation - TODO: add argument description
|
||||||
|
ErrorAddress - TODO: add argument description
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
TODO: add return values
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
#endif
|
91
MdeModulePkg/Universal/BaseMemoryTestPei/BaseMemoryTest.inf
Normal file
91
MdeModulePkg/Universal/BaseMemoryTestPei/BaseMemoryTest.inf
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
#/** @file
|
||||||
|
# Component description file for PeiBaseMemoryTestInit module.
|
||||||
|
#
|
||||||
|
# This driver provides memory test ppi for memory test in Pei Phase.
|
||||||
|
# Copyright (c) 2006 - 2007, 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.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#**/
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Defines Section - statements that will be processed to create a Makefile.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010005
|
||||||
|
BASE_NAME = PeiBaseMemoryTestInit
|
||||||
|
FILE_GUID = 736EB068-8C01-47c5-964B-1C57BD5D4D64
|
||||||
|
MODULE_TYPE = PEIM
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
EDK_RELEASE_VERSION = 0x00020000
|
||||||
|
EFI_SPECIFICATION_VERSION = 0x00020000
|
||||||
|
|
||||||
|
ENTRY_POINT = PeiBaseMemoryTestInit
|
||||||
|
|
||||||
|
#
|
||||||
|
# The following information is for reference only and not required by the build tools.
|
||||||
|
#
|
||||||
|
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||||
|
#
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Sources Section - list of files that are required for the build to succeed.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
[Sources.common]
|
||||||
|
BaseMemoryTest.c
|
||||||
|
BaseMemoryTest.h
|
||||||
|
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Includes Section - list of Include locations that are required for
|
||||||
|
# this module.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Package Dependency Section - list of Package files that are required for
|
||||||
|
# this module.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
IntelFrameworkPkg/IntelFrameworkPkg.dec
|
||||||
|
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Library Class Section - list of Library Classes that are required for
|
||||||
|
# this module.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
ReportStatusCodeLib
|
||||||
|
PeimEntryPoint
|
||||||
|
DebugLib
|
||||||
|
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# PPI C Name Section - list of PPI and PPI Notify C Names that this module
|
||||||
|
# uses or produces.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
[Ppis]
|
||||||
|
gPeiBaseMemoryTestPpiGuid # PPI ALWAYS_PRODUCED
|
||||||
|
|
56
MdeModulePkg/Universal/BaseMemoryTestPei/BaseMemoryTest.msa
Normal file
56
MdeModulePkg/Universal/BaseMemoryTestPei/BaseMemoryTest.msa
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">
|
||||||
|
<MsaHeader>
|
||||||
|
<ModuleName>PeiBaseMemoryTestInit</ModuleName>
|
||||||
|
<ModuleType>PEIM</ModuleType>
|
||||||
|
<GuidValue>736EB068-8C01-47c5-964B-1C57BD5D4D64</GuidValue>
|
||||||
|
<Version>1.0</Version>
|
||||||
|
<Abstract>Component description file for PeiBaseMemoryTestInit module.</Abstract>
|
||||||
|
<Description>This driver provides memory test ppi for memory test in Pei Phase.</Description>
|
||||||
|
<Copyright>Copyright (c) 2006 - 2007, Intel Corporation</Copyright>
|
||||||
|
<License>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.</License>
|
||||||
|
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
|
||||||
|
</MsaHeader>
|
||||||
|
<ModuleDefinitions>
|
||||||
|
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
|
||||||
|
<BinaryModule>false</BinaryModule>
|
||||||
|
<OutputFileBasename>PeiBaseMemoryTestInit</OutputFileBasename>
|
||||||
|
</ModuleDefinitions>
|
||||||
|
<LibraryClassDefinitions>
|
||||||
|
<LibraryClass Usage="ALWAYS_CONSUMED" RecommendedInstanceGuid="bda39d3a-451b-4350-8266-81ab10fa0523">
|
||||||
|
<Keyword>DebugLib</Keyword>
|
||||||
|
<HelpText>Recommended libary Instance is PeiDxeDebugLibReportStatusCode instance in MdePkg.</HelpText>
|
||||||
|
</LibraryClass>
|
||||||
|
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||||
|
<Keyword>PeimEntryPoint</Keyword>
|
||||||
|
</LibraryClass>
|
||||||
|
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||||
|
<Keyword>ReportStatusCodeLib</Keyword>
|
||||||
|
</LibraryClass>
|
||||||
|
</LibraryClassDefinitions>
|
||||||
|
<SourceFiles>
|
||||||
|
<Filename>BaseMemoryTest.h</Filename>
|
||||||
|
<Filename>BaseMemoryTest.c</Filename>
|
||||||
|
</SourceFiles>
|
||||||
|
<PackageDependencies>
|
||||||
|
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||||
|
<Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
|
||||||
|
</PackageDependencies>
|
||||||
|
<PPIs>
|
||||||
|
<Ppi Usage="ALWAYS_PRODUCED">
|
||||||
|
<PpiCName>gPeiBaseMemoryTestPpiGuid</PpiCName>
|
||||||
|
</Ppi>
|
||||||
|
</PPIs>
|
||||||
|
<Externs>
|
||||||
|
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
|
||||||
|
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
|
||||||
|
<Extern>
|
||||||
|
<ModuleEntryPoint>PeiBaseMemoryTestInit</ModuleEntryPoint>
|
||||||
|
</Extern>
|
||||||
|
</Externs>
|
||||||
|
</ModuleSurfaceArea>
|
150
MdeModulePkg/Universal/RuntimeDxe/Crc32.c
Normal file
150
MdeModulePkg/Universal/RuntimeDxe/Crc32.c
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
/*++
|
||||||
|
|
||||||
|
Copyright (c) 2006, 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:
|
||||||
|
|
||||||
|
Crc32.c
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
CalculateCrc32 Boot Services as defined in DXE CIS.
|
||||||
|
|
||||||
|
This Boot Services is in the Runtime Driver because this service is
|
||||||
|
also required by SetVirtualAddressMap() when the EFI System Table and
|
||||||
|
EFI Runtime Services Table are converted from physical address to
|
||||||
|
virtual addresses. This requires that the 32-bit CRC be recomputed.
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
|
//
|
||||||
|
// The package level header files this module uses
|
||||||
|
//
|
||||||
|
#include <PiDxe.h>
|
||||||
|
|
||||||
|
UINT32 mCrcTable[256];
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
RuntimeDriverCalculateCrc32 (
|
||||||
|
IN VOID *Data,
|
||||||
|
IN UINTN DataSize,
|
||||||
|
OUT UINT32 *CrcOut
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
Calculate CRC32 for target data
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
Data - The target data.
|
||||||
|
DataSize - The target data size.
|
||||||
|
CrcOut - The CRC32 for target data.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_SUCCESS - The CRC32 for target data is calculated successfully.
|
||||||
|
EFI_INVALID_PARAMETER - Some parameter is not valid, so the CRC32 is not
|
||||||
|
calculated.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
{
|
||||||
|
UINT32 Crc;
|
||||||
|
UINTN Index;
|
||||||
|
UINT8 *Ptr;
|
||||||
|
|
||||||
|
if (Data == NULL || DataSize == 0 || CrcOut == NULL) {
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
Crc = 0xffffffff;
|
||||||
|
for (Index = 0, Ptr = Data; Index < DataSize; Index++, Ptr++) {
|
||||||
|
Crc = (Crc >> 8) ^ mCrcTable[(UINT8) Crc ^ *Ptr];
|
||||||
|
}
|
||||||
|
|
||||||
|
*CrcOut = Crc ^ 0xffffffff;
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC
|
||||||
|
UINT32
|
||||||
|
ReverseBits (
|
||||||
|
UINT32 Value
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
Reverse bits for 32bit data.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
Value - the data to be reversed.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
UINT32 data reversed.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
{
|
||||||
|
UINTN Index;
|
||||||
|
UINT32 NewValue;
|
||||||
|
|
||||||
|
NewValue = 0;
|
||||||
|
for (Index = 0; Index < 32; Index++) {
|
||||||
|
if (Value & (1 << Index)) {
|
||||||
|
NewValue = NewValue | (1 << (31 - Index));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
RuntimeDriverInitializeCrc32Table (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
Initialize CRC32 table.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
None.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
None.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
{
|
||||||
|
UINTN TableEntry;
|
||||||
|
UINTN Index;
|
||||||
|
UINT32 Value;
|
||||||
|
|
||||||
|
for (TableEntry = 0; TableEntry < 256; TableEntry++) {
|
||||||
|
Value = ReverseBits ((UINT32) TableEntry);
|
||||||
|
for (Index = 0; Index < 8; Index++) {
|
||||||
|
if (Value & 0x80000000) {
|
||||||
|
Value = (Value << 1) ^ 0x04c11db7;
|
||||||
|
} else {
|
||||||
|
Value = Value << 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mCrcTable[TableEntry] = ReverseBits (Value);
|
||||||
|
}
|
||||||
|
}
|
486
MdeModulePkg/Universal/RuntimeDxe/Runtime.c
Normal file
486
MdeModulePkg/Universal/RuntimeDxe/Runtime.c
Normal file
@ -0,0 +1,486 @@
|
|||||||
|
/*++
|
||||||
|
|
||||||
|
Copyright (c) 2006, 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:
|
||||||
|
|
||||||
|
Runtime.c
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
Runtime Architectural Protocol as defined in the DXE CIS
|
||||||
|
|
||||||
|
This code is used to produce the EFI runtime virtual switch over
|
||||||
|
|
||||||
|
THIS IS VERY DANGEROUS CODE BE VERY CAREFUL IF YOU CHANGE IT
|
||||||
|
|
||||||
|
The transition for calling EFI Runtime functions in physical mode to calling
|
||||||
|
them in virtual mode is very very complex. Every pointer in needs to be
|
||||||
|
converted from physical mode to virtual mode. Be very careful walking linked
|
||||||
|
lists! Then to make it really hard the code it's self needs be relocated into
|
||||||
|
the new virtual address space.
|
||||||
|
|
||||||
|
So here is the concept. The code in this module will never ever be called in
|
||||||
|
virtual mode. This is the code that collects the information needed to convert
|
||||||
|
to virtual mode (DXE core registers runtime stuff with this code). Since this
|
||||||
|
code is used to fixup all runtime images, it CAN NOT fix it's self up. So some
|
||||||
|
code has to stay behind and that is us.
|
||||||
|
|
||||||
|
Also you need to be careful about when you allocate memory, as once we are in
|
||||||
|
runtime (including our EVT_SIGNAL_EXIT_BOOT_SERVICES event) you can no longer
|
||||||
|
allocate memory.
|
||||||
|
|
||||||
|
Any runtime driver that gets loaded before us will not be callable in virtual
|
||||||
|
mode. This is due to the fact that the DXE core can not register the info
|
||||||
|
needed with us. This is good, since it keeps the code in this file from
|
||||||
|
getting registered.
|
||||||
|
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
- Move the CalculateCrc32 function from Runtime Arch Protocol to Boot Service.
|
||||||
|
Runtime Arch Protocol definition no longer contains CalculateCrc32. Boot Service
|
||||||
|
Table now contains an item named CalculateCrc32.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
|
//
|
||||||
|
// The package level header files this module uses
|
||||||
|
//
|
||||||
|
#include <PiDxe.h>
|
||||||
|
#include <FrameworkDxe.h>
|
||||||
|
//
|
||||||
|
// The protocols, PPI and GUID defintions for this module
|
||||||
|
//
|
||||||
|
#include <Protocol/LoadedImage.h>
|
||||||
|
#include <Protocol/Runtime.h>
|
||||||
|
#include <Protocol/UgaIo.h>
|
||||||
|
|
||||||
|
//
|
||||||
|
// The Library classes this module consumes
|
||||||
|
//
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
#include <Library/UefiDriverEntryPoint.h>
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/ReportStatusCodeLib.h>
|
||||||
|
#include <Library/BaseMemoryLib.h>
|
||||||
|
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||||
|
#include <Library/UefiBootServicesTableLib.h>
|
||||||
|
#include <Library/CacheMaintenanceLib.h>
|
||||||
|
#include <Library/PeCoffLib.h>
|
||||||
|
|
||||||
|
#include "Runtime.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// Global Variables
|
||||||
|
//
|
||||||
|
EFI_MEMORY_DESCRIPTOR *mVirtualMap = NULL;
|
||||||
|
UINTN mVirtualMapDescriptorSize;
|
||||||
|
UINTN mVirtualMapMaxIndex;
|
||||||
|
VOID *mMyImageBase;
|
||||||
|
|
||||||
|
//
|
||||||
|
// The handle onto which the Runtime Architectural Protocol instance is installed
|
||||||
|
//
|
||||||
|
EFI_HANDLE mRuntimeHandle = NULL;
|
||||||
|
|
||||||
|
//
|
||||||
|
// The Runtime Architectural Protocol instance produced by this driver
|
||||||
|
//
|
||||||
|
EFI_RUNTIME_ARCH_PROTOCOL mRuntime = {
|
||||||
|
INITIALIZE_LIST_HEAD_VARIABLE (mRuntime.ImageHead),
|
||||||
|
INITIALIZE_LIST_HEAD_VARIABLE (mRuntime.EventHead),
|
||||||
|
|
||||||
|
//
|
||||||
|
// Make sure Size != sizeof (EFI_MEMORY_DESCRIPTOR). This will
|
||||||
|
// prevent people from having pointer math bugs in their code.
|
||||||
|
// now you have to use *DescriptorSize to make things work.
|
||||||
|
//
|
||||||
|
sizeof (EFI_MEMORY_DESCRIPTOR) + sizeof (UINT64) - (sizeof (EFI_MEMORY_DESCRIPTOR) % sizeof (UINT64)),
|
||||||
|
EFI_MEMORY_DESCRIPTOR_VERSION,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
FALSE,
|
||||||
|
FALSE
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Worker Functions
|
||||||
|
//
|
||||||
|
STATIC
|
||||||
|
VOID
|
||||||
|
RuntimeDriverCalculateEfiHdrCrc (
|
||||||
|
IN OUT EFI_TABLE_HEADER *Hdr
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
Calcualte the 32-bit CRC in a EFI table using the Runtime Drivers
|
||||||
|
internal function. The EFI Boot Services Table can not be used because
|
||||||
|
the EFI Boot Services Table was destroyed at ExitBootServices()
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
Hdr - Pointer to an EFI standard header
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
None
|
||||||
|
|
||||||
|
--*/
|
||||||
|
{
|
||||||
|
UINT32 Crc;
|
||||||
|
|
||||||
|
Hdr->CRC32 = 0;
|
||||||
|
|
||||||
|
Crc = 0;
|
||||||
|
RuntimeDriverCalculateCrc32 ((UINT8 *) Hdr, Hdr->HeaderSize, &Crc);
|
||||||
|
Hdr->CRC32 = Crc;
|
||||||
|
}
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
RuntimeDriverConvertPointer (
|
||||||
|
IN UINTN DebugDisposition,
|
||||||
|
IN OUT VOID **ConvertAddress
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
Determines the new virtual address that is to be used on subsequent memory accesses.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
DebugDisposition - Supplies type information for the pointer being converted.
|
||||||
|
ConvertAddress - A pointer to a pointer that is to be fixed to be the value needed
|
||||||
|
for the new virtual address mappings being applied.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_SUCCESS - The pointer pointed to by Address was modified.
|
||||||
|
EFI_NOT_FOUND - The pointer pointed to by Address was not found to be part
|
||||||
|
of the current memory map. This is normally fatal.
|
||||||
|
EFI_INVALID_PARAMETER - One of the parameters has an invalid value.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
{
|
||||||
|
UINTN Address;
|
||||||
|
VOID *PlabelConvertAddress;
|
||||||
|
UINT64 VirtEndOfRange;
|
||||||
|
EFI_MEMORY_DESCRIPTOR *VirtEntry;
|
||||||
|
UINTN Index;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Make sure ConvertAddress is a valid pointer
|
||||||
|
//
|
||||||
|
if (ConvertAddress == NULL) {
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Get the address to convert
|
||||||
|
//
|
||||||
|
Address = (UINTN) *ConvertAddress;
|
||||||
|
|
||||||
|
//
|
||||||
|
// If this is a null pointer, return if it's allowed
|
||||||
|
//
|
||||||
|
if (Address == 0) {
|
||||||
|
if (DebugDisposition & EFI_OPTIONAL_POINTER) {
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlabelConvertAddress = NULL;
|
||||||
|
VirtEntry = mVirtualMap;
|
||||||
|
for (Index = 0; Index < mVirtualMapMaxIndex; Index++) {
|
||||||
|
//
|
||||||
|
// To prevent the inclusion of 64-bit math functions a UINTN was placed in
|
||||||
|
// front of VirtEntry->NumberOfPages to cast it to a 32-bit thing on IA-32
|
||||||
|
// platforms. If you get this ASSERT remove the UINTN and do a 64-bit
|
||||||
|
// multiply.
|
||||||
|
//
|
||||||
|
ASSERT (((UINTN) VirtEntry->NumberOfPages < 0xffffffff) || (sizeof (UINTN) > 4));
|
||||||
|
|
||||||
|
if ((VirtEntry->Attribute & EFI_MEMORY_RUNTIME) == EFI_MEMORY_RUNTIME) {
|
||||||
|
if (Address >= VirtEntry->PhysicalStart) {
|
||||||
|
VirtEndOfRange = VirtEntry->PhysicalStart + (((UINTN) VirtEntry->NumberOfPages) * EFI_PAGE_SIZE);
|
||||||
|
if (Address < VirtEndOfRange) {
|
||||||
|
//
|
||||||
|
// Compute new address
|
||||||
|
//
|
||||||
|
*ConvertAddress = (VOID *) (Address - (UINTN) VirtEntry->PhysicalStart + (UINTN) VirtEntry->VirtualStart);
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VirtEntry = NextMemoryDescriptor (VirtEntry, mVirtualMapDescriptorSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
return EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC
|
||||||
|
EFI_STATUS
|
||||||
|
RuntimeDriverConvertInternalPointer (
|
||||||
|
IN OUT VOID **ConvertAddress
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
Determines the new virtual address that is to be used on subsequent memory accesses
|
||||||
|
for internal pointers.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
ConvertAddress - A pointer to a pointer that is to be fixed to be the value needed
|
||||||
|
for the new virtual address mappings being applied.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_SUCCESS - The pointer pointed to by Address was modified.
|
||||||
|
EFI_NOT_FOUND - The pointer pointed to by Address was not found to be part
|
||||||
|
of the current memory map. This is normally fatal.
|
||||||
|
EFI_INVALID_PARAMETER - One of the parameters has an invalid value.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
{
|
||||||
|
return RuntimeDriverConvertPointer (0x0, ConvertAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
RuntimeDriverSetVirtualAddressMap (
|
||||||
|
IN UINTN MemoryMapSize,
|
||||||
|
IN UINTN DescriptorSize,
|
||||||
|
IN UINT32 DescriptorVersion,
|
||||||
|
IN EFI_MEMORY_DESCRIPTOR *VirtualMap
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
Changes the runtime addressing mode of EFI firmware from physical to virtual.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
MemoryMapSize - The size in bytes of VirtualMap.
|
||||||
|
DescriptorSize - The size in bytes of an entry in the VirtualMap.
|
||||||
|
DescriptorVersion - The version of the structure entries in VirtualMap.
|
||||||
|
VirtualMap - An array of memory descriptors which contain new virtual
|
||||||
|
address mapping information for all runtime ranges.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_SUCCESS - The virtual address map has been applied.
|
||||||
|
EFI_UNSUPPORTED - EFI firmware is not at runtime, or the EFI firmware is already in
|
||||||
|
virtual address mapped mode.
|
||||||
|
EFI_INVALID_PARAMETER - DescriptorSize or DescriptorVersion is invalid.
|
||||||
|
EFI_NO_MAPPING - A virtual address was not supplied for a range in the memory
|
||||||
|
map that requires a mapping.
|
||||||
|
EFI_NOT_FOUND - A virtual address was supplied for an address that is not found
|
||||||
|
in the memory map.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_RUNTIME_EVENT_ENTRY *RuntimeEvent;
|
||||||
|
EFI_RUNTIME_IMAGE_ENTRY *RuntimeImage;
|
||||||
|
LIST_ENTRY *Link;
|
||||||
|
EFI_PHYSICAL_ADDRESS VirtImageBase;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Can only switch to virtual addresses once the memory map is locked down,
|
||||||
|
// and can only set it once
|
||||||
|
//
|
||||||
|
if (!mRuntime.AtRuntime || mRuntime.VirtualMode) {
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Only understand the original descriptor format
|
||||||
|
//
|
||||||
|
if (DescriptorVersion != EFI_MEMORY_DESCRIPTOR_VERSION || DescriptorSize < sizeof (EFI_MEMORY_DESCRIPTOR)) {
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// We are now committed to go to virtual mode, so lets get to it!
|
||||||
|
//
|
||||||
|
mRuntime.VirtualMode = TRUE;
|
||||||
|
|
||||||
|
//
|
||||||
|
// ConvertPointer() needs this mVirtualMap to do the conversion. So set up
|
||||||
|
// globals we need to parse the virtual address map.
|
||||||
|
//
|
||||||
|
mVirtualMapDescriptorSize = DescriptorSize;
|
||||||
|
mVirtualMapMaxIndex = MemoryMapSize / DescriptorSize;
|
||||||
|
mVirtualMap = VirtualMap;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Currently the bug in StatusCode/RuntimeLib has been fixed, it will
|
||||||
|
// check whether in Runtime or not (this is judged by looking at
|
||||||
|
// mEfiAtRuntime global So this ReportStatusCode will work
|
||||||
|
//
|
||||||
|
REPORT_STATUS_CODE (
|
||||||
|
EFI_PROGRESS_CODE,
|
||||||
|
(EFI_SOFTWARE_EFI_BOOT_SERVICE | EFI_SW_RS_PC_SET_VIRTUAL_ADDRESS_MAP)
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Signal all the EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE events.
|
||||||
|
// All runtime events are stored in a list in Runtime AP.
|
||||||
|
//
|
||||||
|
for (Link = mRuntime.EventHead.ForwardLink; Link != &mRuntime.EventHead; Link = Link->ForwardLink) {
|
||||||
|
RuntimeEvent = _CR (Link, EFI_RUNTIME_EVENT_ENTRY, Link);
|
||||||
|
if ((RuntimeEvent->Type & EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE) == EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE) {
|
||||||
|
RuntimeEvent->NotifyFunction (
|
||||||
|
RuntimeEvent->Event,
|
||||||
|
RuntimeEvent->NotifyContext
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Relocate runtime images. All runtime images are stored in a list in Runtime AP.
|
||||||
|
//
|
||||||
|
for (Link = mRuntime.ImageHead.ForwardLink; Link != &mRuntime.ImageHead; Link = Link->ForwardLink) {
|
||||||
|
RuntimeImage = _CR (Link, EFI_RUNTIME_IMAGE_ENTRY, Link);
|
||||||
|
//
|
||||||
|
// We don't want to relocate our selves, as we only run in physical mode.
|
||||||
|
//
|
||||||
|
if (mMyImageBase != RuntimeImage->ImageBase) {
|
||||||
|
|
||||||
|
VirtImageBase = (EFI_PHYSICAL_ADDRESS) (UINTN) RuntimeImage->ImageBase;
|
||||||
|
Status = RuntimeDriverConvertPointer (0, (VOID **) &VirtImageBase);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
PeCoffLoaderRelocateImageForRuntime (
|
||||||
|
(EFI_PHYSICAL_ADDRESS) (UINTN) RuntimeImage->ImageBase,
|
||||||
|
VirtImageBase,
|
||||||
|
(UINTN) RuntimeImage->ImageSize,
|
||||||
|
RuntimeImage->RelocationData
|
||||||
|
);
|
||||||
|
|
||||||
|
InvalidateInstructionCacheRange (RuntimeImage->ImageBase, (UINTN)RuntimeImage->ImageSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Convert all the Runtime Services except ConvertPointer() and SetVirtualAddressMap()
|
||||||
|
// and recompute the CRC-32
|
||||||
|
//
|
||||||
|
RuntimeDriverConvertInternalPointer ((VOID **) &gRT->GetTime);
|
||||||
|
RuntimeDriverConvertInternalPointer ((VOID **) &gRT->SetTime);
|
||||||
|
RuntimeDriverConvertInternalPointer ((VOID **) &gRT->GetWakeupTime);
|
||||||
|
RuntimeDriverConvertInternalPointer ((VOID **) &gRT->SetWakeupTime);
|
||||||
|
RuntimeDriverConvertInternalPointer ((VOID **) &gRT->ResetSystem);
|
||||||
|
RuntimeDriverConvertInternalPointer ((VOID **) &gRT->GetNextHighMonotonicCount);
|
||||||
|
RuntimeDriverConvertInternalPointer ((VOID **) &gRT->GetVariable);
|
||||||
|
RuntimeDriverConvertInternalPointer ((VOID **) &gRT->SetVariable);
|
||||||
|
RuntimeDriverConvertInternalPointer ((VOID **) &gRT->GetNextVariableName);
|
||||||
|
RuntimeDriverConvertInternalPointer ((VOID **) &gRT->QueryVariableInfo);
|
||||||
|
RuntimeDriverConvertInternalPointer ((VOID **) &gRT->UpdateCapsule);
|
||||||
|
RuntimeDriverConvertInternalPointer ((VOID **) &gRT->QueryCapsuleCapabilities);
|
||||||
|
RuntimeDriverCalculateEfiHdrCrc (&gRT->Hdr);
|
||||||
|
|
||||||
|
//
|
||||||
|
// BugBug: PI requires System Configuration Tables Conversion.
|
||||||
|
// Currently, we do not implement it.
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
// Convert the runtime fields of the EFI System Table and recompute the CRC-32
|
||||||
|
//
|
||||||
|
RuntimeDriverConvertInternalPointer ((VOID **) &gST->FirmwareVendor);
|
||||||
|
RuntimeDriverConvertInternalPointer ((VOID **) &gST->ConfigurationTable);
|
||||||
|
RuntimeDriverConvertInternalPointer ((VOID **) &gST->RuntimeServices);
|
||||||
|
RuntimeDriverCalculateEfiHdrCrc (&gST->Hdr);
|
||||||
|
|
||||||
|
//
|
||||||
|
// At this point, gRT and gST are physical pointers, but the contents of these tables
|
||||||
|
// have been converted to runtime.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// mVirtualMap is only valid during SetVirtualAddressMap() call
|
||||||
|
//
|
||||||
|
mVirtualMap = NULL;
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
RuntimeDriverInitialize (
|
||||||
|
IN EFI_HANDLE ImageHandle,
|
||||||
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
Install Runtime AP. This code includes the EfiDriverLib, but it functions at
|
||||||
|
RT in physical mode. The only Lib services are gBS, gRT, and the DEBUG and
|
||||||
|
ASSERT macros (they do ReportStatusCode).
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
(Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_SUCEESS - Runtime Driver Architectural Protocol Installed
|
||||||
|
|
||||||
|
Other - Return value from gBS->InstallMultipleProtocolInterfaces
|
||||||
|
|
||||||
|
--*/
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_LOADED_IMAGE_PROTOCOL *MyLoadedImage;
|
||||||
|
|
||||||
|
//
|
||||||
|
// This image needs to be exclued from relocation for virtual mode, so cache
|
||||||
|
// a copy of the Loaded Image protocol to test later.
|
||||||
|
//
|
||||||
|
Status = gBS->HandleProtocol (
|
||||||
|
ImageHandle,
|
||||||
|
&gEfiLoadedImageProtocolGuid,
|
||||||
|
(VOID**)&MyLoadedImage
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
mMyImageBase = MyLoadedImage->ImageBase;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize the table used to compute 32-bit CRCs
|
||||||
|
//
|
||||||
|
RuntimeDriverInitializeCrc32Table ();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Fill in the entries of the EFI Boot Services and EFI Runtime Services Tables
|
||||||
|
//
|
||||||
|
gBS->CalculateCrc32 = RuntimeDriverCalculateCrc32;
|
||||||
|
gRT->SetVirtualAddressMap = RuntimeDriverSetVirtualAddressMap;
|
||||||
|
gRT->ConvertPointer = RuntimeDriverConvertPointer;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Install the Runtime Architectural Protocol onto a new handle
|
||||||
|
//
|
||||||
|
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||||
|
&mRuntimeHandle,
|
||||||
|
&gEfiRuntimeArchProtocolGuid,
|
||||||
|
&mRuntime,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
168
MdeModulePkg/Universal/RuntimeDxe/Runtime.h
Normal file
168
MdeModulePkg/Universal/RuntimeDxe/Runtime.h
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
/*++
|
||||||
|
|
||||||
|
Copyright (c) 2006, 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:
|
||||||
|
|
||||||
|
Runtime.h
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
Runtime Architectural Protocol as defined in the DXE CIS
|
||||||
|
|
||||||
|
This code is used to produce the EFI runtime architectural protocol.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
|
#ifndef _RUNTIME_H_
|
||||||
|
#define _RUNTIME_H_
|
||||||
|
|
||||||
|
//
|
||||||
|
// Function Prototypes
|
||||||
|
//
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
RuntimeDriverCalculateCrc32 (
|
||||||
|
IN VOID *Data,
|
||||||
|
IN UINTN DataSize,
|
||||||
|
OUT UINT32 *CrcOut
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
Calculate CRC32 for target data
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
Data - The target data.
|
||||||
|
DataSize - The target data size.
|
||||||
|
CrcOut - The CRC32 for target data.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_SUCCESS - The CRC32 for target data is calculated successfully.
|
||||||
|
EFI_INVALID_PARAMETER - Some parameter is not valid, so the CRC32 is not
|
||||||
|
calculated.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
RuntimeDriverConvertPointer (
|
||||||
|
IN UINTN DebugDisposition,
|
||||||
|
IN OUT VOID **ConvertAddress
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
Determines the new virtual address that is to be used on subsequent memory accesses.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
DebugDisposition - Supplies type information for the pointer being converted.
|
||||||
|
ConvertAddress - A pointer to a pointer that is to be fixed to be the value needed
|
||||||
|
for the new virtual address mappings being applied.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_SUCCESS - The pointer pointed to by Address was modified.
|
||||||
|
EFI_NOT_FOUND - The pointer pointed to by Address was not found to be part
|
||||||
|
of the current memory map. This is normally fatal.
|
||||||
|
EFI_INVALID_PARAMETER - One of the parameters has an invalid value.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
RuntimeDriverSetVirtualAddressMap (
|
||||||
|
IN UINTN MemoryMapSize,
|
||||||
|
IN UINTN DescriptorSize,
|
||||||
|
IN UINT32 DescriptorVersion,
|
||||||
|
IN EFI_MEMORY_DESCRIPTOR *VirtualMap
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
Changes the runtime addressing mode of EFI firmware from physical to virtual.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
MemoryMapSize - The size in bytes of VirtualMap.
|
||||||
|
DescriptorSize - The size in bytes of an entry in the VirtualMap.
|
||||||
|
DescriptorVersion - The version of the structure entries in VirtualMap.
|
||||||
|
VirtualMap - An array of memory descriptors which contain new virtual
|
||||||
|
address mapping information for all runtime ranges.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_SUCCESS - The virtual address map has been applied.
|
||||||
|
EFI_UNSUPPORTED - EFI firmware is not at runtime, or the EFI firmware is already in
|
||||||
|
virtual address mapped mode.
|
||||||
|
EFI_INVALID_PARAMETER - DescriptorSize or DescriptorVersion is invalid.
|
||||||
|
EFI_NO_MAPPING - A virtual address was not supplied for a range in the memory
|
||||||
|
map that requires a mapping.
|
||||||
|
EFI_NOT_FOUND - A virtual address was supplied for an address that is not found
|
||||||
|
in the memory map.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
VOID
|
||||||
|
RuntimeDriverInitializeCrc32Table (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
Initialize CRC32 table.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
None.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
None.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
RuntimeDriverInitialize (
|
||||||
|
IN EFI_HANDLE ImageHandle,
|
||||||
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
Install Runtime AP. This code includes the EfiRuntimeLib, but it only
|
||||||
|
functions at RT in physical mode.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
ImageHandle - Image handle of this driver.
|
||||||
|
SystemTable - Pointer to the EFI System Table.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_SUCEESS - Runtime Driver Architectural Protocol installed.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
#endif
|
110
MdeModulePkg/Universal/RuntimeDxe/Runtime.inf
Normal file
110
MdeModulePkg/Universal/RuntimeDxe/Runtime.inf
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
#/** @file
|
||||||
|
# Component description file for Runtime module.
|
||||||
|
#
|
||||||
|
# This module is used to produce the EFI runtime virtual switch over services.
|
||||||
|
# Copyright (c) 2006 - 2007, 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.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#**/
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Defines Section - statements that will be processed to create a Makefile.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010005
|
||||||
|
BASE_NAME = Runtime
|
||||||
|
FILE_GUID = B601F8C4-43B7-4784-95B1-F4226CB40CEE
|
||||||
|
MODULE_TYPE = DXE_RUNTIME_DRIVER
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
EDK_RELEASE_VERSION = 0x00020000
|
||||||
|
EFI_SPECIFICATION_VERSION = 0x00020000
|
||||||
|
|
||||||
|
ENTRY_POINT = RuntimeDriverInitialize
|
||||||
|
|
||||||
|
#
|
||||||
|
# The following information is for reference only and not required by the build tools.
|
||||||
|
#
|
||||||
|
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||||
|
#
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Sources Section - list of files that are required for the build to succeed.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
[Sources.common]
|
||||||
|
Crc32.c
|
||||||
|
Runtime.h
|
||||||
|
Runtime.c
|
||||||
|
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Includes Section - list of Include locations that are required for
|
||||||
|
# this module.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
[Includes]
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Package Dependency Section - list of Package files that are required for
|
||||||
|
# this module.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
IntelFrameworkPkg/IntelFrameworkPkg.dec
|
||||||
|
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Library Class Section - list of Library Classes that are required for
|
||||||
|
# this module.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
PeCoffLib
|
||||||
|
CacheMaintenanceLib
|
||||||
|
UefiBootServicesTableLib
|
||||||
|
UefiRuntimeServicesTableLib
|
||||||
|
BaseMemoryLib
|
||||||
|
ReportStatusCodeLib
|
||||||
|
DebugLib
|
||||||
|
UefiDriverEntryPoint
|
||||||
|
BaseLib
|
||||||
|
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Guid C Name Section - list of Guids that this module uses or produces.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
[Guids]
|
||||||
|
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Protocol C Name Section - list of Protocol and Protocol Notify C Names
|
||||||
|
# that this module uses or produces.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
[Protocols]
|
||||||
|
gEfiRuntimeArchProtocolGuid # PROTOCOL ALWAYS_PRODUCED
|
||||||
|
gEfiLoadedImageProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||||
|
|
87
MdeModulePkg/Universal/RuntimeDxe/Runtime.msa
Normal file
87
MdeModulePkg/Universal/RuntimeDxe/Runtime.msa
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">
|
||||||
|
<MsaHeader>
|
||||||
|
<ModuleName>Runtime</ModuleName>
|
||||||
|
<ModuleType>DXE_RUNTIME_DRIVER</ModuleType>
|
||||||
|
<GuidValue>B601F8C4-43B7-4784-95B1-F4226CB40CEE</GuidValue>
|
||||||
|
<Version>1.0</Version>
|
||||||
|
<Abstract>Component description file for Runtime module.</Abstract>
|
||||||
|
<Description>This module is used to produce the EFI runtime virtual switch over services.</Description>
|
||||||
|
<Copyright>Copyright (c) 2006 - 2007, Intel Corporation</Copyright>
|
||||||
|
<License>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.</License>
|
||||||
|
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
|
||||||
|
</MsaHeader>
|
||||||
|
<ModuleDefinitions>
|
||||||
|
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
|
||||||
|
<BinaryModule>false</BinaryModule>
|
||||||
|
<OutputFileBasename>Runtime</OutputFileBasename>
|
||||||
|
</ModuleDefinitions>
|
||||||
|
<LibraryClassDefinitions>
|
||||||
|
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||||
|
<Keyword>BaseLib</Keyword>
|
||||||
|
</LibraryClass>
|
||||||
|
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||||
|
<Keyword>UefiDriverEntryPoint</Keyword>
|
||||||
|
</LibraryClass>
|
||||||
|
<LibraryClass Usage="ALWAYS_CONSUMED" RecommendedInstanceGuid="bda39d3a-451b-4350-8266-81ab10fa0523">
|
||||||
|
<Keyword>DebugLib</Keyword>
|
||||||
|
<HelpText>Recommended libary Instance is PeiDxeDebugLibReportStatusCode instance in MdePkg.</HelpText>
|
||||||
|
</LibraryClass>
|
||||||
|
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||||
|
<Keyword>ReportStatusCodeLib</Keyword>
|
||||||
|
</LibraryClass>
|
||||||
|
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||||
|
<Keyword>BaseMemoryLib</Keyword>
|
||||||
|
</LibraryClass>
|
||||||
|
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||||
|
<Keyword>UefiRuntimeServicesTableLib</Keyword>
|
||||||
|
</LibraryClass>
|
||||||
|
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||||
|
<Keyword>UefiBootServicesTableLib</Keyword>
|
||||||
|
</LibraryClass>
|
||||||
|
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||||
|
<Keyword>CacheMaintenanceLib</Keyword>
|
||||||
|
</LibraryClass>
|
||||||
|
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||||
|
<Keyword>PeCoffLib</Keyword>
|
||||||
|
</LibraryClass>
|
||||||
|
</LibraryClassDefinitions>
|
||||||
|
<SourceFiles>
|
||||||
|
<Filename>Runtime.dxs</Filename>
|
||||||
|
<Filename>Runtime.c</Filename>
|
||||||
|
<Filename>Runtime.h</Filename>
|
||||||
|
<Filename>Crc32.c</Filename>
|
||||||
|
</SourceFiles>
|
||||||
|
<PackageDependencies>
|
||||||
|
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||||
|
<Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
|
||||||
|
</PackageDependencies>
|
||||||
|
<Protocols>
|
||||||
|
<Protocol Usage="ALWAYS_CONSUMED">
|
||||||
|
<ProtocolCName>gEfiLoadedImageProtocolGuid</ProtocolCName>
|
||||||
|
</Protocol>
|
||||||
|
<Protocol Usage="ALWAYS_PRODUCED">
|
||||||
|
<ProtocolCName>gEfiRuntimeArchProtocolGuid</ProtocolCName>
|
||||||
|
</Protocol>
|
||||||
|
</Protocols>
|
||||||
|
<SystemTables>
|
||||||
|
<SystemTableCNames Usage="SOMETIMES_CONSUMED">
|
||||||
|
<SystemTableCName>gEfiUgaIoProtocolGuid</SystemTableCName>
|
||||||
|
</SystemTableCNames>
|
||||||
|
<SystemTableCNames Usage="SOMETIMES_CONSUMED">
|
||||||
|
<SystemTableCName>gEfiCapsuleGuid</SystemTableCName>
|
||||||
|
</SystemTableCNames>
|
||||||
|
</SystemTables>
|
||||||
|
<Externs>
|
||||||
|
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
|
||||||
|
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
|
||||||
|
<Extern>
|
||||||
|
<ModuleEntryPoint>RuntimeDriverInitialize</ModuleEntryPoint>
|
||||||
|
</Extern>
|
||||||
|
</Externs>
|
||||||
|
</ModuleSurfaceArea>
|
130
MdeModulePkg/Universal/SecurityStubDxe/SecurityStub.c
Normal file
130
MdeModulePkg/Universal/SecurityStubDxe/SecurityStub.c
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
/** @file
|
||||||
|
This driver supports platform security service.
|
||||||
|
|
||||||
|
Copyright (c) 2006 - 2007, 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.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
#include "SecurityStub.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// Handle for the Security Architectural Protocol instance produced by this driver
|
||||||
|
//
|
||||||
|
EFI_HANDLE mSecurityArchProtocolHandle = NULL;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Security Architectural Protocol instance produced by this driver
|
||||||
|
//
|
||||||
|
EFI_SECURITY_ARCH_PROTOCOL mSecurityStub = {
|
||||||
|
SecurityStubAuthenticateState
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
The EFI_SECURITY_ARCH_PROTOCOL (SAP) is used to abstract platform-specific
|
||||||
|
policy from the DXE core response to an attempt to use a file that returns a
|
||||||
|
given status for the authentication check from the section extraction protocol.
|
||||||
|
|
||||||
|
The possible responses in a given SAP implementation may include locking
|
||||||
|
flash upon failure to authenticate, attestation logging for all signed drivers,
|
||||||
|
and other exception operations. The File parameter allows for possible logging
|
||||||
|
within the SAP of the driver.
|
||||||
|
|
||||||
|
If File is NULL, then EFI_INVALID_PARAMETER is returned.
|
||||||
|
|
||||||
|
If the file specified by File with an authentication status specified by
|
||||||
|
AuthenticationStatus is safe for the DXE Core to use, then EFI_SUCCESS is returned.
|
||||||
|
|
||||||
|
If the file specified by File with an authentication status specified by
|
||||||
|
AuthenticationStatus is not safe for the DXE Core to use under any circumstances,
|
||||||
|
then EFI_ACCESS_DENIED is returned.
|
||||||
|
|
||||||
|
If the file specified by File with an authentication status specified by
|
||||||
|
AuthenticationStatus is not safe for the DXE Core to use right now, but it
|
||||||
|
might be possible to use it at a future time, then EFI_SECURITY_VIOLATION is
|
||||||
|
returned.
|
||||||
|
|
||||||
|
@param This The EFI_SECURITY_ARCH_PROTOCOL instance.
|
||||||
|
@param AuthenticationStatus
|
||||||
|
This is the authentication type returned from the Section
|
||||||
|
Extraction protocol. See the Section Extraction Protocol
|
||||||
|
Specification for details on this type.
|
||||||
|
@param File This is a pointer to the device path of the file that is
|
||||||
|
being dispatched. This will optionally be used for logging.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The file specified by File did authenticate, and the
|
||||||
|
platform policy dictates that the DXE Core may use File.
|
||||||
|
@retval EFI_INVALID_PARAMETER Driver is NULL.
|
||||||
|
@retval EFI_SECURITY_VIOLATION The file specified by File did not authenticate, and
|
||||||
|
the platform policy dictates that File should be placed
|
||||||
|
in the untrusted state. A file may be promoted from
|
||||||
|
the untrusted to the trusted state at a future time
|
||||||
|
with a call to the Trust() DXE Service.
|
||||||
|
@retval EFI_ACCESS_DENIED The file specified by File did not authenticate, and
|
||||||
|
the platform policy dictates that File should not be
|
||||||
|
used for any purpose.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
SecurityStubAuthenticateState (
|
||||||
|
IN EFI_SECURITY_ARCH_PROTOCOL *This,
|
||||||
|
IN UINT32 AuthenticationStatus,
|
||||||
|
IN EFI_DEVICE_PATH_PROTOCOL *File
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (File == NULL) {
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
The user Entry Point for DXE driver. The user code starts with this function
|
||||||
|
as the real entry point for the image goes into a library that calls this
|
||||||
|
function.
|
||||||
|
|
||||||
|
@param[in] ImageHandle The firmware allocated handle for the EFI image.
|
||||||
|
@param[in] SystemTable A pointer to the EFI System Table.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The entry point is executed successfully.
|
||||||
|
@retval other Some error occurs when executing this entry point.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
SecurityStubInitialize (
|
||||||
|
IN EFI_HANDLE ImageHandle,
|
||||||
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Make sure the Security Architectural Protocol is not already installed in the system
|
||||||
|
//
|
||||||
|
ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiSecurityArchProtocolGuid);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Install the Security Architectural Protocol onto a new handle
|
||||||
|
//
|
||||||
|
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||||
|
&mSecurityArchProtocolHandle,
|
||||||
|
&gEfiSecurityArchProtocolGuid,
|
||||||
|
&mSecurityStub,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
31
MdeModulePkg/Universal/SecurityStubDxe/SecurityStub.dxs
Normal file
31
MdeModulePkg/Universal/SecurityStubDxe/SecurityStub.dxs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*++
|
||||||
|
|
||||||
|
Copyright (c) 2006, 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:
|
||||||
|
|
||||||
|
SecurityStub.dxs
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
Dependency expression source file.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
|
//
|
||||||
|
// Include common header file for this module.
|
||||||
|
//
|
||||||
|
#include "CommonHeader.h"
|
||||||
|
|
||||||
|
#include <DxeDepex.h>
|
||||||
|
|
||||||
|
DEPENDENCY_START
|
||||||
|
TRUE
|
||||||
|
DEPENDENCY_END
|
46
MdeModulePkg/Universal/SecurityStubDxe/SecurityStub.h
Normal file
46
MdeModulePkg/Universal/SecurityStubDxe/SecurityStub.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/** @file
|
||||||
|
Some definitions for Security Architectural Protocol stub driver
|
||||||
|
|
||||||
|
Copyright (c) 2006 - 2007, 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.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef _SECURITY_STUB_ARCH_PROTOCOL_H
|
||||||
|
#define _SECURITY_STUB_ARCH_PROTOCOL_H
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Common header files for this module.
|
||||||
|
//
|
||||||
|
#include <PiDxe.h>
|
||||||
|
#include <Protocol/Security.h>
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/UefiBootServicesTableLib.h>
|
||||||
|
#include <Library/UefiDriverEntryPoint.h>
|
||||||
|
|
||||||
|
//
|
||||||
|
// Function prototypes
|
||||||
|
//
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
SecurityStubAuthenticateState (
|
||||||
|
IN EFI_SECURITY_ARCH_PROTOCOL *This,
|
||||||
|
IN UINT32 AuthenticationStatus,
|
||||||
|
IN EFI_DEVICE_PATH_PROTOCOL *File
|
||||||
|
);
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
SecurityStubInitialize (
|
||||||
|
IN EFI_HANDLE ImageHandle,
|
||||||
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
|
);
|
||||||
|
|
||||||
|
#endif
|
101
MdeModulePkg/Universal/SecurityStubDxe/SecurityStub.inf
Normal file
101
MdeModulePkg/Universal/SecurityStubDxe/SecurityStub.inf
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
#/** @file
|
||||||
|
# Component description file for SecurityStub module
|
||||||
|
#
|
||||||
|
# Copyright (c) 2006 - 2007, 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.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#**/
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Defines Section - statements that will be processed to create a Makefile.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010005
|
||||||
|
BASE_NAME = SecurityStub
|
||||||
|
FILE_GUID = F80697E9-7FD6-4665-8646-88E33EF71DFC
|
||||||
|
MODULE_TYPE = DXE_DRIVER
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
EDK_RELEASE_VERSION = 0x00020000
|
||||||
|
EFI_SPECIFICATION_VERSION = 0x00020000
|
||||||
|
|
||||||
|
ENTRY_POINT = SecurityStubInitialize
|
||||||
|
|
||||||
|
#
|
||||||
|
# The following information is for reference only and not required by the build tools.
|
||||||
|
#
|
||||||
|
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||||
|
#
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Sources Section - list of files that are required for the build to succeed.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
[Sources.common]
|
||||||
|
SecurityStub.c
|
||||||
|
SecurityStub.h
|
||||||
|
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Includes Section - list of Include locations that are required for
|
||||||
|
# this module.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
[Includes]
|
||||||
|
$(WORKSPACE)/MdePkg/Include/Library
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Package Dependency Section - list of Package files that are required for
|
||||||
|
# this module.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Library Class Section - list of Library Classes that are required for
|
||||||
|
# this module.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
UefiDriverEntryPoint
|
||||||
|
UefiBootServicesTableLib
|
||||||
|
DebugLib
|
||||||
|
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Protocol C Name Section - list of Protocol and Protocol Notify C Names
|
||||||
|
# that this module uses or produces.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
[Protocols]
|
||||||
|
gEfiSecurityArchProtocolGuid # PROTOCOL ALWAYS_PRODUCED
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Dependency Expression Section - list of Dependency expressions that are required for
|
||||||
|
# this module.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
[Depex]
|
||||||
|
TRUE
|
56
MdeModulePkg/Universal/SecurityStubDxe/SecurityStub.msa
Normal file
56
MdeModulePkg/Universal/SecurityStubDxe/SecurityStub.msa
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">
|
||||||
|
<MsaHeader>
|
||||||
|
<ModuleName>SecurityStub</ModuleName>
|
||||||
|
<ModuleType>DXE_DRIVER</ModuleType>
|
||||||
|
<GuidValue>F80697E9-7FD6-4665-8646-88E33EF71DFC</GuidValue>
|
||||||
|
<Version>1.0</Version>
|
||||||
|
<Abstract>Component description file for SecurityStub module</Abstract>
|
||||||
|
<Description>This driver supports platform security service.</Description>
|
||||||
|
<Copyright>Copyright (c) 2006 - 2007, Intel Corporation</Copyright>
|
||||||
|
<License>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.</License>
|
||||||
|
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
|
||||||
|
</MsaHeader>
|
||||||
|
<ModuleDefinitions>
|
||||||
|
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
|
||||||
|
<BinaryModule>false</BinaryModule>
|
||||||
|
<OutputFileBasename>SecurityStub</OutputFileBasename>
|
||||||
|
</ModuleDefinitions>
|
||||||
|
<LibraryClassDefinitions>
|
||||||
|
<LibraryClass Usage="ALWAYS_CONSUMED" RecommendedInstanceGuid="bda39d3a-451b-4350-8266-81ab10fa0523">
|
||||||
|
<Keyword>DebugLib</Keyword>
|
||||||
|
<HelpText>Recommended libary Instance is PeiDxeDebugLibReportStatusCode instance in MdePkg.</HelpText>
|
||||||
|
</LibraryClass>
|
||||||
|
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||||
|
<Keyword>UefiBootServicesTableLib</Keyword>
|
||||||
|
</LibraryClass>
|
||||||
|
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||||
|
<Keyword>UefiDriverEntryPoint</Keyword>
|
||||||
|
</LibraryClass>
|
||||||
|
</LibraryClassDefinitions>
|
||||||
|
<SourceFiles>
|
||||||
|
<Filename>SecurityStub.dxs</Filename>
|
||||||
|
<Filename>SecurityStub.h</Filename>
|
||||||
|
<Filename>SecurityStub.c</Filename>
|
||||||
|
</SourceFiles>
|
||||||
|
<PackageDependencies>
|
||||||
|
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||||
|
</PackageDependencies>
|
||||||
|
<Protocols>
|
||||||
|
<Protocol Usage="ALWAYS_PRODUCED">
|
||||||
|
<ProtocolCName>gEfiSecurityArchProtocolGuid</ProtocolCName>
|
||||||
|
</Protocol>
|
||||||
|
</Protocols>
|
||||||
|
<Externs>
|
||||||
|
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
|
||||||
|
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
|
||||||
|
<Extern>
|
||||||
|
<ModuleEntryPoint>SecurityStubInitialize</ModuleEntryPoint>
|
||||||
|
</Extern>
|
||||||
|
</Externs>
|
||||||
|
</ModuleSurfaceArea>
|
@ -164,4 +164,8 @@ typedef union {
|
|||||||
|
|
||||||
#define EFI_PAGES_TO_SIZE(a) ( (a) << EFI_PAGE_SHIFT)
|
#define EFI_PAGES_TO_SIZE(a) ( (a) << EFI_PAGE_SHIFT)
|
||||||
|
|
||||||
|
|
||||||
|
#define EFI_MAX_BIT MAX_BIT
|
||||||
|
#define EFI_MAX_ADDRESS MAX_ADDRESS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user