]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c
check the usage of %d,%x,%ld,%lx and so on in debug print statement.
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbMassStorageDxe / UsbMassBoot.c
index 9b2ba5ab390d5567bc15ba000877eafbea47e3a0..589087accd9ed73141f1c54c4741ba4fa05f3740 100644 (file)
@@ -1,5 +1,8 @@
 /** @file\r
 \r
+  This file implement the command set of "USB Mass Storage Specification\r
+  for Bootability".\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
@@ -9,42 +12,21 @@ http://opensource.org/licenses/bsd-license.php
 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
 \r
-Module Name:\r
-\r
-  UsbMassBoot.c\r
+**/\r
 \r
-Abstract:\r
+#include "UsbMassImpl.h"\r
 \r
-  This file implement the command set of "USB Mass Storage Specification\r
-  for Bootability".\r
 \r
-Revision History\r
+/**\r
+  Return the current TPL.\r
 \r
+  @return Current TPL.\r
 \r
 **/\r
-\r
-#include "UsbMassImpl.h"\r
-\r
-\r
 EFI_TPL\r
 UsbGetCurrentTpl (\r
   VOID\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  return the current TPL, copied from the EDKII glue lib.\r
-\r
-Arguments:\r
-\r
-  VOID\r
-\r
-Returns:\r
-\r
-  Current TPL\r
-\r
---*/\r
 {\r
   EFI_TPL                 Tpl;\r
 \r
@@ -57,7 +39,7 @@ Returns:
 /**\r
   Read an UINT32 from the buffer to avoid byte alignment problems, then\r
   convert that to the little endia. The USB mass storage bootability spec\r
-  use big endia\r
+  use big endia.\r
 \r
   @param  Buf                    The buffer contains the first byte of the UINT32\r
                                  in big endia.\r
@@ -65,7 +47,6 @@ Returns:
   @return The UINT32 value read from the buffer in little endia.\r
 \r
 **/\r
-STATIC\r
 UINT32\r
 UsbBootGetUint32 (\r
   IN UINT8                  *Buf\r
@@ -82,13 +63,12 @@ UsbBootGetUint32 (
   Put an UINT32 in little endia to the buffer. The data is converted to\r
   big endia before writing.\r
 \r
-  @param  Buf                    The buffer to write data to\r
+  @param  Buf                    The buffer to write data to.\r
   @param  Data32                 The data to write.\r
 \r
-  @return None\r
+  @return None.\r
 \r
 **/\r
-STATIC\r
 VOID\r
 UsbBootPutUint32 (\r
   IN UINT8                  *Buf,\r
@@ -99,18 +79,16 @@ UsbBootPutUint32 (
   CopyMem (Buf, &Data32, sizeof (UINT32));\r
 }\r
 \r
-\r
 /**\r
   Put an UINT16 in little endia to the buffer. The data is converted to\r
   big endia before writing.\r
 \r
-  @param  Buf                    The buffer to write data to\r
-  @param  Data16                 The data to write\r
+  @param  Buf                    The buffer to write data to.\r
+  @param  Data16                 The data to write.\r
 \r
-  @return None\r
+  @return None.\r
 \r
 **/\r
-STATIC\r
 VOID\r
 UsbBootPutUint16 (\r
   IN UINT8                   *Buf,\r
@@ -121,15 +99,18 @@ UsbBootPutUint16 (
   CopyMem (Buf, &Data16, sizeof (UINT16));\r
 }\r
 \r
-\r
 /**\r
   Request sense information via sending Request Sense\r
   Packet Command.\r
 \r
-  @param  UsbMass                The device to be requested sense data\r
+  @param  UsbMass                The device to be requested sense data.\r
 \r
-  @retval EFI_DEVICE_ERROR       Hardware error\r
-  @retval EFI_SUCCESS            Success\r
+  @retval EFI_SUCCESS            The command is excuted OK.\r
+  @retval EFI_DEVICE_ERROR       Failed to request sense.\r
+  @retval EFI_NO_RESPONSE        The device media doesn't response this request.\r
+  @retval EFI_INVALID_PARAMETER  The command has some invalid parameters.\r
+  @retval EFI_WRITE_PROTECTED    The device is write protected.\r
+  @retval EFI_MEDIA_CHANGED      The device media has been changed.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -257,7 +238,6 @@ UsbBootRequestSense (
   @retval EFI_MEDIA_CHANGED      The device media has been changed\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 UsbBootExecCmd (\r
   IN USB_MASS_DEVICE            *UsbMass,\r
@@ -311,6 +291,7 @@ UsbBootExecCmd (
   @param  DataDir                The direction of data transfer\r
   @param  Data                   The buffer to hold the data\r
   @param  DataLen                The length of expected data\r
+  @param  Timeout                The timeout used to transfer\r
 \r
   @retval EFI_SUCCESS            The command is excuted OK\r
   @retval EFI_DEVICE_ERROR       Failed to request sense\r
@@ -319,7 +300,6 @@ UsbBootExecCmd (
   @retval EFI_MEDIA_CHANGED      The device media has been changed\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 UsbBootExecCmdWithRetry (\r
   IN USB_MASS_DEVICE          *UsbMass,\r
@@ -369,7 +349,6 @@ UsbBootExecCmdWithRetry (
 }\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
@@ -471,7 +450,8 @@ UsbBootInquiry (
 \r
   @retval EFI_SUCCESS            The disk gemotric is successfully retrieved.\r
   @retval EFI_DEVICE_ERROR       Something is inconsistent with the disk gemotric.\r
-\r
+  @retval Other                  Read capacity request fails.\r
\r
 **/\r
 EFI_STATUS\r
 UsbBootReadCapacity (\r
@@ -521,15 +501,14 @@ UsbBootReadCapacity (
   return EFI_SUCCESS;\r
 }\r
 \r
-\r
 /**\r
   Retrieves mode sense information via sending Mode Sense\r
   Packet Command.\r
 \r
   @param  UsbMass                The USB_FLOPPY_DEV instance.\r
 \r
-  @retval EFI_DEVICE_ERROR       Hardware error\r
   @retval EFI_SUCCESS            Success\r
+  @retval Other                  Execute Request command fails.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -570,7 +549,7 @@ UsbScsiModeSense (
   // devices support this command, so have a try here.\r
   //\r
   if (!EFI_ERROR (Status)) {\r
-    Media->ReadOnly = (BOOLEAN) ((ModeParaHeader.DevicePara & 0x80) ? TRUE : FALSE);\r
+    Media->ReadOnly = (BOOLEAN) (((ModeParaHeader.DevicePara & 0x80) != 0) ? TRUE : FALSE);\r
   }\r
 \r
   return Status;\r
@@ -588,7 +567,7 @@ UsbScsiModeSense (
   @param  UsbMass                The device to retireve disk gemotric.\r
 \r
   @retval EFI_SUCCESS            The disk gemotric is successfully retrieved.\r
-  @retval EFI_DEVICE_ERROR       Something is inconsistent with the disk gemotric.\r
+  @retval Other                  Get the parameters failed.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -646,7 +625,7 @@ UsbBootGetParams (
   @param  UsbMass                The device to retireve disk gemotric.\r
 \r
   @retval EFI_SUCCESS            The disk gemotric is successfully retrieved.\r
-  @retval EFI_DEVICE_ERROR       Something is inconsistent with the disk gemotric.\r
+  @retval Other                  Decect media fails.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -711,7 +690,7 @@ ON_ERROR:
       (Media->LastBlock != OldMedia.LastBlock)) {\r
 \r
     OldTpl = UsbGetCurrentTpl ();\r
-    DEBUG ((EFI_D_ERROR, "UsbBootDetectMedia: TPL before reinstall BlockIoProtocol is %d\n", OldTpl));\r
+    DEBUG ((EFI_D_ERROR, "UsbBootDetectMedia: TPL before reinstall BlockIoProtocol is %d\n", (UINT32)OldTpl));\r
 \r
     gBS->RestoreTPL (TPL_CALLBACK);\r
 \r
@@ -722,7 +701,7 @@ ON_ERROR:
            &UsbMass->BlockIo\r
            );\r
 \r
-    DEBUG ((EFI_D_ERROR, "UsbBootDetectMedia: TPL after reinstall is %d\n", UsbGetCurrentTpl()));\r
+    DEBUG ((EFI_D_ERROR, "UsbBootDetectMedia: TPL after reinstall is %d\n", (UINT32)UsbGetCurrentTpl()));\r
     ASSERT (UsbGetCurrentTpl () == TPL_CALLBACK);\r
 \r
     gBS->RaiseTPL (OldTpl);\r