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