McfgParser.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /** @file
  2. MCFG table parser
  3. Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. @par Reference(s):
  6. - PCI Firmware Specification - Revision 3.2, January 26, 2015.
  7. **/
  8. #include <IndustryStandard/Acpi.h>
  9. #include <Library/UefiLib.h>
  10. #include "AcpiParser.h"
  11. #include "AcpiTableParser.h"
  12. // Local variables
  13. STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
  14. /**
  15. An ACPI_PARSER array describing the ACPI MCFG Table.
  16. **/
  17. STATIC CONST ACPI_PARSER McfgParser[] = {
  18. PARSE_ACPI_HEADER (&AcpiHdrInfo),
  19. { L"Reserved", 8,36, L"0x%lx", NULL, NULL, NULL, NULL },
  20. };
  21. /**
  22. An ACPI_PARSER array describing the PCI configuration Space Base Address structure.
  23. **/
  24. STATIC CONST ACPI_PARSER PciCfgSpaceBaseAddrParser[] = {
  25. { L"Base Address", 8, 0, L"0x%lx", NULL, NULL, NULL, NULL },
  26. { L"PCI Segment Group No.", 2, 8, L"0x%x", NULL, NULL, NULL, NULL },
  27. { L"Start Bus No.", 1, 10, L"0x%x", NULL, NULL, NULL, NULL },
  28. { L"End Bus No.", 1, 11, L"0x%x", NULL, NULL, NULL, NULL },
  29. { L"Reserved", 4, 12, L"0x%x", NULL, NULL, NULL, NULL }
  30. };
  31. /**
  32. This function parses the ACPI MCFG table.
  33. When trace is enabled this function parses the MCFG table and
  34. traces the ACPI table fields.
  35. This function also performs validation of the ACPI table fields.
  36. @param [in] Trace If TRUE, trace the ACPI fields.
  37. @param [in] Ptr Pointer to the start of the buffer.
  38. @param [in] AcpiTableLength Length of the ACPI table.
  39. @param [in] AcpiTableRevision Revision of the ACPI table.
  40. **/
  41. VOID
  42. EFIAPI
  43. ParseAcpiMcfg (
  44. IN BOOLEAN Trace,
  45. IN UINT8 *Ptr,
  46. IN UINT32 AcpiTableLength,
  47. IN UINT8 AcpiTableRevision
  48. )
  49. {
  50. UINT32 Offset;
  51. UINT32 PciCfgOffset;
  52. UINT8 *PciCfgSpacePtr;
  53. if (!Trace) {
  54. return;
  55. }
  56. Offset = ParseAcpi (
  57. TRUE,
  58. 0,
  59. "MCFG",
  60. Ptr,
  61. AcpiTableLength,
  62. PARSER_PARAMS (McfgParser)
  63. );
  64. PciCfgSpacePtr = Ptr + Offset;
  65. while (Offset < AcpiTableLength) {
  66. PciCfgOffset = ParseAcpi (
  67. TRUE,
  68. 2,
  69. "PCI Configuration Space",
  70. PciCfgSpacePtr,
  71. (AcpiTableLength - Offset),
  72. PARSER_PARAMS (PciCfgSpaceBaseAddrParser)
  73. );
  74. PciCfgSpacePtr += PciCfgOffset;
  75. Offset += PciCfgOffset;
  76. }
  77. }