]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/VirtioScsiDxe/VirtioScsi.h
OvmfPkg/AmdSevDxe: decrypt the pages of the initial SMRAM save state map
[mirror_edk2.git] / OvmfPkg / VirtioScsiDxe / VirtioScsi.h
1 /** @file
2
3 Internal definitions for the virtio-scsi driver, which produces Extended SCSI
4 Pass Thru Protocol instances for virtio-scsi devices.
5
6 Copyright (C) 2012, Red Hat, Inc.
7
8 This program and the accompanying materials are licensed and made available
9 under the terms and conditions of the BSD License which accompanies this
10 distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
14 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 **/
17
18 #ifndef _VIRTIO_SCSI_DXE_H_
19 #define _VIRTIO_SCSI_DXE_H_
20
21 #include <Protocol/ComponentName.h>
22 #include <Protocol/DriverBinding.h>
23 #include <Protocol/ScsiPassThruExt.h>
24
25 #include <IndustryStandard/Virtio.h>
26
27
28 //
29 // This driver supports 2-byte target identifiers and 4-byte LUN identifiers.
30 //
31 // EFI_EXT_SCSI_PASS_THRU_PROTOCOL provides TARGET_MAX_BYTES bytes for target
32 // identification, and 8 bytes for LUN identification.
33 //
34 // EFI_EXT_SCSI_PASS_THRU_MODE.AdapterId is also a target identifier,
35 // consisting of 4 bytes. Make sure TARGET_MAX_BYTES can accommodate both
36 // AdapterId and our target identifiers.
37 //
38 #if TARGET_MAX_BYTES < 4
39 # error "virtio-scsi requires TARGET_MAX_BYTES >= 4"
40 #endif
41
42
43 #define VSCSI_SIG SIGNATURE_32 ('V', 'S', 'C', 'S')
44
45 typedef struct {
46 //
47 // Parts of this structure are initialized / torn down in various functions
48 // at various call depths. The table to the right should make it easier to
49 // track them.
50 //
51 // field init function init depth
52 // ---------------- ------------------ ----------
53 UINT32 Signature; // DriverBindingStart 0
54 VIRTIO_DEVICE_PROTOCOL *VirtIo; // DriverBindingStart 0
55 EFI_EVENT ExitBoot; // DriverBindingStart 0
56 BOOLEAN InOutSupported; // VirtioScsiInit 1
57 UINT16 MaxTarget; // VirtioScsiInit 1
58 UINT32 MaxLun; // VirtioScsiInit 1
59 UINT32 MaxSectors; // VirtioScsiInit 1
60 VRING Ring; // VirtioRingInit 2
61 EFI_EXT_SCSI_PASS_THRU_PROTOCOL PassThru; // VirtioScsiInit 1
62 EFI_EXT_SCSI_PASS_THRU_MODE PassThruMode; // VirtioScsiInit 1
63 VOID *RingMap; // VirtioRingMap 2
64 } VSCSI_DEV;
65
66 #define VIRTIO_SCSI_FROM_PASS_THRU(PassThruPointer) \
67 CR (PassThruPointer, VSCSI_DEV, PassThru, VSCSI_SIG)
68
69
70 //
71 // Probe, start and stop functions of this driver, called by the DXE core for
72 // specific devices.
73 //
74 // The following specifications document these interfaces:
75 // - Driver Writer's Guide for UEFI 2.3.1 v1.01, 9 Driver Binding Protocol
76 // - UEFI Spec 2.3.1 + Errata C, 10.1 EFI Driver Binding Protocol
77 //
78
79 EFI_STATUS
80 EFIAPI
81 VirtioScsiDriverBindingSupported (
82 IN EFI_DRIVER_BINDING_PROTOCOL *This,
83 IN EFI_HANDLE DeviceHandle,
84 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
85 );
86
87
88 EFI_STATUS
89 EFIAPI
90 VirtioScsiDriverBindingStart (
91 IN EFI_DRIVER_BINDING_PROTOCOL *This,
92 IN EFI_HANDLE DeviceHandle,
93 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
94 );
95
96
97 EFI_STATUS
98 EFIAPI
99 VirtioScsiDriverBindingStop (
100 IN EFI_DRIVER_BINDING_PROTOCOL *This,
101 IN EFI_HANDLE DeviceHandle,
102 IN UINTN NumberOfChildren,
103 IN EFI_HANDLE *ChildHandleBuffer
104 );
105
106
107 //
108 // The next seven functions implement EFI_EXT_SCSI_PASS_THRU_PROTOCOL
109 // for the virtio-scsi HBA. Refer to UEFI Spec 2.3.1 + Errata C, sections
110 // - 14.1 SCSI Driver Model Overview,
111 // - 14.7 Extended SCSI Pass Thru Protocol.
112 //
113
114 EFI_STATUS
115 EFIAPI
116 VirtioScsiPassThru (
117 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
118 IN UINT8 *Target,
119 IN UINT64 Lun,
120 IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
121 IN EFI_EVENT Event OPTIONAL
122 );
123
124
125 EFI_STATUS
126 EFIAPI
127 VirtioScsiGetNextTargetLun (
128 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
129 IN OUT UINT8 **Target,
130 IN OUT UINT64 *Lun
131 );
132
133
134 EFI_STATUS
135 EFIAPI
136 VirtioScsiBuildDevicePath (
137 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
138 IN UINT8 *Target,
139 IN UINT64 Lun,
140 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
141 );
142
143
144 EFI_STATUS
145 EFIAPI
146 VirtioScsiGetTargetLun (
147 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
148 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
149 OUT UINT8 **Target,
150 OUT UINT64 *Lun
151 );
152
153
154 EFI_STATUS
155 EFIAPI
156 VirtioScsiResetChannel (
157 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This
158 );
159
160
161 EFI_STATUS
162 EFIAPI
163 VirtioScsiResetTargetLun (
164 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
165 IN UINT8 *Target,
166 IN UINT64 Lun
167 );
168
169
170 EFI_STATUS
171 EFIAPI
172 VirtioScsiGetNextTarget (
173 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
174 IN OUT UINT8 **Target
175 );
176
177
178 //
179 // The purpose of the following scaffolding (EFI_COMPONENT_NAME_PROTOCOL and
180 // EFI_COMPONENT_NAME2_PROTOCOL implementation) is to format the driver's name
181 // in English, for display on standard console devices. This is recommended for
182 // UEFI drivers that follow the UEFI Driver Model. Refer to the Driver Writer's
183 // Guide for UEFI 2.3.1 v1.01, 11 UEFI Driver and Controller Names.
184 //
185 // Device type names ("Virtio SCSI Host Device") are not formatted because the
186 // driver supports only that device type. Therefore the driver name suffices
187 // for unambiguous identification.
188 //
189
190 EFI_STATUS
191 EFIAPI
192 VirtioScsiGetDriverName (
193 IN EFI_COMPONENT_NAME_PROTOCOL *This,
194 IN CHAR8 *Language,
195 OUT CHAR16 **DriverName
196 );
197
198
199 EFI_STATUS
200 EFIAPI
201 VirtioScsiGetDeviceName (
202 IN EFI_COMPONENT_NAME_PROTOCOL *This,
203 IN EFI_HANDLE DeviceHandle,
204 IN EFI_HANDLE ChildHandle,
205 IN CHAR8 *Language,
206 OUT CHAR16 **ControllerName
207 );
208
209 #endif // _VIRTIO_SCSI_DXE_H_