From patchwork Tue Apr 9 11:08:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 10891049 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2312A17E6 for ; Tue, 9 Apr 2019 11:29:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 101CA23B24 for ; Tue, 9 Apr 2019 11:29:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 048962787C; Tue, 9 Apr 2019 11:29:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3B4BF2582C for ; Tue, 9 Apr 2019 11:29:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hDovL-0000tk-9J; Tue, 09 Apr 2019 11:28:19 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hDovJ-0000rL-TL for xen-devel@lists.xenproject.org; Tue, 09 Apr 2019 11:28:17 +0000 X-Inumbo-ID: 915f48b2-5aba-11e9-92d7-bc764e045a96 Received: from SMTP03.CITRIX.COM (unknown [162.221.156.55]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 915f48b2-5aba-11e9-92d7-bc764e045a96; Tue, 09 Apr 2019 11:28:16 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.60,329,1549929600"; d="scan'208";a="83096472" From: Anthony PERARD To: Date: Tue, 9 Apr 2019 12:08:41 +0100 Message-ID: <20190409110844.14746-29-anthony.perard@citrix.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190409110844.14746-1-anthony.perard@citrix.com> References: <20190409110844.14746-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 28/31] OvmfPkg/PlatformBootManagerLib: Use a Xen console for ConOut/ConIn X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel , Jordan Justen , Julien Grall , Anthony PERARD , xen-devel@lists.xenproject.org, Laszlo Ersek Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP On a Xen PVH guest, none of the existing serial or console interface works, so we add a new one, based on XenConsoleSerialPortLib, and implemeted via SerialDxe. That a simple console implementation that can works on both PVH guest and HVM guests, even if it rarely going to be use on HVM. Have PlatformBootManagerLib look for the new console, when running as a Xen guest. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Anthony PERARD --- Notes: v2: - Use MdeModulePkg/Universal/SerialDxe instead of something new. - Have PlatformInitializeConsole() look for it by using the known-in-advance device path for the xen console in the PLATFORM_CONSOLE_CONNECT_ENTRY. OvmfPkg/XenOvmf.dsc | 4 ++ OvmfPkg/XenOvmf.fdf | 1 + OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf | 4 ++ OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h | 1 + OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c | 10 +++- OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c | 59 ++++++++++++++++++++ 6 files changed, 78 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/XenOvmf.dsc b/OvmfPkg/XenOvmf.dsc index 35af05715b..a26f611058 100644 --- a/OvmfPkg/XenOvmf.dsc +++ b/OvmfPkg/XenOvmf.dsc @@ -599,6 +599,10 @@ [Components] OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf OvmfPkg/XenBusDxe/XenBusDxe.inf OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf + MdeModulePkg/Universal/SerialDxe/SerialDxe.inf { + + SerialPortLib|OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.inf + } MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf diff --git a/OvmfPkg/XenOvmf.fdf b/OvmfPkg/XenOvmf.fdf index d614bdce1d..e078c7b405 100644 --- a/OvmfPkg/XenOvmf.fdf +++ b/OvmfPkg/XenOvmf.fdf @@ -298,6 +298,7 @@ [FV.DXEFV] INF OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf INF OvmfPkg/XenBusDxe/XenBusDxe.inf INF OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf +INF MdeModulePkg/Universal/SerialDxe/SerialDxe.inf INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf diff --git a/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf index c41aaeef3f..7dd0683cd2 100644 --- a/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf +++ b/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf @@ -67,6 +67,10 @@ [Pcd] gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate ## CONSUMES + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits ## CONSUMES + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity ## CONSUMES + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits ## CONSUMES [Pcd.IA32, Pcd.X64] gEfiMdePkgTokenSpaceGuid.PcdFSBClock diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h index 4948ca6518..2ab1a76f6a 100644 --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h @@ -172,6 +172,7 @@ typedef struct { #define CONSOLE_IN BIT1 #define STD_ERROR BIT2 extern PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[]; +extern PLATFORM_CONSOLE_CONNECT_ENTRY gXenPlatformConsole[]; // // Platform BDS Functions diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c index 1a6d47732e..f186060f34 100644 --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c @@ -85,6 +85,13 @@ InstallDevicePathCallback ( VOID ); +STATIC +BOOLEAN +XenDetected ( + VOID + ); + + VOID PlatformRegisterFvBootOption ( EFI_GUID *FileGuid, @@ -404,7 +411,8 @@ PlatformBootManagerBeforeConsole ( // EfiBootManagerDispatchDeferredImages (); - PlatformInitializeConsole (gPlatformConsole); + PlatformInitializeConsole ( + XenDetected() ? gXenPlatformConsole : gPlatformConsole); PcdStatus = PcdSet16S (PcdPlatformBootTimeOut, GetFrontPageTimeoutFromQemu ()); ASSERT_RETURN_ERROR (PcdStatus); diff --git a/OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c b/OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c index 1250a6d351..4179370c81 100644 --- a/OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c +++ b/OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c @@ -16,6 +16,11 @@ #include "BdsPlatform.h" #include +#define SERIAL_DXE_FILE_GUID { \ + 0xD3987D4B, 0x971A, 0x435F, \ + { 0x8C, 0xAF, 0x49, 0x67, 0xEB, 0x62, 0x72, 0x41 } \ + } + // // Debug Agent UART Device Path structure // @@ -49,6 +54,18 @@ typedef struct { } VENDOR_RAMFB_DEVICE_PATH; #pragma pack () +// +// Xen Console Device Path structure +// +#pragma pack(1) +typedef struct { + VENDOR_DEVICE_PATH VendorHardware; + UART_DEVICE_PATH Uart; + VENDOR_DEVICE_PATH TerminalType; + EFI_DEVICE_PATH_PROTOCOL End; +} XEN_CONSOLE_DEVICE_PATH; +#pragma pack() + ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode = gPnpPs2Keyboard; ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode = gPnp16550ComPort; UART_DEVICE_PATH gUartDeviceNode = gUart; @@ -147,6 +164,37 @@ STATIC VENDOR_RAMFB_DEVICE_PATH gQemuRamfbDevicePath = { gEndEntire }; +STATIC XEN_CONSOLE_DEVICE_PATH gXenConsoleDevicePath = { + { + { + HARDWARE_DEVICE_PATH, + HW_VENDOR_DP, + { + (UINT8) (sizeof (VENDOR_DEVICE_PATH)), + (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) + } + }, + SERIAL_DXE_FILE_GUID + }, + { + { + MESSAGING_DEVICE_PATH, + MSG_UART_DP, + { + (UINT8) (sizeof (UART_DEVICE_PATH)), + (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8) + } + }, + 0, + FixedPcdGet64 (PcdUartDefaultBaudRate), + FixedPcdGet8 (PcdUartDefaultDataBits), + FixedPcdGet8 (PcdUartDefaultParity), + FixedPcdGet8 (PcdUartDefaultStopBits), + }, + gPcAnsiTerminal, + gEndEntire +}; + // // Predefined platform default console device path // @@ -169,6 +217,17 @@ PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = { } }; +PLATFORM_CONSOLE_CONNECT_ENTRY gXenPlatformConsole[] = { + { + (EFI_DEVICE_PATH_PROTOCOL *)&gXenConsoleDevicePath, + (CONSOLE_OUT | CONSOLE_IN | STD_ERROR) + }, + { + NULL, + 0 + } +}; + // // Predefined platform connect sequence //