]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.h
Change the name of extension
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbMassStorageDxe / UsbMassImpl.h
1 /** @file
2
3 The implementation of USB mass storage class device driver.
4
5 Copyright (c) 2007 - 2008, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #ifndef _EFI_USBMASS_IMPL_H_
17 #define _EFI_USBMASS_IMPL_H_
18
19 typedef struct _USB_MASS_DEVICE USB_MASS_DEVICE;
20
21 #include "UsbMass.h"
22 #include "UsbMassBot.h"
23 #include "UsbMassCbi.h"
24 #include "UsbMassBoot.h"
25
26 #define USB_MASS_SIGNATURE SIGNATURE_32 ('U', 's', 'b', 'M')
27
28 struct _USB_MASS_DEVICE {
29 UINT32 Signature;
30 EFI_HANDLE Controller;
31 EFI_USB_IO_PROTOCOL *UsbIo;
32 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
33 EFI_BLOCK_IO_PROTOCOL BlockIo;
34 EFI_BLOCK_IO_MEDIA BlockIoMedia;
35 BOOLEAN OpticalStorage;
36 UINT8 Lun; // Logical Unit Number
37 UINT8 Pdt; // Peripheral Device Type
38 USB_MASS_TRANSPORT *Transport; // USB mass storage transport protocol
39 VOID *Context; // Opaque storage for mass transport
40 };
41
42 #define USB_MASS_DEVICE_FROM_BLOCK_IO(a) \
43 CR (a, USB_MASS_DEVICE, BlockIo, USB_MASS_SIGNATURE)
44
45 extern EFI_COMPONENT_NAME_PROTOCOL gUsbMassStorageComponentName;
46 extern EFI_COMPONENT_NAME2_PROTOCOL gUsbMassStorageComponentName2;
47
48 //
49 // Functions for Driver Binding Protocol
50 //
51
52 /**
53 Check whether the controller is a supported USB mass storage.
54
55 @param This The USB mass storage driver binding protocol.
56 @param Controller The controller handle to check.
57 @param RemainingDevicePath The remaining device path.
58
59 @retval EFI_SUCCESS The driver supports this controller.
60 @retval other This device isn't supported.
61
62 **/
63 EFI_STATUS
64 EFIAPI
65 USBMassDriverBindingSupported (
66 IN EFI_DRIVER_BINDING_PROTOCOL *This,
67 IN EFI_HANDLE Controller,
68 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
69 );
70
71 /**
72 Starts the USB mass storage device with this driver.
73
74 This function consumes USB I/O Portocol, intializes USB mass storage device,
75 installs Block I/O Protocol, and submits Asynchronous Interrupt
76 Transfer to manage the USB mass storage device.
77
78 @param This The USB mass storage driver binding protocol.
79 @param Controller The USB mass storage device to start on
80 @param RemainingDevicePath The remaining device path.
81
82 @retval EFI_SUCCESS This driver supports this device.
83 @retval EFI_UNSUPPORTED This driver does not support this device.
84 @retval EFI_DEVICE_ERROR This driver cannot be started due to device Error.
85 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.
86 @retval EFI_ALREADY_STARTED This driver has been started.
87
88 **/
89 EFI_STATUS
90 EFIAPI
91 USBMassDriverBindingStart (
92 IN EFI_DRIVER_BINDING_PROTOCOL *This,
93 IN EFI_HANDLE Controller,
94 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
95 );
96
97 /**
98 Stop controlling the device.
99
100 @param This The USB mass storage driver binding
101 @param Controller The device controller controlled by the driver.
102 @param NumberOfChildren The number of children of this device
103 @param ChildHandleBuffer The buffer of children handle.
104
105 @retval EFI_SUCCESS The driver stopped from controlling the device.
106 @retval Others Failed to stop the driver
107
108 **/
109 EFI_STATUS
110 EFIAPI
111 USBMassDriverBindingStop (
112 IN EFI_DRIVER_BINDING_PROTOCOL *This,
113 IN EFI_HANDLE Controller,
114 IN UINTN NumberOfChildren,
115 IN EFI_HANDLE *ChildHandleBuffer
116 );
117
118 //
119 // Functions for Block I/O Protocol
120 //
121
122 /**
123 Reset the block device.
124
125 This function implements EFI_BLOCK_IO_PROTOCOL.Reset().
126 It resets the block device hardware.
127 ExtendedVerification is ignored in this implementation.
128
129 @param This Indicates a pointer to the calling context.
130 @param ExtendedVerification Indicates that the driver may perform a more exhaustive
131 verification operation of the device during reset.
132
133 @retval EFI_SUCCESS The block device was reset.
134 @retval EFI_DEVICE_ERROR The block device is not functioning correctly and could not be reset.
135
136 **/
137 EFI_STATUS
138 EFIAPI
139 UsbMassReset (
140 IN EFI_BLOCK_IO_PROTOCOL *This,
141 IN BOOLEAN ExtendedVerification
142 );
143
144 /**
145 Reads the requested number of blocks from the device.
146
147 This function implements EFI_BLOCK_IO_PROTOCOL.ReadBlocks().
148 It reads the requested number of blocks from the device.
149 All the blocks are read, or an error is returned.
150
151 @param This Indicates a pointer to the calling context.
152 @param MediaId The media ID that the read request is for.
153 @param Lba The starting logical block address to read from on the device.
154 @param BufferSize The size of the Buffer in bytes.
155 This must be a multiple of the intrinsic block size of the device.
156 @param Buffer A pointer to the destination buffer for the data. The caller is
157 responsible for either having implicit or explicit ownership of the buffer.
158
159 @retval EFI_SUCCESS The data was read correctly from the device.
160 @retval EFI_DEVICE_ERROR The device reported an error while attempting to perform the read operation.
161 @retval EFI_NO_MEDIA There is no media in the device.
162 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
163 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the intrinsic block size of the device.
164 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
165 or the buffer is not on proper alignment.
166
167 **/
168 EFI_STATUS
169 EFIAPI
170 UsbMassReadBlocks (
171 IN EFI_BLOCK_IO_PROTOCOL *This,
172 IN UINT32 MediaId,
173 IN EFI_LBA Lba,
174 IN UINTN BufferSize,
175 OUT VOID *Buffer
176 );
177
178 /**
179 Writes a specified number of blocks to the device.
180
181 This function implements EFI_BLOCK_IO_PROTOCOL.WriteBlocks().
182 It writes a specified number of blocks to the device.
183 All blocks are written, or an error is returned.
184
185 @param This Indicates a pointer to the calling context.
186 @param MediaId The media ID that the write request is for.
187 @param Lba The starting logical block address to be written.
188 @param BufferSize The size of the Buffer in bytes.
189 This must be a multiple of the intrinsic block size of the device.
190 @param Buffer Pointer to the source buffer for the data.
191
192 @retval EFI_SUCCESS The data were written correctly to the device.
193 @retval EFI_WRITE_PROTECTED The device cannot be written to.
194 @retval EFI_NO_MEDIA There is no media in the device.
195 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
196 @retval EFI_DEVICE_ERROR The device reported an error while attempting to perform the write operation.
197 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the intrinsic
198 block size of the device.
199 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
200 or the buffer is not on proper alignment.
201
202 **/
203 EFI_STATUS
204 EFIAPI
205 UsbMassWriteBlocks (
206 IN EFI_BLOCK_IO_PROTOCOL *This,
207 IN UINT32 MediaId,
208 IN EFI_LBA Lba,
209 IN UINTN BufferSize,
210 IN VOID *Buffer
211 );
212
213 /**
214 Flushes all modified data to a physical block device.
215
216 This function implements EFI_BLOCK_IO_PROTOCOL.FlushBlocks().
217 USB mass storage device doesn't support write cache,
218 so return EFI_SUCCESS directly.
219
220 @param This Indicates a pointer to the calling context.
221
222 @retval EFI_SUCCESS All outstanding data were written correctly to the device.
223 @retval EFI_DEVICE_ERROR The device reported an error while attempting to write data.
224 @retval EFI_NO_MEDIA There is no media in the device.
225
226 **/
227 EFI_STATUS
228 EFIAPI
229 UsbMassFlushBlocks (
230 IN EFI_BLOCK_IO_PROTOCOL *This
231 );
232
233
234 #endif