From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web08.2661.1652352917194448306 for ; Thu, 12 May 2022 03:55:19 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=kvlVyf21; spf=pass (domain: intel.com, ip: 192.55.52.115, 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=1652352918; x=1683888918; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=x56U7t+71Ymo2Mef41T/QFRgLX0GDYn7CO3cygk/9lQ=; b=kvlVyf21X3r5eYUw2xGgHWnK51mZMmZisfbNTx2HC9FRvqShxCQMzZ2Y zM/syciHucrKrBCplbcCLFTRVbQQycRZkfwBhoobXy78klEgBNZSjUpU/ VCsTNpzwDsECgTxJ4NoYUM4MsGJmuAfWPc8yh9+qnxxgRL1EunQGJOoDL nkg9giaS6n+dZrxX9VogbrtdST0zcfzqQMteFQPr1e0nKxRtNPYpNhcGa d94TgXj4uh8UE1flPL27NnAeDOn6gu+8lfzwURVjMqaZQRt4NTSWs+F6y OdD9Cn+duUtmcEMKWlZdgKXDB4p2EbMK/OXQI+mMoM5CP9Hz85h3pKRbj Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10344"; a="270094643" X-IronPort-AV: E=Sophos;i="5.91,219,1647327600"; d="scan'208";a="270094643" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2022 03:55:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,219,1647327600"; d="scan'208";a="566627458" Received: from shwdesfp01.ccr.corp.intel.com ([10.239.158.158]) by orsmga007.jf.intel.com with ESMTP; 12 May 2022 03:55:16 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Guo Dong , Ray Ni , Maurice Ma , Benjamin You , Sean Rhodes Subject: [PATCH v2 2/3] UefiPayloadPkg: Add Serial IO device path according to related protocol Date: Thu, 12 May 2022 18:54:58 +0800 Message-Id: <03aeca65da52907434e14d1f9fbd1c0651874257.1652351830.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 | 146 +++++------------- .../PlatformBootManagerLib/PlatformConsole.h | 1 - 3 files changed, 41 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 75aafebccd..5aece6636f 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 @@ -447,18 +360,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 @@ -476,6 +377,39 @@ 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 +=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 + )=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 @@ -500,6 +434,11 @@ DetectAndPreparePlatformPciDevicePaths ( NULL=0D );=0D =0D + VisitAllInstancesOfProtocol (=0D + &gEfiSerialIoProtocolGuid,=0D + AddDevicePathForOneSerialIoInstance=0D + );=0D +=0D Status =3D VisitAllInstancesOfProtocol (=0D &gEfiPciIoProtocolGuid,=0D DetectAndPreparePlatformPciDevicePath=0D @@ -552,11 +491,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 3713c21c45..6889c897ad 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