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