#include "UsbMassCbi.h"\r
#include "UsbMassBoot.h"\r
\r
-\r
-//\r
-// MassStorage raises TPL to TPL_NOTIFY to serialize all its operations\r
-// to protect shared data structures.\r
-//\r
-#define USB_MASS_TPL TPL_NOTIFY\r
-\r
-#define USB_MASS_SIGNATURE EFI_SIGNATURE_32 ('U', 's', 'b', 'M')\r
-\r
+#define USB_MASS_SIGNATURE SIGNATURE_32 ('U', 's', 'b', 'M')\r
\r
struct _USB_MASS_DEVICE {\r
UINT32 Signature;\r
VOID *Context; // Opaque storage for mass transport\r
};\r
\r
-#define USB_MASS_DEVICE_FROM_BLOCKIO(a) \\r
+#define USB_MASS_DEVICE_FROM_BLOCK_IO(a) \\r
CR (a, USB_MASS_DEVICE, BlockIo, USB_MASS_SIGNATURE)\r
\r
extern EFI_COMPONENT_NAME_PROTOCOL gUsbMassStorageComponentName;\r
extern EFI_COMPONENT_NAME2_PROTOCOL gUsbMassStorageComponentName2;\r
\r
+//\r
+// Functions for Driver Binding Protocol\r
+//\r
+\r
+/**\r
+ Check whether the controller is a supported USB mass storage.\r
+\r
+ @param This The USB mass storage driver binding protocol.\r
+ @param Controller The controller handle to check.\r
+ @param RemainingDevicePath The remaining device path.\r
+\r
+ @retval EFI_SUCCESS The driver supports this controller.\r
+ @retval other This device isn't supported.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+USBMassDriverBindingSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ );\r
+\r
+/**\r
+ Starts the USB mass storage device with this driver.\r
+\r
+ This function consumes USB I/O Portocol, intializes USB mass storage device,\r
+ installs Block I/O Protocol, and submits Asynchronous Interrupt\r
+ Transfer to manage the USB mass storage device.\r
+\r
+ @param This The USB mass storage driver binding protocol.\r
+ @param Controller The USB mass storage device to start on\r
+ @param RemainingDevicePath The remaining device path.\r
+\r
+ @retval EFI_SUCCESS This driver supports this device.\r
+ @retval EFI_UNSUPPORTED This driver does not support this device.\r
+ @retval EFI_DEVICE_ERROR This driver cannot be started due to device Error.\r
+ @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.\r
+ @retval EFI_ALREADY_STARTED This driver has been started.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+USBMassDriverBindingStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ );\r
+\r
+/**\r
+ Stop controlling the device.\r
+\r
+ @param This The USB mass storage driver binding\r
+ @param Controller The device controller controlled by the driver.\r
+ @param NumberOfChildren The number of children of this device\r
+ @param ChildHandleBuffer The buffer of children handle.\r
+\r
+ @retval EFI_SUCCESS The driver stopped from controlling the device.\r
+ @retval Others Failed to stop the driver\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+USBMassDriverBindingStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
+ );\r
+\r
+//\r
+// Functions for Block I/O Protocol\r
+//\r
+\r
+/**\r
+ Reset the block device.\r
+\r
+ This function implements EFI_BLOCK_IO_PROTOCOL.Reset(). \r
+ It resets the block device hardware.\r
+ ExtendedVerification is ignored in this implementation.\r
+\r
+ @param This Indicates a pointer to the calling context.\r
+ @param ExtendedVerification Indicates that the driver may perform a more exhaustive\r
+ verification operation of the device during reset.\r
+\r
+ @retval EFI_SUCCESS The block device was reset.\r
+ @retval EFI_DEVICE_ERROR The block device is not functioning correctly and could not be reset.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UsbMassReset (\r
+ IN EFI_BLOCK_IO_PROTOCOL *This,\r
+ IN BOOLEAN ExtendedVerification\r
+ );\r
+\r
+/**\r
+ Reads the requested number of blocks from the device.\r
+\r
+ This function implements EFI_BLOCK_IO_PROTOCOL.ReadBlocks(). \r
+ It reads the requested number of blocks from the device.\r
+ All the blocks are read, or an error is returned.\r
+\r
+ @param This Indicates a pointer to the calling context.\r
+ @param MediaId The media ID that the read request is for.\r
+ @param Lba The starting logical block address to read from on the device.\r
+ @param BufferSize The size of the Buffer in bytes.\r
+ This must be a multiple of the intrinsic block size of the device.\r
+ @param Buffer A pointer to the destination buffer for the data. The caller is\r
+ responsible for either having implicit or explicit ownership of the buffer.\r
+\r
+ @retval EFI_SUCCESS The data was read correctly from the device.\r
+ @retval EFI_DEVICE_ERROR The device reported an error while attempting to perform the read operation.\r
+ @retval EFI_NO_MEDIA There is no media in the device.\r
+ @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
+ @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the intrinsic block size of the device.\r
+ @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
+ or the buffer is not on proper alignment.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UsbMassReadBlocks (\r
+ IN EFI_BLOCK_IO_PROTOCOL *This,\r
+ IN UINT32 MediaId,\r
+ IN EFI_LBA Lba,\r
+ IN UINTN BufferSize,\r
+ OUT VOID *Buffer\r
+ );\r
+\r
+/**\r
+ Writes a specified number of blocks to the device.\r
+\r
+ This function implements EFI_BLOCK_IO_PROTOCOL.WriteBlocks(). \r
+ It writes a specified number of blocks to the device.\r
+ All blocks are written, or an error is returned.\r
+\r
+ @param This Indicates a pointer to the calling context.\r
+ @param MediaId The media ID that the write request is for.\r
+ @param Lba The starting logical block address to be written.\r
+ @param BufferSize The size of the Buffer in bytes.\r
+ This must be a multiple of the intrinsic block size of the device.\r
+ @param Buffer Pointer to the source buffer for the data.\r
+\r
+ @retval EFI_SUCCESS The data were written correctly to the device.\r
+ @retval EFI_WRITE_PROTECTED The device cannot be written to.\r
+ @retval EFI_NO_MEDIA There is no media in the device.\r
+ @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
+ @retval EFI_DEVICE_ERROR The device reported an error while attempting to perform the write operation.\r
+ @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the intrinsic\r
+ block size of the device.\r
+ @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
+ or the buffer is not on proper alignment.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UsbMassWriteBlocks (\r
+ IN EFI_BLOCK_IO_PROTOCOL *This,\r
+ IN UINT32 MediaId,\r
+ IN EFI_LBA Lba,\r
+ IN UINTN BufferSize,\r
+ IN VOID *Buffer\r
+ );\r
+\r
+/**\r
+ Flushes all modified data to a physical block device.\r
+\r
+ This function implements EFI_BLOCK_IO_PROTOCOL.FlushBlocks().\r
+ USB mass storage device doesn't support write cache,\r
+ so return EFI_SUCCESS directly.\r
+\r
+ @param This Indicates a pointer to the calling context.\r
+\r
+ @retval EFI_SUCCESS All outstanding data were written correctly to the device.\r
+ @retval EFI_DEVICE_ERROR The device reported an error while attempting to write data.\r
+ @retval EFI_NO_MEDIA There is no media in the device.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UsbMassFlushBlocks (\r
+ IN EFI_BLOCK_IO_PROTOCOL *This\r
+ );\r
+\r
+\r
#endif\r