/*++\r
\r
-Copyright (c) 2006, Intel Corporation \r
-All rights reserved. This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php \r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+Copyright (c) 2006 - 2007, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
Module Name:\r
\r
\r
#include <DxeMain.h>\r
\r
-VOID\r
-EFIAPI\r
-DxeMain (\r
- IN VOID *HobStart\r
- );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-CoreEfiNotAvailableYetArg0 (\r
- VOID\r
- );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-CoreEfiNotAvailableYetArg1 (\r
- UINTN Arg1\r
- );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-CoreEfiNotAvailableYetArg2 (\r
- UINTN Arg1,\r
- UINTN Arg2\r
- );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-CoreEfiNotAvailableYetArg3 (\r
- UINTN Arg1,\r
- UINTN Arg2,\r
- UINTN Arg3\r
- );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-CoreEfiNotAvailableYetArg4 (\r
- UINTN Arg1,\r
- UINTN Arg2,\r
- UINTN Arg3,\r
- UINTN Arg4\r
- );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-CoreEfiNotAvailableYetArg5 (\r
- UINTN Arg1,\r
- UINTN Arg2,\r
- UINTN Arg3,\r
- UINTN Arg4,\r
- UINTN Arg5\r
- );\r
-\r
-EFI_STATUS\r
-CoreGetPeiProtocol (\r
- IN EFI_GUID *ProtocolGuid,\r
- IN VOID **Interface\r
- );\r
- \r
-EFI_STATUS\r
-DxeMainUefiDecompressGetInfo (\r
- IN EFI_DECOMPRESS_PROTOCOL *This,\r
- IN VOID *Source,\r
- IN UINT32 SourceSize,\r
- OUT UINT32 *DestinationSize,\r
- OUT UINT32 *ScratchSize\r
- );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DxeMainUefiDecompress (\r
- IN EFI_DECOMPRESS_PROTOCOL *This,\r
- IN VOID *Source,\r
- IN UINT32 SourceSize,\r
- IN OUT VOID *Destination,\r
- IN UINT32 DestinationSize,\r
- IN OUT VOID *Scratch,\r
- IN UINT32 ScratchSize\r
- );\r
-\r
-EFI_STATUS\r
-DxeMainTianoDecompressGetInfo (\r
- IN EFI_TIANO_DECOMPRESS_PROTOCOL *This,\r
- IN VOID *Source,\r
- IN UINT32 SourceSize,\r
- OUT UINT32 *DestinationSize,\r
- OUT UINT32 *ScratchSize\r
- );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DxeMainTianoDecompress (\r
- IN EFI_TIANO_DECOMPRESS_PROTOCOL *This,\r
- IN VOID *Source,\r
- IN UINT32 SourceSize,\r
- IN OUT VOID *Destination,\r
- IN UINT32 DestinationSize,\r
- IN OUT VOID *Scratch,\r
- IN UINT32 ScratchSize\r
- );\r
-\r
-EFI_STATUS\r
-DxeMainCustomDecompressGetInfo (\r
- IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL *This,\r
- IN VOID *Source,\r
- IN UINT32 SourceSize,\r
- OUT UINT32 *DestinationSize,\r
- OUT UINT32 *ScratchSize\r
- );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DxeMainCustomDecompress (\r
- IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL *This,\r
- IN VOID *Source,\r
- IN UINT32 SourceSize,\r
- IN OUT VOID *Destination,\r
- IN UINT32 DestinationSize,\r
- IN OUT VOID *Scratch,\r
- IN UINT32 ScratchSize\r
- );\r
-\r
//\r
// DXE Core Global Variables for Protocols from PEI\r
//\r
EFI_TIMER_ARCH_PROTOCOL *gTimer = NULL;\r
EFI_BDS_ARCH_PROTOCOL *gBds = NULL;\r
EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *gWatchdogTimer = NULL;\r
-EFI_RUNTIME_ARCH_PROTOCOL *gRuntime = NULL;\r
+\r
\r
//\r
// BugBug: I'n not runtime, but is the PPI?\r
sizeof (EFI_BOOT_SERVICES), // HeaderSize\r
0, // CRC32\r
0 // Reserved\r
- }, \r
+ },\r
(EFI_RAISE_TPL) CoreRaiseTpl, // RaiseTPL\r
(EFI_RESTORE_TPL) CoreRestoreTpl, // RestoreTPL\r
(EFI_ALLOCATE_PAGES) CoreAllocatePages, // AllocatePages\r
(EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES) CoreUninstallMultipleProtocolInterfaces, // UninstallMultipleProtocolInterfaces\r
(EFI_CALCULATE_CRC32) CoreEfiNotAvailableYetArg3, // CalculateCrc32\r
(EFI_COPY_MEM) CopyMem, // CopyMem\r
- (EFI_SET_MEM) SetMem // SetMem\r
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
- , \r
- (EFI_CREATE_EVENT_EX) CoreCreateEventEx // CreateEventEx\r
-#endif\r
+ (EFI_SET_MEM) SetMem, // SetMem\r
+ (EFI_CREATE_EVENT_EX) CoreCreateEventEx // CreateEventEx\r
};\r
\r
EFI_DXE_SERVICES mDxeServices = {\r
0, // CRC32\r
0 // Reserved\r
},\r
- (EFI_GET_TIME) CoreEfiNotAvailableYetArg2, // GetTime\r
- (EFI_SET_TIME) CoreEfiNotAvailableYetArg1, // SetTime\r
- (EFI_GET_WAKEUP_TIME) CoreEfiNotAvailableYetArg3, // GetWakeupTime\r
- (EFI_SET_WAKEUP_TIME) CoreEfiNotAvailableYetArg2, // SetWakeupTime\r
- (EFI_SET_VIRTUAL_ADDRESS_MAP) CoreEfiNotAvailableYetArg4, // SetVirtualAddressMap\r
- (EFI_CONVERT_POINTER) CoreEfiNotAvailableYetArg2, // ConvertPointer\r
- (EFI_GET_VARIABLE) CoreEfiNotAvailableYetArg5, // GetVariable\r
- (EFI_GET_NEXT_VARIABLE_NAME) CoreEfiNotAvailableYetArg3, // GetNextVariableName\r
- (EFI_SET_VARIABLE) CoreEfiNotAvailableYetArg5, // SetVariable\r
- (EFI_GET_NEXT_HIGH_MONO_COUNT) CoreEfiNotAvailableYetArg1, // GetNextHighMonotonicCount\r
- (EFI_RESET_SYSTEM) CoreEfiNotAvailableYetArg4 // ResetSystem \r
-#if ((EDK_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION < 0x00020000))\r
- //\r
- // This Tiano extension was removed when UEFI 2.0 support was added. \r
- // It's now just a protocol.\r
- //\r
- ,\r
- (EFI_REPORT_STATUS_CODE) CoreEfiNotAvailableYetArg5 // ReportStatusCode\r
-#elif (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
- //\r
- // New runtime services added by UEFI 2.0\r
- //\r
- ,\r
+ (EFI_GET_TIME) CoreEfiNotAvailableYetArg2, // GetTime\r
+ (EFI_SET_TIME) CoreEfiNotAvailableYetArg1, // SetTime\r
+ (EFI_GET_WAKEUP_TIME) CoreEfiNotAvailableYetArg3, // GetWakeupTime\r
+ (EFI_SET_WAKEUP_TIME) CoreEfiNotAvailableYetArg2, // SetWakeupTime\r
+ (EFI_SET_VIRTUAL_ADDRESS_MAP) CoreEfiNotAvailableYetArg4, // SetVirtualAddressMap\r
+ (EFI_CONVERT_POINTER) CoreEfiNotAvailableYetArg2, // ConvertPointer\r
+ (EFI_GET_VARIABLE) CoreEfiNotAvailableYetArg5, // GetVariable\r
+ (EFI_GET_NEXT_VARIABLE_NAME) CoreEfiNotAvailableYetArg3, // GetNextVariableName\r
+ (EFI_SET_VARIABLE) CoreEfiNotAvailableYetArg5, // SetVariable\r
+ (EFI_GET_NEXT_HIGH_MONO_COUNT) CoreEfiNotAvailableYetArg1, // GetNextHighMonotonicCount\r
+ (EFI_RESET_SYSTEM) CoreEfiNotAvailableYetArg4, // ResetSystem\r
(EFI_UPDATE_CAPSULE) CoreEfiNotAvailableYetArg3, // UpdateCapsule\r
(EFI_QUERY_CAPSULE_CAPABILITIES) CoreEfiNotAvailableYetArg4, // QueryCapsuleCapabilities\r
(EFI_QUERY_VARIABLE_INFO) CoreEfiNotAvailableYetArg4 // QueryVariableInfo\r
-#endif\r
};\r
\r
+EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate = {\r
+ INITIALIZE_LIST_HEAD_VARIABLE (gRuntimeTemplate.ImageHead),\r
+ INITIALIZE_LIST_HEAD_VARIABLE (gRuntimeTemplate.EventHead),\r
+\r
+ //\r
+ // Make sure Size != sizeof (EFI_MEMORY_DESCRIPTOR). This will\r
+ // prevent people from having pointer math bugs in their code.\r
+ // now you have to use *DescriptorSize to make things work.\r
+ //\r
+ sizeof (EFI_MEMORY_DESCRIPTOR) + sizeof (UINT64) - (sizeof (EFI_MEMORY_DESCRIPTOR) % sizeof (UINT64)),\r
+ EFI_MEMORY_DESCRIPTOR_VERSION,\r
+ 0,\r
+ NULL,\r
+ NULL,\r
+ FALSE,\r
+ FALSE\r
+};\r
+\r
+EFI_RUNTIME_ARCH_PROTOCOL *gRuntime = &gRuntimeTemplate;\r
+\r
//\r
-// DXE Core Global Variables for the EFI System Table, Boot Services Table, \r
+// DXE Core Global Variables for the EFI System Table, Boot Services Table,\r
// DXE Services Table, and Runtime Services Table\r
//\r
EFI_BOOT_SERVICES *gBS = &mBootServices;\r
ASSERT (gRT != NULL);\r
\r
gST->RuntimeServices = gRT;\r
- \r
+\r
//\r
// Start the Image Services.\r
//\r
// Call constructor for all libraries\r
//\r
ProcessLibraryConstructorList (gDxeCoreImageHandle, gST);\r
+ PERF_END (0,PEI_TOK, NULL, 0) ;\r
+ PERF_START (0,DXE_TOK, NULL, 0) ;\r
\r
//\r
// Initialize the Global Coherency Domain Services\r
ASSERT_EFI_ERROR (Status);\r
\r
//\r
- // Initialize the ReportStatusCode with PEI version, if availible\r
+ // Initialize the ReportStatusCode with PEI version, if available\r
//\r
CoreGetPeiProtocol (&gEfiStatusCodeRuntimeProtocolGuid, (VOID **)&gStatusCode->ReportStatusCode);\r
-#if ((EDK_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION < 0x00020000))\r
- //\r
- // This Tiano extension was removed when UEFI 2.0 support was added. \r
- // It's now just a protocol.\r
- //\r
- gRT->ReportStatusCode = gStatusCode->ReportStatusCode;\r
-#endif\r
\r
//\r
// Report Status Code here for DXE_ENTRY_POINT once it is available\r
Status = CoreInitializeEventServices ();\r
ASSERT_EFI_ERROR (Status);\r
\r
- \r
+\r
//\r
// Get the Protocols that were passed in from PEI to DXE through GUIDed HOBs\r
//\r
- // These Protocols are not architectural. This implementation is sharing code between \r
- // PEI and DXE in order to save FLASH space. These Protocols could also be implemented \r
- // as part of the DXE Core. However, that would also require the DXE Core to be ported \r
- // each time a different CPU is used, a different Decompression algorithm is used, or a \r
- // different Image type is used. By placing these Protocols in PEI, the DXE Core remains \r
- // generic, and only PEI and the Arch Protocols need to be ported from Platform to Platform, \r
+ // These Protocols are not architectural. This implementation is sharing code between\r
+ // PEI and DXE in order to save FLASH space. These Protocols could also be implemented\r
+ // as part of the DXE Core. However, that would also require the DXE Core to be ported\r
+ // each time a different CPU is used, a different Decompression algorithm is used, or a\r
+ // different Image type is used. By placing these Protocols in PEI, the DXE Core remains\r
+ // generic, and only PEI and the Arch Protocols need to be ported from Platform to Platform,\r
// and from CPU to CPU.\r
//\r
\r
//\r
// Publish the EFI, Tiano, and Custom Decompress protocols for use by other DXE components\r
- // \r
+ //\r
Status = CoreInstallMultipleProtocolInterfaces (\r
&mDecompressHandle,\r
&gEfiDecompressProtocolGuid, &gEfiDecompress,\r
ASSERT_EFI_ERROR (Status);\r
\r
//\r
- // Produce the Section Extraction Protocol \r
+ // Produce the Section Extraction Protocol\r
//\r
Status = InitializeSectionExtraction (gDxeCoreImageHandle, gST);\r
ASSERT_EFI_ERROR (Status);\r
DEBUG_CODE_BEGIN ();\r
CoreDisplayMissingArchProtocols ();\r
DEBUG_CODE_END ();\r
- \r
+\r
//\r
// Assert if the Architectural Protocols are not present.\r
//\r
// Transfer control to the BDS Architectural Protocol\r
//\r
gBds->Entry (gBds);\r
- \r
+\r
//\r
// BDS should never return\r
//\r
Arguments:\r
\r
Arg1 - Undefined\r
- \r
+\r
Arg2 - Undefined\r
\r
Returns:\r
Arguments:\r
\r
Arg1 - Undefined\r
- \r
+\r
Arg2 - Undefined\r
- \r
+\r
Arg3 - Undefined\r
\r
Returns:\r
Arguments:\r
\r
Arg1 - Undefined\r
- \r
+\r
Arg2 - Undefined\r
- \r
+\r
Arg3 - Undefined\r
- \r
+\r
Arg4 - Undefined\r
\r
Returns:\r
Arguments:\r
\r
Arg1 - Undefined\r
- \r
+\r
Arg2 - Undefined\r
- \r
+\r
Arg3 - Undefined\r
- \r
+\r
Arg4 - Undefined\r
- \r
+\r
Arg5 - Undefined\r
\r
Returns:\r
if (GuidHob == NULL) {\r
return EFI_NOT_FOUND;\r
}\r
- \r
+\r
Buffer = GET_GUID_HOB_DATA (GuidHob);\r
ASSERT (Buffer != NULL);\r
\r
UINT32 Crc;\r
\r
Hdr->CRC32 = 0;\r
- \r
+\r
//\r
// If gBS->CalculateCrce32 () == CoreEfiNotAvailableYet () then\r
// Crc will come back as zero if we set it to zero here\r
//\r
Crc = 0;\r
gBS->CalculateCrc32 ((UINT8 *)Hdr, Hdr->HeaderSize, &Crc);\r
- Hdr->CRC32 = Crc; \r
+ Hdr->CRC32 = Crc;\r
}\r
\r
\r
\r
Routine Description:\r
\r
- EFI 1.0 API to terminate Boot Services\r
+ Terminates all boot services.\r
\r
Arguments:\r
\r
- ImageHandle - Handle that represents the identity of the calling image\r
+ ImageHandle - Handle that identifies the exiting image.\r
\r
MapKey -Key to the latest memory map.\r
\r
//\r
gCpu->DisableInterrupt (gCpu);\r
\r
- //\r
- // Register Runtime events with the Runtime Architectural Protocol\r
- //\r
- CoreShutdownEventServices ();\r
-\r
- //\r
- // Register Runtime images with the Runtime Architectural Protocol\r
- //\r
- CoreShutdownImageServices ();\r
-\r
//\r
// Report that ExitBootServices() has been called\r
//\r
SetMem (gBS, sizeof (EFI_BOOT_SERVICES), 0);\r
gBS = NULL;\r
\r
+ //\r
+ // Update the AtRuntime field in Runtiem AP.\r
+ //\r
+ gRuntime->AtRuntime = TRUE;\r
+\r
return Status;\r
}\r
\r
OUT UINT32 *ScratchSize\r
)\r
{\r
+ if (Source == NULL \r
+ || DestinationSize == NULL \r
+ || ScratchSize == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
return UefiDecompressGetInfo (Source, SourceSize, DestinationSize, ScratchSize);\r
}\r
\r
EFI_STATUS Status;\r
UINT32 TestDestinationSize;\r
UINT32 TestScratchSize;\r
-\r
+ \r
+ if (Source == NULL \r
+ || Destination== NULL \r
+ || Scratch == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+ \r
Status = UefiDecompressGetInfo (Source, SourceSize, &TestDestinationSize, &TestScratchSize);\r
if (EFI_ERROR (Status)) {\r
return Status;\r
OUT UINT32 *ScratchSize\r
)\r
{\r
+ if (Source == NULL \r
+ || DestinationSize == NULL \r
+ || ScratchSize == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
return TianoDecompressGetInfo (Source, SourceSize, DestinationSize, ScratchSize);\r
}\r
\r
EFI_STATUS Status;\r
UINT32 TestDestinationSize;\r
UINT32 TestScratchSize;\r
-\r
+ \r
+ if (Source == NULL \r
+ || Destination== NULL \r
+ || Scratch == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+ \r
Status = TianoDecompressGetInfo (Source, SourceSize, &TestDestinationSize, &TestScratchSize);\r
if (EFI_ERROR (Status)) {\r
return Status;\r
OUT UINT32 *ScratchSize\r
)\r
{\r
+ if (Source == NULL \r
+ || DestinationSize == NULL \r
+ || ScratchSize == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+ \r
return CustomDecompressGetInfo (Source, SourceSize, DestinationSize, ScratchSize);\r
}\r
\r
UINT32 TestDestinationSize;\r
UINT32 TestScratchSize;\r
\r
+ if (Source == NULL \r
+ || Destination== NULL \r
+ || Scratch == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
Status = CustomDecompressGetInfo (Source, SourceSize, &TestDestinationSize, &TestScratchSize);\r
if (EFI_ERROR (Status)) {\r
return Status;\r