From patchwork Wed Apr 6 12:40:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 65171 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1027589lbc; Wed, 6 Apr 2016 05:41:02 -0700 (PDT) X-Received: by 10.66.62.232 with SMTP id b8mr3906308pas.104.1459946449414; Wed, 06 Apr 2016 05:40:49 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id l17si4454981pfi.54.2016.04.06.05.40.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Apr 2016 05:40:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7ABFF1A1FB9; Wed, 6 Apr 2016 05:40:46 -0700 (PDT) X-Original-To: edk2-devel@ml01.01.org Delivered-To: edk2-devel@ml01.01.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 139DC1A1FAD for ; Wed, 6 Apr 2016 05:40:45 -0700 (PDT) Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A138AC057FA0; Wed, 6 Apr 2016 12:40:44 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com ([10.3.113.15]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u36CeV8R027635; Wed, 6 Apr 2016 08:40:43 -0400 From: Laszlo Ersek To: edk2-devel-01 Date: Wed, 6 Apr 2016 14:40:16 +0200 Message-Id: <1459946427-15771-7-git-send-email-lersek@redhat.com> In-Reply-To: <1459946427-15771-1-git-send-email-lersek@redhat.com> References: <1459946427-15771-1-git-send-email-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Subject: [edk2] [wave 3 PATCH v2 06/17] OvmfPkg: IndustryStandard: factor out Virtio095.h X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" In the upcoming virtio-1.0 series, we'll introduce "Virtio10.h". However, the "Virtio.h" header file should continue to expose the generic type and macro definitions for all virtio versions that OvmfPkg supports. Therefore extract "Virtio095.h" like this: Virtio.h -> Virtio095.h so that in the upcoming patches, we can insert "Virtio10.h" in the middle of the inclusion chain. This follows the example of "Acpi.h" and "Pci.h" under "MdePkg/Include/IndustryStandard". Cc: Jordan Justen Cc: Ard Biesheuvel Suggested-by: Jordan Justen Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek --- Notes: v2: - new in v2 [Jordan] OvmfPkg/Include/IndustryStandard/Virtio.h | 159 +------------------- OvmfPkg/Include/IndustryStandard/{Virtio.h => Virtio095.h} | 8 +- 2 files changed, 8 insertions(+), 159 deletions(-) -- 1.8.3.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/OvmfPkg/Include/IndustryStandard/Virtio.h b/OvmfPkg/Include/IndustryStandard/Virtio.h index fcf7b67431f9..e1682fc69a42 100644 --- a/OvmfPkg/Include/IndustryStandard/Virtio.h +++ b/OvmfPkg/Include/IndustryStandard/Virtio.h @@ -1,13 +1,13 @@ /** @file - Generic type and macro definitions corresponding to the virtio-0.9.5 - specification. + Generic type and macro definitions corresponding to the virtio + specifications. - Copyright (C) 2012, Red Hat, Inc. + Copyright (C) 2012-2016, Red Hat, Inc. Portion of Copyright (C) 2013, ARM Ltd. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -15,161 +15,10 @@ WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #ifndef _VIRTIO_H_ #define _VIRTIO_H_ -#include - -// -// VirtIo Subsystem Device IDs -// -#define VIRTIO_SUBSYSTEM_NETWORK_CARD 1 -#define VIRTIO_SUBSYSTEM_BLOCK_DEVICE 2 -#define VIRTIO_SUBSYSTEM_CONSOLE 3 -#define VIRTIO_SUBSYSTEM_ENTROPY_SOURCE 4 -#define VIRTIO_SUBSYSTEM_MEMORY_BALLOONING 5 -#define VIRTIO_SUBSYSTEM_IO_MEMORY 6 -#define VIRTIO_SUBSYSTEM_RPMSG 7 -#define VIRTIO_SUBSYSTEM_SCSI_HOST 8 -#define VIRTIO_SUBSYSTEM_9P_TRANSPORT 9 -#define VIRTIO_SUBSYSTEM_MAC80211_WLAN 10 - -// -// Virtio IDs -// -#define VIRTIO_VENDOR_ID 0x1AF4 -#define VIRTIO_MMIO_MAGIC 0x74726976 // "virt" - - -// -// VirtIo Device Specific Configuration Offsets -// -#define VIRTIO_DEVICE_SPECIFIC_CONFIGURATION_OFFSET_PCI 20 -#define VIRTIO_DEVICE_SPECIFIC_CONFIGURATION_OFFSET_PCI_WITH_MSI_X 24 -#define VIRTIO_DEVICE_SPECIFIC_CONFIGURATION_OFFSET_MMIO 0x100 - -// -// PCI VirtIo Header Offsets -// -#define VIRTIO_PCI_OFFSET_DEVICE_FEATURES 0x00 -#define VIRTIO_PCI_OFFSET_GUEST_FEATURES 0x04 -#define VIRTIO_PCI_OFFSET_QUEUE_ADDRESS 0x08 -#define VIRTIO_PCI_OFFSET_QUEUE_SIZE 0x0C -#define VIRTIO_PCI_OFFSET_QUEUE_SELECT 0x0E -#define VIRTIO_PCI_OFFSET_QUEUE_NOTIFY 0x10 -#define VIRTIO_PCI_OFFSET_QUEUE_DEVICE_STATUS 0x12 -#define VIRTIO_PCI_OFFSET_QUEUE_DEVICE_ISR 0x13 - -// -// MMIO VirtIo Header Offsets -// -#define VIRTIO_MMIO_OFFSET_MAGIC 0x00 -#define VIRTIO_MMIO_OFFSET_VERSION 0x04 -#define VIRTIO_MMIO_OFFSET_DEVICE_ID 0x08 -#define VIRTIO_MMIO_OFFSET_VENDOR_ID 0x0C -#define VIRTIO_MMIO_OFFSET_HOST_FEATURES 0x10 -#define VIRTIO_MMIO_OFFSET_HOST_FEATURES_SEL 0x14 -#define VIRTIO_MMIO_OFFSET_GUEST_FEATURES 0x20 -#define VIRTIO_MMIO_OFFSET_GUEST_FEATURES_SEL 0x24 -#define VIRTIO_MMIO_OFFSET_GUEST_PAGE_SIZE 0x28 -#define VIRTIO_MMIO_OFFSET_QUEUE_SEL 0x30 -#define VIRTIO_MMIO_OFFSET_QUEUE_NUM_MAX 0x34 -#define VIRTIO_MMIO_OFFSET_QUEUE_NUM 0x38 -#define VIRTIO_MMIO_OFFSET_QUEUE_ALIGN 0x3C -#define VIRTIO_MMIO_OFFSET_QUEUE_PFN 0x40 -#define VIRTIO_MMIO_OFFSET_QUEUE_NOTIFY 0x50 -#define VIRTIO_MMIO_OFFSET_INTERRUPT_STATUS 0x60 -#define VIRTIO_MMIO_OFFSET_INTERRUPT_ACK 0x64 -#define VIRTIO_MMIO_OFFSET_STATUS 0x70 - -// -// Data in the communication area is defined as packed and accessed as -// volatile. -// -// Some structures contain arrays with dynamically determined size. In such -// cases the array and its sibling fields are replaced with pointers. -// -// All indices (variables and fields named *Idx) are free-running and wrap -// around after 0xFFFF. The queue size reported by the host is always an -// integral power of 2, not greater than 32768. Actual array indices are -// consistently calculated by taking the remainder of a given Idx object modulo -// QueueSize. Since 0x10000 is an integral multiple of the QueueSize, UINT16 -// wraparound is a correct wraparound modulo QueueSize too (it doesn't offset -// the remainder class). -// -// virtio-0.9.5, 2.3.4 Available Ring -// -#define VRING_AVAIL_F_NO_INTERRUPT BIT0 - -typedef struct { - volatile UINT16 *Flags; - volatile UINT16 *Idx; - - volatile UINT16 *Ring; // QueueSize elements - volatile UINT16 *UsedEvent; // unused as per negotiation -} VRING_AVAIL; - - -// -// virtio-0.9.5, 2.3.5 Used Ring -// -#define VRING_USED_F_NO_NOTIFY BIT0 - -#pragma pack(1) -typedef struct { - UINT32 Id; - UINT32 Len; -} VRING_USED_ELEM; -#pragma pack() - -typedef struct { - volatile UINT16 *Flags; - volatile UINT16 *Idx; - volatile VRING_USED_ELEM *UsedElem; // QueueSize elements - volatile UINT16 *AvailEvent; // unused as per negotiation -} VRING_USED; - - -// -// virtio-0.9.5, 2.3.2 Descriptor Table -// -#define VRING_DESC_F_NEXT BIT0 // more descriptors in this request -#define VRING_DESC_F_WRITE BIT1 // buffer to be written *by the host* -#define VRING_DESC_F_INDIRECT BIT2 // unused - -#pragma pack(1) -typedef struct { - UINT64 Addr; - UINT32 Len; - UINT16 Flags; - UINT16 Next; -} VRING_DESC; -#pragma pack() - -typedef struct { - UINTN NumPages; - VOID *Base; // deallocate only this field - volatile VRING_DESC *Desc; // QueueSize elements - VRING_AVAIL Avail; - VRING_USED Used; - UINT16 QueueSize; -} VRING; - -// -// virtio-0.9.5, 2.2.2.1 Device Status -// -#define VSTAT_ACK BIT0 -#define VSTAT_DRIVER BIT1 -#define VSTAT_DRIVER_OK BIT2 -#define VSTAT_FAILED BIT7 - -// -// virtio-0.9.5, Appendix B: Reserved (Device-Independent) Feature Bits -// -#define VIRTIO_F_NOTIFY_ON_EMPTY BIT24 -#define VIRTIO_F_RING_INDIRECT_DESC BIT28 -#define VIRTIO_F_RING_EVENT_IDX BIT29 - +#include #endif // _VIRTIO_H_ diff --git a/OvmfPkg/Include/IndustryStandard/Virtio.h b/OvmfPkg/Include/IndustryStandard/Virtio095.h similarity index 94% copy from OvmfPkg/Include/IndustryStandard/Virtio.h copy to OvmfPkg/Include/IndustryStandard/Virtio095.h index fcf7b67431f9..6bf77cb32075 100644 --- a/OvmfPkg/Include/IndustryStandard/Virtio.h +++ b/OvmfPkg/Include/IndustryStandard/Virtio095.h @@ -1,27 +1,27 @@ /** @file Generic type and macro definitions corresponding to the virtio-0.9.5 specification. - Copyright (C) 2012, Red Hat, Inc. + Copyright (C) 2012-2016, Red Hat, Inc. Portion of Copyright (C) 2013, ARM Ltd. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ -#ifndef _VIRTIO_H_ -#define _VIRTIO_H_ +#ifndef _VIRTIO_0_9_5_H_ +#define _VIRTIO_0_9_5_H_ #include // // VirtIo Subsystem Device IDs // #define VIRTIO_SUBSYSTEM_NETWORK_CARD 1 @@ -168,8 +168,8 @@ typedef struct { // virtio-0.9.5, Appendix B: Reserved (Device-Independent) Feature Bits // #define VIRTIO_F_NOTIFY_ON_EMPTY BIT24 #define VIRTIO_F_RING_INDIRECT_DESC BIT28 #define VIRTIO_F_RING_EVENT_IDX BIT29 -#endif // _VIRTIO_H_ +#endif // _VIRTIO_0_9_5_H_