SPDX-License-Identifier: BSD-2-Clause-Patent\r
**/\r
\r
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
#include <IndustryStandard/Acpi10.h>\r
#include <IndustryStandard/Pci22.h>\r
\r
// This structure is interpreted by the UpdatePciInfo() function in the edk2\r
// PCI Bus UEFI_DRIVER.\r
//\r
-#pragma pack (1)\r
-typedef struct {\r
- EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR AddressSpaceDesc;\r
- EFI_ACPI_END_TAG_DESCRIPTOR EndDesc;\r
-} MMIO64_PREFERENCE;\r
-#pragma pack ()\r
-\r
-STATIC CONST MMIO64_PREFERENCE mConfiguration = {\r
- //\r
- // AddressSpaceDesc\r
- //\r
- {\r
- ACPI_ADDRESS_SPACE_DESCRIPTOR, // Desc\r
- (UINT16)( // Len\r
+// This structure looks like:\r
+// AddressDesc-1 + AddressDesc-2 + ... + AddressDesc-n + EndDesc\r
+//\r
+STATIC CONST EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR mMmio64Configuration = {\r
+ ACPI_ADDRESS_SPACE_DESCRIPTOR, // Desc\r
+ (UINT16)( // Len\r
sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) -\r
OFFSET_OF (\r
EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR,\r
ResType\r
)\r
),\r
- ACPI_ADDRESS_SPACE_TYPE_MEM, // ResType\r
- 0, // GenFlag\r
- 0, // SpecificFlag\r
- 64, // AddrSpaceGranularity:\r
+ ACPI_ADDRESS_SPACE_TYPE_MEM, // ResType\r
+ 0, // GenFlag\r
+ 0, // SpecificFlag\r
+ 64, // AddrSpaceGranularity:\r
// aperture selection hint\r
// for BAR allocation\r
- 0, // AddrRangeMin\r
- 0, // AddrRangeMax:\r
+ 0, // AddrRangeMin\r
+ 0, // AddrRangeMax:\r
// no special alignment\r
// for affected BARs\r
- MAX_UINT64, // AddrTranslationOffset:\r
+ MAX_UINT64, // AddrTranslationOffset:\r
// hint covers all\r
// eligible BARs\r
- 0 // AddrLen:\r
+ 0 // AddrLen:\r
// use probed BAR size\r
- },\r
- //\r
- // EndDesc\r
- //\r
- {\r
- ACPI_END_TAG_DESCRIPTOR, // Desc\r
- 0 // Checksum: to be ignored\r
- }\r
+};\r
+\r
+STATIC CONST EFI_ACPI_END_TAG_DESCRIPTOR mEndDesc = {\r
+ ACPI_END_TAG_DESCRIPTOR, // Desc\r
+ 0 // Checksum: to be ignored\r
};\r
\r
//\r
)\r
{\r
mCheckDeviceCalled = TRUE;\r
+ UINTN Length;\r
+ UINT8 *Ptr;\r
\r
//\r
// Unlike the general description of this protocol member suggests, there is\r
// the edk2 PCI Bus UEFI_DRIVER actually handles error codes; see the\r
// UpdatePciInfo() function.\r
//\r
- *Configuration = AllocateCopyPool (sizeof mConfiguration, &mConfiguration);\r
+ Length = sizeof mMmio64Configuration + sizeof mEndDesc;\r
+\r
+ *Configuration = AllocateZeroPool (Length);\r
+\r
if (*Configuration == NULL) {\r
DEBUG ((\r
DEBUG_WARN,\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
+ Ptr = (UINT8 *)(UINTN)*Configuration;\r
+ CopyMem (Ptr, &mMmio64Configuration, sizeof mMmio64Configuration);\r
+ Length = sizeof mMmio64Configuration;\r
+\r
+ CopyMem (Ptr + Length, &mEndDesc, sizeof mEndDesc);\r
+\r
return EFI_SUCCESS;\r
}\r
\r