]>
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 | |
5 | This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | @par Reference(s):\r | |
14 | - PCI Firmware Specification - Revision 3.2, January 26, 2015.\r | |
15 | **/\r | |
16 | \r | |
17 | #include <IndustryStandard/Acpi.h>\r | |
18 | #include <Library/UefiLib.h>\r | |
19 | #include "AcpiParser.h"\r | |
20 | #include "AcpiTableParser.h"\r | |
21 | \r | |
22 | // Local variables\r | |
23 | STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;\r | |
24 | \r | |
a6eaba4d DB |
25 | /**\r |
26 | An ACPI_PARSER array describing the ACPI MCFG Table.\r | |
27 | **/\r | |
ee4dc24f RN |
28 | STATIC CONST ACPI_PARSER McfgParser[] = {\r |
29 | PARSE_ACPI_HEADER (&AcpiHdrInfo),\r | |
30 | {L"Reserved", 8, 36, L"0x%lx", NULL, NULL, NULL, NULL},\r | |
31 | };\r | |
32 | \r | |
a6eaba4d DB |
33 | /**\r |
34 | An ACPI_PARSER array describing the PCI configuration Space Base Address structure.\r | |
35 | **/\r | |
ee4dc24f RN |
36 | STATIC CONST ACPI_PARSER PciCfgSpaceBaseAddrParser[] = {\r |
37 | {L"Base Address", 8, 0, L"0x%lx", NULL, NULL, NULL, NULL},\r | |
38 | {L"PCI Segment Group No.", 2, 8, L"0x%x", NULL, NULL, NULL, NULL},\r | |
39 | {L"Start Bus No.", 1, 10, L"0x%x", NULL, NULL, NULL, NULL},\r | |
40 | {L"End Bus No.", 1, 11, L"0x%x", NULL, NULL, NULL, NULL},\r | |
41 | {L"Reserved", 4, 12, L"0x%x", NULL, NULL, NULL, NULL}\r | |
42 | };\r | |
43 | \r | |
a6eaba4d DB |
44 | /**\r |
45 | This function parses the ACPI MCFG table.\r | |
ee4dc24f RN |
46 | When trace is enabled this function parses the MCFG table and\r |
47 | traces the ACPI table fields.\r | |
48 | \r | |
49 | This function also performs validation of the ACPI table fields.\r | |
50 | \r | |
51 | @param [in] Trace If TRUE, trace the ACPI fields.\r | |
52 | @param [in] Ptr Pointer to the start of the buffer.\r | |
53 | @param [in] AcpiTableLength Length of the ACPI table.\r | |
54 | @param [in] AcpiTableRevision Revision of the ACPI table.\r | |
a6eaba4d | 55 | **/\r |
ee4dc24f RN |
56 | VOID\r |
57 | EFIAPI\r | |
58 | ParseAcpiMcfg (\r | |
59 | IN BOOLEAN Trace,\r | |
60 | IN UINT8* Ptr,\r | |
61 | IN UINT32 AcpiTableLength,\r | |
62 | IN UINT8 AcpiTableRevision\r | |
63 | )\r | |
64 | {\r | |
65 | UINT32 Offset;\r | |
66 | UINT32 PciCfgOffset;\r | |
67 | UINT8* PciCfgSpacePtr;\r | |
68 | \r | |
69 | if (!Trace) {\r | |
70 | return;\r | |
71 | }\r | |
72 | \r | |
73 | Offset = ParseAcpi (\r | |
74 | TRUE,\r | |
75 | 0,\r | |
76 | "MCFG",\r | |
77 | Ptr,\r | |
78 | AcpiTableLength,\r | |
79 | PARSER_PARAMS (McfgParser)\r | |
80 | );\r | |
81 | \r | |
82 | PciCfgSpacePtr = Ptr + Offset;\r | |
83 | \r | |
84 | while (Offset < AcpiTableLength) {\r | |
85 | PciCfgOffset = ParseAcpi (\r | |
86 | TRUE,\r | |
87 | 2,\r | |
88 | "PCI Configuration Space",\r | |
89 | PciCfgSpacePtr,\r | |
90 | (AcpiTableLength - Offset),\r | |
91 | PARSER_PARAMS (PciCfgSpaceBaseAddrParser)\r | |
92 | );\r | |
93 | PciCfgSpacePtr += PciCfgOffset;\r | |
94 | Offset += PciCfgOffset;\r | |
95 | }\r | |
96 | }\r |