blob: 3e4e5606ccad09dd8bf7cb8d476c0a7e2e46cb2f [file] [log] [blame]
Vishal Bhoj82c80712015-12-15 21:13:33 +05301/** @file
2
3 Internal definitions for the VirtIo MMIO 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_MMIO_DEVICE_INTERNAL_H_
18#define _VIRTIO_MMIO_DEVICE_INTERNAL_H_
19
20#include <Protocol/VirtioDevice.h>
21
22#include <IndustryStandard/Virtio.h>
23
24#include <Library/DebugLib.h>
25#include <Library/IoLib.h>
26#include <Library/UefiLib.h>
27#include <Library/VirtioMmioDeviceLib.h>
28
29#define VIRTIO_MMIO_DEVICE_SIGNATURE SIGNATURE_32 ('V', 'M', 'I', 'O')
30
31typedef struct {
32 UINT32 Signature;
33 VIRTIO_DEVICE_PROTOCOL VirtioDevice;
34 PHYSICAL_ADDRESS BaseAddress;
35} VIRTIO_MMIO_DEVICE;
36
37#define VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE(Device) \
38 CR (Device, VIRTIO_MMIO_DEVICE, VirtioDevice, VIRTIO_MMIO_DEVICE_SIGNATURE)
39
40#define VIRTIO_CFG_WRITE(Device, Offset, Val) \
41 (MmioWrite32 (Device->BaseAddress + (Offset), Val))
42#define VIRTIO_CFG_READ(Device, Offset) \
43 (MmioRead32 (Device->BaseAddress + (Offset)))
44
45EFI_STATUS
46EFIAPI
47VirtioMmioDeviceRead (
48 IN VIRTIO_DEVICE_PROTOCOL *This,
49 IN UINTN FieldOFfset,
50 IN UINTN FieldSize,
51 IN UINTN BufferSize,
52 OUT VOID* Buffer
53 );
54
55EFI_STATUS
56EFIAPI
57VirtioMmioDeviceWrite (
58 IN VIRTIO_DEVICE_PROTOCOL *This,
59 IN UINTN FieldOffset,
60 IN UINTN FieldSize,
61 IN UINT64 Value
62 );
63
64EFI_STATUS
65EFIAPI
66VirtioMmioGetDeviceFeatures (
67 IN VIRTIO_DEVICE_PROTOCOL *This,
68 OUT UINT32 *DeviceFeatures
69 );
70
71EFI_STATUS
72EFIAPI
73VirtioMmioGetQueueAddress (
74 IN VIRTIO_DEVICE_PROTOCOL *This,
75 OUT UINT32 *QueueAddress
76 );
77
78EFI_STATUS
79EFIAPI
80VirtioMmioGetQueueSize (
81 IN VIRTIO_DEVICE_PROTOCOL *This,
82 OUT UINT16 *QueueNumMax
83 );
84
85EFI_STATUS
86EFIAPI
87VirtioMmioGetDeviceStatus (
88 IN VIRTIO_DEVICE_PROTOCOL *This,
89 OUT UINT8 *DeviceStatus
90 );
91
92EFI_STATUS
93EFIAPI
94VirtioMmioSetQueueSize (
95 VIRTIO_DEVICE_PROTOCOL *This,
96 UINT16 QueueSize
97 );
98
99EFI_STATUS
100EFIAPI
101VirtioMmioSetDeviceStatus (
102 VIRTIO_DEVICE_PROTOCOL *This,
103 UINT8 DeviceStatus
104 );
105
106EFI_STATUS
107EFIAPI
108VirtioMmioSetQueueNotify (
109 VIRTIO_DEVICE_PROTOCOL *This,
110 UINT16 QueueNotify
111 );
112
113EFI_STATUS
114EFIAPI
115VirtioMmioSetQueueSel (
116 VIRTIO_DEVICE_PROTOCOL *This,
117 UINT16 Sel
118 );
119
120EFI_STATUS
121VirtioMmioSetQueueAddress (
122 VIRTIO_DEVICE_PROTOCOL *This,
123 UINT32 Address
124 );
125
126EFI_STATUS
127EFIAPI
128VirtioMmioSetQueueAlignment (
129 VIRTIO_DEVICE_PROTOCOL *This,
130 UINT32 Alignment
131 );
132
133EFI_STATUS
134EFIAPI
135VirtioMmioSetPageSize (
136 VIRTIO_DEVICE_PROTOCOL *This,
137 UINT32 PageSize
138 );
139
140EFI_STATUS
141EFIAPI
142VirtioMmioSetGuestFeatures (
143 VIRTIO_DEVICE_PROTOCOL *This,
144 UINT32 Features
145 );
146
147#endif // _VIRTIO_MMIO_DEVICE_INTERNAL_H_