]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Isa Floppy driver code scrub.
authorrsun3 <rsun3@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 1 Jul 2009 05:48:44 +0000 (05:48 +0000)
committerrsun3 <rsun3@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 1 Jul 2009 05:48:44 +0000 (05:48 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8697 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/ComponentName.c
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/ComponentName.h
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppy.c
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppy.h
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyBlock.c
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyCtrl.c
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxe.inf

index a02e3683d3f7c280bdcff62de632de65137bde90..624f725ab2bd0efca91388ed838273c3f92904b1 100644 (file)
@@ -1,6 +1,7 @@
-/**@file\r
+/** @file\r
+  UEFI Component Name(2) protocol implementation for Isa Floppy driver.\r
 \r
-Copyright (c) 2006 - 2007, Intel Corporation.<BR>\r
+Copyright (c) 2006 - 2009, Intel Corporation. <BR>\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
@@ -53,10 +54,9 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIsaFloppyDriverNameTable
   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[in]  This              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
+  @param[in]  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
@@ -64,23 +64,18 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIsaFloppyDriverNameTable
                                 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
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
+  @param[out]  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
 \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
@@ -112,15 +107,13 @@ IsaFloppyComponentNameGetDriverName (
   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[in]  This              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
+  @param[in]  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
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
+  @param[in]  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
@@ -128,8 +121,7 @@ IsaFloppyComponentNameGetDriverName (
                                 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[in]  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
@@ -137,8 +129,7 @@ IsaFloppyComponentNameGetDriverName (
                                 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
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
+  @param[out]  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
@@ -149,72 +140,55 @@ IsaFloppyComponentNameGetDriverName (
                                 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
 IsaFloppyComponentNameGetControllerName (\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
+  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
-  EFI_STATUS                            Status;\r
-  EFI_BLOCK_IO_PROTOCOL                 *BlkIo;\r
-  FDC_BLK_IO_DEV                        *FdcDev;\r
-  EFI_ISA_IO_PROTOCOL                   *IsaIoProtocol;\r
+  EFI_STATUS             Status;\r
+  EFI_BLOCK_IO_PROTOCOL  *BlkIo;\r
+  FDC_BLK_IO_DEV         *FdcDev;\r
 \r
+  if (Language == NULL || ControllerName == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
   //\r
   // This is a device driver, so ChildHandle must be NULL.\r
   //\r
   if (ChildHandle != NULL) {\r
     return EFI_UNSUPPORTED;\r
   }\r
+\r
   //\r
-  // Check Controller's handle\r
+  // Check if this driver is currently managing ControllerHandle\r
   //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEfiIsaIoProtocolGuid,\r
-                  (VOID **) &IsaIoProtocol,\r
-                  gFdcControllerDriver.DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-    gBS->CloseProtocol (\r
-           ControllerHandle,\r
-           &gEfiIsaIoProtocolGuid,\r
-           gFdcControllerDriver.DriverBindingHandle,\r
-           ControllerHandle\r
-           );\r
-\r
-    return EFI_UNSUPPORTED;\r
+  Status = EfiTestManagedDevice (\r
+             ControllerHandle,\r
+             gFdcControllerDriver.DriverBindingHandle,\r
+             &gEfiIsaIoProtocolGuid\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
   }\r
 \r
-  if (Status != EFI_ALREADY_STARTED) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
   //\r
-  // Get the Block I/O Protocol on Controller\r
+  // Get the device context\r
   //\r
   Status = gBS->OpenProtocol (\r
                   ControllerHandle,\r
@@ -227,9 +201,7 @@ IsaFloppyComponentNameGetControllerName (
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
-  //\r
-  // Get the Floppy Disk Controller's Device structure\r
-  //\r
+\r
   FdcDev = FDD_BLK_IO_FROM_THIS (BlkIo);\r
 \r
   return LookupUnicodeString2 (\r
@@ -244,33 +216,34 @@ IsaFloppyComponentNameGetControllerName (
 /**\r
   Add the component name for the floppy device\r
 \r
-  @param  FdcDev                 - A pointer to the FDC_BLK_IO_DEV instance.\r
+  @param[in]  FdcDev  A pointer to the FDC_BLK_IO_DEV instance.\r
 \r
 **/\r
 VOID\r
 AddName (\r
-  IN  FDC_BLK_IO_DEV         *FdcDev\r
+  IN  FDC_BLK_IO_DEV  *FdcDev\r
   )\r
-\r
 {\r
-  CHAR16  FloppyDriveName[FLOPPY_DRIVE_NAME_ASCII_LEN + 1];\r
-\r
-  StrCpy (FloppyDriveName, FLOPPY_DRIVE_NAME);\r
-  FloppyDriveName[FLOPPY_DRIVE_NAME_ASCII_LEN - 1] = (CHAR16) (L'0' + FdcDev->Disk);\r
-  AddUnicodeString2 (\r
-    "eng",\r
-    gIsaFloppyComponentName.SupportedLanguages,\r
-    &FdcDev->ControllerNameTable,\r
-    FloppyDriveName,\r
-    TRUE\r
-    );\r
-  AddUnicodeString2 (\r
-    "en",\r
-    gIsaFloppyComponentName2.SupportedLanguages,\r
-    &FdcDev->ControllerNameTable,\r
-    FloppyDriveName,\r
-    FALSE\r
-    );\r
-\r
+  CHAR16  FloppyDriveName[FLOPPY_DRIVE_NAME_LEN + 1];\r
+\r
+  if (!(FeaturePcdGet(PcdComponentNameDisable) && FeaturePcdGet(PcdComponentName2Disable))) {\r
+    StrCpy (FloppyDriveName, FLOPPY_DRIVE_NAME);\r
+    FloppyDriveName[FLOPPY_DRIVE_NAME_LEN - 1] = (CHAR16) (L'0' + FdcDev->Disk);\r
+\r
+    AddUnicodeString2 (\r
+      "eng",\r
+      gIsaFloppyComponentName.SupportedLanguages,\r
+      &FdcDev->ControllerNameTable,\r
+      FloppyDriveName,\r
+      TRUE\r
+      );\r
+    AddUnicodeString2 (\r
+      "en",\r
+      gIsaFloppyComponentName2.SupportedLanguages,\r
+      &FdcDev->ControllerNameTable,\r
+      FloppyDriveName,\r
+      FALSE\r
+      );\r
+  }\r
 }\r
 \r
index 2a36821da0a83541c8deadedd6ecf1bfd441b59e..09dc2d29f9291c3e0ee3a631558805fc6e8e9ff6 100644 (file)
@@ -1,6 +1,7 @@
-/**@file\r
+/** @file\r
+  Header file for implementation of UEFI Component Name(2) protocol.\r
 \r
-Copyright (c) 2006 - 2007, Intel Corporation.<BR>\r
+Copyright (c) 2006 - 2009, Intel Corporation<BR>\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
@@ -11,19 +12,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
-#ifndef _ISA_FLOPPY_COMPONENT_NAME_H\r
-#define _ISA_FLOPPY_COMPONENT_NAME_H\r
+#ifndef _COMPONENT_NAME_H_\r
+#define _COMPONENT_NAME_H_\r
 \r
-#define FLOPPY_DRIVE_NAME           L"ISA Floppy Drive # "\r
-#define FLOPPY_DRIVE_NAME_ASCII_LEN (sizeof ("ISA Floppy Drive # ") - 1)\r
-#define ADD_FLOPPY_NAME(x)                 AddName ((x))\r
+#define FLOPPY_DRIVE_NAME      L"ISA Floppy Drive # "\r
+#define FLOPPY_DRIVE_NAME_LEN  ((sizeof (FLOPPY_DRIVE_NAME) / sizeof (CHAR16)) - 1)\r
 \r
 extern EFI_COMPONENT_NAME_PROTOCOL   gIsaFloppyComponentName;\r
 extern EFI_COMPONENT_NAME2_PROTOCOL  gIsaFloppyComponentName2;\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
@@ -34,10 +31,9 @@ extern EFI_COMPONENT_NAME2_PROTOCOL  gIsaFloppyComponentName2;
   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[in]  This              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
+  @param[in]  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
@@ -45,23 +41,18 @@ extern EFI_COMPONENT_NAME2_PROTOCOL  gIsaFloppyComponentName2;
                                 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
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
+  @param[out]  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
 \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
@@ -85,15 +76,13 @@ IsaFloppyComponentNameGetDriverName (
   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[in]  This              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
+  @param[in]  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
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
+  @param[in]  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
@@ -101,8 +90,7 @@ IsaFloppyComponentNameGetDriverName (
                                 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[in]  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
@@ -110,8 +98,7 @@ IsaFloppyComponentNameGetDriverName (
                                 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
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
+  @param[out]  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
@@ -122,54 +109,38 @@ IsaFloppyComponentNameGetDriverName (
                                 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
 IsaFloppyComponentNameGetControllerName (\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
+  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
 \r
-VOID\r
-AddName (\r
-  IN  FDC_BLK_IO_DEV               *FdcDev\r
-  )\r
 /**\r
+  Add the component name for the floppy device\r
 \r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  FdcDev  - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
+  @param[in]  FdcDev  A pointer to the FDC_BLK_IO_DEV instance.\r
 \r
 **/\r
-;\r
+VOID\r
+AddName (\r
+  IN  FDC_BLK_IO_DEV  *FdcDev\r
+  );\r
 \r
 #endif\r
+\r
index e819a1d13219e0b3939c1450bf697cd8751274ab..fdc83d383bf7e6af8912ba7fd19f03b088f4acc5 100644 (file)
@@ -1,15 +1,14 @@
-/**@file\r
-  ISA Floppy Driver\r
+/** @file\r
+  ISA Floppy Disk UEFI Driver conforming to the UEFI driver model\r
+\r
   1. Support two types diskette drive  \r
      1.44M drive and 2.88M drive (and now only support 1.44M)\r
-  2. Support two diskette drives\r
+  2. Support two diskette drives per floppy disk controller\r
   3. Use DMA channel 2 to transfer data\r
   4. Do not use interrupt\r
   5. Support diskette change line signal and write protect\r
   \r
-  conforming to EFI driver model\r
-  \r
-Copyright (c) 2006 - 2007, Intel Corporation.<BR>\r
+Copyright (c) 2006 - 2009, Intel Corporation.<BR>\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
@@ -22,7 +21,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include "IsaFloppy.h"\r
 \r
-LIST_ENTRY              gControllerHead = INITIALIZE_LIST_HEAD_VARIABLE(gControllerHead);\r
+LIST_ENTRY  mControllerHead = INITIALIZE_LIST_HEAD_VARIABLE (mControllerHead);\r
 \r
 //\r
 // ISA Floppy Driver Binding Protocol\r
@@ -38,14 +37,13 @@ EFI_DRIVER_BINDING_PROTOCOL gFdcControllerDriver = {
 \r
 \r
 /**\r
-  The user Entry Point for module IsaFloppy. The user code starts with this function.\r
+  The main Entry Point for this driver.\r
 \r
-  @param[in] ImageHandle    The firmware allocated handle for the EFI image.  \r
-  @param[in] SystemTable    A pointer to the EFI System Table.\r
+  @param[in] ImageHandle  The firmware allocated handle for the EFI image.  \r
+  @param[in] SystemTable  A pointer to the EFI System Table.\r
   \r
-  @retval EFI_SUCCESS       The entry point is executed successfully.\r
-  @retval other             Some error occurs when executing this entry point.\r
-\r
+  @retval EFI_SUCCESS     The entry point is executed successfully.\r
+  @retval other           Some error occurs when executing this entry point.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -54,7 +52,7 @@ InitializeIsaFloppy(
   IN EFI_SYSTEM_TABLE     *SystemTable\r
   )\r
 {\r
-  EFI_STATUS              Status;\r
+  EFI_STATUS  Status;\r
 \r
   //\r
   // Install driver model protocol(s).\r
@@ -69,19 +67,21 @@ InitializeIsaFloppy(
              );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-\r
   return Status;\r
 }\r
 \r
 /**\r
-  Test controller is a Floppy Disk Controller\r
+  Test if the controller is a floppy disk drive device\r
   \r
-  @param This                 Pointer of EFI_DRIVER_BINDING_PROTOCOL\r
-  @param Controller           driver's controller\r
-  @param RemainingDevicePath  children device path\r
+  @param[in] This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.  \r
+  @param[in] Controller           The handle of the controller to test.\r
+  @param[in] RemainingDevicePath  A pointer to the remaining portion of a device path.\r
   \r
-  @retval EFI_UNSUPPORTED controller is not floppy disk\r
-  @retval EFI_SUCCESS     controller is floppy disk\r
+  @retval EFI_SUCCESS             The device is supported by this driver.\r
+  @retval EFI_ALREADY_STARTED     The device is already being managed by this driver.\r
+  @retval EFI_ACCESS_DENIED       The device is already being managed by a different driver \r
+                                  or an application that requires exclusive access.\r
+  @retval EFI_UNSUPPORTED         The device is is not supported by this driver.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -91,8 +91,35 @@ FdcControllerDriverSupported (
   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
   )\r
 {\r
-  EFI_STATUS                          Status;\r
-  EFI_ISA_IO_PROTOCOL                 *IsaIo;\r
+  EFI_STATUS                Status;\r
+  EFI_ISA_IO_PROTOCOL       *IsaIo;\r
+  EFI_DEVICE_PATH_PROTOCOL  *ParentDevicePath;\r
+\r
+  //\r
+  // Ignore the parameter RemainingDevicePath because this is a device driver.\r
+  //\r
+\r
+  //\r
+  // Open the device path protocol\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  Controller,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID **) &ParentDevicePath,\r
+                  This->DriverBindingHandle,\r
+                  Controller,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  gBS->CloseProtocol (\r
+         Controller,\r
+         &gEfiDevicePathProtocolGuid,\r
+         This->DriverBindingHandle,\r
+         Controller\r
+         );\r
 \r
   //\r
   // Open the ISA I/O Protocol\r
@@ -109,7 +136,7 @@ FdcControllerDriverSupported (
     return Status;\r
   }\r
   //\r
-  // Use the ISA I/O Protocol to see if Controller is a Floppy Disk Controller\r
+  // Use the ISA I/O Protocol to see if Controller is a floppy disk drive device\r
   //\r
   Status = EFI_SUCCESS;\r
   if (IsaIo->ResourceList->Device.HID != EISA_PNP_ID (0x604)) {\r
@@ -129,13 +156,20 @@ FdcControllerDriverSupported (
 }\r
 \r
 /**\r
-  Create floppy control instance on controller.\r
-  \r
-  @param This         Pointer of EFI_DRIVER_BINDING_PROTOCOL\r
-  @param Controller   driver controller handle\r
-  @param RemainingDevicePath Children's device path\r
-  \r
-  @retval whether success to create floppy control instance.\r
+  Start this driver on Controller.\r
+\r
+  @param[in] This                  A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param[in] ControllerHandle      The handle of the controller to start. This handle \r
+                                   must support a protocol interface that supplies \r
+                                   an I/O abstraction to the driver.\r
+  @param[in] RemainingDevicePath   A pointer to the remaining portion of a device path. \r
+                                   This parameter is ignored by device drivers, and is optional for bus drivers.\r
+\r
+  @retval EFI_SUCCESS              The device was started.\r
+  @retval EFI_DEVICE_ERROR         The device could not be started due to a device error.\r
+                                   Currently not implemented.\r
+  @retval EFI_OUT_OF_RESOURCES     The request could not be completed due to a lack of resources.\r
+  @retval Others                   The driver failded to start the device.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -145,13 +179,13 @@ FdcControllerDriverStart (
   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
   )\r
 {\r
-  EFI_STATUS                                Status;\r
-  FDC_BLK_IO_DEV                            *FdcDev;\r
-  EFI_ISA_IO_PROTOCOL                       *IsaIo;\r
-  UINTN                                     Index;\r
-  LIST_ENTRY                                *List;\r
-  BOOLEAN                                   Found;\r
-  EFI_DEVICE_PATH_PROTOCOL                  *ParentDevicePath;\r
+  EFI_STATUS                Status;\r
+  FDC_BLK_IO_DEV            *FdcDev;\r
+  EFI_ISA_IO_PROTOCOL       *IsaIo;\r
+  UINTN                     Index;\r
+  LIST_ENTRY                *List;\r
+  BOOLEAN                   Found;\r
+  EFI_DEVICE_PATH_PROTOCOL  *ParentDevicePath;\r
 \r
   FdcDev  = NULL;\r
   IsaIo   = NULL;\r
@@ -194,14 +228,14 @@ FdcControllerDriverStart (
     goto Done;\r
   }\r
   //\r
-  // Allocate the Floppy Disk Controller's Device structure\r
+  // Allocate the floppy device's Device structure\r
   //\r
   FdcDev = AllocateZeroPool (sizeof (FDC_BLK_IO_DEV));\r
   if (FdcDev == NULL) {\r
     goto Done;\r
   }\r
   //\r
-  // Initialize the Floppy Disk Controller's Device structure\r
+  // Initialize the floppy device's device structure\r
   //\r
   FdcDev->Signature       = FDC_BLK_IO_DEV_SIGNATURE;\r
   FdcDev->Handle          = Controller;\r
@@ -212,10 +246,11 @@ FdcControllerDriverStart (
   FdcDev->ControllerState = NULL;\r
   FdcDev->DevicePath      = ParentDevicePath;\r
 \r
-  ADD_FLOPPY_NAME (FdcDev);\r
+  FdcDev->ControllerNameTable = NULL;\r
+  AddName (FdcDev);\r
   \r
   //\r
-  // Look up the base address of the Floppy Disk Controller\r
+  // Look up the base address of the Floppy Disk Controller which controls this floppy device\r
   //\r
   for (Index = 0; FdcDev->IsaIo->ResourceList->ResourceItem[Index].Type != EfiIsaAcpiResourceEndOfList; Index++) {\r
     if (FdcDev->IsaIo->ResourceList->ResourceItem[Index].Type == EfiIsaAcpiResourceIo) {\r
@@ -223,11 +258,11 @@ FdcControllerDriverStart (
     }\r
   }\r
   //\r
-  // Maintain the list of controller list\r
+  // Maintain the list of floppy disk controllers\r
   //\r
   Found = FALSE;\r
-  List  = gControllerHead.ForwardLink;\r
-  while (List != &gControllerHead) {\r
+  List  = mControllerHead.ForwardLink;\r
+  while (List != &mControllerHead) {\r
     FdcDev->ControllerState = FLOPPY_CONTROLLER_FROM_LIST_ENTRY (List);\r
     if (FdcDev->BaseAddress == FdcDev->ControllerState->BaseAddress) {\r
       Found = TRUE;\r
@@ -239,7 +274,7 @@ FdcControllerDriverStart (
 \r
   if (!Found) {\r
     //\r
-    // The Controller is new\r
+    // A new floppy disk controller controlling this floppy disk drive is found\r
     //\r
     FdcDev->ControllerState = AllocatePool (sizeof (FLOPPY_CONTROLLER_CONTEXT));\r
     if (FdcDev->ControllerState == NULL) {\r
@@ -252,10 +287,10 @@ FdcControllerDriverStart (
     FdcDev->ControllerState->BaseAddress        = FdcDev->BaseAddress;\r
     FdcDev->ControllerState->NumberOfDrive      = 0;\r
 \r
-    InsertTailList (&gControllerHead, &FdcDev->ControllerState->Link);\r
+    InsertTailList (&mControllerHead, &FdcDev->ControllerState->Link);\r
   }\r
   //\r
-  // Create a timer event for each Floppd Disk Controller.\r
+  // Create a timer event for each floppy disk drive device.\r
   // This timer event is used to control the motor on and off\r
   //\r
   Status = gBS->CreateEvent (\r
@@ -304,8 +339,9 @@ FdcControllerDriverStart (
                   &FdcDev->BlkIo,\r
                   NULL\r
                   );\r
-\r
-  FdcDev->ControllerState->NumberOfDrive++;\r
+  if (!EFI_ERROR (Status)) {\r
+    FdcDev->ControllerState->NumberOfDrive++;\r
+  }\r
 \r
 Done:\r
   if (EFI_ERROR (Status)) {\r
@@ -317,14 +353,19 @@ Done:
       );\r
 \r
     //\r
-    // Close the device path protocol\r
+    // If a floppy drive device structure was allocated, then free it\r
     //\r
-    gBS->CloseProtocol (\r
-           Controller,\r
-           &gEfiDevicePathProtocolGuid,\r
-           This->DriverBindingHandle,\r
-           Controller\r
-           );\r
+    if (FdcDev != NULL) {\r
+      if (FdcDev->Event != NULL) {\r
+        //\r
+        // Close the event for turning the motor off\r
+        //\r
+        gBS->CloseEvent (FdcDev->Event);\r
+      }\r
+\r
+      FreeUnicodeStringTable (FdcDev->ControllerNameTable);\r
+      FreePool (FdcDev);\r
+    }\r
 \r
     //\r
     // Close the ISA I/O Protocol\r
@@ -337,38 +378,34 @@ Done:
              Controller\r
              );\r
     }\r
+\r
     //\r
-    // If a Floppy Disk Controller Device structure was allocated, then free it\r
+    // Close the device path protocol\r
     //\r
-    if (FdcDev != NULL) {\r
-      if (FdcDev->Event != NULL) {\r
-        //\r
-        // Close the event for turning the motor off\r
-        //\r
-        gBS->CloseEvent (FdcDev->Event);\r
-      }\r
-\r
-      FreeUnicodeStringTable (FdcDev->ControllerNameTable);\r
-      gBS->FreePool (FdcDev);\r
-    }\r
+    gBS->CloseProtocol (\r
+           Controller,\r
+           &gEfiDevicePathProtocolGuid,\r
+           This->DriverBindingHandle,\r
+           Controller\r
+           );\r
   }\r
 \r
   return Status;\r
 }\r
 \r
 /**\r
-  Stop this driver on ControllerHandle. Support stoping any child handles\r
-  created by this driver.\r
-\r
-  @param  This              Protocol instance pointer.\r
-  @param  Controller        Handle of device to stop driver on\r
-  @param  NumberOfChildren  Number of Handles in ChildHandleBuffer. If number of\r
-                            children is zero stop the entire bus driver.\r
-  @param  ChildHandleBuffer List of Child Handles to Stop.\r
-\r
-  @retval EFI_SUCCESS       This driver is removed ControllerHandle\r
-  @retval other             This driver was not removed from this device\r
-\r
+  Stop this driver on ControllerHandle.\r
+\r
+  @param[in] This               A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param[in] ControllerHandle   A handle to the device being stopped. The handle must \r
+                                support a bus specific I/O protocol for the driver \r
+                                to use to stop the device.\r
+  @param[in] NumberOfChildren   The number of child device handles in ChildHandleBuffer.\r
+  @param[in] ChildHandleBuffer  An array of child handles to be freed. May be NULL \r
+                                if NumberOfChildren is 0.\r
+\r
+  @retval EFI_SUCCESS           The device was stopped.\r
+  @retval EFI_DEVICE_ERROR      The device could not be stopped due to a device error.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -383,6 +420,10 @@ FdcControllerDriverStop (
   EFI_BLOCK_IO_PROTOCOL *BlkIo;\r
   FDC_BLK_IO_DEV        *FdcDev;\r
 \r
+  //\r
+  // Ignore NumberOfChildren since this is a device driver\r
+  //\r
+\r
   //\r
   // Get the Block I/O Protocol on Controller\r
   //\r
@@ -398,7 +439,7 @@ FdcControllerDriverStop (
     return Status;\r
   }\r
   //\r
-  // Get the Floppy Disk Controller's Device structure\r
+  // Get the floppy drive device's Device structure\r
   //\r
   FdcDev = FDD_BLK_IO_FROM_THIS (BlkIo);\r
 \r
@@ -411,11 +452,6 @@ FdcControllerDriverStop (
     FdcDev->DevicePath\r
     );\r
 \r
-  //\r
-  // Turn the motor off on the Floppy Disk Controller\r
-  //\r
-  FddTimerProc (FdcDev->Event, FdcDev);\r
-\r
   //\r
   // Uninstall the Block I/O Protocol\r
   //\r
@@ -427,6 +463,17 @@ FdcControllerDriverStop (
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
+\r
+  //\r
+  // Close the event for turning the motor off\r
+  //\r
+  gBS->CloseEvent (FdcDev->Event);\r
+\r
+  //\r
+  // Turn the motor off on the floppy drive device\r
+  //\r
+  FddTimerProc (FdcDev->Event, FdcDev);\r
+\r
   //\r
   // Close the device path protocol\r
   //\r
@@ -452,21 +499,16 @@ FdcControllerDriverStop (
   //\r
   FdcDev->ControllerState->NumberOfDrive--;\r
 \r
-  //\r
-  // Close the event for turning the motor off\r
-  //\r
-  gBS->CloseEvent (FdcDev->Event);\r
-\r
   //\r
   // Free the cache if one was allocated\r
   //\r
   FdcFreeCache (FdcDev);\r
 \r
   //\r
-  // Free the Floppy Disk Controller's Device structure\r
+  // Free the floppy drive device's device structure\r
   //\r
   FreeUnicodeStringTable (FdcDev->ControllerNameTable);\r
-  gBS->FreePool (FdcDev);\r
+  FreePool (FdcDev);\r
 \r
   return EFI_SUCCESS;\r
 }\r
index e518d4774dada8087f1d9d9419fe41b3eba7d1ac..13e03e221dde120500da7499795a3af1eb7cbf6f 100644 (file)
@@ -1,8 +1,7 @@
-/**@file\r
-  Include for ISA Floppy Driver\r
-  Define the data structure and so on\r
+/** @file\r
+  Include file for ISA Floppy Driver\r
   \r
-Copyright (c) 2006 - 2007, Intel Corporation.<BR>\r
+Copyright (c) 2006 - 2009, Intel Corporation.<BR>\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
@@ -13,15 +12,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
-#ifndef _ISA_FLOPPY_H\r
-#define _ISA_FLOPPY_H\r
+#ifndef _ISA_FLOPPY_H_\r
+#define _ISA_FLOPPY_H_\r
 \r
-#include <PiDxe.h>\r
-#include <FrameworkPei.h>\r
+#include <Uefi.h>\r
 \r
 #include <Protocol/BlockIo.h>\r
 #include <Protocol/IsaIo.h>\r
 #include <Protocol/DevicePath.h>\r
+#include <Guid/StatusCodeDataTypeId.h>\r
 \r
 #include <Library/TimerLib.h>\r
 #include <Library/DebugLib.h>\r
@@ -32,16 +31,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/ReportStatusCodeLib.h>\r
-//\r
-// Driver Binding Externs\r
-//\r
+#include <Library/PcdLib.h>\r
+\r
 extern EFI_DRIVER_BINDING_PROTOCOL  gFdcControllerDriver;\r
-extern EFI_COMPONENT_NAME_PROTOCOL  gIsaFloppyComponentName;\r
-extern EFI_COMPONENT_NAME2_PROTOCOL gIsaFloppyComponentName2;\r
 \r
-//\r
-// define some value\r
-//\r
 #define STALL_1_SECOND  1000000\r
 #define STALL_1_MSECOND 1000\r
 \r
@@ -57,14 +50,14 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gIsaFloppyComponentName2;
 #define FLOPPY_CONTROLLER_CONTEXT_SIGNATURE SIGNATURE_32 ('F', 'D', 'C', 'C')\r
 \r
 typedef enum {\r
-  FDC_DISK0   = 0,\r
-  FDC_DISK1   = 1,\r
-  FDC_MAX_DISK= 2\r
+  FdcDisk0   = 0,\r
+  FdcDisk1   = 1,\r
+  FdcMaxDisk = 2\r
 } EFI_FDC_DISK;\r
 \r
 typedef struct {\r
   UINT32          Signature;\r
-  LIST_ENTRY  Link;\r
+  LIST_ENTRY      Link;\r
   BOOLEAN         FddResetPerformed;\r
   EFI_STATUS      FddResetStatus;\r
   BOOLEAN         NeedRecalibrate;\r
@@ -97,11 +90,11 @@ typedef struct {
 \r
 #define FDD_BLK_IO_FROM_THIS(a) CR (a, FDC_BLK_IO_DEV, BlkIo, FDC_BLK_IO_DEV_SIGNATURE)\r
 #define FLOPPY_CONTROLLER_FROM_LIST_ENTRY(a) \\r
-  CR (a, \\r
-      FLOPPY_CONTROLLER_CONTEXT, \\r
-      Link, \\r
-      FLOPPY_CONTROLLER_CONTEXT_SIGNATURE \\r
-      )\r
+          CR (a, \\r
+              FLOPPY_CONTROLLER_CONTEXT, \\r
+              Link, \\r
+              FLOPPY_CONTROLLER_CONTEXT_SIGNATURE \\r
+              )\r
 \r
 #define DISK_1440K_EOT            0x12\r
 #define DISK_1440K_GPL            0x1b\r
@@ -154,9 +147,9 @@ typedef struct {
   UINT8 Status0;\r
   UINT8 Status1;\r
   UINT8 Status2;\r
-  UINT8 C;\r
-  UINT8 H;\r
-  UINT8 S;\r
+  UINT8 Cylinder;\r
+  UINT8 Head;\r
+  UINT8 Sector;\r
   UINT8 Number;\r
 } FDD_RESULT_PACKET;\r
 \r
@@ -164,32 +157,31 @@ typedef struct {
 // FDC Registers\r
 //\r
 //\r
-// 0x3F2 Digital Output Register\r
+// Digital Output Register address offset\r
 //\r
 #define FDC_REGISTER_DOR  2\r
 \r
 //\r
-// 0x3F4 Main Status Register\r
+// Main Status Register address offset\r
 //\r
 #define FDC_REGISTER_MSR  4\r
 \r
 //\r
-// 0x3F5 Data Register\r
+// Data Register address offset\r
 //\r
 #define FDC_REGISTER_DTR  5\r
 \r
 //\r
-// 0x3F7 Configuration Control Register(data rate select)\r
+// Configuration Control Register(data rate select) address offset\r
 //\r
 #define FDC_REGISTER_CCR  7\r
 \r
 //\r
-// 0x3F7 Digital Input Register(diskchange)\r
+// Digital Input Register(diskchange) address offset\r
 //\r
 #define FDC_REGISTER_DIR  7\r
 \r
 \r
-\r
 //\r
 // FDC Register Bit Definitions\r
 //\r
@@ -484,23 +476,21 @@ typedef struct {
 //\r
 #define IC_ATRC 0xC0\r
 \r
-//\r
-// Global Variables\r
-//\r
-extern EFI_DRIVER_BINDING_PROTOCOL   gFdcControllerDriver;\r
-\r
 //\r
 // EFI Driver Binding Protocol Functions\r
 //\r
+\r
 /**\r
-  Test controller is a Floppy Disk Controller\r
+  Test controller is a floppy disk drive device\r
   \r
-  @param This                 Pointer of EFI_DRIVER_BINDING_PROTOCOL\r
-  @param Controller           driver's controller\r
-  @param RemainingDevicePath  children device path\r
+  @param[in] This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.  \r
+  @param[in] Controller           The handle of the controller to test.\r
+  @param[in] RemainingDevicePath  A pointer to the remaining portion of a device path.\r
   \r
-  @retval EFI_UNSUPPORTED controller is not floppy disk\r
-  @retval EFI_SUCCESS     controller is floppy disk\r
+  @retval EFI_SUCCESS             The device is supported by this driver.\r
+  @retval EFI_ALREADY_STARTED     The device is already being managed by this driver.\r
+  @retval EFI_ACCESS_DENIED       The device is already being managed by a different driver \r
+                                  or an application that requires exclusive access.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -511,13 +501,20 @@ FdcControllerDriverSupported (
   );\r
 \r
 /**\r
-  Create floppy control instance on controller.\r
-  \r
-  @param This         Pointer of EFI_DRIVER_BINDING_PROTOCOL\r
-  @param Controller   driver controller handle\r
-  @param RemainingDevicePath Children's device path\r
-  \r
-  @retval whether success to create floppy control instance.\r
+  Start this driver on Controller.\r
+\r
+  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param[in]  ControllerHandle     The handle of the controller to start. This handle \r
+                                   must support a protocol interface that supplies \r
+                                   an I/O abstraction to the driver.\r
+  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path. \r
+                                   This parameter is ignored by device drivers, and is optional for bus drivers.\r
+\r
+  @retval EFI_SUCCESS              The device was started.\r
+  @retval EFI_DEVICE_ERROR         The device could not be started due to a device error.\r
+                                   Currently not implemented.\r
+  @retval EFI_OUT_OF_RESOURCES     The request could not be completed due to a lack of resources.\r
+  @retval Others                   The driver failded to start the device.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -528,18 +525,18 @@ FdcControllerDriverStart (
   );\r
 \r
 /**\r
-  Stop this driver on ControllerHandle. Support stoping any child handles\r
-  created by this driver.\r
-\r
-  @param  This              Protocol instance pointer.\r
-  @param  Controller        Handle of device to stop driver on\r
-  @param  NumberOfChildren  Number of Handles in ChildHandleBuffer. If number of\r
-                            children is zero stop the entire bus driver.\r
-  @param  ChildHandleBuffer List of Child Handles to Stop.\r
-\r
-  @retval EFI_SUCCESS       This driver is removed ControllerHandle\r
-  @retval other             This driver was not removed from this device\r
-\r
+  Stop this driver on ControllerHandle.\r
+\r
+  @param[in]  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param[in]  ControllerHandle  A handle to the device being stopped. The handle must \r
+                                support a bus specific I/O protocol for the driver \r
+                                to use to stop the device.\r
+  @param[in]  NumberOfChildren  The number of child device handles in ChildHandleBuffer.\r
+  @param[in]  ChildHandleBuffer An array of child handles to be freed. May be NULL \r
+                                if NumberOfChildren is 0.\r
+\r
+  @retval EFI_SUCCESS           The device was stopped.\r
+  @retval EFI_DEVICE_ERROR      The device could not be stopped due to a device error.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -553,8 +550,9 @@ FdcControllerDriverStop (
 //\r
 // EFI Block I/O Protocol Functions\r
 //\r
+\r
 /**\r
-  Reset the Floppy Logic Drive, call the FddReset function   \r
+  Reset the Floppy Logic Drive, call the FddReset function.   \r
   \r
   @param This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface\r
   @param ExtendedVerification BOOLEAN: Indicate that the driver may perform a more \r
@@ -573,7 +571,7 @@ FdcReset (
   );\r
 \r
 /**\r
-  Flush block via fdd controller\r
+  Flush block via fdd controller.\r
   \r
   @param  This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface\r
   @return EFI_SUCCESS\r
@@ -586,11 +584,11 @@ FddFlushBlocks (
   );\r
 \r
 /**\r
-  Read the requested number of blocks from the device   \r
+  Read the requested number of blocks from the device.   \r
   \r
   @param This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface\r
   @param MediaId UINT32:    The media id that the read request is for    \r
-  @param  LBA EFI_LBA:     The starting logic block address to read from on the device\r
+  @param  Lba EFI_LBA:     The starting logic block address to read from on the device\r
   @param  BufferSize UINTN:  The size of the Buffer in bytes\r
   @param  Buffer VOID *:     A pointer to the destination buffer for the data\r
   \r
@@ -610,17 +608,17 @@ EFIAPI
 FddReadBlocks (\r
   IN  EFI_BLOCK_IO_PROTOCOL  *This,\r
   IN  UINT32                 MediaId,\r
-  IN  EFI_LBA                LBA,\r
+  IN  EFI_LBA                Lba,\r
   IN  UINTN                  BufferSize,\r
   OUT VOID                   *Buffer\r
   );\r
 \r
 /**\r
-  Write a specified number of blocks to the device   \r
+  Write a specified number of blocks to the device.   \r
   \r
   @param  This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface\r
   @param  MediaId UINT32:    The media id that the write request is for   \r
-  @param  LBA EFI_LBA:     The starting logic block address to be written\r
+  @param  Lba EFI_LBA:     The starting logic block address to be written\r
   @param  BufferSize UINTN:  The size in bytes in Buffer\r
   @param  Buffer VOID *:     A pointer to the source buffer for the data\r
   \r
@@ -640,7 +638,7 @@ EFIAPI
 FddWriteBlocks (\r
   IN EFI_BLOCK_IO_PROTOCOL  *This,\r
   IN UINT32                 MediaId,\r
-  IN EFI_LBA                LBA,\r
+  IN EFI_LBA                Lba,\r
   IN UINTN                  BufferSize,\r
   IN VOID                   *Buffer\r
   );\r
@@ -650,7 +648,7 @@ FddWriteBlocks (
 //\r
 /**\r
 \r
-  Detect the floppy drive is presented or not\r
+  Detect the floppy drive is presented or not.\r
  \r
   @param  FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV\r
   @retval EFI_SUCCESS    Drive is presented\r
@@ -664,8 +662,8 @@ DiscoverFddDevice (
 \r
 /**\r
 \r
-  Do recalibrate  and see the drive is presented or not\r
-  Set the media parameters\r
+  Do recalibrate  and see the drive is presented or not.\r
+  Set the media parameters.\r
   \r
   @param FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV\r
   @return the drive is presented or not\r
@@ -678,7 +676,7 @@ FddIdentify (
 \r
 /**\r
 \r
-  Reset the Floppy Logic Drive\r
+  Reset the Floppy Logic Drive.\r
   \r
   @param  FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV\r
   \r
@@ -694,8 +692,8 @@ FddReset (
 \r
 /**\r
 \r
-  Turn the drive's motor on\r
-  The drive's motor must be on before any command can be executed\r
+  Turn the drive's motor on.\r
+  The drive's motor must be on before any command can be executed.\r
   \r
   @param  FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV\r
   \r
@@ -711,7 +709,7 @@ MotorOn (
 \r
 /**\r
 \r
-  Set a Timer and when Timer goes off, turn the motor off\r
+  Set a Timer and when Timer goes off, turn the motor off.\r
   \r
   \r
   @param  FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV\r
@@ -726,7 +724,7 @@ MotorOff (
   );\r
 \r
 /**\r
-  Detect the disk in the drive is changed or not\r
+  Detect the disk in the drive is changed or not.\r
   \r
   \r
   @param  FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
@@ -744,7 +742,7 @@ DisketChanged (
 /**\r
   Do the Specify command, this command sets DMA operation\r
   and the initial values for each of the three internal\r
-  times: HUT, SRT and HLT\r
+  times: HUT, SRT and HLT.\r
   \r
   @param FdcDev    Pointer to instance of FDC_BLK_IO_DEV\r
   \r
@@ -758,7 +756,7 @@ Specify (
   );\r
 \r
 /**\r
-  Set the head of floppy drive to track 0\r
+  Set the head of floppy drive to track 0.\r
  \r
   @param  FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
   @retval EFI_SUCCESS:    Execute the Recalibrate operation successfully\r
@@ -771,7 +769,7 @@ Recalibrate (
   );\r
 \r
 /**\r
-  Set the head of floppy drive to the new cylinder\r
+  Set the head of floppy drive to the new cylinder.\r
   \r
   @param  FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
   @param  Lba EFI_LBA     : The logic block address want to seek\r
@@ -787,8 +785,7 @@ Seek (
   );\r
 \r
 /**\r
-  Do the Sense Interrupt Status command, this command\r
-  resets the interrupt signal\r
+  Do the Sense Interrupt Status command, this command resets the interrupt signal.\r
   \r
   @param  FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
   @param  StatusRegister0 UINT8 *: Be used to save Status Register 0 read from FDC\r
@@ -807,7 +804,7 @@ SenseIntStatus (
   );\r
 \r
 /**\r
-  Do the Sense Drive Status command\r
+  Do the Sense Drive Status command.\r
   \r
   @param  FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
   @param  Lba EFI_LBA     : Logic block address\r
@@ -824,8 +821,7 @@ SenseDrvStatus (
   );\r
 \r
 /**\r
-  Update the disk media properties and if necessary\r
-                        reinstall Block I/O interface\r
+  Update the disk media properties and if necessary reinstall Block I/O interface.\r
  \r
   @param  FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
   \r
@@ -839,7 +835,7 @@ DetectMedia (
   );\r
 \r
 /**\r
-  Set the data rate and so on\r
+  Set the data rate and so on.\r
  \r
   @param  FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
 \r
@@ -851,7 +847,7 @@ Setup (
   );\r
 \r
 /**\r
-  Read or Write a number of blocks in the same cylinder\r
+  Read or Write a number of blocks in the same cylinder.\r
  \r
   @param  FdcDev      A pointer to Data Structure FDC_BLK_IO_DEV\r
   @param  HostAddress device address \r
@@ -872,7 +868,7 @@ ReadWriteDataSector (
   );\r
 \r
 /**\r
-  Fill in FDD command's parameter\r
+  Fill in FDD command's parameter.\r
   \r
   @param FdcDev   Pointer to instance of FDC_BLK_IO_DEV\r
   @param Lba      The starting logic block address to read from on the device\r
@@ -887,24 +883,23 @@ FillPara (
   );\r
 \r
 /**\r
-  Read result byte from Data Register of FDC\r
-  \r
-  @param FdcDev  Pointer to instance of FDC_BLK_IO_DEV\r
-  @param Pointer UINT8 *: Be used to save result byte read from FDC\r
+  Read result byte from Data Register of FDC.\r
   \r
+  @param FdcDev   Pointer to instance of FDC_BLK_IO_DEV\r
+  @param Pointer  Buffer to store the byte read from FDC\r
   \r
-  @retval  EFI_SUCCESS:    Read result byte from FDC successfully\r
-  @retval  EFI_DEVICE_ERROR: The FDC is not ready to be read\r
+  @retval EFI_SUCCESS       Read result byte from FDC successfully\r
+  @retval EFI_DEVICE_ERROR  The FDC is not ready to be read\r
 \r
 **/\r
 EFI_STATUS\r
 DataInByte (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN UINT8           *Pointer\r
+  IN  FDC_BLK_IO_DEV  *FdcDev,\r
+  OUT UINT8           *Pointer\r
   );\r
 \r
 /**\r
-  Write command byte to Data Register of FDC\r
+  Write command byte to Data Register of FDC.\r
   \r
   @param FdcDev  Pointer to instance of FDC_BLK_IO_DEV\r
   @param Pointer Be used to save command byte written to FDC\r
@@ -920,8 +915,7 @@ DataOutByte (
   );\r
 \r
 /**\r
-  Detect the specified floppy logic drive is busy or\r
-  not within a period of time\r
+  Detect the specified floppy logic drive is busy or not within a period of time.\r
   \r
   @param FdcDev          Indicate it is drive A or drive B\r
   @param TimeoutInSeconds the time period for waiting\r
@@ -938,8 +932,7 @@ FddWaitForBSYClear (
   );\r
 \r
 /**\r
-\r
-  Routine Description:  Determine whether FDC is ready to write or read\r
+  Determine whether FDC is ready to write or read.\r
   \r
   @param  FdcDev Pointer to instance of FDC_BLK_IO_DEV\r
   @param  Dio BOOLEAN:      Indicate the FDC is waiting to write or read\r
@@ -957,8 +950,7 @@ FddDRQReady (
   );\r
 \r
 /**\r
-  Set FDC control structure's attribute according to\r
-  result \r
+  Set FDC control structure's attribute according to result.\r
 \r
   @param Result  Point to result structure\r
   @param FdcDev  FDC control structure\r
@@ -976,7 +968,7 @@ CheckResult (
   );\r
 \r
 /**\r
-  Check the drive status information\r
+  Check the drive status information.\r
   \r
   @param StatusRegister3  the value of Status Register 3\r
   \r
@@ -990,26 +982,25 @@ CheckStatus3 (
   );\r
 \r
 /**\r
-  Calculate the number of block in the same cylinder\r
-  according to LBA\r
+  Calculate the number of block in the same cylinder according to Lba.\r
   \r
   @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
-  @param LBA EFI_LBA:      The starting logic block address\r
+  @param Lba EFI_LBA:      The starting logic block address\r
   @param NumberOfBlocks UINTN: The number of blocks\r
   \r
   @return The number of blocks in the same cylinder which the starting\r
-        logic block address is LBA\r
+        logic block address is Lba\r
 \r
 **/\r
 UINTN\r
 GetTransferBlockCount (\r
   IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN EFI_LBA         LBA,\r
+  IN EFI_LBA         Lba,\r
   IN UINTN           NumberOfBlocks\r
   );\r
 \r
 /**\r
-  When the Timer(2s) off, turn the drive's motor off\r
+  When the Timer(2s) off, turn the drive's motor off.\r
   \r
   @param Event EFI_EVENT: Event(the timer) whose notification function is being\r
                      invoked\r
@@ -1024,7 +1015,7 @@ FddTimerProc (
   );\r
 \r
 /**\r
-  Read I/O port for FDC\r
+  Read I/O port for FDC.\r
  \r
   @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
   @param Offset The offset address of port\r
@@ -1037,7 +1028,7 @@ FdcReadPort (
   );\r
 \r
 /**\r
-  Write I/O port for FDC\r
+  Write I/O port for FDC.\r
  \r
   @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
   @param Offset The offset address of port\r
@@ -1052,11 +1043,11 @@ FdcWritePort (
   );\r
 \r
 /**\r
-  Read or Write a number of blocks to floppy device\r
+  Read or Write a number of blocks to floppy device.\r
 \r
   @param This     Pointer to instance of EFI_BLOCK_IO_PROTOCOL\r
   @param MediaId  The media id of read/write request\r
-  @param LBA      The starting logic block address to read from on the device\r
+  @param Lba      The starting logic block address to read from on the device\r
   @param BufferSize The size of the Buffer in bytes\r
   @param Operation   - GC_TODO: add argument description\r
   @param Buffer      - GC_TODO: add argument description\r
@@ -1081,14 +1072,14 @@ EFI_STATUS
 FddReadWriteBlocks (\r
   IN  EFI_BLOCK_IO_PROTOCOL  *This,\r
   IN  UINT32                 MediaId,\r
-  IN  EFI_LBA                LBA,\r
+  IN  EFI_LBA                Lba,\r
   IN  UINTN                  BufferSize,\r
   IN  BOOLEAN                Operation,\r
   OUT VOID                   *Buffer\r
   );\r
 \r
 /**\r
-  Common interface for free cache \r
+  Common interface for free cache. \r
   \r
   @param FdcDev  Pointer of FDC_BLK_IO_DEV instance\r
   \r
index 5f4a9903574c473a94519da7b678466ba38ce17f..b823034bc5124ceaba6c882de45a7c4e265f9032 100644 (file)
@@ -1,15 +1,7 @@
-/**@file\r
-  ISA Floppy Driver\r
-  1. Support two types diskette drive  \r
-     1.44M drive and 2.88M drive (and now only support 1.44M)\r
-  2. Support two diskette drives\r
-  3. Use DMA channel 2 to transfer data\r
-  4. Do not use interrupt\r
-  5. Support diskette change line signal and write protect\r
+/** @file \r
+  Implementation of the EFI Block IO Protocol for ISA Floppy driver\r
   \r
-  Implement the Block IO interface\r
-  \r
-Copyright (c) 2006 - 2007, Intel Corporation.<BR>\r
+Copyright (c) 2006 - 2009, Intel Corporation.<BR>\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
@@ -20,20 +12,17 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
-\r
 #include "IsaFloppy.h"\r
 \r
 /**\r
-  Reset the Floppy Logic Drive, call the FddReset function   \r
-  \r
-  @param This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface\r
-  @param ExtendedVerification BOOLEAN: Indicate that the driver may perform a more \r
-                    exhaustive verification operation of the device during \r
-                    reset, now this par is ignored in this driver          \r
-  @retval  EFI_SUCCESS:      The Floppy Logic Drive is reset\r
-  @retval  EFI_DEVICE_ERROR: The Floppy Logic Drive is not functioning correctly \r
-                      and can not be reset\r
+  Reset the Block Device.\r
+\r
+  @param  This                 Indicates a pointer to the calling context.\r
+  @param  ExtendedVerification Driver may perform diagnostics on reset.\r
 \r
+  @retval EFI_SUCCESS          The device was reset.\r
+  @retval EFI_DEVICE_ERROR     The device is not functioning properly and could\r
+                               not be reset.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -59,10 +48,13 @@ FdcReset (
 }\r
 \r
 /**\r
-  Flush block via fdd controller\r
-  \r
-  @param  This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface\r
-  @return EFI_SUCCESS\r
+  Flush the Block Device.\r
+\r
+  @param  This              Indicates a pointer to the calling context.\r
+\r
+  @retval EFI_SUCCESS       All outstanding data was written to the device\r
+  @retval EFI_DEVICE_ERROR  The device reported an error while writting back the data\r
+  @retval EFI_NO_MEDIA      There is no media in the device.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -78,10 +70,10 @@ FddFlushBlocks (
 }\r
 \r
 /**\r
-  Common report status code interface\r
+  Common report status code interface.\r
   \r
   @param This  Pointer of FDC_BLK_IO_DEV instance\r
-  @param Read  Error type: read or write?\r
+  @param Read  Read or write operation when error occurrs\r
 **/\r
 VOID\r
 FddReportStatus (\r
@@ -101,23 +93,22 @@ FddReportStatus (
 }\r
 \r
 /**\r
-  Read the requested number of blocks from the device   \r
-  \r
-  @param This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface\r
-  @param MediaId UINT32:    The media id that the read request is for    \r
-  @param  LBA EFI_LBA:     The starting logic block address to read from on the device\r
-  @param  BufferSize UINTN:  The size of the Buffer in bytes\r
-  @param  Buffer VOID *:     A pointer to the destination buffer for the data\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\r
-                     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 \r
-                         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
+  Read BufferSize bytes from Lba into Buffer.\r
+\r
+  @param  This       Indicates a pointer to the calling context.\r
+  @param  MediaId    Id of the media, changes every time the media is replaced.\r
+  @param  Lba        The starting Logical Block Address to read from\r
+  @param  BufferSize Size of Buffer, must be a multiple of device block size.\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 performing the read.\r
+  @retval EFI_NO_MEDIA          There is no media in the device.\r
+  @retval EFI_MEDIA_CHANGED     The MediaId does not matched the current device.\r
+  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the 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
@@ -125,14 +116,14 @@ EFIAPI
 FddReadBlocks (\r
   IN  EFI_BLOCK_IO_PROTOCOL  *This,\r
   IN  UINT32                 MediaId,\r
-  IN  EFI_LBA                LBA,\r
+  IN  EFI_LBA                Lba,\r
   IN  UINTN                  BufferSize,\r
   OUT VOID                   *Buffer\r
   )\r
 {\r
   EFI_STATUS  Status;\r
 \r
-  Status = FddReadWriteBlocks (This, MediaId, LBA, BufferSize, READ, Buffer);\r
+  Status = FddReadWriteBlocks (This, MediaId, Lba, BufferSize, READ, Buffer);\r
 \r
   if (EFI_ERROR (Status)) {\r
     FddReportStatus (This, TRUE);\r
@@ -142,38 +133,38 @@ FddReadBlocks (
 }\r
 \r
 /**\r
-  Write a specified number of blocks to the device   \r
-  \r
-  @param  This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface\r
-  @param  MediaId UINT32:    The media id that the write request is for   \r
-  @param  LBA EFI_LBA:     The starting logic block address to be written\r
-  @param  BufferSize UINTN:  The size in bytes in Buffer\r
-  @param  Buffer VOID *:     A 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 can not 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 \r
-                       the write operation \r
-  @retval  EFI_BAD_BUFFER_SIZE: The BufferSize parameter is not a multiple of the \r
-                         intrinsic 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
+  Write BufferSize bytes from Lba into Buffer.\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. The caller is\r
+                     responsible for writing to only legitimate locations.\r
+  @param  BufferSize Size of Buffer, must be a multiple of device block size.\r
+  @param  Buffer     A pointer to the source buffer for the data.\r
+\r
+  @retval EFI_SUCCESS           The data was written correctly to the device.\r
+  @retval EFI_WRITE_PROTECTED   The device can not be written to.\r
+  @retval EFI_DEVICE_ERROR      The device reported an error while performing the write.\r
+  @retval EFI_NO_MEDIA          There is no media in the device.\r
+  @retval EFI_MEDIA_CHNAGED     The MediaId does not matched the current device.\r
+  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the 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
 FddWriteBlocks (\r
   IN EFI_BLOCK_IO_PROTOCOL  *This,\r
   IN UINT32                 MediaId,\r
-  IN EFI_LBA                LBA,\r
+  IN EFI_LBA                Lba,\r
   IN UINTN                  BufferSize,\r
   IN VOID                   *Buffer\r
   )\r
 {\r
   EFI_STATUS  Status;\r
 \r
-  Status = FddReadWriteBlocks (This, MediaId, LBA, BufferSize, WRITE, Buffer);\r
+  Status = FddReadWriteBlocks (This, MediaId, Lba, BufferSize, WRITE, Buffer);\r
 \r
   if (EFI_ERROR (Status)) {\r
     FddReportStatus (This, FALSE);\r
@@ -183,36 +174,31 @@ FddWriteBlocks (
 }\r
 \r
 /**\r
-  Read or Write a number of blocks to floppy device\r
-\r
-  @param This     Pointer to instance of EFI_BLOCK_IO_PROTOCOL\r
-  @param MediaId  The media id of read/write request\r
-  @param LBA      The starting logic block address to read from on the device\r
-  @param BufferSize The size of the Buffer in bytes\r
-  @param Operation   - GC_TODO: add argument description\r
-  @param Buffer      - GC_TODO: add argument description\r
-\r
-  @retval EFI_INVALID_PARAMETER - GC_TODO: Add description for return value\r
-  @retval EFI_SUCCESS - GC_TODO: Add description for return value\r
-  @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
-  @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
-  @retval EFI_NO_MEDIA - GC_TODO: Add description for return value\r
-  @retval EFI_MEDIA_CHANGED - GC_TODO: Add description for return value\r
-  @retval EFI_WRITE_PROTECTED - GC_TODO: Add description for return value\r
-  @retval EFI_BAD_BUFFER_SIZE - GC_TODO: Add description for return value\r
-  @retval EFI_INVALID_PARAMETER - GC_TODO: Add description for return value\r
-  @retval EFI_INVALID_PARAMETER - GC_TODO: Add description for return value\r
-  @retval EFI_SUCCESS - GC_TODO: Add description for return value\r
-  @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
-  @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
-  @retval EFI_SUCCESS - GC_TODO: Add description for return value\r
+  Read or Write a number of blocks to floppy disk\r
+\r
+  @param  This       Indicates a pointer to the calling context.\r
+  @param  MediaId    Id of the media, changes every time the media is replaced.\r
+  @param  Lba        The starting Logical Block Address to read from\r
+  @param  BufferSize Size of Buffer, must be a multiple of device block size.\r
+  @param  Operation  Specifies the read or write operation.\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 performing the read.\r
+  @retval EFI_NO_MEDIA          There is no media in the device.\r
+  @retval EFI_MEDIA_CHANGED     The MediaId does not matched the current device.\r
+  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the 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
+  @retval EFI_WRITE_PROTECTED   The device can not be written to.\r
 \r
 **/\r
 EFI_STATUS\r
 FddReadWriteBlocks (\r
   IN  EFI_BLOCK_IO_PROTOCOL  *This,\r
   IN  UINT32                 MediaId,\r
-  IN  EFI_LBA                LBA,\r
+  IN  EFI_LBA                Lba,\r
   IN  UINTN                  BufferSize,\r
   IN  BOOLEAN                Operation,\r
   OUT VOID                   *Buffer\r
@@ -224,10 +210,7 @@ FddReadWriteBlocks (
   UINTN               NumberOfBlocks;\r
   UINTN               BlockCount;\r
   EFI_STATUS          Status;\r
-  //\r
-  //  EFI_STATUS            CacheStatus;\r
-  //\r
-  EFI_LBA             LBA0;\r
+  EFI_LBA             Lba0;\r
   UINT8               *Pointer;\r
 \r
   //\r
@@ -238,7 +221,7 @@ FddReadWriteBlocks (
   FdcDev    = FDD_BLK_IO_FROM_THIS (This);\r
 \r
   if (Operation == WRITE) {\r
-    if (LBA == 0) {\r
+    if (Lba == 0) {\r
       FdcFreeCache (FdcDev);\r
     }\r
   }\r
@@ -274,13 +257,6 @@ FddReadWriteBlocks (
   if (!(Media->MediaPresent)) {\r
     MotorOff (FdcDev);\r
     FdcFreeCache (FdcDev);\r
-\r
-    /*\r
-    if (FdcDev->Cache) {\r
-      gBS->FreePool (FdcDev->Cache);\r
-      FdcDev->Cache = NULL;\r
-    }\r
-*/\r
     return EFI_NO_MEDIA;\r
   }\r
   //\r
@@ -306,12 +282,12 @@ FddReadWriteBlocks (
     return EFI_BAD_BUFFER_SIZE;\r
   }\r
 \r
-  if (LBA > Media->LastBlock) {\r
+  if (Lba > Media->LastBlock) {\r
     MotorOff (FdcDev);\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  if (((BufferSize / BlockSize) + LBA - 1) > Media->LastBlock) {\r
+  if (((BufferSize / BlockSize) + Lba - 1) > Media->LastBlock) {\r
     MotorOff (FdcDev);\r
     return EFI_INVALID_PARAMETER;\r
   }\r
@@ -320,8 +296,8 @@ FddReadWriteBlocks (
     //\r
     // See if the data that is being read is already in the cache\r
     //\r
-    if (FdcDev->Cache) {\r
-      if (LBA == 0 && BufferSize == BlockSize) {\r
+    if (FdcDev->Cache != NULL) {\r
+      if (Lba == 0 && BufferSize == BlockSize) {\r
         MotorOff (FdcDev);\r
         CopyMem ((UINT8 *) Buffer, (UINT8 *) FdcDev->Cache, BlockSize);\r
         return EFI_SUCCESS;\r
@@ -338,26 +314,26 @@ FddReadWriteBlocks (
   }\r
 \r
   NumberOfBlocks  = BufferSize / BlockSize;\r
-  LBA0            = LBA;\r
+  Lba0            = Lba;\r
   Pointer         = Buffer;\r
 \r
   //\r
   // read blocks in the same cylinder.\r
   // in a cylinder , there are 18 * 2 = 36 blocks\r
   //\r
-  BlockCount = GetTransferBlockCount (FdcDev, LBA, NumberOfBlocks);\r
+  BlockCount = GetTransferBlockCount (FdcDev, Lba, NumberOfBlocks);\r
   while ((BlockCount != 0) && !EFI_ERROR (Status)) {\r
-    Status = ReadWriteDataSector (FdcDev, Buffer, LBA, BlockCount, Operation);\r
+    Status = ReadWriteDataSector (FdcDev, Buffer, Lba, BlockCount, Operation);\r
     if (EFI_ERROR (Status)) {\r
       MotorOff (FdcDev);\r
       FddReset (FdcDev);\r
       return EFI_DEVICE_ERROR;\r
     }\r
 \r
-    LBA += BlockCount;\r
+    Lba += BlockCount;\r
     NumberOfBlocks -= BlockCount;\r
     Buffer      = (VOID *) ((UINTN) Buffer + BlockCount * BlockSize);\r
-    BlockCount  = GetTransferBlockCount (FdcDev, LBA, NumberOfBlocks);\r
+    BlockCount  = GetTransferBlockCount (FdcDev, Lba, NumberOfBlocks);\r
   }\r
 \r
   Buffer = Pointer;\r
@@ -371,7 +347,7 @@ FddReadWriteBlocks (
     //\r
     // Cache the data read\r
     //\r
-    if (LBA0 == 0 && !FdcDev->Cache) {\r
+    if (Lba0 == 0 && FdcDev->Cache == NULL) {\r
       FdcDev->Cache = AllocateCopyPool (BlockSize, Buffer);\r
     }\r
   }\r
@@ -381,18 +357,18 @@ FddReadWriteBlocks (
 }\r
 \r
 /**\r
-  Common interface for free cache \r
+  Free cache for a floppy disk.\r
   \r
-  @param FdcDev  Pointer of FDC_BLK_IO_DEV instance\r
+  @param FdcDev  A Pointer to FDC_BLK_IO_DEV instance\r
   \r
 **/\r
 VOID\r
 FdcFreeCache (\r
-  IN    FDC_BLK_IO_DEV  *FdcDev\r
+  IN FDC_BLK_IO_DEV  *FdcDev\r
   )\r
 {\r
-  if (FdcDev->Cache) {\r
-    gBS->FreePool (FdcDev->Cache);\r
+  if (FdcDev->Cache != NULL) {\r
+    FreePool (FdcDev->Cache);\r
     FdcDev->Cache = NULL;\r
   }\r
 }\r
index fab96051fdeb7de1632786e6870bb1572e91e035..60df61f08197e5dd7c5947407cca190c51001d13 100644 (file)
@@ -1,15 +1,7 @@
-/**@file\r
-  ISA Floppy Driver\r
-  1. Support two types diskette drive\r
-     1.44M drive and 2.88M drive (and now only support 1.44M)\r
-  2. Support two diskette drives\r
-  3. Use DMA channel 2 to transfer data\r
-  4. Do not use interrupt\r
-  5. Support diskette change line signal and write protect\r
-\r
-  The internal function for the floppy driver\r
+/** @file\r
+  Internal floppy disk controller programming functions for the floppy driver.\r
   \r
-Copyright (c) 2006 - 2007, Intel Corporation.<BR>\r
+Copyright (c) 2006 - 2009, Intel Corporation.<BR>\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
@@ -23,13 +15,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include "IsaFloppy.h"\r
 \r
 /**\r
-\r
-  Detect the floppy drive is presented or not\r
+  Detect whether a floppy drive is present or not.\r
  \r
-  @param  FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV\r
-  @retval EFI_SUCCESS    Drive is presented\r
-  @retval EFI_NOT_FOUND  Drive is not presented\r
+  @param[in] FdcDev  A pointer to the FDC_BLK_IO_DEV\r
 \r
+  @retval EFI_SUCCESS    The floppy disk drive is present\r
+  @retval EFI_NOT_FOUND  The floppy disk drive is not present\r
 **/\r
 EFI_STATUS\r
 DiscoverFddDevice (\r
@@ -40,9 +31,6 @@ DiscoverFddDevice (
 \r
   FdcDev->BlkIo.Media = &FdcDev->BlkMedia;\r
 \r
-  //\r
-  // Call FddIndentify subroutine\r
-  //\r
   Status = FddIdentify (FdcDev);\r
   if (EFI_ERROR (Status)) {\r
     return EFI_NOT_FOUND;\r
@@ -59,13 +47,13 @@ DiscoverFddDevice (
 }\r
 \r
 /**\r
-\r
-  Do recalibrate  and see the drive is presented or not\r
-  Set the media parameters\r
+  Do recalibrate and check if the drive is present or not\r
+  and set the media parameters if the driver is present.\r
   \r
-  @param FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV\r
-  @return the drive is presented or not\r
+  @param[in] FdcDev  A pointer to the FDC_BLK_IO_DEV\r
 \r
+  @retval EFI_SUCCESS       The floppy disk drive is present\r
+  @retval EFI_DEVICE_ERROR  The floppy disk drive is not present\r
 **/\r
 EFI_STATUS\r
 FddIdentify (\r
@@ -94,9 +82,6 @@ FddIdentify (
   //\r
   FdcDev->BlkIo.Media->RemovableMedia = TRUE;\r
   FdcDev->BlkIo.Media->MediaPresent   = TRUE;\r
-  //\r
-  // investigate\r
-  //\r
   FdcDev->BlkIo.Media->MediaId = 0;\r
 \r
   //\r
@@ -137,10 +122,9 @@ FddIdentify (
 }\r
 \r
 /**\r
-\r
-  Reset the Floppy Logic Drive\r
+  Reset the Floppy Logic Drive.\r
   \r
-  @param  FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV\r
+  @param  FdcDev FDC_BLK_IO_DEV * : A pointer to the FDC_BLK_IO_DEV\r
   \r
   @retval EFI_SUCCESS:    The Floppy Logic Drive is reset\r
   @retval EFI_DEVICE_ERROR: The Floppy Logic Drive is not functioning correctly and\r
@@ -152,7 +136,7 @@ FddReset (
   IN FDC_BLK_IO_DEV  *FdcDev\r
   )\r
 {\r
-  UINT8 data;\r
+  UINT8 Data;\r
   UINT8 StatusRegister0;\r
   UINT8 PresentCylinderNumber;\r
   UINTN Index;\r
@@ -179,9 +163,9 @@ FddReset (
   //         use bit0 & bit1 to  select the logic drive\r
   //         write "0" to bit2\r
   //\r
-  data = 0x0;\r
-  data = (UINT8) (data | (SELECT_DRV & FdcDev->Disk));\r
-  FdcWritePort (FdcDev, FDC_REGISTER_DOR, data);\r
+  Data = 0x0;\r
+  Data = (UINT8) (Data | (SELECT_DRV & FdcDev->Disk));\r
+  FdcWritePort (FdcDev, FDC_REGISTER_DOR, Data);\r
 \r
   //\r
   // wait some time,at least 120us\r
@@ -193,8 +177,8 @@ FddReset (
   //   write "1" to bit2\r
   //   write "1" to bit3 : enable DMA\r
   //\r
-  data |= 0x0C;\r
-  FdcWritePort (FdcDev, FDC_REGISTER_DOR, data);\r
+  Data |= 0x0C;\r
+  FdcWritePort (FdcDev, FDC_REGISTER_DOR, Data);\r
 \r
   //\r
   // Experience value\r
@@ -236,16 +220,13 @@ FddReset (
 }\r
 \r
 /**\r
-\r
-  Turn the drive's motor on\r
-  The drive's motor must be on before any command can be executed\r
+  Turn the floppy disk drive's motor on.\r
+  The drive's motor must be on before any command can be executed.\r
   \r
-  @param  FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV\r
+  @param[in] FdcDev  A pointer to the FDC_BLK_IO_DEV\r
   \r
-  @retval  EFI_SUCCESS:       Turn the drive's motor on successfully\r
-  @retval  EFI_DEVICE_ERROR:    The drive is busy, so can not turn motor on\r
-  @retval  EFI_INVALID_PARAMETER: Fail to Set timer(Cancel timer)\r
-\r
+  @retval  EFI_SUCCESS            The drive's motor was turned on successfully\r
+  @retval  EFI_DEVICE_ERROR       The drive is busy, so can not turn motor on\r
 **/\r
 EFI_STATUS\r
 MotorOn (\r
@@ -253,7 +234,7 @@ MotorOn (
   )\r
 {\r
   EFI_STATUS  Status;\r
-  UINT8       data;\r
+  UINT8       DorData;\r
 \r
   //\r
   // Control of the floppy drive motors is a big pain. If motor is off, you have\r
@@ -269,17 +250,15 @@ MotorOn (
   // Cancel the timer\r
   //\r
   Status = gBS->SetTimer (FdcDev->Event, TimerCancel, 0);\r
+  ASSERT_EFI_ERROR (Status);\r
 \r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
   //\r
   // Get the motor status\r
   //\r
-  data = FdcReadPort (FdcDev, FDC_REGISTER_DOR);\r
+  DorData = FdcReadPort (FdcDev, FDC_REGISTER_DOR);\r
 \r
-  if (((FdcDev->Disk == FDC_DISK0) && ((data & 0x10) == 0x10)) ||\r
-      ((FdcDev->Disk == FDC_DISK1) && ((data & 0x21) == 0x21))\r
+  if (((FdcDev->Disk == FdcDisk0) && ((DorData & 0x10) == 0x10)) ||\r
+      ((FdcDev->Disk == FdcDisk1) && ((DorData & 0x21) == 0x21))\r
       ) {\r
     return EFI_SUCCESS;\r
   }\r
@@ -293,21 +272,21 @@ MotorOn (
   //\r
   // for drive A: 1CH, drive B: 2DH\r
   //\r
-  data = 0x0C;\r
-  data = (UINT8) (data | (SELECT_DRV & FdcDev->Disk));\r
-  if (FdcDev->Disk == FDC_DISK0) {\r
+  DorData = 0x0C;\r
+  DorData = (UINT8) (DorData | (SELECT_DRV & FdcDev->Disk));\r
+  if (FdcDev->Disk == FdcDisk0) {\r
     //\r
     // drive A\r
     //\r
-    data |= DRVA_MOTOR_ON;\r
+    DorData |= DRVA_MOTOR_ON;\r
   } else {\r
     //\r
     // drive B\r
     //\r
-    data |= DRVB_MOTOR_ON;\r
+    DorData |= DRVB_MOTOR_ON;\r
   }\r
 \r
-  FdcWritePort (FdcDev, FDC_REGISTER_DOR, data);\r
+  FdcWritePort (FdcDev, FDC_REGISTER_DOR, DorData);\r
 \r
   //\r
   // Experience value\r
@@ -318,15 +297,12 @@ MotorOn (
 }\r
 \r
 /**\r
-\r
-  Set a Timer and when Timer goes off, turn the motor off\r
-  \r
+  Set a Timer and when Timer goes off, turn the motor off.\r
   \r
-  @param  FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV\r
+  @param[in] FdcDev  A pointer to the FDC_BLK_IO_DEV\r
   \r
-  @retval  EFI_SUCCESS:       Set the Timer successfully\r
-  @retval  EFI_INVALID_PARAMETER: Fail to Set the timer\r
-\r
+  @retval  EFI_SUCCESS            Set the Timer successfully\r
+  @retval  EFI_INVALID_PARAMETER  Fail to Set the timer\r
 **/\r
 EFI_STATUS\r
 MotorOff (\r
@@ -340,15 +316,14 @@ MotorOff (
 }\r
 \r
 /**\r
-  Detect the disk in the drive is changed or not\r
-  \r
+  Detect whether the disk in the drive is changed or not.\r
   \r
-  @param  FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
+  @param[in] FdcDev  A pointer to FDC_BLK_IO_DEV\r
   \r
-  @retval  EFI_SUCCESS:    No disk media change\r
-  @retval  EFI_DEVICE_ERROR: Fail to do the recalibrate or seek operation\r
-  @retval  EFI_NO_MEDIA:   No disk in the drive\r
-  @retval  EFI_MEDIA_CHANGED:  There is a new disk in the drive\r
+  @retval  EFI_SUCCESS        No disk media change\r
+  @retval  EFI_DEVICE_ERROR   Fail to do the recalibrate or seek operation\r
+  @retval  EFI_NO_MEDIA       No disk in the drive\r
+  @retval  EFI_MEDIA_CHANGED  There is a new disk in the drive\r
 **/\r
 EFI_STATUS\r
 DisketChanged (\r
@@ -356,19 +331,19 @@ DisketChanged (
   )\r
 {\r
   EFI_STATUS  Status;\r
-  UINT8       data;\r
+  UINT8       Data;\r
 \r
   //\r
   // Check change line\r
   //\r
-  data = FdcReadPort (FdcDev, FDC_REGISTER_DIR);\r
+  Data = FdcReadPort (FdcDev, FDC_REGISTER_DIR);\r
 \r
   //\r
   // Io delay\r
   //\r
   MicroSecondDelay (50);\r
 \r
-  if ((data & DIR_DCL) == 0x80) {\r
+  if ((Data & DIR_DCL) == 0x80) {\r
     //\r
     // disk change line is active\r
     //\r
@@ -386,14 +361,14 @@ DisketChanged (
       //\r
     }\r
 \r
-    data = FdcReadPort (FdcDev, FDC_REGISTER_DIR);\r
+    Data = FdcReadPort (FdcDev, FDC_REGISTER_DIR);\r
 \r
     //\r
     // Io delay\r
     //\r
     MicroSecondDelay (50);\r
 \r
-    if ((data & DIR_DCL) == 0x80) {\r
+    if ((Data & DIR_DCL) == 0x80) {\r
       return EFI_NO_MEDIA;\r
     }\r
 \r
@@ -406,13 +381,12 @@ DisketChanged (
 /**\r
   Do the Specify command, this command sets DMA operation\r
   and the initial values for each of the three internal\r
-  times: HUT, SRT and HLT\r
+  times: HUT, SRT and HLT.\r
   \r
-  @param FdcDev    Pointer to instance of FDC_BLK_IO_DEV\r
+  @param[in] FdcDev  Pointer to instance of FDC_BLK_IO_DEV\r
   \r
-  @retval  EFI_SUCCESS:    Execute the Specify command successfully\r
-  @retval  EFI_DEVICE_ERROR: Fail to execute the command\r
-\r
+  @retval EFI_SUCCESS       Execute the Specify command successfully\r
+  @retval EFI_DEVICE_ERROR  Fail to execute the command\r
 **/\r
 EFI_STATUS\r
 Specify (\r
@@ -447,9 +421,9 @@ Specify (
 }\r
 \r
 /**\r
-  Set the head of floppy drive to track 0\r
+  Set the head of floppy drive to track 0.\r
  \r
-  @param  FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
+  @param  FdcDev FDC_BLK_IO_DEV *: A pointer to FDC_BLK_IO_DEV\r
   @retval EFI_SUCCESS:    Execute the Recalibrate operation successfully\r
   @retval EFI_DEVICE_ERROR: Fail to execute the Recalibrate operation\r
 \r
@@ -474,7 +448,7 @@ Recalibrate (
     //\r
     // drive select\r
     //\r
-    if (FdcDev->Disk == FDC_DISK0) {\r
+    if (FdcDev->Disk == FdcDisk0) {\r
       Command.DiskHeadSel = 0;\r
       //\r
       // 0\r
@@ -521,9 +495,9 @@ Recalibrate (
 }\r
 \r
 /**\r
-  Set the head of floppy drive to the new cylinder\r
+  Set the head of floppy drive to the new cylinder.\r
   \r
-  @param  FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
+  @param  FdcDev FDC_BLK_IO_DEV *: A pointer to FDC_BLK_IO_DEV\r
   @param  Lba EFI_LBA     : The logic block address want to seek\r
   \r
   @retval  EFI_SUCCESS:    Execute the Seek operation successfully\r
@@ -573,7 +547,7 @@ Seek (
 \r
   ZeroMem (&Command, sizeof (FDD_SEEK_CMD));\r
   Command.CommandCode = SEEK_CMD;\r
-  if (FdcDev->Disk == FDC_DISK0) {\r
+  if (FdcDev->Disk == FdcDisk0) {\r
     Command.DiskHeadSel = 0;\r
     //\r
     // 0\r
@@ -625,9 +599,9 @@ Seek (
 \r
 /**\r
   Do the Sense Interrupt Status command, this command\r
-  resets the interrupt signal\r
+  resets the interrupt signal.\r
   \r
-  @param  FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
+  @param  FdcDev FDC_BLK_IO_DEV *: A pointer to FDC_BLK_IO_DEV\r
   @param  StatusRegister0 UINT8 *: Be used to save Status Register 0 read from FDC\r
   @param  PresentCylinderNumber  UINT8 *: Be used to save present cylinder number\r
                                     read from FDC\r
@@ -643,10 +617,10 @@ SenseIntStatus (
   IN OUT UINT8           *PresentCylinderNumber\r
   )\r
 {\r
-  UINT8 command;\r
+  UINT8 Command;\r
 \r
-  command = SENSE_INT_STATUS_CMD;\r
-  if (EFI_ERROR (DataOutByte (FdcDev, &command))) {\r
+  Command = SENSE_INT_STATUS_CMD;\r
+  if (EFI_ERROR (DataOutByte (FdcDev, &Command))) {\r
     return EFI_DEVICE_ERROR;\r
   }\r
 \r
@@ -662,9 +636,9 @@ SenseIntStatus (
 }\r
 \r
 /**\r
-  Do the Sense Drive Status command\r
+  Do the Sense Drive Status command.\r
   \r
-  @param  FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
+  @param  FdcDev FDC_BLK_IO_DEV *: A pointer to FDC_BLK_IO_DEV\r
   @param  Lba EFI_LBA     : Logic block address\r
   \r
   @retval  EFI_SUCCESS:    Execute the Sense Drive Status command successfully\r
@@ -693,7 +667,7 @@ SenseDrvStatus (
   ZeroMem (&Command, sizeof (FDD_COMMAND_PACKET2));\r
   Command.CommandCode = SENSE_DRV_STATUS_CMD;\r
 \r
-  if (FdcDev->Disk == FDC_DISK0) {\r
+  if (FdcDev->Disk == FdcDisk0) {\r
     Command.DiskHeadSel = 0;\r
   } else {\r
     Command.DiskHeadSel = 1;\r
@@ -725,10 +699,9 @@ SenseDrvStatus (
 }\r
 \r
 /**\r
-  Update the disk media properties and if necessary\r
-                        reinstall Block I/O interface\r
+  Update the disk media properties and if necessary reinstall Block I/O interface.\r
  \r
-  @param  FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
+  @param  FdcDev FDC_BLK_IO_DEV *: A pointer to FDC_BLK_IO_DEV\r
   \r
   @retval  EFI_SUCCESS:    Do the operation successfully\r
   @retval  EFI_DEVICE_ERROR: Fail to the operation\r
@@ -740,13 +713,13 @@ DetectMedia (
   )\r
 {\r
   EFI_STATUS  Status;\r
-  BOOLEAN     bReset;\r
-  BOOLEAN     bReadOnlyLastTime;\r
-  BOOLEAN     bMediaPresentLastTime;\r
+  BOOLEAN     Reset;\r
+  BOOLEAN     ReadOnlyLastTime;\r
+  BOOLEAN     MediaPresentLastTime;\r
 \r
-  bReset                = FALSE;\r
-  bReadOnlyLastTime     = FdcDev->BlkIo.Media->ReadOnly;\r
-  bMediaPresentLastTime = FdcDev->BlkIo.Media->MediaPresent;\r
+  Reset                = FALSE;\r
+  ReadOnlyLastTime     = FdcDev->BlkIo.Media->ReadOnly;\r
+  MediaPresentLastTime = FdcDev->BlkIo.Media->MediaPresent;\r
 \r
   //\r
   // Check disk change\r
@@ -756,7 +729,7 @@ DetectMedia (
   if (Status == EFI_MEDIA_CHANGED) {\r
     FdcDev->BlkIo.Media->MediaId++;\r
     FdcDev->BlkIo.Media->MediaPresent = TRUE;\r
-    bReset = TRUE;\r
+    Reset = TRUE;\r
   } else if (Status == EFI_NO_MEDIA) {\r
     FdcDev->BlkIo.Media->MediaPresent = FALSE;\r
   } else if (Status != EFI_SUCCESS) {\r
@@ -779,15 +752,15 @@ DetectMedia (
     }\r
   }\r
 \r
-  if (FdcDev->BlkIo.Media->MediaPresent && (bReadOnlyLastTime != FdcDev->BlkIo.Media->ReadOnly)) {\r
-    bReset = TRUE;\r
+  if (FdcDev->BlkIo.Media->MediaPresent && (ReadOnlyLastTime != FdcDev->BlkIo.Media->ReadOnly)) {\r
+    Reset = TRUE;\r
   }\r
 \r
-  if (bMediaPresentLastTime != FdcDev->BlkIo.Media->MediaPresent) {\r
-    bReset = TRUE;\r
+  if (MediaPresentLastTime != FdcDev->BlkIo.Media->MediaPresent) {\r
+    Reset = TRUE;\r
   }\r
 \r
-  if (bReset) {\r
+  if (Reset) {\r
     Status = gBS->ReinstallProtocolInterface (\r
                     FdcDev->Handle,\r
                     &gEfiBlockIoProtocolGuid,\r
@@ -804,9 +777,9 @@ DetectMedia (
 }\r
 \r
 /**\r
-  Set the data rate and so on\r
+  Set the data rate and so on.\r
  \r
-  @param  FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
+  @param  FdcDev  A pointer to FDC_BLK_IO_DEV\r
 \r
   @retval EFI_SUCCESS success to set the data rate\r
 **/\r
@@ -837,9 +810,9 @@ Setup (
 }\r
 \r
 /**\r
-  Read or Write a number of blocks in the same cylinder\r
+  Read or Write a number of blocks in the same cylinder.\r
  \r
-  @param  FdcDev      A pointer to Data Structure FDC_BLK_IO_DEV\r
+  @param  FdcDev      A pointer to FDC_BLK_IO_DEV\r
   @param  HostAddress device address \r
   @param  Lba         The starting logic block address to read from on the device\r
   @param  NumberOfBlocks The number of block wanted to be read or write\r
@@ -952,7 +925,7 @@ ReadWriteDataSector (
 \r
     MicroSecondDelay (50);\r
     Times = Times - 1;\r
-  } while (Times);\r
+  } while (Times >= 0);\r
 \r
   if (Times == 0) {\r
     return EFI_TIMEOUT;\r
@@ -987,7 +960,7 @@ ReadWriteDataSector (
 }\r
 \r
 /**\r
-  Fill in FDD command's parameter\r
+  Fill in FDD command's parameter.\r
   \r
   @param FdcDev   Pointer to instance of FDC_BLK_IO_DEV\r
   @param Lba      The starting logic block address to read from on the device\r
@@ -1011,7 +984,7 @@ FillPara (
   //\r
   // Fill the command parameter\r
   //\r
-  if (FdcDev->Disk == FDC_DISK0) {\r
+  if (FdcDev->Disk == FdcDisk0) {\r
     Command->DiskHeadSel = 0;\r
   } else {\r
     Command->DiskHeadSel = 1;\r
@@ -1028,23 +1001,22 @@ FillPara (
 }\r
 \r
 /**\r
-  Read result byte from Data Register of FDC\r
-  \r
-  @param FdcDev  Pointer to instance of FDC_BLK_IO_DEV\r
-  @param Pointer UINT8 *: Be used to save result byte read from FDC\r
+  Read result byte from Data Register of FDC.\r
   \r
+  @param FdcDev   Pointer to instance of FDC_BLK_IO_DEV\r
+  @param Pointer  Buffer to store the byte read from FDC\r
   \r
-  @retval  EFI_SUCCESS:    Read result byte from FDC successfully\r
-  @retval  EFI_DEVICE_ERROR: The FDC is not ready to be read\r
+  @retval EFI_SUCCESS       Read result byte from FDC successfully\r
+  @retval EFI_DEVICE_ERROR  The FDC is not ready to be read\r
 \r
 **/\r
 EFI_STATUS\r
 DataInByte (\r
-  IN     FDC_BLK_IO_DEV  *FdcDev,\r
-  IN OUT UINT8           *Pointer\r
+  IN  FDC_BLK_IO_DEV  *FdcDev,\r
+  OUT UINT8           *Pointer\r
   )\r
 {\r
-  UINT8 data;\r
+  UINT8 Data;\r
 \r
   //\r
   // wait for 1ms and detect the FDC is ready to be read\r
@@ -1056,19 +1028,19 @@ DataInByte (
     //\r
   }\r
 \r
-  data = FdcReadPort (FdcDev, FDC_REGISTER_DTR);\r
+  Data = FdcReadPort (FdcDev, FDC_REGISTER_DTR);\r
 \r
   //\r
   // Io delay\r
   //\r
   MicroSecondDelay (50);\r
 \r
-  *Pointer = data;\r
+  *Pointer = Data;\r
   return EFI_SUCCESS;\r
 }\r
 \r
 /**\r
-  Write command byte to Data Register of FDC\r
+  Write command byte to Data Register of FDC.\r
   \r
   @param FdcDev  Pointer to instance of FDC_BLK_IO_DEV\r
   @param Pointer Be used to save command byte written to FDC\r
@@ -1083,21 +1055,21 @@ DataOutByte (
   IN UINT8           *Pointer\r
   )\r
 {\r
-  UINT8 data;\r
+  UINT8 Data;\r
 \r
   //\r
   // wait for 1ms and detect the FDC is ready to be written\r
   //\r
   if (EFI_ERROR (FddDRQReady (FdcDev, DATA_OUT, 1))) {\r
-    return EFI_DEVICE_ERROR;\r
     //\r
-    // is not ready\r
+    // Not ready\r
     //\r
+    return EFI_DEVICE_ERROR;\r
   }\r
 \r
-  data = *Pointer;\r
+  Data = *Pointer;\r
 \r
-  FdcWritePort (FdcDev, FDC_REGISTER_DTR, data);\r
+  FdcWritePort (FdcDev, FDC_REGISTER_DTR, Data);\r
 \r
   //\r
   // Io delay\r
@@ -1108,8 +1080,7 @@ DataOutByte (
 }\r
 \r
 /**\r
-  Detect the specified floppy logic drive is busy or\r
-  not within a period of time\r
+  Detect the specified floppy logic drive is busy or not within a period of time.\r
   \r
   @param FdcDev           Indicate it is drive A or drive B\r
   @param TimeoutInSeconds the time period for waiting\r
@@ -1139,7 +1110,7 @@ FddWaitForBSYClear (
   //\r
   // set mask: for drive A set bit0 & bit4; for drive B set bit1 & bit4\r
   //\r
-  Mask  = (UINT8) ((FdcDev->Disk == FDC_DISK0 ? MSR_DAB : MSR_DBB) | MSR_CB);\r
+  Mask  = (UINT8) ((FdcDev->Disk == FdcDisk0 ? MSR_DAB : MSR_DBB) | MSR_CB);\r
 \r
   Delay = ((TimeoutInSeconds * STALL_1_MSECOND) / 50) + 1;\r
   do {\r
@@ -1153,7 +1124,7 @@ FddWaitForBSYClear (
 \r
     MicroSecondDelay (50);\r
     Delay = Delay - 1;\r
-  } while (Delay);\r
+  } while (Delay >= 0);\r
 \r
   if (Delay == 0) {\r
     return EFI_TIMEOUT;\r
@@ -1164,7 +1135,7 @@ FddWaitForBSYClear (
 \r
 /**\r
 \r
-  Routine Description:  Determine whether FDC is ready to write or read\r
+  Routine Description:  Determine whether FDC is ready to write or read.\r
   \r
   @param  FdcDev Pointer to instance of FDC_BLK_IO_DEV\r
   @param  Dio BOOLEAN:      Indicate the FDC is waiting to write or read\r
@@ -1213,7 +1184,7 @@ FddDRQReady (
     // Stall for 50 us\r
     //\r
     Delay = Delay - 1;\r
-  } while (Delay);\r
+  } while (Delay >= 0);\r
 \r
   if (Delay == 0) {\r
     return EFI_NOT_READY;\r
@@ -1226,8 +1197,7 @@ FddDRQReady (
 }\r
 \r
 /**\r
-  Set FDC control structure's attribute according to\r
-  result \r
+  Set FDC control structure's attribute according to result. \r
 \r
   @param Result  Point to result structure\r
   @param FdcDev  FDC control structure\r
@@ -1261,14 +1231,14 @@ CheckResult (
   //\r
   // Check Status Register1\r
   //\r
-  if (Result->Status1 & (STS1_EN | STS1_DE | STS1_OR | STS1_ND | STS1_NW | STS1_MA)) {\r
+  if ((Result->Status1 & (STS1_EN | STS1_DE | STS1_OR | STS1_ND | STS1_NW | STS1_MA)) != 0) {\r
     FdcDev->ControllerState->NeedRecalibrate = TRUE;\r
     return EFI_DEVICE_ERROR;\r
   }\r
   //\r
   // Check Status Register2\r
   //\r
-  if (Result->Status2 & (STS2_CM | STS2_DD | STS2_WC | STS2_BC | STS2_MD)) {\r
+  if ((Result->Status2 & (STS2_CM | STS2_DD | STS2_WC | STS2_BC | STS2_MD)) != 0) {\r
     FdcDev->ControllerState->NeedRecalibrate = TRUE;\r
     return EFI_DEVICE_ERROR;\r
   }\r
@@ -1277,7 +1247,7 @@ CheckResult (
 }\r
 \r
 /**\r
-  Check the drive status information\r
+  Check the drive status information.\r
   \r
   @param StatusRegister3  the value of Status Register 3\r
   \r
@@ -1290,7 +1260,7 @@ CheckStatus3 (
   IN UINT8 StatusRegister3\r
   )\r
 {\r
-  if (StatusRegister3 & STS3_WP) {\r
+  if ((StatusRegister3 & STS3_WP) != 0) {\r
     return EFI_WRITE_PROTECTED;\r
   }\r
 \r
@@ -1298,10 +1268,9 @@ CheckStatus3 (
 }\r
 \r
 /**\r
-  Calculate the number of block in the same cylinder\r
-  according to LBA\r
+  Calculate the number of block in the same cylinder according to LBA.\r
   \r
-  @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
+  @param FdcDev FDC_BLK_IO_DEV *: A pointer to FDC_BLK_IO_DEV\r
   @param LBA EFI_LBA:      The starting logic block address\r
   @param NumberOfBlocks UINTN: The number of blocks\r
   \r
@@ -1335,7 +1304,7 @@ GetTransferBlockCount (
 }\r
 \r
 /**\r
-  When the Timer(2s) off, turn the drive's motor off\r
+  When the Timer(2s) off, turn the drive's motor off.\r
   \r
   @param Event EFI_EVENT: Event(the timer) whose notification function is being\r
                      invoked\r
@@ -1350,35 +1319,36 @@ FddTimerProc (
   )\r
 {\r
   FDC_BLK_IO_DEV  *FdcDev;\r
-  UINT8           data;\r
+  UINT8           Data;\r
 \r
   FdcDev = (FDC_BLK_IO_DEV *) Context;\r
 \r
   //\r
   // Get the motor status\r
   //\r
-  data = FdcReadPort (FdcDev, FDC_REGISTER_DOR);\r
+  Data = FdcReadPort (FdcDev, FDC_REGISTER_DOR);\r
 \r
-  if (((FdcDev->Disk == FDC_DISK0) && ((data & 0x10) != 0x10)) ||\r
-      ((FdcDev->Disk == FDC_DISK1) && ((data & 0x21) != 0x21))\r
+  if (((FdcDev->Disk == FdcDisk0) && ((Data & 0x10) != 0x10)) ||\r
+      ((FdcDev->Disk == FdcDisk1) && ((Data & 0x21) != 0x21))\r
       ) {\r
     return ;\r
   }\r
   //\r
   // the motor is on, so need motor off\r
   //\r
-  data = 0x0C;\r
-  data = (UINT8) (data | (SELECT_DRV & FdcDev->Disk));\r
-  FdcWritePort (FdcDev, FDC_REGISTER_DOR, data);\r
+  Data = 0x0C;\r
+  Data = (UINT8) (Data | (SELECT_DRV & FdcDev->Disk));\r
+  FdcWritePort (FdcDev, FDC_REGISTER_DOR, Data);\r
   MicroSecondDelay (500);\r
 }\r
 \r
 /**\r
-  Read I/O port for FDC\r
+  Read an I/O port of FDC.\r
  \r
-  @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
-  @param Offset The offset address of port\r
+  @param[in] FdcDev  A pointer to FDC_BLK_IO_DEV.\r
+  @param[in] Offset  The address offset of the I/O port.\r
 \r
+  @retval  8-bit data read from the I/O port.\r
 **/\r
 UINT8\r
 FdcReadPort (\r
@@ -1386,29 +1356,27 @@ FdcReadPort (
   IN UINT32          Offset\r
   )\r
 {\r
+  EFI_STATUS  Status;\r
   UINT8       Data;\r
 \r
-  //\r
-  // Call IsaIo\r
-  //\r
-  FdcDev->IsaIo->Io.Read (\r
-                      FdcDev->IsaIo,\r
-                      EfiIsaIoWidthUint8,\r
-                      FdcDev->BaseAddress + Offset,\r
-                      1,\r
-                      &Data\r
-                      );\r
+  Status = FdcDev->IsaIo->Io.Read (\r
+                            FdcDev->IsaIo,\r
+                            EfiIsaIoWidthUint8,\r
+                            FdcDev->BaseAddress + Offset,\r
+                            1,\r
+                            &Data\r
+                            );\r
+  ASSERT_EFI_ERROR (Status);\r
 \r
   return Data;\r
 }\r
 \r
 /**\r
-  Write I/O port for FDC\r
+  Write an I/O port of FDC.\r
  \r
-  @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
-  @param Offset The offset address of port\r
-  @param Data   Value written to port\r
-  \r
+  @param[in] FdcDev  A pointer to FDC_BLK_IO_DEV\r
+  @param[in] Offset  The address offset of the I/O port\r
+  @param[in] Data    8-bit Value written to the I/O port\r
 **/\r
 VOID\r
 FdcWritePort (\r
@@ -1417,16 +1385,15 @@ FdcWritePort (
   IN UINT8           Data\r
   )\r
 {\r
+  EFI_STATUS  Status;\r
 \r
-  //\r
-  // Call IsaIo\r
-  //\r
-  FdcDev->IsaIo->Io.Write (\r
-                      FdcDev->IsaIo,\r
-                      EfiIsaIoWidthUint8,\r
-                      FdcDev->BaseAddress + Offset,\r
-                      1,\r
-                      &Data\r
-                      );\r
+  Status = FdcDev->IsaIo->Io.Write (\r
+                            FdcDev->IsaIo,\r
+                            EfiIsaIoWidthUint8,\r
+                            FdcDev->BaseAddress + Offset,\r
+                            1,\r
+                            &Data\r
+                            );\r
+  ASSERT_EFI_ERROR (Status);\r
 }\r
 \r
index 288bf4e28d6ca35f536b8460ae3990e6064aa8c0..abfa1e2ebb331f936a3b4e1479618a1def9f9127 100644 (file)
@@ -1,15 +1,14 @@
 #/** @file\r
 # Component description file for IsaFloppy module.\r
 #\r
-# ISA Floppy Driver\r
-#  1. Support two types diskette drive\r
-#   1.44M drive and 2.88M drive (and now only support 1.44M)\r
-#  2. Support two diskette drives\r
+# ISA Floppy Disk UEFI Driver conforming to the UEFI driver model\r
+#\r
+#  1. Support two types diskette drive  \r
+#     1.44M drive and 2.88M drive (and now only support 1.44M)\r
+#  2. Support two diskette drives per floppy disk controller\r
 #  3. Use DMA channel 2 to transfer data\r
 #  4. Do not use interrupt\r
 #  5. Support diskette change line signal and write protect\r
-# \r
-#  Conforming to EFI driver model\r
 #\r
 # Copyright (c) 2007 - 2009, Intel Corporation\r
 #\r
   UefiDriverEntryPoint\r
   DebugLib\r
   TimerLib\r
+  PcdLib\r
 \r
 [Protocols]\r
   gEfiIsaIoProtocolGuid                         # PROTOCOL TO_START\r
   gEfiBlockIoProtocolGuid                       # PROTOCOL BY_START\r
   gEfiDevicePathProtocolGuid                    # PROTOCOL TO_START\r
 \r
-\r
+[FeaturePcd.common]\r
+  gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable        # CONSUMES\r
+  gEfiMdePkgTokenSpaceGuid.PcdComponentName2Disable       # CONSUMES\r