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.web09.66198.1629357932549949887 for ; Thu, 19 Aug 2021 00:25:32 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Y8dnYKMz; 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=1629357931; 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=NLf9o13wFsl0arBi+sLHWCdNDhbeE65O9IP5plwYQ7U=; b=Y8dnYKMzr5JGRZ5Te1SdLMXH0t/uEn2pZbMRVwShyBnP6f1g2cMImpSPb/ffRD0QoH9Td4 8AcuG9cfmwgoRpfCZOcFTzb9HMvU69YXfM0b63O9ulotplH7kbMzyV8C3/BxAChYgVnAtb tL/QyumwXSTZm2LkdZoUZk9Xt+TaYfg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-104-beSr0qcKOtOP-0IOQva1Xw-1; Thu, 19 Aug 2021 03:25:30 -0400 X-MC-Unique: beSr0qcKOtOP-0IOQva1Xw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B41F18799E0 for ; Thu, 19 Aug 2021 07:25:29 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.193.216]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7BE1EBA6F; Thu, 19 Aug 2021 07:25:25 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id B16AB180079B; Thu, 19 Aug 2021 09:25:17 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Gerd Hoffmann Subject: [PATCH v4 2/7] OvmfPkg/VirtioMmioDeviceLib: Add virtio 1.0 detection. Date: Thu, 19 Aug 2021 09:25:12 +0200 Message-Id: <20210819072517.1565797-3-kraxel@redhat.com> In-Reply-To: <20210819072517.1565797-1-kraxel@redhat.com> References: <20210819072517.1565797-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Add #defines for the Version field. Read and store the version, log the version found as info message. Continue to return UNSUPPORTED for now, we need some more patches to complete virtio 1.0 support first. Signed-off-by: Gerd Hoffmann --- .../VirtioMmioDeviceLib/VirtioMmioDevice.h | 4 ++++ .../VirtioMmioDeviceLib/VirtioMmioDevice.c | 17 +++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h index ab53b90d51c9..0c2f99633c46 100644 --- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h +++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h @@ -23,9 +23,13 @@ #include #define VIRTIO_MMIO_DEVICE_SIGNATURE SIGNATURE_32 ('V', 'M', 'I', 'O') +#define VIRTIO_MMIO_DEVICE_VERSION_0_95 1 +#define VIRTIO_MMIO_DEVICE_VERSION_1_00 2 + typedef struct { UINT32 Signature; + UINT32 Version; VIRTIO_DEVICE_PROTOCOL VirtioDevice; PHYSICAL_ADDRESS BaseAddress; } VIRTIO_MMIO_DEVICE; diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c index 6dbbba008c75..0c92f5373151 100644 --- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c +++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c @@ -58,7 +58,6 @@ VirtioMmioInit ( ) { UINT32 MagicValue; - UINT32 Version; // // Initialize VirtIo Mmio Device @@ -66,7 +65,6 @@ VirtioMmioInit ( CopyMem (&Device->VirtioDevice, &mMmioDeviceProtocolTemplate, sizeof (VIRTIO_DEVICE_PROTOCOL)); Device->BaseAddress = BaseAddress; - Device->VirtioDevice.Revision = VIRTIO_SPEC_REVISION (0, 9, 5); Device->VirtioDevice.SubSystemDeviceId = MmioRead32 (BaseAddress + VIRTIO_MMIO_OFFSET_DEVICE_ID); @@ -78,8 +76,19 @@ VirtioMmioInit ( return EFI_UNSUPPORTED; } - Version = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_VERSION); - if (Version != 1) { + Device->Version = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_VERSION); + switch (Device->Version) { + case VIRTIO_MMIO_DEVICE_VERSION_0_95: + DEBUG ((DEBUG_INFO, "%a virtio 0.9.5, id %d\n", __FUNCTION__, + Device->VirtioDevice.SubSystemDeviceId)); + Device->VirtioDevice.Revision = VIRTIO_SPEC_REVISION (0, 9, 5); + break; + case VIRTIO_MMIO_DEVICE_VERSION_1_00: + DEBUG ((DEBUG_INFO, "%a virtio 1.0, id %d\n", __FUNCTION__, + Device->VirtioDevice.SubSystemDeviceId)); + Device->VirtioDevice.Revision = VIRTIO_SPEC_REVISION (1, 0, 0); + return EFI_UNSUPPORTED; + default: return EFI_UNSUPPORTED; } -- 2.31.1