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