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 accomodate 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 | BOOLEAN InOutSupported; // VirtioScsiInit 1
|
---|
56 | UINT16 MaxTarget; // VirtioScsiInit 1
|
---|
57 | UINT32 MaxLun; // VirtioScsiInit 1
|
---|
58 | UINT32 MaxSectors; // VirtioScsiInit 1
|
---|
59 | VRING Ring; // VirtioRingInit 2
|
---|
60 | EFI_EXT_SCSI_PASS_THRU_PROTOCOL PassThru; // VirtioScsiInit 1
|
---|
61 | EFI_EXT_SCSI_PASS_THRU_MODE PassThruMode; // VirtioScsiInit 1
|
---|
62 | } VSCSI_DEV;
|
---|
63 |
|
---|
64 | #define VIRTIO_SCSI_FROM_PASS_THRU(PassThruPointer) \
|
---|
65 | CR (PassThruPointer, VSCSI_DEV, PassThru, VSCSI_SIG)
|
---|
66 |
|
---|
67 |
|
---|
68 | //
|
---|
69 | // Probe, start and stop functions of this driver, called by the DXE core for
|
---|
70 | // specific devices.
|
---|
71 | //
|
---|
72 | // The following specifications document these interfaces:
|
---|
73 | // - Driver Writer's Guide for UEFI 2.3.1 v1.01, 9 Driver Binding Protocol
|
---|
74 | // - UEFI Spec 2.3.1 + Errata C, 10.1 EFI Driver Binding Protocol
|
---|
75 | //
|
---|
76 |
|
---|
77 | EFI_STATUS
|
---|
78 | EFIAPI
|
---|
79 | VirtioScsiDriverBindingSupported (
|
---|
80 | IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
---|
81 | IN EFI_HANDLE DeviceHandle,
|
---|
82 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
---|
83 | );
|
---|
84 |
|
---|
85 |
|
---|
86 | EFI_STATUS
|
---|
87 | EFIAPI
|
---|
88 | VirtioScsiDriverBindingStart (
|
---|
89 | IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
---|
90 | IN EFI_HANDLE DeviceHandle,
|
---|
91 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
---|
92 | );
|
---|
93 |
|
---|
94 |
|
---|
95 | EFI_STATUS
|
---|
96 | EFIAPI
|
---|
97 | VirtioScsiDriverBindingStop (
|
---|
98 | IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
---|
99 | IN EFI_HANDLE DeviceHandle,
|
---|
100 | IN UINTN NumberOfChildren,
|
---|
101 | IN EFI_HANDLE *ChildHandleBuffer
|
---|
102 | );
|
---|
103 |
|
---|
104 |
|
---|
105 | //
|
---|
106 | // The next seven functions implement EFI_EXT_SCSI_PASS_THRU_PROTOCOL
|
---|
107 | // for the virtio-scsi HBA. Refer to UEFI Spec 2.3.1 + Errata C, sections
|
---|
108 | // - 14.1 SCSI Driver Model Overview,
|
---|
109 | // - 14.7 Extended SCSI Pass Thru Protocol.
|
---|
110 | //
|
---|
111 |
|
---|
112 | EFI_STATUS
|
---|
113 | EFIAPI
|
---|
114 | VirtioScsiPassThru (
|
---|
115 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
|
---|
116 | IN UINT8 *Target,
|
---|
117 | IN UINT64 Lun,
|
---|
118 | IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
|
---|
119 | IN EFI_EVENT Event OPTIONAL
|
---|
120 | );
|
---|
121 |
|
---|
122 |
|
---|
123 | EFI_STATUS
|
---|
124 | EFIAPI
|
---|
125 | VirtioScsiGetNextTargetLun (
|
---|
126 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
|
---|
127 | IN OUT UINT8 **Target,
|
---|
128 | IN OUT UINT64 *Lun
|
---|
129 | );
|
---|
130 |
|
---|
131 |
|
---|
132 | EFI_STATUS
|
---|
133 | EFIAPI
|
---|
134 | VirtioScsiBuildDevicePath (
|
---|
135 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
|
---|
136 | IN UINT8 *Target,
|
---|
137 | IN UINT64 Lun,
|
---|
138 | IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
|
---|
139 | );
|
---|
140 |
|
---|
141 |
|
---|
142 | EFI_STATUS
|
---|
143 | EFIAPI
|
---|
144 | VirtioScsiGetTargetLun (
|
---|
145 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
|
---|
146 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
|
---|
147 | OUT UINT8 **Target,
|
---|
148 | OUT UINT64 *Lun
|
---|
149 | );
|
---|
150 |
|
---|
151 |
|
---|
152 | EFI_STATUS
|
---|
153 | EFIAPI
|
---|
154 | VirtioScsiResetChannel (
|
---|
155 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This
|
---|
156 | );
|
---|
157 |
|
---|
158 |
|
---|
159 | EFI_STATUS
|
---|
160 | EFIAPI
|
---|
161 | VirtioScsiResetTargetLun (
|
---|
162 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
|
---|
163 | IN UINT8 *Target,
|
---|
164 | IN UINT64 Lun
|
---|
165 | );
|
---|
166 |
|
---|
167 |
|
---|
168 | EFI_STATUS
|
---|
169 | EFIAPI
|
---|
170 | VirtioScsiGetNextTarget (
|
---|
171 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
|
---|
172 | IN OUT UINT8 **Target
|
---|
173 | );
|
---|
174 |
|
---|
175 |
|
---|
176 | //
|
---|
177 | // The purpose of the following scaffolding (EFI_COMPONENT_NAME_PROTOCOL and
|
---|
178 | // EFI_COMPONENT_NAME2_PROTOCOL implementation) is to format the driver's name
|
---|
179 | // in English, for display on standard console devices. This is recommended for
|
---|
180 | // UEFI drivers that follow the UEFI Driver Model. Refer to the Driver Writer's
|
---|
181 | // Guide for UEFI 2.3.1 v1.01, 11 UEFI Driver and Controller Names.
|
---|
182 | //
|
---|
183 | // Device type names ("Virtio SCSI Host Device") are not formatted because the
|
---|
184 | // driver supports only that device type. Therefore the driver name suffices
|
---|
185 | // for unambiguous identification.
|
---|
186 | //
|
---|
187 |
|
---|
188 | EFI_STATUS
|
---|
189 | EFIAPI
|
---|
190 | VirtioScsiGetDriverName (
|
---|
191 | IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
---|
192 | IN CHAR8 *Language,
|
---|
193 | OUT CHAR16 **DriverName
|
---|
194 | );
|
---|
195 |
|
---|
196 |
|
---|
197 | EFI_STATUS
|
---|
198 | EFIAPI
|
---|
199 | VirtioScsiGetDeviceName (
|
---|
200 | IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
---|
201 | IN EFI_HANDLE DeviceHandle,
|
---|
202 | IN EFI_HANDLE ChildHandle,
|
---|
203 | IN CHAR8 *Language,
|
---|
204 | OUT CHAR16 **ControllerName
|
---|
205 | );
|
---|
206 |
|
---|
207 | #endif // _VIRTIO_SCSI_DXE_H_
|
---|