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
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.
14 - Microsoft Serial Port Console Redirection Table
15 Specification - Version 1.03 - August 10, 2015.
18 #include <IndustryStandard/Acpi.h>
19 #include <IndustryStandard/SerialPortConsoleRedirectionTable.h>
20 #include <Library/UefiLib.h>
21 #include "AcpiParser.h"
22 #include "AcpiTableParser.h"
25 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo
;
27 /** This function validates the Interrupt Type.
29 @param [in] Ptr Pointer to the start of the field data.
30 @param [in] Context Pointer to context specific information e.g. this
31 could be a pointer to the ACPI table header.
36 ValidateInterruptType (
41 /** This function validates the Irq.
43 @param [in] Ptr Pointer to the start of the field data.
44 @param [in] Context Pointer to context specific information e.g. this
45 could be a pointer to the ACPI table header.
55 /** An ACPI_PARSER array describing the ACPI SPCR Table.
57 STATIC CONST ACPI_PARSER SpcrParser
[] = {
58 PARSE_ACPI_HEADER (&AcpiHdrInfo
),
59 {L
"Interface Type", 1, 36, L
"%d", NULL
, NULL
, NULL
, NULL
},
60 {L
"Reserved", 3, 37, L
"%x %x %x", Dump3Chars
, NULL
, NULL
, NULL
},
61 {L
"Base Address", 12, 40, NULL
, DumpGas
, NULL
, NULL
, NULL
},
62 {L
"Interrupt Type", 1, 52, L
"%d", NULL
, NULL
, ValidateInterruptType
, NULL
},
63 {L
"IRQ", 1, 53, L
"%d", NULL
, NULL
, ValidateIrq
, NULL
},
64 {L
"Global System Interrupt", 4, 54, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
65 {L
"Baud Rate", 1, 58, L
"%d", NULL
, NULL
, NULL
, NULL
},
66 {L
"Parity", 1, 59, L
"%d", NULL
, NULL
, NULL
, NULL
},
67 {L
"Stop Bits", 1, 60, L
"%d", NULL
, NULL
, NULL
, NULL
},
68 {L
"Flow Control", 1, 61, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
69 {L
"Terminal Type", 1, 62, L
"%d", NULL
, NULL
, NULL
, NULL
},
70 {L
"Reserved", 1, 63, L
"%x", NULL
, NULL
, NULL
, NULL
},
72 {L
"PCI Device ID", 2, 64, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
73 {L
"PCI Vendor ID", 2, 66, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
74 {L
"PCI Bus Number", 1, 68, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
75 {L
"PCI Device Number", 1, 69, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
76 {L
"PCI Function Number", 1, 70, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
77 {L
"PCI Flags", 4, 71, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
78 {L
"PCI Segment", 1, 75, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
79 {L
"Reserved", 4, 76, L
"%x", NULL
, NULL
, NULL
, NULL
}
82 /** This function validates the Interrupt Type.
84 @param [in] Ptr Pointer to the start of the field data.
85 @param [in] Context Pointer to context specific information e.g. this
86 could be a pointer to the ACPI table header.
91 ValidateInterruptType (
96 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
97 UINT8 InterruptType
= *Ptr
;
99 EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERRUPT_TYPE_GIC
) {
100 IncrementErrorCount ();
102 L
"\nERROR: InterruptType = %d. This must be 8 on ARM Platforms",
109 /** This function validates the Irq.
111 @param [in] Ptr Pointer to the start of the field data.
112 @param [in] Context Pointer to context specific information e.g. this
113 could be a pointer to the ACPI table header.
123 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
126 IncrementErrorCount ();
128 L
"\nERROR: Irq = %d. This must be zero on ARM Platforms\n",
135 /** This function parses the ACPI SPCR table.
136 When trace is enabled this function parses the SPCR table and
137 traces the ACPI table fields.
139 This function also performs validations of the ACPI table fields.
141 @param [in] Trace If TRUE, trace the ACPI fields.
142 @param [in] Ptr Pointer to the start of the buffer.
143 @param [in] AcpiTableLength Length of the ACPI table.
144 @param [in] AcpiTableRevision Revision of the ACPI table.
151 IN UINT32 AcpiTableLength
,
152 IN UINT8 AcpiTableRevision
166 PARSER_PARAMS (SpcrParser
)