99 Bdf = (UINT16)DeviceHandlePci->BusNumber << 8;
100 Bdf |= (DeviceHandlePci->DeviceNumber & 0x1F) << 3;
101 Bdf |= DeviceHandlePci->FunctionNumber & 0x7;
124 IN UINT32 MemAffCount
129 ASSERT (Srat !=
NULL);
130 ASSERT (MemAffInfo !=
NULL);
135 while (MemAffCount-- != 0) {
136 DEBUG ((DEBUG_INFO,
"SRAT: MemAff = 0x%p\n", MemAff));
138 MemAff->Type = EFI_ACPI_6_3_MEMORY_AFFINITY;
140 MemAff->ProximityDomain = MemAffInfo->ProximityDomain;
141 MemAff->Reserved1 = EFI_ACPI_RESERVED_WORD;
142 MemAff->AddressBaseLow = (UINT32)(MemAffInfo->BaseAddress & MAX_UINT32);
143 MemAff->AddressBaseHigh = (UINT32)(MemAffInfo->BaseAddress >> 32);
144 MemAff->LengthLow = (UINT32)(MemAffInfo->Length & MAX_UINT32);
145 MemAff->LengthHigh = (UINT32)(MemAffInfo->Length >> 32);
146 MemAff->Reserved2 = EFI_ACPI_RESERVED_DWORD;
147 MemAff->Flags = MemAffInfo->Flags;
148 MemAff->Reserved3 = EFI_ACPI_RESERVED_QWORD;
184 IN UINT32 GenInitAffCount
191 UINT32 DeviceHandleCount;
193 ASSERT (Srat !=
NULL);
194 ASSERT (GenInitAffInfo !=
NULL);
197 (UINT8 *)Srat + GenInitAffOff);
199 while (GenInitAffCount-- != 0) {
200 DEBUG ((DEBUG_INFO,
"SRAT: GenInitAff = 0x%p\n", GenInitAff));
202 GenInitAff->Type = EFI_ACPI_6_3_GENERIC_INITIATOR_AFFINITY;
205 GenInitAff->Reserved1 = EFI_ACPI_RESERVED_WORD;
206 GenInitAff->DeviceHandleType = GenInitAffInfo->DeviceHandleType;
207 GenInitAff->ProximityDomain = GenInitAffInfo->ProximityDomain;
212 "ERROR: SRAT: Invalid Device Handle Token.\n"
215 return EFI_INVALID_PARAMETER;
218 if (GenInitAffInfo->DeviceHandleType == EFI_ACPI_6_3_ACPI_DEVICE_HANDLE) {
219 Status = GetEArchCommonObjDeviceHandleAcpi (
221 GenInitAffInfo->DeviceHandleToken,
225 if (EFI_ERROR (Status)) {
228 "ERROR: SRAT: Failed to get ACPI Device Handle Inf."
229 " DeviceHandleToken = %p."
231 GenInitAffInfo->DeviceHandleToken,
238 ASSERT (DeviceHandleCount == 1);
241 GenInitAff->DeviceHandle.Acpi.AcpiHid = DeviceHandleAcpi->
Hid;
242 GenInitAff->DeviceHandle.Acpi.AcpiUid = DeviceHandleAcpi->
Uid;
243 GenInitAff->DeviceHandle.Acpi.Reserved[0] = EFI_ACPI_RESERVED_BYTE;
244 GenInitAff->DeviceHandle.Acpi.Reserved[1] = EFI_ACPI_RESERVED_BYTE;
245 GenInitAff->DeviceHandle.Acpi.Reserved[2] = EFI_ACPI_RESERVED_BYTE;
246 GenInitAff->DeviceHandle.Acpi.Reserved[3] = EFI_ACPI_RESERVED_BYTE;
247 }
else if (GenInitAffInfo->DeviceHandleType ==
248 EFI_ACPI_6_3_PCI_DEVICE_HANDLE)
250 Status = GetEArchCommonObjDeviceHandlePci (
252 GenInitAffInfo->DeviceHandleToken,
256 if (EFI_ERROR (Status)) {
259 "ERROR: SRAT: Failed to get ACPI Device Handle Inf."
260 " DeviceHandleToken = %p."
262 GenInitAffInfo->DeviceHandleToken,
269 ASSERT (DeviceHandleCount == 1);
272 GenInitAff->DeviceHandle.Pci.PciSegment = DeviceHandlePci->
SegmentNumber;
273 GenInitAff->DeviceHandle.Pci.PciBdfNumber =
GetBdf (DeviceHandlePci);
275 GenInitAff->DeviceHandle.Pci.Reserved[0] = EFI_ACPI_RESERVED_BYTE;
276 GenInitAff->DeviceHandle.Pci.Reserved[1] = EFI_ACPI_RESERVED_BYTE;
277 GenInitAff->DeviceHandle.Pci.Reserved[2] = EFI_ACPI_RESERVED_BYTE;
278 GenInitAff->DeviceHandle.Pci.Reserved[3] = EFI_ACPI_RESERVED_BYTE;
279 GenInitAff->DeviceHandle.Pci.Reserved[4] = EFI_ACPI_RESERVED_BYTE;
280 GenInitAff->DeviceHandle.Pci.Reserved[5] = EFI_ACPI_RESERVED_BYTE;
281 GenInitAff->DeviceHandle.Pci.Reserved[6] = EFI_ACPI_RESERVED_BYTE;
282 GenInitAff->DeviceHandle.Pci.Reserved[7] = EFI_ACPI_RESERVED_BYTE;
283 GenInitAff->DeviceHandle.Pci.Reserved[8] = EFI_ACPI_RESERVED_BYTE;
284 GenInitAff->DeviceHandle.Pci.Reserved[9] = EFI_ACPI_RESERVED_BYTE;
285 GenInitAff->DeviceHandle.Pci.Reserved[10] = EFI_ACPI_RESERVED_BYTE;
286 GenInitAff->DeviceHandle.Pci.Reserved[11] = EFI_ACPI_RESERVED_BYTE;
290 "ERROR: SRAT: Invalid Device Handle Type.\n"
293 return EFI_INVALID_PARAMETER;
296 GenInitAff->Flags = GenInitAffInfo->Flags;
297 GenInitAff->Reserved2[0] = EFI_ACPI_RESERVED_BYTE;
298 GenInitAff->Reserved2[1] = EFI_ACPI_RESERVED_BYTE;
344 UINT32 GenInitiatorAffCount;
347 UINT32 GenInitiatorAffOffset;
356 (AcpiTableInfo !=
NULL) &&
357 (CfgMgrProtocol !=
NULL) &&
359 (AcpiTableInfo->TableGeneratorId == This->GeneratorID) &&
360 (AcpiTableInfo->AcpiTableSignature == This->AcpiTableSignature)
363 if ((AcpiTableInfo->AcpiTableRevision < This->MinAcpiTableRevision) ||
364 (AcpiTableInfo->AcpiTableRevision > This->AcpiTableRevision))
368 "ERROR: SRAT: Requested table revision = %d is not supported. "
369 "Supported table revisions: Minimum = %d. Maximum = %d\n",
370 AcpiTableInfo->AcpiTableRevision,
371 This->MinAcpiTableRevision,
372 This->AcpiTableRevision
374 return EFI_INVALID_PARAMETER;
379 Status = GetEArchCommonObjMemoryAffinityInfo (
385 if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
388 "ERROR: SRAT: Failed to get Memory Affinity Info. Status = %r\n",
394 Status = GetEArchCommonObjGenericInitiatorAffinityInfo (
397 &GenInitiatorAffInfo,
398 &GenInitiatorAffCount
400 if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
403 "ERROR: SRAT: Failed to get Generic Initiator Affinity Info."
417 if (EFI_ERROR (Status)) {
420 "ERROR: SRAT: Failed to reserve arch offsets."
427 if (MemAffCount != 0) {
428 MemAffOffset = TableSize;
433 if (GenInitiatorAffCount != 0) {
434 GenInitiatorAffOffset = TableSize;
436 GenInitiatorAffCount);
441 if (*Table ==
NULL) {
442 Status = EFI_OUT_OF_RESOURCES;
445 "ERROR: SRAT: Failed to allocate memory for SRAT Table, Size = %d," \
457 "SRAT: Srat = 0x%p TableSize = 0x%x\n",
469 if (EFI_ERROR (Status)) {
472 "ERROR: SRAT: Failed to add ACPI header. Status = %r\n",
481 Srat->Reserved2 = EFI_ACPI_RESERVED_QWORD;
484 if (EFI_ERROR (Status)) {
487 "ERROR: SRAT: Failed to add arch objects header. Status = %r\n",
493 if (MemAffCount != 0) {
501 if (EFI_ERROR (Status)) {
504 "ERROR: SRAT: Failed to add Memory Affinity structures. Status = %r\n",
511 if (GenInitiatorAffCount != 0) {
515 GenInitiatorAffOffset,
519 if (EFI_ERROR (Status)) {
522 "ERROR: SRAT: Failed to add Generic Initiator Affinity structures."
534 if (*Table !=
NULL) {
565 (AcpiTableInfo !=
NULL) &&
566 (CfgMgrProtocol !=
NULL) &&
567 (AcpiTableInfo->TableGeneratorId == This->GeneratorID) &&
568 (AcpiTableInfo->AcpiTableSignature == This->AcpiTableSignature)
571 if ((Table ==
NULL) || (*Table ==
NULL)) {
572 DEBUG ((DEBUG_ERROR,
"ERROR: SRAT: Invalid Table Pointer\n"));
574 return EFI_INVALID_PARAMETER;
584#define SRAT_GENERATOR_REVISION CREATE_REVISION (1, 0)
594 L
"ACPI.STD.SRAT.GENERATOR",
636 DEBUG ((DEBUG_INFO,
"SRAT: Register Generator. Status = %r\n", Status));
660 DEBUG ((DEBUG_INFO,
"SRAT: Deregister Generator. Status = %r\n", Status));
#define EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_REVISION
#define EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_SIGNATURE
EFI_STATUS EFIAPI RegisterAcpiTableGenerator(IN CONST ACPI_TABLE_GENERATOR *CONST Generator)
EFI_STATUS EFIAPI DeregisterAcpiTableGenerator(IN CONST ACPI_TABLE_GENERATOR *CONST Generator)
#define CREATE_STD_ACPI_TABLE_GEN_ID(TableId)
#define TABLE_GENERATOR_CREATOR_ID
@ EStdAcpiTableIdSrat
SRAT Generator.
@ EArchCommonObjGenericInitiatorAffinityInfo
14 - Generic Initiator Affinity
@ EArchCommonObjDeviceHandleAcpi
12 - Device Handle Acpi
@ EArchCommonObjDeviceHandlePci
13 - Device Handle Pci
@ EArchCommonObjMemoryAffinityInfo
11 - Memory Affinity Info
EFI_STATUS EFIAPI AddArchObjects(IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER *CONST Srat)
EFI_STATUS EFIAPI ArchReserveOffsets(IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN OUT UINT32 *ArchOffset)
#define GET_OBJECT_LIST(CmObjectNameSpace, CmObjectId, Type)
@ EObjNameSpaceArchCommon
Arch Common Objects Namespace.
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define SRAT_GENERATOR_REVISION
STATIC EFI_STATUS AddGenericInitiatorAffinity(IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER *CONST Srat, IN CONST UINT32 GenInitAffOff, IN CONST CM_ARCH_COMMON_GENERIC_INITIATOR_AFFINITY_INFO *GenInitAffInfo, IN UINT32 GenInitAffCount)
STATIC EFI_STATUS EFIAPI BuildSratTable(IN CONST ACPI_TABLE_GENERATOR *CONST This, IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST AcpiTableInfo, IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, OUT EFI_ACPI_DESCRIPTION_HEADER **CONST Table)
EFI_STATUS EFIAPI AcpiSratLibDestructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS EFIAPI AcpiSratLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
STATIC CONST ACPI_TABLE_GENERATOR SratGenerator
STATIC EFI_STATUS EFIAPI FreeSratTableResources(IN CONST ACPI_TABLE_GENERATOR *CONST This, IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST AcpiTableInfo, IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN OUT EFI_ACPI_DESCRIPTION_HEADER **CONST Table)
STATIC EFI_STATUS AddMemoryAffinity(IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER *CONST Srat, IN CONST UINT32 MemAffOffset, IN CONST CM_ARCH_COMMON_MEMORY_AFFINITY_INFO *MemAffInfo, IN UINT32 MemAffCount)
STATIC UINT16 GetBdf(IN CONST CM_ARCH_COMMON_DEVICE_HANDLE_PCI *DeviceHandlePci)
EFI_STATUS EFIAPI AddAcpiHeader(IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN CONST ACPI_TABLE_GENERATOR *CONST Generator, IN OUT EFI_ACPI_DESCRIPTION_HEADER *CONST AcpiHeader, IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST AcpiTableInfo, IN CONST UINT32 Length)
UINT16 SegmentNumber
PCI Segment Number.
UINT32 Reserved1
Must be set to 1.