From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web10.50084.1681722211414100293 for ; Mon, 17 Apr 2023 02:03:31 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Lf8G5kUb; spf=pass (domain: redhat.com, ip: 170.10.133.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681722210; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a/LbtiTZXHWaMDUE2aFgvY7MotOWzD6L7nchC9LBAcg=; b=Lf8G5kUb4DPkF4NMhzHZ7p33Izj+tGcjmzSIC98LVCcKRCE4t1tjzyrrVLzknOsqpkuh3n a+3MXOPObkATAIAT8fnJsyvkYtIteWKUJ0oj+5XHsnLW+N/9HcGqzabcKCUat7YBD6QkAQ U6EJPdwz0/g7GV2k8oY9xFjqsVAhpe8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-616-pbL2ys1SOR61iSbxbyQp3A-1; Mon, 17 Apr 2023 05:03:27 -0400 X-MC-Unique: pbL2ys1SOR61iSbxbyQp3A-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1C40F884EC1; Mon, 17 Apr 2023 09:03:27 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.193.149]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C981C40CFD40; Mon, 17 Apr 2023 09:03:26 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 17B8618003A1; Mon, 17 Apr 2023 11:03:20 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Stefan Berger , Julien Grall , Anthony Perard , Ard Biesheuvel , Jordan Justen , Pawel Polawski , Oliver Steffen , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Jiewen Yao , Gerd Hoffmann Subject: [PATCH 4/4] OvmfPkg/PlatformBootManagerLib: setup virtio serial console Date: Mon, 17 Apr 2023 11:03:20 +0200 Message-Id: <20230417090320.225046-5-kraxel@redhat.com> In-Reply-To: <20230417090320.225046-1-kraxel@redhat.com> References: <20230417090320.225046-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true In case a virtio-serial device is present in the system register the first serial port as console. Signed-off-by: Gerd Hoffmann --- .../PlatformBootManagerLib/BdsPlatform.c | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c index a90076c9e672..3b7dc53e9f86 100644 --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c @@ -976,6 +976,45 @@ PreparePciSerialDevicePath ( return EFI_SUCCESS; } +EFI_STATUS +PrepareVirtioSerialDevicePath ( + IN EFI_HANDLE DeviceHandle + ) +{ + EFI_STATUS Status; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + + DevicePath = NULL; + Status = gBS->HandleProtocol ( + DeviceHandle, + &gEfiDevicePathProtocolGuid, + (VOID *)&DevicePath + ); + if (EFI_ERROR (Status)) { + return Status; + } + + gPnp16550ComPortDeviceNode.UID = 0; + DevicePath = AppendDevicePathNode ( + DevicePath, + (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode + ); + DevicePath = AppendDevicePathNode ( + DevicePath, + (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode + ); + DevicePath = AppendDevicePathNode ( + DevicePath, + (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode + ); + + EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL); + EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL); + EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL); + + return EFI_SUCCESS; +} + EFI_STATUS VisitAllInstancesOfProtocol ( IN EFI_GUID *Id, @@ -1144,6 +1183,14 @@ DetectAndPreparePlatformPciDevicePath ( return EFI_SUCCESS; } + if (((Pci->Hdr.VendorId == 0x1af4) && (Pci->Hdr.DeviceId == 0x1003)) || + ((Pci->Hdr.VendorId == 0x1af4) && (Pci->Hdr.DeviceId == 0x1043))) + { + DEBUG ((DEBUG_INFO, "Found virtio serial device\n")); + PrepareVirtioSerialDevicePath (Handle); + return EFI_SUCCESS; + } + return Status; } -- 2.39.2