blob: 6311ae849d182b61bb49203309ebada420711b78 [file] [log] [blame]
Vishal Bhoj82c80712015-12-15 21:13:33 +05301/** @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
29typedef 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
41EFI_STATUS
42EFIAPI
43VirtioPciIoRead (
44 IN VIRTIO_PCI_DEVICE *Dev,
45 IN UINTN FieldOffset,
46 IN UINTN FieldSize,
47 IN UINTN BufferSize,
48 OUT VOID *Buffer
49 );
50
51EFI_STATUS
52EFIAPI
53VirtioPciIoWrite (
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 *******************************************/
63EFI_STATUS
64EFIAPI
65VirtioPciDeviceRead (
66 IN VIRTIO_DEVICE_PROTOCOL *This,
67 IN UINTN FieldOffset,
68 IN UINTN FieldSize,
69 IN UINTN BufferSize,
70 OUT VOID *Buffer
71 );
72
73EFI_STATUS
74EFIAPI
75VirtioPciDeviceWrite (
76 IN VIRTIO_DEVICE_PROTOCOL *This,
77 IN UINTN FieldOffset,
78 IN UINTN FieldSize,
79 IN UINT64 Value
80 );
81
82EFI_STATUS
83EFIAPI
84VirtioPciGetDeviceFeatures (
85 IN VIRTIO_DEVICE_PROTOCOL *This,
86 OUT UINT32 *DeviceFeatures
87 );
88
89EFI_STATUS
90EFIAPI
91VirtioPciGetQueueAddress (
92 IN VIRTIO_DEVICE_PROTOCOL *This,
93 OUT UINT32 *QueueAddress
94 );
95
96EFI_STATUS
97EFIAPI
98VirtioPciGetQueueSize (
99 IN VIRTIO_DEVICE_PROTOCOL *This,
100 OUT UINT16 *QueueNumMax
101 );
102
103EFI_STATUS
104EFIAPI
105VirtioPciSetQueueAlignment (
106 VIRTIO_DEVICE_PROTOCOL *This,
107 UINT32 Alignment
108 );
109
110EFI_STATUS
111EFIAPI
112VirtioPciSetPageSize (
113 VIRTIO_DEVICE_PROTOCOL *This,
114 UINT32 PageSize
115 );
116
117EFI_STATUS
118EFIAPI
119VirtioPciGetDeviceStatus (
120 IN VIRTIO_DEVICE_PROTOCOL *This,
121 OUT UINT8 *DeviceStatus
122 );
123
124EFI_STATUS
125EFIAPI
126VirtioPciSetGuestFeatures (
127 IN VIRTIO_DEVICE_PROTOCOL *This,
128 IN UINT32 Features
129 );
130
131EFI_STATUS
132EFIAPI
133VirtioPciSetQueueAddress (
134 VIRTIO_DEVICE_PROTOCOL *This,
135 UINT32 Address
136 );
137
138EFI_STATUS
139EFIAPI
140VirtioPciSetQueueSel (
141 VIRTIO_DEVICE_PROTOCOL *This,
142 UINT16 Sel
143 );
144
145EFI_STATUS
146EFIAPI
147VirtioPciSetQueueNotify (
148 VIRTIO_DEVICE_PROTOCOL *This,
149 UINT16 Index
150 );
151
152EFI_STATUS
153EFIAPI
154VirtioPciSetQueueSize (
155 VIRTIO_DEVICE_PROTOCOL *This,
156 UINT16 Size
157 );
158
159EFI_STATUS
160EFIAPI
161VirtioPciSetDeviceStatus (
162 VIRTIO_DEVICE_PROTOCOL *This,
163 UINT8 DeviceStatus
164 );
165
166#endif // _VIRTIO_PCI_DEVICE_DXE_H_