From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web12.6679.1652166681383551366 for ; Tue, 10 May 2022 00:11:27 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=k8NFlQnc; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: zhiguang.liu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652166686; x=1683702686; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=z1CsI3kJrGHX3FptnWUItN+vdM5CBQ4Qt64m2s2vfsE=; b=k8NFlQncbzkngv9IP7gUGx12aELHMYT0+P5NWKQ9LdCs+5OgiTF1P4jd xZkLr1BWHnFy1SJSug0KORFyxM5ESic2uLWGcJ8cfEHC6aMgdicYCJILq dQaFMhYVov60YxikhI3YZr+tMRbGAvhK9jUmqKjjHUjAGMmPZKy1Uq7ZQ VafFjZgIMfwbSnko7+nQs7vnNCbVAm539yHDJ3ILjOxvaPUt5jWUP/tVj sZEJxi85R1SEWPgBRzi0jnWrENtBIMPzy1W/5uv29btUgFTSou35YSAAH lQlBcIq0bkXfRon7e+eyLz3JcOBybZw+4dDhlUfWvzYKojJzuA65JHknw A==; X-IronPort-AV: E=McAfee;i="6400,9594,10342"; a="268127951" X-IronPort-AV: E=Sophos;i="5.91,213,1647327600"; d="scan'208";a="268127951" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2022 00:11:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,213,1647327600"; d="scan'208";a="696953457" Received: from shwdesfp01.ccr.corp.intel.com ([10.239.158.158]) by orsmga004.jf.intel.com with ESMTP; 10 May 2022 00:11:24 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Guo Dong , Ray Ni , Maurice Ma , Benjamin You , Sean Rhodes Subject: [PATCH 2/3] UefiPayloadPkg: Add Serial IO device path according to related protocol Date: Tue, 10 May 2022 15:11:10 +0800 Message-Id: <3e4cc390c9e7ffe9204b1564329086e7c3fc45cf.1652166437.git.zhiguang.liu@intel.com> X-Mailer: git-send-email 2.32.0.windows.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Current code follow some rules to check if the PCI device connected to a serial port device, but some platform or hardware doesn't follow such rule. By locating gEfiSerialIoProtocolGuid protocol, we can find the related device path. Cc: Guo Dong Cc: Ray Ni Cc: Maurice Ma Cc: Benjamin You Cc: Sean Rhodes Signed-off-by: Zhiguang Liu --- .../PlatformBootManagerLib.inf | 1 + .../PlatformBootManagerLib/PlatformConsole.c | 149 +++++------------- .../PlatformBootManagerLib/PlatformConsole.h | 1 - 3 files changed, 44 insertions(+), 107 deletions(-) diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootMana= gerLib.inf b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootMana= gerLib.inf index 80390e0d98..acf2880d22 100644 --- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.= inf +++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.= inf @@ -60,6 +60,7 @@ gEfiDxeSmmReadyToLockProtocolGuid=0D gEfiSmmAccess2ProtocolGuid=0D gUniversalPayloadPlatformBootManagerOverrideProtocolGuid=0D + gEfiSerialIoProtocolGuid=0D =0D [Pcd]=0D gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut=0D diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.= c b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.c index 9887183624..5e1c77d866 100644 --- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.c +++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.c @@ -47,36 +47,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define gPnpPs2Keyboard \=0D PNPID_DEVICE_PATH_NODE(0x0303)=0D =0D -#define gUartVendor \=0D - { \=0D - { \=0D - HARDWARE_DEVICE_PATH, \=0D - HW_VENDOR_DP, \=0D - { \=0D - (UINT8) (sizeof (VENDOR_DEVICE_PATH)), \=0D - (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) \=0D - } \=0D - }, \=0D - EDKII_SERIAL_PORT_LIB_VENDOR_GUID \=0D - }=0D -=0D -#define gUart \=0D - { \=0D - { \=0D - MESSAGING_DEVICE_PATH, \=0D - MSG_UART_DP, \=0D - { \=0D - (UINT8) (sizeof (UART_DEVICE_PATH)), \=0D - (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8) \=0D - } \=0D - }, \=0D - 0, \=0D - 115200, \=0D - 8, \=0D - 1, \=0D - 1 \=0D - }=0D -=0D #define gPcAnsiTerminal \=0D { \=0D { \=0D @@ -92,9 +62,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =0D ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode =3D gPnpPs2Keyboard;=0D ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode =3D gPnp16550ComPort;=0D -UART_DEVICE_PATH gUartDeviceNode =3D gUart;=0D VENDOR_DEVICE_PATH gTerminalTypeDeviceNode =3D gPcAnsiTerminal;=0D -VENDOR_DEVICE_PATH gUartDeviceVendorNode =3D gUartVendor;=0D =0D //=0D // Predefined platform root bridge=0D @@ -112,13 +80,11 @@ EFI_DEVICE_PATH_PROTOCOL *gPlatformRootBridges[] =3D { BOOLEAN mDetectDisplayOnly;=0D =0D /**=0D - Add IsaKeyboard to ConIn; add IsaSerial to ConOut, ConIn, ErrOut.=0D + Add IsaKeyboard to ConIn.=0D =0D @param[in] DeviceHandle Handle of the LPC Bridge device.=0D =0D - @retval EFI_SUCCESS Console devices on the LPC bridge have been added t= o=0D - ConOut, ConIn, and ErrOut.=0D -=0D + @retval EFI_SUCCESS IsaKeyboard on the LPC bridge have been added to Co= nIn.=0D @return Error codes, due to EFI_DEVICE_PATH_PROTOCOL missin= g=0D from DeviceHandle.=0D **/=0D @@ -129,7 +95,6 @@ PrepareLpcBridgeDevicePath ( {=0D EFI_STATUS Status;=0D EFI_DEVICE_PATH_PROTOCOL *DevicePath;=0D - EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;=0D =0D DevicePath =3D NULL;=0D Status =3D gBS->HandleProtocol (=0D @@ -141,26 +106,11 @@ PrepareLpcBridgeDevicePath ( return Status;=0D }=0D =0D - TempDevicePath =3D DevicePath;=0D -=0D //=0D // Register Keyboard=0D //=0D DevicePath =3D AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOC= OL *)&gPnpPs2KeyboardDeviceNode);=0D EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);=0D -=0D - //=0D - // Register COM1=0D - //=0D - DevicePath =3D TempDevicePath;=0D - DevicePath =3D AppendDevicePathNode ((EFI_DEVICE_PATH_PROTOCOL *)NULL, (= EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceVendorNode);=0D - DevicePath =3D AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOC= OL *)&gUartDeviceNode);=0D - DevicePath =3D AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOC= OL *)&gTerminalTypeDeviceNode);=0D -=0D - EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);=0D - EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);=0D - EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);=0D -=0D return EFI_SUCCESS;=0D }=0D =0D @@ -291,43 +241,6 @@ PreparePciVgaDevicePath ( return EFI_SUCCESS;=0D }=0D =0D -/**=0D - Add PCI Serial to ConOut, ConIn, ErrOut.=0D -=0D - @param[in] DeviceHandle - Handle of PciIo protocol.=0D -=0D - @retval EFI_SUCCESS - PCI Serial is added to ConOut, ConIn, and ErrOut.= =0D - @retval EFI_STATUS - No PCI Serial device is added.=0D -=0D -**/=0D -EFI_STATUS=0D -PreparePciSerialDevicePath (=0D - IN EFI_HANDLE DeviceHandle=0D - )=0D -{=0D - EFI_STATUS Status;=0D - EFI_DEVICE_PATH_PROTOCOL *DevicePath;=0D -=0D - DevicePath =3D NULL;=0D - Status =3D gBS->HandleProtocol (=0D - DeviceHandle,=0D - &gEfiDevicePathProtocolGuid,=0D - (VOID *)&DevicePath=0D - );=0D - if (EFI_ERROR (Status)) {=0D - return Status;=0D - }=0D -=0D - DevicePath =3D AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOC= OL *)&gUartDeviceNode);=0D - DevicePath =3D AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOC= OL *)&gTerminalTypeDeviceNode);=0D -=0D - EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);=0D - EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);=0D - EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);=0D -=0D - return EFI_SUCCESS;=0D -}=0D -=0D /**=0D For every PCI instance execute a callback function.=0D =0D @@ -452,18 +365,6 @@ DetectAndPreparePlatformPciDevicePath ( PrepareLpcBridgeDevicePath (Handle);=0D return EFI_SUCCESS;=0D }=0D -=0D - //=0D - // Here we decide which Serial device to enable in PCI bus=0D - //=0D - if (IS_PCI_16550SERIAL (&Pci)) {=0D - //=0D - // Add them to ConOut, ConIn, ErrOut.=0D - //=0D - DEBUG ((DEBUG_INFO, "Found PCI 16550 SERIAL device\n"));=0D - PreparePciSerialDevicePath (Handle);=0D - return EFI_SUCCESS;=0D - }=0D }=0D =0D //=0D @@ -481,6 +382,41 @@ DetectAndPreparePlatformPciDevicePath ( return Status;=0D }=0D =0D +/**=0D + For every Serial Io instance, add it to ConOut, ConIn, ErrOut.=0D +=0D + @param[in] Handle - The Serial Io device handle=0D + @param[in] Instance - The instance of the SerialIo protocol=0D + @param[in] Context - The context of the callback=0D +=0D + @retval EFI_STATUS - Callback function failed.=0D +=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +AddDevicePathForOneSerialIoInstance (=0D + IN EFI_HANDLE Handle,=0D + IN VOID *Instance,=0D + IN VOID *Context=0D + )=0D +{=0D + EFI_STATUS Status;=0D + EFI_DEVICE_PATH_PROTOCOL *DevicePath;=0D +=0D + DevicePath =3D NULL;=0D + Status =3D gBS->HandleProtocol (=0D + Handle,=0D + &gEfiDevicePathProtocolGuid,=0D + (VOID *)&DevicePath=0D + );=0D + DevicePath =3D AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOC= OL *)&gTerminalTypeDeviceNode);=0D +=0D + EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);=0D + EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);=0D + EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);=0D + return Status;=0D +}=0D +=0D /**=0D Do platform specific PCI Device check and add them to ConOut, ConIn, Err= Out=0D =0D @@ -505,6 +441,12 @@ DetectAndPreparePlatformPciDevicePaths ( NULL=0D );=0D =0D + VisitAllInstancesOfProtocol (=0D + &gEfiSerialIoProtocolGuid,=0D + AddDevicePathForOneSerialIoInstance,=0D + NULL=0D + );=0D +=0D Status =3D VisitAllInstancesOfProtocol (=0D &gEfiPciIoProtocolGuid,=0D DetectAndPreparePlatformPciDevicePath,=0D @@ -558,11 +500,6 @@ PlatformConsoleInit ( VOID=0D )=0D {=0D - gUartDeviceNode.BaudRate =3D PcdGet64 (PcdUartDefaultBaudRate);=0D - gUartDeviceNode.DataBits =3D PcdGet8 (PcdUartDefaultDataBits);=0D - gUartDeviceNode.Parity =3D PcdGet8 (PcdUartDefaultParity);=0D - gUartDeviceNode.StopBits =3D PcdGet8 (PcdUartDefaultStopBits);=0D -=0D ConnectRootBridge ();=0D =0D //=0D diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.= h b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.h index a13f4b8b59..2c7d21cc84 100644 --- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.h +++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.h @@ -21,7 +21,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include =0D =0D #define IS_PCI_ISA_PDECODE(_p) IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS= _BRIDGE_ISA_PDECODE, 0)=0D -#define IS_PCI_16550SERIAL(_p) IS_CLASS3 (_p, PCI_CLASS_SCC, PCI_SUBCLASS= _SERIAL, PCI_IF_16550)=0D =0D //=0D // Type definitions=0D --=20 2.32.0.windows.2