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.129.124]) by mx.groups.io with SMTP id smtpd.web10.49488.1683205940669330954 for ; Thu, 04 May 2023 06:12:20 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=R5DM58DN; spf=pass (domain: redhat.com, ip: 170.10.129.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683205939; 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=tGrea1eXYGIsWbvajJoQnVg+Mkgm0IR2NR3r5+I/YnM=; b=R5DM58DNtx6+50CulB3V6CbDbcNuSnZe7EJYJ9lr164daini9/ifyUfQ6qs2H09eEBHRGi bJYZNdAT1g7XrNvxLVAu12IDa68aomVf6BK/MWJtfAUTIBShGrKV+AEuE0bY1sk4V5OVV5 5n8IP48tMLCSAS5a/KT6PlAq+FqgPSo= 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-103-MIV9o6RjPxya27ck1BiI_g-1; Thu, 04 May 2023 09:12:11 -0400 X-MC-Unique: MIV9o6RjPxya27ck1BiI_g-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C14D7800B35; Thu, 4 May 2023 13:12:10 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C8B33C15BAE; Thu, 4 May 2023 13:12:06 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 332EE1800986; Thu, 4 May 2023 15:12:01 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Oliver Steffen , Stefan Berger , Anthony Perard , Jiewen Yao , Julien Grall , Pawel Polawski , Jordan Justen , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Ard Biesheuvel Subject: [PATCH v2 4/4] OvmfPkg/PlatformBootManagerLib: setup virtio serial console Date: Thu, 4 May 2023 15:12:01 +0200 Message-Id: <20230504131201.1026585-5-kraxel@redhat.com> In-Reply-To: <20230504131201.1026585-1-kraxel@redhat.com> References: <20230504131201.1026585-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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.40.1