• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /** @file
2 
3   Internal definitions for the VirtIo PCI Device driver
4 
5   Copyright (C) 2013, ARM Ltd
6 
7   This program and the accompanying materials are licensed and made available
8   under the terms and conditions of the BSD License which accompanies this
9   distribution. The full text of the license may be found at
10   http://opensource.org/licenses/bsd-license.php
11 
12   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
13   WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 
15 **/
16 
17 #ifndef _VIRTIO_PCI_DEVICE_DXE_H_
18 #define _VIRTIO_PCI_DEVICE_DXE_H_
19 
20 #include <Protocol/ComponentName.h>
21 #include <Protocol/DriverBinding.h>
22 #include <Protocol/PciIo.h>
23 #include <Protocol/VirtioDevice.h>
24 
25 #include <IndustryStandard/Virtio.h>
26 
27 #define VIRTIO_PCI_DEVICE_SIGNATURE   SIGNATURE_32 ('V', 'P', 'C', 'I')
28 
29 typedef struct {
30   UINT32                 Signature;
31   VIRTIO_DEVICE_PROTOCOL VirtioDevice;
32   EFI_PCI_IO_PROTOCOL   *PciIo;
33   UINT64                 OriginalPciAttributes;
34   UINT32                 DeviceSpecificConfigurationOffset;
35 } VIRTIO_PCI_DEVICE;
36 
37 #define VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE(Device) \
38     CR (Device, VIRTIO_PCI_DEVICE, VirtioDevice, VIRTIO_PCI_DEVICE_SIGNATURE)
39 
40 
41 EFI_STATUS
42 EFIAPI
43 VirtioPciIoRead (
44   IN  VIRTIO_PCI_DEVICE         *Dev,
45   IN  UINTN                      FieldOffset,
46   IN  UINTN                      FieldSize,
47   IN  UINTN                      BufferSize,
48   OUT VOID                       *Buffer
49   );
50 
51 EFI_STATUS
52 EFIAPI
53 VirtioPciIoWrite (
54   IN  VIRTIO_PCI_DEVICE         *Dev,
55   IN UINTN                       FieldOffset,
56   IN UINTN                       FieldSize,
57   IN UINT64                      Value
58   );
59 
60 /********************************************
61  * PCI Functions for VIRTIO_DEVICE_PROTOCOL
62  *******************************************/
63 EFI_STATUS
64 EFIAPI
65 VirtioPciDeviceRead (
66   IN  VIRTIO_DEVICE_PROTOCOL     *This,
67   IN  UINTN                      FieldOffset,
68   IN  UINTN                      FieldSize,
69   IN  UINTN                      BufferSize,
70   OUT VOID                       *Buffer
71   );
72 
73 EFI_STATUS
74 EFIAPI
75 VirtioPciDeviceWrite (
76   IN VIRTIO_DEVICE_PROTOCOL      *This,
77   IN UINTN                       FieldOffset,
78   IN UINTN                       FieldSize,
79   IN UINT64                      Value
80   );
81 
82 EFI_STATUS
83 EFIAPI
84 VirtioPciGetDeviceFeatures (
85   IN VIRTIO_DEVICE_PROTOCOL *This,
86   OUT UINT64                *DeviceFeatures
87   );
88 
89 EFI_STATUS
90 EFIAPI
91 VirtioPciGetQueueSize (
92   IN  VIRTIO_DEVICE_PROTOCOL  *This,
93   OUT UINT16                  *QueueNumMax
94   );
95 
96 EFI_STATUS
97 EFIAPI
98 VirtioPciSetQueueAlignment (
99   VIRTIO_DEVICE_PROTOCOL         *This,
100   UINT32                         Alignment
101   );
102 
103 EFI_STATUS
104 EFIAPI
105 VirtioPciSetPageSize (
106   VIRTIO_DEVICE_PROTOCOL         *This,
107   UINT32                         PageSize
108   );
109 
110 EFI_STATUS
111 EFIAPI
112 VirtioPciGetDeviceStatus (
113   IN  VIRTIO_DEVICE_PROTOCOL  *This,
114   OUT UINT8                   *DeviceStatus
115   );
116 
117 EFI_STATUS
118 EFIAPI
119 VirtioPciSetGuestFeatures (
120   IN VIRTIO_DEVICE_PROTOCOL  *This,
121   IN UINT64                   Features
122   );
123 
124 EFI_STATUS
125 EFIAPI
126 VirtioPciSetQueueAddress (
127   IN VIRTIO_DEVICE_PROTOCOL  *This,
128   IN VRING                   *Ring
129   );
130 
131 EFI_STATUS
132 EFIAPI
133 VirtioPciSetQueueSel (
134   VIRTIO_DEVICE_PROTOCOL         *This,
135   UINT16                         Sel
136   );
137 
138 EFI_STATUS
139 EFIAPI
140 VirtioPciSetQueueNotify (
141   VIRTIO_DEVICE_PROTOCOL         *This,
142   UINT16                         Index
143   );
144 
145 EFI_STATUS
146 EFIAPI
147 VirtioPciSetQueueSize (
148   VIRTIO_DEVICE_PROTOCOL         *This,
149   UINT16                         Size
150   );
151 
152 EFI_STATUS
153 EFIAPI
154 VirtioPciSetDeviceStatus (
155   VIRTIO_DEVICE_PROTOCOL         *This,
156   UINT8                          DeviceStatus
157   );
158 
159 #endif // _VIRTIO_PCI_DEVICE_DXE_H_
160