]> git.proxmox.com Git - mirror_edk2.git/blob - ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / ShellPkg / Library / UefiShellAcpiViewCommandLib / Parsers / Rsdp / RsdpParser.c
1 /** @file
2 RSDP table parser
3
4 Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 @par Reference(s):
8 - ACPI 6.2 Specification - Errata A, September 2017
9 **/
10
11 #include <Library/UefiLib.h>
12 #include "AcpiParser.h"
13 #include "AcpiTableParser.h"
14
15 // Local Variables
16 STATIC CONST UINT64 *XsdtAddress;
17
18 /**
19 This function validates the RSDT Address.
20
21 @param [in] Ptr Pointer to the start of the field data.
22 @param [in] Context Pointer to context specific information e.g. this
23 could be a pointer to the ACPI table header.
24 **/
25 STATIC
26 VOID
27 EFIAPI
28 ValidateRsdtAddress (
29 IN UINT8 *Ptr,
30 IN VOID *Context
31 )
32 {
33 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
34 // Reference: Server Base Boot Requirements System Software on ARM Platforms
35 // Section: 4.2.1.1 RSDP
36 // Root System Description Pointer (RSDP), ACPI ? 5.2.5.
37 // - Within the RSDP, the RsdtAddress field must be null (zero) and the
38 // XsdtAddresss MUST be a valid, non-null, 64-bit value.
39 UINT32 RsdtAddr;
40
41 RsdtAddr = *(UINT32 *)Ptr;
42
43 if (RsdtAddr != 0) {
44 IncrementErrorCount ();
45 Print (
46 L"\nERROR: Rsdt Address = 0x%p. This must be NULL on ARM Platforms.",
47 RsdtAddr
48 );
49 }
50
51 #endif
52 }
53
54 /**
55 This function validates the XSDT Address.
56
57 @param [in] Ptr Pointer to the start of the field data.
58 @param [in] Context Pointer to context specific information e.g. this
59 could be a pointer to the ACPI table header.
60 **/
61 STATIC
62 VOID
63 EFIAPI
64 ValidateXsdtAddress (
65 IN UINT8 *Ptr,
66 IN VOID *Context
67 )
68 {
69 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
70 // Reference: Server Base Boot Requirements System Software on ARM Platforms
71 // Section: 4.2.1.1 RSDP
72 // Root System Description Pointer (RSDP), ACPI ? 5.2.5.
73 // - Within the RSDP, the RsdtAddress field must be null (zero) and the
74 // XsdtAddresss MUST be a valid, non-null, 64-bit value.
75 UINT64 XsdtAddr;
76
77 XsdtAddr = *(UINT64 *)Ptr;
78
79 if (XsdtAddr == 0) {
80 IncrementErrorCount ();
81 Print (
82 L"\nERROR: Xsdt Address = 0x%p. This must not be NULL on ARM Platforms.",
83 XsdtAddr
84 );
85 }
86
87 #endif
88 }
89
90 /**
91 An array describing the ACPI RSDP Table.
92 **/
93 STATIC CONST ACPI_PARSER RsdpParser[] = {
94 { L"Signature", 8, 0, NULL, Dump8Chars, NULL, NULL, NULL },
95 { L"Checksum", 1, 8, L"0x%x", NULL, NULL, NULL, NULL },
96 { L"Oem ID", 6, 9, NULL, Dump6Chars, NULL, NULL, NULL },
97 { L"Revision", 1, 15, L"%d", NULL, NULL, NULL, NULL },
98 { L"RSDT Address", 4, 16, L"0x%x", NULL, NULL, ValidateRsdtAddress, NULL },
99 { L"Length", 4, 20, L"%d", NULL, NULL, NULL, NULL },
100 { L"XSDT Address", 8, 24, L"0x%lx", NULL, (VOID **)&XsdtAddress,
101 ValidateXsdtAddress, NULL },
102 { L"Extended Checksum", 1, 32, L"0x%x", NULL, NULL, NULL, NULL },
103 { L"Reserved", 3, 33, L"%x %x %x", Dump3Chars, NULL, NULL, NULL }
104 };
105
106 /**
107 This function parses the ACPI RSDP table.
108
109 This function invokes the parser for the XSDT table.
110 * Note - This function does not support parsing of RSDT table.
111
112 This function also performs a RAW dump of the ACPI table and
113 validates the checksum.
114
115 @param [in] Trace If TRUE, trace the ACPI fields.
116 @param [in] Ptr Pointer to the start of the buffer.
117 @param [in] AcpiTableLength Length of the ACPI table.
118 @param [in] AcpiTableRevision Revision of the ACPI table.
119 **/
120 VOID
121 EFIAPI
122 ParseAcpiRsdp (
123 IN BOOLEAN Trace,
124 IN UINT8 *Ptr,
125 IN UINT32 AcpiTableLength,
126 IN UINT8 AcpiTableRevision
127 )
128 {
129 if (Trace) {
130 DumpRaw (Ptr, AcpiTableLength);
131 VerifyChecksum (TRUE, Ptr, AcpiTableLength);
132 }
133
134 ParseAcpi (
135 Trace,
136 0,
137 "RSDP",
138 Ptr,
139 AcpiTableLength,
140 PARSER_PARAMS (RsdpParser)
141 );
142
143 // Check if the values used to control the parsing logic have been
144 // successfully read.
145 if (XsdtAddress == NULL) {
146 IncrementErrorCount ();
147 Print (
148 L"ERROR: Insufficient table length. AcpiTableLength = %d." \
149 L"RSDP parsing aborted.\n",
150 AcpiTableLength
151 );
152 return;
153 }
154
155 // This code currently supports parsing of XSDT table only
156 // and does not parse the RSDT table. Platforms provide the
157 // RSDT to enable compatibility with ACPI 1.0 operating systems.
158 // Therefore the RSDT should not be used on ARM platforms.
159 if ((*XsdtAddress) == 0) {
160 IncrementErrorCount ();
161 Print (L"ERROR: XSDT Pointer is not set. RSDP parsing aborted.\n");
162 return;
163 }
164
165 ProcessAcpiTable ((UINT8 *)(UINTN)(*XsdtAddress));
166 }