Home | History | Annotate | Download | only in AcpiTables
      1 /** @file
      2 * SPCR Table
      3 *
      4 * Copyright (c) 2014 - 2016, ARM Limited. All rights reserved.
      5 *
      6 * This program and the accompanying materials are licensed and made available
      7 * under the terms and conditions of the BSD License which accompanies this
      8 * distribution.  The full text of the license may be found at
      9 * http://opensource.org/licenses/bsd-license.php
     10 *
     11 * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     12 * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     13 *
     14 **/
     15 
     16 #include "ArmPlatform.h"
     17 #include <Library/AcpiLib.h>
     18 #include <Library/ArmLib.h>
     19 #include <Library/PcdLib.h>
     20 #include <IndustryStandard/Acpi.h>
     21 #include <IndustryStandard/SerialPortConsoleRedirectionTable.h>
     22 
     23 /**
     24  * References:
     25  * Serial Port Console Redirection Table Specification Version 1.03 - August 10, 2015
     26  **/
     27 
     28 
     29 ///
     30 /// SPCR Flow Control
     31 ///
     32 #define SPCR_FLOW_CONTROL_NONE           0
     33 
     34 
     35 STATIC EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE Spcr = {
     36   ARM_ACPI_HEADER (EFI_ACPI_5_1_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE,
     37                      EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE,
     38                      EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_REVISION),
     39   // UINT8                                   InterfaceType;
     40   EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERFACE_TYPE_ARM_PL011_UART,
     41   // UINT8                                   Reserved1[3];
     42   {
     43     EFI_ACPI_RESERVED_BYTE,
     44     EFI_ACPI_RESERVED_BYTE,
     45     EFI_ACPI_RESERVED_BYTE
     46   },
     47   // EFI_ACPI_5_0_GENERIC_ADDRESS_STRUCTURE  BaseAddress;
     48   ARM_GAS32 (FixedPcdGet64 (PcdSerialRegisterBase)),
     49   // UINT8                                   InterruptType;
     50   EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERRUPT_TYPE_GIC,
     51   // UINT8                                   Irq;
     52   0,                                         // Not used on ARM
     53   // UINT32                                  GlobalSystemInterrupt;
     54   FixedPcdGet32 (PL011UartInterrupt),
     55   // UINT8                                   BaudRate;
     56 #if (FixedPcdGet64 (PcdUartDefaultBaudRate) == 9600)
     57   EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_BAUD_RATE_9600,
     58 #elif (FixedPcdGet64 (PcdUartDefaultBaudRate) == 19200)
     59   EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_BAUD_RATE_19200,
     60 #elif (FixedPcdGet64 (PcdUartDefaultBaudRate) == 57600)
     61   EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_BAUD_RATE_57600,
     62 #elif (FixedPcdGet64 (PcdUartDefaultBaudRate) == 115200)
     63   EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_BAUD_RATE_115200,
     64 #else
     65 #error Unsupported SPCR Baud Rate
     66 #endif
     67   // UINT8                                   Parity;
     68   EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_PARITY_NO_PARITY,
     69   // UINT8                                   StopBits;
     70   EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_STOP_BITS_1,
     71   // UINT8                                   FlowControl;
     72   SPCR_FLOW_CONTROL_NONE,
     73   // UINT8                                   TerminalType;
     74   EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_TERMINAL_TYPE_ANSI,
     75   // UINT8                                   Reserved2;
     76   EFI_ACPI_RESERVED_BYTE,
     77   // UINT16                                  PciDeviceId;
     78   0xFFFF,
     79   // UINT16                                  PciVendorId;
     80   0xFFFF,
     81   // UINT8                                   PciBusNumber;
     82   0x00,
     83   // UINT8                                   PciDeviceNumber;
     84   0x00,
     85   // UINT8                                   PciFunctionNumber;
     86   0x00,
     87   // UINT32                                  PciFlags;
     88   0x00000000,
     89   // UINT8                                   PciSegment;
     90   0x00,
     91   // UINT32                                  Reserved3;
     92   EFI_ACPI_RESERVED_DWORD
     93 };
     94 
     95 //
     96 // Reference the table being generated to prevent the optimizer from removing the
     97 // data structure from the executable
     98 //
     99 VOID* CONST ReferenceAcpiTable = &Spcr;
    100