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