]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.h
MdeModulePkg/UsbMass: Fix various typos
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbMassStorageDxe / UsbMassImpl.h
index eddff8c1bcea966cc49d518c4a31f1f18e1ce75e..283bed7055a0c811751d3602f5a818ff5f1945ff 100644 (file)
 /** @file\r
+  Definitions of functions for Driver Binding Protocol and Block I/O Protocol,\r
+  and other internal definitions.\r
 \r
-  The implementation of USB mass storage class device driver.\r
-\r
-Copyright (c) 2007 - 2008, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
 #ifndef _EFI_USBMASS_IMPL_H_\r
 #define _EFI_USBMASS_IMPL_H_\r
 \r
-typedef struct _USB_MASS_DEVICE USB_MASS_DEVICE;\r
+#define  USB_MASS_SIGNATURE    SIGNATURE_32 ('U', 's', 'b', 'M')\r
 \r
-#include "UsbMass.h"\r
-#include "UsbMassBot.h"\r
-#include "UsbMassCbi.h"\r
-#include "UsbMassBoot.h"\r
+#define USB_MASS_DEVICE_FROM_BLOCK_IO(a) \\r
+        CR (a, USB_MASS_DEVICE, BlockIo, USB_MASS_SIGNATURE)\r
 \r
+#define USB_MASS_DEVICE_FROM_DISK_INFO(a) \\r
+        CR (a, USB_MASS_DEVICE, DiskInfo, USB_MASS_SIGNATURE)\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
-\r
-struct _USB_MASS_DEVICE {\r
-  UINT32                    Signature;\r
-  EFI_HANDLE                Controller;\r
-  EFI_USB_IO_PROTOCOL       *UsbIo;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  EFI_BLOCK_IO_PROTOCOL     BlockIo;\r
-  EFI_BLOCK_IO_MEDIA        BlockIoMedia;\r
-  BOOLEAN                   OpticalStorage;\r
-  UINT8                     Lun;          // Logical Unit Number\r
-  UINT8                     Pdt;          // Peripheral Device Type\r
-  USB_MASS_TRANSPORT        *Transport;   // USB mass storage transport protocol\r
-  VOID                      *Context;     // Opaque storage for mass transport\r
-};\r
-\r
-#define USB_MASS_DEVICE_FROM_BLOCKIO(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 Protocol, initializes 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 EFI_DEVICE_ERROR       The device could not be stopped due to a device error.\r
+  @retval EFI_UNSUPPORTED        Block I/O Protocol is not installed on Controller.\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
+// EFI Component Name Functions\r
+//\r
+\r
+/**\r
+  Retrieves a Unicode string that is the user readable name of the driver.\r
+\r
+  This function retrieves the user readable name of a driver in the form of a\r
+  Unicode string. If the driver specified by This has a user readable name in\r
+  the language specified by Language, then a pointer to the driver name is\r
+  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
+  by This does not support the language specified by Language,\r
+  then EFI_UNSUPPORTED is returned.\r
+\r
+  @param  This                  A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
+  @param  Language              A pointer to a Null-terminated ASCII string\r
+                                array indicating the language. This is the\r
+                                language of the driver name that the caller is\r
+                                requesting, and it must match one of the\r
+                                languages specified in SupportedLanguages. The\r
+                                number of languages supported by a driver is up\r
+                                to the driver writer. Language is specified\r
+                                in RFC 4646 or ISO 639-2 language code format.\r
+  @param  DriverName            A pointer to the Unicode string to return.\r
+                                This Unicode string is the name of the\r
+                                driver specified by This in the language\r
+                                specified by Language.\r
+\r
+  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
+                                This and the language specified by Language was\r
+                                returned in DriverName.\r
+  @retval EFI_INVALID_PARAMETER Language is NULL.\r
+  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
+                                the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UsbMassStorageGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  );\r
+\r
+\r
+/**\r
+  Retrieves a Unicode string that is the user readable name of the controller\r
+  that is being managed by a driver.\r
+\r
+  This function retrieves the user readable name of the controller specified by\r
+  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
+  driver specified by This has a user readable name in the language specified by\r
+  Language, then a pointer to the controller name is returned in ControllerName,\r
+  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
+  managing the controller specified by ControllerHandle and ChildHandle,\r
+  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
+  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
+\r
+  @param  This                  A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
+  @param  ControllerHandle      The handle of a controller that the driver\r
+                                specified by This is managing.  This handle\r
+                                specifies the controller whose name is to be\r
+                                returned.\r
+  @param  ChildHandle           The handle of the child controller to retrieve\r
+                                the name of.  This is an optional parameter that\r
+                                may be NULL.  It will be NULL for device\r
+                                drivers.  It will also be NULL for a bus drivers\r
+                                that wish to retrieve the name of the bus\r
+                                controller.  It will not be NULL for a bus\r
+                                driver that wishes to retrieve the name of a\r
+                                child controller.\r
+  @param  Language              A pointer to a Null-terminated ASCII string\r
+                                array indicating the language.  This is the\r
+                                language of the driver name that the caller is\r
+                                requesting, and it must match one of the\r
+                                languages specified in SupportedLanguages. The\r
+                                number of languages supported by a driver is up\r
+                                to the driver writer. Language is specified in\r
+                                RFC 4646 or ISO 639-2 language code format.\r
+  @param  ControllerName        A pointer to the Unicode string to return.\r
+                                This Unicode string is the name of the\r
+                                controller specified by ControllerHandle and\r
+                                ChildHandle in the language specified by\r
+                                Language from the point of view of the driver\r
+                                specified by This.\r
+\r
+  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
+                                the language specified by Language for the\r
+                                driver specified by This was returned in\r
+                                DriverName.\r
+  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
+  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
+                                EFI_HANDLE.\r
+  @retval EFI_INVALID_PARAMETER Language is NULL.\r
+  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
+  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
+                                managing the controller specified by\r
+                                ControllerHandle and ChildHandle.\r
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
+                                the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UsbMassStorageGetControllerName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
+  IN  EFI_HANDLE                                      ControllerHandle,\r
+  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
+  IN  CHAR8                                           *Language,\r
+  OUT CHAR16                                          **ControllerName\r
+  );\r
+\r
 #endif\r