From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web10.785.1589262940764065435 for ; Mon, 11 May 2020 22:55:40 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.88, mailfrom: ming.tan@intel.com) IronPort-SDR: m329Dc/gwm+vQUW05ubV8bWJ93Ebf9BNGB3mxS81p26BrIonIkKfOTDZtNC3ZiCj4DnIrhy6WG c2kZGOEuAFnQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2020 22:55:40 -0700 IronPort-SDR: WbjRNXDQ0haGJs78hoaqD1KY+zMZy4qEHS2BP4fJBkB8jkHMjnWWP2EtRg+AFjp480VpmISp44 RHp2uhDcRuhg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,382,1583222400"; d="scan'208";a="463419572" Received: from shwdejointlab96.ccr.corp.intel.com ([10.239.134.144]) by fmsmga005.fm.intel.com with ESMTP; 11 May 2020 22:55:38 -0700 From: "Tan, Ming" To: devel@edk2.groups.io Subject: [PATCH v2] Add Features/Intel/OutOfBandManagement/SpcrFeaturePkg. Date: Tue, 12 May 2020 13:55:34 +0800 Message-Id: <20200512055534.22812-1-ming.tan@intel.com> X-Mailer: git-send-email 2.24.0.windows.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2710 It is used to support the Serial Port Console Redirection Table (SPCR). Signed-off-by: Ming Tan --- v2: Add the EFIAPI for function GetSpcrDevice() in Include/Library/SpcrDevi= ceLib.h and Library/SpcrDeviceLibNull/SpcrDeviceLibNull.c. .../Include/Library/SpcrDeviceLib.h | 27 + .../SpcrFeaturePkg/Include/SpcrFeature.dsc | 108 ++++ .../SpcrDeviceLibNull/SpcrDeviceLibNull.c | 26 + .../SpcrDeviceLibNull/SpcrDeviceLibNull.inf | 22 + .../SpcrFeaturePkg/Readme.md | 64 +++ .../SpcrFeaturePkg/SpcrAcpiDxe/SpcrAcpi.c | 467 ++++++++++++++++++ .../SpcrFeaturePkg/SpcrAcpiDxe/SpcrAcpi.h | 81 +++ .../SpcrAcpiDxe/SpcrAcpiDxe.inf | 42 ++ .../SpcrFeaturePkg/SpcrFeaturePkg.dec | 27 + .../SpcrFeaturePkg/SpcrFeaturePkg.dsc | 30 ++ 10 files changed, 894 insertions(+) create mode 100644 Features/Intel/OutOfBandManagement/SpcrFeaturePkg/Inclu= de/Library/SpcrDeviceLib.h create mode 100644 Features/Intel/OutOfBandManagement/SpcrFeaturePkg/Inclu= de/SpcrFeature.dsc create mode 100644 Features/Intel/OutOfBandManagement/SpcrFeaturePkg/Libra= ry/SpcrDeviceLibNull/SpcrDeviceLibNull.c create mode 100644 Features/Intel/OutOfBandManagement/SpcrFeaturePkg/Libra= ry/SpcrDeviceLibNull/SpcrDeviceLibNull.inf create mode 100644 Features/Intel/OutOfBandManagement/SpcrFeaturePkg/Readm= e.md create mode 100644 Features/Intel/OutOfBandManagement/SpcrFeaturePkg/SpcrA= cpiDxe/SpcrAcpi.c create mode 100644 Features/Intel/OutOfBandManagement/SpcrFeaturePkg/SpcrA= cpiDxe/SpcrAcpi.h create mode 100644 Features/Intel/OutOfBandManagement/SpcrFeaturePkg/SpcrA= cpiDxe/SpcrAcpiDxe.inf create mode 100644 Features/Intel/OutOfBandManagement/SpcrFeaturePkg/SpcrF= eaturePkg.dec create mode 100644 Features/Intel/OutOfBandManagement/SpcrFeaturePkg/SpcrF= eaturePkg.dsc diff --git a/Features/Intel/OutOfBandManagement/SpcrFeaturePkg/Include/Libr= ary/SpcrDeviceLib.h b/Features/Intel/OutOfBandManagement/SpcrFeaturePkg/Inc= lude/Library/SpcrDeviceLib.h new file mode 100644 index 0000000000..947813815e --- /dev/null +++ b/Features/Intel/OutOfBandManagement/SpcrFeaturePkg/Include/Library/Spc= rDeviceLib.h @@ -0,0 +1,27 @@ +/** @file=0D + Header file for a library about SPCR device.=0D + SpcrDeviceLib is usd for Serial Port Console Redirection Table (SPCR) de= vice.=0D +=0D + Copyright (c) 2011 - 2020, Intel Corporation. All rights reserved.
=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#ifndef _SPCR_DEVICE_LIB_H_=0D +#define _SPCR_DEVICE_LIB_H_=0D +=0D +/**=0D + Get a Serial Port device used for SPCR.=0D + The caller should call FreePool() to free the memory if return value is = not NULL.=0D +=0D + @retval NULL Can not get device.=0D + @retval Others A serial port device path.=0D +=0D +**/=0D +EFI_DEVICE_PATH_PROTOCOL *=0D +EFIAPI=0D +GetSpcrDevice (=0D + VOID=0D + );=0D +=0D +#endif // _SPCR_DEVICE_LIB_H_=0D diff --git a/Features/Intel/OutOfBandManagement/SpcrFeaturePkg/Include/Spcr= Feature.dsc b/Features/Intel/OutOfBandManagement/SpcrFeaturePkg/Include/Spc= rFeature.dsc new file mode 100644 index 0000000000..89ef648f31 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/SpcrFeaturePkg/Include/SpcrFeature= .dsc @@ -0,0 +1,108 @@ +## @file=0D +# This package provides advanced feature functionality about Serial Port C= onsole Redirection Table (SPCR).=0D +# This file should be included into another package DSC file to build this= feature.=0D +#=0D +# The DEC files are used by the utilities that parse DSC and=0D +# INF files to generate AutoGen.c and AutoGen.h files=0D +# for the build infrastructure.=0D +#=0D +# Copyright (c) 2020, Intel Corporation. All rights reserved.
=0D +#=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +=0D +##########################################################################= ######=0D +#=0D +# Defines Section - statements that will be processed to create a Makefile= .=0D +#=0D +##########################################################################= ######=0D +[Defines]=0D +!ifndef $(PEI_ARCH)=0D + !error "PEI_ARCH must be specified to build this feature!"=0D +!endif=0D +!ifndef $(DXE_ARCH)=0D + !error "DXE_ARCH must be specified to build this feature!"=0D +!endif=0D +=0D +##########################################################################= ######=0D +#=0D +# Library Class section - list of all Library Classes needed by this featu= re.=0D +#=0D +##########################################################################= ######=0D +[LibraryClasses]=0D + #######################################=0D + # Edk2 Packages=0D + #######################################=0D + BaseLib|MdePkg/Library/BaseLib/BaseLib.inf=0D + BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf= =0D + DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf=0D + UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntry= Point.inf=0D + UefiLib|MdePkg/Library/UefiLib/UefiLib.inf=0D + PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf=0D + PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf=0D + UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBoo= tServicesTableLib.inf=0D + DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf=0D + UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/U= efiRuntimeServicesTableLib.inf=0D +=0D + #######################################=0D + # SpcrFeaturePkg Packages=0D + #######################################=0D + SpcrDeviceLib|SpcrFeaturePkg/Library/SpcrDeviceLibNull/SpcrDeviceLibNull= .inf=0D +=0D +[LibraryClasses.common.DXE_DRIVER]=0D + #######################################=0D + # Edk2 Packages=0D + #######################################=0D + MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAll= ocationLib.inf=0D +=0D +##########################################################################= ######=0D +#=0D +# Component section - list of all components that need built for this feat= ure.=0D +#=0D +# Note: The EDK II DSC file is not used to specify how compiled binary ima= ges get placed=0D +# into firmware volume images. This section is just a list of module= s to compile from=0D +# source into UEFI-compliant binaries.=0D +# It is the FDF file that contains information on combining binary f= iles into firmware=0D +# volume images, whose concept is beyond UEFI and is described in PI= specification.=0D +# There may also be modules listed in this section that are not requ= ired in the FDF file,=0D +# When a module listed here is excluded from FDF file, then UEFI-com= pliant binary will be=0D +# generated for it, but the binary will not be put into any firmware= volume.=0D +#=0D +##########################################################################= ######=0D +=0D +#=0D +# Feature DXE Components=0D +#=0D +=0D +# @todo: Change below line to [Components.$(DXE_ARCH)] after https://bugzi= lla.tianocore.org/show_bug.cgi?id=3D2308=0D +# is completed.=0D +[Components.X64]=0D + #####################################=0D + # Spcr Feature Package=0D + #####################################=0D +=0D + # Add library instances here that are not included in package components= and should be tested=0D + # in the package build.=0D +=0D + # Add components here that should be included in the package build.=0D + SpcrFeaturePkg/SpcrAcpiDxe/SpcrAcpiDxe.inf=0D + #{=0D +# =0D +# SpcrDeviceLib|SpcrFeaturePkg/Library/SpcrDeviceLibNull/SpcrDeviceLi= bNull.inf=0D +# }=0D +=0D +##########################################################################= #########################=0D +#=0D +# BuildOptions Section - Define the module specific tool chain flags that = should be used as=0D +# the default flags for a module. These flags are a= ppended to any=0D +# standard flags that are defined by the build proc= ess. They can be=0D +# applied for any modules or only those modules wit= h the specific=0D +# module style (EDK or EDKII) specified in [Compone= nts] section.=0D +#=0D +# For advanced features, it is recommended to enabl= e [BuildOptions] in=0D +# the applicable INF file so it does not affect the= whole board package=0D +# build when this DSC file is active.=0D +#=0D +##########################################################################= #########################=0D +[BuildOptions]=0D diff --git a/Features/Intel/OutOfBandManagement/SpcrFeaturePkg/Library/Spcr= DeviceLibNull/SpcrDeviceLibNull.c b/Features/Intel/OutOfBandManagement/Spcr= FeaturePkg/Library/SpcrDeviceLibNull/SpcrDeviceLibNull.c new file mode 100644 index 0000000000..d30f421887 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/SpcrFeaturePkg/Library/SpcrDeviceL= ibNull/SpcrDeviceLibNull.c @@ -0,0 +1,26 @@ +/** @file=0D + Implementation for a NULL library of SpcrDeviceLib.=0D + SpcrDeviceLib is usd for Serial Port Console Redirection Table (SPCR) de= vice.=0D +=0D + Copyright (c) 2017 - 2020, Intel Corporation. All rights reserved.
=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#include =0D +#include =0D +=0D +/**=0D + Get a Serial Port device used for SPCR.=0D +=0D + @retval NULL Can not get device.=0D +=0D +**/=0D +EFI_DEVICE_PATH_PROTOCOL*=0D +EFIAPI=0D +GetSpcrDevice (=0D + VOID=0D + )=0D +{=0D + return NULL;=0D +}=0D diff --git a/Features/Intel/OutOfBandManagement/SpcrFeaturePkg/Library/Spcr= DeviceLibNull/SpcrDeviceLibNull.inf b/Features/Intel/OutOfBandManagement/Sp= crFeaturePkg/Library/SpcrDeviceLibNull/SpcrDeviceLibNull.inf new file mode 100644 index 0000000000..bf40dc48c3 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/SpcrFeaturePkg/Library/SpcrDeviceL= ibNull/SpcrDeviceLibNull.inf @@ -0,0 +1,22 @@ +## @file=0D +# Implementation for a NULL library of SpcrDeviceLib.=0D +# SpcrDeviceLib is usd for Serial Port Console Redirection Table (SPCR) de= vice.=0D +#=0D +# Copyright (c) 2017 - 2020, Intel Corporation. All rights reserved.
=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +=0D +[Defines]=0D + INF_VERSION =3D 0x00010017=0D + BASE_NAME =3D SpcrDeviceLibNull=0D + FILE_GUID =3D 8865739F-D0A8-4936-A457-8B3521EC60D1= =0D + VERSION_STRING =3D 1.0=0D + MODULE_TYPE =3D BASE=0D + LIBRARY_CLASS =3D SpcrDeviceLib=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D +=0D +[Sources]=0D + SpcrDeviceLibNull.c=0D diff --git a/Features/Intel/OutOfBandManagement/SpcrFeaturePkg/Readme.md b/= Features/Intel/OutOfBandManagement/SpcrFeaturePkg/Readme.md new file mode 100644 index 0000000000..a16835b151 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/SpcrFeaturePkg/Readme.md @@ -0,0 +1,64 @@ +# Overview=0D +* **Feature Name:** Serial Port Console Redirection Table (SPCR)=0D +* **PI Phase(s) Supported:** DXE=0D +* **SMM Required?** No=0D +=0D +More Information:=0D +* [Serial Port Console Redirection Table (SPCR)](https://docs.microsoft.co= m/en-us/windows-hardware/drivers/serports/serial-port-console-redirection-t= able)=0D +=0D +## Purpose=0D +The SPCR feature provides the functionality that select a serial port devi= ce and fill its info to ACPI table.=0D +Windows can get this info and use this serial port as input/output device = in Microsoft=C2=AE Windows=C2=AE Emergency Management Services (EMS).=0D +=0D +# High-Level Theory of Operation=0D +A dxe driver will call a library function to get the serial port device, a= nd produces the ACPI table.=0D +Platform can implement its own library to select the serial port device.=0D +=0D +## Firmware Volumes=0D +* PostMemory=0D +=0D +## Modules=0D +* SpcrAcpiDxe=0D +* SpcrDeviceLibNull=0D +=0D +## SpcrAcpiDxe=0D +The main driver of convert the serial port device info to ACPI table.=0D +It will call the function GetSpcrDevice() in the library SpcrDeviceLib to = get the serial port device path.=0D +If the serial port device path is not NULL, then use gEfiPciIoProtocolGuid= to get the PCI info, and use the gEfiSerialIoProtocolGuid to get the seria= l port info, such as the baud rate etc.=0D +If the serial port device is PCI device 00:16:03 (AMT serial over lan PCI = device), then will set the BaseAddress.=0D +At last fill the ACPI table as Windows required.=0D +=0D +## SpcrDeviceLibNull=0D +A NULL implemention of library SpcrDeviceLib, it return NULL for function = GetSpcrDevice().=0D +Platform maybe implemente its own SpcrDeviceLib.=0D +=0D +## Key Functions=0D +Fill the serial port device info used for SPCR to ACPI table.=0D +=0D +## Configuration=0D +There is not special configuration.=0D +But the platform maybe implemente its own SpcrDeviceLib.=0D +=0D +## Data Flows=0D +GetSpcrDevice() -> serial port device path -> get PCI info and serial port= info -> ACPI table.=0D +=0D +## Control Flows=0D +GetSpcrDevice() in SpcrDeviceLib -> SpcrAcpiDxe.=0D +=0D +## Build Flows=0D +There is not special build flow.=0D +=0D +## Test Point Results=0D +* Check the output ACPI table.=0D +=0D +## Functional Exit Criteria=0D +* Check the output ACPI table.=0D +=0D +## Feature Enabling Checklist=0D +There is not special PCD to enable this feature.=0D +=0D +## Performance Impact=0D +The SpcrAcpiDxe.efi with SpcrDeviceLibNull debug version size: 1.4KB, rele= ase version size: 1.12KB.=0D +=0D +## Common Optimizations=0D +N/A now.=0D diff --git a/Features/Intel/OutOfBandManagement/SpcrFeaturePkg/SpcrAcpiDxe/= SpcrAcpi.c b/Features/Intel/OutOfBandManagement/SpcrFeaturePkg/SpcrAcpiDxe/= SpcrAcpi.c new file mode 100644 index 0000000000..85ac48cfa5 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/SpcrFeaturePkg/SpcrAcpiDxe/SpcrAcp= i.c @@ -0,0 +1,467 @@ +/** @file=0D + Implementation the driver used to add SPCR device info to ACPI table.=0D + SPCR is abbreviation of Serial Port Console Redirection Table (SPCR).=0D +=0D + Copyright (c) 2004 - 2020, Intel Corporation. All rights reserved.
=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#include "SpcrAcpi.h"=0D +=0D +#define PCANSITYPE 0=0D +#define VT100TYPE 1=0D +#define VT100PLUSTYPE 2=0D +#define VTUTF8TYPE 3=0D +=0D +#define PCI_MAX_BAR_NO 6=0D +=0D +UINT8 TerminalTypeValue[4] =3D=0D +{=0D + PCANSITYPE,=0D + VT100TYPE,=0D + VT100PLUSTYPE,=0D + VTUTF8TYPE=0D +};=0D +=0D +///=0D +/// Guid for messaging path, used in Serial port setting.=0D +///=0D +EFI_GUID TerminalTypeGuid[4] =3D {=0D + DEVICE_PATH_MESSAGING_PC_ANSI,=0D + DEVICE_PATH_MESSAGING_VT_100,=0D + DEVICE_PATH_MESSAGING_VT_100_PLUS,=0D + DEVICE_PATH_MESSAGING_VT_UTF8=0D +};=0D +=0D +//=0D +// Serial Port Console Redirection Table=0D +// Please modify all values in Spcr.h only.=0D +//=0D +EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE gSpcrInfo =3D {=0D + {=0D + EFI_ACPI_2_0_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE,=0D + sizeof (EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE),=0D + EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_REVISION,=0D +=0D + //=0D + // Checksum will be updated at runtime=0D + //=0D + 0x00,=0D +=0D + //=0D + // It is expected that these values will be programmed at runtime=0D + //=0D + {'I', 'N', 'T', 'E', 'L', ' '},=0D +=0D + SIGNATURE_64 ('S', 'P', 'C', 'R', 'T', 'a', 'b', 'l'),=0D + 0x00, // Spcr revision,=0D + SIGNATURE_32 ('I', 'N', 'T', 'L'),=0D + 0x01=0D + },=0D +=0D + //=0D + // Beginning of SPCR specific fields=0D + //=0D + 0x00, //INTERFACE_TYPE,=0D + {=0D + 0x00, //RESERVED_BYTE,=0D + 0x00, //RESERVED_BYTE,=0D + 0x00 //RESERVED_BYTE,=0D + },=0D +=0D + //=0D + // Base Address Block=0D + //=0D + {=0D + EFI_ACPI_3_0_SYSTEM_IO,=0D + 0x08, //BASE_ADDRESS_BIT_WIDTH,=0D + 0x00, //BASE_ADDRESS_BIT_OFFSET,=0D + 0x00, //RESERVED_BYTE,=0D + 0x0000000000000000 //BASE_ADDRESS_ADDRESS,=0D + },=0D +=0D + 0x03, //INTERRUPT_TYPE,=0D + 0x04, //IRQ,=0D + 0x04, //GLOBAL_SYSTEM_INTERRUPT,=0D + 0x07, //BAUD_RATE,=0D + 0x00, //PARITY,=0D + 0x01, //STOP_BITS,=0D + 0x00, //FLOW_CONTROL,=0D + 0x03, //TERMINAL_TYPE,=0D + 0x00, //LANGUAGE,=0D + 0xFFFF, //PCI_DEVICE_ID,=0D + 0xFFFF, //PCI_VENDOR_ID,=0D + 0x00, //PCI_BUS_NUMBER,=0D + 0x00, //PCI_DEVICE_NUMBER,=0D + 0x00, //PCI_FUNCTION_NUMBER,=0D + 0x00000000, //PCI_FLAGS,=0D + 0x00, //PCI_SEGMENT,=0D + EFI_ACPI_RESERVED_DWORD=0D +};=0D +=0D +=0D +/**=0D +=0D + Install Boot Device Selection Protocol=0D +=0D + @param ImageHandle The image handle.=0D + @param SystemTable The system table.=0D +=0D + @retval EFI_SUCEESS BDS has finished initializing.=0D + Return the dispatcher and recall BDS.Entry=0D + @retval Other Return status from AllocatePool() or gBS->InstallP= rotocolInterface=0D +=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +SpcrInitialize (=0D + IN EFI_HANDLE ImageHandle,=0D + IN EFI_SYSTEM_TABLE *SystemTable=0D + )=0D +{=0D + EFI_STATUS Status;=0D + EFI_EVENT ReadyToBootEvent;=0D + //=0D + // Install protocol interface=0D + //=0D + Status =3D EfiCreateEventReadyToBootEx (=0D + TPL_CALLBACK,=0D + OutOfBandACPITableConstruction,=0D + NULL,=0D + &ReadyToBootEvent=0D + );=0D + return Status;=0D +}=0D +=0D +/**=0D + Check whether the device path node is ISA Serial Node.=0D +=0D + @param DevicePath Device path node to be checked=0D +=0D + @retval TRUE It's ISA Serial Node.=0D + @retval FALSE It's NOT ISA Serial Node.=0D +=0D +**/=0D +BOOLEAN=0D +HasIsaSerialNode (=0D + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath=0D + )=0D +{=0D + EFI_DEVICE_PATH_PROTOCOL *Node;=0D + ACPI_HID_DEVICE_PATH *Acpi;=0D +=0D + for (Node =3D DevicePath; !IsDevicePathEnd (Node); Node =3D NextDevicePa= thNode (Node)) {=0D + Acpi =3D (ACPI_HID_DEVICE_PATH *) Node;=0D + if ((DevicePathType (Acpi) =3D=3D ACPI_DEVICE_PATH) && (DevicePathSubT= ype (Acpi) =3D=3D ACPI_DP) &&=0D + (ReadUnaligned32 (&Acpi->HID) =3D=3D EISA_PNP_ID (0x0501))) {=0D + return TRUE;=0D + }=0D + }=0D +=0D + return FALSE;=0D +}=0D +=0D +/**=0D + Get Irq and resource info from isa type console device.=0D +=0D + @param SavedDevicePath Device path for isa device.=0D +=0D +**/=0D +VOID=0D +GetIsaTypeInfo (=0D + IN EFI_DEVICE_PATH_PROTOCOL *SavedDevicePath=0D + )=0D +{=0D + EFI_STATUS Status;=0D + EFI_HANDLE Handle;=0D + ACPI_RESOURCE_HEADER_PTR Resources;=0D + EFI_SIO_PROTOCOL *Sio;=0D + EFI_ACPI_IRQ_NOFLAG_DESCRIPTOR *Irq;=0D + EFI_ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR *FixedLocation;=0D +=0D + //=0D + // Try to get IRP and BaseAddress info.=0D + //=0D + Status =3D gBS->LocateDevicePath(=0D + &gEfiSioProtocolGuid,=0D + &SavedDevicePath,=0D + &Handle=0D + );=0D + if (EFI_ERROR(Status)) {=0D + return;=0D + }=0D +=0D + Status =3D gBS->HandleProtocol (=0D + Handle,=0D + &gEfiSioProtocolGuid,=0D + (VOID **) &Sio=0D + );=0D + if (EFI_ERROR(Status)) {=0D + return;=0D + }=0D +=0D + Status =3D Sio->GetResources (Sio, &Resources);=0D + if (EFI_ERROR(Status)) {=0D + return;=0D + }=0D +=0D + while (Resources.SmallHeader->Byte !=3D ACPI_END_TAG_DESCRIPTOR) {=0D + switch (Resources.SmallHeader->Byte) {=0D + case ACPI_IRQ_DESCRIPTOR:=0D + case ACPI_IRQ_NOFLAG_DESCRIPTOR:=0D + Irq =3D (EFI_ACPI_IRQ_NOFLAG_DESCRIPTOR *) Resources.SmallHeader= ;=0D + gSpcrInfo.Irq =3D 0;=0D + while (Irq->Mask > 1) {=0D + gSpcrInfo.Irq ++;=0D + Irq->Mask =3D Irq->Mask >> 1;=0D + }=0D + break;=0D + case ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR:=0D + FixedLocation =3D (EFI_ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR *)= Resources.SmallHeader;=0D + gSpcrInfo.BaseAddress.Address =3D FixedLocation->BaseAddress;=0D + break;=0D + default:=0D + break;=0D + }=0D +=0D + if (Resources.SmallHeader->Bits.Type =3D=3D 0) {=0D + Resources.SmallHeader =3D (ACPI_SMALL_RESOURCE_HEADER *) ((UINT8 *= ) Resources.SmallHeader=0D + + Resources.SmallHeader->Bits.Length=0D + + sizeof (*Resources.SmallHeader));=0D + } else {=0D + Resources.LargeHeader =3D (ACPI_LARGE_RESOURCE_HEADER *) ((UINT8 *= ) Resources.LargeHeader=0D + + Resources.LargeHeader->Length=0D + + sizeof (*Resources.LargeHeader));=0D + }=0D + }=0D +}=0D +=0D +/**=0D + Get Irq and resource info from Pci type console device.=0D +=0D + @param SavedDevicePath Device path for PCI device.=0D +=0D +**/=0D +VOID=0D +GetPciTypeInfo (=0D + IN EFI_DEVICE_PATH_PROTOCOL *SavedDevicePath=0D + )=0D +{=0D + EFI_STATUS Status;=0D + EFI_HANDLE PciHandle;=0D + EFI_PCI_IO_PROTOCOL *PciIo;=0D + UINTN Bus;=0D + UINTN Device;=0D + UINTN Function;=0D + UINTN SegNum;=0D + UINTN Irq;=0D + UINT16 BaseAddress;=0D + UINT8 Count;=0D + UINT64 Supports;=0D + UINT16 VendorId;=0D + UINT16 DeviceId;=0D + EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Resources;=0D +=0D + PciIo =3D NULL;=0D + Resources =3D NULL;=0D + Supports =3D 0x01;=0D + Bus =3D 0;=0D + Device =3D 0;=0D + Function =3D 0;=0D + SegNum =3D 0;=0D + Irq =3D 0;=0D + BaseAddress =3D 0;=0D + VendorId =3D 0;=0D + DeviceId =3D 0;=0D +=0D + Status =3D gBS->LocateDevicePath (&gEfiPciIoProtocolGuid, &SavedDevicePa= th, (VOID **) &PciHandle);=0D + if (EFI_ERROR (Status)) {=0D + Status =3D EFI_NOT_FOUND;=0D + return;=0D + }=0D +=0D + Status =3D gBS->HandleProtocol(PciHandle, &gEfiPciIoProtocolGuid, (VOID = **) &PciIo);=0D + if (EFI_ERROR (Status) || (PciIo =3D=3D NULL)) {=0D + Status =3D EFI_NOT_FOUND;=0D + return;=0D + }=0D +=0D + PciIo->GetLocation(PciIo, &SegNum, &Bus, &Device, &Function);=0D + if (EFI_ERROR (Status)) {=0D + Status =3D EFI_NOT_FOUND;=0D + return;=0D + }=0D +=0D + if (Bus =3D=3D 0x00 && Device =3D=3D 0x16 && Function =3D=3D 3)=0D + {=0D + for (Count =3D 0; Count < PCI_MAX_BAR_NO; Count++) {=0D + Status =3D PciIo->GetBarAttributes (PciIo, Count, &Supports, (VOID = **) &Resources);=0D + if (!EFI_ERROR(Status)) {=0D + if (Resources->ResType =3D=3D 1) { // TYPE_IO=0D + BaseAddress=3D (UINT16)Resources->AddrRangeMin;=0D + break;=0D + }=0D + FreePool (Resources);=0D + Resources =3D NULL;=0D + }=0D + }=0D + }=0D +=0D + Status =3D PciIo->Pci.Read(PciIo, EfiPciIoWidthUint8, 0x3c, 1, &Irq);=0D + if (EFI_ERROR(Status)) {=0D + goto Done;=0D + }=0D +=0D + Status =3D PciIo->Pci.Read(PciIo, EfiPciIoWidthUint16, 0x00, 1, &VendorI= d);=0D + if (EFI_ERROR(Status)) {=0D + goto Done;=0D + }=0D +=0D + Status =3D PciIo->Pci.Read(PciIo, EfiPciIoWidthUint16, 0x02, 1, &DeviceI= d);=0D + if (EFI_ERROR(Status)) {=0D + goto Done;=0D + }=0D +=0D + gSpcrInfo.BaseAddress.Address =3D BaseAddress;=0D + gSpcrInfo.Irq =3D (UINT8) Irq;=0D +=0D + gSpcrInfo.PciDeviceId =3D DeviceId;=0D + gSpcrInfo.PciVendorId =3D VendorId;=0D + gSpcrInfo.PciBusNumber =3D (UINT8) Bus;=0D + gSpcrInfo.PciDeviceNumber =3D (UINT8) Device;=0D + gSpcrInfo.PciFunctionNumber =3D (UINT8) Function;=0D + gSpcrInfo.PciSegment =3D (UINT8) SegNum;=0D +=0D +Done:=0D + if (Resources !=3D NULL) {=0D + FreePool (Resources);=0D + }=0D +}=0D +=0D +/**=0D + Installs the Smbios Table to the System Table. This function gets called= =0D + when the EFI_EVENT_SIGNAL_READY_TO_BOOT gets signaled=0D +=0D + @param Event The event to signal=0D + @param Context Event contex=0D +=0D +**/=0D +VOID=0D +EFIAPI=0D +OutOfBandACPITableConstruction (=0D + IN EFI_EVENT Event,=0D + IN VOID *Context=0D + )=0D +{=0D + EFI_DEVICE_PATH_PROTOCOL *SavedDevicePath;=0D + EFI_DEVICE_PATH_PROTOCOL *TmpDevicePath;=0D + EFI_DEVICE_PATH_PROTOCOL *Tmp2DevicePath;=0D + EFI_ACPI_TABLE_PROTOCOL *AcpiTablProtocol;=0D + UINTN TurnKey;=0D + EFI_STATUS Status;=0D + EFI_HANDLE Handle;=0D + EFI_SERIAL_IO_PROTOCOL *SerialIo;=0D + UINT32 FlowControl;=0D + VENDOR_DEVICE_PATH *Vendor;=0D + UINT8 Index;=0D +=0D + Handle =3D NULL;=0D +=0D + SavedDevicePath =3D GetSpcrDevice();=0D + if (SavedDevicePath =3D=3D NULL) {=0D + return;=0D +=0D + }=0D + //=0D + // Get TerminalType info from the last device path node.=0D + //=0D + TmpDevicePath =3D SavedDevicePath;=0D + Tmp2DevicePath =3D TmpDevicePath;=0D + while (!IsDevicePathEnd (TmpDevicePath)) {=0D + Tmp2DevicePath =3D TmpDevicePath;=0D + TmpDevicePath =3D NextDevicePathNode(TmpDevicePath);=0D + }=0D + Vendor =3D (VENDOR_DEVICE_PATH *) Tmp2DevicePath;=0D + for (Index=3D0; Index < 4; Index ++) {=0D + if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[Index])) {=0D + gSpcrInfo.TerminalType =3D TerminalTypeValue[Index];=0D + break;=0D + }=0D + }=0D + SetDevicePathEndNode (Tmp2DevicePath);=0D + TmpDevicePath =3D SavedDevicePath;=0D + //=0D + // Get Console attribute from the serial io protocol.=0D + //=0D + Status =3D gBS->LocateDevicePath(=0D + &gEfiSerialIoProtocolGuid,=0D + &TmpDevicePath,=0D + &Handle=0D + );=0D + if (EFI_ERROR(Status)) {=0D + goto out;=0D + }=0D +=0D + Status =3D gBS->HandleProtocol (=0D + Handle,=0D + &gEfiSerialIoProtocolGuid,=0D + (VOID **) &SerialIo=0D + );=0D + if (EFI_ERROR(Status)) {=0D + goto out;=0D + }=0D +=0D + switch (SerialIo->Mode->BaudRate) {=0D + case 9600:=0D + gSpcrInfo.BaudRate =3D 3;=0D + break;=0D + case 19200:=0D + gSpcrInfo.BaudRate =3D 4;=0D + break;=0D + case 57600:=0D + gSpcrInfo.BaudRate =3D 6;=0D + break;=0D + case 115200:=0D + default:=0D + gSpcrInfo.BaudRate =3D 7;=0D + break;=0D + }=0D +=0D + gSpcrInfo.FlowControl =3D 0;=0D + SerialIo->GetControl(SerialIo, &FlowControl);=0D + if ((FlowControl & EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE) !=3D 0) {=0D + gSpcrInfo.FlowControl =3D UART_FLOW_CONTROL_HARDWARE;=0D + }=0D +=0D + if (HasIsaSerialNode(SavedDevicePath)) {=0D + GetIsaTypeInfo (SavedDevicePath);=0D + } else {=0D + GetPciTypeInfo (SavedDevicePath);=0D + }=0D + //=0D + // Not create before, create new Spcr ACPI table.=0D + //=0D + Status =3D gBS->LocateProtocol (=0D + &gEfiAcpiTableProtocolGuid,=0D + NULL,=0D + (VOID**)&AcpiTablProtocol=0D + );=0D + if (EFI_ERROR (Status)) {=0D + goto out;=0D + }=0D +=0D + //=0D + // Add table=0D + //=0D + Status =3D AcpiTablProtocol->InstallAcpiTable (=0D + AcpiTablProtocol,=0D + &gSpcrInfo,=0D + sizeof (EFI_ACPI_SERIAL_PORT_CONSOLE_RED= IRECTION_TABLE),=0D + &TurnKey=0D + );=0D + ASSERT_EFI_ERROR (Status);=0D +=0D +out:=0D + FreePool(SavedDevicePath);=0D +}=0D diff --git a/Features/Intel/OutOfBandManagement/SpcrFeaturePkg/SpcrAcpiDxe/= SpcrAcpi.h b/Features/Intel/OutOfBandManagement/SpcrFeaturePkg/SpcrAcpiDxe/= SpcrAcpi.h new file mode 100644 index 0000000000..c11da439fc --- /dev/null +++ b/Features/Intel/OutOfBandManagement/SpcrFeaturePkg/SpcrAcpiDxe/SpcrAcp= i.h @@ -0,0 +1,81 @@ +/** @file=0D + Header file for the driver used to add SPCR device info to ACPI table.=0D + SPCR is abbreviation of Serial Port Console Redirection Table (SPCR).=0D +=0D + Copyright (c) 2004 - 2020, Intel Corporation. All rights reserved.
=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#ifndef _SPCR_ACPI_H_=0D +#define _SPCR_ACPI_H_=0D +=0D +=0D +#include =0D +#include =0D +//#include =0D +=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +#pragma pack(1)=0D +=0D +///=0D +/// HII specific Vendor Device Path definition.=0D +///=0D +typedef struct {=0D + VENDOR_DEVICE_PATH VendorDevicePath;=0D + EFI_DEVICE_PATH_PROTOCOL End;=0D +} HII_VENDOR_DEVICE_PATH;=0D +=0D +#pragma pack()=0D +//=0D +// Prototypes=0D +//=0D +=0D +/**=0D +=0D + Install Boot Device Selection Protocol=0D +=0D + @param ImageHandle The image handle.=0D + @param SystemTable The system table.=0D +=0D + @retval EFI_SUCEESS BDS has finished initializing.=0D + Return the dispatcher and recall BDS.Entry=0D + @retval Other Return status from AllocatePool() or gBS->InstallP= rotocolInterface=0D +=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +SpcrInitialize (=0D + IN EFI_HANDLE ImageHandle,=0D + IN EFI_SYSTEM_TABLE *SystemTable=0D + );=0D +=0D +/**=0D + Installs the Smbios Table to the System Table. This function gets called= =0D + when the EFI_EVENT_SIGNAL_READY_TO_BOOT gets signaled=0D +=0D + @param Event The event to signal=0D + @param Context Event contex=0D +=0D +**/=0D +VOID=0D +EFIAPI=0D +OutOfBandACPITableConstruction (=0D + IN EFI_EVENT Event,=0D + IN VOID *Context=0D + );=0D +#endif=0D diff --git a/Features/Intel/OutOfBandManagement/SpcrFeaturePkg/SpcrAcpiDxe/= SpcrAcpiDxe.inf b/Features/Intel/OutOfBandManagement/SpcrFeaturePkg/SpcrAcp= iDxe/SpcrAcpiDxe.inf new file mode 100644 index 0000000000..3fc84959a0 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/SpcrFeaturePkg/SpcrAcpiDxe/SpcrAcp= iDxe.inf @@ -0,0 +1,42 @@ +## @file=0D +# SPCR is abbreviation of Serial Port Console Redirection Table (SPCR).=0D +#=0D +# Copyright (c) 2008 - 2020, Intel Corporation. All rights reserved.
=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +=0D +[Defines]=0D + INF_VERSION =3D 0x00010017=0D + BASE_NAME =3D SpcrAcpiDxe=0D + FILE_GUID =3D 31740724-5F96-48ca-AA0F-332ACA6B9A75= =0D + VERSION_STRING =3D 2.0=0D + MODULE_TYPE =3D DXE_DRIVER=0D + ENTRY_POINT =3D SpcrInitialize=0D +#=0D +# The following information is for reference only and not required by the = build tools.=0D +#=0D +# VALID_ARCHITECTURES =3D IA32 X64 IPF EBC=0D +#=0D +=0D +[LibraryClasses]=0D + UefiDriverEntryPoint=0D + UefiLib=0D + SpcrDeviceLib=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D + SpcrFeaturePkg/SpcrFeaturePkg.dec=0D +=0D +[Sources]=0D + SpcrAcpi.h=0D + SpcrAcpi.c=0D +=0D +[Protocols]=0D + gEfiAcpiTableProtocolGuid ## CONSUMES=0D + gEfiSioProtocolGuid ## SOMETIMES_CONSUMES=0D + gEfiSerialIoProtocolGuid ## SOMETIMES_CONSUMES=0D + gEfiPciIoProtocolGuid ## SOMETIMES_CONSUMES=0D +=0D +[Depex]=0D + TRUE=0D diff --git a/Features/Intel/OutOfBandManagement/SpcrFeaturePkg/SpcrFeatureP= kg.dec b/Features/Intel/OutOfBandManagement/SpcrFeaturePkg/SpcrFeaturePkg.d= ec new file mode 100644 index 0000000000..03776abf06 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/SpcrFeaturePkg/SpcrFeaturePkg.dec @@ -0,0 +1,27 @@ +## @file=0D +# This package provides advanced feature functionality about Serial Port C= onsole Redirection Table (SPCR).=0D +# This package should only depend on EDK II Core packages, IntelSiliconPkg= , and MinPlatformPkg.=0D +#=0D +# The DEC files are used by the utilities that parse DSC and=0D +# INF files to generate AutoGen.c and AutoGen.h files=0D +# for the build infrastructure.=0D +#=0D +# Copyright (c) 2020, Intel Corporation. All rights reserved.
=0D +#=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +=0D +[Defines]=0D + DEC_SPECIFICATION =3D 0x00010017=0D + PACKAGE_NAME =3D SpcrFeaturePkg=0D + PACKAGE_GUID =3D 20E84A8A-9008-4798-8215-697555E95B29=0D + PACKAGE_VERSION =3D 0.1=0D +=0D +[Includes]=0D + Include=0D +=0D +[LibraryClasses]=0D + ## @libraryclass Provides an API for get SPCR device.=0D + #=0D + SpcrDeviceLib|Include/Library/SpcrDeviceLib.h=0D diff --git a/Features/Intel/OutOfBandManagement/SpcrFeaturePkg/SpcrFeatureP= kg.dsc b/Features/Intel/OutOfBandManagement/SpcrFeaturePkg/SpcrFeaturePkg.d= sc new file mode 100644 index 0000000000..82d2d3ac73 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/SpcrFeaturePkg/SpcrFeaturePkg.dsc @@ -0,0 +1,30 @@ +## @file=0D +# This package provides advanced feature functionality about Serial Port C= onsole Redirection Table (SPCR).=0D +# This package should only depend on EDK II Core packages, IntelSiliconPkg= , and MinPlatformPkg.=0D +#=0D +# The DEC files are used by the utilities that parse DSC and=0D +# INF files to generate AutoGen.c and AutoGen.h files=0D +# for the build infrastructure.=0D +#=0D +# Copyright (c) 2020, Intel Corporation. All rights reserved.
=0D +#=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +=0D +[Defines]=0D + PLATFORM_NAME =3D SpcrFeaturePkg=0D + PLATFORM_GUID =3D 2CEB97B5-610D-440F-A2A7-6775AE2A7E89= =0D + PLATFORM_VERSION =3D 0.1=0D + DSC_SPECIFICATION =3D 0x00010005=0D + OUTPUT_DIRECTORY =3D Build/$(PLATFORM_NAME)=0D + SUPPORTED_ARCHITECTURES =3D IA32|X64=0D + BUILD_TARGETS =3D DEBUG|RELEASE|NOOPT=0D + SKUID_IDENTIFIER =3D DEFAULT=0D + PEI_ARCH =3D IA32=0D + DXE_ARCH =3D X64=0D +=0D +#=0D +# This package always builds the feature.=0D +#=0D +!include Include/SpcrFeature.dsc=0D --=20 2.24.0.windows.2