2008-05-21 03:40:12 +02:00
|
|
|
/** @file
|
|
|
|
The file contains the GCD related services in the EFI Boot Services Table.
|
2008-07-24 04:54:45 +02:00
|
|
|
The GCD services are used to manage the memory and I/O regions that
|
2008-07-18 11:50:09 +02:00
|
|
|
are accessible to the CPU that is executing the DXE core.
|
2008-04-09 09:07:50 +02:00
|
|
|
|
2011-01-06 03:51:08 +01:00
|
|
|
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
|
2010-04-24 11:49:11 +02:00
|
|
|
This program and the accompanying materials
|
2008-05-21 03:40:12 +02:00
|
|
|
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.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-04-09 09:07:50 +02:00
|
|
|
**/
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-08-27 16:29:23 +02:00
|
|
|
#include "DxeMain.h"
|
2008-09-23 09:35:34 +02:00
|
|
|
#include "Gcd.h"
|
2007-07-04 12:51:54 +02:00
|
|
|
|
|
|
|
#define MINIMUM_INITIAL_MEMORY_SIZE 0x10000
|
|
|
|
|
|
|
|
#define MEMORY_ATTRIBUTE_MASK (EFI_RESOURCE_ATTRIBUTE_PRESENT | \
|
|
|
|
EFI_RESOURCE_ATTRIBUTE_INITIALIZED | \
|
|
|
|
EFI_RESOURCE_ATTRIBUTE_TESTED | \
|
|
|
|
EFI_RESOURCE_ATTRIBUTE_READ_PROTECTED | \
|
|
|
|
EFI_RESOURCE_ATTRIBUTE_WRITE_PROTECTED | \
|
|
|
|
EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTED | \
|
|
|
|
EFI_RESOURCE_ATTRIBUTE_16_BIT_IO | \
|
|
|
|
EFI_RESOURCE_ATTRIBUTE_32_BIT_IO | \
|
2008-07-24 04:54:45 +02:00
|
|
|
EFI_RESOURCE_ATTRIBUTE_64_BIT_IO )
|
2007-07-04 12:51:54 +02:00
|
|
|
|
|
|
|
#define TESTED_MEMORY_ATTRIBUTES (EFI_RESOURCE_ATTRIBUTE_PRESENT | \
|
|
|
|
EFI_RESOURCE_ATTRIBUTE_INITIALIZED | \
|
|
|
|
EFI_RESOURCE_ATTRIBUTE_TESTED )
|
|
|
|
|
|
|
|
#define INITIALIZED_MEMORY_ATTRIBUTES (EFI_RESOURCE_ATTRIBUTE_PRESENT | \
|
|
|
|
EFI_RESOURCE_ATTRIBUTE_INITIALIZED )
|
|
|
|
|
|
|
|
#define PRESENT_MEMORY_ATTRIBUTES (EFI_RESOURCE_ATTRIBUTE_PRESENT)
|
|
|
|
|
|
|
|
#define INVALID_CPU_ARCH_ATTRIBUTES 0xffffffff
|
|
|
|
|
|
|
|
//
|
|
|
|
// Module Variables
|
|
|
|
//
|
|
|
|
EFI_LOCK mGcdMemorySpaceLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY);
|
|
|
|
EFI_LOCK mGcdIoSpaceLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY);
|
|
|
|
LIST_ENTRY mGcdMemorySpaceMap = INITIALIZE_LIST_HEAD_VARIABLE (mGcdMemorySpaceMap);
|
|
|
|
LIST_ENTRY mGcdIoSpaceMap = INITIALIZE_LIST_HEAD_VARIABLE (mGcdIoSpaceMap);
|
|
|
|
|
|
|
|
EFI_GCD_MAP_ENTRY mGcdMemorySpaceMapEntryTemplate = {
|
|
|
|
EFI_GCD_MAP_SIGNATURE,
|
2008-07-24 04:54:45 +02:00
|
|
|
{
|
2008-07-18 11:50:09 +02:00
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
},
|
2007-07-04 12:51:54 +02:00
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
EfiGcdMemoryTypeNonExistent,
|
|
|
|
(EFI_GCD_IO_TYPE) 0,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
EFI_GCD_MAP_ENTRY mGcdIoSpaceMapEntryTemplate = {
|
|
|
|
EFI_GCD_MAP_SIGNATURE,
|
2008-07-18 11:50:09 +02:00
|
|
|
{
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
},
|
2007-07-04 12:51:54 +02:00
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
(EFI_GCD_MEMORY_TYPE) 0,
|
|
|
|
EfiGcdIoTypeNonExistent,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
GCD_ATTRIBUTE_CONVERSION_ENTRY mAttributeConversionTable[] = {
|
|
|
|
{ EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, EFI_MEMORY_UC, TRUE },
|
2008-07-24 04:54:45 +02:00
|
|
|
{ EFI_RESOURCE_ATTRIBUTE_UNCACHED_EXPORTED, EFI_MEMORY_UCE, TRUE },
|
2007-07-04 12:51:54 +02:00
|
|
|
{ EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE, EFI_MEMORY_WC, TRUE },
|
|
|
|
{ EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE, EFI_MEMORY_WT, TRUE },
|
|
|
|
{ EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE, EFI_MEMORY_WB, TRUE },
|
|
|
|
{ EFI_RESOURCE_ATTRIBUTE_READ_PROTECTED, EFI_MEMORY_RP, TRUE },
|
|
|
|
{ EFI_RESOURCE_ATTRIBUTE_WRITE_PROTECTED, EFI_MEMORY_WP, TRUE },
|
|
|
|
{ EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTED, EFI_MEMORY_XP, TRUE },
|
|
|
|
{ EFI_RESOURCE_ATTRIBUTE_PRESENT, EFI_MEMORY_PRESENT, FALSE },
|
|
|
|
{ EFI_RESOURCE_ATTRIBUTE_INITIALIZED, EFI_MEMORY_INITIALIZED, FALSE },
|
|
|
|
{ EFI_RESOURCE_ATTRIBUTE_TESTED, EFI_MEMORY_TESTED, FALSE },
|
2008-07-18 11:50:09 +02:00
|
|
|
{ 0, 0, FALSE }
|
2007-07-04 12:51:54 +02:00
|
|
|
};
|
|
|
|
|
2011-01-06 03:51:08 +01:00
|
|
|
///
|
|
|
|
/// Lookup table used to print GCD Memory Space Map
|
|
|
|
///
|
|
|
|
GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *mGcdMemoryTypeNames[] = {
|
|
|
|
"NonExist ", // EfiGcdMemoryTypeNonExistent
|
|
|
|
"Reserved ", // EfiGcdMemoryTypeReserved
|
|
|
|
"SystemMem", // EfiGcdMemoryTypeSystemMemory
|
|
|
|
"MMIO ", // EfiGcdMemoryTypeMemoryMappedIo
|
|
|
|
"Unknown " // EfiGcdMemoryTypeMaximum
|
|
|
|
};
|
|
|
|
|
|
|
|
///
|
|
|
|
/// Lookup table used to print GCD I/O Space Map
|
|
|
|
///
|
|
|
|
GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *mGcdIoTypeNames[] = {
|
|
|
|
"NonExist", // EfiGcdIoTypeNonExistent
|
|
|
|
"Reserved", // EfiGcdIoTypeReserved
|
|
|
|
"I/O ", // EfiGcdIoTypeIo
|
|
|
|
"Unknown " // EfiGcdIoTypeMaximum
|
|
|
|
};
|
|
|
|
|
|
|
|
///
|
|
|
|
/// Lookup table used to print GCD Allocation Types
|
|
|
|
///
|
|
|
|
GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *mGcdAllocationTypeNames[] = {
|
|
|
|
"AnySearchBottomUp ", // EfiGcdAllocateAnySearchBottomUp
|
|
|
|
"MaxAddressSearchBottomUp ", // EfiGcdAllocateMaxAddressSearchBottomUp
|
|
|
|
"AtAddress ", // EfiGcdAllocateAddress
|
|
|
|
"AnySearchTopDown ", // EfiGcdAllocateAnySearchTopDown
|
|
|
|
"MaxAddressSearchTopDown ", // EfiGcdAllocateMaxAddressSearchTopDown
|
|
|
|
"Unknown " // EfiGcdMaxAllocateType
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
Dump the entire contents if the GCD Memory Space Map using DEBUG() macros when
|
|
|
|
PcdDebugPrintErrorLevel has the DEBUG_GCD bit set.
|
|
|
|
|
2011-01-12 00:11:23 +01:00
|
|
|
@param InitialMap TRUE if the initial GCD Memory Map is being dumped. Otherwise, FALSE.
|
|
|
|
|
2011-01-06 03:51:08 +01:00
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
CoreDumpGcdMemorySpaceMap (
|
2011-01-12 00:11:23 +01:00
|
|
|
BOOLEAN InitialMap
|
2011-01-06 03:51:08 +01:00
|
|
|
)
|
|
|
|
{
|
2011-01-12 00:11:23 +01:00
|
|
|
DEBUG_CODE (
|
|
|
|
EFI_STATUS Status;
|
|
|
|
UINTN NumberOfDescriptors;
|
|
|
|
EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap;
|
|
|
|
UINTN Index;
|
|
|
|
|
|
|
|
Status = CoreGetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
if (InitialMap) {
|
|
|
|
DEBUG ((DEBUG_GCD, "GCD:Initial GCD Memory Space Map\n"));
|
|
|
|
}
|
|
|
|
DEBUG ((DEBUG_GCD, "GCDMemType Range Capabilities Attributes \n"));
|
|
|
|
DEBUG ((DEBUG_GCD, "========== ================================= ================ ================\n"));
|
|
|
|
for (Index = 0; Index < NumberOfDescriptors; Index++) {
|
|
|
|
DEBUG ((DEBUG_GCD, "%a %016lx-%016lx %016lx %016lx%c\n",
|
|
|
|
mGcdMemoryTypeNames[MIN (MemorySpaceMap[Index].GcdMemoryType, EfiGcdMemoryTypeMaximum)],
|
|
|
|
MemorySpaceMap[Index].BaseAddress,
|
|
|
|
MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length - 1,
|
|
|
|
MemorySpaceMap[Index].Capabilities,
|
|
|
|
MemorySpaceMap[Index].Attributes,
|
|
|
|
MemorySpaceMap[Index].ImageHandle == NULL ? ' ' : '*'
|
|
|
|
));
|
|
|
|
}
|
|
|
|
DEBUG ((DEBUG_GCD, "\n"));
|
|
|
|
FreePool (MemorySpaceMap);
|
|
|
|
);
|
2011-01-06 03:51:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Dump the entire contents if the GCD I/O Space Map using DEBUG() macros when
|
|
|
|
PcdDebugPrintErrorLevel has the DEBUG_GCD bit set.
|
|
|
|
|
2011-01-12 00:11:23 +01:00
|
|
|
@param InitialMap TRUE if the initial GCD I/O Map is being dumped. Otherwise, FALSE.
|
|
|
|
|
2011-01-06 03:51:08 +01:00
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
CoreDumpGcdIoSpaceMap (
|
2011-01-12 00:11:23 +01:00
|
|
|
BOOLEAN InitialMap
|
2011-01-06 03:51:08 +01:00
|
|
|
)
|
|
|
|
{
|
2011-01-12 00:11:23 +01:00
|
|
|
DEBUG_CODE (
|
|
|
|
EFI_STATUS Status;
|
|
|
|
UINTN NumberOfDescriptors;
|
|
|
|
EFI_GCD_IO_SPACE_DESCRIPTOR *IoSpaceMap;
|
|
|
|
UINTN Index;
|
|
|
|
|
|
|
|
Status = CoreGetIoSpaceMap (&NumberOfDescriptors, &IoSpaceMap);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
if (InitialMap) {
|
|
|
|
DEBUG ((DEBUG_GCD, "GCD:Initial GCD I/O Space Map\n"));
|
|
|
|
}
|
|
|
|
|
|
|
|
DEBUG ((DEBUG_GCD, "GCDIoType Range \n"));
|
|
|
|
DEBUG ((DEBUG_GCD, "========== =================================\n"));
|
|
|
|
for (Index = 0; Index < NumberOfDescriptors; Index++) {
|
|
|
|
DEBUG ((DEBUG_GCD, "%a %016lx-%016lx%c\n",
|
|
|
|
mGcdIoTypeNames[MIN (IoSpaceMap[Index].GcdIoType, EfiGcdIoTypeMaximum)],
|
|
|
|
IoSpaceMap[Index].BaseAddress,
|
|
|
|
IoSpaceMap[Index].BaseAddress + IoSpaceMap[Index].Length - 1,
|
|
|
|
IoSpaceMap[Index].ImageHandle == NULL ? ' ' : '*'
|
|
|
|
));
|
|
|
|
}
|
|
|
|
DEBUG ((DEBUG_GCD, "\n"));
|
|
|
|
FreePool (IoSpaceMap);
|
|
|
|
);
|
2011-01-06 03:51:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Acquire memory lock on mGcdMemorySpaceLock.
|
|
|
|
|
|
|
|
**/
|
2007-07-04 12:51:54 +02:00
|
|
|
VOID
|
|
|
|
CoreAcquireGcdMemoryLock (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
CoreAcquireLock (&mGcdMemorySpaceLock);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Release memory lock on mGcdMemorySpaceLock.
|
|
|
|
|
|
|
|
**/
|
2007-07-04 12:51:54 +02:00
|
|
|
VOID
|
|
|
|
CoreReleaseGcdMemoryLock (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
CoreReleaseLock (&mGcdMemorySpaceLock);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Acquire memory lock on mGcdIoSpaceLock.
|
|
|
|
|
|
|
|
**/
|
2007-07-04 12:51:54 +02:00
|
|
|
VOID
|
|
|
|
CoreAcquireGcdIoLock (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
CoreAcquireLock (&mGcdIoSpaceLock);
|
|
|
|
}
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Release memory lock on mGcdIoSpaceLock.
|
|
|
|
|
|
|
|
**/
|
2007-07-04 12:51:54 +02:00
|
|
|
VOID
|
|
|
|
CoreReleaseGcdIoLock (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
CoreReleaseLock (&mGcdIoSpaceLock);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// GCD Initialization Worker Functions
|
|
|
|
//
|
2008-05-09 09:08:30 +02:00
|
|
|
/**
|
|
|
|
Aligns a value to the specified boundary.
|
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param Value 64 bit value to align
|
|
|
|
@param Alignment Log base 2 of the boundary to align Value to
|
|
|
|
@param RoundUp TRUE if Value is to be rounded up to the nearest
|
|
|
|
aligned boundary. FALSE is Value is to be
|
|
|
|
rounded down to the nearest aligned boundary.
|
2008-05-09 09:08:30 +02:00
|
|
|
|
|
|
|
@return A 64 bit value is the aligned to the value nearest Value with an alignment by Alignment.
|
|
|
|
|
|
|
|
**/
|
2007-07-04 12:51:54 +02:00
|
|
|
UINT64
|
|
|
|
AlignValue (
|
|
|
|
IN UINT64 Value,
|
|
|
|
IN UINTN Alignment,
|
|
|
|
IN BOOLEAN RoundUp
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINT64 AlignmentMask;
|
|
|
|
|
|
|
|
AlignmentMask = LShiftU64 (1, Alignment) - 1;
|
|
|
|
if (RoundUp) {
|
|
|
|
Value += AlignmentMask;
|
|
|
|
}
|
|
|
|
return Value & (~AlignmentMask);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
/**
|
2007-07-04 12:51:54 +02:00
|
|
|
Aligns address to the page boundary.
|
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param Value 64 bit address to align
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
@return A 64 bit value is the aligned to the value nearest Value with an alignment by Alignment.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
**/
|
2007-07-04 12:51:54 +02:00
|
|
|
UINT64
|
2008-05-09 09:08:30 +02:00
|
|
|
PageAlignAddress (
|
2007-07-04 12:51:54 +02:00
|
|
|
IN UINT64 Value
|
|
|
|
)
|
2008-05-09 09:08:30 +02:00
|
|
|
{
|
|
|
|
return AlignValue (Value, EFI_PAGE_SHIFT, TRUE);
|
|
|
|
}
|
2007-07-04 12:51:54 +02:00
|
|
|
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
/**
|
2007-07-04 12:51:54 +02:00
|
|
|
Aligns length to the page boundary.
|
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param Value 64 bit length to align
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
@return A 64 bit value is the aligned to the value nearest Value with an alignment by Alignment.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
**/
|
|
|
|
UINT64
|
|
|
|
PageAlignLength (
|
|
|
|
IN UINT64 Value
|
|
|
|
)
|
2007-07-04 12:51:54 +02:00
|
|
|
{
|
|
|
|
return AlignValue (Value, EFI_PAGE_SHIFT, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// GCD Memory Space Worker Functions
|
|
|
|
//
|
2008-05-09 09:08:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Allocate pool for two entries.
|
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param TopEntry An entry of GCD map
|
|
|
|
@param BottomEntry An entry of GCD map
|
2008-05-09 09:08:30 +02:00
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@retval EFI_OUT_OF_RESOURCES No enough buffer to be allocated.
|
2008-05-09 09:08:30 +02:00
|
|
|
@retval EFI_SUCCESS Both entries successfully allocated.
|
|
|
|
|
|
|
|
**/
|
2007-07-04 12:51:54 +02:00
|
|
|
EFI_STATUS
|
|
|
|
CoreAllocateGcdMapEntry (
|
|
|
|
IN OUT EFI_GCD_MAP_ENTRY **TopEntry,
|
|
|
|
IN OUT EFI_GCD_MAP_ENTRY **BottomEntry
|
|
|
|
)
|
|
|
|
{
|
2008-08-27 16:29:23 +02:00
|
|
|
*TopEntry = AllocateZeroPool (sizeof (EFI_GCD_MAP_ENTRY));
|
2007-07-04 12:51:54 +02:00
|
|
|
if (*TopEntry == NULL) {
|
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
|
|
|
|
2008-08-27 16:29:23 +02:00
|
|
|
*BottomEntry = AllocateZeroPool (sizeof (EFI_GCD_MAP_ENTRY));
|
2007-07-04 12:51:54 +02:00
|
|
|
if (*BottomEntry == NULL) {
|
|
|
|
CoreFreePool (*TopEntry);
|
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Internal function. Inserts a new descriptor into a sorted list
|
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param Link The linked list to insert the range BaseAddress
|
|
|
|
and Length into
|
|
|
|
@param Entry A pointer to the entry that is inserted
|
|
|
|
@param BaseAddress The base address of the new range
|
|
|
|
@param Length The length of the new range in bytes
|
|
|
|
@param TopEntry Top pad entry to insert if needed.
|
|
|
|
@param BottomEntry Bottom pad entry to insert if needed.
|
2008-05-09 09:08:30 +02:00
|
|
|
|
|
|
|
@retval EFI_SUCCESS The new range was inserted into the linked list
|
|
|
|
|
|
|
|
**/
|
2007-07-04 12:51:54 +02:00
|
|
|
EFI_STATUS
|
|
|
|
CoreInsertGcdMapEntry (
|
|
|
|
IN LIST_ENTRY *Link,
|
|
|
|
IN EFI_GCD_MAP_ENTRY *Entry,
|
|
|
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
|
|
|
IN UINT64 Length,
|
|
|
|
IN EFI_GCD_MAP_ENTRY *TopEntry,
|
|
|
|
IN EFI_GCD_MAP_ENTRY *BottomEntry
|
|
|
|
)
|
|
|
|
{
|
|
|
|
ASSERT (Length != 0);
|
|
|
|
ASSERT (TopEntry->Signature == 0);
|
|
|
|
ASSERT (BottomEntry->Signature == 0);
|
|
|
|
|
|
|
|
if (BaseAddress > Entry->BaseAddress) {
|
|
|
|
CopyMem (BottomEntry, Entry, sizeof (EFI_GCD_MAP_ENTRY));
|
|
|
|
Entry->BaseAddress = BaseAddress;
|
|
|
|
BottomEntry->EndAddress = BaseAddress - 1;
|
|
|
|
InsertTailList (Link, &BottomEntry->Link);
|
2008-07-24 04:54:45 +02:00
|
|
|
}
|
2007-07-04 12:51:54 +02:00
|
|
|
|
|
|
|
if ((BaseAddress + Length - 1) < Entry->EndAddress) {
|
|
|
|
CopyMem (TopEntry, Entry, sizeof (EFI_GCD_MAP_ENTRY));
|
|
|
|
TopEntry->BaseAddress = BaseAddress + Length;
|
|
|
|
Entry->EndAddress = BaseAddress + Length - 1;
|
|
|
|
InsertHeadList (Link, &TopEntry->Link);
|
|
|
|
}
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
|
|
|
|
/**
|
2008-07-18 11:50:09 +02:00
|
|
|
Merge the Gcd region specified by Link and its adjacent entry.
|
2008-05-09 09:08:30 +02:00
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param Link Specify the entry to be merged (with its
|
|
|
|
adjacent entry).
|
|
|
|
@param Forward Direction (forward or backward).
|
|
|
|
@param Map Boundary.
|
2008-05-09 09:08:30 +02:00
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@retval EFI_SUCCESS Successfully returned.
|
2008-05-09 09:08:30 +02:00
|
|
|
@retval EFI_UNSUPPORTED These adjacent regions could not merge.
|
|
|
|
|
|
|
|
**/
|
2007-07-04 12:51:54 +02:00
|
|
|
EFI_STATUS
|
|
|
|
CoreMergeGcdMapEntry (
|
|
|
|
IN LIST_ENTRY *Link,
|
|
|
|
IN BOOLEAN Forward,
|
|
|
|
IN LIST_ENTRY *Map
|
|
|
|
)
|
|
|
|
{
|
|
|
|
LIST_ENTRY *AdjacentLink;
|
|
|
|
EFI_GCD_MAP_ENTRY *Entry;
|
|
|
|
EFI_GCD_MAP_ENTRY *AdjacentEntry;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Get adjacent entry
|
|
|
|
//
|
|
|
|
if (Forward) {
|
|
|
|
AdjacentLink = Link->ForwardLink;
|
|
|
|
} else {
|
|
|
|
AdjacentLink = Link->BackLink;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// If AdjacentLink is the head of the list, then no merge can be performed
|
|
|
|
//
|
|
|
|
if (AdjacentLink == Map) {
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
Entry = CR (Link, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
|
|
|
|
AdjacentEntry = CR (AdjacentLink, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
|
|
|
|
|
|
|
|
if (Entry->Capabilities != AdjacentEntry->Capabilities) {
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
if (Entry->Attributes != AdjacentEntry->Attributes) {
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
if (Entry->GcdMemoryType != AdjacentEntry->GcdMemoryType) {
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
if (Entry->GcdIoType != AdjacentEntry->GcdIoType) {
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
if (Entry->ImageHandle != AdjacentEntry->ImageHandle) {
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
if (Entry->DeviceHandle != AdjacentEntry->DeviceHandle) {
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Forward) {
|
|
|
|
Entry->EndAddress = AdjacentEntry->EndAddress;
|
|
|
|
} else {
|
|
|
|
Entry->BaseAddress = AdjacentEntry->BaseAddress;
|
|
|
|
}
|
|
|
|
RemoveEntryList (AdjacentLink);
|
|
|
|
CoreFreePool (AdjacentEntry);
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Merge adjacent entries on total chain.
|
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param TopEntry Top entry of GCD map.
|
|
|
|
@param BottomEntry Bottom entry of GCD map.
|
|
|
|
@param StartLink Start link of the list for this loop.
|
|
|
|
@param EndLink End link of the list for this loop.
|
|
|
|
@param Map Boundary.
|
2008-05-09 09:08:30 +02:00
|
|
|
|
|
|
|
@retval EFI_SUCCESS GCD map successfully cleaned up.
|
|
|
|
|
|
|
|
**/
|
2007-07-04 12:51:54 +02:00
|
|
|
EFI_STATUS
|
|
|
|
CoreCleanupGcdMapEntry (
|
|
|
|
IN EFI_GCD_MAP_ENTRY *TopEntry,
|
|
|
|
IN EFI_GCD_MAP_ENTRY *BottomEntry,
|
|
|
|
IN LIST_ENTRY *StartLink,
|
|
|
|
IN LIST_ENTRY *EndLink,
|
|
|
|
IN LIST_ENTRY *Map
|
|
|
|
)
|
|
|
|
{
|
|
|
|
LIST_ENTRY *Link;
|
|
|
|
|
|
|
|
if (TopEntry->Signature == 0) {
|
|
|
|
CoreFreePool (TopEntry);
|
|
|
|
}
|
|
|
|
if (BottomEntry->Signature == 0) {
|
|
|
|
CoreFreePool (BottomEntry);
|
|
|
|
}
|
|
|
|
|
|
|
|
Link = StartLink;
|
|
|
|
while (Link != EndLink->ForwardLink) {
|
|
|
|
CoreMergeGcdMapEntry (Link, FALSE, Map);
|
|
|
|
Link = Link->ForwardLink;
|
|
|
|
}
|
|
|
|
CoreMergeGcdMapEntry (EndLink, TRUE, Map);
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Search a segment of memory space in GCD map. The result is a range of GCD entry list.
|
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param BaseAddress The start address of the segment.
|
|
|
|
@param Length The length of the segment.
|
|
|
|
@param StartLink The first GCD entry involves this segment of
|
|
|
|
memory space.
|
|
|
|
@param EndLink The first GCD entry involves this segment of
|
|
|
|
memory space.
|
|
|
|
@param Map Points to the start entry to search.
|
2008-05-09 09:08:30 +02:00
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@retval EFI_SUCCESS Successfully found the entry.
|
2008-05-09 09:08:30 +02:00
|
|
|
@retval EFI_NOT_FOUND Not found.
|
|
|
|
|
|
|
|
**/
|
2007-07-04 12:51:54 +02:00
|
|
|
EFI_STATUS
|
|
|
|
CoreSearchGcdMapEntry (
|
|
|
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
|
|
|
IN UINT64 Length,
|
|
|
|
OUT LIST_ENTRY **StartLink,
|
|
|
|
OUT LIST_ENTRY **EndLink,
|
|
|
|
IN LIST_ENTRY *Map
|
|
|
|
)
|
|
|
|
{
|
|
|
|
LIST_ENTRY *Link;
|
|
|
|
EFI_GCD_MAP_ENTRY *Entry;
|
|
|
|
|
|
|
|
ASSERT (Length != 0);
|
|
|
|
|
|
|
|
*StartLink = NULL;
|
|
|
|
*EndLink = NULL;
|
|
|
|
|
|
|
|
Link = Map->ForwardLink;
|
|
|
|
while (Link != Map) {
|
|
|
|
Entry = CR (Link, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
|
|
|
|
if (BaseAddress >= Entry->BaseAddress && BaseAddress <= Entry->EndAddress) {
|
|
|
|
*StartLink = Link;
|
|
|
|
}
|
|
|
|
if (*StartLink != NULL) {
|
2008-07-24 04:54:45 +02:00
|
|
|
if ((BaseAddress + Length - 1) >= Entry->BaseAddress &&
|
2007-07-04 12:51:54 +02:00
|
|
|
(BaseAddress + Length - 1) <= Entry->EndAddress ) {
|
|
|
|
*EndLink = Link;
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Link = Link->ForwardLink;
|
|
|
|
}
|
2008-07-18 11:50:09 +02:00
|
|
|
|
2007-07-04 12:51:54 +02:00
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
/**
|
2007-07-04 12:51:54 +02:00
|
|
|
Count the amount of GCD map entries.
|
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param Map Points to the start entry to do the count loop.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
@return The count.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
**/
|
|
|
|
UINTN
|
|
|
|
CoreCountGcdMapEntry (
|
|
|
|
IN LIST_ENTRY *Map
|
|
|
|
)
|
2007-07-04 12:51:54 +02:00
|
|
|
{
|
|
|
|
UINTN Count;
|
|
|
|
LIST_ENTRY *Link;
|
|
|
|
|
|
|
|
Count = 0;
|
|
|
|
Link = Map->ForwardLink;
|
|
|
|
while (Link != Map) {
|
|
|
|
Count++;
|
|
|
|
Link = Link->ForwardLink;
|
|
|
|
}
|
2008-07-24 04:54:45 +02:00
|
|
|
|
2007-07-04 12:51:54 +02:00
|
|
|
return Count;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
/**
|
2007-07-04 12:51:54 +02:00
|
|
|
Return the memory attribute specified by Attributes
|
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param Attributes A num with some attribute bits on.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
@return The enum value of memory attribute.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
**/
|
|
|
|
UINT64
|
|
|
|
ConverToCpuArchAttributes (
|
|
|
|
UINT64 Attributes
|
2008-05-21 03:40:12 +02:00
|
|
|
)
|
2007-07-04 12:51:54 +02:00
|
|
|
{
|
|
|
|
if ( (Attributes & EFI_MEMORY_UC) == EFI_MEMORY_UC) {
|
|
|
|
return EFI_MEMORY_UC;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( (Attributes & EFI_MEMORY_WC ) == EFI_MEMORY_WC) {
|
|
|
|
return EFI_MEMORY_WC;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( (Attributes & EFI_MEMORY_WT ) == EFI_MEMORY_WT) {
|
|
|
|
return EFI_MEMORY_WT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( (Attributes & EFI_MEMORY_WB) == EFI_MEMORY_WB) {
|
|
|
|
return EFI_MEMORY_WB;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( (Attributes & EFI_MEMORY_WP) == EFI_MEMORY_WP) {
|
|
|
|
return EFI_MEMORY_WP;
|
|
|
|
}
|
|
|
|
|
|
|
|
return INVALID_CPU_ARCH_ATTRIBUTES;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Do operation on a segment of memory space specified (add, free, remove, change attribute ...).
|
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param Operation The type of the operation
|
|
|
|
@param GcdMemoryType Additional information for the operation
|
|
|
|
@param GcdIoType Additional information for the operation
|
|
|
|
@param BaseAddress Start address of the segment
|
|
|
|
@param Length length of the segment
|
|
|
|
@param Capabilities The alterable attributes of a newly added entry
|
|
|
|
@param Attributes The attributes needs to be set
|
|
|
|
|
|
|
|
@retval EFI_INVALID_PARAMETER Length is 0 or address (length) not aligned when
|
|
|
|
setting attribute.
|
|
|
|
@retval EFI_SUCCESS Action successfully done.
|
|
|
|
@retval EFI_UNSUPPORTED Could not find the proper descriptor on this
|
|
|
|
segment or set an upsupported attribute.
|
|
|
|
@retval EFI_ACCESS_DENIED Operate on an space non-exist or is used for an
|
|
|
|
image.
|
|
|
|
@retval EFI_NOT_FOUND Free a non-using space or remove a non-exist
|
|
|
|
space, and so on.
|
2008-05-09 09:08:30 +02:00
|
|
|
@retval EFI_OUT_OF_RESOURCES No buffer could be allocated.
|
|
|
|
|
|
|
|
**/
|
2007-07-04 12:51:54 +02:00
|
|
|
EFI_STATUS
|
|
|
|
CoreConvertSpace (
|
|
|
|
IN UINTN Operation,
|
|
|
|
IN EFI_GCD_MEMORY_TYPE GcdMemoryType,
|
|
|
|
IN EFI_GCD_IO_TYPE GcdIoType,
|
|
|
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
|
|
|
IN UINT64 Length,
|
|
|
|
IN UINT64 Capabilities,
|
|
|
|
IN UINT64 Attributes
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
LIST_ENTRY *Map;
|
|
|
|
LIST_ENTRY *Link;
|
|
|
|
EFI_GCD_MAP_ENTRY *Entry;
|
|
|
|
EFI_GCD_MAP_ENTRY *TopEntry;
|
|
|
|
EFI_GCD_MAP_ENTRY *BottomEntry;
|
|
|
|
LIST_ENTRY *StartLink;
|
|
|
|
LIST_ENTRY *EndLink;
|
2011-01-06 03:51:08 +01:00
|
|
|
UINT64 CpuArchAttributes;
|
2007-07-04 12:51:54 +02:00
|
|
|
|
|
|
|
if (Length == 0) {
|
2011-01-12 00:11:23 +01:00
|
|
|
DEBUG ((DEBUG_GCD, " Status = %r\n", EFI_INVALID_PARAMETER));
|
2007-07-04 12:51:54 +02:00
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
Map = NULL;
|
2008-05-09 09:52:58 +02:00
|
|
|
if ((Operation & GCD_MEMORY_SPACE_OPERATION) != 0) {
|
2007-07-04 12:51:54 +02:00
|
|
|
CoreAcquireGcdMemoryLock ();
|
|
|
|
Map = &mGcdMemorySpaceMap;
|
2009-02-10 10:56:23 +01:00
|
|
|
} else if ((Operation & GCD_IO_SPACE_OPERATION) != 0) {
|
2007-07-04 12:51:54 +02:00
|
|
|
CoreAcquireGcdIoLock ();
|
|
|
|
Map = &mGcdIoSpaceMap;
|
2009-02-10 10:56:23 +01:00
|
|
|
} else {
|
|
|
|
ASSERT (FALSE);
|
2007-07-04 12:51:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Search for the list of descriptors that cover the range BaseAddress to BaseAddress+Length
|
|
|
|
//
|
|
|
|
Status = CoreSearchGcdMapEntry (BaseAddress, Length, &StartLink, &EndLink, Map);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
Status = EFI_UNSUPPORTED;
|
|
|
|
|
|
|
|
goto Done;
|
|
|
|
}
|
2010-02-26 09:53:27 +01:00
|
|
|
ASSERT (StartLink != NULL && EndLink != NULL);
|
2007-07-04 12:51:54 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Verify that the list of descriptors are unallocated non-existent memory.
|
|
|
|
//
|
|
|
|
Link = StartLink;
|
|
|
|
while (Link != EndLink->ForwardLink) {
|
|
|
|
Entry = CR (Link, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
|
|
|
|
switch (Operation) {
|
|
|
|
//
|
|
|
|
// Add operations
|
|
|
|
//
|
|
|
|
case GCD_ADD_MEMORY_OPERATION:
|
|
|
|
if (Entry->GcdMemoryType != EfiGcdMemoryTypeNonExistent ||
|
|
|
|
Entry->ImageHandle != NULL ) {
|
|
|
|
Status = EFI_ACCESS_DENIED;
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GCD_ADD_IO_OPERATION:
|
|
|
|
if (Entry->GcdIoType != EfiGcdIoTypeNonExistent ||
|
|
|
|
Entry->ImageHandle != NULL ) {
|
|
|
|
Status = EFI_ACCESS_DENIED;
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
//
|
|
|
|
// Free operations
|
|
|
|
//
|
|
|
|
case GCD_FREE_MEMORY_OPERATION:
|
|
|
|
case GCD_FREE_IO_OPERATION:
|
|
|
|
if (Entry->ImageHandle == NULL) {
|
|
|
|
Status = EFI_NOT_FOUND;
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
//
|
|
|
|
// Remove operations
|
|
|
|
//
|
|
|
|
case GCD_REMOVE_MEMORY_OPERATION:
|
|
|
|
if (Entry->GcdMemoryType == EfiGcdMemoryTypeNonExistent) {
|
|
|
|
Status = EFI_NOT_FOUND;
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
if (Entry->ImageHandle != NULL) {
|
|
|
|
Status = EFI_ACCESS_DENIED;
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GCD_REMOVE_IO_OPERATION:
|
|
|
|
if (Entry->GcdIoType == EfiGcdIoTypeNonExistent) {
|
|
|
|
Status = EFI_NOT_FOUND;
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
if (Entry->ImageHandle != NULL) {
|
|
|
|
Status = EFI_ACCESS_DENIED;
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
//
|
|
|
|
// Set attribute operations
|
|
|
|
//
|
|
|
|
case GCD_SET_ATTRIBUTES_MEMORY_OPERATION:
|
2008-05-09 09:52:58 +02:00
|
|
|
if ((Attributes & EFI_MEMORY_RUNTIME) != 0) {
|
2007-07-04 12:51:54 +02:00
|
|
|
if ((BaseAddress & EFI_PAGE_MASK) != 0 || (Length & EFI_PAGE_MASK) != 0) {
|
|
|
|
Status = EFI_INVALID_PARAMETER;
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((Entry->Capabilities & Attributes) != Attributes) {
|
|
|
|
Status = EFI_UNSUPPORTED;
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Link = Link->ForwardLink;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Allocate work space to perform this operation
|
|
|
|
//
|
|
|
|
Status = CoreAllocateGcdMapEntry (&TopEntry, &BottomEntry);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
Status = EFI_OUT_OF_RESOURCES;
|
|
|
|
goto Done;
|
|
|
|
}
|
2010-02-26 09:53:27 +01:00
|
|
|
ASSERT (TopEntry != NULL && BottomEntry != NULL);
|
2007-07-04 12:51:54 +02:00
|
|
|
|
|
|
|
if (Operation == GCD_SET_ATTRIBUTES_MEMORY_OPERATION) {
|
|
|
|
//
|
|
|
|
// Call CPU Arch Protocol to attempt to set attributes on the range
|
|
|
|
//
|
|
|
|
CpuArchAttributes = ConverToCpuArchAttributes (Attributes);
|
2011-01-06 03:51:08 +01:00
|
|
|
if (CpuArchAttributes != INVALID_CPU_ARCH_ATTRIBUTES) {
|
|
|
|
if (gCpu != NULL) {
|
|
|
|
Status = gCpu->SetMemoryAttributes (
|
|
|
|
gCpu,
|
|
|
|
BaseAddress,
|
|
|
|
Length,
|
|
|
|
CpuArchAttributes
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
goto Done;
|
|
|
|
}
|
2007-07-04 12:51:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Convert/Insert the list of descriptors from StartLink to EndLink
|
|
|
|
//
|
|
|
|
Link = StartLink;
|
|
|
|
while (Link != EndLink->ForwardLink) {
|
|
|
|
Entry = CR (Link, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
|
|
|
|
CoreInsertGcdMapEntry (Link, Entry, BaseAddress, Length, TopEntry, BottomEntry);
|
|
|
|
switch (Operation) {
|
|
|
|
//
|
|
|
|
// Add operations
|
|
|
|
//
|
|
|
|
case GCD_ADD_MEMORY_OPERATION:
|
|
|
|
Entry->GcdMemoryType = GcdMemoryType;
|
|
|
|
if (GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo) {
|
|
|
|
Entry->Capabilities = Capabilities | EFI_MEMORY_RUNTIME | EFI_MEMORY_PORT_IO;
|
|
|
|
} else {
|
|
|
|
Entry->Capabilities = Capabilities | EFI_MEMORY_RUNTIME;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GCD_ADD_IO_OPERATION:
|
|
|
|
Entry->GcdIoType = GcdIoType;
|
|
|
|
break;
|
|
|
|
//
|
|
|
|
// Free operations
|
|
|
|
//
|
|
|
|
case GCD_FREE_MEMORY_OPERATION:
|
|
|
|
case GCD_FREE_IO_OPERATION:
|
|
|
|
Entry->ImageHandle = NULL;
|
|
|
|
Entry->DeviceHandle = NULL;
|
|
|
|
break;
|
|
|
|
//
|
|
|
|
// Remove operations
|
|
|
|
//
|
|
|
|
case GCD_REMOVE_MEMORY_OPERATION:
|
|
|
|
Entry->GcdMemoryType = EfiGcdMemoryTypeNonExistent;
|
|
|
|
Entry->Capabilities = 0;
|
|
|
|
break;
|
|
|
|
case GCD_REMOVE_IO_OPERATION:
|
|
|
|
Entry->GcdIoType = EfiGcdIoTypeNonExistent;
|
|
|
|
break;
|
|
|
|
//
|
|
|
|
// Set attribute operations
|
|
|
|
//
|
|
|
|
case GCD_SET_ATTRIBUTES_MEMORY_OPERATION:
|
|
|
|
Entry->Attributes = Attributes;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Link = Link->ForwardLink;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Cleanup
|
|
|
|
//
|
|
|
|
Status = CoreCleanupGcdMapEntry (TopEntry, BottomEntry, StartLink, EndLink, Map);
|
|
|
|
|
|
|
|
Done:
|
2011-01-12 00:11:23 +01:00
|
|
|
DEBUG ((DEBUG_GCD, " Status = %r\n", Status));
|
2011-01-06 03:51:08 +01:00
|
|
|
|
2008-05-09 09:52:58 +02:00
|
|
|
if ((Operation & GCD_MEMORY_SPACE_OPERATION) != 0) {
|
2007-07-04 12:51:54 +02:00
|
|
|
CoreReleaseGcdMemoryLock ();
|
2011-01-12 00:11:23 +01:00
|
|
|
CoreDumpGcdMemorySpaceMap (FALSE);
|
2007-07-04 12:51:54 +02:00
|
|
|
}
|
2008-05-09 09:52:58 +02:00
|
|
|
if ((Operation & GCD_IO_SPACE_OPERATION) != 0) {
|
2007-07-04 12:51:54 +02:00
|
|
|
CoreReleaseGcdIoLock ();
|
2011-01-12 00:11:23 +01:00
|
|
|
CoreDumpGcdIoSpaceMap (FALSE);
|
2007-07-04 12:51:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Check whether an entry could be used to allocate space.
|
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param Operation Allocate memory or IO
|
|
|
|
@param Entry The entry to be tested
|
|
|
|
@param GcdMemoryType The desired memory type
|
|
|
|
@param GcdIoType The desired IO type
|
2008-05-09 09:08:30 +02:00
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@retval EFI_NOT_FOUND The memory type does not match or there's an
|
|
|
|
image handle on the entry.
|
|
|
|
@retval EFI_UNSUPPORTED The operation unsupported.
|
|
|
|
@retval EFI_SUCCESS It's ok for this entry to be used to allocate
|
2008-05-09 09:08:30 +02:00
|
|
|
space.
|
|
|
|
|
|
|
|
**/
|
2007-07-04 12:51:54 +02:00
|
|
|
EFI_STATUS
|
|
|
|
CoreAllocateSpaceCheckEntry (
|
|
|
|
IN UINTN Operation,
|
|
|
|
IN EFI_GCD_MAP_ENTRY *Entry,
|
|
|
|
IN EFI_GCD_MEMORY_TYPE GcdMemoryType,
|
|
|
|
IN EFI_GCD_IO_TYPE GcdIoType
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if (Entry->ImageHandle != NULL) {
|
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
}
|
|
|
|
switch (Operation) {
|
|
|
|
case GCD_ALLOCATE_MEMORY_OPERATION:
|
|
|
|
if (Entry->GcdMemoryType != GcdMemoryType) {
|
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GCD_ALLOCATE_IO_OPERATION:
|
|
|
|
if (Entry->GcdIoType != GcdIoType) {
|
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Allocate space on specified address and length.
|
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param Operation The type of operation (memory or IO)
|
|
|
|
@param GcdAllocateType The type of allocate operation
|
|
|
|
@param GcdMemoryType The desired memory type
|
|
|
|
@param GcdIoType The desired IO type
|
|
|
|
@param Alignment Align with 2^Alignment
|
|
|
|
@param Length Length to allocate
|
|
|
|
@param BaseAddress Base address to allocate
|
|
|
|
@param ImageHandle The image handle consume the allocated space.
|
|
|
|
@param DeviceHandle The device handle consume the allocated space.
|
|
|
|
|
|
|
|
@retval EFI_INVALID_PARAMETER Invalid parameter.
|
|
|
|
@retval EFI_NOT_FOUND No descriptor for the desired space exists.
|
2008-05-09 09:08:30 +02:00
|
|
|
@retval EFI_SUCCESS Space successfully allocated.
|
|
|
|
|
|
|
|
**/
|
2007-07-04 12:51:54 +02:00
|
|
|
EFI_STATUS
|
|
|
|
CoreAllocateSpace (
|
|
|
|
IN UINTN Operation,
|
|
|
|
IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType,
|
|
|
|
IN EFI_GCD_MEMORY_TYPE GcdMemoryType,
|
|
|
|
IN EFI_GCD_IO_TYPE GcdIoType,
|
|
|
|
IN UINTN Alignment,
|
|
|
|
IN UINT64 Length,
|
|
|
|
IN OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_HANDLE DeviceHandle OPTIONAL
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_PHYSICAL_ADDRESS AlignmentMask;
|
|
|
|
EFI_PHYSICAL_ADDRESS MaxAddress;
|
|
|
|
LIST_ENTRY *Map;
|
|
|
|
LIST_ENTRY *Link;
|
|
|
|
LIST_ENTRY *SubLink;
|
|
|
|
EFI_GCD_MAP_ENTRY *Entry;
|
|
|
|
EFI_GCD_MAP_ENTRY *TopEntry;
|
|
|
|
EFI_GCD_MAP_ENTRY *BottomEntry;
|
|
|
|
LIST_ENTRY *StartLink;
|
|
|
|
LIST_ENTRY *EndLink;
|
|
|
|
BOOLEAN Found;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Make sure parameters are valid
|
|
|
|
//
|
|
|
|
if (GcdAllocateType < 0 || GcdAllocateType >= EfiGcdMaxAllocateType) {
|
2011-01-12 00:11:23 +01:00
|
|
|
DEBUG ((DEBUG_GCD, " Status = %r\n", EFI_INVALID_PARAMETER));
|
2007-07-04 12:51:54 +02:00
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
if (GcdMemoryType < 0 || GcdMemoryType >= EfiGcdMemoryTypeMaximum) {
|
2011-01-12 00:11:23 +01:00
|
|
|
DEBUG ((DEBUG_GCD, " Status = %r\n", EFI_INVALID_PARAMETER));
|
2007-07-04 12:51:54 +02:00
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
if (GcdIoType < 0 || GcdIoType >= EfiGcdIoTypeMaximum) {
|
2011-01-12 00:11:23 +01:00
|
|
|
DEBUG ((DEBUG_GCD, " Status = %r\n", EFI_INVALID_PARAMETER));
|
2007-07-04 12:51:54 +02:00
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
if (BaseAddress == NULL) {
|
2011-01-12 00:11:23 +01:00
|
|
|
DEBUG ((DEBUG_GCD, " Status = %r\n", EFI_INVALID_PARAMETER));
|
2007-07-04 12:51:54 +02:00
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
if (ImageHandle == NULL) {
|
2011-01-12 00:11:23 +01:00
|
|
|
DEBUG ((DEBUG_GCD, " Status = %r\n", EFI_INVALID_PARAMETER));
|
2007-07-04 12:51:54 +02:00
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
if (Alignment >= 64) {
|
2011-01-12 00:11:23 +01:00
|
|
|
DEBUG ((DEBUG_GCD, " Status = %r\n", EFI_NOT_FOUND));
|
2007-07-04 12:51:54 +02:00
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
}
|
|
|
|
if (Length == 0) {
|
2011-01-12 00:11:23 +01:00
|
|
|
DEBUG ((DEBUG_GCD, " Status = %r\n", EFI_INVALID_PARAMETER));
|
2007-07-04 12:51:54 +02:00
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
Map = NULL;
|
2008-05-09 09:52:58 +02:00
|
|
|
if ((Operation & GCD_MEMORY_SPACE_OPERATION) != 0) {
|
2007-07-04 12:51:54 +02:00
|
|
|
CoreAcquireGcdMemoryLock ();
|
|
|
|
Map = &mGcdMemorySpaceMap;
|
2009-02-10 10:56:23 +01:00
|
|
|
} else if ((Operation & GCD_IO_SPACE_OPERATION) != 0) {
|
2007-07-04 12:51:54 +02:00
|
|
|
CoreAcquireGcdIoLock ();
|
|
|
|
Map = &mGcdIoSpaceMap;
|
2009-02-10 10:56:23 +01:00
|
|
|
} else {
|
|
|
|
ASSERT (FALSE);
|
2007-07-04 12:51:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Found = FALSE;
|
|
|
|
StartLink = NULL;
|
|
|
|
EndLink = NULL;
|
|
|
|
//
|
|
|
|
// Compute alignment bit mask
|
|
|
|
//
|
|
|
|
AlignmentMask = LShiftU64 (1, Alignment) - 1;
|
|
|
|
|
|
|
|
if (GcdAllocateType == EfiGcdAllocateAddress) {
|
|
|
|
//
|
|
|
|
// Verify that the BaseAddress passed in is aligned correctly
|
|
|
|
//
|
|
|
|
if ((*BaseAddress & AlignmentMask) != 0) {
|
|
|
|
Status = EFI_NOT_FOUND;
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Search for the list of descriptors that cover the range BaseAddress to BaseAddress+Length
|
|
|
|
//
|
|
|
|
Status = CoreSearchGcdMapEntry (*BaseAddress, Length, &StartLink, &EndLink, Map);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
Status = EFI_NOT_FOUND;
|
|
|
|
goto Done;
|
|
|
|
}
|
2010-02-26 09:53:27 +01:00
|
|
|
ASSERT (StartLink != NULL && EndLink != NULL);
|
2007-07-04 12:51:54 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Verify that the list of descriptors are unallocated memory matching GcdMemoryType.
|
|
|
|
//
|
|
|
|
Link = StartLink;
|
|
|
|
while (Link != EndLink->ForwardLink) {
|
|
|
|
Entry = CR (Link, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
|
|
|
|
Link = Link->ForwardLink;
|
|
|
|
Status = CoreAllocateSpaceCheckEntry (Operation, Entry, GcdMemoryType, GcdIoType);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Found = TRUE;
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Entry = CR (Map->BackLink, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Compute the maximum address to use in the search algorithm
|
|
|
|
//
|
|
|
|
if (GcdAllocateType == EfiGcdAllocateMaxAddressSearchBottomUp ||
|
|
|
|
GcdAllocateType == EfiGcdAllocateMaxAddressSearchTopDown ) {
|
|
|
|
MaxAddress = *BaseAddress;
|
|
|
|
} else {
|
|
|
|
MaxAddress = Entry->EndAddress;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Verify that the list of descriptors are unallocated memory matching GcdMemoryType.
|
|
|
|
//
|
|
|
|
if (GcdAllocateType == EfiGcdAllocateMaxAddressSearchTopDown ||
|
|
|
|
GcdAllocateType == EfiGcdAllocateAnySearchTopDown ) {
|
|
|
|
Link = Map->BackLink;
|
|
|
|
} else {
|
|
|
|
Link = Map->ForwardLink;
|
|
|
|
}
|
|
|
|
while (Link != Map) {
|
|
|
|
Entry = CR (Link, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
|
|
|
|
|
|
|
|
if (GcdAllocateType == EfiGcdAllocateMaxAddressSearchTopDown ||
|
|
|
|
GcdAllocateType == EfiGcdAllocateAnySearchTopDown ) {
|
|
|
|
Link = Link->BackLink;
|
|
|
|
} else {
|
|
|
|
Link = Link->ForwardLink;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = CoreAllocateSpaceCheckEntry (Operation, Entry, GcdMemoryType, GcdIoType);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GcdAllocateType == EfiGcdAllocateMaxAddressSearchTopDown ||
|
2008-07-18 11:50:09 +02:00
|
|
|
GcdAllocateType == EfiGcdAllocateAnySearchTopDown) {
|
2007-07-04 12:51:54 +02:00
|
|
|
if ((Entry->BaseAddress + Length) > MaxAddress) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (Length > (Entry->EndAddress + 1)) {
|
|
|
|
Status = EFI_NOT_FOUND;
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
if (Entry->EndAddress > MaxAddress) {
|
|
|
|
*BaseAddress = MaxAddress;
|
|
|
|
} else {
|
|
|
|
*BaseAddress = Entry->EndAddress;
|
|
|
|
}
|
|
|
|
*BaseAddress = (*BaseAddress + 1 - Length) & (~AlignmentMask);
|
|
|
|
} else {
|
|
|
|
*BaseAddress = (Entry->BaseAddress + AlignmentMask) & (~AlignmentMask);
|
|
|
|
if ((*BaseAddress + Length - 1) > MaxAddress) {
|
|
|
|
Status = EFI_NOT_FOUND;
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Search for the list of descriptors that cover the range BaseAddress to BaseAddress+Length
|
|
|
|
//
|
|
|
|
Status = CoreSearchGcdMapEntry (*BaseAddress, Length, &StartLink, &EndLink, Map);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
Status = EFI_NOT_FOUND;
|
|
|
|
goto Done;
|
|
|
|
}
|
2010-02-26 09:53:27 +01:00
|
|
|
ASSERT (StartLink != NULL && EndLink != NULL);
|
2007-07-04 12:51:54 +02:00
|
|
|
|
|
|
|
Link = StartLink;
|
|
|
|
//
|
|
|
|
// Verify that the list of descriptors are unallocated memory matching GcdMemoryType.
|
|
|
|
//
|
|
|
|
Found = TRUE;
|
|
|
|
SubLink = StartLink;
|
|
|
|
while (SubLink != EndLink->ForwardLink) {
|
|
|
|
Entry = CR (SubLink, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
|
|
|
|
Status = CoreAllocateSpaceCheckEntry (Operation, Entry, GcdMemoryType, GcdIoType);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
Link = SubLink;
|
|
|
|
Found = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
SubLink = SubLink->ForwardLink;
|
|
|
|
}
|
|
|
|
if (Found) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!Found) {
|
|
|
|
Status = EFI_NOT_FOUND;
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Allocate work space to perform this operation
|
|
|
|
//
|
|
|
|
Status = CoreAllocateGcdMapEntry (&TopEntry, &BottomEntry);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
Status = EFI_OUT_OF_RESOURCES;
|
|
|
|
goto Done;
|
|
|
|
}
|
2010-02-26 09:53:27 +01:00
|
|
|
ASSERT (TopEntry != NULL && BottomEntry != NULL);
|
2007-07-04 12:51:54 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Convert/Insert the list of descriptors from StartLink to EndLink
|
|
|
|
//
|
|
|
|
Link = StartLink;
|
|
|
|
while (Link != EndLink->ForwardLink) {
|
|
|
|
Entry = CR (Link, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
|
|
|
|
CoreInsertGcdMapEntry (Link, Entry, *BaseAddress, Length, TopEntry, BottomEntry);
|
|
|
|
Entry->ImageHandle = ImageHandle;
|
|
|
|
Entry->DeviceHandle = DeviceHandle;
|
|
|
|
Link = Link->ForwardLink;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Cleanup
|
|
|
|
//
|
|
|
|
Status = CoreCleanupGcdMapEntry (TopEntry, BottomEntry, StartLink, EndLink, Map);
|
|
|
|
|
|
|
|
Done:
|
2011-01-12 00:11:23 +01:00
|
|
|
DEBUG ((DEBUG_GCD, " Status = %r", Status));
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
DEBUG ((DEBUG_GCD, " (BaseAddress = %016lx)", *BaseAddress));
|
|
|
|
}
|
|
|
|
DEBUG ((DEBUG_GCD, "\n"));
|
2011-01-06 03:51:08 +01:00
|
|
|
|
2008-05-09 09:52:58 +02:00
|
|
|
if ((Operation & GCD_MEMORY_SPACE_OPERATION) != 0) {
|
2007-07-04 12:51:54 +02:00
|
|
|
CoreReleaseGcdMemoryLock ();
|
2011-01-12 00:11:23 +01:00
|
|
|
CoreDumpGcdMemorySpaceMap (FALSE);
|
2007-07-04 12:51:54 +02:00
|
|
|
}
|
2008-05-09 09:52:58 +02:00
|
|
|
if ((Operation & GCD_IO_SPACE_OPERATION) !=0) {
|
2007-07-04 12:51:54 +02:00
|
|
|
CoreReleaseGcdIoLock ();
|
2011-01-12 00:11:23 +01:00
|
|
|
CoreDumpGcdIoSpaceMap (FALSE);
|
2007-07-04 12:51:54 +02:00
|
|
|
}
|
2011-01-12 00:11:23 +01:00
|
|
|
|
2007-07-04 12:51:54 +02:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
/**
|
2007-07-04 12:51:54 +02:00
|
|
|
Add a segment of memory to GCD map.
|
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param GcdMemoryType Memory type of the segment.
|
|
|
|
@param BaseAddress Base address of the segment.
|
|
|
|
@param Length Length of the segment.
|
|
|
|
@param Capabilities alterable attributes of the segment.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@retval EFI_INVALID_PARAMETER Invalid parameters.
|
2008-05-09 09:08:30 +02:00
|
|
|
@retval EFI_SUCCESS Successfully add a segment of memory space.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
CoreInternalAddMemorySpace (
|
|
|
|
IN EFI_GCD_MEMORY_TYPE GcdMemoryType,
|
|
|
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
|
|
|
IN UINT64 Length,
|
|
|
|
IN UINT64 Capabilities
|
|
|
|
)
|
2007-07-04 12:51:54 +02:00
|
|
|
{
|
2011-01-06 03:51:08 +01:00
|
|
|
DEBUG ((DEBUG_GCD, "GCD:AddMemorySpace(Base=%016lx,Length=%016lx)\n", BaseAddress, Length));
|
|
|
|
DEBUG ((DEBUG_GCD, " GcdMemoryType = %a\n", mGcdMemoryTypeNames[MIN (GcdMemoryType, EfiGcdMemoryTypeMaximum)]));
|
|
|
|
DEBUG ((DEBUG_GCD, " Capabilities = %016lx\n", Capabilities));
|
|
|
|
|
2007-07-04 12:51:54 +02:00
|
|
|
//
|
|
|
|
// Make sure parameters are valid
|
|
|
|
//
|
|
|
|
if (GcdMemoryType <= EfiGcdMemoryTypeNonExistent || GcdMemoryType >= EfiGcdMemoryTypeMaximum) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CoreConvertSpace (GCD_ADD_MEMORY_OPERATION, GcdMemoryType, (EFI_GCD_IO_TYPE) 0, BaseAddress, Length, Capabilities, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// GCD Core Services
|
|
|
|
//
|
2008-05-09 09:08:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Allocates nonexistent memory, reserved memory, system memory, or memorymapped
|
|
|
|
I/O resources from the global coherency domain of the processor.
|
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param GcdAllocateType The type of allocate operation
|
|
|
|
@param GcdMemoryType The desired memory type
|
|
|
|
@param Alignment Align with 2^Alignment
|
|
|
|
@param Length Length to allocate
|
|
|
|
@param BaseAddress Base address to allocate
|
|
|
|
@param ImageHandle The image handle consume the allocated space.
|
|
|
|
@param DeviceHandle The device handle consume the allocated space.
|
2008-05-09 09:08:30 +02:00
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@retval EFI_INVALID_PARAMETER Invalid parameter.
|
|
|
|
@retval EFI_NOT_FOUND No descriptor contains the desired space.
|
2008-05-09 09:08:30 +02:00
|
|
|
@retval EFI_SUCCESS Memory space successfully allocated.
|
|
|
|
|
|
|
|
**/
|
2007-07-04 12:51:54 +02:00
|
|
|
EFI_STATUS
|
2008-09-10 05:25:49 +02:00
|
|
|
EFIAPI
|
2007-07-04 12:51:54 +02:00
|
|
|
CoreAllocateMemorySpace (
|
|
|
|
IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType,
|
|
|
|
IN EFI_GCD_MEMORY_TYPE GcdMemoryType,
|
|
|
|
IN UINTN Alignment,
|
|
|
|
IN UINT64 Length,
|
|
|
|
IN OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_HANDLE DeviceHandle OPTIONAL
|
|
|
|
)
|
|
|
|
{
|
2011-01-06 03:51:08 +01:00
|
|
|
DEBUG ((DEBUG_GCD, "GCD:AllocateMemorySpace(Base=%016lx,Length=%016lx)\n", *BaseAddress, Length));
|
|
|
|
DEBUG ((DEBUG_GCD, " GcdAllocateType = %a\n", mGcdAllocationTypeNames[MIN (GcdAllocateType, EfiGcdMaxAllocateType)]));
|
|
|
|
DEBUG ((DEBUG_GCD, " GcdMemoryType = %a\n", mGcdMemoryTypeNames[MIN (GcdMemoryType, EfiGcdMemoryTypeMaximum)]));
|
|
|
|
DEBUG ((DEBUG_GCD, " Alignment = %016lx\n", LShiftU64 (1, Alignment)));
|
|
|
|
DEBUG ((DEBUG_GCD, " ImageHandle = %p\n", ImageHandle));
|
|
|
|
DEBUG ((DEBUG_GCD, " DeviceHandle = %p\n", DeviceHandle));
|
|
|
|
|
2007-07-04 12:51:54 +02:00
|
|
|
return CoreAllocateSpace (
|
2008-07-24 04:54:45 +02:00
|
|
|
GCD_ALLOCATE_MEMORY_OPERATION,
|
|
|
|
GcdAllocateType,
|
|
|
|
GcdMemoryType,
|
|
|
|
(EFI_GCD_IO_TYPE) 0,
|
|
|
|
Alignment,
|
|
|
|
Length,
|
|
|
|
BaseAddress,
|
|
|
|
ImageHandle,
|
2007-07-04 12:51:54 +02:00
|
|
|
DeviceHandle
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Adds reserved memory, system memory, or memory-mapped I/O resources to the
|
|
|
|
global coherency domain of the processor.
|
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param GcdMemoryType Memory type of the memory space.
|
|
|
|
@param BaseAddress Base address of the memory space.
|
|
|
|
@param Length Length of the memory space.
|
|
|
|
@param Capabilities alterable attributes of the memory space.
|
2008-05-09 09:08:30 +02:00
|
|
|
|
|
|
|
@retval EFI_SUCCESS Merged this memory space into GCD map.
|
|
|
|
|
|
|
|
**/
|
2007-07-04 12:51:54 +02:00
|
|
|
EFI_STATUS
|
2008-09-10 05:25:49 +02:00
|
|
|
EFIAPI
|
2007-07-04 12:51:54 +02:00
|
|
|
CoreAddMemorySpace (
|
|
|
|
IN EFI_GCD_MEMORY_TYPE GcdMemoryType,
|
|
|
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
|
|
|
IN UINT64 Length,
|
|
|
|
IN UINT64 Capabilities
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_PHYSICAL_ADDRESS PageBaseAddress;
|
|
|
|
UINT64 PageLength;
|
|
|
|
|
|
|
|
Status = CoreInternalAddMemorySpace (GcdMemoryType, BaseAddress, Length, Capabilities);
|
|
|
|
|
|
|
|
if (!EFI_ERROR (Status) && GcdMemoryType == EfiGcdMemoryTypeSystemMemory) {
|
|
|
|
|
|
|
|
PageBaseAddress = PageAlignLength (BaseAddress);
|
|
|
|
PageLength = PageAlignLength (BaseAddress + Length - PageBaseAddress);
|
|
|
|
|
|
|
|
Status = CoreAllocateMemorySpace (
|
|
|
|
EfiGcdAllocateAddress,
|
|
|
|
GcdMemoryType,
|
2008-07-24 04:54:45 +02:00
|
|
|
EFI_PAGE_SHIFT,
|
2007-07-04 12:51:54 +02:00
|
|
|
PageLength,
|
|
|
|
&PageBaseAddress,
|
|
|
|
gDxeCoreImageHandle,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
CoreAddMemoryDescriptor (
|
|
|
|
EfiConventionalMemory,
|
|
|
|
PageBaseAddress,
|
|
|
|
RShiftU64 (PageLength, EFI_PAGE_SHIFT),
|
|
|
|
Capabilities
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
for (; PageLength != 0; PageLength -= EFI_PAGE_SIZE, PageBaseAddress += EFI_PAGE_SIZE) {
|
|
|
|
Status = CoreAllocateMemorySpace (
|
|
|
|
EfiGcdAllocateAddress,
|
|
|
|
GcdMemoryType,
|
2008-07-24 04:54:45 +02:00
|
|
|
EFI_PAGE_SHIFT,
|
2007-07-04 12:51:54 +02:00
|
|
|
EFI_PAGE_SIZE,
|
|
|
|
&PageBaseAddress,
|
|
|
|
gDxeCoreImageHandle,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
CoreAddMemoryDescriptor (
|
|
|
|
EfiConventionalMemory,
|
|
|
|
PageBaseAddress,
|
|
|
|
1,
|
|
|
|
Capabilities
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
/**
|
2007-07-04 12:51:54 +02:00
|
|
|
Frees nonexistent memory, reserved memory, system memory, or memory-mapped
|
2008-05-09 09:08:30 +02:00
|
|
|
I/O resources from the global coherency domain of the processor.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param BaseAddress Base address of the memory space.
|
|
|
|
@param Length Length of the memory space.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
@retval EFI_SUCCESS Space successfully freed.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
**/
|
2007-07-04 12:51:54 +02:00
|
|
|
EFI_STATUS
|
2008-09-10 05:25:49 +02:00
|
|
|
EFIAPI
|
2008-05-09 09:08:30 +02:00
|
|
|
CoreFreeMemorySpace (
|
2007-07-04 12:51:54 +02:00
|
|
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
|
|
|
IN UINT64 Length
|
|
|
|
)
|
2008-05-09 09:08:30 +02:00
|
|
|
{
|
2011-01-06 03:51:08 +01:00
|
|
|
DEBUG ((DEBUG_GCD, "GCD:FreeMemorySpace(Base=%016lx,Length=%016lx)\n", BaseAddress, Length));
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
return CoreConvertSpace (GCD_FREE_MEMORY_OPERATION, (EFI_GCD_MEMORY_TYPE) 0, (EFI_GCD_IO_TYPE) 0, BaseAddress, Length, 0, 0);
|
|
|
|
}
|
2007-07-04 12:51:54 +02:00
|
|
|
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
/**
|
2007-07-04 12:51:54 +02:00
|
|
|
Removes reserved memory, system memory, or memory-mapped I/O resources from
|
2008-05-09 09:08:30 +02:00
|
|
|
the global coherency domain of the processor.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param BaseAddress Base address of the memory space.
|
|
|
|
@param Length Length of the memory space.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
@retval EFI_SUCCESS Successfully remove a segment of memory space.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
**/
|
|
|
|
EFI_STATUS
|
2008-09-10 05:25:49 +02:00
|
|
|
EFIAPI
|
2008-05-09 09:08:30 +02:00
|
|
|
CoreRemoveMemorySpace (
|
|
|
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
|
|
|
IN UINT64 Length
|
|
|
|
)
|
2007-07-04 12:51:54 +02:00
|
|
|
{
|
2011-01-06 03:51:08 +01:00
|
|
|
DEBUG ((DEBUG_GCD, "GCD:RemoveMemorySpace(Base=%016lx,Length=%016lx)\n", BaseAddress, Length));
|
|
|
|
|
2007-07-04 12:51:54 +02:00
|
|
|
return CoreConvertSpace (GCD_REMOVE_MEMORY_OPERATION, (EFI_GCD_MEMORY_TYPE) 0, (EFI_GCD_IO_TYPE) 0, BaseAddress, Length, 0, 0);
|
|
|
|
}
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Build a memory descriptor according to an entry.
|
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param Descriptor The descriptor to be built
|
2008-05-09 09:08:30 +02:00
|
|
|
@param Entry According to this entry
|
|
|
|
|
|
|
|
**/
|
2007-07-04 12:51:54 +02:00
|
|
|
VOID
|
|
|
|
BuildMemoryDescriptor (
|
|
|
|
IN OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Descriptor,
|
|
|
|
IN EFI_GCD_MAP_ENTRY *Entry
|
|
|
|
)
|
|
|
|
{
|
|
|
|
Descriptor->BaseAddress = Entry->BaseAddress;
|
|
|
|
Descriptor->Length = Entry->EndAddress - Entry->BaseAddress + 1;
|
|
|
|
Descriptor->Capabilities = Entry->Capabilities;
|
|
|
|
Descriptor->Attributes = Entry->Attributes;
|
|
|
|
Descriptor->GcdMemoryType = Entry->GcdMemoryType;
|
|
|
|
Descriptor->ImageHandle = Entry->ImageHandle;
|
|
|
|
Descriptor->DeviceHandle = Entry->DeviceHandle;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
/**
|
2007-07-04 12:51:54 +02:00
|
|
|
Retrieves the descriptor for a memory region containing a specified address.
|
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param BaseAddress Specified start address
|
|
|
|
@param Descriptor Specified length
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@retval EFI_INVALID_PARAMETER Invalid parameter
|
2008-05-09 09:08:30 +02:00
|
|
|
@retval EFI_SUCCESS Successfully get memory space descriptor.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
**/
|
|
|
|
EFI_STATUS
|
2008-09-10 05:25:49 +02:00
|
|
|
EFIAPI
|
2008-05-09 09:08:30 +02:00
|
|
|
CoreGetMemorySpaceDescriptor (
|
|
|
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
|
|
|
OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Descriptor
|
|
|
|
)
|
2007-07-04 12:51:54 +02:00
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
LIST_ENTRY *StartLink;
|
|
|
|
LIST_ENTRY *EndLink;
|
|
|
|
EFI_GCD_MAP_ENTRY *Entry;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Make sure parameters are valid
|
|
|
|
//
|
|
|
|
if (Descriptor == NULL) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
CoreAcquireGcdMemoryLock ();
|
|
|
|
|
|
|
|
//
|
2008-07-24 04:54:45 +02:00
|
|
|
// Search for the list of descriptors that contain BaseAddress
|
2007-07-04 12:51:54 +02:00
|
|
|
//
|
|
|
|
Status = CoreSearchGcdMapEntry (BaseAddress, 1, &StartLink, &EndLink, &mGcdMemorySpaceMap);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
Status = EFI_NOT_FOUND;
|
|
|
|
} else {
|
2010-02-26 09:53:27 +01:00
|
|
|
ASSERT (StartLink != NULL && EndLink != NULL);
|
2007-07-04 12:51:54 +02:00
|
|
|
//
|
|
|
|
// Copy the contents of the found descriptor into Descriptor
|
|
|
|
//
|
|
|
|
Entry = CR (StartLink, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
|
|
|
|
BuildMemoryDescriptor (Descriptor, Entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
CoreReleaseGcdMemoryLock ();
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Modifies the attributes for a memory region in the global coherency domain of the
|
|
|
|
processor.
|
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param BaseAddress Specified start address
|
|
|
|
@param Length Specified length
|
|
|
|
@param Attributes Specified attributes
|
2008-05-09 09:08:30 +02:00
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@retval EFI_SUCCESS Successfully set attribute of a segment of
|
2008-05-09 09:08:30 +02:00
|
|
|
memory space.
|
|
|
|
|
|
|
|
**/
|
2007-07-04 12:51:54 +02:00
|
|
|
EFI_STATUS
|
2008-09-10 05:25:49 +02:00
|
|
|
EFIAPI
|
2007-07-04 12:51:54 +02:00
|
|
|
CoreSetMemorySpaceAttributes (
|
|
|
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
|
|
|
IN UINT64 Length,
|
|
|
|
IN UINT64 Attributes
|
|
|
|
)
|
2008-05-09 09:08:30 +02:00
|
|
|
{
|
2011-01-06 03:51:08 +01:00
|
|
|
DEBUG ((DEBUG_GCD, "GCD:SetMemorySpaceAttributes(Base=%016lx,Length=%016lx)\n", BaseAddress, Length));
|
|
|
|
DEBUG ((DEBUG_GCD, " Attributes = %016lx\n", Attributes));
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
return CoreConvertSpace (GCD_SET_ATTRIBUTES_MEMORY_OPERATION, (EFI_GCD_MEMORY_TYPE) 0, (EFI_GCD_IO_TYPE) 0, BaseAddress, Length, 0, Attributes);
|
|
|
|
}
|
2007-07-04 12:51:54 +02:00
|
|
|
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
/**
|
|
|
|
Returns a map of the memory resources in the global coherency domain of the
|
|
|
|
processor.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param NumberOfDescriptors Number of descriptors.
|
|
|
|
@param MemorySpaceMap Descriptor array
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@retval EFI_INVALID_PARAMETER Invalid parameter
|
|
|
|
@retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
|
2008-05-09 09:08:30 +02:00
|
|
|
@retval EFI_SUCCESS Successfully get memory space map.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
**/
|
2007-07-04 12:51:54 +02:00
|
|
|
EFI_STATUS
|
2008-09-10 05:25:49 +02:00
|
|
|
EFIAPI
|
2007-07-04 12:51:54 +02:00
|
|
|
CoreGetMemorySpaceMap (
|
|
|
|
OUT UINTN *NumberOfDescriptors,
|
|
|
|
OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR **MemorySpaceMap
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
LIST_ENTRY *Link;
|
|
|
|
EFI_GCD_MAP_ENTRY *Entry;
|
|
|
|
EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Descriptor;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Make sure parameters are valid
|
|
|
|
//
|
|
|
|
if (NumberOfDescriptors == NULL) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
if (MemorySpaceMap == NULL) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
CoreAcquireGcdMemoryLock ();
|
|
|
|
|
|
|
|
//
|
|
|
|
// Count the number of descriptors
|
|
|
|
//
|
|
|
|
*NumberOfDescriptors = CoreCountGcdMapEntry (&mGcdMemorySpaceMap);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Allocate the MemorySpaceMap
|
|
|
|
//
|
2008-08-27 16:29:23 +02:00
|
|
|
*MemorySpaceMap = AllocatePool (*NumberOfDescriptors * sizeof (EFI_GCD_MEMORY_SPACE_DESCRIPTOR));
|
2007-07-04 12:51:54 +02:00
|
|
|
if (*MemorySpaceMap == NULL) {
|
|
|
|
Status = EFI_OUT_OF_RESOURCES;
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Fill in the MemorySpaceMap
|
|
|
|
//
|
|
|
|
Descriptor = *MemorySpaceMap;
|
|
|
|
Link = mGcdMemorySpaceMap.ForwardLink;
|
|
|
|
while (Link != &mGcdMemorySpaceMap) {
|
|
|
|
Entry = CR (Link, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
|
|
|
|
BuildMemoryDescriptor (Descriptor, Entry);
|
|
|
|
Descriptor++;
|
|
|
|
Link = Link->ForwardLink;
|
|
|
|
}
|
|
|
|
Status = EFI_SUCCESS;
|
|
|
|
|
|
|
|
Done:
|
|
|
|
CoreReleaseGcdMemoryLock ();
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Adds reserved I/O or I/O resources to the global coherency domain of the processor.
|
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param GcdIoType IO type of the segment.
|
|
|
|
@param BaseAddress Base address of the segment.
|
|
|
|
@param Length Length of the segment.
|
2008-05-09 09:08:30 +02:00
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@retval EFI_SUCCESS Merged this segment into GCD map.
|
2008-05-09 09:08:30 +02:00
|
|
|
@retval EFI_INVALID_PARAMETER Parameter not valid
|
|
|
|
|
|
|
|
**/
|
2007-07-04 12:51:54 +02:00
|
|
|
EFI_STATUS
|
2008-09-10 05:25:49 +02:00
|
|
|
EFIAPI
|
2007-07-04 12:51:54 +02:00
|
|
|
CoreAddIoSpace (
|
|
|
|
IN EFI_GCD_IO_TYPE GcdIoType,
|
|
|
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
|
|
|
IN UINT64 Length
|
|
|
|
)
|
|
|
|
{
|
2011-01-06 03:51:08 +01:00
|
|
|
DEBUG ((DEBUG_GCD, "GCD:AddIoSpace(Base=%016lx,Length=%016lx)\n", BaseAddress, Length));
|
|
|
|
DEBUG ((DEBUG_GCD, " GcdIoType = %a\n", mGcdIoTypeNames[MIN (GcdIoType, EfiGcdIoTypeMaximum)]));
|
|
|
|
|
2007-07-04 12:51:54 +02:00
|
|
|
//
|
|
|
|
// Make sure parameters are valid
|
|
|
|
//
|
|
|
|
if (GcdIoType <= EfiGcdIoTypeNonExistent || GcdIoType >= EfiGcdIoTypeMaximum) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
return CoreConvertSpace (GCD_ADD_IO_OPERATION, (EFI_GCD_MEMORY_TYPE) 0, GcdIoType, BaseAddress, Length, 0, 0);
|
|
|
|
}
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Allocates nonexistent I/O, reserved I/O, or I/O resources from the global coherency
|
|
|
|
domain of the processor.
|
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param GcdAllocateType The type of allocate operation
|
|
|
|
@param GcdIoType The desired IO type
|
|
|
|
@param Alignment Align with 2^Alignment
|
|
|
|
@param Length Length to allocate
|
|
|
|
@param BaseAddress Base address to allocate
|
|
|
|
@param ImageHandle The image handle consume the allocated space.
|
|
|
|
@param DeviceHandle The device handle consume the allocated space.
|
2008-05-09 09:08:30 +02:00
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@retval EFI_INVALID_PARAMETER Invalid parameter.
|
|
|
|
@retval EFI_NOT_FOUND No descriptor contains the desired space.
|
2008-05-09 09:08:30 +02:00
|
|
|
@retval EFI_SUCCESS IO space successfully allocated.
|
|
|
|
|
|
|
|
**/
|
2007-07-04 12:51:54 +02:00
|
|
|
EFI_STATUS
|
2008-09-10 05:25:49 +02:00
|
|
|
EFIAPI
|
2007-07-04 12:51:54 +02:00
|
|
|
CoreAllocateIoSpace (
|
|
|
|
IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType,
|
|
|
|
IN EFI_GCD_IO_TYPE GcdIoType,
|
|
|
|
IN UINTN Alignment,
|
|
|
|
IN UINT64 Length,
|
|
|
|
IN OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_HANDLE DeviceHandle OPTIONAL
|
|
|
|
)
|
|
|
|
{
|
2011-01-06 03:51:08 +01:00
|
|
|
DEBUG ((DEBUG_GCD, "GCD:AllocateIoSpace(Base=%016lx,Length=%016lx)\n", *BaseAddress, Length));
|
|
|
|
DEBUG ((DEBUG_GCD, " GcdAllocateType = %a\n", mGcdAllocationTypeNames[MIN (GcdAllocateType, EfiGcdMaxAllocateType)]));
|
2011-01-21 19:49:36 +01:00
|
|
|
DEBUG ((DEBUG_GCD, " GcdIoType = %a\n", mGcdIoTypeNames[MIN (GcdIoType, EfiGcdIoTypeMaximum)]));
|
2011-01-06 03:51:08 +01:00
|
|
|
DEBUG ((DEBUG_GCD, " Alignment = %016lx\n", LShiftU64 (1, Alignment)));
|
|
|
|
DEBUG ((DEBUG_GCD, " ImageHandle = %p\n", ImageHandle));
|
|
|
|
DEBUG ((DEBUG_GCD, " DeviceHandle = %p\n", DeviceHandle));
|
|
|
|
|
2007-07-04 12:51:54 +02:00
|
|
|
return CoreAllocateSpace (
|
2008-07-24 04:54:45 +02:00
|
|
|
GCD_ALLOCATE_IO_OPERATION,
|
|
|
|
GcdAllocateType,
|
|
|
|
(EFI_GCD_MEMORY_TYPE) 0,
|
|
|
|
GcdIoType,
|
|
|
|
Alignment,
|
|
|
|
Length,
|
|
|
|
BaseAddress,
|
|
|
|
ImageHandle,
|
2007-07-04 12:51:54 +02:00
|
|
|
DeviceHandle
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
/**
|
2007-07-04 12:51:54 +02:00
|
|
|
Frees nonexistent I/O, reserved I/O, or I/O resources from the global coherency
|
2008-05-09 09:08:30 +02:00
|
|
|
domain of the processor.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param BaseAddress Base address of the segment.
|
|
|
|
@param Length Length of the segment.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
@retval EFI_SUCCESS Space successfully freed.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
**/
|
2007-07-04 12:51:54 +02:00
|
|
|
EFI_STATUS
|
2008-09-10 05:25:49 +02:00
|
|
|
EFIAPI
|
2008-05-09 09:08:30 +02:00
|
|
|
CoreFreeIoSpace (
|
2007-07-04 12:51:54 +02:00
|
|
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
|
|
|
IN UINT64 Length
|
|
|
|
)
|
2008-05-09 09:08:30 +02:00
|
|
|
{
|
2011-01-06 03:51:08 +01:00
|
|
|
DEBUG ((DEBUG_GCD, "GCD:FreeIoSpace(Base=%016lx,Length=%016lx)\n", BaseAddress, Length));
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
return CoreConvertSpace (GCD_FREE_IO_OPERATION, (EFI_GCD_MEMORY_TYPE) 0, (EFI_GCD_IO_TYPE) 0, BaseAddress, Length, 0, 0);
|
|
|
|
}
|
2007-07-04 12:51:54 +02:00
|
|
|
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
/**
|
2007-07-04 12:51:54 +02:00
|
|
|
Removes reserved I/O or I/O resources from the global coherency domain of the
|
2008-05-09 09:08:30 +02:00
|
|
|
processor.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param BaseAddress Base address of the segment.
|
|
|
|
@param Length Length of the segment.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
@retval EFI_SUCCESS Successfully removed a segment of IO space.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
**/
|
|
|
|
EFI_STATUS
|
2008-09-10 05:25:49 +02:00
|
|
|
EFIAPI
|
2008-05-09 09:08:30 +02:00
|
|
|
CoreRemoveIoSpace (
|
|
|
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
|
|
|
IN UINT64 Length
|
|
|
|
)
|
2007-07-04 12:51:54 +02:00
|
|
|
{
|
2011-01-06 03:51:08 +01:00
|
|
|
DEBUG ((DEBUG_GCD, "GCD:RemoveIoSpace(Base=%016lx,Length=%016lx)\n", BaseAddress, Length));
|
|
|
|
|
2007-07-04 12:51:54 +02:00
|
|
|
return CoreConvertSpace (GCD_REMOVE_IO_OPERATION, (EFI_GCD_MEMORY_TYPE) 0, (EFI_GCD_IO_TYPE) 0, BaseAddress, Length, 0, 0);
|
|
|
|
}
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Build a IO descriptor according to an entry.
|
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param Descriptor The descriptor to be built
|
2008-05-09 09:08:30 +02:00
|
|
|
@param Entry According to this entry
|
|
|
|
|
|
|
|
**/
|
2007-07-04 12:51:54 +02:00
|
|
|
VOID
|
|
|
|
BuildIoDescriptor (
|
|
|
|
IN EFI_GCD_IO_SPACE_DESCRIPTOR *Descriptor,
|
|
|
|
IN EFI_GCD_MAP_ENTRY *Entry
|
|
|
|
)
|
|
|
|
{
|
|
|
|
Descriptor->BaseAddress = Entry->BaseAddress;
|
|
|
|
Descriptor->Length = Entry->EndAddress - Entry->BaseAddress + 1;
|
|
|
|
Descriptor->GcdIoType = Entry->GcdIoType;
|
|
|
|
Descriptor->ImageHandle = Entry->ImageHandle;
|
|
|
|
Descriptor->DeviceHandle = Entry->DeviceHandle;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
/**
|
2007-07-04 12:51:54 +02:00
|
|
|
Retrieves the descriptor for an I/O region containing a specified address.
|
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param BaseAddress Specified start address
|
|
|
|
@param Descriptor Specified length
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@retval EFI_INVALID_PARAMETER Descriptor is NULL.
|
2008-05-09 09:08:30 +02:00
|
|
|
@retval EFI_SUCCESS Successfully get the IO space descriptor.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
**/
|
|
|
|
EFI_STATUS
|
2008-09-10 05:25:49 +02:00
|
|
|
EFIAPI
|
2008-05-09 09:08:30 +02:00
|
|
|
CoreGetIoSpaceDescriptor (
|
|
|
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
|
|
|
OUT EFI_GCD_IO_SPACE_DESCRIPTOR *Descriptor
|
|
|
|
)
|
2007-07-04 12:51:54 +02:00
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
LIST_ENTRY *StartLink;
|
|
|
|
LIST_ENTRY *EndLink;
|
|
|
|
EFI_GCD_MAP_ENTRY *Entry;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Make sure parameters are valid
|
|
|
|
//
|
|
|
|
if (Descriptor == NULL) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
CoreAcquireGcdIoLock ();
|
|
|
|
|
|
|
|
//
|
2008-07-24 04:54:45 +02:00
|
|
|
// Search for the list of descriptors that contain BaseAddress
|
2007-07-04 12:51:54 +02:00
|
|
|
//
|
|
|
|
Status = CoreSearchGcdMapEntry (BaseAddress, 1, &StartLink, &EndLink, &mGcdIoSpaceMap);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
Status = EFI_NOT_FOUND;
|
|
|
|
} else {
|
2010-02-26 09:53:27 +01:00
|
|
|
ASSERT (StartLink != NULL && EndLink != NULL);
|
2007-07-04 12:51:54 +02:00
|
|
|
//
|
|
|
|
// Copy the contents of the found descriptor into Descriptor
|
|
|
|
//
|
|
|
|
Entry = CR (StartLink, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
|
|
|
|
BuildIoDescriptor (Descriptor, Entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
CoreReleaseGcdIoLock ();
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
/**
|
2007-07-04 12:51:54 +02:00
|
|
|
Returns a map of the I/O resources in the global coherency domain of the processor.
|
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param NumberOfDescriptors Number of descriptors.
|
|
|
|
@param IoSpaceMap Descriptor array
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@retval EFI_INVALID_PARAMETER Invalid parameter
|
|
|
|
@retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
|
2008-05-09 09:08:30 +02:00
|
|
|
@retval EFI_SUCCESS Successfully get IO space map.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
**/
|
|
|
|
EFI_STATUS
|
2008-09-10 05:25:49 +02:00
|
|
|
EFIAPI
|
2008-05-09 09:08:30 +02:00
|
|
|
CoreGetIoSpaceMap (
|
|
|
|
OUT UINTN *NumberOfDescriptors,
|
|
|
|
OUT EFI_GCD_IO_SPACE_DESCRIPTOR **IoSpaceMap
|
|
|
|
)
|
2007-07-04 12:51:54 +02:00
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
LIST_ENTRY *Link;
|
|
|
|
EFI_GCD_MAP_ENTRY *Entry;
|
|
|
|
EFI_GCD_IO_SPACE_DESCRIPTOR *Descriptor;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Make sure parameters are valid
|
|
|
|
//
|
|
|
|
if (NumberOfDescriptors == NULL) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
if (IoSpaceMap == NULL) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
CoreAcquireGcdIoLock ();
|
|
|
|
|
|
|
|
//
|
|
|
|
// Count the number of descriptors
|
|
|
|
//
|
|
|
|
*NumberOfDescriptors = CoreCountGcdMapEntry (&mGcdIoSpaceMap);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Allocate the IoSpaceMap
|
|
|
|
//
|
2008-08-27 16:29:23 +02:00
|
|
|
*IoSpaceMap = AllocatePool (*NumberOfDescriptors * sizeof (EFI_GCD_IO_SPACE_DESCRIPTOR));
|
2007-07-04 12:51:54 +02:00
|
|
|
if (*IoSpaceMap == NULL) {
|
|
|
|
Status = EFI_OUT_OF_RESOURCES;
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Fill in the IoSpaceMap
|
|
|
|
//
|
|
|
|
Descriptor = *IoSpaceMap;
|
|
|
|
Link = mGcdIoSpaceMap.ForwardLink;
|
|
|
|
while (Link != &mGcdIoSpaceMap) {
|
|
|
|
Entry = CR (Link, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
|
|
|
|
BuildIoDescriptor (Descriptor, Entry);
|
|
|
|
Descriptor++;
|
|
|
|
Link = Link->ForwardLink;
|
|
|
|
}
|
|
|
|
Status = EFI_SUCCESS;
|
|
|
|
|
|
|
|
Done:
|
|
|
|
CoreReleaseGcdIoLock ();
|
|
|
|
return Status;
|
2008-07-24 04:54:45 +02:00
|
|
|
}
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2011-01-12 00:11:23 +01:00
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
/**
|
|
|
|
Converts a Resource Descriptor HOB attributes mask to an EFI Memory Descriptor
|
|
|
|
capabilities mask
|
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param GcdMemoryType Type of resource in the GCD memory map.
|
|
|
|
@param Attributes The attribute mask in the Resource Descriptor
|
|
|
|
HOB.
|
2008-05-09 09:08:30 +02:00
|
|
|
|
|
|
|
@return The capabilities mask for an EFI Memory Descriptor.
|
|
|
|
|
|
|
|
**/
|
2007-07-04 12:51:54 +02:00
|
|
|
UINT64
|
|
|
|
CoreConvertResourceDescriptorHobAttributesToCapabilities (
|
|
|
|
EFI_GCD_MEMORY_TYPE GcdMemoryType,
|
|
|
|
UINT64 Attributes
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINT64 Capabilities;
|
|
|
|
GCD_ATTRIBUTE_CONVERSION_ENTRY *Conversion;
|
2008-07-24 04:54:45 +02:00
|
|
|
|
2007-07-04 12:51:54 +02:00
|
|
|
//
|
|
|
|
// Convert the Resource HOB Attributes to an EFI Memory Capabilities mask
|
|
|
|
//
|
|
|
|
for (Capabilities = 0, Conversion = mAttributeConversionTable; Conversion->Attribute != 0; Conversion++) {
|
|
|
|
if (Conversion->Memory || (GcdMemoryType != EfiGcdMemoryTypeSystemMemory)) {
|
|
|
|
if (Attributes & Conversion->Attribute) {
|
|
|
|
Capabilities |= Conversion->Capability;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-07-24 04:54:45 +02:00
|
|
|
|
2007-07-04 12:51:54 +02:00
|
|
|
return Capabilities;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
/**
|
2008-09-16 09:35:17 +02:00
|
|
|
External function. Initializes memory services based on the memory
|
|
|
|
descriptor HOBs. This function is responsible for priming the memory
|
|
|
|
map, so memory allocations and resource allocations can be made.
|
|
|
|
The first part of this function can not depend on any memory services
|
|
|
|
until at least one memory descriptor is provided to the memory services.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param HobStart The start address of the HOB.
|
|
|
|
@param MemoryBaseAddress Start address of memory region found to init DXE
|
|
|
|
core.
|
|
|
|
@param MemoryLength Length of memory region found to init DXE core.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
@retval EFI_SUCCESS Memory services successfully initialized.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
CoreInitializeMemoryServices (
|
|
|
|
IN VOID **HobStart,
|
|
|
|
OUT EFI_PHYSICAL_ADDRESS *MemoryBaseAddress,
|
|
|
|
OUT UINT64 *MemoryLength
|
|
|
|
)
|
2007-07-04 12:51:54 +02:00
|
|
|
{
|
|
|
|
EFI_PEI_HOB_POINTERS Hob;
|
|
|
|
EFI_MEMORY_TYPE_INFORMATION *EfiMemoryTypeInformation;
|
|
|
|
UINTN DataSize;
|
|
|
|
BOOLEAN Found;
|
|
|
|
EFI_HOB_HANDOFF_INFO_TABLE *PhitHob;
|
|
|
|
EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob;
|
|
|
|
EFI_HOB_RESOURCE_DESCRIPTOR *PhitResourceHob;
|
|
|
|
EFI_PHYSICAL_ADDRESS BaseAddress;
|
|
|
|
UINT64 Length;
|
|
|
|
UINT64 Attributes;
|
|
|
|
UINT64 Capabilities;
|
|
|
|
EFI_PHYSICAL_ADDRESS MaxMemoryBaseAddress;
|
|
|
|
UINT64 MaxMemoryLength;
|
|
|
|
UINT64 MaxMemoryAttributes;
|
|
|
|
EFI_PHYSICAL_ADDRESS MaxAddress;
|
|
|
|
EFI_PHYSICAL_ADDRESS HighAddress;
|
|
|
|
EFI_HOB_RESOURCE_DESCRIPTOR *MaxResourceHob;
|
|
|
|
EFI_HOB_GUID_TYPE *GuidHob;
|
2010-02-05 08:54:16 +01:00
|
|
|
UINT32 ReservedCodePageNumber;
|
2007-07-04 12:51:54 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Point at the first HOB. This must be the PHIT HOB.
|
|
|
|
//
|
|
|
|
Hob.Raw = *HobStart;
|
|
|
|
ASSERT (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_HANDOFF);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Initialize the spin locks and maps in the memory services.
|
|
|
|
// Also fill in the memory services into the EFI Boot Services Table
|
|
|
|
//
|
|
|
|
CoreInitializePool ();
|
|
|
|
|
|
|
|
//
|
|
|
|
// Initialize Local Variables
|
|
|
|
//
|
|
|
|
PhitResourceHob = NULL;
|
|
|
|
MaxResourceHob = NULL;
|
|
|
|
ResourceHob = NULL;
|
|
|
|
BaseAddress = 0;
|
|
|
|
Length = 0;
|
|
|
|
Attributes = 0;
|
|
|
|
MaxMemoryBaseAddress = 0;
|
|
|
|
MaxMemoryLength = 0;
|
|
|
|
MaxMemoryAttributes = 0;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Cache the PHIT HOB for later use
|
|
|
|
//
|
|
|
|
PhitHob = Hob.HandoffInformationTable;
|
2010-02-05 08:54:16 +01:00
|
|
|
|
2010-02-10 07:10:53 +01:00
|
|
|
if (PcdGet64(PcdLoadModuleAtFixAddressEnable) != 0) {
|
2010-02-05 08:54:16 +01:00
|
|
|
ReservedCodePageNumber = PcdGet32(PcdLoadFixAddressRuntimeCodePageNumber);
|
|
|
|
ReservedCodePageNumber += PcdGet32(PcdLoadFixAddressBootTimeCodePageNumber);
|
|
|
|
|
|
|
|
//
|
|
|
|
// cache the Top address for loading modules at Fixed Address
|
|
|
|
//
|
|
|
|
gLoadModuleAtFixAddressConfigurationTable.DxeCodeTopAddress = PhitHob->EfiMemoryTop
|
|
|
|
+ EFI_PAGES_TO_SIZE(ReservedCodePageNumber);
|
|
|
|
}
|
2007-07-04 12:51:54 +02:00
|
|
|
//
|
|
|
|
// See if a Memory Type Information HOB is available
|
|
|
|
//
|
|
|
|
GuidHob = GetFirstGuidHob (&gEfiMemoryTypeInformationGuid);
|
|
|
|
if (GuidHob != NULL) {
|
|
|
|
EfiMemoryTypeInformation = GET_GUID_HOB_DATA (GuidHob);
|
|
|
|
DataSize = GET_GUID_HOB_DATA_SIZE (GuidHob);
|
|
|
|
if (EfiMemoryTypeInformation != NULL && DataSize > 0 && DataSize <= (EfiMaxMemoryType + 1) * sizeof (EFI_MEMORY_TYPE_INFORMATION)) {
|
|
|
|
CopyMem (&gMemoryTypeInformation, EfiMemoryTypeInformation, DataSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Find the Resource Descriptor HOB that contains range FreeMemoryBaseAddress..FreeMemoryLength
|
|
|
|
//
|
|
|
|
Length = 0;
|
|
|
|
Found = FALSE;
|
|
|
|
for (Hob.Raw = *HobStart; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {
|
|
|
|
|
|
|
|
if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {
|
|
|
|
|
|
|
|
ResourceHob = Hob.ResourceDescriptor;
|
|
|
|
|
|
|
|
if (ResourceHob->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY &&
|
|
|
|
(ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) == TESTED_MEMORY_ATTRIBUTES ) {
|
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
if (PhitHob->EfiFreeMemoryBottom >= ResourceHob->PhysicalStart &&
|
2007-07-04 12:51:54 +02:00
|
|
|
PhitHob->EfiFreeMemoryTop <= (ResourceHob->PhysicalStart + ResourceHob->ResourceLength) ) {
|
|
|
|
|
|
|
|
//
|
|
|
|
// Cache the resource descriptor HOB for the memory region described by the PHIT HOB
|
|
|
|
//
|
|
|
|
PhitResourceHob = ResourceHob;
|
|
|
|
Found = TRUE;
|
|
|
|
|
|
|
|
Attributes = PhitResourceHob->ResourceAttribute;
|
|
|
|
BaseAddress = PageAlignAddress (PhitHob->EfiMemoryTop);
|
|
|
|
Length = PageAlignLength (ResourceHob->PhysicalStart + ResourceHob->ResourceLength - BaseAddress);
|
|
|
|
if (Length < MINIMUM_INITIAL_MEMORY_SIZE) {
|
|
|
|
BaseAddress = PageAlignAddress (PhitHob->EfiFreeMemoryBottom);
|
|
|
|
Length = PageAlignLength (PhitHob->EfiFreeMemoryTop - BaseAddress);
|
|
|
|
if (Length < MINIMUM_INITIAL_MEMORY_SIZE) {
|
|
|
|
BaseAddress = PageAlignAddress (ResourceHob->PhysicalStart);
|
|
|
|
Length = PageAlignLength ((UINT64)((UINTN)*HobStart - BaseAddress));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Assert if a resource descriptor HOB for the memory region described by the PHIT was not found
|
|
|
|
//
|
|
|
|
ASSERT (Found);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Search all the resource descriptor HOBs from the highest possible addresses down for a memory
|
|
|
|
// region that is big enough to initialize the DXE core. Always skip the PHIT Resource HOB.
|
|
|
|
// The max address must be within the physically addressible range for the processor.
|
|
|
|
//
|
|
|
|
MaxMemoryLength = 0;
|
2008-12-16 16:34:21 +01:00
|
|
|
MaxAddress = MAX_ADDRESS;
|
2007-07-04 12:51:54 +02:00
|
|
|
do {
|
|
|
|
HighAddress = 0;
|
|
|
|
Found = FALSE;
|
|
|
|
//
|
|
|
|
// Search for a tested memory region that is below MaxAddress
|
|
|
|
//
|
|
|
|
for (Hob.Raw = *HobStart; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {
|
|
|
|
|
|
|
|
//
|
|
|
|
// See if this is a resource descriptor HOB that does not contain the PHIT.
|
|
|
|
//
|
|
|
|
if (Hob.ResourceDescriptor != PhitResourceHob && GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {
|
|
|
|
|
|
|
|
ResourceHob = Hob.ResourceDescriptor;
|
|
|
|
//
|
|
|
|
// See if this resource descrior HOB describes tested system memory below MaxAddress
|
|
|
|
//
|
2008-07-18 11:50:09 +02:00
|
|
|
if (ResourceHob->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY &&
|
|
|
|
(ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) == TESTED_MEMORY_ATTRIBUTES &&
|
|
|
|
ResourceHob->PhysicalStart + ResourceHob->ResourceLength <= MaxAddress) {
|
2007-07-04 12:51:54 +02:00
|
|
|
//
|
|
|
|
// See if this is the highest tested system memory region below MaxAddress
|
|
|
|
//
|
|
|
|
if (ResourceHob->PhysicalStart > HighAddress) {
|
|
|
|
|
|
|
|
MaxResourceHob = ResourceHob;
|
|
|
|
HighAddress = MaxResourceHob->PhysicalStart;
|
|
|
|
Found = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Found) {
|
|
|
|
//
|
|
|
|
// Compute the size of the tested memory region below MaxAddrees
|
|
|
|
//
|
|
|
|
MaxMemoryBaseAddress = PageAlignAddress (MaxResourceHob->PhysicalStart);
|
|
|
|
MaxMemoryLength = PageAlignLength (MaxResourceHob->PhysicalStart + MaxResourceHob->ResourceLength - MaxMemoryBaseAddress);
|
|
|
|
MaxMemoryAttributes = MaxResourceHob->ResourceAttribute;
|
|
|
|
}
|
|
|
|
MaxAddress = ResourceHob->PhysicalStart;
|
|
|
|
} while (Found && MaxMemoryLength < MINIMUM_INITIAL_MEMORY_SIZE);
|
|
|
|
|
2008-07-18 11:50:09 +02:00
|
|
|
if ((Length < MINIMUM_INITIAL_MEMORY_SIZE) ||
|
|
|
|
(MaxMemoryBaseAddress > BaseAddress && MaxMemoryLength >= MINIMUM_INITIAL_MEMORY_SIZE)) {
|
2007-07-04 12:51:54 +02:00
|
|
|
BaseAddress = MaxMemoryBaseAddress;
|
|
|
|
Length = MaxMemoryLength;
|
|
|
|
Attributes = MaxMemoryAttributes;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// If no memory regions are found that are big enough to initialize the DXE core, then ASSERT().
|
|
|
|
//
|
|
|
|
ASSERT (Length >= MINIMUM_INITIAL_MEMORY_SIZE);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Convert the Resource HOB Attributes to an EFI Memory Capabilities mask
|
|
|
|
//
|
|
|
|
Capabilities = CoreConvertResourceDescriptorHobAttributesToCapabilities (EfiGcdMemoryTypeSystemMemory, Attributes);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Declare the very first memory region, so the EFI Memory Services are available.
|
|
|
|
//
|
|
|
|
CoreAddMemoryDescriptor (
|
|
|
|
EfiConventionalMemory,
|
|
|
|
BaseAddress,
|
|
|
|
RShiftU64 (Length, EFI_PAGE_SHIFT),
|
|
|
|
Capabilities
|
|
|
|
);
|
|
|
|
|
|
|
|
*MemoryBaseAddress = BaseAddress;
|
|
|
|
*MemoryLength = Length;
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
/**
|
|
|
|
External function. Initializes the GCD and memory services based on the memory
|
2007-07-04 12:51:54 +02:00
|
|
|
descriptor HOBs. This function is responsible for priming the GCD map and the
|
2008-09-16 09:35:17 +02:00
|
|
|
memory map, so memory allocations and resource allocations can be made. The
|
|
|
|
HobStart will be relocated to a pool buffer.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param HobStart The start address of the HOB
|
|
|
|
@param MemoryBaseAddress Start address of memory region found to init DXE
|
|
|
|
core.
|
|
|
|
@param MemoryLength Length of memory region found to init DXE core.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
@retval EFI_SUCCESS GCD services successfully initialized.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
CoreInitializeGcdServices (
|
2008-07-18 11:50:09 +02:00
|
|
|
IN OUT VOID **HobStart,
|
2008-05-09 09:08:30 +02:00
|
|
|
IN EFI_PHYSICAL_ADDRESS MemoryBaseAddress,
|
|
|
|
IN UINT64 MemoryLength
|
|
|
|
)
|
2007-07-04 12:51:54 +02:00
|
|
|
{
|
2008-07-18 11:50:09 +02:00
|
|
|
EFI_PEI_HOB_POINTERS Hob;
|
2007-07-04 12:51:54 +02:00
|
|
|
VOID *NewHobList;
|
2008-07-18 11:50:09 +02:00
|
|
|
EFI_HOB_HANDOFF_INFO_TABLE *PhitHob;
|
2007-07-04 12:51:54 +02:00
|
|
|
UINT8 SizeOfMemorySpace;
|
|
|
|
UINT8 SizeOfIoSpace;
|
|
|
|
EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob;
|
|
|
|
EFI_PHYSICAL_ADDRESS BaseAddress;
|
|
|
|
UINT64 Length;
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_GCD_MAP_ENTRY *Entry;
|
|
|
|
EFI_GCD_MEMORY_TYPE GcdMemoryType;
|
|
|
|
EFI_GCD_IO_TYPE GcdIoType;
|
|
|
|
EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor;
|
|
|
|
EFI_HOB_MEMORY_ALLOCATION *MemoryHob;
|
|
|
|
EFI_HOB_FIRMWARE_VOLUME *FirmwareVolumeHob;
|
|
|
|
UINTN NumberOfDescriptors;
|
|
|
|
EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap;
|
|
|
|
UINTN Index;
|
|
|
|
UINT64 Capabilities;
|
|
|
|
EFI_HOB_CPU * CpuHob;
|
2008-07-18 11:50:09 +02:00
|
|
|
|
2007-07-04 12:51:54 +02:00
|
|
|
//
|
|
|
|
// Cache the PHIT HOB for later use
|
|
|
|
//
|
|
|
|
PhitHob = (EFI_HOB_HANDOFF_INFO_TABLE *)(*HobStart);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Get the number of address lines in the I/O and Memory space for the CPU
|
|
|
|
//
|
|
|
|
CpuHob = GetFirstHob (EFI_HOB_TYPE_CPU);
|
|
|
|
ASSERT (CpuHob != NULL);
|
|
|
|
SizeOfMemorySpace = CpuHob->SizeOfMemorySpace;
|
|
|
|
SizeOfIoSpace = CpuHob->SizeOfIoSpace;
|
2008-07-24 04:54:45 +02:00
|
|
|
|
2007-07-04 12:51:54 +02:00
|
|
|
//
|
|
|
|
// Initialize the GCD Memory Space Map
|
|
|
|
//
|
2008-08-27 16:29:23 +02:00
|
|
|
Entry = AllocateCopyPool (sizeof (EFI_GCD_MAP_ENTRY), &mGcdMemorySpaceMapEntryTemplate);
|
2007-07-04 12:51:54 +02:00
|
|
|
ASSERT (Entry != NULL);
|
|
|
|
|
|
|
|
Entry->EndAddress = LShiftU64 (1, SizeOfMemorySpace) - 1;
|
|
|
|
|
|
|
|
InsertHeadList (&mGcdMemorySpaceMap, &Entry->Link);
|
|
|
|
|
2011-01-12 00:11:23 +01:00
|
|
|
CoreDumpGcdMemorySpaceMap (TRUE);
|
2011-01-06 03:51:08 +01:00
|
|
|
|
2007-07-04 12:51:54 +02:00
|
|
|
//
|
|
|
|
// Initialize the GCD I/O Space Map
|
|
|
|
//
|
2008-08-27 16:29:23 +02:00
|
|
|
Entry = AllocateCopyPool (sizeof (EFI_GCD_MAP_ENTRY), &mGcdIoSpaceMapEntryTemplate);
|
2007-07-04 12:51:54 +02:00
|
|
|
ASSERT (Entry != NULL);
|
|
|
|
|
|
|
|
Entry->EndAddress = LShiftU64 (1, SizeOfIoSpace) - 1;
|
|
|
|
|
|
|
|
InsertHeadList (&mGcdIoSpaceMap, &Entry->Link);
|
|
|
|
|
2011-01-12 00:11:23 +01:00
|
|
|
CoreDumpGcdIoSpaceMap (TRUE);
|
2011-01-06 03:51:08 +01:00
|
|
|
|
2007-07-04 12:51:54 +02:00
|
|
|
//
|
2008-07-24 04:54:45 +02:00
|
|
|
// Walk the HOB list and add all resource descriptors to the GCD
|
2007-07-04 12:51:54 +02:00
|
|
|
//
|
|
|
|
for (Hob.Raw = *HobStart; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {
|
|
|
|
|
|
|
|
GcdMemoryType = EfiGcdMemoryTypeNonExistent;
|
|
|
|
GcdIoType = EfiGcdIoTypeNonExistent;
|
|
|
|
|
|
|
|
if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {
|
|
|
|
|
|
|
|
ResourceHob = Hob.ResourceDescriptor;
|
|
|
|
|
|
|
|
switch (ResourceHob->ResourceType) {
|
|
|
|
case EFI_RESOURCE_SYSTEM_MEMORY:
|
|
|
|
if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) == TESTED_MEMORY_ATTRIBUTES) {
|
|
|
|
GcdMemoryType = EfiGcdMemoryTypeSystemMemory;
|
|
|
|
}
|
|
|
|
if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) == INITIALIZED_MEMORY_ATTRIBUTES) {
|
|
|
|
GcdMemoryType = EfiGcdMemoryTypeReserved;
|
|
|
|
}
|
|
|
|
if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) == PRESENT_MEMORY_ATTRIBUTES) {
|
|
|
|
GcdMemoryType = EfiGcdMemoryTypeReserved;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EFI_RESOURCE_MEMORY_MAPPED_IO:
|
|
|
|
case EFI_RESOURCE_FIRMWARE_DEVICE:
|
|
|
|
GcdMemoryType = EfiGcdMemoryTypeMemoryMappedIo;
|
|
|
|
break;
|
|
|
|
case EFI_RESOURCE_MEMORY_MAPPED_IO_PORT:
|
|
|
|
case EFI_RESOURCE_MEMORY_RESERVED:
|
|
|
|
GcdMemoryType = EfiGcdMemoryTypeReserved;
|
|
|
|
break;
|
|
|
|
case EFI_RESOURCE_IO:
|
|
|
|
GcdIoType = EfiGcdIoTypeIo;
|
|
|
|
break;
|
|
|
|
case EFI_RESOURCE_IO_RESERVED:
|
|
|
|
GcdIoType = EfiGcdIoTypeReserved;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GcdMemoryType != EfiGcdMemoryTypeNonExistent) {
|
|
|
|
//
|
|
|
|
// Convert the Resource HOB Attributes to an EFI Memory Capabilities mask
|
|
|
|
//
|
|
|
|
Capabilities = CoreConvertResourceDescriptorHobAttributesToCapabilities (
|
|
|
|
GcdMemoryType,
|
|
|
|
ResourceHob->ResourceAttribute
|
|
|
|
);
|
|
|
|
|
|
|
|
Status = CoreInternalAddMemorySpace (
|
|
|
|
GcdMemoryType,
|
|
|
|
ResourceHob->PhysicalStart,
|
|
|
|
ResourceHob->ResourceLength,
|
|
|
|
Capabilities
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GcdIoType != EfiGcdIoTypeNonExistent) {
|
|
|
|
Status = CoreAddIoSpace (
|
|
|
|
GcdIoType,
|
|
|
|
ResourceHob->PhysicalStart,
|
|
|
|
ResourceHob->ResourceLength
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Allocate first memory region from the GCD by the DXE core
|
|
|
|
//
|
|
|
|
Status = CoreAllocateMemorySpace (
|
|
|
|
EfiGcdAllocateAddress,
|
|
|
|
EfiGcdMemoryTypeSystemMemory,
|
|
|
|
0,
|
|
|
|
MemoryLength,
|
|
|
|
&MemoryBaseAddress,
|
|
|
|
gDxeCoreImageHandle,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Walk the HOB list and allocate all memory space that is consumed by memory allocation HOBs,
|
|
|
|
// and Firmware Volume HOBs. Also update the EFI Memory Map with the memory allocation HOBs.
|
|
|
|
//
|
|
|
|
for (Hob.Raw = *HobStart; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {
|
|
|
|
if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_MEMORY_ALLOCATION) {
|
|
|
|
MemoryHob = Hob.MemoryAllocation;
|
|
|
|
BaseAddress = MemoryHob->AllocDescriptor.MemoryBaseAddress;
|
2007-11-08 04:52:35 +01:00
|
|
|
Status = CoreGetMemorySpaceDescriptor (BaseAddress, &Descriptor);
|
2007-07-04 12:51:54 +02:00
|
|
|
if (!EFI_ERROR (Status)) {
|
2007-11-08 04:52:35 +01:00
|
|
|
Status = CoreAllocateMemorySpace (
|
|
|
|
EfiGcdAllocateAddress,
|
2008-07-24 04:54:45 +02:00
|
|
|
Descriptor.GcdMemoryType,
|
2007-11-08 04:52:35 +01:00
|
|
|
0,
|
|
|
|
MemoryHob->AllocDescriptor.MemoryLength,
|
|
|
|
&BaseAddress,
|
|
|
|
gDxeCoreImageHandle,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
if (!EFI_ERROR (Status) && Descriptor.GcdMemoryType == EfiGcdMemoryTypeSystemMemory) {
|
2007-07-04 12:51:54 +02:00
|
|
|
CoreAddMemoryDescriptor (
|
|
|
|
MemoryHob->AllocDescriptor.MemoryType,
|
|
|
|
MemoryHob->AllocDescriptor.MemoryBaseAddress,
|
|
|
|
RShiftU64 (MemoryHob->AllocDescriptor.MemoryLength, EFI_PAGE_SHIFT),
|
|
|
|
Descriptor.Capabilities & (~EFI_MEMORY_RUNTIME)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_FV) {
|
|
|
|
FirmwareVolumeHob = Hob.FirmwareVolume;
|
|
|
|
BaseAddress = FirmwareVolumeHob->BaseAddress;
|
|
|
|
Status = CoreAllocateMemorySpace (
|
|
|
|
EfiGcdAllocateAddress,
|
2008-07-24 04:54:45 +02:00
|
|
|
EfiGcdMemoryTypeMemoryMappedIo,
|
2007-07-04 12:51:54 +02:00
|
|
|
0,
|
|
|
|
FirmwareVolumeHob->Length,
|
|
|
|
&BaseAddress,
|
|
|
|
gDxeCoreImageHandle,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Relocate HOB List to an allocated pool buffer.
|
|
|
|
//
|
2008-08-27 16:29:23 +02:00
|
|
|
NewHobList = AllocateCopyPool (
|
2008-07-24 04:54:45 +02:00
|
|
|
(UINTN)PhitHob->EfiFreeMemoryBottom - (UINTN)(*HobStart),
|
2007-07-04 12:51:54 +02:00
|
|
|
*HobStart
|
|
|
|
);
|
|
|
|
ASSERT (NewHobList != NULL);
|
|
|
|
|
|
|
|
*HobStart = NewHobList;
|
2007-08-03 07:39:46 +02:00
|
|
|
gHobList = NewHobList;
|
2007-07-04 12:51:54 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Add and allocate the remaining unallocated system memory to the memory services.
|
|
|
|
//
|
|
|
|
Status = CoreGetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap);
|
2009-02-06 04:58:04 +01:00
|
|
|
ASSERT (Status == EFI_SUCCESS);
|
|
|
|
|
2007-07-04 12:51:54 +02:00
|
|
|
for (Index = 0; Index < NumberOfDescriptors; Index++) {
|
|
|
|
if (MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeSystemMemory) {
|
|
|
|
if (MemorySpaceMap[Index].ImageHandle == NULL) {
|
|
|
|
BaseAddress = PageAlignAddress (MemorySpaceMap[Index].BaseAddress);
|
|
|
|
Length = PageAlignLength (MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length - BaseAddress);
|
2008-03-04 12:33:13 +01:00
|
|
|
if (Length == 0 || MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length < BaseAddress) {
|
|
|
|
continue;
|
|
|
|
}
|
2007-07-04 12:51:54 +02:00
|
|
|
CoreAddMemoryDescriptor (
|
|
|
|
EfiConventionalMemory,
|
|
|
|
BaseAddress,
|
|
|
|
RShiftU64 (Length, EFI_PAGE_SHIFT),
|
|
|
|
MemorySpaceMap[Index].Capabilities & (~EFI_MEMORY_RUNTIME)
|
|
|
|
);
|
|
|
|
Status = CoreAllocateMemorySpace (
|
|
|
|
EfiGcdAllocateAddress,
|
|
|
|
EfiGcdMemoryTypeSystemMemory,
|
|
|
|
0,
|
|
|
|
Length,
|
|
|
|
&BaseAddress,
|
|
|
|
gDxeCoreImageHandle,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CoreFreePool (MemorySpaceMap);
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|