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