]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Refine USB Mass Storage Driver.
authorxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 12 Jan 2009 07:30:42 +0000 (07:30 +0000)
committerxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 12 Jan 2009 07:30:42 +0000 (07:30 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7247 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Bus/Usb/UsbMassStorageDxe/ComponentName.c
MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMass.h
MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c
MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h
MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.c
MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.h
MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassCbi.c
MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassCbi.h
MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c
MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.h
MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf

index a48f0bee7cda0c21d8a8f1fcba4d3c52861b013c..f159b3ed76df5e1afa6134ed00992ca8db376601 100644 (file)
@@ -1,6 +1,5 @@
 /** @file\r
 /** @file\r
-\r
-  UEFI Component Name(2) protocol implementation.\r
+  UEFI Component Name(2) protocol implementation for USB Mass Storage Driver.\r
 \r
 Copyright (c) 2004 - 2007, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
 \r
 Copyright (c) 2004 - 2007, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
@@ -13,141 +12,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
 \r
 **/\r
 \r
-\r
-#include <Uefi.h>\r
-\r
-\r
-#include <Library/UefiLib.h>\r
-\r
-//\r
-// EFI Component Name Functions\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[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          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 3066 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       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
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\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[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  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
-\r
-  @param  ChildHandle[in]       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
-\r
-  @param  Language[in]          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 3066 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   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
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\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
+#include "UsbMassImpl.h"\r
 \r
 //\r
 // EFI Component Name Protocol\r
 \r
 //\r
 // EFI Component Name Protocol\r
@@ -184,10 +49,9 @@ mUsbMassStorageDriverNameTable[] = {
   by This does not support the language specified by Language,\r
   then EFI_UNSUPPORTED is returned.\r
 \r
   by This does not support the language specified by Language,\r
   then EFI_UNSUPPORTED is returned.\r
 \r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+  @param  This                  A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
                                 EFI_COMPONENT_NAME_PROTOCOL instance.\r
                                 EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\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
                                 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
@@ -195,8 +59,7 @@ mUsbMassStorageDriverNameTable[] = {
                                 number of languages supported by a driver is up\r
                                 to the driver writer. Language is specified\r
                                 in RFC 3066 or ISO 639-2 language code format.\r
                                 number of languages supported by a driver is up\r
                                 to the driver writer. Language is specified\r
                                 in RFC 3066 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\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
                                 This Unicode string is the name of the\r
                                 driver specified by This in the language\r
                                 specified by Language.\r
@@ -204,11 +67,8 @@ mUsbMassStorageDriverNameTable[] = {
   @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_SUCCESS           The Unicode string for the Driver specified by\r
                                 This and the language specified by Language was\r
                                 returned in DriverName.\r
-\r
   @retval EFI_INVALID_PARAMETER Language is NULL.\r
   @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
   @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
   @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
   @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
                                 the language specified by Language.\r
 \r
   @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
                                 the language specified by Language.\r
 \r
@@ -243,15 +103,13 @@ UsbMassStorageGetDriverName (
   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
   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[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+  @param  This                  A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
                                 EFI_COMPONENT_NAME_PROTOCOL instance.\r
                                 EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\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
                                 specified by This is managing.  This handle\r
                                 specifies the controller whose name is to be\r
                                 returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\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
                                 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
@@ -259,8 +117,7 @@ UsbMassStorageGetDriverName (
                                 controller.  It will not be NULL for a bus\r
                                 driver that wishes to retrieve the name of a\r
                                 child controller.\r
                                 controller.  It will not be NULL for a bus\r
                                 driver that wishes to retrieve the name of a\r
                                 child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\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
                                 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
@@ -268,8 +125,7 @@ UsbMassStorageGetDriverName (
                                 number of languages supported by a driver is up\r
                                 to the driver writer. Language is specified in\r
                                 RFC 3066 or ISO 639-2 language code format.\r
                                 number of languages supported by a driver is up\r
                                 to the driver writer. Language is specified in\r
                                 RFC 3066 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\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
                                 This Unicode string is the name of the\r
                                 controller specified by ControllerHandle and\r
                                 ChildHandle in the language specified by\r
@@ -280,20 +136,14 @@ UsbMassStorageGetDriverName (
                                 the language specified by Language for the\r
                                 driver specified by This was returned in\r
                                 DriverName.\r
                                 the language specified by Language for the\r
                                 driver specified by This was returned in\r
                                 DriverName.\r
-\r
   @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
   @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
-\r
   @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
                                 EFI_HANDLE.\r
   @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
                                 EFI_HANDLE.\r
-\r
   @retval EFI_INVALID_PARAMETER Language is NULL.\r
   @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
   @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
   @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\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 is not currently\r
                                 managing the controller specified by\r
                                 ControllerHandle and ChildHandle.\r
-\r
   @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
                                 the language specified by Language.\r
 \r
   @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
                                 the language specified by Language.\r
 \r
index 546dbed882a8714a88cdeb817faefab957328e40..d7708cb2d3b437e86c6a424eb3265d33325ec561 100644 (file)
@@ -1,12 +1,6 @@
 /** @file\r
 /** @file\r
-\r
-  Defination for the USB mass storage class driver. The USB mass storage\r
-  class is specified in two layers: the bottom layer is the transportation\r
-  protocol. The top layer is the command set. The transportation layer\r
-  provides the transportation of the command, data and result. The command\r
-  set defines what the command, data and result. The Bulk-Only-Transport and\r
-  Control/Bulk/Interrupt transport are two transportation protocol. USB mass\r
-  storage class adopts various industrial standard as its command set.\r
+  Definition of USB Mass Storage Class and its value, USB Mass Transport Protocol, \r
+  and other common definitions.\r
 \r
 Copyright (c) 2007 - 2008, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
 \r
 Copyright (c) 2007 - 2008, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
@@ -72,8 +66,22 @@ typedef enum {
   USB_MASS_CMD_SUCCESS    = 0,\r
   USB_MASS_CMD_FAIL,\r
   USB_MASS_CMD_PERSISTENT\r
   USB_MASS_CMD_SUCCESS    = 0,\r
   USB_MASS_CMD_FAIL,\r
   USB_MASS_CMD_PERSISTENT\r
-}USB_MASS_DEV_CLASS_AND_VALUE;\r
+} USB_MASS_DEV_CLASS_AND_VALUE;\r
+\r
+/**\r
+  Initializes USB transport protocol.\r
+\r
+  This function initializes the USB mass storage class transport protocol.\r
+  It will save its context in the Context if Context isn't NULL.\r
+\r
+  @param  UsbIo                 The USB I/O Protocol instance\r
+  @param  Context               The buffer to save the context to\r
 \r
 \r
+  @retval EFI_SUCCESS           The device is successfully initialized.\r
+  @retval EFI_UNSUPPORTED       The transport protocol doesn't support the device.\r
+  @retval Other                 The USB transport initialization fails.\r
+\r
+**/\r
 typedef\r
 EFI_STATUS\r
 (*USB_MASS_INIT_TRANSPORT) (\r
 typedef\r
 EFI_STATUS\r
 (*USB_MASS_INIT_TRANSPORT) (\r
@@ -81,6 +89,23 @@ EFI_STATUS
   OUT VOID                    **Context    OPTIONAL\r
   );\r
 \r
   OUT VOID                    **Context    OPTIONAL\r
   );\r
 \r
+/**\r
+  Execute USB mass storage command through the transport protocol.\r
+\r
+  @param  Context               The USB Transport Protocol.\r
+  @param  Cmd                   The command to transfer to device\r
+  @param  CmdLen                The length of the command\r
+  @param  DataDir               The direction of data transfer\r
+  @param  Data                  The buffer to hold the data\r
+  @param  DataLen               The length of the buffer\r
+  @param  Lun                   Should be 0, this field for bot only\r
+  @param  Timeout               The time to wait\r
+  @param  CmdStatus             The result of the command execution\r
+\r
+  @retval EFI_SUCCESS           The command is executed successfully.\r
+  @retval Other                 Failed to execute the command\r
+\r
+**/\r
 typedef\r
 EFI_STATUS\r
 (*USB_MASS_EXEC_COMMAND) (\r
 typedef\r
 EFI_STATUS\r
 (*USB_MASS_EXEC_COMMAND) (\r
@@ -95,6 +120,17 @@ EFI_STATUS
   OUT UINT32                  *CmdStatus\r
   );\r
 \r
   OUT UINT32                  *CmdStatus\r
   );\r
 \r
+/**\r
+  Reset the USB mass storage device by Transport protocol.\r
+\r
+  @param  Context               The USB Transport Protocol\r
+  @param  ExtendedVerification  The flag controlling the rule of reset.\r
+                                Not used here.\r
+\r
+  @retval EFI_SUCCESS           The device is reset.\r
+  @retval Others                Failed to reset the device.\r
+\r
+**/\r
 typedef\r
 EFI_STATUS\r
 (*USB_MASS_RESET) (\r
 typedef\r
 EFI_STATUS\r
 (*USB_MASS_RESET) (\r
@@ -102,6 +138,17 @@ EFI_STATUS
   IN  BOOLEAN                 ExtendedVerification\r
   );\r
 \r
   IN  BOOLEAN                 ExtendedVerification\r
   );\r
 \r
+/**\r
+  Get the max LUN (Logical Unit Number) of USB mass storage device.\r
+\r
+  @param  Context          The context of the transport protocol.\r
+  @param  MaxLun           Return pointer to the max number of LUN. (e.g. MaxLun=1 means LUN0 and\r
+                           LUN1 in all.)\r
+\r
+  @retval EFI_SUCCESS      Max LUN is got successfully.\r
+  @retval Others           Fail to execute this request.\r
+\r
+**/\r
 typedef\r
 EFI_STATUS\r
 (*USB_MASS_GET_MAX_LUN) (\r
 typedef\r
 EFI_STATUS\r
 (*USB_MASS_GET_MAX_LUN) (\r
@@ -109,6 +156,14 @@ EFI_STATUS
   IN  UINT8                   *MaxLun\r
   );\r
 \r
   IN  UINT8                   *MaxLun\r
   );\r
 \r
+/**\r
+  Clean up the transport protocol's resource.\r
+\r
+  @param  Context               The instance of transport protocol.\r
+\r
+  @retval EFI_SUCCESS           The resource is cleaned up.\r
+\r
+**/\r
 typedef\r
 EFI_STATUS\r
 (*USB_MASS_CLEAN_UP) (\r
 typedef\r
 EFI_STATUS\r
 (*USB_MASS_CLEAN_UP) (\r
@@ -132,22 +187,18 @@ typedef struct {
   USB_MASS_CLEAN_UP       CleanUp;     ///< Clean up the resources.\r
 } USB_MASS_TRANSPORT;\r
 \r
   USB_MASS_CLEAN_UP       CleanUp;     ///< Clean up the resources.\r
 } USB_MASS_TRANSPORT;\r
 \r
-\r
-/**\r
-  Use the USB clear feature control transfer to clear the endpoint\r
-  stall condition.\r
-\r
-  @param  UsbIo                  The USB IO protocol to use\r
-  @param  EndpointAddr           The endpoint to clear stall for\r
-\r
-  @retval EFI_SUCCESS            The endpoint stall condtion is clear\r
-  @retval Others                 Failed to clear the endpoint stall condtion\r
-\r
-**/\r
-EFI_STATUS\r
-UsbClearEndpointStall (\r
-  IN EFI_USB_IO_PROTOCOL      *UsbIo,\r
-  IN UINT8                    EndpointAddr\r
-  );\r
+typedef struct {\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;     \r
+} USB_MASS_DEVICE;\r
 \r
 #endif\r
 \r
 #endif\r
index 44f0b03833258e96181b4f270065590cffb401e8..71deef051e39b666538f44f27fd576f4804712ee 100644 (file)
@@ -788,7 +788,6 @@ UsbBootWriteBlocks (
   return Status;\r
 }\r
 \r
   return Status;\r
 }\r
 \r
-\r
 /**\r
   Use the USB clear feature control transfer to clear the endpoint stall condition.\r
 \r
 /**\r
   Use the USB clear feature control transfer to clear the endpoint stall condition.\r
 \r
index ab3fb68e4a0dac8f05e4d45f2ea4fb2477cc404d..cd66d825ef2e8c9a2d477b7eff134387498fdcd6 100644 (file)
@@ -16,6 +16,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #ifndef _EFI_USB_MASS_BOOT_H_\r
 #define _EFI_USB_MASS_BOOT_H_\r
 \r
 #ifndef _EFI_USB_MASS_BOOT_H_\r
 #define _EFI_USB_MASS_BOOT_H_\r
 \r
+#include "UsbMass.h"\r
+\r
 typedef enum {\r
   //\r
   // The opcodes of various USB boot commands:\r
 typedef enum {\r
   //\r
   // The opcodes of various USB boot commands:\r
@@ -226,17 +228,18 @@ typedef struct {
 #define USB_BOOT_SENSE_KEY(Key)     ((Key) & 0x0f)\r
 \r
 /**\r
 #define USB_BOOT_SENSE_KEY(Key)     ((Key) & 0x0f)\r
 \r
 /**\r
-  Get the parameters for the USB mass storage media, including\r
-  the RemovableMedia, block size, and last block number. This\r
-  function is used both to initialize the media during the\r
-  DriverBindingStart and to re-initialize it when the media is\r
+  Get the parameters for the USB mass storage media.\r
+\r
+  This function get the parameters for the USB mass storage media,\r
+  It is used both to initialize the media during the Start() phase\r
+  of Driver Binding Protocol and to re-initialize it when the media is\r
   changed. Althought the RemoveableMedia is unlikely to change,\r
   changed. Althought the RemoveableMedia is unlikely to change,\r
-  I include it here.\r
+  it is also included here.\r
 \r
 \r
-  @param  UsbMass                The device to retireve disk gemotric.\r
+  @param  UsbMass                The device to retrieve disk gemotric.\r
 \r
   @retval EFI_SUCCESS            The disk gemotric is successfully retrieved.\r
 \r
   @retval EFI_SUCCESS            The disk gemotric is successfully retrieved.\r
-  @retval Other                  Get the parameters failed.\r
+  @retval Other                  Failed to get the parameters.\r
 \r
 **/\r
 EFI_STATUS\r
 \r
 **/\r
 EFI_STATUS\r
@@ -244,14 +247,12 @@ UsbBootGetParams (
   IN USB_MASS_DEVICE          *UsbMass\r
   );\r
 \r
   IN USB_MASS_DEVICE          *UsbMass\r
   );\r
 \r
-\r
 /**\r
 /**\r
-  Use the TEST UNIT READY command to check whether it is ready.\r
-  If it is ready, update the parameters.\r
+  Execute TEST UNIT READY command to check if the device is ready.\r
 \r
   @param  UsbMass                The device to test\r
 \r
 \r
   @param  UsbMass                The device to test\r
 \r
-  @retval EFI_SUCCESS            The device is ready and parameters are updated.\r
+  @retval EFI_SUCCESS            The device is ready.\r
   @retval Others                 Device not ready.\r
 \r
 **/\r
   @retval Others                 Device not ready.\r
 \r
 **/\r
@@ -260,15 +261,13 @@ UsbBootIsUnitReady (
   IN USB_MASS_DEVICE          *UsbMass\r
   );\r
 \r
   IN USB_MASS_DEVICE          *UsbMass\r
   );\r
 \r
-\r
 /**\r
   Detect whether the removable media is present and whether it has changed.\r
 /**\r
   Detect whether the removable media is present and whether it has changed.\r
-  The Non-removable media doesn't need it.\r
 \r
 \r
-  @param  UsbMass                The device to retireve disk gemotric.\r
+  @param  UsbMass                The device to check.\r
 \r
 \r
-  @retval EFI_SUCCESS            The disk gemotric is successfully retrieved.\r
-  @retval Other                  Decect media fails.\r
+  @retval EFI_SUCCESS            The media status is successfully checked.\r
+  @retval Other                  Failed to detect media.\r
 \r
 **/\r
 EFI_STATUS\r
 \r
 **/\r
 EFI_STATUS\r
@@ -276,7 +275,6 @@ UsbBootDetectMedia (
   IN  USB_MASS_DEVICE       *UsbMass\r
   );\r
 \r
   IN  USB_MASS_DEVICE       *UsbMass\r
   );\r
 \r
-\r
 /**\r
   Read some blocks from the device.\r
 \r
 /**\r
   Read some blocks from the device.\r
 \r
@@ -297,14 +295,13 @@ UsbBootReadBlocks (
   OUT UINT8                   *Buffer\r
   );\r
 \r
   OUT UINT8                   *Buffer\r
   );\r
 \r
-\r
 /**\r
   Write some blocks to the device.\r
 \r
   @param  UsbMass                The USB mass storage device to write to\r
   @param  Lba                    The start block number\r
   @param  TotalBlock             Total block number to write\r
 /**\r
   Write some blocks to the device.\r
 \r
   @param  UsbMass                The USB mass storage device to write to\r
   @param  Lba                    The start block number\r
   @param  TotalBlock             Total block number to write\r
-  @param  Buffer                 The buffer to write to\r
+  @param  Buffer                 Pointer to the source buffer for the data.\r
 \r
   @retval EFI_SUCCESS            Data are written into the buffer\r
   @retval Others                 Failed to write all the data\r
 \r
   @retval EFI_SUCCESS            Data are written into the buffer\r
   @retval Others                 Failed to write all the data\r
@@ -315,7 +312,24 @@ UsbBootWriteBlocks (
   IN  USB_MASS_DEVICE         *UsbMass,\r
   IN  UINT32                  Lba,\r
   IN  UINTN                   TotalBlock,\r
   IN  USB_MASS_DEVICE         *UsbMass,\r
   IN  UINT32                  Lba,\r
   IN  UINTN                   TotalBlock,\r
-  OUT UINT8                   *Buffer\r
+  IN  UINT8                   *Buffer\r
   );\r
   );\r
+\r
+/**\r
+  Use the USB clear feature control transfer to clear the endpoint stall condition.\r
+\r
+  @param  UsbIo                  The USB I/O Protocol instance\r
+  @param  EndpointAddr           The endpoint to clear stall for\r
+\r
+  @retval EFI_SUCCESS            The endpoint stall condition is cleared.\r
+  @retval Others                 Failed to clear the endpoint stall condition.\r
+\r
+**/\r
+EFI_STATUS\r
+UsbClearEndpointStall (\r
+  IN EFI_USB_IO_PROTOCOL    *UsbIo,\r
+  IN UINT8                  EndpointAddr\r
+  );\r
+\r
 #endif\r
 \r
 #endif\r
 \r
index 178aa80d3e3ab3560a4961fa7482591a0b3acb4c..c6c8f8d11b27780a7ebc33cf10368078aea8c4a4 100644 (file)
@@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
 \r
 **/\r
 \r
-#include "UsbMass.h"\r
+#include "UsbMassBoot.h"\r
 #include "UsbMassBot.h"\r
 \r
 //\r
 #include "UsbMassBot.h"\r
 \r
 //\r
@@ -58,9 +58,7 @@ UsbBotInit (
   //\r
   // Allocate the BOT context for USB_BOT_PROTOCOL and two endpoint descriptors.\r
   //\r
   //\r
   // Allocate the BOT context for USB_BOT_PROTOCOL and two endpoint descriptors.\r
   //\r
-  UsbBot = AllocateZeroPool (\r
-             sizeof (USB_BOT_PROTOCOL) + 2 * sizeof (EFI_USB_ENDPOINT_DESCRIPTOR)\r
-             );\r
+  UsbBot = AllocateZeroPool (sizeof (USB_BOT_PROTOCOL) + 2 * sizeof (EFI_USB_ENDPOINT_DESCRIPTOR));\r
   ASSERT (UsbBot != NULL);\r
 \r
   UsbBot->UsbIo = UsbIo;\r
   ASSERT (UsbBot != NULL);\r
 \r
   UsbBot->UsbIo = UsbIo;\r
@@ -103,7 +101,7 @@ UsbBotInit (
        (UsbBot->BulkOutEndpoint == NULL)) {\r
 \r
       UsbBot->BulkOutEndpoint   = (EFI_USB_ENDPOINT_DESCRIPTOR *) (UsbBot + 1) + 1;\r
        (UsbBot->BulkOutEndpoint == NULL)) {\r
 \r
       UsbBot->BulkOutEndpoint   = (EFI_USB_ENDPOINT_DESCRIPTOR *) (UsbBot + 1) + 1;\r
-      CopyMem(UsbBot->BulkOutEndpoint, &EndPoint, sizeof(EndPoint));\r
+      CopyMem (UsbBot->BulkOutEndpoint, &EndPoint, sizeof(EndPoint));\r
     }\r
   }\r
 \r
     }\r
   }\r
 \r
index 7f6f5fff8e3961bec8178d65cfa138acc1028b21..63d9fecd815db7da3afc4a15bc89f2493a0755b0 100644 (file)
@@ -17,6 +17,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #ifndef _EFI_USBMASS_BOT_H_\r
 #define _EFI_USBMASS_BOT_H_\r
 \r
 #ifndef _EFI_USBMASS_BOT_H_\r
 #define _EFI_USBMASS_BOT_H_\r
 \r
+#include "UsbMass.h"\r
+\r
 extern USB_MASS_TRANSPORT mUsbBotTransport;\r
 \r
 typedef enum {\r
 extern USB_MASS_TRANSPORT mUsbBotTransport;\r
 \r
 typedef enum {\r
index d56254b77c8d406244c90e5cdc8bd2571665b9a5..d1424e2f754b1138c1d1437d658467c9ce0b6911 100644 (file)
@@ -15,7 +15,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
 \r
 **/\r
 \r
-#include "UsbMass.h"\r
+#include "UsbMassBoot.h"\r
 #include "UsbMassCbi.h"\r
 \r
 //\r
 #include "UsbMassCbi.h"\r
 \r
 //\r
index ec4c3e14dab146ffd01a213bccd3ba0a7c466415..05f3795d17da287e8e6d918f605cbf5fc77105cc 100644 (file)
@@ -16,6 +16,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #ifndef _EFI_USBMASS_CBI_H_\r
 #define _EFI_USBMASS_CBI_H_\r
 \r
 #ifndef _EFI_USBMASS_CBI_H_\r
 #define _EFI_USBMASS_CBI_H_\r
 \r
+#include "UsbMass.h"\r
+\r
 extern USB_MASS_TRANSPORT mUsbCbi0Transport;\r
 extern USB_MASS_TRANSPORT mUsbCbi1Transport;\r
 \r
 extern USB_MASS_TRANSPORT mUsbCbi0Transport;\r
 extern USB_MASS_TRANSPORT mUsbCbi1Transport;\r
 \r
index 6efdf10af1363a2d692bcfa9b8a6f244587a3b79..0db4c143560662596a94183ce49590635286f5e9 100644 (file)
@@ -376,7 +376,7 @@ UsbMassInitMedia (
   @param  This            The USB mass driver's driver binding.\r
   @param  Controller      The device to test.\r
   @param  Transport       The pointer to pointer to USB_MASS_TRANSPORT.\r
   @param  This            The USB mass driver's driver binding.\r
   @param  Controller      The device to test.\r
   @param  Transport       The pointer to pointer to USB_MASS_TRANSPORT.\r
-  @param  Context         The passing parameter.\r
+  @param  Context         The parameter for USB_MASS_DEVICE.Context.\r
   @param  MaxLun          Get the MaxLun if is BOT dev.\r
 \r
   @retval EFI_SUCCESS     The initialization is successful.\r
   @param  MaxLun          Get the MaxLun if is BOT dev.\r
 \r
   @retval EFI_SUCCESS     The initialization is successful.\r
@@ -457,22 +457,23 @@ ON_EXIT:
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
-  Usb mass storage driver initializes multi lun.\r
+  Initialize data for device that supports multiple LUNSs.\r
 \r
 \r
-  @param  This            The USB mass driver's driver binding.\r
-  @param  Controller      The device to test.\r
-  @param  Transport       The pointer to USB_MASS_TRANSPORT.\r
-  @param  Context         The passing parameter.\r
-  @param  DevicePath      The remaining device path\r
-  @param  MaxLun          The MaxLun number passed.\r
+  @param  This                 The Driver Binding Protocol instance.\r
+  @param  Controller           The device to initialize.\r
+  @param  Transport            Pointer to USB_MASS_TRANSPORT.\r
+  @param  Context              Parameter for USB_MASS_DEVICE.Context.\r
+  @param  DevicePath           The remaining device path.\r
+  @param  MaxLun               The max LUN number.\r
 \r
 \r
-  @retval EFI_SUCCESS     Initialization is success.\r
-  @retval Other           Initialization fails.\r
+  @retval EFI_SUCCESS          At least one LUN is initialized successfully.\r
+  @retval EFI_OUT_OF_RESOURCES Out of resource while creating device path node.\r
+  @retval Other                Initialization fails.\r
 \r
 **/\r
 EFI_STATUS\r
 UsbMassInitMultiLun (\r
 \r
 **/\r
 EFI_STATUS\r
 UsbMassInitMultiLun (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN EFI_DRIVER_BINDING_PROTOCOL   *This,\r
   IN EFI_HANDLE                    Controller,\r
   IN USB_MASS_TRANSPORT            *Transport,\r
   IN VOID                          *Context,\r
   IN EFI_HANDLE                    Controller,\r
   IN USB_MASS_TRANSPORT            *Transport,\r
   IN VOID                          *Context,\r
@@ -494,10 +495,7 @@ UsbMassInitMultiLun (
     \r
     UsbIo   = NULL;\r
     UsbMass = AllocateZeroPool (sizeof (USB_MASS_DEVICE));\r
     \r
     UsbIo   = NULL;\r
     UsbMass = AllocateZeroPool (sizeof (USB_MASS_DEVICE));\r
-    if (UsbMass == NULL) {\r
-      Status = EFI_OUT_OF_RESOURCES;\r
-      goto ON_ERROR;\r
-    }\r
+    ASSERT (UsbMass != NULL);\r
       \r
     UsbMass->Signature            = USB_MASS_SIGNATURE;\r
     UsbMass->UsbIo                = UsbIo;\r
       \r
     UsbMass->Signature            = USB_MASS_SIGNATURE;\r
     UsbMass->UsbIo                = UsbIo;\r
@@ -512,11 +510,14 @@ UsbMassInitMultiLun (
     UsbMass->Lun                  = Index;\r
     \r
     //\r
     UsbMass->Lun                  = Index;\r
     \r
     //\r
-    // Get the storage's parameters, such as last block number.\r
-    // then install the BLOCK_IO\r
+    // Initialize the media parameter data for EFI_BLOCK_IO_MEDIA of Block I/O Protocol.\r
     //\r
     Status = UsbMassInitMedia (UsbMass);\r
     if (!EFI_ERROR (Status)) {\r
     //\r
     Status = UsbMassInitMedia (UsbMass);\r
     if (!EFI_ERROR (Status)) {\r
+      //\r
+      // According to USB Mass Storage Specification for Bootability, only following\r
+      // 4 Peripheral Device Types are in spec.\r
+      //\r
       if ((UsbMass->Pdt != USB_PDT_DIRECT_ACCESS) && \r
            (UsbMass->Pdt != USB_PDT_CDROM) &&\r
            (UsbMass->Pdt != USB_PDT_OPTICAL) && \r
       if ((UsbMass->Pdt != USB_PDT_DIRECT_ACCESS) && \r
            (UsbMass->Pdt != USB_PDT_CDROM) &&\r
            (UsbMass->Pdt != USB_PDT_OPTICAL) && \r
@@ -530,7 +531,7 @@ UsbMassInitMultiLun (
     }\r
 \r
     //\r
     }\r
 \r
     //\r
-    // Create a device path node of device logic unit, and append it \r
+    // Create a device path node for device logic unit, and append it.\r
     //\r
     LunNode.Header.Type    = MESSAGING_DEVICE_PATH;\r
     LunNode.Header.SubType = MSG_DEVICE_LOGICAL_UNIT_DP;\r
     //\r
     LunNode.Header.Type    = MESSAGING_DEVICE_PATH;\r
     LunNode.Header.SubType = MSG_DEVICE_LOGICAL_UNIT_DP;\r
@@ -548,7 +549,7 @@ UsbMassInitMultiLun (
     }\r
 \r
     //\r
     }\r
 \r
     //\r
-    // Create a UsbMass handle for each lun, and install blockio and devicepath protocols.\r
+    // Create a new handle for each LUN, and install Block I/O Protocol and Device Path Protocol.\r
     //\r
     Status = gBS->InstallMultipleProtocolInterfaces (\r
                     &UsbMass->Controller,\r
     //\r
     Status = gBS->InstallMultipleProtocolInterfaces (\r
                     &UsbMass->Controller,\r
@@ -565,7 +566,7 @@ UsbMassInitMultiLun (
     }\r
 \r
     //\r
     }\r
 \r
     //\r
-    // Open UsbIo protocol by child to setup a parent-child relationship.\r
+    // Open USB I/O Protocol by child to setup a parent-child relationship.\r
     //\r
     Status = gBS->OpenProtocol (\r
                     Controller,\r
     //\r
     Status = gBS->OpenProtocol (\r
                     Controller,\r
@@ -596,10 +597,10 @@ UsbMassInitMultiLun (
 \r
 ON_ERROR:\r
   if (UsbMass->DevicePath != NULL) {\r
 \r
 ON_ERROR:\r
   if (UsbMass->DevicePath != NULL) {\r
-    gBS->FreePool (UsbMass->DevicePath);\r
+    FreePool (UsbMass->DevicePath);\r
   }\r
   if (UsbMass != NULL) {\r
   }\r
   if (UsbMass != NULL) {\r
-    gBS->FreePool (UsbMass);\r
+    FreePool (UsbMass);\r
   }\r
   if (UsbIo != NULL) {\r
     gBS->CloseProtocol (\r
   }\r
   if (UsbIo != NULL) {\r
     gBS->CloseProtocol (\r
@@ -611,7 +612,7 @@ ON_ERROR:
   }\r
 \r
   //\r
   }\r
 \r
   //\r
-  // If only success to initialize one lun, return success, or else return error\r
+  // Return EFI_SUCCESS if at least one LUN is initialized successfully.\r
   //\r
   if (Index > 0) {\r
     return EFI_SUCCESS; \r
   //\r
   if (Index > 0) {\r
     return EFI_SUCCESS; \r
@@ -621,14 +622,14 @@ ON_ERROR:
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
-  Initialize No/Unsupported LUN device.\r
+  Initialize data for device that does not support multiple LUNSs.\r
 \r
 \r
-  @param This             The USB mass driver's driver binding.\r
-  @param Controller       The device to test.\r
-  @param Transport        The pointer to USB_MASS_TRANSPORT.\r
-  @param Context          The passing parameter.\r
+  @param  This            The Driver Binding Protocol instance.\r
+  @param  Controller      The device to initialize.\r
+  @param  Transport       Pointer to USB_MASS_TRANSPORT.\r
+  @param  Context         Parameter for USB_MASS_DEVICE.Context.\r
 \r
 \r
-  @retval EFI_SUCCESS     Initialization is success.\r
+  @retval EFI_SUCCESS     Initialization succeeds.\r
   @retval Other           Initialization fails.\r
 \r
 **/\r
   @retval Other           Initialization fails.\r
 \r
 **/\r
@@ -646,9 +647,8 @@ UsbMassInitNonLun (
 \r
   UsbIo   = NULL;\r
   UsbMass = AllocateZeroPool (sizeof (USB_MASS_DEVICE));\r
 \r
   UsbIo   = NULL;\r
   UsbMass = AllocateZeroPool (sizeof (USB_MASS_DEVICE));\r
-  if (UsbMass == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
+  ASSERT (UsbMass != NULL);\r
+\r
   Status = gBS->OpenProtocol (\r
                   Controller,\r
                   &gEfiUsbIoProtocolGuid,\r
   Status = gBS->OpenProtocol (\r
                   Controller,\r
                   &gEfiUsbIoProtocolGuid,\r
@@ -676,11 +676,14 @@ UsbMassInitNonLun (
   UsbMass->Context              = Context;\r
   \r
   //\r
   UsbMass->Context              = Context;\r
   \r
   //\r
-  // Get the storage's parameters, such as last block number.\r
-  // then install the BLOCK_IO\r
+  // Initialize the media parameter data for EFI_BLOCK_IO_MEDIA of Block I/O Protocol.\r
   //\r
   Status = UsbMassInitMedia (UsbMass);\r
   if (!EFI_ERROR (Status)) {\r
   //\r
   Status = UsbMassInitMedia (UsbMass);\r
   if (!EFI_ERROR (Status)) {\r
+    //\r
+    // According to USB Mass Storage Specification for Bootability, only following\r
+    // 4 Peripheral Device Types are in spec.\r
+    //\r
     if ((UsbMass->Pdt != USB_PDT_DIRECT_ACCESS) && \r
          (UsbMass->Pdt != USB_PDT_CDROM) &&\r
          (UsbMass->Pdt != USB_PDT_OPTICAL) && \r
     if ((UsbMass->Pdt != USB_PDT_DIRECT_ACCESS) && \r
          (UsbMass->Pdt != USB_PDT_CDROM) &&\r
          (UsbMass->Pdt != USB_PDT_OPTICAL) && \r
@@ -707,7 +710,7 @@ UsbMassInitNonLun (
 \r
 ON_ERROR:\r
   if (UsbMass != NULL) {\r
 \r
 ON_ERROR:\r
   if (UsbMass != NULL) {\r
-    gBS->FreePool (UsbMass);\r
+    FreePool (UsbMass);\r
   }\r
   gBS->CloseProtocol (\r
          Controller,\r
   }\r
   gBS->CloseProtocol (\r
          Controller,\r
@@ -796,7 +799,6 @@ ON_EXIT:
   return Status;\r
 }\r
 \r
   return Status;\r
 }\r
 \r
-\r
 /**\r
   Starts the USB mass storage device with this driver.\r
 \r
 /**\r
   Starts the USB mass storage device with this driver.\r
 \r
@@ -804,9 +806,9 @@ ON_EXIT:
   installs Block I/O Protocol, and submits Asynchronous Interrupt\r
   Transfer to manage the USB mass storage device.\r
 \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
+  @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
 \r
   @retval EFI_SUCCESS           This driver supports this device.\r
   @retval EFI_UNSUPPORTED       This driver does not support this device.\r
@@ -833,9 +835,6 @@ USBMassDriverBindingStart (
   Context   = NULL;\r
   MaxLun    = 0;\r
 \r
   Context   = NULL;\r
   MaxLun    = 0;\r
 \r
-  //\r
-  // Get interface and protocols, initialize transport\r
-  //\r
   Status = UsbMassInitTransport (This, Controller, &Transport, &Context, &MaxLun);\r
 \r
   if (EFI_ERROR (Status)) {\r
   Status = UsbMassInitTransport (This, Controller, &Transport, &Context, &MaxLun);\r
 \r
   if (EFI_ERROR (Status)) {\r
@@ -844,15 +843,15 @@ USBMassDriverBindingStart (
   }\r
   if (MaxLun == 0) {\r
     //\r
   }\r
   if (MaxLun == 0) {\r
     //\r
-    // Initialize No/Unsupported LUN device\r
+    // Initialize data for device that does not support multiple LUNSs.\r
     //\r
     //\r
-    Status = UsbMassInitNonLun(This, Controller, Transport, Context);\r
+    Status = UsbMassInitNonLun (This, Controller, Transport, Context);\r
     if (EFI_ERROR (Status)) { \r
       DEBUG ((EFI_D_ERROR, "USBMassDriverBindingStart: UsbMassInitNonLun (%r)\n", Status));\r
     }\r
   } else {\r
     //\r
     if (EFI_ERROR (Status)) { \r
       DEBUG ((EFI_D_ERROR, "USBMassDriverBindingStart: UsbMassInitNonLun (%r)\n", Status));\r
     }\r
   } else {\r
     //\r
-    // Open device path to prepare append Device Logic Unit node.\r
+    // Open device path to prepare for appending Device Logic Unit node.\r
     //\r
     Status = gBS->OpenProtocol (\r
                     Controller,\r
     //\r
     Status = gBS->OpenProtocol (\r
                     Controller,\r
@@ -869,7 +868,8 @@ USBMassDriverBindingStart (
     }\r
 \r
     //\r
     }\r
 \r
     //\r
-    // Try best to initialize all LUNs, and return success only if one of LUNs successed to initialized.\r
+    // Initialize data for device that supports multiple LUNSs.\r
+    // EFI_SUCCESS is returned if at least 1 LUN is initialized successfully.\r
     //\r
     Status = UsbMassInitMultiLun (This, Controller, Transport, Context, DevicePath, MaxLun);\r
     if (EFI_ERROR (Status)) {\r
     //\r
     Status = UsbMassInitMultiLun (This, Controller, Transport, Context, DevicePath, MaxLun);\r
     if (EFI_ERROR (Status)) {\r
@@ -895,6 +895,8 @@ USBMassDriverBindingStart (
   @param  ChildHandleBuffer      The buffer of children handle.\r
 \r
   @retval EFI_SUCCESS            The driver stopped from controlling the 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
   @retval Others                 Failed to stop the driver\r
 \r
 **/\r
@@ -909,17 +911,17 @@ USBMassDriverBindingStop (
 {\r
   EFI_STATUS            Status;\r
   USB_MASS_DEVICE       *UsbMass;\r
 {\r
   EFI_STATUS            Status;\r
   USB_MASS_DEVICE       *UsbMass;\r
-  EFI_USB_IO_PROTOCOL     *UsbIo;\r
+  EFI_USB_IO_PROTOCOL   *UsbIo;\r
   EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
   EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
-  UINTN                   Index;\r
-  BOOLEAN                 AllChildrenStopped;\r
+  UINTN                 Index;\r
+  BOOLEAN               AllChildrenStopped;\r
 \r
   //\r
 \r
   //\r
-  // This a bus driver stop function since multi-lun supported. There are three \r
-  // kinds of device handle might be passed, 1st is a handle with devicepath/\r
-  // usbio/blockio installed(non-multi-lun), 2nd is a handle with devicepath/\r
-  // usbio installed(multi-lun root), 3rd is a handle with devicepath/blockio\r
-  // installed(multi-lun).\r
+  // This is a bus driver stop function since multi-lun is supported.\r
+  // There are three kinds of device handles that might be passed:\r
+  // 1st is a handle with Device Path & USB I/O & Block I/O installed (non-multi-lun)\r
+  // 2nd is a handle with Device Path & USB I/O installed (multi-lun root)\r
+  // 3rd is a handle with Device Path & Block I/O installed (multi-lun).\r
   //\r
   if (NumberOfChildren == 0) {\r
     //\r
   //\r
   if (NumberOfChildren == 0) {\r
     //\r
@@ -936,8 +938,8 @@ USBMassDriverBindingStop (
   \r
     if (EFI_ERROR(Status)) {\r
       //\r
   \r
     if (EFI_ERROR(Status)) {\r
       //\r
-      // This is a 2nd type handle(multi-lun root), which only needs close \r
-      // devicepath protocol.\r
+      // This is a 2nd type handle(multi-lun root), which only needs to close \r
+      // Device Path Protocol.\r
       //\r
       gBS->CloseProtocol (\r
             Controller,\r
       //\r
       gBS->CloseProtocol (\r
             Controller,\r
@@ -950,8 +952,8 @@ USBMassDriverBindingStop (
     }\r
     \r
     //\r
     }\r
     \r
     //\r
-    // This is a 1st type handle(non-multi-lun), which only needs uninstall\r
-    // blockio protocol, close usbio protocol and free mass device.\r
+    // This is a 1st type handle(non-multi-lun), which only needs to uninstall\r
+    // Block I/O Protocol, close USB I/O Protocol and free mass device.\r
     //\r
     UsbMass = USB_MASS_DEVICE_FROM_BLOCK_IO (BlockIo);\r
   \r
     //\r
     UsbMass = USB_MASS_DEVICE_FROM_BLOCK_IO (BlockIo);\r
   \r
@@ -976,7 +978,7 @@ USBMassDriverBindingStop (
           );\r
   \r
     UsbMass->Transport->CleanUp (UsbMass->Context);\r
           );\r
   \r
     UsbMass->Transport->CleanUp (UsbMass->Context);\r
-    gBS->FreePool (UsbMass);\r
+    FreePool (UsbMass);\r
     \r
     DEBUG ((EFI_D_INFO, "Success to stop non-multi-lun root handle\n"));\r
     return EFI_SUCCESS;\r
     \r
     DEBUG ((EFI_D_INFO, "Success to stop non-multi-lun root handle\n"));\r
     return EFI_SUCCESS;\r
@@ -984,8 +986,8 @@ USBMassDriverBindingStop (
 \r
   //\r
   // This is a 3rd type handle(multi-lun), which needs uninstall\r
 \r
   //\r
   // This is a 3rd type handle(multi-lun), which needs uninstall\r
-  // blockio and devicepath protocol, close usbio protocol and \r
-  // free mass device.\r
+  // Block I/O Protocol and Device Path Protocol, close USB I/O Protocol and \r
+  // free mass device for all children.\r
   //\r
   AllChildrenStopped = TRUE;\r
 \r
   //\r
   AllChildrenStopped = TRUE;\r
 \r
@@ -1008,11 +1010,11 @@ USBMassDriverBindingStop (
     UsbMass = USB_MASS_DEVICE_FROM_BLOCK_IO (BlockIo);\r
 \r
     gBS->CloseProtocol (\r
     UsbMass = USB_MASS_DEVICE_FROM_BLOCK_IO (BlockIo);\r
 \r
     gBS->CloseProtocol (\r
-          Controller,\r
-          &gEfiUsbIoProtocolGuid,\r
-          This->DriverBindingHandle,\r
-          ChildHandleBuffer[Index]\r
-          );\r
+           Controller,\r
+           &gEfiUsbIoProtocolGuid,\r
+           This->DriverBindingHandle,\r
+           ChildHandleBuffer[Index]\r
+           );\r
   \r
     Status = gBS->UninstallMultipleProtocolInterfaces (\r
                     ChildHandleBuffer[Index],\r
   \r
     Status = gBS->UninstallMultipleProtocolInterfaces (\r
                     ChildHandleBuffer[Index],\r
@@ -1025,7 +1027,7 @@ USBMassDriverBindingStop (
     \r
     if (EFI_ERROR (Status)) {\r
       //\r
     \r
     if (EFI_ERROR (Status)) {\r
       //\r
-      // Fail to uninstall blockio and devicepath protocol, so re-open usbio by child.\r
+      // Fail to uninstall Block I/O Protocol and Device Path Protocol, so re-open USB I/O Protocol by child.\r
       //\r
       AllChildrenStopped = FALSE;\r
       DEBUG ((EFI_D_ERROR, "Fail to stop No.%d multi-lun child handle when uninstalling blockio and devicepath\n", (UINT32)Index));\r
       //\r
       AllChildrenStopped = FALSE;\r
       DEBUG ((EFI_D_ERROR, "Fail to stop No.%d multi-lun child handle when uninstalling blockio and devicepath\n", (UINT32)Index));\r
@@ -1040,12 +1042,12 @@ USBMassDriverBindingStop (
              );\r
     } else {\r
       //\r
              );\r
     } else {\r
       //\r
-      // Success to stop this multi-lun handle, so go on next child.\r
+      // Succeed to stop this multi-lun handle, so go on with next child.\r
       //\r
       if (((Index + 1) == NumberOfChildren) && AllChildrenStopped) {\r
         UsbMass->Transport->CleanUp (UsbMass->Context);\r
       }\r
       //\r
       if (((Index + 1) == NumberOfChildren) && AllChildrenStopped) {\r
         UsbMass->Transport->CleanUp (UsbMass->Context);\r
       }\r
-      gBS->FreePool (UsbMass);\r
+      FreePool (UsbMass);\r
     }\r
   }\r
 \r
     }\r
   }\r
 \r
@@ -1053,19 +1055,20 @@ USBMassDriverBindingStop (
     return EFI_DEVICE_ERROR;\r
   }\r
   \r
     return EFI_DEVICE_ERROR;\r
   }\r
   \r
-  DEBUG ((EFI_D_INFO, "Success to stop all %d multi-lun children handles\n", (UINT32)NumberOfChildren));\r
+  DEBUG ((EFI_D_INFO, "Success to stop all %d multi-lun children handles\n", (UINT32) NumberOfChildren));\r
   return EFI_SUCCESS;\r
 }\r
 \r
 /**\r
   return EFI_SUCCESS;\r
 }\r
 \r
 /**\r
-  The entry point for the driver, which will install the driver binding and\r
-  component name protocol.\r
+  Entrypoint of USB Mass Storage Driver.\r
+\r
+  This function is the entrypoint of USB Mass Storage Driver. It installs Driver Binding\r
+  Protocol together with Component Name Protocols.\r
 \r
 \r
-  @param  ImageHandle       The image handle of this driver.\r
-  @param  SystemTable       The system table.\r
+  @param  ImageHandle       The firmware allocated handle for the EFI image.\r
+  @param  SystemTable       A pointer to the EFI System Table.\r
 \r
 \r
-  @retval EFI_SUCCESS       The protocols are installed OK.\r
-  @retval Others            Failed to install protocols.\r
+  @retval EFI_SUCCESS       The entry point is executed successfully.\r
 \r
 **/\r
 EFI_STATUS\r
 \r
 **/\r
 EFI_STATUS\r
index c4c987f2f6848211d4cef956257ca74902fe582b..252cde2ff1d815ead538a6168357a1712e2e5b4d 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 /** @file\r
-\r
-  The implementation of USB mass storage class device driver.\r
+  Definitions of functions for Driver Binding Protocol and Block I/O Protocol,\r
+  and other internal definitions.\r
 \r
 Copyright (c) 2007 - 2008, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
 \r
 Copyright (c) 2007 - 2008, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
@@ -16,8 +16,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #ifndef _EFI_USBMASS_IMPL_H_\r
 #define _EFI_USBMASS_IMPL_H_\r
 \r
 #ifndef _EFI_USBMASS_IMPL_H_\r
 #define _EFI_USBMASS_IMPL_H_\r
 \r
-typedef struct _USB_MASS_DEVICE USB_MASS_DEVICE;\r
-\r
 #include "UsbMass.h"\r
 #include "UsbMassBot.h"\r
 #include "UsbMassCbi.h"\r
 #include "UsbMass.h"\r
 #include "UsbMassBot.h"\r
 #include "UsbMassCbi.h"\r
@@ -25,20 +23,6 @@ typedef struct _USB_MASS_DEVICE USB_MASS_DEVICE;
 \r
 #define  USB_MASS_SIGNATURE    SIGNATURE_32 ('U', 's', 'b', 'M')\r
 \r
 \r
 #define  USB_MASS_SIGNATURE    SIGNATURE_32 ('U', 's', 'b', 'M')\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_BLOCK_IO(a) \\r
         CR (a, USB_MASS_DEVICE, BlockIo, USB_MASS_SIGNATURE)\r
 \r
 #define USB_MASS_DEVICE_FROM_BLOCK_IO(a) \\r
         CR (a, USB_MASS_DEVICE, BlockIo, USB_MASS_SIGNATURE)\r
 \r
@@ -75,9 +59,9 @@ USBMassDriverBindingSupported (
   installs Block I/O Protocol, and submits Asynchronous Interrupt\r
   Transfer to manage the USB mass storage device.\r
 \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
+  @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
 \r
   @retval EFI_SUCCESS           This driver supports this device.\r
   @retval EFI_UNSUPPORTED       This driver does not support this device.\r
@@ -103,6 +87,8 @@ USBMassDriverBindingStart (
   @param  ChildHandleBuffer      The buffer of children handle.\r
 \r
   @retval EFI_SUCCESS            The driver stopped from controlling the 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
   @retval Others                 Failed to stop the driver\r
 \r
 **/\r
@@ -230,5 +216,119 @@ UsbMassFlushBlocks (
   IN EFI_BLOCK_IO_PROTOCOL  *This\r
   );\r
 \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 3066 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 3066 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 not a valid EFI_HANDLE.\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
 \r
 #endif\r
index e9bdf4ef27e90adb20808981361291bbe479a2e9..0025e86f9d137ad219222a524dac14e25b804d96 100644 (file)
@@ -1,5 +1,13 @@
 #/** @file\r
 #/** @file\r
-# Component name for module UsbMassStorage\r
+# USB Mass Storage Driver that manages USB mass storage devices and\r
+# produces Block I/O Protocol.\r
+#\r
+# The USB mass storage class is specified in two layers: the bottom layer\r
+# is the transportation protocol. The top layer is the command set.\r
+# The transportation layer provides the transportation of the command, data and result.\r
+# The command set defines the command, data and result.\r
+# The Bulk-Only-Transport and Control/Bulk/Interrupt transport are two transportation protocol.\r
+# USB mass storage class adopts various industrial standard as its command set.\r
 #\r
 # Copyright (c) 2006 - 2008, Intel Corporation. \r
 #\r
 #\r
 # Copyright (c) 2006 - 2008, Intel Corporation. \r
 #\r
@@ -59,7 +67,7 @@
 \r
 \r
 [Protocols]\r
 \r
 \r
 [Protocols]\r
-  gEfiUsbIoProtocolGuid                         # PROTOCOL ALWAYS_CONSUMED\r
-  gEfiBlockIoProtocolGuid                       # PROTOCOL ALWAYS_PRODUCED\r
-  gEfiDevicePathProtocolGuid                    # PROTOCOL ALWAYS_CONSUMED\r
+  gEfiUsbIoProtocolGuid                         # PROTOCOL TO_START\r
+  gEfiDevicePathProtocolGuid                    # PROTOCOL TO_START\r
+  gEfiBlockIoProtocolGuid                       # PROTOCOL BY_START\r
 \r
 \r