Skip to content

Commit

Permalink
Should all be there?
Browse files Browse the repository at this point in the history
  • Loading branch information
kuqin12 committed Jan 22, 2025
1 parent 7c9458e commit bfff3f6
Show file tree
Hide file tree
Showing 9 changed files with 242 additions and 0 deletions.
26 changes: 26 additions & 0 deletions MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,32 @@ BuildResourceDescriptorWithOwnerHob (
ASSERT (FALSE);
}

/**
Builds a HOB that describes a chunk of system memory with memory attributes.
This function builds a HOB that describes a chunk of system memory.
If there is no additional space for HOB creation, then ASSERT().
@param ResourceType The type of resource described by this HOB.
@param ResourceAttribute The resource attributes of the memory described by this HOB.
@param PhysicalStart The 64 bit physical address of memory described by this HOB.
@param NumberOfBytes The length of the memory described by this HOB in bytes.
@param Attributes The memory attribute for the memory described by this HOB.
**/
VOID
EFIAPI
BuildResourceDescriptorWithCacheHob (
IN EFI_RESOURCE_TYPE ResourceType,
IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,
IN EFI_PHYSICAL_ADDRESS PhysicalStart,
IN UINT64 NumberOfBytes,
IN UINT64 Attributes
)
{
ASSERT (FALSE);
}

/**
Builds a HOB that describes a chunk of system memory.
Expand Down
26 changes: 26 additions & 0 deletions MdePkg/Include/Library/HobLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,32 @@ BuildResourceDescriptorWithOwnerHob (
IN EFI_GUID *OwnerGUID
);

/**
Builds a HOB that describes a chunk of system memory with memory attributes.
This function builds a HOB that describes a chunk of system memory.
It can only be invoked during PEI phase;
for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
If there is no additional space for HOB creation, then ASSERT().
@param ResourceType The type of resource described by this HOB.
@param ResourceAttribute The resource attributes of the memory described by this HOB.
@param PhysicalStart The 64 bit physical address of memory described by this HOB.
@param NumberOfBytes The length of the memory described by this HOB in bytes.
@param Attributes The memory attribute for the memory described by this HOB.
**/
VOID
EFIAPI
BuildResourceDescriptorWithCacheHob (
IN EFI_RESOURCE_TYPE ResourceType,
IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,
IN EFI_PHYSICAL_ADDRESS PhysicalStart,
IN UINT64 NumberOfBytes,
IN UINT64 Attributes
);

/**
Builds a HOB that describes a chunk of system memory.
Expand Down
17 changes: 17 additions & 0 deletions MdePkg/Include/Pi/PiHob.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define EFI_HOB_TYPE_LOAD_PEIM_UNUSED 0x000A
#define EFI_HOB_TYPE_UEFI_CAPSULE 0x000B
#define EFI_HOB_TYPE_FV3 0x000C
#define EFI_HOB_TYPE_RESOURCE_DESCRIPTOR2 0x000D
#define EFI_HOB_TYPE_UNUSED 0xFFFE
#define EFI_HOB_TYPE_END_OF_HOB_LIST 0xFFFF

Expand Down Expand Up @@ -332,6 +333,22 @@ typedef struct {
UINT64 ResourceLength;
} EFI_HOB_RESOURCE_DESCRIPTOR;

///
/// Describes the resource properties of all fixed,
/// nonrelocatable resource ranges found on the processor
/// host bus during the HOB producer phase.
///
typedef struct {
///
/// The HOB generic header. Header.HobType = EFI_HOB_TYPE_RESOURCE_DESCRIPTOR.
///
EFI_HOB_RESOURCE_DESCRIPTOR V1;
///
/// The memory attributes (paging and caching) of the resource region.
///
UINT64 Attributes;
} EFI_HOB_RESOURCE_DESCRIPTOR_V2;

///
/// Allows writers of executable content in the HOB producer phase to
/// maintain and manage HOBs with specific GUID.
Expand Down
26 changes: 26 additions & 0 deletions MdePkg/Library/DxeCoreHobLib/HobLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,32 @@ BuildResourceDescriptorWithOwnerHob (
ASSERT (FALSE);
}

/**
Builds a HOB that describes a chunk of system memory with memory attributes.
This function builds a HOB that describes a chunk of system memory.
If there is no additional space for HOB creation, then ASSERT().
@param ResourceType The type of resource described by this HOB.
@param ResourceAttribute The resource attributes of the memory described by this HOB.
@param PhysicalStart The 64 bit physical address of memory described by this HOB.
@param NumberOfBytes The length of the memory described by this HOB in bytes.
@param Attributes The memory attribute for the memory described by this HOB.
**/
VOID
EFIAPI
BuildResourceDescriptorWithCacheHob (
IN EFI_RESOURCE_TYPE ResourceType,
IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,
IN EFI_PHYSICAL_ADDRESS PhysicalStart,
IN UINT64 NumberOfBytes,
IN UINT64 Attributes
)
{
ASSERT (FALSE);
}

/**
Builds a HOB that describes a chunk of system memory.
Expand Down
26 changes: 26 additions & 0 deletions MdePkg/Library/DxeHobLib/HobLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,32 @@ BuildResourceDescriptorWithOwnerHob (
ASSERT (FALSE);
}

/**
Builds a HOB that describes a chunk of system memory with memory attributes.
This function builds a HOB that describes a chunk of system memory.
If there is no additional space for HOB creation, then ASSERT().
@param ResourceType The type of resource described by this HOB.
@param ResourceAttribute The resource attributes of the memory described by this HOB.
@param PhysicalStart The 64 bit physical address of memory described by this HOB.
@param NumberOfBytes The length of the memory described by this HOB in bytes.
@param Attributes The memory attribute for the memory described by this HOB.
**/
VOID
EFIAPI
BuildResourceDescriptorWithCacheHob (
IN EFI_RESOURCE_TYPE ResourceType,
IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,
IN EFI_PHYSICAL_ADDRESS PhysicalStart,
IN UINT64 NumberOfBytes,
IN UINT64 Attributes
)
{
ASSERT (FALSE);
}

