]> git.proxmox.com Git - mirror_edk2.git/blob - ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Spcr/SpcrParser.c
ShellPkg: acpiview: SPCR: Remove redundant forward declaration
[mirror_edk2.git] / ShellPkg / Library / UefiShellAcpiViewCommandLib / Parsers / Spcr / SpcrParser.c
1 /** @file
2 SPCR 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 - Microsoft Serial Port Console Redirection Table
9 Specification - Version 1.03 - August 10, 2015.
10 **/
11
12 #include <IndustryStandard/Acpi.h>
13 #include <IndustryStandard/SerialPortConsoleRedirectionTable.h>
14 #include <Library/UefiLib.h>
15 #include "AcpiParser.h"
16 #include "AcpiTableParser.h"
17
18 // Local variables
19 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
20
21 /**
22 This function validates the Interrupt Type.
23
24 @param [in] Ptr Pointer to the start of the field data.
25 @param [in] Context Pointer to context specific information e.g. this
26 could be a pointer to the ACPI table header.
27 **/
28 STATIC
29 VOID
30 EFIAPI
31 ValidateInterruptType (
32 IN UINT8* Ptr,
33 IN VOID* Context
34 )
35 {
36 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
37 UINT8 InterruptType;
38
39 InterruptType = *Ptr;
40
41 if (InterruptType !=
42 EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERRUPT_TYPE_GIC) {
43 IncrementErrorCount ();
44 Print (
45 L"\nERROR: InterruptType = %d. This must be 8 on ARM Platforms",
46 InterruptType
47 );
48 }
49 #endif
50 }
51
52 /**
53 This function validates the Irq.
54
55 @param [in] Ptr Pointer to the start of the field data.
56 @param [in] Context Pointer to context specific information e.g. this
57 could be a pointer to the ACPI table header.
58 **/
59 STATIC
60 VOID
61 EFIAPI
62 ValidateIrq (
63 IN UINT8* Ptr,
64 IN VOID* Context
65 )
66 {
67 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
68 UINT8 Irq;
69
70 Irq = *Ptr;
71
72 if (Irq != 0) {
73 IncrementErrorCount ();
74 Print (
75 L"\nERROR: Irq = %d. This must be zero on ARM Platforms\n",
76 Irq
77 );
78 }
79 #endif
80 }
81
82 /**
83 An ACPI_PARSER array describing the ACPI SPCR Table.
84 **/
85 STATIC CONST ACPI_PARSER SpcrParser[] = {
86 PARSE_ACPI_HEADER (&AcpiHdrInfo),
87 {L"Interface Type", 1, 36, L"%d", NULL, NULL, NULL, NULL},
88 {L"Reserved", 3, 37, L"%x %x %x", Dump3Chars, NULL, NULL, NULL},
89 {L"Base Address", 12, 40, NULL, DumpGas, NULL, NULL, NULL},
90 {L"Interrupt Type", 1, 52, L"%d", NULL, NULL, ValidateInterruptType, NULL},
91 {L"IRQ", 1, 53, L"%d", NULL, NULL, ValidateIrq, NULL},
92 {L"Global System Interrupt", 4, 54, L"0x%x", NULL, NULL, NULL, NULL},
93 {L"Baud Rate", 1, 58, L"%d", NULL, NULL, NULL, NULL},
94 {L"Parity", 1, 59, L"%d", NULL, NULL, NULL, NULL},
95 {L"Stop Bits", 1, 60, L"%d", NULL, NULL, NULL, NULL},
96 {L"Flow Control", 1, 61, L"0x%x", NULL, NULL, NULL, NULL},
97 {L"Terminal Type", 1, 62, L"%d", NULL, NULL, NULL, NULL},
98 {L"Reserved", 1, 63, L"%x", NULL, NULL, NULL, NULL},
99
100 {L"PCI Device ID", 2, 64, L"0x%x", NULL, NULL, NULL, NULL},
101 {L"PCI Vendor ID", 2, 66, L"0x%x", NULL, NULL, NULL, NULL},
102 {L"PCI Bus Number", 1, 68, L"0x%x", NULL, NULL, NULL, NULL},
103 {L"PCI Device Number", 1, 69, L"0x%x", NULL, NULL, NULL, NULL},
104 {L"PCI Function Number", 1, 70, L"0x%x", NULL, NULL, NULL, NULL},
105 {L"PCI Flags", 4, 71, L"0x%x", NULL, NULL, NULL, NULL},
106 {L"PCI Segment", 1, 75, L"0x%x", NULL, NULL, NULL, NULL},
107 {L"Reserved", 4, 76, L"%x", NULL, NULL, NULL, NULL}
108 };
109
110 /**
111 This function parses the ACPI SPCR table.
112 When trace is enabled this function parses the SPCR table and
113 traces the ACPI table fields.
114
115 This function also performs validations of the ACPI table fields.
116
117 @param [in] Trace If TRUE, trace the ACPI fields.
118 @param [in] Ptr Pointer to the start of the buffer.
119 @param [in] AcpiTableLength Length of the ACPI table.
120 @param [in] AcpiTableRevision Revision of the ACPI table.
121 **/
122 VOID
123 EFIAPI
124 ParseAcpiSpcr (
125 IN BOOLEAN Trace,
126 IN UINT8* Ptr,
127 IN UINT32 AcpiTableLength,
128 IN UINT8 AcpiTableRevision
129 )
130 {
131 if (!Trace) {
132 return;
133 }
134
135 // Dump the SPCR
136 ParseAcpi (
137 TRUE,
138 0,
139 "SPCR",
140 Ptr,
141 AcpiTableLength,
142 PARSER_PARAMS (SpcrParser)
143 );
144 }