• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /** @file
2   Definitions from the VirtIo 1.0 specification (csprd05).
3 
4   Copyright (C) 2016, Red Hat, Inc.
5 
6   This program and the accompanying materials are licensed and made available
7   under the terms and conditions of the BSD License which accompanies this
8   distribution. The full text of the license may be found at
9   http://opensource.org/licenses/bsd-license.php
10 
11   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
12   WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 **/
14 
15 #ifndef _VIRTIO_1_0_H_
16 #define _VIRTIO_1_0_H_
17 
18 #include <IndustryStandard/Virtio095.h>
19 
20 //
21 // Subsystem Device IDs (to be) introduced in VirtIo 1.0
22 //
23 #define VIRTIO_SUBSYSTEM_GPU_DEVICE         16
24 
25 //
26 // Structures for parsing the VirtIo 1.0 specific PCI capabilities from the
27 // config space
28 //
29 #pragma pack (1)
30 typedef struct {
31   UINT8 CapId;   // Capability identifier (generic)
32   UINT8 CapNext; // Link to next capability (generic)
33 } VIRTIO_PCI_CAP_LINK;
34 
35 typedef struct {
36   UINT8  ConfigType; // Identifies the specific VirtIo 1.0 config structure
37   UINT8  Bar;        // The BAR that contains the structure
38   UINT8  Padding[3];
39   UINT32 Offset;     // Offset within Bar until the start of the structure
40   UINT32 Length;     // Length of the structure
41 } VIRTIO_PCI_CAP;
42 #pragma pack ()
43 
44 //
45 // Values for the VIRTIO_PCI_CAP.ConfigType field
46 //
47 #define VIRTIO_PCI_CAP_COMMON_CFG 1 // Common configuration
48 #define VIRTIO_PCI_CAP_NOTIFY_CFG 2 // Notifications
49 #define VIRTIO_PCI_CAP_DEVICE_CFG 4 // Device specific configuration
50 
51 //
52 // Structure pointed-to by Bar and Offset in VIRTIO_PCI_CAP when ConfigType is
53 // VIRTIO_PCI_CAP_COMMON_CFG
54 //
55 #pragma pack (1)
56 typedef struct {
57   UINT32 DeviceFeatureSelect;
58   UINT32 DeviceFeature;
59   UINT32 DriverFeatureSelect;
60   UINT32 DriverFeature;
61   UINT16 MsixConfig;
62   UINT16 NumQueues;
63   UINT8  DeviceStatus;
64   UINT8  ConfigGeneration;
65   UINT16 QueueSelect;
66   UINT16 QueueSize;
67   UINT16 QueueMsixVector;
68   UINT16 QueueEnable;
69   UINT16 QueueNotifyOff;
70   UINT64 QueueDesc;
71   UINT64 QueueAvail;
72   UINT64 QueueUsed;
73 } VIRTIO_PCI_COMMON_CFG;
74 #pragma pack ()
75 
76 //
77 // VirtIo 1.0 device status bits
78 //
79 #define VSTAT_FEATURES_OK BIT3
80 
81 //
82 // VirtIo 1.0 reserved (device-independent) feature bits
83 //
84 #define VIRTIO_F_VERSION_1 BIT32
85 
86 #endif // _VIRTIO_1_0_H_
87