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