/**
Builds a HOB that describes a chunk of system memory.
Expand Down
43 changes: 43 additions & 0 deletions MdePkg/Library/PeiHobLib/HobLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#include <PiPei.h>
#include <Uefi/UefiSpec.h>

#include <Guid/MemoryAllocationHob.h>

Expand Down Expand Up @@ -342,6 +343,48 @@ BuildResourceDescriptorWithOwnerHob (
CopyGuid (&Hob->Owner, OwnerGUID);
}

/**
Builds a HOB that describes a chunk of system memory with memory attributes.
This function builds a HOB that describes a chunk of system memory.
It can only be invoked during PEI phase;
for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
If there is no additional space for HOB creation, then ASSERT().
@param ResourceType The type of resource described by this HOB.
@param ResourceAttribute The resource attributes of the memory described by this HOB.
@param PhysicalStart The 64 bit physical address of memory described by this HOB.
@param NumberOfBytes The length of the memory described by this HOB in bytes.
@param Attributes The memory attribute for the memory described by this HOB.
**/
VOID
EFIAPI
BuildResourceDescriptorWithCacheHob (
IN EFI_RESOURCE_TYPE ResourceType,
IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,
IN EFI_PHYSICAL_ADDRESS PhysicalStart,
IN UINT64 NumberOfBytes,
IN UINT64 Attributes
)
{
EFI_HOB_RESOURCE_DESCRIPTOR_V2 *Hob;

Hob = InternalPeiCreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR2, (UINT16)sizeof (EFI_HOB_RESOURCE_DESCRIPTOR_V2));
if (Hob == NULL) {
return;
}

Hob->V1.ResourceType = ResourceType;
Hob->V1.ResourceAttribute = ResourceAttribute;
Hob->V1.PhysicalStart = PhysicalStart;
Hob->V1.ResourceLength = NumberOfBytes;
Hob->Attributes = Attributes;

ZeroMem (&(Hob->V1.Owner), sizeof (EFI_GUID));
}

/**
Builds a HOB that describes a chunk of system memory.
Expand Down
26 changes: 26 additions & 0 deletions MdePkg/Test/Mock/Library/Stub/StubHobLib/StubHobLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,32 @@ BuildResourceDescriptorWithOwnerHob (
ASSERT (FALSE);
}

/**
Builds a HOB that describes a chunk of system memory with memory attributes.
This function builds a HOB that describes a chunk of system memory.
If there is no additional space for HOB creation, then ASSERT().
@param ResourceType The type of resource described by this HOB.
@param ResourceAttribute The resource attributes of the memory described by this HOB.
@param PhysicalStart The 64 bit physical address of memory described by this HOB.
@param NumberOfBytes The length of the memory described by this HOB in bytes.
@param Attributes The memory attribute for the memory described by this HOB.
**/
VOID
EFIAPI
BuildResourceDescriptorWithCacheHob (
IN EFI_RESOURCE_TYPE ResourceType,
IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,
IN EFI_PHYSICAL_ADDRESS PhysicalStart,
IN UINT64 NumberOfBytes,
IN UINT64 Attributes
)
{
ASSERT (FALSE);
}

/**
Builds a HOB that describes a chunk of system memory.
Expand Down
26 changes: 26 additions & 0 deletions StandaloneMmPkg/Library/StandaloneMmCoreHobLib/Common.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,32 @@ BuildResourceDescriptorWithOwnerHob (
ASSERT (FALSE);
}

/**
Builds a HOB that describes a chunk of system memory with memory attributes.
This function builds a HOB that describes a chunk of system memory.
If there is no additional space for HOB creation, then ASSERT().
@param ResourceType The type of resource described by this HOB.
@param ResourceAttribute The resource attributes of the memory described by this HOB.
@param PhysicalStart The 64 bit physical address of memory described by this HOB.
@param NumberOfBytes The length of the memory described by this HOB in bytes.
@param Attributes The memory attribute for the memory described by this HOB.
**/
VOID
EFIAPI
BuildResourceDescriptorWithCacheHob (
IN EFI_RESOURCE_TYPE ResourceType,
IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,
IN EFI_PHYSICAL_ADDRESS PhysicalStart,
IN UINT64 NumberOfBytes,
IN UINT64 Attributes
)
{
ASSERT (FALSE);
}

/**
Builds a Capsule Volume HOB.
Expand Down
26 changes: 26 additions & 0 deletions StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,32 @@ BuildResourceDescriptorWithOwnerHob (
ASSERT (FALSE);
}

/**
Builds a HOB that describes a chunk of system memory with memory attributes.
This function builds a HOB that describes a chunk of system memory.
If there is no additional space for HOB creation, then ASSERT().
@param ResourceType The type of resource described by this HOB.
@param ResourceAttribute The resource attributes of the memory described by this HOB.
@param PhysicalStart The 64 bit physical address of memory described by this HOB.
@param NumberOfBytes The length of the memory described by this HOB in bytes.
@param Attributes The memory attribute for the memory described by this HOB.
**/
VOID
EFIAPI
BuildResourceDescriptorWithCacheHob (
IN EFI_RESOURCE_TYPE ResourceType,
IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,
IN EFI_PHYSICAL_ADDRESS PhysicalStart,
IN UINT64 NumberOfBytes,
IN UINT64 Attributes
)
{
ASSERT (FALSE);
}

/**
Builds a Capsule Volume HOB.
Expand Down

0 comments on commit bfff3f6

Please sign in to comment.