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.28949.1685620641012832327 for ; Thu, 01 Jun 2023 04:57:21 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EV2jDQW2; 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=1685620640; 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=A5oAE10fYXAOEZOAII7NmwkS3zQJG/smWzjri5GQ8To=; b=EV2jDQW2MOfN54L/Nt3OzrlfoJUGlJYAKwUPrlQs+ijc59g7mjHrvy4mRXOLIuvLi/LoDz TDMi8rfHSWkklKUSUxeUAXAyPLje5ucr93TI2014k5q0mHHHQVyAg7tmfA+6uqIwFvXx1U /vejgDNuxpn2pGb0TZWS9eAE6o+snIc= 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-465-8RO-WWwRN4uvZP9T0PJQLQ-1; Thu, 01 Jun 2023 07:57:17 -0400 X-MC-Unique: 8RO-WWwRN4uvZP9T0PJQLQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A26E085A5BA; Thu, 1 Jun 2023 11:57:16 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.155]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6107440C6EC4; Thu, 1 Jun 2023 11:57:16 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id C417E180098E; Thu, 1 Jun 2023 13:57:13 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Jiewen Yao , Gerd Hoffmann , Leif Lindholm , Ard Biesheuvel , Oliver Steffen , Pawel Polawski , Jordan Justen , Sami Mujawar , Ard Biesheuvel Subject: [PATCH v2 3/4] ArmVirt/PlatformBootManagerLib: factor out IsVirtioPci() Date: Thu, 1 Jun 2023 13:57:12 +0200 Message-Id: <20230601115713.1212372-4-kraxel@redhat.com> In-Reply-To: <20230601115713.1212372-1-kraxel@redhat.com> References: <20230601115713.1212372-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true IsVirtioPciRng() becomes just a thin wrapper for IsVirtioPci(). This allows to add similar thin wrappers for other virtio devices in the future. Signed-off-by: Gerd Hoffmann Reviewed-by: Ard Biesheuvel --- .../PlatformBootManagerLib/PlatformBm.c | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c b/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c index 5eb6f0f9c14a..ed38c42a43ee 100644 --- a/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c +++ b/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c @@ -313,15 +313,16 @@ IsVirtioRng ( } /** - This FILTER_FUNCTION checks if a handle corresponds to a Virtio RNG device at - the EFI_PCI_IO_PROTOCOL level. + This function checks if a handle corresponds to the Virtio Device ID given + at the EFI_PCI_IO_PROTOCOL level. **/ STATIC BOOLEAN EFIAPI -IsVirtioPciRng ( +IsVirtioPci ( IN EFI_HANDLE Handle, - IN CONST CHAR16 *ReportText + IN CONST CHAR16 *ReportText, + IN UINT16 VirtIoDeviceId ) { EFI_STATUS Status; @@ -387,11 +388,11 @@ IsVirtioPciRng ( // // From DeviceId and RevisionId, determine whether the device is a // modern-only Virtio 1.0 device. In case of Virtio 1.0, DeviceId can - // immediately be restricted to VIRTIO_SUBSYSTEM_ENTROPY_SOURCE, and + // immediately be restricted to VirtIoDeviceId, and // SubsystemId will only play a sanity-check role. Otherwise, DeviceId can // only be sanity-checked, and SubsystemId will decide. // - if ((DeviceId == 0x1040 + VIRTIO_SUBSYSTEM_ENTROPY_SOURCE) && + if ((DeviceId == 0x1040 + VirtIoDeviceId) && (RevisionId >= 0x01)) { Virtio10 = TRUE; @@ -419,7 +420,7 @@ IsVirtioPciRng ( return TRUE; } - if (!Virtio10 && (SubsystemId == VIRTIO_SUBSYSTEM_ENTROPY_SOURCE)) { + if (!Virtio10 && (SubsystemId == VirtIoDeviceId)) { return TRUE; } @@ -430,6 +431,21 @@ IsVirtioPciRng ( return FALSE; } +/** + This FILTER_FUNCTION checks if a handle corresponds to a Virtio RNG device at + the EFI_PCI_IO_PROTOCOL level. +**/ +STATIC +BOOLEAN +EFIAPI +IsVirtioPciRng ( + IN EFI_HANDLE Handle, + IN CONST CHAR16 *ReportText + ) +{ + return IsVirtioPci (Handle, ReportText, VIRTIO_SUBSYSTEM_ENTROPY_SOURCE); +} + /** This CALLBACK_FUNCTION attempts to connect a handle non-recursively, asking the matching driver to produce all first-level child handles. -- 2.40.1