Add in UefiApplicationEntryPoint library class and library instance.

The major difference between UefiApplicationEntryPoint and UefiDriverEntryPoint is that:
1) UEFI application will always be unloaded no matter what is the return status code from the application. Therefore, the library destructors should be called always.
2) UEFI application should not register any callback to evevnt such as EFI_EVENT_GROUP_VIRTUAL_ADDRESS_CHANGE and EFI_EVENT_GROUP_EXIT_BOOT_SERVICES.
3) UEFI application does not support module merger like Uefi Driver.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2199 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qwang12 2007-01-09 08:17:21 +00:00
parent fe64f4ffd6
commit b244c7dc74
5 changed files with 289 additions and 22 deletions

View File

@ -0,0 +1,129 @@
/** @file
Entry point to a UEFI Application.
Copyright (c) 2007, Intel Corporation<BR>
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 __UEFI_APPLICATION_ENTRY_POINT_H__
#define __UEFI_APPLICATION_ENTRY_POINT_H__
//
// Declare the EFI/UEFI Specification Revision to which this driver is implemented
//
extern const UINT32 _gUefiDriverRevision;
/**
Enrty point to UEFI Application.
@param ImageHandle ImageHandle of the loaded driver.
@param SystemTable Pointer to the EFI System Table.
@retval EFI_SUCCESS One or more of the drivers returned a success code.
@retval !EFI_SUCESS The return status from the last driver entry point in the list.
**/
EFI_STATUS
EFIAPI
_ModuleEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
/**
Enrty point wrapper of UEFI Application.
@param ImageHandle ImageHandle of the loaded driver.
@param SystemTable Pointer to the EFI System Table.
@retval EFI_SUCCESS One or more of the drivers returned a success code.
@retval !EFI_SUCESS The return status from the last driver entry point in the list.
**/
EFI_STATUS
EFIAPI
EfiMain (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
/**
Invoke the destuctors of all libraries and call gBS->Exit
to return control to firmware core.
@param Status Status returned by the application that is exiting.
@retval VOID
**/
VOID
EFIAPI
Exit (
IN EFI_STATUS Status
);
/**
Call constructors for all libraries. Autogen tool inserts the implementation
of this function into Autogen.c.
@param ImageHandle ImageHandle of the loaded driver.
@param SystemTable Pointer to the EFI System Table.
@retval VOID
**/
VOID
EFIAPI
ProcessLibraryConstructorList (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
/**
Call destructors for all libraries. Autogen tool inserts the implementation
of this function into Autogen.c.
@param ImageHandle ImageHandle of the loaded driver.
@param SystemTable Pointer to the EFI System Table.
@retval VOID
**/
VOID
EFIAPI
ProcessLibraryDestructorList (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
/**
Call driver entry point. For UEFI application, user
can only specify one entry point. Tool will automatically insert
this to Autogen.c.
@param ImageHandle ImageHandle of the loaded driver.
@param SystemTable Pointer to the EFI System Table.
@return Status returned by entry points specified by
the user.
**/
EFI_STATUS
EFIAPI
ProcessModuleEntryPointList (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
#endif

View File

@ -0,0 +1,103 @@
/** @file
Entry point library instance to a UEFI application.
Copyright (c) 2007, Intel Corporation<BR>
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.
**/
/**
Enrty point to UEFI application.
@param ImageHandle ImageHandle of the loaded driver.
@param SystemTable Pointer to the EFI System Table.
@retval EFI_SUCCESS One or more of the drivers returned a success code.
@retval !EFI_SUCESS The return status from the last driver entry point in the list.
**/
EFI_STATUS
EFIAPI
_ModuleEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
if (_gUefiDriverRevision != 0) {
//
// Make sure that the EFI/UEFI spec revision of the platform is >= EFI/UEFI spec revision of the application.
//
if (SystemTable->Hdr.Revision < _gUefiDriverRevision) {
return EFI_INCOMPATIBLE_VERSION;
}
}
//
// Call constructor for all libraries.
//
ProcessLibraryConstructorList (ImageHandle, SystemTable);
//
// Call the module's entry point
//
Status = ProcessModuleEntryPointList (ImageHandle, SystemTable);
//
// Process destructor for all libraries.
//
ProcessLibraryDestructorList (ImageHandle, SystemTable);
//
// Return the return status code from the driver entry point
//
return Status;
}
/**
Invoke the destuctors of all libraries and call gBS->Exit
to return control to firmware core.
@param Status Status returned by the application that is exiting.
@retval VOID
**/
VOID
EFIAPI
Exit (
IN EFI_STATUS Status
)
{
ProcessLibraryDestructorList (gImageHandle, gST);
gBS->Exit (gImageHandle, Status, 0, NULL);
}
/**
Enrty point wrapper of UEFI Application.
@param ImageHandle ImageHandle of the loaded driver.
@param SystemTable Pointer to the EFI System Table.
@retval EFI_SUCCESS One or more of the drivers returned a success code.
@retval !EFI_SUCESS The return status from the last driver entry point in the list.
**/
EFI_STATUS
EFIAPI
EfiMain (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
return _ModuleEntryPoint (ImageHandle, SystemTable);
}

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">
<MsaHeader>
<ModuleName>UefiApplicationEntryPoint</ModuleName>
<ModuleType>UEFI_DRIVER</ModuleType>
<GuidValue>DADE8301-CB29-4fd5-8148-56FD246C5B88</GuidValue>
<Version>1.0</Version>
<Abstract>Component description file for the entry point to a EFI Application</Abstract>
<Description>Library to abstract entry point to a EFI Application.</Description>
<Copyright>Copyright (c) 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>UefiApplicationEntryPoint</OutputFileBasename>
</ModuleDefinitions>
<LibraryClassDefinitions>
<LibraryClass Usage="ALWAYS_PRODUCED">
<Keyword>UefiApplicationEntryPoint</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiBootServicesTableLib</Keyword>
</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>ApplicationEntryPoint.c</Filename>
</SourceFiles>
<PackageDependencies>
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
</PackageDependencies>
<Externs>
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
</Externs>
</ModuleSurfaceArea>

View File

@ -6,7 +6,7 @@
<Version>0.3</Version>
<Abstract>EFI/Tiano MdePkg Package</Abstract>
<Description>This FPD file is used for Package Level build.</Description>
<Copyright>Copyright (c) 2006, Intel Corporation</Copyright>
<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
@ -100,16 +100,6 @@
</ModuleSaBuildOptions>
</ModuleSA>
<ModuleSA SupArchList="IA32" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" ModuleGuid="926c9cd0-4bb8-479b-9ac4-8a2a23f85307">
<PcdBuildDefinition>
<PcdData ItemType="FIXED_AT_BUILD">
<C_Name>PcdIoBlockBaseAddressForIpf</C_Name>
<Token>0x0000000c</Token>
<TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
<DatumType>UINT64</DatumType>
<MaxDatumSize>8</MaxDatumSize>
<Value>0x0ffffc000000</Value>
</PcdData>
</PcdBuildDefinition>
<ModuleSaBuildOptions>
<FvBinding>NULL</FvBinding>
<FfsFormatKey>LIBRARY</FfsFormatKey>
@ -1248,16 +1238,6 @@
</ModuleSaBuildOptions>
</ModuleSA>
<ModuleSA SupArchList="X64" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" ModuleGuid="926c9cd0-4bb8-479b-9ac4-8a2a23f85307">
<PcdBuildDefinition>
<PcdData ItemType="FIXED_AT_BUILD">
<C_Name>PcdIoBlockBaseAddressForIpf</C_Name>
<Token>0x0000000c</Token>
<TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
<DatumType>UINT64</DatumType>
<MaxDatumSize>8</MaxDatumSize>
<Value>0x0ffffc000000</Value>
</PcdData>
</PcdBuildDefinition>
<ModuleSaBuildOptions>
<FvBinding>NULL</FvBinding>
<FfsFormatKey>LIBRARY</FfsFormatKey>
@ -2332,6 +2312,14 @@
<FfsFormatKey>LIBRARY</FfsFormatKey>
</ModuleSaBuildOptions>
</ModuleSA>
<!--Mod: UefiApplicationEntryPoint Type: UEFI_DRIVER Path: MdePkg\Library\UefiApplicationEntryPoint\UefiApplicationEntryPoint.msa-->
<ModuleSA ModuleGuid="DADE8301-CB29-4fd5-8148-56FD246C5B88" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3" SupArchList="IA32"/>
<!--Mod: UefiApplicationEntryPoint Type: UEFI_DRIVER Path: MdePkg\Library\UefiApplicationEntryPoint\UefiApplicationEntryPoint.msa-->
<ModuleSA ModuleGuid="DADE8301-CB29-4fd5-8148-56FD246C5B88" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3" SupArchList="X64"/>
<!--Mod: UefiApplicationEntryPoint Type: UEFI_DRIVER Path: MdePkg\Library\UefiApplicationEntryPoint\UefiApplicationEntryPoint.msa-->
<ModuleSA ModuleGuid="DADE8301-CB29-4fd5-8148-56FD246C5B88" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3" SupArchList="IPF"/>
<!--Mod: UefiApplicationEntryPoint Type: UEFI_DRIVER Path: MdePkg\Library\UefiApplicationEntryPoint\UefiApplicationEntryPoint.msa-->
<ModuleSA ModuleGuid="DADE8301-CB29-4fd5-8148-56FD246C5B88" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3" SupArchList="EBC"/>
</FrameworkModules>
<BuildOptions>
<Ffs FfsKey="APPLICATION">

View File

@ -6,7 +6,7 @@
<Version>0.3</Version>
<Abstract>Framework Module Development Environment Industry Standards</Abstract>
<Description>This Package provides headers and libraries that conform to EFI/Framework Industry standards.</Description>
<Copyright>Copyright (c) 2006, Intel Corporation.</Copyright>
<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.
@ -174,6 +174,10 @@
<IncludeHeader>Include/Library/UefiRuntimeServicesTableLib.h</IncludeHeader>
<HelpText/>
</LibraryClass>
<LibraryClass Name="UefiApplicationEntryPoint" SupArchList="IA32 X64 IPF EBC ARM PPC" SupModuleList="UEFI_APPLICATION">
<IncludeHeader>Include/Library/UefiApplicationEntryPoint.h</IncludeHeader>
<HelpText>Library to abstract entry point to a EFI Application.</HelpText>
</LibraryClass>
</LibraryClassDeclarations>
<IndustryStdIncludes>
<IndustryStdHeader Name="BaseTypes">
@ -1180,6 +1184,7 @@
<Filename>Library/UefiLib/UefiLib.msa</Filename>
<Filename>Library/DxeMemoryLib/DxeMemoryLib.msa</Filename>
<Filename>Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.msa</Filename>
<Filename>Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.msa</Filename>
</MsaFiles>
<PackageHeaders>
<IncludePkgHeader ModuleType="BASE">Include/Base.h</IncludePkgHeader>