Add EBC, FTW, Crc32SectionExtract, NullMemoryTest modules.

CrcSectionExtract cannot build for now for some missing definitions. 

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2813 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qhuang8
2007-06-27 14:52:40 +00:00
parent eb5f1a7fc7
commit d7dec593ea
40 changed files with 14183 additions and 3 deletions

View File

@ -0,0 +1,230 @@
/*++
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:
Crc32SectionExtract.c
Abstract:
Implements GUIDed section extraction protocol interface with
a specific GUID: CRC32.
Please refer to the Framewokr Firmware Volume Specification 0.9.
--*/
#include <GuidedSection.h>
#include <Crc32SectionExtract.h>
EFI_STATUS
EFIAPI
InitializeCrc32GuidedSectionExtractionProtocol (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
/*++
Routine Description:
Entry point of the CRC32 GUIDed section extraction protocol.
Creates and initializes an instance of the GUIDed section
extraction protocol with CRC32 GUID.
Arguments:
ImageHandle EFI_HANDLE: A handle for the image that is initializing
this driver
SystemTable EFI_SYSTEM_TABLE: A pointer to the EFI system table
Returns:
EFI_SUCCESS: Driver initialized successfully
EFI_LOAD_ERROR: Failed to Initialize or has been loaded
EFI_OUT_OF_RESOURCES: Could not allocate needed resources
--*/
{
EFI_STATUS Status;
EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL *Crc32GuidedSep;
EFI_HANDLE Handle;
//
// Call all constructors per produced protocols
//
Status = GuidedSectionExtractionProtocolConstructor (
&Crc32GuidedSep,
(EFI_EXTRACT_GUIDED_SECTION) Crc32ExtractSection
);
if (EFI_ERROR (Status)) {
if (Crc32GuidedSep != NULL) {
FreePool (Crc32GuidedSep);
}
return Status;
}
//
// Pass in a NULL to install to a new handle
//
Handle = NULL;
Status = gBS->InstallProtocolInterface (
&Handle,
&gEfiCrc32GuidedSectionExtractionProtocolGuid,
EFI_NATIVE_INTERFACE,
Crc32GuidedSep
);
if (EFI_ERROR (Status)) {
FreePool (Crc32GuidedSep);
return EFI_LOAD_ERROR;
}
return EFI_SUCCESS;
}
STATIC
UINT32
EFIAPI
GetSectionLength (
IN EFI_COMMON_SECTION_HEADER *CommonHeader
)
/*++
Routine Description:
Get a length of section.
Parameters:
CommonHeader - Pointer to the common section header.
Return Value:
The length of the section, including the section header.
--*/
// TODO: function comment is missing 'Arguments:'
// TODO: function comment is missing 'Returns:'
// TODO: CommonHeader - add argument and description to function comment
{
UINT32 Size;
Size = *(UINT32 *) CommonHeader->Size & 0x00FFFFFF;
return Size;
}
STATIC
EFI_STATUS
EFIAPI
Crc32ExtractSection (
IN EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL *This,
IN VOID *InputSection,
OUT VOID **OutputBuffer,
OUT UINTN *OutputSize,
OUT UINT32 *AuthenticationStatus
)
/*++
Routine Description:
This function reads and extracts contents of a section from an
encapsulating section.
Parameters:
This - Indicates the calling context.
InputSection - Buffer containing the input GUIDed section
to be processed.
OutputBuffer - *OutputBuffer is allocated from boot services
pool memory and containing the new section
stream. The caller is responsible for freeing
this buffer.
AuthenticationStatus - Pointer to a caller allocated UINT32 that
indicates the authentication status of the
output buffer
Return Value:
EFI_SUCCESS
EFI_OUT_OF_RESOURCES
EFI_INVALID_PARAMETER
EFI_NOT_AVAILABLE_YET
--*/
// TODO: function comment is missing 'Arguments:'
// TODO: function comment is missing 'Returns:'
// TODO: This - add argument and description to function comment
// TODO: InputSection - add argument and description to function comment
// TODO: OutputBuffer - add argument and description to function comment
// TODO: OutputSize - add argument and description to function comment
// TODO: AuthenticationStatus - add argument and description to function comment
// TODO: EFI_INVALID_PARAMETER - add return value to function comment
// TODO: EFI_INVALID_PARAMETER - add return value to function comment
// TODO: EFI_OUT_OF_RESOURCES - add return value to function comment
// TODO: EFI_SUCCESS - add return value to function comment
{
EFI_STATUS Status;
CRC32_SECTION_HEADER *Crc32SectionHeader;
EFI_GUID_DEFINED_SECTION *GuidedSectionHeader;
UINT8 *Image;
UINT32 Crc32Checksum;
VOID *DummyInterface;
if (OutputBuffer == NULL) {
return EFI_INVALID_PARAMETER;
}
*OutputBuffer = NULL;
//
// Points to the section header
//
Crc32SectionHeader = (CRC32_SECTION_HEADER *) InputSection;
GuidedSectionHeader = (EFI_GUID_DEFINED_SECTION *) InputSection;
//
// Check if the GUID is a CRC32 section GUID
//
if (!CompareGuid (
&(GuidedSectionHeader->SectionDefinitionGuid),
&gEfiCrc32GuidedSectionExtractionProtocolGuid
)) {
return EFI_INVALID_PARAMETER;
}
Image = (UINT8 *) InputSection + (UINT32) (GuidedSectionHeader->DataOffset);
*OutputSize = GetSectionLength ((EFI_COMMON_SECTION_HEADER *) InputSection) - (UINT32) GuidedSectionHeader->DataOffset;
*OutputBuffer = AllocatePool (*OutputSize);
if (*OutputBuffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
//
// Implictly CRC32 GUIDed section should have STATUS_VALID bit set
//
ASSERT (GuidedSectionHeader->Attributes & EFI_GUIDED_SECTION_AUTH_STATUS_VALID);
*AuthenticationStatus = EFI_LOCAL_AUTH_STATUS_IMAGE_SIGNED | EFI_AGGREGATE_AUTH_STATUS_IMAGE_SIGNED;
//
// Check whether there exists EFI_SECURITY_POLICY_PROTOCOL_GUID.
//
Status = gBS->LocateProtocol (&gEfiSecurityPolicyProtocolGuid, NULL, &DummyInterface);
if (!EFI_ERROR (Status)) {
*AuthenticationStatus |= EFI_LOCAL_AUTH_STATUS_PLATFORM_OVERRIDE | EFI_AGGREGATE_AUTH_STATUS_PLATFORM_OVERRIDE;
} else {
//
// Calculate CRC32 Checksum of Image
//
gBS->CalculateCrc32 (Image, *OutputSize, &Crc32Checksum);
if (Crc32Checksum != Crc32SectionHeader->CRC32Checksum) {
*AuthenticationStatus |= EFI_LOCAL_AUTH_STATUS_TEST_FAILED | EFI_AGGREGATE_AUTH_STATUS_TEST_FAILED;
}
}
CopyMem (*OutputBuffer, Image, *OutputSize);
return EFI_SUCCESS;
}

View File

@ -0,0 +1,26 @@
/*++
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:
Crc32SectionExtraction.dxs
Abstract:
Dependency expression file.
--*/
#include "DxeDepex.h"
DEPENDENCY_START
EFI_RUNTIME_ARCH_PROTOCOL_GUID
DEPENDENCY_END

View File

@ -0,0 +1,112 @@
/*++
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:
Crc32SectionExtract.h
Abstract:
Header file for Crc32SectionExtract.c
Please refer to the Framewokr Firmware Volume Specification 0.9.
--*/
#ifndef _CRC32_GUIDED_SECTION_EXTRACTION_H
#define _CRC32_GUIDED_SECTION_EXTRACTION_H
//
// The package level header files this module uses
//
#include <PiDxe.h>
//
// The protocols, PPI and GUID defintions for this module
//
#include <Protocol/SecurityPolicy.h>
#include <Protocol/GuidedSectionExtaction.h>
//
// The Library classes this module consumes
//
#include <Library/MemoryAllocationLib.h>
#include <Library/DebugLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/BaseMemoryLib.h>
#include <Library/UefiBootServicesTableLib.h>
typedef struct {
EFI_GUID_DEFINED_SECTION GuidedSectionHeader;
UINT32 CRC32Checksum;
} CRC32_SECTION_HEADER;
//
// Function prototype declarations
//
STATIC
EFI_STATUS
EFIAPI
Crc32ExtractSection (
IN EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL *This,
IN VOID *InputSection,
OUT VOID **OutputBuffer,
OUT UINTN *OutputSize,
OUT UINT32 *AuthenticationStatus
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
InputSection - TODO: add argument description
OutputBuffer - TODO: add argument description
OutputSize - TODO: add argument description
AuthenticationStatus - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
EFIAPI
InitializeCrc32GuidedSectionExtractionProtocol (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
/*++
Routine Description:
Entry point of the CRC32 GUIDed section extraction protocol.
Creates and initializes an instance of the GUIDed section
extraction protocol with CRC32 GUID.
Arguments:
ImageHandle EFI_HANDLE: A handle for the image that is initializing
this driver
SystemTable EFI_SYSTEM_TABLE: A pointer to the EFI system table
Returns:
EFI_SUCCESS: Driver initialized successfully
EFI_LOAD_ERROR: Failed to Initialize or has been loaded
EFI_OUT_OF_RESOURCES: Could not allocate needed resources
--*/
;
#endif

View File

@ -0,0 +1,88 @@
#/** @file
# Component description file for Crc32SectionExtract module.
#
# This driver implements CRC32 GUIDed section extraction protocol interface.
# 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 = Crc32SectionExtract
FILE_GUID = 51C9F40C-5243-4473-B265-B3C8FFAFF9FA
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
EDK_RELEASE_VERSION = 0x00020000
EFI_SPECIFICATION_VERSION = 0x00020000
ENTRY_POINT = InitializeCrc32GuidedSectionExtractionProtocol
#
# 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]
Crc32SectionExtract.dxs
GuidedSection.h
GuidedSection.c
Crc32SectionExtract.h
Crc32SectionExtract.c
################################################################################
#
# 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]
MemoryAllocationLib
UefiBootServicesTableLib
BaseMemoryLib
UefiDriverEntryPoint
DebugLib
################################################################################
#
# Protocol C Name Section - list of Protocol and Protocol Notify C Names
# that this module uses or produces.
#
################################################################################
[Protocols]
gEfiSecurityPolicyProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
gEfiCrc32GuidedSectionExtractionProtocolGuid # PROTOCOL ALWAYS_PRODUCED

View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<MsaHeader>
<ModuleName>Crc32SectionExtract</ModuleName>
<ModuleType>DXE_DRIVER</ModuleType>
<GuidValue>51C9F40C-5243-4473-B265-B3C8FFAFF9FA</GuidValue>
<Version>1.0</Version>
<Abstract>Component description file for Crc32SectionExtract module.</Abstract>
<Description>This driver implements CRC32 GUIDed section extraction protocol interface.</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>Crc32SectionExtract</OutputFileBasename>
</ModuleDefinitions>
<LibraryClassDefinitions>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>DebugLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiDriverEntryPoint</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>BaseMemoryLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiBootServicesTableLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>MemoryAllocationLib</Keyword>
</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>Crc32SectionExtract.c</Filename>
<Filename>Crc32SectionExtract.h</Filename>
<Filename>GuidedSection.c</Filename>
<Filename>GuidedSection.h</Filename>
<Filename>Crc32SectionExtract.dxs</Filename>
</SourceFiles>
<PackageDependencies>
<Package PackageGuid="1E73767F-8F52-4603-AEB4-F29B510B6766"/>
</PackageDependencies>
<Protocols>
<Protocol Usage="SOMETIMES_CONSUMED">
<ProtocolCName>gEfiSecurityPolicyProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_PRODUCED">
<ProtocolCName>gEfiCrc32GuidedSectionExtractionProtocolGuid</ProtocolCName>
</Protocol>
</Protocols>
<Externs>
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
<Extern>
<ModuleEntryPoint>InitializeCrc32GuidedSectionExtractionProtocol</ModuleEntryPoint>
</Extern>
</Externs>
</ModuleSurfaceArea>

View File

@ -0,0 +1,61 @@
/*++
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:
GuidedSection.c
Abstract:
GUIDed section extraction protocol implementation.
This contains the common constructor of GUIDed section
extraction protocol. GUID specific implementation of each
GUIDed section extraction protocol can be found in other
files under the same directory.
--*/
#include "GuidedSection.h"
EFI_STATUS
GuidedSectionExtractionProtocolConstructor (
OUT EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL **GuidedSep,
IN EFI_EXTRACT_GUIDED_SECTION ExtractSection
)
/*++
Routine Description:
Constructor for the GUIDed section extraction protocol. Initializes
instance data.
Arguments:
This Instance to construct
Returns:
EFI_SUCCESS: Instance initialized.
--*/
// TODO: GuidedSep - add argument and description to function comment
// TODO: ExtractSection - add argument and description to function comment
// TODO: EFI_OUT_OF_RESOURCES - add return value to function comment
{
*GuidedSep = AllocatePool (sizeof (EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL));
if (*GuidedSep == NULL) {
return EFI_OUT_OF_RESOURCES;
}
(*GuidedSep)->ExtractSection = ExtractSection;
return EFI_SUCCESS;
}

View File

@ -0,0 +1,54 @@
/*++
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:
GuidedSection.h
Abstract:
Header file for GuidedSection.c
Please refer to the Framewokr Firmware Volume Specification 0.9.
--*/
#ifndef _GUIDED_SECTION_EXTRACTION_H
#define _GUIDED_SECTION_EXTRACTION_H
#include "Crc32SectionExtract.h"
//
// Function prototype declarations
//
EFI_STATUS
GuidedSectionExtractionProtocolConstructor (
OUT EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL **GuidedSep,
IN EFI_EXTRACT_GUIDED_SECTION ExtractSection
)
/*++
Routine Description:
TODO: Add function description
Arguments:
GuidedSep - TODO: add argument description
ExtractSection - TODO: add argument description
Returns:
TODO: add return values
--*/
;
#endif