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.web11.26218.1683901397233772850 for ; Fri, 12 May 2023 07:23:17 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DJItP3VD; 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=1683901396; 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=pr+l7U6e18jJwRn/5O9CHG+ZP9u2X+z/WPat2br35MI=; b=DJItP3VDnOQXVollOf7ilwhJfa3FZ0ptPAmaVbZLoouhemYyEomiAIOd7+Oab5j9CVbZC1 dNZoJlVJiE+n2JO3j7CJLUDpbd1Pd4BDZiyIhO9mWAAWEUDi7gncx1P2e2jhP0w9f25BBc 5H/lqOOTseH60dfEg6ldP9AXma8gTyg= 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-634-u4-alTkUNUuKoEtmb24YZw-1; Fri, 12 May 2023 10:23:11 -0400 X-MC-Unique: u4-alTkUNUuKoEtmb24YZw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6C61B101A54F; Fri, 12 May 2023 14:23:11 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2E9C1400E89; Fri, 12 May 2023 14:23:10 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id B59221800908; Fri, 12 May 2023 16:23:06 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Gerd Hoffmann , Jiewen Yao , Jordan Justen , Leif Lindholm , Pawel Polawski , Sami Mujawar , Oliver Steffen , Ard Biesheuvel Subject: [PATCH 3/5] ArmVirt/PlatformBootManagerLib: factor out IsVirtioPci() Date: Fri, 12 May 2023 16:23:04 +0200 Message-Id: <20230512142306.1323983-4-kraxel@redhat.com> In-Reply-To: <20230512142306.1323983-1-kraxel@redhat.com> References: <20230512142306.1323983-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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 --- .../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