]>
Commit | Line | Data |
---|---|---|
e237e7ae | 1 | /** @file\r |
2 | \r | |
cc5166ff | 3 | The implementation of USB mass storage class device driver.\r |
4 | \r | |
c7e39923 | 5 | Copyright (c) 2007 - 2008, Intel Corporation\r |
e237e7ae | 6 | All rights reserved. This program and the accompanying materials\r |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT 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 | |
19 | typedef 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 | 28 | struct _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 | 45 | extern EFI_COMPONENT_NAME_PROTOCOL gUsbMassStorageComponentName;\r |
46 | extern 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 | |
63 | EFI_STATUS\r | |
64 | EFIAPI\r | |
65 | USBMassDriverBindingSupported (\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 | |
89 | EFI_STATUS\r | |
90 | EFIAPI\r | |
91 | USBMassDriverBindingStart (\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 | |
109 | EFI_STATUS\r | |
110 | EFIAPI\r | |
111 | USBMassDriverBindingStop (\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 | |
137 | EFI_STATUS\r | |
138 | EFIAPI\r | |
139 | UsbMassReset (\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 | |
168 | EFI_STATUS\r | |
169 | EFIAPI\r | |
170 | UsbMassReadBlocks (\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 | |
203 | EFI_STATUS\r | |
204 | EFIAPI\r | |
205 | UsbMassWriteBlocks (\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 | |
227 | EFI_STATUS\r | |
228 | EFIAPI\r | |
229 | UsbMassFlushBlocks (\r | |
230 | IN EFI_BLOCK_IO_PROTOCOL *This\r | |
231 | );\r | |
232 | \r | |
233 | \r | |
e237e7ae | 234 | #endif\r |