]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Move the files of IsaFloppy to upper directory
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 12 Jul 2007 05:45:18 +0000 (05:45 +0000)
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 12 Jul 2007 05:45:18 +0000 (05:45 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3208 6f19259b-4bc3-4df7-8a09-765794883524

16 files changed:
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/ComponentName.c [new file with mode: 0644]
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/ComponentName.h [new file with mode: 0644]
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/Dxe/ComponentName.c [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/Dxe/ComponentName.h [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/Dxe/IsaFloppy.c [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/Dxe/IsaFloppy.h [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/Dxe/IsaFloppy.inf [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/Dxe/IsaFloppy.msa [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/Dxe/IsaFloppyBlock.c [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/Dxe/IsaFloppyCtrl.c [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppy.c [new file with mode: 0644]
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppy.h [new file with mode: 0644]
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppy.inf [new file with mode: 0644]
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppy.msa [new file with mode: 0644]
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyBlock.c [new file with mode: 0644]
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyCtrl.c [new file with mode: 0644]

diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/ComponentName.c b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/ComponentName.c
new file mode 100644 (file)
index 0000000..7a488c8
--- /dev/null
@@ -0,0 +1,239 @@
+/*++\r
+\r
+  Copyright (c) 2006 - 2007, 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
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  ComponentName.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#include "IsaFloppy.h"\r
+\r
+//\r
+// EFI Component Name Protocol\r
+//\r
+EFI_COMPONENT_NAME_PROTOCOL     gIsaFloppyComponentName = {\r
+  IsaFloppyComponentNameGetDriverName,\r
+  IsaFloppyComponentNameGetControllerName,\r
+  "eng"\r
+};\r
+\r
+STATIC EFI_UNICODE_STRING_TABLE mIsaFloppyDriverNameTable[] = {\r
+  {\r
+    "eng",\r
+    L"ISA Floppy Driver"\r
+  },\r
+  {\r
+    NULL,\r
+    NULL\r
+  }\r
+};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IsaFloppyComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+  \r
+    Retrieves a Unicode string that is the user readable name of the EFI Driver.\r
+\r
+  Arguments:\r
+  \r
+    This       - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+    Language   - A pointer to a three character ISO 639-2 language identifier.\r
+                 This is the language of the driver name that that the caller \r
+                 is requesting, and it must match one of the languages specified\r
+                 in SupportedLanguages.  The number of languages supported by a \r
+                 driver is up to the driver writer.\r
+    DriverName - A pointer to the Unicode string to return.  This Unicode string\r
+                 is the name of the driver specified by This in the language \r
+                 specified by Language.\r
+\r
+  Returns:\r
+  \r
+    EFI_SUCCESS           - The Unicode string for the Driver specified by This\r
+                            and the language specified by Language was returned \r
+                            in DriverName.\r
+    EFI_INVALID_PARAMETER - Language is NULL.\r
+    EFI_INVALID_PARAMETER - DriverName is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+                            language specified by Language.\r
+\r
+--*/\r
+{\r
+  return LookupUnicodeString (\r
+           Language,\r
+           gIsaFloppyComponentName.SupportedLanguages,\r
+           mIsaFloppyDriverNameTable,\r
+           DriverName\r
+           );\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
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+  \r
+    Retrieves a Unicode string that is the user readable name of the controller\r
+    that is being managed by an EFI Driver.\r
+\r
+  Arguments:\r
+  \r
+    This             - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+    ControllerHandle - The handle of a controller that the driver specified by \r
+                       This is managing.  This handle specifies the controller \r
+                       whose name is to be returned.\r
+    ChildHandle      - The handle of the child controller to retrieve the name \r
+                       of.  This is an optional parameter that may be NULL.  It \r
+                       will be NULL for device drivers.  It will also be NULL \r
+                       for a bus drivers that wish to retrieve the name of the \r
+                       bus controller.  It will not be NULL for a bus driver \r
+                       that wishes to retrieve the name of a child controller.\r
+    Language         - A pointer to a three character ISO 639-2 language \r
+                       identifier.  This is the language of the controller name \r
+                       that that the caller is requesting, and it must match one\r
+                       of the languages specified in SupportedLanguages.  The \r
+                       number of languages supported by a driver is up to the \r
+                       driver writer.\r
+    ControllerName   - A pointer to the Unicode string to return.  This Unicode\r
+                       string is the name of the controller specified by \r
+                       ControllerHandle and ChildHandle in the language \r
+                       specified by Language from the point of view of the \r
+                       driver specified by This. \r
+\r
+  Returns:\r
+  \r
+    EFI_SUCCESS           - The Unicode string for the user readable name in the \r
+                            language specified by Language for the driver \r
+                            specified by This was returned in DriverName.\r
+    EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid \r
+                            EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - Language is NULL.\r
+    EFI_INVALID_PARAMETER - ControllerName is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This is not currently \r
+                            managing the controller specified by \r
+                            ControllerHandle and ChildHandle.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+                            language specified by Language.\r
+\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
+\r
+  //\r
+  // This is a device driver, so ChildHandle must be NULL.\r
+  //\r
+  if (ChildHandle != NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  //\r
+  // Check Controller's handle\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
+  }\r
+\r
+  if (Status != EFI_ALREADY_STARTED) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  //\r
+  // Get the Block I/O Protocol on Controller\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiBlockIoProtocolGuid,\r
+                  (VOID **) &BlkIo,\r
+                  gFdcControllerDriver.DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  //\r
+  // Get the Floppy Disk Controller's Device structure\r
+  //\r
+  FdcDev = FDD_BLK_IO_FROM_THIS (BlkIo);\r
+\r
+  return LookupUnicodeString (\r
+           Language,\r
+           gIsaFloppyComponentName.SupportedLanguages,\r
+           FdcDev->ControllerNameTable,\r
+           ControllerName\r
+           );\r
+}\r
+\r
+VOID\r
+AddName (\r
+  IN  FDC_BLK_IO_DEV         *FdcDev\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+  \r
+    Add the component name for the floppy device\r
+\r
+  Arguments:\r
+  \r
+    FdcDev                 - A pointer to the FDC_BLK_IO_DEV instance.\r
+\r
+  Returns:\r
+\r
+    None\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
+  AddUnicodeString (\r
+    "eng",\r
+    gIsaFloppyComponentName.SupportedLanguages,\r
+    &FdcDev->ControllerNameTable,\r
+    FloppyDriveName\r
+    );\r
+}\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/ComponentName.h b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/ComponentName.h
new file mode 100644 (file)
index 0000000..f7c06e7
--- /dev/null
@@ -0,0 +1,111 @@
+/*++\r
+\r
+  Copyright (c) 2006 - 2007, 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
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  ComponentName.h\r
+\r
+Abstract:\r
+\r
+Revision History:\r
+\r
+--*/\r
+\r
+#ifndef _ISA_FLOPPY_COMPONENT_NAME_H\r
+#define _ISA_FLOPPY_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
+\r
+extern EFI_COMPONENT_NAME_PROTOCOL  gIsaFloppyComponentName;\r
+\r
+//\r
+// EFI Component Name Functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+IsaFloppyComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This        - GC_TODO: add argument description\r
+  Language    - GC_TODO: add argument description\r
+  DriverName  - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\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
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This              - GC_TODO: add argument description\r
+  ControllerHandle  - GC_TODO: add argument description\r
+  ChildHandle       - GC_TODO: add argument description\r
+  Language          - GC_TODO: add argument description\r
+  ControllerName    - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+AddName (\r
+  IN  FDC_BLK_IO_DEV               *FdcDev\r
+  )\r
+/*++\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
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/Dxe/ComponentName.c b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/Dxe/ComponentName.c
deleted file mode 100644 (file)
index 7a488c8..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-/*++\r
-\r
-  Copyright (c) 2006 - 2007, 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
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-\r
-Module Name:\r
-\r
-  ComponentName.c\r
-\r
-Abstract:\r
-\r
---*/\r
-\r
-#include "IsaFloppy.h"\r
-\r
-//\r
-// EFI Component Name Protocol\r
-//\r
-EFI_COMPONENT_NAME_PROTOCOL     gIsaFloppyComponentName = {\r
-  IsaFloppyComponentNameGetDriverName,\r
-  IsaFloppyComponentNameGetControllerName,\r
-  "eng"\r
-};\r
-\r
-STATIC EFI_UNICODE_STRING_TABLE mIsaFloppyDriverNameTable[] = {\r
-  {\r
-    "eng",\r
-    L"ISA Floppy Driver"\r
-  },\r
-  {\r
-    NULL,\r
-    NULL\r
-  }\r
-};\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-IsaFloppyComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  )\r
-/*++\r
-\r
-  Routine Description:\r
-  \r
-    Retrieves a Unicode string that is the user readable name of the EFI Driver.\r
-\r
-  Arguments:\r
-  \r
-    This       - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
-    Language   - A pointer to a three character ISO 639-2 language identifier.\r
-                 This is the language of the driver name that that the caller \r
-                 is requesting, and it must match one of the languages specified\r
-                 in SupportedLanguages.  The number of languages supported by a \r
-                 driver is up to the driver writer.\r
-    DriverName - A pointer to the Unicode string to return.  This Unicode string\r
-                 is the name of the driver specified by This in the language \r
-                 specified by Language.\r
-\r
-  Returns:\r
-  \r
-    EFI_SUCCESS           - The Unicode string for the Driver specified by This\r
-                            and the language specified by Language was returned \r
-                            in DriverName.\r
-    EFI_INVALID_PARAMETER - Language is NULL.\r
-    EFI_INVALID_PARAMETER - DriverName is NULL.\r
-    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
-                            language specified by Language.\r
-\r
---*/\r
-{\r
-  return LookupUnicodeString (\r
-           Language,\r
-           gIsaFloppyComponentName.SupportedLanguages,\r
-           mIsaFloppyDriverNameTable,\r
-           DriverName\r
-           );\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
-  )\r
-/*++\r
-\r
-  Routine Description:\r
-  \r
-    Retrieves a Unicode string that is the user readable name of the controller\r
-    that is being managed by an EFI Driver.\r
-\r
-  Arguments:\r
-  \r
-    This             - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
-    ControllerHandle - The handle of a controller that the driver specified by \r
-                       This is managing.  This handle specifies the controller \r
-                       whose name is to be returned.\r
-    ChildHandle      - The handle of the child controller to retrieve the name \r
-                       of.  This is an optional parameter that may be NULL.  It \r
-                       will be NULL for device drivers.  It will also be NULL \r
-                       for a bus drivers that wish to retrieve the name of the \r
-                       bus controller.  It will not be NULL for a bus driver \r
-                       that wishes to retrieve the name of a child controller.\r
-    Language         - A pointer to a three character ISO 639-2 language \r
-                       identifier.  This is the language of the controller name \r
-                       that that the caller is requesting, and it must match one\r
-                       of the languages specified in SupportedLanguages.  The \r
-                       number of languages supported by a driver is up to the \r
-                       driver writer.\r
-    ControllerName   - A pointer to the Unicode string to return.  This Unicode\r
-                       string is the name of the controller specified by \r
-                       ControllerHandle and ChildHandle in the language \r
-                       specified by Language from the point of view of the \r
-                       driver specified by This. \r
-\r
-  Returns:\r
-  \r
-    EFI_SUCCESS           - The Unicode string for the user readable name in the \r
-                            language specified by Language for the driver \r
-                            specified by This was returned in DriverName.\r
-    EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
-    EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid \r
-                            EFI_HANDLE.\r
-    EFI_INVALID_PARAMETER - Language is NULL.\r
-    EFI_INVALID_PARAMETER - ControllerName is NULL.\r
-    EFI_UNSUPPORTED       - The driver specified by This is not currently \r
-                            managing the controller specified by \r
-                            ControllerHandle and ChildHandle.\r
-    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
-                            language specified by Language.\r
-\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
-\r
-  //\r
-  // This is a device driver, so ChildHandle must be NULL.\r
-  //\r
-  if (ChildHandle != NULL) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  //\r
-  // Check Controller's handle\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
-  }\r
-\r
-  if (Status != EFI_ALREADY_STARTED) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  //\r
-  // Get the Block I/O Protocol on Controller\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEfiBlockIoProtocolGuid,\r
-                  (VOID **) &BlkIo,\r
-                  gFdcControllerDriver.DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Get the Floppy Disk Controller's Device structure\r
-  //\r
-  FdcDev = FDD_BLK_IO_FROM_THIS (BlkIo);\r
-\r
-  return LookupUnicodeString (\r
-           Language,\r
-           gIsaFloppyComponentName.SupportedLanguages,\r
-           FdcDev->ControllerNameTable,\r
-           ControllerName\r
-           );\r
-}\r
-\r
-VOID\r
-AddName (\r
-  IN  FDC_BLK_IO_DEV         *FdcDev\r
-  )\r
-/*++\r
-\r
-  Routine Description:\r
-  \r
-    Add the component name for the floppy device\r
-\r
-  Arguments:\r
-  \r
-    FdcDev                 - A pointer to the FDC_BLK_IO_DEV instance.\r
-\r
-  Returns:\r
-\r
-    None\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
-  AddUnicodeString (\r
-    "eng",\r
-    gIsaFloppyComponentName.SupportedLanguages,\r
-    &FdcDev->ControllerNameTable,\r
-    FloppyDriveName\r
-    );\r
-}\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/Dxe/ComponentName.h b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/Dxe/ComponentName.h
deleted file mode 100644 (file)
index f7c06e7..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/*++\r
-\r
-  Copyright (c) 2006 - 2007, 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
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-Module Name:\r
-\r
-  ComponentName.h\r
-\r
-Abstract:\r
-\r
-Revision History:\r
-\r
---*/\r
-\r
-#ifndef _ISA_FLOPPY_COMPONENT_NAME_H\r
-#define _ISA_FLOPPY_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
-\r
-extern EFI_COMPONENT_NAME_PROTOCOL  gIsaFloppyComponentName;\r
-\r
-//\r
-// EFI Component Name Functions\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-IsaFloppyComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  This        - GC_TODO: add argument description\r
-  Language    - GC_TODO: add argument description\r
-  DriverName  - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\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
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  This              - GC_TODO: add argument description\r
-  ControllerHandle  - GC_TODO: add argument description\r
-  ChildHandle       - GC_TODO: add argument description\r
-  Language          - GC_TODO: add argument description\r
-  ControllerName    - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-VOID\r
-AddName (\r
-  IN  FDC_BLK_IO_DEV               *FdcDev\r
-  )\r
-/*++\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
-\r
---*/\r
-;\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/Dxe/IsaFloppy.c b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/Dxe/IsaFloppy.c
deleted file mode 100644 (file)
index 6bdccc2..0000000
+++ /dev/null
@@ -1,490 +0,0 @@
-/*++\r
-\r
-  Copyright (c) 2006 - 2007, 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
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-Module Name:\r
-\r
-  IsaFloppy.c\r
-\r
-Abstract:\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
-  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
-Revision History:\r
-\r
---*/\r
-\r
-#include "IsaFloppy.h"\r
-\r
-LIST_ENTRY              gControllerHead = INITIALIZE_LIST_HEAD_VARIABLE(gControllerHead);\r
-\r
-//\r
-// ISA Floppy Driver Binding Protocol\r
-//\r
-EFI_DRIVER_BINDING_PROTOCOL gFdcControllerDriver = {\r
-  FdcControllerDriverSupported,\r
-  FdcControllerDriverStart,\r
-  FdcControllerDriverStop,\r
-  0xa,\r
-  NULL,\r
-  NULL\r
-};\r
-\r
-\r
-/**\r
-  The user Entry Point for module IsaFloppy. The user code starts with this function.\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
-  \r
-  @retval EFI_SUCCESS       The entry point is executed successfully.\r
-  @retval other             Some error occurs when executing this entry point.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeIsaFloppy(\r
-  IN EFI_HANDLE           ImageHandle,\r
-  IN EFI_SYSTEM_TABLE     *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-\r
-  //\r
-  // Install driver model protocol(s).\r
-  //\r
-  Status = EfiLibInstallAllDriverProtocols (\r
-             ImageHandle,\r
-             SystemTable,\r
-             &gFdcControllerDriver,\r
-             ImageHandle,\r
-             &gIsaFloppyComponentName,\r
-             NULL,\r
-             NULL\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FdcControllerDriverSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  ControllerDriver Protocol Method\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
---*/\r
-// GC_TODO:    This - add argument and description to function comment\r
-// GC_TODO:    Controller - add argument and description to function comment\r
-// GC_TODO:    RemainingDevicePath - add argument and description to function comment\r
-{\r
-  EFI_STATUS                          Status;\r
-  EFI_ISA_IO_PROTOCOL                 *IsaIo;\r
-\r
-  //\r
-  // Open the ISA I/O Protocol\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiIsaIoProtocolGuid,\r
-                  (VOID **) &IsaIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Use the ISA I/O Protocol to see if Controller is a Floppy Disk Controller\r
-  //\r
-  Status = EFI_SUCCESS;\r
-  if (IsaIo->ResourceList->Device.HID != EISA_PNP_ID (0x604)) {\r
-    Status = EFI_UNSUPPORTED;\r
-  }\r
-  //\r
-  // Close the ISA I/O Protocol\r
-  //\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiIsaIoProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FdcControllerDriverStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
---*/\r
-// GC_TODO:    This - add argument and description to function comment\r
-// GC_TODO:    Controller - add argument and description to function comment\r
-// GC_TODO:    RemainingDevicePath - add argument and description to function comment\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
-\r
-  FdcDev  = NULL;\r
-  IsaIo   = NULL;\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
-  // Report enable progress code\r
-  //\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_PC_ENABLE,\r
-    ParentDevicePath\r
-    );\r
-\r
-  //\r
-  // Open the ISA I/O Protocol\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiIsaIoProtocolGuid,\r
-                  (VOID **) &IsaIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-  //\r
-  // Allocate the Floppy Disk Controller'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
-  //\r
-  FdcDev->Signature       = FDC_BLK_IO_DEV_SIGNATURE;\r
-  FdcDev->Handle          = Controller;\r
-  FdcDev->IsaIo           = IsaIo;\r
-  FdcDev->Disk            = (EFI_FDC_DISK) IsaIo->ResourceList->Device.UID;\r
-  FdcDev->Cache           = NULL;\r
-  FdcDev->Event           = NULL;\r
-  FdcDev->ControllerState = NULL;\r
-  FdcDev->DevicePath      = ParentDevicePath;\r
-\r
-  ADD_FLOPPY_NAME (FdcDev);\r
-  \r
-  //\r
-  // Look up the base address of the Floppy Disk Controller\r
-  //\r
-  for (Index = 0; FdcDev->IsaIo->ResourceList->ResourceItem[Index].Type != EfiIsaAcpiResourceEndOfList; Index++) {\r
-    if (FdcDev->IsaIo->ResourceList->ResourceItem[Index].Type == EfiIsaAcpiResourceIo) {\r
-      FdcDev->BaseAddress = (UINT16) FdcDev->IsaIo->ResourceList->ResourceItem[Index].StartRange;\r
-    }\r
-  }\r
-  //\r
-  // Maintain the list of controller list\r
-  //\r
-  Found = FALSE;\r
-  List  = gControllerHead.ForwardLink;\r
-  while (List != &gControllerHead) {\r
-    FdcDev->ControllerState = FLOPPY_CONTROLLER_FROM_LIST_ENTRY (List);\r
-    if (FdcDev->BaseAddress == FdcDev->ControllerState->BaseAddress) {\r
-      Found = TRUE;\r
-      break;\r
-    }\r
-\r
-    List = List->ForwardLink;\r
-  }\r
-\r
-  if (!Found) {\r
-    //\r
-    // The Controller is new\r
-    //\r
-    FdcDev->ControllerState = AllocatePool (sizeof (FLOPPY_CONTROLLER_CONTEXT));\r
-    if (FdcDev->ControllerState == NULL) {\r
-      goto Done;\r
-    }\r
-\r
-    FdcDev->ControllerState->Signature          = FLOPPY_CONTROLLER_CONTEXT_SIGNATURE;\r
-    FdcDev->ControllerState->FddResetPerformed  = FALSE;\r
-    FdcDev->ControllerState->NeedRecalibrate    = FALSE;\r
-    FdcDev->ControllerState->BaseAddress        = FdcDev->BaseAddress;\r
-    FdcDev->ControllerState->NumberOfDrive      = 0;\r
-\r
-    InsertTailList (&gControllerHead, &FdcDev->ControllerState->Link);\r
-  }\r
-  //\r
-  // Create a timer event for each Floppd Disk Controller.\r
-  // This timer event is used to control the motor on and off\r
-  //\r
-  Status = gBS->CreateEvent (\r
-                  EVT_TIMER | EVT_NOTIFY_SIGNAL,\r
-                  TPL_NOTIFY,\r
-                  FddTimerProc,\r
-                  FdcDev,\r
-                  &FdcDev->Event\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-  //\r
-  // Reset the Floppy Disk Controller\r
-  //\r
-  if (!FdcDev->ControllerState->FddResetPerformed) {\r
-    FdcDev->ControllerState->FddResetPerformed  = TRUE;\r
-    FdcDev->ControllerState->FddResetStatus     = FddReset (FdcDev);\r
-  }\r
-\r
-  if (EFI_ERROR (FdcDev->ControllerState->FddResetStatus)) {\r
-    Status = EFI_DEVICE_ERROR;\r
-    goto Done;\r
-  }\r
-\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_PC_PRESENCE_DETECT,\r
-    ParentDevicePath\r
-    );\r
-\r
-  //\r
-  // Discover the Floppy Drive\r
-  //\r
-  Status = DiscoverFddDevice (FdcDev);\r
-  if (EFI_ERROR (Status)) {\r
-    Status = EFI_DEVICE_ERROR;\r
-    goto Done;\r
-  }\r
-  //\r
-  // Install protocol interfaces for the serial device.\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &Controller,\r
-                  &gEfiBlockIoProtocolGuid,\r
-                  &FdcDev->BlkIo,\r
-                  NULL\r
-                  );\r
-\r
-  FdcDev->ControllerState->NumberOfDrive++;\r
-\r
-Done:\r
-  if (EFI_ERROR (Status)) {\r
-\r
-    REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_EC_CONTROLLER_ERROR,\r
-      ParentDevicePath\r
-      );\r
-\r
-    //\r
-    // Close the device path protocol\r
-    //\r
-    gBS->CloseProtocol (\r
-           Controller,\r
-           &gEfiDevicePathProtocolGuid,\r
-           This->DriverBindingHandle,\r
-           Controller\r
-           );\r
-\r
-    //\r
-    // Close the ISA I/O Protocol\r
-    //\r
-    if (IsaIo != NULL) {\r
-      gBS->CloseProtocol (\r
-             Controller,\r
-             &gEfiIsaIoProtocolGuid,\r
-             This->DriverBindingHandle,\r
-             Controller\r
-             );\r
-    }\r
-    //\r
-    // If a Floppy Disk Controller Device structure was allocated, then free it\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
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FdcControllerDriverStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN  EFI_HANDLE                   Controller,\r
-  IN  UINTN                        NumberOfChildren,\r
-  IN  EFI_HANDLE                   *ChildHandleBuffer\r
-  )\r
-/*++\r
-\r
-  Routine Description:\r
-\r
-  Arguments:\r
-\r
-  Returns:\r
-\r
---*/\r
-// GC_TODO:    This - add argument and description to function comment\r
-// GC_TODO:    Controller - add argument and description to function comment\r
-// GC_TODO:    NumberOfChildren - add argument and description to function comment\r
-// GC_TODO:    ChildHandleBuffer - add argument and description to function comment\r
-// GC_TODO:    EFI_SUCCESS - add return value to function comment\r
-{\r
-  EFI_STATUS            Status;\r
-  EFI_BLOCK_IO_PROTOCOL *BlkIo;\r
-  FDC_BLK_IO_DEV        *FdcDev;\r
-\r
-  //\r
-  // Get the Block I/O Protocol on Controller\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiBlockIoProtocolGuid,\r
-                  (VOID **) &BlkIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Get the Floppy Disk Controller's Device structure\r
-  //\r
-  FdcDev = FDD_BLK_IO_FROM_THIS (BlkIo);\r
-\r
-  //\r
-  // Report disable progress code\r
-  //\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_PC_DISABLE,\r
-    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
-  Status = gBS->UninstallProtocolInterface (\r
-                  Controller,\r
-                  &gEfiBlockIoProtocolGuid,\r
-                  &FdcDev->BlkIo\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Close the device path protocol\r
-  //\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiDevicePathProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  //\r
-  // Close the ISA I/O Protocol\r
-  //\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiIsaIoProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  //\r
-  // Free the controller list if needed\r
-  //\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
-  //\r
-  FreeUnicodeStringTable (FdcDev->ControllerNameTable);\r
-  gBS->FreePool (FdcDev);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/Dxe/IsaFloppy.h b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/Dxe/IsaFloppy.h
deleted file mode 100644 (file)
index f60b146..0000000
+++ /dev/null
@@ -1,1321 +0,0 @@
-/*++\r
-\r
-  Copyright (c) 2006 - 2007, 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
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-Module Name:\r
-\r
-  IsaFloppy.h\r
-\r
-Abstract:\r
-\r
-  Include for ISA Floppy Driver\r
-  Define the data structure and so on\r
-\r
-Revision History:\r
-\r
---*/\r
-\r
-#ifndef _ISA_FLOPPY_H\r
-#define _ISA_FLOPPY_H\r
-\r
-#include <PiDxe.h>\r
-#include <FrameworkPei.h>\r
-//\r
-// The protocols, PPI and GUID defintions for this module\r
-//\r
-#include <Protocol/BlockIo.h>\r
-#include <Protocol/IsaIo.h>\r
-#include <Protocol/DevicePath.h>\r
-//\r
-// The Library classes this module consumes\r
-//\r
-#include <Library/TimerLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/ReportStatusCodeLib.h>\r
-//\r
-// Driver Binding Externs\r
-//\r
-extern EFI_DRIVER_BINDING_PROTOCOL gFdcControllerDriver;\r
-extern EFI_COMPONENT_NAME_PROTOCOL gIsaFloppyComponentName;\r
-\r
-//\r
-// define some value\r
-//\r
-#define STALL_1_SECOND  1000000\r
-#define STALL_1_MSECOND 1000\r
-\r
-#define DATA_IN         1\r
-#define DATA_OUT        0\r
-#define READ            0\r
-#define WRITE           1\r
-\r
-//\r
-// Internal Data Structures\r
-//\r
-#define FDC_BLK_IO_DEV_SIGNATURE            EFI_SIGNATURE_32 ('F', 'B', 'I', 'O')\r
-#define FLOPPY_CONTROLLER_CONTEXT_SIGNATURE EFI_SIGNATURE_32 ('F', 'D', 'C', 'C')\r
-\r
-typedef enum {\r
-  FDC_DISK0   = 0,\r
-  FDC_DISK1   = 1,\r
-  FDC_MAX_DISK= 2\r
-} EFI_FDC_DISK;\r
-\r
-typedef struct {\r
-  UINT32          Signature;\r
-  LIST_ENTRY  Link;\r
-  BOOLEAN         FddResetPerformed;\r
-  EFI_STATUS      FddResetStatus;\r
-  BOOLEAN         NeedRecalibrate;\r
-  UINT8           NumberOfDrive;\r
-  UINT16          BaseAddress;\r
-} FLOPPY_CONTROLLER_CONTEXT;\r
-\r
-typedef struct {\r
-  UINTN                                     Signature;\r
-  EFI_HANDLE                                Handle;\r
-  EFI_BLOCK_IO_PROTOCOL                     BlkIo;\r
-  EFI_BLOCK_IO_MEDIA                        BlkMedia;\r
-\r
-  EFI_ISA_IO_PROTOCOL                       *IsaIo;\r
-\r
-  UINT16                                    BaseAddress;\r
-\r
-  EFI_FDC_DISK                              Disk;\r
-  UINT8                                     PresentCylinderNumber;\r
-  UINT8                                     *Cache;\r
-\r
-  EFI_EVENT                                 Event;\r
-  EFI_UNICODE_STRING_TABLE                  *ControllerNameTable;\r
-  FLOPPY_CONTROLLER_CONTEXT                 *ControllerState;\r
-\r
-  EFI_DEVICE_PATH_PROTOCOL                  *DevicePath;\r
-} FDC_BLK_IO_DEV;\r
-\r
-#include "ComponentName.h"\r
-\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
-\r
-#define DISK_1440K_EOT            0x12\r
-#define DISK_1440K_GPL            0x1b\r
-#define DISK_1440K_DTL            0xff\r
-#define DISK_1440K_NUMBER         0x02\r
-#define DISK_1440K_MAXTRACKNUM    0x4f\r
-#define DISK_1440K_BYTEPERSECTOR  512\r
-\r
-typedef struct {\r
-  UINT8 CommandCode;\r
-  UINT8 DiskHeadSel;\r
-  UINT8 Cylinder;\r
-  UINT8 Head;\r
-  UINT8 Sector;\r
-  UINT8 Number;\r
-  UINT8 EndOfTrack;\r
-  UINT8 GapLength;\r
-  UINT8 DataLength;\r
-} FDD_COMMAND_PACKET1;\r
-\r
-typedef struct {\r
-  UINT8 CommandCode;\r
-  UINT8 DiskHeadSel;\r
-} FDD_COMMAND_PACKET2;\r
-\r
-typedef struct {\r
-  UINT8 CommandCode;\r
-  UINT8 SrtHut;\r
-  UINT8 HltNd;\r
-} FDD_SPECIFY_CMD;\r
-\r
-typedef struct {\r
-  UINT8 CommandCode;\r
-  UINT8 DiskHeadSel;\r
-  UINT8 NewCylinder;\r
-} FDD_SEEK_CMD;\r
-\r
-typedef struct {\r
-  UINT8 CommandCode;\r
-  UINT8 DiskHeadSel;\r
-  UINT8 Cylinder;\r
-  UINT8 Head;\r
-  UINT8 Sector;\r
-  UINT8 EndOfTrack;\r
-  UINT8 GapLength;\r
-  UINT8 ScanTestPause;\r
-} FDD_SCAN_CMD;\r
-\r
-typedef struct {\r
-  UINT8 Status0;\r
-  UINT8 Status1;\r
-  UINT8 Status2;\r
-  UINT8 C;\r
-  UINT8 H;\r
-  UINT8 S;\r
-  UINT8 Number;\r
-} FDD_RESULT_PACKET;\r
-\r
-//\r
-// FDC Registers\r
-//\r
-//\r
-// 0x3F2 Digital Output Register\r
-//\r
-#define FDC_REGISTER_DOR  2\r
-\r
-//\r
-// 0x3F4 Main Status Register\r
-//\r
-#define FDC_REGISTER_MSR  4\r
-\r
-//\r
-// 0x3F5 Data Register\r
-//\r
-#define FDC_REGISTER_DTR  5\r
-\r
-//\r
-// 0x3F7 Configuration Control Register(data rate select)\r
-//\r
-#define FDC_REGISTER_CCR  7\r
-\r
-//\r
-// 0x3F7 Digital Input Register(diskchange)\r
-//\r
-#define FDC_REGISTER_DIR  7\r
-\r
-\r
-\r
-//\r
-// FDC Register Bit Definitions\r
-//\r
-//\r
-// Digital Out Register(WO)\r
-//\r
-//\r
-// Select Drive: 0=A 1=B\r
-//\r
-#define SELECT_DRV  BIT0\r
-\r
-//\r
-// Reset FDC\r
-//\r
-#define RESET_FDC BIT2\r
-\r
-//\r
-// Enable Int & DMA\r
-//\r
-#define INT_DMA_ENABLE  BIT3\r
-\r
-//\r
-// Turn On Drive A Motor\r
-//\r
-#define DRVA_MOTOR_ON BIT4\r
-\r
-//\r
-// Turn On Drive B Motor\r
-//\r
-#define DRVB_MOTOR_ON BIT5\r
-\r
-//\r
-// Main Status Register(RO)\r
-//\r
-//\r
-// Drive A Busy\r
-//\r
-#define MSR_DAB BIT0\r
-\r
-//\r
-// Drive B Busy\r
-//\r
-#define MSR_DBB BIT1\r
-\r
-//\r
-// FDC Busy\r
-//\r
-#define MSR_CB  BIT4\r
-\r
-//\r
-// Non-DMA Mode\r
-//\r
-#define MSR_NDM BIT5\r
-\r
-//\r
-// Data Input/Output\r
-//\r
-#define MSR_DIO BIT6\r
-\r
-//\r
-// Request For Master\r
-//\r
-#define MSR_RQM BIT7\r
-\r
-//\r
-// Configuration Control Register(WO)\r
-//\r
-//\r
-// Data Rate select\r
-//\r
-#define CCR_DRC (BIT0 | BIT1)\r
-\r
-//\r
-// Digital Input Register(RO)\r
-//\r
-//\r
-// Disk change line\r
-//\r
-#define DIR_DCL BIT7\r
-//\r
-// #define CCR_DCL         BIT7      // Diskette change\r
-//\r
-// 500K\r
-//\r
-#define DRC_500KBS  0x0\r
-\r
-//\r
-// 300K\r
-//\r
-#define DRC_300KBS  0x01\r
-\r
-//\r
-// 250K\r
-//\r
-#define DRC_250KBS  0x02\r
-\r
-//\r
-// FDC Command Code\r
-//\r
-#define READ_DATA_CMD         0x06\r
-#define WRITE_DATA_CMD        0x05\r
-#define WRITE_DEL_DATA_CMD    0x09\r
-#define READ_DEL_DATA_CMD     0x0C\r
-#define READ_TRACK_CMD        0x02\r
-#define READ_ID_CMD           0x0A\r
-#define FORMAT_TRACK_CMD      0x0D\r
-#define SCAN_EQU_CMD          0x11\r
-#define SCAN_LOW_EQU_CMD      0x19\r
-#define SCAN_HIGH_EQU_CMD     0x1D\r
-#define SEEK_CMD              0x0F\r
-#define RECALIBRATE_CMD       0x07\r
-#define SENSE_INT_STATUS_CMD  0x08\r
-#define SPECIFY_CMD           0x03\r
-#define SENSE_DRV_STATUS_CMD  0x04\r
-\r
-//\r
-// CMD_MT: Multi_Track Selector\r
-// when set , this flag selects the multi-track operating mode.\r
-// In this mode, the FDC treats a complete cylinder under head0 and 1\r
-// as a single track\r
-//\r
-#define CMD_MT  BIT7\r
-\r
-//\r
-// CMD_MFM: MFM/FM Mode Selector\r
-// A one selects the double density(MFM) mode\r
-// A zero selects single density (FM) mode\r
-//\r
-#define CMD_MFM BIT6\r
-\r
-//\r
-// CMD_SK: Skip Flag\r
-// When set to 1, sectors containing a deleted data address mark will\r
-// automatically be skipped during the execution of Read Data.\r
-// When set to 0, the sector is read or written the same as the read and\r
-// write commands.\r
-//\r
-#define CMD_SK  BIT5\r
-\r
-//\r
-// FDC Status Register Bit Definitions\r
-//\r
-//\r
-// Status Register 0\r
-//\r
-//\r
-// Interrupt Code\r
-//\r
-#define STS0_IC (BIT7 | BIT6)\r
-\r
-//\r
-// Seek End: the FDC completed a seek or recalibrate command\r
-//\r
-#define STS0_SE BIT5\r
-\r
-//\r
-// Equipment Check\r
-//\r
-#define STS0_EC BIT4\r
-\r
-//\r
-// Not Ready(unused), this bit is always 0\r
-//\r
-#define STS0_NR BIT3\r
-\r
-//\r
-// Head Address: the current head address\r
-//\r
-#define STS0_HA BIT2\r
-\r
-//\r
-// STS0_US1 & STS0_US0: Drive Select(the current selected drive)\r
-//\r
-//\r
-// Unit Select1\r
-//\r
-#define STS0_US1  BIT1\r
-\r
-//\r
-// Unit Select0\r
-//\r
-#define STS0_US0  BIT0\r
-\r
-//\r
-// Status Register 1\r
-//\r
-//\r
-// End of Cylinder\r
-//\r
-#define STS1_EN BIT7\r
-\r
-//\r
-// BIT6 is unused\r
-//\r
-//\r
-// Data Error: The FDC detected a CRC error in either the ID field or\r
-// data field of a sector\r
-//\r
-#define STS1_DE BIT5\r
-\r
-//\r
-// Overrun/Underrun: Becomes set if FDC does not receive CPU or DMA service\r
-// within the required time interval\r
-//\r
-#define STS1_OR BIT4\r
-\r
-//\r
-// BIT3 is unused\r
-//\r
-//\r
-// No data\r
-//\r
-#define STS1_ND BIT2\r
-\r
-//\r
-// Not Writable\r
-//\r
-#define STS1_NW BIT1\r
-\r
-//\r
-// Missing Address Mark\r
-//\r
-#define STS1_MA BIT0\r
-\r
-//\r
-// Control Mark\r
-//\r
-#define STS2_CM BIT6\r
-\r
-//\r
-// Data Error in Data Field: The FDC detected a CRC error in the data field\r
-//\r
-#define STS2_DD BIT5\r
-\r
-//\r
-// Wrong Cylinder: The track address from sector ID field is different from\r
-// the track address maintained inside FDC\r
-//\r
-#define STS2_WC BIT4\r
-\r
-//\r
-// Bad Cylinder\r
-//\r
-#define STS2_BC BIT1\r
-\r
-//\r
-// Missing Address Mark in Data Field\r
-//\r
-#define STS2_MD BIT0\r
-\r
-//\r
-// Write Protected\r
-//\r
-#define STS3_WP BIT6\r
-\r
-//\r
-// Track 0\r
-//\r
-#define STS3_T0 BIT4\r
-\r
-//\r
-// Head Address\r
-//\r
-#define STS3_HD BIT2\r
-\r
-//\r
-// STS3_US1 & STS3_US0 : Drive Select\r
-//\r
-#define STS3_US1  BIT1\r
-#define STS3_US0  BIT0\r
-\r
-//\r
-// Status Register 0 Interrupt Code Description\r
-//\r
-//\r
-// Normal Termination of Command\r
-//\r
-#define IC_NT 0x0\r
-\r
-//\r
-// Abnormal Termination of Command\r
-//\r
-#define IC_AT 0x40\r
-\r
-//\r
-// Invalid Command\r
-//\r
-#define IC_IC 0x80\r
-\r
-//\r
-// Abnormal Termination caused by Polling\r
-//\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
-EFI_STATUS\r
-EFIAPI\r
-FdcControllerDriverSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  This                - GC_TODO: add argument description\r
-  Controller          - GC_TODO: add argument description\r
-  RemainingDevicePath - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FdcControllerDriverStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  This                - GC_TODO: add argument description\r
-  Controller          - GC_TODO: add argument description\r
-  RemainingDevicePath - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FdcControllerDriverStop (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN UINTN                        NumberOfChildren,\r
-  IN EFI_HANDLE                   *ChildHandleBuffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  This              - GC_TODO: add argument description\r
-  Controller        - GC_TODO: add argument description\r
-  NumberOfChildren  - GC_TODO: add argument description\r
-  ChildHandleBuffer - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-//\r
-// EFI Block I/O Protocol Functions\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-FdcReset (\r
-  IN EFI_BLOCK_IO_PROTOCOL  *This,\r
-  IN BOOLEAN                ExtendedVerification\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  This                  - GC_TODO: add argument description\r
-  ExtendedVerification  - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FddFlushBlocks (\r
-  IN EFI_BLOCK_IO_PROTOCOL  *This\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  This  - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FddReadBlocks (\r
-  IN  EFI_BLOCK_IO_PROTOCOL  *This,\r
-  IN  UINT32                 MediaId,\r
-  IN  EFI_LBA                LBA,\r
-  IN  UINTN                  BufferSize,\r
-  OUT VOID                   *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  This        - GC_TODO: add argument description\r
-  MediaId     - GC_TODO: add argument description\r
-  LBA         - GC_TODO: add argument description\r
-  BufferSize  - GC_TODO: add argument description\r
-  Buffer      - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\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 UINTN                  BufferSize,\r
-  IN VOID                   *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  This        - GC_TODO: add argument description\r
-  MediaId     - GC_TODO: add argument description\r
-  LBA         - GC_TODO: add argument description\r
-  BufferSize  - GC_TODO: add argument description\r
-  Buffer      - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-//\r
-// Prototypes of internal functions\r
-//\r
-EFI_STATUS\r
-DiscoverFddDevice (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-/*++\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
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-FddIdentify (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-/*++\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
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-FddReset (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-/*++\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
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-MotorOn (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-/*++\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
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-MotorOff (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-/*++\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
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-DisketChanged (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-/*++\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
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-Specify (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-/*++\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
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-Recalibrate (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-/*++\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
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-Seek (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN EFI_LBA         Lba\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  FdcDev  - GC_TODO: add argument description\r
-  Lba     - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-SenseIntStatus (\r
-  IN     FDC_BLK_IO_DEV  *FdcDev,\r
-  IN OUT UINT8           *StatusRegister0,\r
-  IN OUT UINT8           *PresentCylinderNumber\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  FdcDev                - GC_TODO: add argument description\r
-  StatusRegister0       - GC_TODO: add argument description\r
-  PresentCylinderNumber - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-SenseDrvStatus (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN EFI_LBA         Lba\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  FdcDev  - GC_TODO: add argument description\r
-  Lba     - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-DetectMedia (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-/*++\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
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-Setup (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-/*++\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
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-ReadWriteDataSector (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN VOID            *HostAddress,\r
-  IN EFI_LBA         Lba,\r
-  IN UINTN           NumberOfBlocks,\r
-  IN BOOLEAN         Read\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  FdcDev          - GC_TODO: add argument description\r
-  HostAddress     - GC_TODO: add argument description\r
-  Lba             - GC_TODO: add argument description\r
-  NumberOfBlocks  - GC_TODO: add argument description\r
-  Read            - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-VOID\r
-FillPara (\r
-  IN FDC_BLK_IO_DEV       *FdcDev,\r
-  IN EFI_LBA              Lba,\r
-  IN FDD_COMMAND_PACKET1  *Command\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  FdcDev  - GC_TODO: add argument description\r
-  Lba     - GC_TODO: add argument description\r
-  Command - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-DataInByte (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN UINT8           *Pointer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  FdcDev  - GC_TODO: add argument description\r
-  Pointer - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-DataOutByte (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN UINT8           *Pointer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  FdcDev  - GC_TODO: add argument description\r
-  Pointer - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-FddWaitForBSYClear (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN UINTN           TimeoutInSeconds\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  FdcDev            - GC_TODO: add argument description\r
-  TimeoutInSeconds  - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-FddDRQReady (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN BOOLEAN         Dio,\r
-  IN UINTN           TimeoutInSeconds\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  FdcDev            - GC_TODO: add argument description\r
-  Dio               - GC_TODO: add argument description\r
-  TimeoutInSeconds  - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-CheckResult (\r
-  IN     FDD_RESULT_PACKET  *Result,\r
-  IN OUT FDC_BLK_IO_DEV     *FdcDev\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  Result  - GC_TODO: add argument description\r
-  FdcDev  - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-CheckStatus3 (\r
-  IN UINT8 StatusRegister3\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  StatusRegister3 - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-UINTN\r
-GetTransferBlockCount (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN EFI_LBA         LBA,\r
-  IN UINTN           NumberOfBlocks\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  FdcDev          - GC_TODO: add argument description\r
-  LBA             - GC_TODO: add argument description\r
-  NumberOfBlocks  - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-VOID\r
-EFIAPI\r
-FddTimerProc (\r
-  IN EFI_EVENT  Event,\r
-  IN VOID       *Context\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  Event   - GC_TODO: add argument description\r
-  Context - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-UINT8\r
-FdcReadPort (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN UINT32          Offset\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  FdcDev  - GC_TODO: add argument description\r
-  Offset  - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-VOID\r
-FdcWritePort (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN UINT32          Offset,\r
-  IN UINT8           Data\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  FdcDev  - GC_TODO: add argument description\r
-  Offset  - GC_TODO: add argument description\r
-  Data    - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\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  UINTN                  BufferSize,\r
-  IN  BOOLEAN                Operation,\r
-  OUT VOID                   *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  This        - GC_TODO: add argument description\r
-  MediaId     - GC_TODO: add argument description\r
-  LBA         - GC_TODO: add argument description\r
-  BufferSize  - GC_TODO: add argument description\r
-  Operation   - GC_TODO: add argument description\r
-  Buffer      - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-VOID\r
-FdcFreeCache (\r
-  IN    FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-/*++\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
-\r
---*/\r
-;\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/Dxe/IsaFloppy.inf b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/Dxe/IsaFloppy.inf
deleted file mode 100644 (file)
index 1351b0e..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-#/** @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
-#  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
-#  All rights reserved. This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution.  The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#\r
-#\r
-#**/\r
-\r
-################################################################################\r
-#\r
-# Defines Section - statements that will be processed to create a Makefile.\r
-#\r
-################################################################################\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = IsaFloppy\r
-  FILE_GUID                      = 0abd8284-6da3-4616-971a-83a5148067ba\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  EDK_RELEASE_VERSION            = 0x00020000\r
-  EFI_SPECIFICATION_VERSION      = 0x00020000\r
-\r
-  ENTRY_POINT                    = InitializeIsaFloppy\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-#  DRIVER_BINDING                =  gFdcControllerDriver                         \r
-#  COMPONENT_NAME                =  gIsaFloppyComponentName                      \r
-#  Create Event Guid C Name:  Event Type: EVENT_TYPE_PERIODIC_TIMER\r
-#\r
-#\r
-\r
-################################################################################\r
-#\r
-# Sources Section - list of files that are required for the build to succeed.\r
-#\r
-################################################################################\r
-\r
-[Sources.common]\r
-  ComponentName.c\r
-  ComponentName.h\r
-  IsaFloppyCtrl.c\r
-  IsaFloppyBlock.c\r
-  IsaFloppy.c\r
-  IsaFloppy.h\r
-\r
-################################################################################\r
-#\r
-# Package Dependency Section - list of Package files that are required for\r
-#                              this module.\r
-#\r
-################################################################################\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-\r
-################################################################################\r
-#\r
-# Library Class Section - list of Library Classes that are required for\r
-#                         this module.\r
-#\r
-################################################################################\r
-\r
-[LibraryClasses]\r
-  ReportStatusCodeLib\r
-  UefiBootServicesTableLib\r
-  MemoryAllocationLib\r
-  BaseMemoryLib\r
-  UefiLib\r
-  BaseLib\r
-  UefiDriverEntryPoint\r
-  DebugLib\r
-  TimerLib\r
-\r
-\r
-################################################################################\r
-#\r
-# Protocol C Name Section - list of Protocol and Protocol Notify C Names\r
-#                           that this module uses or produces.\r
-#\r
-################################################################################\r
-\r
-[Protocols]\r
-  gEfiIsaIoProtocolGuid                         # PROTOCOL TO_START\r
-  gEfiBlockIoProtocolGuid                       # PROTOCOL BY_START\r
-  gEfiDevicePathProtocolGuid                    # PROTOCOL TO_START\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/Dxe/IsaFloppy.msa b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/Dxe/IsaFloppy.msa
deleted file mode 100644 (file)
index dfe6989..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<ModuleSurfaceArea xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0  http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd" xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
-  <MsaHeader>\r
-    <ModuleName>IsaFloppy</ModuleName>\r
-    <ModuleType>DXE_DRIVER</ModuleType>\r
-    <GuidValue>0abd8284-6da3-4616-971a-83a5148067ba</GuidValue>\r
-    <Version>1.0</Version>\r
-    <Abstract>Component description file for IsaFloppy module.</Abstract>\r
-    <Description>ISA Floppy Driver
-        1. Support two types diskette drive
-           1.44M drive and 2.88M drive (and now only support 1.44M)
-        2. Support two diskette drives
-        3. Use DMA channel 2 to transfer data
-        4. Do not use interrupt
-        5. Support diskette change line signal and write protect
-
-        Conforming to EFI driver model</Description>\r
-    <Copyright>Copyright (c) 2006 - 2007, Intel Corporation<BR></Copyright>\r
-    <License>\r
-      All rights reserved. This program and the accompanying materials\r
-      are licensed and made available under the terms and conditions of the BSD License\r
-      which accompanies this distribution.  The full text of the license may be found at\r
-      http://opensource.org/licenses/bsd-license.php\r
-\r
-      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-    </License>\r
-    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
-  </MsaHeader>\r
-  <ModuleDefinitions>\r
-    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
-    <BinaryModule>false</BinaryModule>\r
-    <OutputFileBasename>IsaFloppy</OutputFileBasename>\r
-  </ModuleDefinitions>\r
-  <LibraryClassDefinitions>\r
-    <LibraryClass Usage="ALWAYS_CONSUMED">\r
-      <Keyword>TimerLib</Keyword>\r
-    </LibraryClass>\r
-    <LibraryClass Usage="ALWAYS_CONSUMED">\r
-      <Keyword>DebugLib</Keyword>\r
-    </LibraryClass>\r
-    <LibraryClass Usage="ALWAYS_CONSUMED">\r
-      <Keyword>UefiDriverModelLib</Keyword>\r
-    </LibraryClass>\r
-    <LibraryClass Usage="ALWAYS_CONSUMED">\r
-      <Keyword>UefiDriverEntryPoint</Keyword>\r
-    </LibraryClass>\r
-    <LibraryClass Usage="ALWAYS_CONSUMED">\r
-      <Keyword>BaseLib</Keyword>\r
-    </LibraryClass>\r
-    <LibraryClass Usage="ALWAYS_CONSUMED">\r
-      <Keyword>UefiLib</Keyword>\r
-    </LibraryClass>\r
-    <LibraryClass Usage="ALWAYS_CONSUMED">\r
-      <Keyword>BaseMemoryLib</Keyword>\r
-    </LibraryClass>\r
-    <LibraryClass Usage="ALWAYS_CONSUMED">\r
-      <Keyword>MemoryAllocationLib</Keyword>\r
-    </LibraryClass>\r
-    <LibraryClass Usage="ALWAYS_CONSUMED">\r
-      <Keyword>UefiBootServicesTableLib</Keyword>\r
-    </LibraryClass>\r
-    <LibraryClass Usage="ALWAYS_CONSUMED">\r
-      <Keyword>ReportStatusCodeLib</Keyword>\r
-    </LibraryClass>\r
-  </LibraryClassDefinitions>\r
-  <SourceFiles>\r
-    <Filename>IsaFloppy.h</Filename>\r
-    <Filename>IsaFloppy.c</Filename>\r
-    <Filename>IsaFloppyBlock.c</Filename>\r
-    <Filename>IsaFloppyCtrl.c</Filename>\r
-    <Filename>ComponentName.h</Filename>\r
-    <Filename>ComponentName.c</Filename>\r
-  </SourceFiles>\r
-  <PackageDependencies>\r
-    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
-    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
-  </PackageDependencies>\r
-  <Protocols>\r
-    <Protocol Usage="TO_START">\r
-      <ProtocolCName>gEfiDevicePathProtocolGuid</ProtocolCName>\r
-    </Protocol>\r
-    <Protocol Usage="BY_START">\r
-      <ProtocolCName>gEfiBlockIoProtocolGuid</ProtocolCName>\r
-    </Protocol>\r
-    <Protocol Usage="TO_START">\r
-      <ProtocolCName>gEfiIsaIoProtocolGuid</ProtocolCName>\r
-    </Protocol>\r
-  </Protocols>\r
-  <Events>\r
-    <CreateEvents>\r
-      <EventTypes Usage="ALWAYS_CONSUMED">\r
-        <EventType>EVENT_TYPE_PERIODIC_TIMER</EventType>\r
-        <HelpText>Timer event for each Floppd Disk Controller to control the motor on and off.</HelpText>\r
-      </EventTypes>\r
-    </CreateEvents>\r
-  </Events>\r
-  <Externs>\r
-    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
-    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
-    <Extern>\r
-      <DriverBinding>gFdcControllerDriver</DriverBinding>\r
-      <ComponentName>gIsaFloppyComponentName</ComponentName>\r
-    </Extern>\r
-  </Externs>\r
-</ModuleSurfaceArea>
\ No newline at end of file
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/Dxe/IsaFloppyBlock.c b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/Dxe/IsaFloppyBlock.c
deleted file mode 100644 (file)
index e6282ca..0000000
+++ /dev/null
@@ -1,458 +0,0 @@
-/*++\r
-\r
-  Copyright (c) 2006 - 2007, 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
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-Module Name:\r
-\r
-  IsaFloppyBlock.c\r
-\r
-Abstract:\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
-  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
-  Implement the Block IO interface\r
-\r
-Revision History:\r
-\r
---*/\r
-\r
-#include "IsaFloppy.h"\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FdcReset (\r
-  IN  EFI_BLOCK_IO_PROTOCOL  *This,\r
-  IN  BOOLEAN                ExtendedVerification\r
-  )\r
-/*++\r
-  \r
-  Routine Description:  Reset the Floppy Logic Drive, call the FddReset function   \r
-  Parameters:\r
-    This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface\r
-    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
-  Returns:\r
-    EFI_SUCCESS:      The Floppy Logic Drive is reset\r
-    EFI_DEVICE_ERROR: The Floppy Logic Drive is not functioning correctly \r
-                      and can not be reset\r
-\r
---*/\r
-// GC_TODO: function comment is missing 'Arguments:'\r
-// GC_TODO:    This - add argument and description to function comment\r
-// GC_TODO:    ExtendedVerification - add argument and description to function comment\r
-{\r
-  FDC_BLK_IO_DEV  *FdcDev;\r
-\r
-  //\r
-  // Reset the Floppy Disk Controller\r
-  //\r
-  FdcDev = FDD_BLK_IO_FROM_THIS (This);\r
-\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_P_PC_RESET | EFI_PERIPHERAL_REMOVABLE_MEDIA,\r
-    FdcDev->DevicePath\r
-    );\r
-\r
-  return FddReset (FdcDev);\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FddFlushBlocks (\r
-  IN  EFI_BLOCK_IO_PROTOCOL  *This\r
-  )\r
-/*++\r
-  \r
-  Routine Description:  \r
-  Parameters:\r
-    This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface\r
-  Returns:\r
-    EFI_SUCCESS:    \r
-\r
---*/\r
-// GC_TODO: function comment is missing 'Arguments:'\r
-// GC_TODO:    This - add argument and description to function comment\r
-{\r
-  //\r
-  // Not supported yet\r
-  //\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-STATIC\r
-VOID\r
-FddReportStatus (\r
-  IN  EFI_BLOCK_IO_PROTOCOL  *This,\r
-  IN  BOOLEAN                Read\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  This  - GC_TODO: add argument description\r
-  Read  - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-  FDC_BLK_IO_DEV  *FdcDev;\r
-\r
-  FdcDev = FDD_BLK_IO_FROM_THIS (This);\r
-\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_ERROR_CODE,\r
-    ((Read) ? EFI_P_EC_INPUT_ERROR : EFI_P_EC_OUTPUT_ERROR) | EFI_PERIPHERAL_REMOVABLE_MEDIA,\r
-    FdcDev->DevicePath\r
-    );\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FddReadBlocks (\r
-  IN  EFI_BLOCK_IO_PROTOCOL  *This,\r
-  IN  UINT32                 MediaId,\r
-  IN  EFI_LBA                LBA,\r
-  IN  UINTN                  BufferSize,\r
-  OUT VOID                   *Buffer\r
-  )\r
-/*++\r
-\r
-  Routine Description:  Read the requested number of blocks from the device   \r
-  Parameters:\r
-    This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface\r
-    MediaId UINT32:    The media id that the read request is for    \r
-    LBA EFI_LBA:     The starting logic block address to read from on the device\r
-    BufferSize UINTN:  The size of the Buffer in bytes\r
-    Buffer VOID *:     A pointer to the destination buffer for the data\r
-  Returns:\r
-    EFI_SUCCESS:     The data was read correctly from the device\r
-    EFI_DEVICE_ERROR:The device reported an error while attempting to perform\r
-                     the read operation\r
-    EFI_NO_MEDIA:    There is no media in the device\r
-    EFI_MEDIA_CHANGED:   The MediaId is not for the current media\r
-    EFI_BAD_BUFFER_SIZE: The BufferSize parameter is not a multiple of the \r
-                         intrinsic block size of the device\r
-    EFI_INVALID_PARAMETER:The read request contains LBAs that are not valid, \r
-                          or the buffer is not on proper alignment \r
-\r
---*/\r
-// GC_TODO: function comment is missing 'Arguments:'\r
-// GC_TODO:    This - add argument and description to function comment\r
-// GC_TODO:    MediaId - add argument and description to function comment\r
-// GC_TODO:    LBA - add argument and description to function comment\r
-// GC_TODO:    BufferSize - add argument and description to function comment\r
-// GC_TODO:    Buffer - add argument and description to function comment\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  Status = FddReadWriteBlocks (This, MediaId, LBA, BufferSize, READ, Buffer);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    FddReportStatus (This, TRUE);\r
-  }\r
-\r
-  return Status;\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 UINTN                  BufferSize,\r
-  IN VOID                   *Buffer\r
-  )\r
-/*++\r
-\r
-  Routine Description:  Write a specified number of blocks to the device   \r
-  Parameters:\r
-    This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface\r
-    MediaId UINT32:    The media id that the write request is for   \r
-    LBA EFI_LBA:     The starting logic block address to be written\r
-    BufferSize UINTN:  The size in bytes in Buffer\r
-    Buffer VOID *:     A pointer to the source buffer for the data\r
-  Returns :\r
-    EFI_SUCCESS:     The data were written correctly to the device\r
-    EFI_WRITE_PROTECTED: The device can not be written to \r
-    EFI_NO_MEDIA:    There is no media in the device\r
-    EFI_MEDIA_CHANGED:   The MediaId is not for the current media\r
-    EFI_DEVICE_ERROR:  The device reported an error while attempting to perform \r
-                       the write operation \r
-    EFI_BAD_BUFFER_SIZE: The BufferSize parameter is not a multiple of the \r
-                         intrinsic block size of the device\r
-    EFI_INVALID_PARAMETER:The write request contains LBAs that are not valid, \r
-                          or the buffer is not on proper alignment \r
-\r
---*/\r
-// GC_TODO: function comment is missing 'Arguments:'\r
-// GC_TODO: function comment is missing 'Returns:'\r
-// GC_TODO:    This - add argument and description to function comment\r
-// GC_TODO:    MediaId - add argument and description to function comment\r
-// GC_TODO:    LBA - add argument and description to function comment\r
-// GC_TODO:    BufferSize - add argument and description to function comment\r
-// GC_TODO:    Buffer - add argument and description to function comment\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  Status = FddReadWriteBlocks (This, MediaId, LBA, BufferSize, WRITE, Buffer);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    FddReportStatus (This, FALSE);\r
-  }\r
-\r
-  return Status;\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  UINTN                  BufferSize,\r
-  IN  BOOLEAN                Operation,\r
-  OUT VOID                   *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  This        - GC_TODO: add argument description\r
-  MediaId     - GC_TODO: add argument description\r
-  LBA         - GC_TODO: add argument description\r
-  BufferSize  - GC_TODO: add argument description\r
-  Operation   - GC_TODO: add argument description\r
-  Buffer      - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  EFI_INVALID_PARAMETER - GC_TODO: Add description for return value\r
-  EFI_SUCCESS - GC_TODO: Add description for return value\r
-  EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
-  EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
-  EFI_NO_MEDIA - GC_TODO: Add description for return value\r
-  EFI_MEDIA_CHANGED - GC_TODO: Add description for return value\r
-  EFI_WRITE_PROTECTED - GC_TODO: Add description for return value\r
-  EFI_BAD_BUFFER_SIZE - GC_TODO: Add description for return value\r
-  EFI_INVALID_PARAMETER - GC_TODO: Add description for return value\r
-  EFI_INVALID_PARAMETER - GC_TODO: Add description for return value\r
-  EFI_SUCCESS - GC_TODO: Add description for return value\r
-  EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
-  EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
-  EFI_SUCCESS - GC_TODO: Add description for return value\r
-\r
---*/\r
-{\r
-  EFI_BLOCK_IO_MEDIA  *Media;\r
-  FDC_BLK_IO_DEV      *FdcDev;\r
-  UINTN               BlockSize;\r
-  UINTN               NumberOfBlocks;\r
-  UINTN               BlockCount;\r
-  EFI_STATUS          Status;\r
-  //\r
-  //  EFI_STATUS            CacheStatus;\r
-  //\r
-  EFI_LBA             LBA0;\r
-  UINT8               *Pointer;\r
-\r
-  //\r
-  // Get the intrinsic block size\r
-  //\r
-  Media     = This->Media;\r
-  BlockSize = Media->BlockSize;\r
-  FdcDev    = FDD_BLK_IO_FROM_THIS (This);\r
-\r
-  if (Operation == WRITE) {\r
-    if (LBA == 0) {\r
-      FdcFreeCache (FdcDev);\r
-    }\r
-  }\r
-  //\r
-  // Check the Parameter is valid\r
-  //\r
-  if (Buffer == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (BufferSize == 0) {\r
-    return EFI_SUCCESS;\r
-  }\r
-  //\r
-  // Set the drive motor on\r
-  //\r
-  Status = MotorOn (FdcDev);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Check to see if media can be detected\r
-  //\r
-  Status = DetectMedia (FdcDev);\r
-  if (EFI_ERROR (Status)) {\r
-    MotorOff (FdcDev);\r
-    FdcFreeCache (FdcDev);\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Check to see if media is present\r
-  //\r
-  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
-  // Check to see if media has been changed\r
-  //\r
-  if (MediaId != Media->MediaId) {\r
-    MotorOff (FdcDev);\r
-    FdcFreeCache (FdcDev);\r
-    return EFI_MEDIA_CHANGED;\r
-  }\r
-\r
-  if (Operation == WRITE) {\r
-    if (Media->ReadOnly) {\r
-      MotorOff (FdcDev);\r
-      return EFI_WRITE_PROTECTED;\r
-    }\r
-  }\r
-  //\r
-  // Check the parameters for this read/write operation\r
-  //\r
-  if (BufferSize % BlockSize != 0) {\r
-    MotorOff (FdcDev);\r
-    return EFI_BAD_BUFFER_SIZE;\r
-  }\r
-\r
-  if (LBA > Media->LastBlock) {\r
-    MotorOff (FdcDev);\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (((BufferSize / BlockSize) + LBA - 1) > Media->LastBlock) {\r
-    MotorOff (FdcDev);\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (Operation == READ) {\r
-    //\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
-        MotorOff (FdcDev);\r
-        CopyMem ((UINT8 *) Buffer, (UINT8 *) FdcDev->Cache, BlockSize);\r
-        return EFI_SUCCESS;\r
-      }\r
-    }\r
-  }\r
-  //\r
-  // Set up Floppy Disk Controller\r
-  //\r
-  Status = Setup (FdcDev);\r
-  if (EFI_ERROR (Status)) {\r
-    MotorOff (FdcDev);\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  NumberOfBlocks  = BufferSize / BlockSize;\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
-  while ((BlockCount != 0) && !EFI_ERROR (Status)) {\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
-    NumberOfBlocks -= BlockCount;\r
-    Buffer      = (VOID *) ((UINTN) Buffer + BlockCount * BlockSize);\r
-    BlockCount  = GetTransferBlockCount (FdcDev, LBA, NumberOfBlocks);\r
-  }\r
-\r
-  Buffer = Pointer;\r
-\r
-  //\r
-  // Turn the motor off\r
-  //\r
-  MotorOff (FdcDev);\r
-\r
-  if (Operation == READ) {\r
-    //\r
-    // Cache the data read\r
-    //\r
-    if (LBA0 == 0 && !FdcDev->Cache) {\r
-      FdcDev->Cache = AllocateCopyPool (BlockSize, Buffer);\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-\r
-}\r
-\r
-VOID\r
-FdcFreeCache (\r
-  IN    FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-/*++\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
-\r
---*/\r
-{\r
-  if (FdcDev->Cache) {\r
-    gBS->FreePool (FdcDev->Cache);\r
-    FdcDev->Cache = NULL;\r
-  }\r
-}\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/Dxe/IsaFloppyCtrl.c b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/Dxe/IsaFloppyCtrl.c
deleted file mode 100644 (file)
index 2fd13c3..0000000
+++ /dev/null
@@ -1,1551 +0,0 @@
-/*++\r
-\r
-  Copyright (c) 2006 - 2007, 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
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-Module Name:\r
-\r
-  IsaFloppyCtrl.c\r
-\r
-Abstract:\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
-  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
-\r
-Revision History:\r
-\r
---*/\r
-\r
-#include "IsaFloppy.h"\r
-\r
-EFI_STATUS\r
-DiscoverFddDevice (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-/*++\r
-\r
-  Routine Description:  Detect the floppy drive is presented or not   \r
-  Parameters:\r
-    FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV       \r
-  Returns:\r
-    EFI_SUCCESS    Drive is presented \r
-    EFI_NOT_FOUND  Drive is not presented\r
-\r
---*/\r
-// GC_TODO: function comment is missing 'Arguments:'\r
-// GC_TODO:    FdcDev - add argument and description to function comment\r
-{\r
-  EFI_STATUS  Status;\r
-\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
-  }\r
-\r
-  FdcDev->BlkIo.Reset               = FdcReset;\r
-  FdcDev->BlkIo.FlushBlocks         = FddFlushBlocks;\r
-  FdcDev->BlkIo.ReadBlocks          = FddReadBlocks;\r
-  FdcDev->BlkIo.WriteBlocks         = FddWriteBlocks;\r
-  FdcDev->BlkMedia.LogicalPartition = FALSE;\r
-  FdcDev->BlkMedia.WriteCaching     = FALSE;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-FddIdentify (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-/*++\r
-\r
-  Routine Description:   Do recalibrate  and see the drive is presented or not\r
-         Set the media parameters\r
-  Parameters:\r
-    FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV       \r
-  Returns:\r
-    EFI_SUCCESS:    \r
-    EFI_DEVICE_ERROR: \r
-\r
---*/\r
-// GC_TODO: function comment is missing 'Arguments:'\r
-// GC_TODO:    FdcDev - add argument and description to function comment\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // Set Floppy Disk Controller's motor on\r
-  //\r
-  Status = MotorOn (FdcDev);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  Status = Recalibrate (FdcDev);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    MotorOff (FdcDev);\r
-    FdcDev->ControllerState->NeedRecalibrate = TRUE;\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Set Media Parameter\r
-  //\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
-  // Check Media\r
-  //\r
-  Status = DisketChanged (FdcDev);\r
-  switch (Status) {\r
-  case EFI_NO_MEDIA:\r
-    FdcDev->BlkIo.Media->MediaPresent = FALSE;\r
-    break;\r
-\r
-  case EFI_MEDIA_CHANGED:\r
-  case EFI_SUCCESS:\r
-    break;\r
-\r
-  default:\r
-    MotorOff (FdcDev);\r
-    return Status;\r
-  }\r
-  //\r
-  // Check Disk Write Protected\r
-  //\r
-  Status = SenseDrvStatus (FdcDev, 0);\r
-  switch (Status) {\r
-  case EFI_WRITE_PROTECTED:\r
-    FdcDev->BlkIo.Media->ReadOnly = TRUE;\r
-    break;\r
-\r
-  case EFI_SUCCESS:\r
-    FdcDev->BlkIo.Media->ReadOnly = FALSE;\r
-    break;\r
-\r
-  default:\r
-    return EFI_DEVICE_ERROR;\r
-    break;\r
-  }\r
-\r
-  MotorOff (FdcDev);\r
-\r
-  //\r
-  // Set Media Default Type\r
-  //\r
-  FdcDev->BlkIo.Media->BlockSize  = DISK_1440K_BYTEPERSECTOR;\r
-  FdcDev->BlkIo.Media->LastBlock  = DISK_1440K_EOT * 2 * (DISK_1440K_MAXTRACKNUM + 1) - 1;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-FddReset (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-/*++\r
-\r
-  Routine Description:  Reset the Floppy Logic Drive   \r
-  Parameters:\r
-    FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV       \r
-  Returns:\r
-    EFI_SUCCESS:    The Floppy Logic Drive is reset\r
-    EFI_DEVICE_ERROR: The Floppy Logic Drive is not functioning correctly and \r
-                      can not be reset\r
-\r
---*/\r
-// GC_TODO: function comment is missing 'Arguments:'\r
-// GC_TODO:    FdcDev - add argument and description to function comment\r
-{\r
-  UINT8 data;\r
-  UINT8 StatusRegister0;\r
-  UINT8 PresentCylinderNumber;\r
-  UINTN Index;\r
-\r
-  //\r
-  // Report reset progress code\r
-  //\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_PC_RESET,\r
-    FdcDev->DevicePath\r
-    );\r
-\r
-  //\r
-  // Reset specified Floppy Logic Drive according to FdcDev -> Disk\r
-  // Set Digital Output Register(DOR) to do reset work\r
-  //   bit0 & bit1 of DOR : Drive Select\r
-  //   bit2 : Reset bit\r
-  //   bit3 : DMA and Int bit\r
-  // Reset : a "0" written to bit2 resets the FDC, this reset will remain\r
-  //         active until\r
-  //         a "1" is written to this bit.\r
-  // Reset step 1:\r
-  //         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
-\r
-  //\r
-  // wait some time,at least 120us\r
-  //\r
-  MicroSecondDelay (500);\r
-\r
-  //\r
-  // Reset step 2:\r
-  //   write "1" to bit2\r
-  //   write "1" to bit3 : enable DMA\r
-  //\r
-  data |= 0x0C;\r
-  FdcWritePort (FdcDev, FDC_REGISTER_DOR, data);\r
-\r
-  //\r
-  // Experience value\r
-  //\r
-  MicroSecondDelay (2000);\r
-\r
-  //\r
-  // wait specified floppy logic drive is not busy\r
-  //\r
-  if (EFI_ERROR (FddWaitForBSYClear (FdcDev, 1))) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Set the Transfer Data Rate\r
-  //\r
-  FdcWritePort (FdcDev, FDC_REGISTER_CCR, 0x0);\r
-\r
-  //\r
-  // Experience value\r
-  //\r
-  MicroSecondDelay (100);\r
-\r
-  //\r
-  // Issue Sense interrupt command for each drive (total 4 drives)\r
-  //\r
-  for (Index = 0; Index < 4; Index++) {\r
-    if (EFI_ERROR (SenseIntStatus (FdcDev, &StatusRegister0, &PresentCylinderNumber))) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-  }\r
-  //\r
-  // issue Specify command\r
-  //\r
-  if (EFI_ERROR (Specify (FdcDev))) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-MotorOn (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-/*++\r
-\r
-  Routine Description:  Turn the drive's motor on\r
-        The drive's motor must be on before any command can be executed   \r
-  Parameters:\r
-    FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV       \r
-  Returns:\r
-    EFI_SUCCESS:       Turn the drive's motor on successfully\r
-    EFI_DEVICE_ERROR:    The drive is busy, so can not turn motor on \r
-    EFI_INVALID_PARAMETER: Fail to Set timer(Cancel timer)  \r
-\r
---*/\r
-// GC_TODO: function comment is missing 'Arguments:'\r
-// GC_TODO:    FdcDev - add argument and description to function comment\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8       data;\r
-\r
-  //\r
-  // Control of the floppy drive motors is a big pain. If motor is off, you have\r
-  // to turn it on first. But you can not leave the motor on all the time, since\r
-  // that would wear out the disk. On the other hand, if you turn the motor off\r
-  // after each operation, the system performance will be awful. The compromise\r
-  // used in this driver is to leave the motor on for 2 seconds after\r
-  // each operation. If a new operation is started in that interval(2s),\r
-  // the motor need not be turned on again. If no new operation is started,\r
-  // a timer goes off and the motor is turned off\r
-  //\r
-  //\r
-  // Cancel the timer\r
-  //\r
-  Status = gBS->SetTimer (FdcDev->Event, TimerCancel, 0);\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
-\r
-  if (((FdcDev->Disk == FDC_DISK0) && ((data & 0x10) == 0x10)) ||\r
-      ((FdcDev->Disk == FDC_DISK1) && ((data & 0x21) == 0x21))\r
-      ) {\r
-    return EFI_SUCCESS;\r
-  }\r
-  //\r
-  // The drive's motor is off, so need turn it on\r
-  // first look at command and drive are busy or not\r
-  //\r
-  if (EFI_ERROR (FddWaitForBSYClear (FdcDev, 1))) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\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
-    //\r
-    // drive A\r
-    //\r
-    data |= DRVA_MOTOR_ON;\r
-  } else {\r
-    //\r
-    // drive B\r
-    //\r
-    data |= DRVB_MOTOR_ON;\r
-  }\r
-\r
-  FdcWritePort (FdcDev, FDC_REGISTER_DOR, data);\r
-\r
-  //\r
-  // Experience value\r
-  //\r
-  MicroSecondDelay (4000);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-MotorOff (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-/*++\r
-\r
-  Routine Description:  Set a Timer and when Timer goes off, turn the motor off\r
-  Parameters:\r
-    FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV       \r
-  Returns:\r
-    EFI_SUCCESS:       Set the Timer successfully\r
-    EFI_INVALID_PARAMETER: Fail to Set the timer  \r
-\r
---*/\r
-// GC_TODO: function comment is missing 'Arguments:'\r
-// GC_TODO:    FdcDev - add argument and description to function comment\r
-{\r
-  //\r
-  // Set the timer : 2s\r
-  //\r
-  return gBS->SetTimer (FdcDev->Event, TimerRelative, 20000000);\r
-}\r
-\r
-EFI_STATUS\r
-DisketChanged (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-/*++\r
-\r
-  Routine Description:  Detect the disk in the drive is changed or not\r
-  Parameters:\r
-    FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV   \r
-  Returns:\r
-    EFI_SUCCESS:    No disk media change\r
-    EFI_DEVICE_ERROR: Fail to do the recalibrate or seek operation\r
-    EFI_NO_MEDIA:   No disk in the drive\r
-    EFI_MEDIA_CHANGED:  There is a new disk in the drive\r
-\r
---*/\r
-// GC_TODO: function comment is missing 'Arguments:'\r
-// GC_TODO:    FdcDev - add argument and description to function comment\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8       data;\r
-\r
-  //\r
-  // Check change line\r
-  //\r
-  data = FdcReadPort (FdcDev, FDC_REGISTER_DIR);\r
-\r
-  //\r
-  // Io delay\r
-  //\r
-  MicroSecondDelay (50);\r
-\r
-  if ((data & DIR_DCL) == 0x80) {\r
-    //\r
-    // disk change line is active\r
-    //\r
-    if (FdcDev->PresentCylinderNumber != 0) {\r
-      Status = Recalibrate (FdcDev);\r
-    } else {\r
-      Status = Seek (FdcDev, 0x30);\r
-    }\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      FdcDev->ControllerState->NeedRecalibrate = TRUE;\r
-      return EFI_DEVICE_ERROR;\r
-      //\r
-      // Fail to do the seek or recalibrate operation\r
-      //\r
-    }\r
-\r
-    data = FdcReadPort (FdcDev, FDC_REGISTER_DIR);\r
-\r
-    //\r
-    // Io delay\r
-    //\r
-    MicroSecondDelay (50);\r
-\r
-    if ((data & DIR_DCL) == 0x80) {\r
-      return EFI_NO_MEDIA;\r
-    }\r
-\r
-    return EFI_MEDIA_CHANGED;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-Specify (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-/*++\r
-\r
-  Routine Description:  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
-  Parameters:\r
-    None\r
-  Returns:\r
-    EFI_SUCCESS:    Execute the Specify command successfully\r
-    EFI_DEVICE_ERROR: Fail to execute the command\r
-\r
---*/\r
-// GC_TODO: function comment is missing 'Arguments:'\r
-// GC_TODO:    FdcDev - add argument and description to function comment\r
-{\r
-  FDD_SPECIFY_CMD Command;\r
-  UINTN           Index;\r
-  UINT8           *CommandPointer;\r
-\r
-  ZeroMem (&Command, sizeof (FDD_SPECIFY_CMD));\r
-  Command.CommandCode = SPECIFY_CMD;\r
-  //\r
-  // set SRT, HUT\r
-  //\r
-  Command.SrtHut = 0xdf;\r
-  //\r
-  // 0xdf;\r
-  //\r
-  // set HLT and DMA\r
-  //\r
-  Command.HltNd   = 0x02;\r
-\r
-  CommandPointer  = (UINT8 *) (&Command);\r
-  for (Index = 0; Index < sizeof (FDD_SPECIFY_CMD); Index++) {\r
-    if (EFI_ERROR (DataOutByte (FdcDev, CommandPointer++))) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-Recalibrate (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-/*++\r
-\r
-  Routine Description:  Set the head of floppy drive to track 0\r
-  Parameters:\r
-    FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
-  Returns:\r
-    EFI_SUCCESS:    Execute the Recalibrate operation successfully\r
-    EFI_DEVICE_ERROR: Fail to execute the Recalibrate operation\r
-\r
---*/\r
-// GC_TODO: function comment is missing 'Arguments:'\r
-// GC_TODO:    FdcDev - add argument and description to function comment\r
-{\r
-  FDD_COMMAND_PACKET2 Command;\r
-  UINTN               Index;\r
-  UINT8               StatusRegister0;\r
-  UINT8               PresentCylinderNumber;\r
-  UINT8               *CommandPointer;\r
-  UINT8               Count;\r
-\r
-  Count = 2;\r
-\r
-  while (Count > 0) {\r
-    ZeroMem (&Command, sizeof (FDD_COMMAND_PACKET2));\r
-    Command.CommandCode = RECALIBRATE_CMD;\r
-    //\r
-    // drive select\r
-    //\r
-    if (FdcDev->Disk == FDC_DISK0) {\r
-      Command.DiskHeadSel = 0;\r
-      //\r
-      // 0\r
-      //\r
-    } else {\r
-      Command.DiskHeadSel = 1;\r
-      //\r
-      // 1\r
-      //\r
-    }\r
-\r
-    CommandPointer = (UINT8 *) (&Command);\r
-    for (Index = 0; Index < sizeof (FDD_COMMAND_PACKET2); Index++) {\r
-      if (EFI_ERROR (DataOutByte (FdcDev, CommandPointer++))) {\r
-        return EFI_DEVICE_ERROR;\r
-      }\r
-    }\r
-    //\r
-    // Experience value\r
-    //\r
-    MicroSecondDelay (250000);\r
-    //\r
-    // need modify according to 1.44M or 2.88M\r
-    //\r
-    if (EFI_ERROR (SenseIntStatus (FdcDev, &StatusRegister0, &PresentCylinderNumber))) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-\r
-    if ((StatusRegister0 & 0xf0) == 0x20 && PresentCylinderNumber == 0) {\r
-      FdcDev->PresentCylinderNumber             = 0;\r
-      FdcDev->ControllerState->NeedRecalibrate  = FALSE;\r
-      return EFI_SUCCESS;\r
-    } else {\r
-      Count--;\r
-      if (Count == 0) {\r
-        return EFI_DEVICE_ERROR;\r
-      }\r
-    }\r
-  }\r
-  //\r
-  // end while\r
-  //\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-Seek (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN EFI_LBA         Lba\r
-  )\r
-/*++\r
-\r
-  Routine Description:  Set the head of floppy drive to the new cylinder\r
-  Parameters:\r
-    FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
-    Lba EFI_LBA     : The logic block address want to seek\r
-  Returns:\r
-    EFI_SUCCESS:    Execute the Seek operation successfully\r
-    EFI_DEVICE_ERROR: Fail to execute the Seek operation\r
-\r
---*/\r
-// GC_TODO: function comment is missing 'Arguments:'\r
-// GC_TODO:    FdcDev - add argument and description to function comment\r
-// GC_TODO:    Lba - add argument and description to function comment\r
-{\r
-  FDD_SEEK_CMD  Command;\r
-  UINT8         EndOfTrack;\r
-  UINT8         Head;\r
-  UINT8         Cylinder;\r
-  UINT8         StatusRegister0;\r
-  UINT8         *CommandPointer;\r
-  UINT8         PresentCylinderNumber;\r
-  UINTN         Index;\r
-  UINT8         DelayTime;\r
-\r
-  if (FdcDev->ControllerState->NeedRecalibrate) {\r
-    if (EFI_ERROR (Recalibrate (FdcDev))) {\r
-      FdcDev->ControllerState->NeedRecalibrate = TRUE;\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-  }\r
-\r
-  EndOfTrack = DISK_1440K_EOT;\r
-  //\r
-  // Calculate cylinder based on Lba and EOT\r
-  //\r
-  Cylinder = (UINT8) ((UINTN) Lba / EndOfTrack / 2);\r
-\r
-  //\r
-  // if the destination cylinder is the present cylinder, unnecessary to do the\r
-  // seek operation\r
-  //\r
-  if (FdcDev->PresentCylinderNumber == Cylinder) {\r
-    return EFI_SUCCESS;\r
-  }\r
-  //\r
-  // Calculate the head : 0 or 1\r
-  //\r
-  Head = (UINT8) ((UINTN) Lba / EndOfTrack % 2);\r
-\r
-  ZeroMem (&Command, sizeof (FDD_SEEK_CMD));\r
-  Command.CommandCode = SEEK_CMD;\r
-  if (FdcDev->Disk == FDC_DISK0) {\r
-    Command.DiskHeadSel = 0;\r
-    //\r
-    // 0\r
-    //\r
-  } else {\r
-    Command.DiskHeadSel = 1;\r
-    //\r
-    // 1\r
-    //\r
-  }\r
-\r
-  Command.DiskHeadSel = (UINT8) (Command.DiskHeadSel | (Head << 2));\r
-  Command.NewCylinder = Cylinder;\r
-\r
-  CommandPointer      = (UINT8 *) (&Command);\r
-  for (Index = 0; Index < sizeof (FDD_SEEK_CMD); Index++) {\r
-    if (EFI_ERROR (DataOutByte (FdcDev, CommandPointer++))) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-  }\r
-  //\r
-  // Io delay\r
-  //\r
-  MicroSecondDelay (100);\r
-\r
-  //\r
-  // Calculate waiting time\r
-  //\r
-  if (FdcDev->PresentCylinderNumber > Cylinder) {\r
-    DelayTime = (UINT8) (FdcDev->PresentCylinderNumber - Cylinder);\r
-  } else {\r
-    DelayTime = (UINT8) (Cylinder - FdcDev->PresentCylinderNumber);\r
-  }\r
-\r
-  MicroSecondDelay ((DelayTime + 1) * 4000);\r
-\r
-  if (EFI_ERROR (SenseIntStatus (FdcDev, &StatusRegister0, &PresentCylinderNumber))) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  if ((StatusRegister0 & 0xf0) == 0x20) {\r
-    FdcDev->PresentCylinderNumber = Command.NewCylinder;\r
-    return EFI_SUCCESS;\r
-  } else {\r
-    FdcDev->ControllerState->NeedRecalibrate = TRUE;\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-}\r
-\r
-EFI_STATUS\r
-SenseIntStatus (\r
-  IN     FDC_BLK_IO_DEV  *FdcDev,\r
-  IN OUT UINT8           *StatusRegister0,\r
-  IN OUT UINT8           *PresentCylinderNumber\r
-  )\r
-/*++\r
-\r
-  Routine Description:  Do the Sense Interrupt Status command, this command \r
-                        resets the interrupt signal\r
-  Parameters:\r
-    StatusRegister0 UINT8 *: Be used to save Status Register 0 read from FDC   \r
-    PresentCylinderNumber  UINT8 *: Be used to save present cylinder number \r
-                                    read from FDC\r
-  Returns:\r
-    EFI_SUCCESS:    Execute the Sense Interrupt Status command successfully\r
-    EFI_DEVICE_ERROR: Fail to execute the command\r
-\r
---*/\r
-// GC_TODO: function comment is missing 'Arguments:'\r
-// GC_TODO:    FdcDev - add argument and description to function comment\r
-// GC_TODO:    StatusRegister0 - add argument and description to function comment\r
-// GC_TODO:    PresentCylinderNumber - add argument and description to function comment\r
-{\r
-  UINT8 command;\r
-\r
-  command = SENSE_INT_STATUS_CMD;\r
-  if (EFI_ERROR (DataOutByte (FdcDev, &command))) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  if (EFI_ERROR (DataInByte (FdcDev, StatusRegister0))) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  if (EFI_ERROR (DataInByte (FdcDev, PresentCylinderNumber))) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-SenseDrvStatus (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN EFI_LBA         Lba\r
-  )\r
-/*++\r
-\r
-  Routine Description:  Do the Sense Drive Status command\r
-  Parameters:\r
-    FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV   \r
-    Lba EFI_LBA     : Logic block address\r
-  Returns:\r
-    EFI_SUCCESS:    Execute the Sense Drive Status command successfully\r
-    EFI_DEVICE_ERROR: Fail to execute the command\r
-    EFI_WRITE_PROTECTED:The disk is write protected \r
-\r
---*/\r
-// GC_TODO: function comment is missing 'Arguments:'\r
-// GC_TODO:    FdcDev - add argument and description to function comment\r
-// GC_TODO:    Lba - add argument and description to function comment\r
-{\r
-  FDD_COMMAND_PACKET2 Command;\r
-  UINT8               Head;\r
-  UINT8               EndOfTrack;\r
-  UINTN               Index;\r
-  UINT8               StatusRegister3;\r
-  UINT8               *CommandPointer;\r
-\r
-  //\r
-  // Sense Drive Status command obtains drive status information,\r
-  // it has not execution phase and goes directly to the result phase from the\r
-  // command phase, Status Register 3 contains the drive status information\r
-  //\r
-  ZeroMem (&Command, sizeof (FDD_COMMAND_PACKET2));\r
-  Command.CommandCode = SENSE_DRV_STATUS_CMD;\r
-\r
-  if (FdcDev->Disk == FDC_DISK0) {\r
-    Command.DiskHeadSel = 0;\r
-  } else {\r
-    Command.DiskHeadSel = 1;\r
-  }\r
-\r
-  EndOfTrack  = DISK_1440K_EOT;\r
-  Head        = (UINT8) ((UINTN) Lba / EndOfTrack % 2);\r
-  Command.DiskHeadSel = (UINT8) (Command.DiskHeadSel | (Head << 2));\r
-\r
-  CommandPointer = (UINT8 *) (&Command);\r
-  for (Index = 0; Index < sizeof (FDD_COMMAND_PACKET2); Index++) {\r
-    if (EFI_ERROR (DataOutByte (FdcDev, CommandPointer++))) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-  }\r
-\r
-  if (EFI_ERROR (DataInByte (FdcDev, &StatusRegister3))) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Io delay\r
-  //\r
-  MicroSecondDelay (50);\r
-\r
-  //\r
-  // Check Status Register 3 to get drive status information\r
-  //\r
-  return CheckStatus3 (StatusRegister3);\r
-}\r
-\r
-EFI_STATUS\r
-DetectMedia (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-/*++\r
-\r
-  Routine Description:  Update the disk media properties and if necessary \r
-                        reinstall Block I/O interface\r
-  Parameters:\r
-    FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV   \r
-  Returns:\r
-    EFI_SUCCESS:    Do the operation successfully\r
-    EFI_DEVICE_ERROR: Fail to the operation\r
-\r
---*/\r
-// GC_TODO: function comment is missing 'Arguments:'\r
-// GC_TODO:    FdcDev - add argument and description to function comment\r
-{\r
-  EFI_STATUS  Status;\r
-  BOOLEAN     bReset;\r
-  BOOLEAN     bReadOnlyLastTime;\r
-  BOOLEAN     bMediaPresentLastTime;\r
-\r
-  bReset                = FALSE;\r
-  bReadOnlyLastTime     = FdcDev->BlkIo.Media->ReadOnly;\r
-  bMediaPresentLastTime = FdcDev->BlkIo.Media->MediaPresent;\r
-\r
-  //\r
-  // Check disk change\r
-  //\r
-  Status = DisketChanged (FdcDev);\r
-  switch (Status) {\r
-  case EFI_MEDIA_CHANGED:\r
-    FdcDev->BlkIo.Media->MediaId++;\r
-    FdcDev->BlkIo.Media->MediaPresent = TRUE;\r
-    bReset = TRUE;\r
-    break;\r
-\r
-  case EFI_NO_MEDIA:\r
-    FdcDev->BlkIo.Media->MediaPresent = FALSE;\r
-    break;\r
-\r
-  case EFI_SUCCESS:\r
-    break;\r
-\r
-  default:\r
-    MotorOff (FdcDev);\r
-    return Status;\r
-    //\r
-    // EFI_DEVICE_ERROR\r
-    //\r
-  }\r
-\r
-  if (FdcDev->BlkIo.Media->MediaPresent) {\r
-    //\r
-    // Check disk write protected\r
-    //\r
-    Status = SenseDrvStatus (FdcDev, 0);\r
-    if (Status == EFI_WRITE_PROTECTED) {\r
-      FdcDev->BlkIo.Media->ReadOnly = TRUE;\r
-    } else {\r
-      FdcDev->BlkIo.Media->ReadOnly = FALSE;\r
-    }\r
-  }\r
-\r
-  if (FdcDev->BlkIo.Media->MediaPresent && (bReadOnlyLastTime != FdcDev->BlkIo.Media->ReadOnly)) {\r
-    bReset = TRUE;\r
-  }\r
-\r
-  if (bMediaPresentLastTime != FdcDev->BlkIo.Media->MediaPresent) {\r
-    bReset = TRUE;\r
-  }\r
-\r
-  if (bReset) {\r
-    Status = gBS->ReinstallProtocolInterface (\r
-                    FdcDev->Handle,\r
-                    &gEfiBlockIoProtocolGuid,\r
-                    &FdcDev->BlkIo,\r
-                    &FdcDev->BlkIo\r
-                    );\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-Setup (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-/*++\r
-\r
-  Routine Description: Set the data rate and so on\r
-  Parameters:\r
-    None  \r
-  Returns:\r
-    EFI_SUCCESS:  \r
-\r
---*/\r
-// GC_TODO: function comment is missing 'Arguments:'\r
-// GC_TODO:    FdcDev - add argument and description to function comment\r
-// GC_TODO:    EFI_DEVICE_ERROR - add return value to function comment\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // Set data rate 500kbs\r
-  //\r
-  FdcWritePort (FdcDev, FDC_REGISTER_CCR, 0x0);\r
-\r
-  //\r
-  // Io delay\r
-  //\r
-  MicroSecondDelay (50);\r
-\r
-  Status = Specify (FdcDev);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-ReadWriteDataSector (\r
-  IN  FDC_BLK_IO_DEV  *FdcDev,\r
-  IN  VOID            *HostAddress,\r
-  IN  EFI_LBA         Lba,\r
-  IN  UINTN           NumberOfBlocks,\r
-  IN  BOOLEAN         Read\r
-  )\r
-/*++\r
-\r
-  Routine Description: Read or Write a number of blocks in the same cylinder\r
-  Parameters:\r
-    FdcDev FDC_BLK_IO_DEV * : A pointer to Data Structure FDC_BLK_IO_DEV\r
-    Buffer VOID *:\r
-    Lba EFI_LBA:\r
-    NumberOfBlocks UINTN:\r
-    Read BOOLEAN:     \r
-  Returns:\r
-    EFI_SUCCESS:  \r
-\r
---*/\r
-// GC_TODO: function comment is missing 'Arguments:'\r
-// GC_TODO:    FdcDev - add argument and description to function comment\r
-// GC_TODO:    HostAddress - add argument and description to function comment\r
-// GC_TODO:    Lba - add argument and description to function comment\r
-// GC_TODO:    NumberOfBlocks - add argument and description to function comment\r
-// GC_TODO:    Read - add argument and description to function comment\r
-// GC_TODO:    EFI_DEVICE_ERROR - add return value to function comment\r
-// GC_TODO:    EFI_DEVICE_ERROR - add return value to function comment\r
-// GC_TODO:    EFI_DEVICE_ERROR - add return value to function comment\r
-// GC_TODO:    EFI_TIMEOUT - add return value to function comment\r
-// GC_TODO:    EFI_DEVICE_ERROR - add return value to function comment\r
-{\r
-  EFI_STATUS                                    Status;\r
-  FDD_COMMAND_PACKET1                           Command;\r
-  FDD_RESULT_PACKET                             Result;\r
-  UINTN                                         Index;\r
-  UINTN                                         Times;\r
-  UINT8                                         *CommandPointer;\r
-\r
-  EFI_PHYSICAL_ADDRESS                          DeviceAddress;\r
-  EFI_ISA_IO_PROTOCOL                           *IsaIo;\r
-  UINTN                                         NumberofBytes;\r
-  VOID                                          *Mapping;\r
-  EFI_ISA_IO_PROTOCOL_OPERATION                 Operation;\r
-  EFI_STATUS                                    Status1;\r
-  UINT8                                         Channel;\r
-  EFI_ISA_ACPI_RESOURCE                         *ResourceItem;\r
-  UINT32                                        Attribute;\r
-\r
-  Status = Seek (FdcDev, Lba);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Map Dma\r
-  //\r
-  IsaIo         = FdcDev->IsaIo;\r
-  NumberofBytes = NumberOfBlocks * 512;\r
-  if (Read == READ) {\r
-    Operation = EfiIsaIoOperationSlaveWrite;\r
-  } else {\r
-    Operation = EfiIsaIoOperationSlaveRead;\r
-  }\r
-\r
-  ResourceItem  = IsaIo->ResourceList->ResourceItem;\r
-  Index         = 0;\r
-  while (ResourceItem[Index].Type != EfiIsaAcpiResourceEndOfList) {\r
-    if (ResourceItem[Index].Type == EfiIsaAcpiResourceDma) {\r
-      break;\r
-    }\r
-\r
-    Index++;\r
-  }\r
-\r
-  if (ResourceItem[Index].Type == EfiIsaAcpiResourceEndOfList) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  Channel   = (UINT8) IsaIo->ResourceList->ResourceItem[Index].StartRange;\r
-  Attribute = IsaIo->ResourceList->ResourceItem[Index].Attribute;\r
-\r
-  Status1 = IsaIo->Map (\r
-                    IsaIo,\r
-                    Operation,\r
-                    Channel,\r
-                    Attribute,\r
-                    HostAddress,\r
-                    &NumberofBytes,\r
-                    &DeviceAddress,\r
-                    &Mapping\r
-                    );\r
-  if (EFI_ERROR (Status1)) {\r
-    return Status1;\r
-  }\r
-\r
-  //\r
-  // Allocate Read or Write command packet\r
-  //\r
-  ZeroMem (&Command, sizeof (FDD_COMMAND_PACKET1));\r
-  if (Read == READ) {\r
-    Command.CommandCode = READ_DATA_CMD | CMD_MT | CMD_MFM | CMD_SK;\r
-  } else {\r
-    Command.CommandCode = WRITE_DATA_CMD | CMD_MT | CMD_MFM;\r
-  }\r
-\r
-  FillPara (FdcDev, Lba, &Command);\r
-\r
-  //\r
-  // Write command bytes to FDC\r
-  //\r
-  CommandPointer = (UINT8 *) (&Command);\r
-  for (Index = 0; Index < sizeof (FDD_COMMAND_PACKET1); Index++) {\r
-    if (EFI_ERROR (DataOutByte (FdcDev, CommandPointer++))) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-  }\r
-  //\r
-  // wait for some time\r
-  //\r
-  Times = (STALL_1_SECOND / 50) + 1;\r
-  do {\r
-    if ((FdcReadPort (FdcDev, FDC_REGISTER_MSR) & 0xc0) == 0xc0) {\r
-      break;\r
-    }\r
-\r
-    MicroSecondDelay (50);\r
-    Times = Times - 1;\r
-  } while (Times);\r
-\r
-  if (Times == 0) {\r
-    return EFI_TIMEOUT;\r
-  }\r
-  //\r
-  // Read result bytes from FDC\r
-  //\r
-  CommandPointer = (UINT8 *) (&Result);\r
-  for (Index = 0; Index < sizeof (FDD_RESULT_PACKET); Index++) {\r
-    if (EFI_ERROR (DataInByte (FdcDev, CommandPointer++))) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-  }\r
-  //\r
-  // Flush before Unmap\r
-  //\r
-  if (Read == READ) {\r
-    Status1 = IsaIo->Flush (IsaIo);\r
-    if (EFI_ERROR (Status1)) {\r
-      return Status1;\r
-    }\r
-  }\r
-  //\r
-  // Unmap Dma\r
-  //\r
-  Status1 = IsaIo->Unmap (IsaIo, Mapping);\r
-  if (EFI_ERROR (Status1)) {\r
-    return Status1;\r
-  }\r
-\r
-  return CheckResult (&Result, FdcDev);\r
-}\r
-\r
-VOID\r
-FillPara (\r
-  IN  FDC_BLK_IO_DEV       *FdcDev,\r
-  IN  EFI_LBA              Lba,\r
-  IN  FDD_COMMAND_PACKET1  *Command\r
-  )\r
-/*++\r
-\r
-  Routine Description: Fill in Parameter\r
-  Parameters:\r
-  Returns:\r
-    \r
---*/\r
-// GC_TODO: function comment is missing 'Arguments:'\r
-// GC_TODO:    FdcDev - add argument and description to function comment\r
-// GC_TODO:    Lba - add argument and description to function comment\r
-// GC_TODO:    Command - add argument and description to function comment\r
-{\r
-  UINT8 EndOfTrack;\r
-\r
-  //\r
-  // Get EndOfTrack from the Para table\r
-  //\r
-  EndOfTrack = DISK_1440K_EOT;\r
-\r
-  //\r
-  // Fill the command parameter\r
-  //\r
-  if (FdcDev->Disk == FDC_DISK0) {\r
-    Command->DiskHeadSel = 0;\r
-  } else {\r
-    Command->DiskHeadSel = 1;\r
-  }\r
-\r
-  Command->Cylinder = (UINT8) ((UINTN) Lba / EndOfTrack / 2);\r
-  Command->Head     = (UINT8) ((UINTN) Lba / EndOfTrack % 2);\r
-  Command->Sector   = (UINT8) ((UINT8) ((UINTN) Lba % EndOfTrack) + 1);\r
-  Command->DiskHeadSel = (UINT8) (Command->DiskHeadSel | (Command->Head << 2));\r
-  Command->Number     = DISK_1440K_NUMBER;\r
-  Command->EndOfTrack = DISK_1440K_EOT;\r
-  Command->GapLength  = DISK_1440K_GPL;\r
-  Command->DataLength = DISK_1440K_DTL;\r
-}\r
-\r
-EFI_STATUS\r
-DataInByte (\r
-  IN     FDC_BLK_IO_DEV  *FdcDev,\r
-  IN OUT UINT8           *Pointer\r
-  )\r
-/*++\r
-\r
-  Routine Description:  Read result byte from Data Register of FDC\r
-  Parameters:\r
-    Pointer UINT8 *: Be used to save result byte read from FDC   \r
-  Returns:\r
-    EFI_SUCCESS:    Read result byte from FDC successfully\r
-    EFI_DEVICE_ERROR: The FDC is not ready to be read\r
-\r
---*/\r
-// GC_TODO: function comment is missing 'Arguments:'\r
-// GC_TODO:    FdcDev - add argument and description to function comment\r
-// GC_TODO:    Pointer - add argument and description to function comment\r
-{\r
-  UINT8 data;\r
-\r
-  //\r
-  // wait for 1ms and detect the FDC is ready to be read\r
-  //\r
-  if (EFI_ERROR (FddDRQReady (FdcDev, DATA_IN, 1))) {\r
-    return EFI_DEVICE_ERROR;\r
-    //\r
-    // is not ready\r
-    //\r
-  }\r
-\r
-  data = FdcReadPort (FdcDev, FDC_REGISTER_DTR);\r
-\r
-  //\r
-  // Io delay\r
-  //\r
-  MicroSecondDelay (50);\r
-\r
-  *Pointer = data;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-DataOutByte (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN UINT8           *Pointer\r
-  )\r
-/*++\r
-\r
-  Routine Description:  Write command byte to Data Register of FDC\r
-  Parameters:\r
-    Pointer UINT8 *: Be used to save command byte written to FDC   \r
-  Returns:\r
-    EFI_SUCCESS:    Write command byte to FDC successfully\r
-    EFI_DEVICE_ERROR: The FDC is not ready to be written\r
-\r
---*/\r
-// GC_TODO: function comment is missing 'Arguments:'\r
-// GC_TODO:    FdcDev - add argument and description to function comment\r
-// GC_TODO:    Pointer - add argument and description to function comment\r
-{\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
-    //\r
-  }\r
-\r
-  data = *Pointer;\r
-\r
-  FdcWritePort (FdcDev, FDC_REGISTER_DTR, data);\r
-\r
-  //\r
-  // Io delay\r
-  //\r
-  MicroSecondDelay (50);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-FddWaitForBSYClear (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN UINTN           TimeoutInSeconds\r
-  )\r
-/*++\r
-\r
-  Routine Description:  Detect the specified floppy logic drive is busy or \r
-                        not within a period of time\r
-  Parameters:\r
-    Disk EFI_FDC_DISK:    Indicate it is drive A or drive B\r
-    TimeoutInSeconds UINTN: the time period for waiting   \r
-  Returns:\r
-    EFI_SUCCESS:  The drive and command are not busy\r
-    EFI_TIMEOUT:  The drive or command is still busy after a period time that \r
-                  set by TimeoutInSeconds\r
-\r
---*/\r
-// GC_TODO: function comment is missing 'Arguments:'\r
-// GC_TODO:    FdcDev - add argument and description to function comment\r
-// GC_TODO:    TimeoutInSeconds - add argument and description to function comment\r
-{\r
-  UINTN Delay;\r
-  UINT8 StatusRegister;\r
-  UINT8 Mask;\r
-\r
-  //\r
-  // How to determine drive and command are busy or not: by the bits of\r
-  // Main Status Register\r
-  // bit0: Drive 0 busy (drive A)\r
-  // bit1: Drive 1 busy (drive B)\r
-  // bit4: Command busy\r
-  //\r
-  //\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
-\r
-  Delay = ((TimeoutInSeconds * STALL_1_MSECOND) / 50) + 1;\r
-  do {\r
-    StatusRegister = FdcReadPort (FdcDev, FDC_REGISTER_MSR);\r
-    if ((StatusRegister & Mask) == 0x00) {\r
-      break;\r
-      //\r
-      // not busy\r
-      //\r
-    }\r
-\r
-    MicroSecondDelay (50);\r
-    Delay = Delay - 1;\r
-  } while (Delay);\r
-\r
-  if (Delay == 0) {\r
-    return EFI_TIMEOUT;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-FddDRQReady (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN BOOLEAN         Dio,\r
-  IN  UINTN          TimeoutInSeconds\r
-  )\r
-/*++\r
-\r
-  Routine Description:  Determine whether FDC is ready to write or read\r
-  Parameters:\r
-    Dio BOOLEAN:      Indicate the FDC is waiting to write or read\r
-    TimeoutInSeconds UINTN: The time period for waiting   \r
-  Returns:\r
-    EFI_SUCCESS:  FDC is ready to write or read\r
-    EFI_NOT_READY:  FDC is not ready within the specified time period\r
-\r
---*/\r
-// GC_TODO: function comment is missing 'Arguments:'\r
-// GC_TODO:    FdcDev - add argument and description to function comment\r
-// GC_TODO:    Dio - add argument and description to function comment\r
-// GC_TODO:    TimeoutInSeconds - add argument and description to function comment\r
-{\r
-  UINTN Delay;\r
-  UINT8 StatusRegister;\r
-  UINT8 DataInOut;\r
-\r
-  //\r
-  // Before writing to FDC or reading from FDC, the Host must examine\r
-  // the bit7(RQM) and bit6(DIO) of the Main Status Register.\r
-  // That is to say:\r
-  //  command bytes can not be written to Data Register\r
-  //  unless RQM is 1 and DIO is 0\r
-  //  result bytes can not be read from Data Register\r
-  //  unless RQM is 1 and DIO is 1\r
-  //\r
-  DataInOut = (UINT8) (Dio << 6);\r
-  //\r
-  // in order to compare bit6\r
-  //\r
-  Delay = ((TimeoutInSeconds * STALL_1_MSECOND) / 50) + 1;\r
-  do {\r
-    StatusRegister = FdcReadPort (FdcDev, FDC_REGISTER_MSR);\r
-    if ((StatusRegister & MSR_RQM) == MSR_RQM && (StatusRegister & MSR_DIO) == DataInOut) {\r
-      break;\r
-      //\r
-      // FDC is ready\r
-      //\r
-    }\r
-\r
-    MicroSecondDelay (50);\r
-    //\r
-    // Stall for 50 us\r
-    //\r
-    Delay = Delay - 1;\r
-  } while (Delay);\r
-\r
-  if (Delay == 0) {\r
-    return EFI_NOT_READY;\r
-    //\r
-    // FDC is not ready within the specified time period\r
-    //\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-CheckResult (\r
-  IN     FDD_RESULT_PACKET  *Result,\r
-  IN OUT FDC_BLK_IO_DEV     *FdcDev\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  Result  - GC_TODO: add argument description\r
-  FdcDev  - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
-  EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
-  EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
-  EFI_SUCCESS - GC_TODO: Add description for return value\r
-\r
---*/\r
-{\r
-  //\r
-  // Check Status Register0\r
-  //\r
-  if ((Result->Status0 & STS0_IC) != IC_NT) {\r
-    if ((Result->Status0 & STS0_SE) == 0x20) {\r
-      //\r
-      // seek error\r
-      //\r
-      FdcDev->ControllerState->NeedRecalibrate = TRUE;\r
-    }\r
-\r
-    FdcDev->ControllerState->NeedRecalibrate = TRUE;\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Check Status Register1\r
-  //\r
-  if (Result->Status1 & (STS1_EN | STS1_DE | STS1_OR | STS1_ND | STS1_NW | STS1_MA)) {\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
-    FdcDev->ControllerState->NeedRecalibrate = TRUE;\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-CheckStatus3 (\r
-  IN UINT8 StatusRegister3\r
-  )\r
-/*++\r
-\r
-  Routine Description:  Check the drive status information\r
-  Parameters:\r
-    StatusRegister3 UINT8: the value of Status Register 3    \r
-  Returns:\r
-    EFI_SUCCESS:     \r
-    EFI_WRITE_PROTECTED:  The disk is write protected\r
-\r
---*/\r
-// GC_TODO: function comment is missing 'Arguments:'\r
-// GC_TODO:    StatusRegister3 - add argument and description to function comment\r
-{\r
-  if (StatusRegister3 & STS3_WP) {\r
-    return EFI_WRITE_PROTECTED;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-UINTN\r
-GetTransferBlockCount (\r
-  IN  FDC_BLK_IO_DEV  *FdcDev,\r
-  IN  EFI_LBA         LBA,\r
-  IN  UINTN           NumberOfBlocks\r
-  )\r
-/*++\r
-\r
-  Routine Description:  Calculate the number of block in the same cylinder \r
-                        according to LBA\r
-  Parameters:\r
-    FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
-    LBA EFI_LBA:      The starting logic block address            \r
-    NumberOfBlocks UINTN: The number of blocks\r
-  Returns:\r
-    UINTN : The number of blocks in the same cylinder which the starting \r
-        logic block address is LBA\r
-\r
---*/\r
-// GC_TODO: function comment is missing 'Arguments:'\r
-// GC_TODO:    FdcDev - add argument and description to function comment\r
-// GC_TODO:    LBA - add argument and description to function comment\r
-// GC_TODO:    NumberOfBlocks - add argument and description to function comment\r
-{\r
-  UINT8 EndOfTrack;\r
-  UINT8 Head;\r
-  UINT8 SectorsInTrack;\r
-\r
-  //\r
-  // Calculate the number of block in the same cylinder\r
-  //\r
-  EndOfTrack      = DISK_1440K_EOT;\r
-  Head            = (UINT8) ((UINTN) LBA / EndOfTrack % 2);\r
-\r
-  SectorsInTrack  = (UINT8) (EndOfTrack * (2 - Head) - (UINT8) ((UINTN) LBA % EndOfTrack));\r
-  if (SectorsInTrack < NumberOfBlocks) {\r
-    return SectorsInTrack;\r
-  } else {\r
-    return NumberOfBlocks;\r
-  }\r
-}\r
-\r
-VOID\r
-EFIAPI\r
-FddTimerProc (\r
-  IN EFI_EVENT  Event,\r
-  IN VOID       *Context\r
-  )\r
-/*++\r
-\r
-  Routine Description:  When the Timer(2s) off, turn the drive's motor off\r
-  Parameters:\r
-    Event EFI_EVENT: Event(the timer) whose notification function is being \r
-                     invoked\r
-    Context VOID *:  Pointer to the notification function's context \r
-  Returns:\r
-    VOID\r
-\r
---*/\r
-// GC_TODO: function comment is missing 'Arguments:'\r
-// GC_TODO:    Event - add argument and description to function comment\r
-// GC_TODO:    Context - add argument and description to function comment\r
-{\r
-  FDC_BLK_IO_DEV  *FdcDev;\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
-\r
-  if (((FdcDev->Disk == FDC_DISK0) && ((data & 0x10) != 0x10)) ||\r
-      ((FdcDev->Disk == FDC_DISK1) && ((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
-  MicroSecondDelay (500);\r
-}\r
-\r
-UINT8\r
-FdcReadPort (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN UINT32          Offset\r
-  )\r
-/*++\r
-\r
-  Routine Description: Read I/O port for FDC  \r
-  Parameters:\r
-  Returns:\r
-    \r
---*/\r
-// GC_TODO: function comment is missing 'Arguments:'\r
-// GC_TODO:    FdcDev - add argument and description to function comment\r
-// GC_TODO:    Offset - add argument and description to function comment\r
-{\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
-\r
-  return Data;\r
-}\r
-\r
-VOID\r
-FdcWritePort (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN UINT32          Offset,\r
-  IN UINT8           Data\r
-  )\r
-/*++\r
-\r
-  Routine Description: Write I/O port for FDC  \r
-  Parameters:\r
-  Returns:\r
-    \r
---*/\r
-// GC_TODO: function comment is missing 'Arguments:'\r
-// GC_TODO:    FdcDev - add argument and description to function comment\r
-// GC_TODO:    Offset - add argument and description to function comment\r
-// GC_TODO:    Data - add argument and description to function comment\r
-{\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
-}\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppy.c b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppy.c
new file mode 100644 (file)
index 0000000..6bdccc2
--- /dev/null
@@ -0,0 +1,490 @@
+/*++\r
+\r
+  Copyright (c) 2006 - 2007, 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
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  IsaFloppy.c\r
+\r
+Abstract:\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
+  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
+Revision History:\r
+\r
+--*/\r
+\r
+#include "IsaFloppy.h"\r
+\r
+LIST_ENTRY              gControllerHead = INITIALIZE_LIST_HEAD_VARIABLE(gControllerHead);\r
+\r
+//\r
+// ISA Floppy Driver Binding Protocol\r
+//\r
+EFI_DRIVER_BINDING_PROTOCOL gFdcControllerDriver = {\r
+  FdcControllerDriverSupported,\r
+  FdcControllerDriverStart,\r
+  FdcControllerDriverStop,\r
+  0xa,\r
+  NULL,\r
+  NULL\r
+};\r
+\r
+\r
+/**\r
+  The user Entry Point for module IsaFloppy. The user code starts with this function.\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
+  \r
+  @retval EFI_SUCCESS       The entry point is executed successfully.\r
+  @retval other             Some error occurs when executing this entry point.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeIsaFloppy(\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+\r
+  //\r
+  // Install driver model protocol(s).\r
+  //\r
+  Status = EfiLibInstallAllDriverProtocols (\r
+             ImageHandle,\r
+             SystemTable,\r
+             &gFdcControllerDriver,\r
+             ImageHandle,\r
+             &gIsaFloppyComponentName,\r
+             NULL,\r
+             NULL\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FdcControllerDriverSupported (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN EFI_HANDLE                   Controller,\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  ControllerDriver Protocol Method\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+--*/\r
+// GC_TODO:    This - add argument and description to function comment\r
+// GC_TODO:    Controller - add argument and description to function comment\r
+// GC_TODO:    RemainingDevicePath - add argument and description to function comment\r
+{\r
+  EFI_STATUS                          Status;\r
+  EFI_ISA_IO_PROTOCOL                 *IsaIo;\r
+\r
+  //\r
+  // Open the ISA I/O Protocol\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  Controller,\r
+                  &gEfiIsaIoProtocolGuid,\r
+                  (VOID **) &IsaIo,\r
+                  This->DriverBindingHandle,\r
+                  Controller,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  //\r
+  // Use the ISA I/O Protocol to see if Controller is a Floppy Disk Controller\r
+  //\r
+  Status = EFI_SUCCESS;\r
+  if (IsaIo->ResourceList->Device.HID != EISA_PNP_ID (0x604)) {\r
+    Status = EFI_UNSUPPORTED;\r
+  }\r
+  //\r
+  // Close the ISA I/O Protocol\r
+  //\r
+  gBS->CloseProtocol (\r
+         Controller,\r
+         &gEfiIsaIoProtocolGuid,\r
+         This->DriverBindingHandle,\r
+         Controller\r
+         );\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FdcControllerDriverStart (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN EFI_HANDLE                   Controller,\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+--*/\r
+// GC_TODO:    This - add argument and description to function comment\r
+// GC_TODO:    Controller - add argument and description to function comment\r
+// GC_TODO:    RemainingDevicePath - add argument and description to function comment\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
+\r
+  FdcDev  = NULL;\r
+  IsaIo   = NULL;\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
+  // Report enable progress code\r
+  //\r
+  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+    EFI_PROGRESS_CODE,\r
+    EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_PC_ENABLE,\r
+    ParentDevicePath\r
+    );\r
+\r
+  //\r
+  // Open the ISA I/O Protocol\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  Controller,\r
+                  &gEfiIsaIoProtocolGuid,\r
+                  (VOID **) &IsaIo,\r
+                  This->DriverBindingHandle,\r
+                  Controller,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+  //\r
+  // Allocate the Floppy Disk Controller'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
+  //\r
+  FdcDev->Signature       = FDC_BLK_IO_DEV_SIGNATURE;\r
+  FdcDev->Handle          = Controller;\r
+  FdcDev->IsaIo           = IsaIo;\r
+  FdcDev->Disk            = (EFI_FDC_DISK) IsaIo->ResourceList->Device.UID;\r
+  FdcDev->Cache           = NULL;\r
+  FdcDev->Event           = NULL;\r
+  FdcDev->ControllerState = NULL;\r
+  FdcDev->DevicePath      = ParentDevicePath;\r
+\r
+  ADD_FLOPPY_NAME (FdcDev);\r
+  \r
+  //\r
+  // Look up the base address of the Floppy Disk Controller\r
+  //\r
+  for (Index = 0; FdcDev->IsaIo->ResourceList->ResourceItem[Index].Type != EfiIsaAcpiResourceEndOfList; Index++) {\r
+    if (FdcDev->IsaIo->ResourceList->ResourceItem[Index].Type == EfiIsaAcpiResourceIo) {\r
+      FdcDev->BaseAddress = (UINT16) FdcDev->IsaIo->ResourceList->ResourceItem[Index].StartRange;\r
+    }\r
+  }\r
+  //\r
+  // Maintain the list of controller list\r
+  //\r
+  Found = FALSE;\r
+  List  = gControllerHead.ForwardLink;\r
+  while (List != &gControllerHead) {\r
+    FdcDev->ControllerState = FLOPPY_CONTROLLER_FROM_LIST_ENTRY (List);\r
+    if (FdcDev->BaseAddress == FdcDev->ControllerState->BaseAddress) {\r
+      Found = TRUE;\r
+      break;\r
+    }\r
+\r
+    List = List->ForwardLink;\r
+  }\r
+\r
+  if (!Found) {\r
+    //\r
+    // The Controller is new\r
+    //\r
+    FdcDev->ControllerState = AllocatePool (sizeof (FLOPPY_CONTROLLER_CONTEXT));\r
+    if (FdcDev->ControllerState == NULL) {\r
+      goto Done;\r
+    }\r
+\r
+    FdcDev->ControllerState->Signature          = FLOPPY_CONTROLLER_CONTEXT_SIGNATURE;\r
+    FdcDev->ControllerState->FddResetPerformed  = FALSE;\r
+    FdcDev->ControllerState->NeedRecalibrate    = FALSE;\r
+    FdcDev->ControllerState->BaseAddress        = FdcDev->BaseAddress;\r
+    FdcDev->ControllerState->NumberOfDrive      = 0;\r
+\r
+    InsertTailList (&gControllerHead, &FdcDev->ControllerState->Link);\r
+  }\r
+  //\r
+  // Create a timer event for each Floppd Disk Controller.\r
+  // This timer event is used to control the motor on and off\r
+  //\r
+  Status = gBS->CreateEvent (\r
+                  EVT_TIMER | EVT_NOTIFY_SIGNAL,\r
+                  TPL_NOTIFY,\r
+                  FddTimerProc,\r
+                  FdcDev,\r
+                  &FdcDev->Event\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+  //\r
+  // Reset the Floppy Disk Controller\r
+  //\r
+  if (!FdcDev->ControllerState->FddResetPerformed) {\r
+    FdcDev->ControllerState->FddResetPerformed  = TRUE;\r
+    FdcDev->ControllerState->FddResetStatus     = FddReset (FdcDev);\r
+  }\r
+\r
+  if (EFI_ERROR (FdcDev->ControllerState->FddResetStatus)) {\r
+    Status = EFI_DEVICE_ERROR;\r
+    goto Done;\r
+  }\r
+\r
+  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+    EFI_PROGRESS_CODE,\r
+    EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_PC_PRESENCE_DETECT,\r
+    ParentDevicePath\r
+    );\r
+\r
+  //\r
+  // Discover the Floppy Drive\r
+  //\r
+  Status = DiscoverFddDevice (FdcDev);\r
+  if (EFI_ERROR (Status)) {\r
+    Status = EFI_DEVICE_ERROR;\r
+    goto Done;\r
+  }\r
+  //\r
+  // Install protocol interfaces for the serial device.\r
+  //\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &Controller,\r
+                  &gEfiBlockIoProtocolGuid,\r
+                  &FdcDev->BlkIo,\r
+                  NULL\r
+                  );\r
+\r
+  FdcDev->ControllerState->NumberOfDrive++;\r
+\r
+Done:\r
+  if (EFI_ERROR (Status)) {\r
+\r
+    REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
+      EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_EC_CONTROLLER_ERROR,\r
+      ParentDevicePath\r
+      );\r
+\r
+    //\r
+    // Close the device path protocol\r
+    //\r
+    gBS->CloseProtocol (\r
+           Controller,\r
+           &gEfiDevicePathProtocolGuid,\r
+           This->DriverBindingHandle,\r
+           Controller\r
+           );\r
+\r
+    //\r
+    // Close the ISA I/O Protocol\r
+    //\r
+    if (IsaIo != NULL) {\r
+      gBS->CloseProtocol (\r
+             Controller,\r
+             &gEfiIsaIoProtocolGuid,\r
+             This->DriverBindingHandle,\r
+             Controller\r
+             );\r
+    }\r
+    //\r
+    // If a Floppy Disk Controller Device structure was allocated, then free it\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
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FdcControllerDriverStop (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   Controller,\r
+  IN  UINTN                        NumberOfChildren,\r
+  IN  EFI_HANDLE                   *ChildHandleBuffer\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+  Arguments:\r
+\r
+  Returns:\r
+\r
+--*/\r
+// GC_TODO:    This - add argument and description to function comment\r
+// GC_TODO:    Controller - add argument and description to function comment\r
+// GC_TODO:    NumberOfChildren - add argument and description to function comment\r
+// GC_TODO:    ChildHandleBuffer - add argument and description to function comment\r
+// GC_TODO:    EFI_SUCCESS - add return value to function comment\r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_BLOCK_IO_PROTOCOL *BlkIo;\r
+  FDC_BLK_IO_DEV        *FdcDev;\r
+\r
+  //\r
+  // Get the Block I/O Protocol on Controller\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  Controller,\r
+                  &gEfiBlockIoProtocolGuid,\r
+                  (VOID **) &BlkIo,\r
+                  This->DriverBindingHandle,\r
+                  Controller,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  //\r
+  // Get the Floppy Disk Controller's Device structure\r
+  //\r
+  FdcDev = FDD_BLK_IO_FROM_THIS (BlkIo);\r
+\r
+  //\r
+  // Report disable progress code\r
+  //\r
+  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+    EFI_PROGRESS_CODE,\r
+    EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_PC_DISABLE,\r
+    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
+  Status = gBS->UninstallProtocolInterface (\r
+                  Controller,\r
+                  &gEfiBlockIoProtocolGuid,\r
+                  &FdcDev->BlkIo\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  //\r
+  // Close the device path protocol\r
+  //\r
+  gBS->CloseProtocol (\r
+         Controller,\r
+         &gEfiDevicePathProtocolGuid,\r
+         This->DriverBindingHandle,\r
+         Controller\r
+         );\r
+\r
+  //\r
+  // Close the ISA I/O Protocol\r
+  //\r
+  gBS->CloseProtocol (\r
+         Controller,\r
+         &gEfiIsaIoProtocolGuid,\r
+         This->DriverBindingHandle,\r
+         Controller\r
+         );\r
+\r
+  //\r
+  // Free the controller list if needed\r
+  //\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
+  //\r
+  FreeUnicodeStringTable (FdcDev->ControllerNameTable);\r
+  gBS->FreePool (FdcDev);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppy.h b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppy.h
new file mode 100644 (file)
index 0000000..f60b146
--- /dev/null
@@ -0,0 +1,1321 @@
+/*++\r
+\r
+  Copyright (c) 2006 - 2007, 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
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  IsaFloppy.h\r
+\r
+Abstract:\r
+\r
+  Include for ISA Floppy Driver\r
+  Define the data structure and so on\r
+\r
+Revision History:\r
+\r
+--*/\r
+\r
+#ifndef _ISA_FLOPPY_H\r
+#define _ISA_FLOPPY_H\r
+\r
+#include <PiDxe.h>\r
+#include <FrameworkPei.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Protocol/BlockIo.h>\r
+#include <Protocol/IsaIo.h>\r
+#include <Protocol/DevicePath.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/TimerLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/ReportStatusCodeLib.h>\r
+//\r
+// Driver Binding Externs\r
+//\r
+extern EFI_DRIVER_BINDING_PROTOCOL gFdcControllerDriver;\r
+extern EFI_COMPONENT_NAME_PROTOCOL gIsaFloppyComponentName;\r
+\r
+//\r
+// define some value\r
+//\r
+#define STALL_1_SECOND  1000000\r
+#define STALL_1_MSECOND 1000\r
+\r
+#define DATA_IN         1\r
+#define DATA_OUT        0\r
+#define READ            0\r
+#define WRITE           1\r
+\r
+//\r
+// Internal Data Structures\r
+//\r
+#define FDC_BLK_IO_DEV_SIGNATURE            EFI_SIGNATURE_32 ('F', 'B', 'I', 'O')\r
+#define FLOPPY_CONTROLLER_CONTEXT_SIGNATURE EFI_SIGNATURE_32 ('F', 'D', 'C', 'C')\r
+\r
+typedef enum {\r
+  FDC_DISK0   = 0,\r
+  FDC_DISK1   = 1,\r
+  FDC_MAX_DISK= 2\r
+} EFI_FDC_DISK;\r
+\r
+typedef struct {\r
+  UINT32          Signature;\r
+  LIST_ENTRY  Link;\r
+  BOOLEAN         FddResetPerformed;\r
+  EFI_STATUS      FddResetStatus;\r
+  BOOLEAN         NeedRecalibrate;\r
+  UINT8           NumberOfDrive;\r
+  UINT16          BaseAddress;\r
+} FLOPPY_CONTROLLER_CONTEXT;\r
+\r
+typedef struct {\r
+  UINTN                                     Signature;\r
+  EFI_HANDLE                                Handle;\r
+  EFI_BLOCK_IO_PROTOCOL                     BlkIo;\r
+  EFI_BLOCK_IO_MEDIA                        BlkMedia;\r
+\r
+  EFI_ISA_IO_PROTOCOL                       *IsaIo;\r
+\r
+  UINT16                                    BaseAddress;\r
+\r
+  EFI_FDC_DISK                              Disk;\r
+  UINT8                                     PresentCylinderNumber;\r
+  UINT8                                     *Cache;\r
+\r
+  EFI_EVENT                                 Event;\r
+  EFI_UNICODE_STRING_TABLE                  *ControllerNameTable;\r
+  FLOPPY_CONTROLLER_CONTEXT                 *ControllerState;\r
+\r
+  EFI_DEVICE_PATH_PROTOCOL                  *DevicePath;\r
+} FDC_BLK_IO_DEV;\r
+\r
+#include "ComponentName.h"\r
+\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
+\r
+#define DISK_1440K_EOT            0x12\r
+#define DISK_1440K_GPL            0x1b\r
+#define DISK_1440K_DTL            0xff\r
+#define DISK_1440K_NUMBER         0x02\r
+#define DISK_1440K_MAXTRACKNUM    0x4f\r
+#define DISK_1440K_BYTEPERSECTOR  512\r
+\r
+typedef struct {\r
+  UINT8 CommandCode;\r
+  UINT8 DiskHeadSel;\r
+  UINT8 Cylinder;\r
+  UINT8 Head;\r
+  UINT8 Sector;\r
+  UINT8 Number;\r
+  UINT8 EndOfTrack;\r
+  UINT8 GapLength;\r
+  UINT8 DataLength;\r
+} FDD_COMMAND_PACKET1;\r
+\r
+typedef struct {\r
+  UINT8 CommandCode;\r
+  UINT8 DiskHeadSel;\r
+} FDD_COMMAND_PACKET2;\r
+\r
+typedef struct {\r
+  UINT8 CommandCode;\r
+  UINT8 SrtHut;\r
+  UINT8 HltNd;\r
+} FDD_SPECIFY_CMD;\r
+\r
+typedef struct {\r
+  UINT8 CommandCode;\r
+  UINT8 DiskHeadSel;\r
+  UINT8 NewCylinder;\r
+} FDD_SEEK_CMD;\r
+\r
+typedef struct {\r
+  UINT8 CommandCode;\r
+  UINT8 DiskHeadSel;\r
+  UINT8 Cylinder;\r
+  UINT8 Head;\r
+  UINT8 Sector;\r
+  UINT8 EndOfTrack;\r
+  UINT8 GapLength;\r
+  UINT8 ScanTestPause;\r
+} FDD_SCAN_CMD;\r
+\r
+typedef struct {\r
+  UINT8 Status0;\r
+  UINT8 Status1;\r
+  UINT8 Status2;\r
+  UINT8 C;\r
+  UINT8 H;\r
+  UINT8 S;\r
+  UINT8 Number;\r
+} FDD_RESULT_PACKET;\r
+\r
+//\r
+// FDC Registers\r
+//\r
+//\r
+// 0x3F2 Digital Output Register\r
+//\r
+#define FDC_REGISTER_DOR  2\r
+\r
+//\r
+// 0x3F4 Main Status Register\r
+//\r
+#define FDC_REGISTER_MSR  4\r
+\r
+//\r
+// 0x3F5 Data Register\r
+//\r
+#define FDC_REGISTER_DTR  5\r
+\r
+//\r
+// 0x3F7 Configuration Control Register(data rate select)\r
+//\r
+#define FDC_REGISTER_CCR  7\r
+\r
+//\r
+// 0x3F7 Digital Input Register(diskchange)\r
+//\r
+#define FDC_REGISTER_DIR  7\r
+\r
+\r
+\r
+//\r
+// FDC Register Bit Definitions\r
+//\r
+//\r
+// Digital Out Register(WO)\r
+//\r
+//\r
+// Select Drive: 0=A 1=B\r
+//\r
+#define SELECT_DRV  BIT0\r
+\r
+//\r
+// Reset FDC\r
+//\r
+#define RESET_FDC BIT2\r
+\r
+//\r
+// Enable Int & DMA\r
+//\r
+#define INT_DMA_ENABLE  BIT3\r
+\r
+//\r
+// Turn On Drive A Motor\r
+//\r
+#define DRVA_MOTOR_ON BIT4\r
+\r
+//\r
+// Turn On Drive B Motor\r
+//\r
+#define DRVB_MOTOR_ON BIT5\r
+\r
+//\r
+// Main Status Register(RO)\r
+//\r
+//\r
+// Drive A Busy\r
+//\r
+#define MSR_DAB BIT0\r
+\r
+//\r
+// Drive B Busy\r
+//\r
+#define MSR_DBB BIT1\r
+\r
+//\r
+// FDC Busy\r
+//\r
+#define MSR_CB  BIT4\r
+\r
+//\r
+// Non-DMA Mode\r
+//\r
+#define MSR_NDM BIT5\r
+\r
+//\r
+// Data Input/Output\r
+//\r
+#define MSR_DIO BIT6\r
+\r
+//\r
+// Request For Master\r
+//\r
+#define MSR_RQM BIT7\r
+\r
+//\r
+// Configuration Control Register(WO)\r
+//\r
+//\r
+// Data Rate select\r
+//\r
+#define CCR_DRC (BIT0 | BIT1)\r
+\r
+//\r
+// Digital Input Register(RO)\r
+//\r
+//\r
+// Disk change line\r
+//\r
+#define DIR_DCL BIT7\r
+//\r
+// #define CCR_DCL         BIT7      // Diskette change\r
+//\r
+// 500K\r
+//\r
+#define DRC_500KBS  0x0\r
+\r
+//\r
+// 300K\r
+//\r
+#define DRC_300KBS  0x01\r
+\r
+//\r
+// 250K\r
+//\r
+#define DRC_250KBS  0x02\r
+\r
+//\r
+// FDC Command Code\r
+//\r
+#define READ_DATA_CMD         0x06\r
+#define WRITE_DATA_CMD        0x05\r
+#define WRITE_DEL_DATA_CMD    0x09\r
+#define READ_DEL_DATA_CMD     0x0C\r
+#define READ_TRACK_CMD        0x02\r
+#define READ_ID_CMD           0x0A\r
+#define FORMAT_TRACK_CMD      0x0D\r
+#define SCAN_EQU_CMD          0x11\r
+#define SCAN_LOW_EQU_CMD      0x19\r
+#define SCAN_HIGH_EQU_CMD     0x1D\r
+#define SEEK_CMD              0x0F\r
+#define RECALIBRATE_CMD       0x07\r
+#define SENSE_INT_STATUS_CMD  0x08\r
+#define SPECIFY_CMD           0x03\r
+#define SENSE_DRV_STATUS_CMD  0x04\r
+\r
+//\r
+// CMD_MT: Multi_Track Selector\r
+// when set , this flag selects the multi-track operating mode.\r
+// In this mode, the FDC treats a complete cylinder under head0 and 1\r
+// as a single track\r
+//\r
+#define CMD_MT  BIT7\r
+\r
+//\r
+// CMD_MFM: MFM/FM Mode Selector\r
+// A one selects the double density(MFM) mode\r
+// A zero selects single density (FM) mode\r
+//\r
+#define CMD_MFM BIT6\r
+\r
+//\r
+// CMD_SK: Skip Flag\r
+// When set to 1, sectors containing a deleted data address mark will\r
+// automatically be skipped during the execution of Read Data.\r
+// When set to 0, the sector is read or written the same as the read and\r
+// write commands.\r
+//\r
+#define CMD_SK  BIT5\r
+\r
+//\r
+// FDC Status Register Bit Definitions\r
+//\r
+//\r
+// Status Register 0\r
+//\r
+//\r
+// Interrupt Code\r
+//\r
+#define STS0_IC (BIT7 | BIT6)\r
+\r
+//\r
+// Seek End: the FDC completed a seek or recalibrate command\r
+//\r
+#define STS0_SE BIT5\r
+\r
+//\r
+// Equipment Check\r
+//\r
+#define STS0_EC BIT4\r
+\r
+//\r
+// Not Ready(unused), this bit is always 0\r
+//\r
+#define STS0_NR BIT3\r
+\r
+//\r
+// Head Address: the current head address\r
+//\r
+#define STS0_HA BIT2\r
+\r
+//\r
+// STS0_US1 & STS0_US0: Drive Select(the current selected drive)\r
+//\r
+//\r
+// Unit Select1\r
+//\r
+#define STS0_US1  BIT1\r
+\r
+//\r
+// Unit Select0\r
+//\r
+#define STS0_US0  BIT0\r
+\r
+//\r
+// Status Register 1\r
+//\r
+//\r
+// End of Cylinder\r
+//\r
+#define STS1_EN BIT7\r
+\r
+//\r
+// BIT6 is unused\r
+//\r
+//\r
+// Data Error: The FDC detected a CRC error in either the ID field or\r
+// data field of a sector\r
+//\r
+#define STS1_DE BIT5\r
+\r
+//\r
+// Overrun/Underrun: Becomes set if FDC does not receive CPU or DMA service\r
+// within the required time interval\r
+//\r
+#define STS1_OR BIT4\r
+\r
+//\r
+// BIT3 is unused\r
+//\r
+//\r
+// No data\r
+//\r
+#define STS1_ND BIT2\r
+\r
+//\r
+// Not Writable\r
+//\r
+#define STS1_NW BIT1\r
+\r
+//\r
+// Missing Address Mark\r
+//\r
+#define STS1_MA BIT0\r
+\r
+//\r
+// Control Mark\r
+//\r
+#define STS2_CM BIT6\r
+\r
+//\r
+// Data Error in Data Field: The FDC detected a CRC error in the data field\r
+//\r
+#define STS2_DD BIT5\r
+\r
+//\r
+// Wrong Cylinder: The track address from sector ID field is different from\r
+// the track address maintained inside FDC\r
+//\r
+#define STS2_WC BIT4\r
+\r
+//\r
+// Bad Cylinder\r
+//\r
+#define STS2_BC BIT1\r
+\r
+//\r
+// Missing Address Mark in Data Field\r
+//\r
+#define STS2_MD BIT0\r
+\r
+//\r
+// Write Protected\r
+//\r
+#define STS3_WP BIT6\r
+\r
+//\r
+// Track 0\r
+//\r
+#define STS3_T0 BIT4\r
+\r
+//\r
+// Head Address\r
+//\r
+#define STS3_HD BIT2\r
+\r
+//\r
+// STS3_US1 & STS3_US0 : Drive Select\r
+//\r
+#define STS3_US1  BIT1\r
+#define STS3_US0  BIT0\r
+\r
+//\r
+// Status Register 0 Interrupt Code Description\r
+//\r
+//\r
+// Normal Termination of Command\r
+//\r
+#define IC_NT 0x0\r
+\r
+//\r
+// Abnormal Termination of Command\r
+//\r
+#define IC_AT 0x40\r
+\r
+//\r
+// Invalid Command\r
+//\r
+#define IC_IC 0x80\r
+\r
+//\r
+// Abnormal Termination caused by Polling\r
+//\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
+EFI_STATUS\r
+EFIAPI\r
+FdcControllerDriverSupported (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN EFI_HANDLE                   Controller,\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This                - GC_TODO: add argument description\r
+  Controller          - GC_TODO: add argument description\r
+  RemainingDevicePath - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FdcControllerDriverStart (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN EFI_HANDLE                   Controller,\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This                - GC_TODO: add argument description\r
+  Controller          - GC_TODO: add argument description\r
+  RemainingDevicePath - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FdcControllerDriverStop (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN EFI_HANDLE                   Controller,\r
+  IN UINTN                        NumberOfChildren,\r
+  IN EFI_HANDLE                   *ChildHandleBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This              - GC_TODO: add argument description\r
+  Controller        - GC_TODO: add argument description\r
+  NumberOfChildren  - GC_TODO: add argument description\r
+  ChildHandleBuffer - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// EFI Block I/O Protocol Functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+FdcReset (\r
+  IN EFI_BLOCK_IO_PROTOCOL  *This,\r
+  IN BOOLEAN                ExtendedVerification\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This                  - GC_TODO: add argument description\r
+  ExtendedVerification  - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FddFlushBlocks (\r
+  IN EFI_BLOCK_IO_PROTOCOL  *This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This  - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FddReadBlocks (\r
+  IN  EFI_BLOCK_IO_PROTOCOL  *This,\r
+  IN  UINT32                 MediaId,\r
+  IN  EFI_LBA                LBA,\r
+  IN  UINTN                  BufferSize,\r
+  OUT VOID                   *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This        - GC_TODO: add argument description\r
+  MediaId     - GC_TODO: add argument description\r
+  LBA         - GC_TODO: add argument description\r
+  BufferSize  - GC_TODO: add argument description\r
+  Buffer      - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\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 UINTN                  BufferSize,\r
+  IN VOID                   *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This        - GC_TODO: add argument description\r
+  MediaId     - GC_TODO: add argument description\r
+  LBA         - GC_TODO: add argument description\r
+  BufferSize  - GC_TODO: add argument description\r
+  Buffer      - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Prototypes of internal functions\r
+//\r
+EFI_STATUS\r
+DiscoverFddDevice (\r
+  IN FDC_BLK_IO_DEV  *FdcDev\r
+  )\r
+/*++\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
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+FddIdentify (\r
+  IN FDC_BLK_IO_DEV  *FdcDev\r
+  )\r
+/*++\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
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+FddReset (\r
+  IN FDC_BLK_IO_DEV  *FdcDev\r
+  )\r
+/*++\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
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+MotorOn (\r
+  IN FDC_BLK_IO_DEV  *FdcDev\r
+  )\r
+/*++\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
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+MotorOff (\r
+  IN FDC_BLK_IO_DEV  *FdcDev\r
+  )\r
+/*++\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
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+DisketChanged (\r
+  IN FDC_BLK_IO_DEV  *FdcDev\r
+  )\r
+/*++\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
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+Specify (\r
+  IN FDC_BLK_IO_DEV  *FdcDev\r
+  )\r
+/*++\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
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+Recalibrate (\r
+  IN FDC_BLK_IO_DEV  *FdcDev\r
+  )\r
+/*++\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
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+Seek (\r
+  IN FDC_BLK_IO_DEV  *FdcDev,\r
+  IN EFI_LBA         Lba\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FdcDev  - GC_TODO: add argument description\r
+  Lba     - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+SenseIntStatus (\r
+  IN     FDC_BLK_IO_DEV  *FdcDev,\r
+  IN OUT UINT8           *StatusRegister0,\r
+  IN OUT UINT8           *PresentCylinderNumber\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FdcDev                - GC_TODO: add argument description\r
+  StatusRegister0       - GC_TODO: add argument description\r
+  PresentCylinderNumber - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+SenseDrvStatus (\r
+  IN FDC_BLK_IO_DEV  *FdcDev,\r
+  IN EFI_LBA         Lba\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FdcDev  - GC_TODO: add argument description\r
+  Lba     - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+DetectMedia (\r
+  IN FDC_BLK_IO_DEV  *FdcDev\r
+  )\r
+/*++\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
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+Setup (\r
+  IN FDC_BLK_IO_DEV  *FdcDev\r
+  )\r
+/*++\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
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+ReadWriteDataSector (\r
+  IN FDC_BLK_IO_DEV  *FdcDev,\r
+  IN VOID            *HostAddress,\r
+  IN EFI_LBA         Lba,\r
+  IN UINTN           NumberOfBlocks,\r
+  IN BOOLEAN         Read\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FdcDev          - GC_TODO: add argument description\r
+  HostAddress     - GC_TODO: add argument description\r
+  Lba             - GC_TODO: add argument description\r
+  NumberOfBlocks  - GC_TODO: add argument description\r
+  Read            - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+FillPara (\r
+  IN FDC_BLK_IO_DEV       *FdcDev,\r
+  IN EFI_LBA              Lba,\r
+  IN FDD_COMMAND_PACKET1  *Command\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FdcDev  - GC_TODO: add argument description\r
+  Lba     - GC_TODO: add argument description\r
+  Command - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+DataInByte (\r
+  IN FDC_BLK_IO_DEV  *FdcDev,\r
+  IN UINT8           *Pointer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FdcDev  - GC_TODO: add argument description\r
+  Pointer - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+DataOutByte (\r
+  IN FDC_BLK_IO_DEV  *FdcDev,\r
+  IN UINT8           *Pointer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FdcDev  - GC_TODO: add argument description\r
+  Pointer - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+FddWaitForBSYClear (\r
+  IN FDC_BLK_IO_DEV  *FdcDev,\r
+  IN UINTN           TimeoutInSeconds\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FdcDev            - GC_TODO: add argument description\r
+  TimeoutInSeconds  - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+FddDRQReady (\r
+  IN FDC_BLK_IO_DEV  *FdcDev,\r
+  IN BOOLEAN         Dio,\r
+  IN UINTN           TimeoutInSeconds\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FdcDev            - GC_TODO: add argument description\r
+  Dio               - GC_TODO: add argument description\r
+  TimeoutInSeconds  - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+CheckResult (\r
+  IN     FDD_RESULT_PACKET  *Result,\r
+  IN OUT FDC_BLK_IO_DEV     *FdcDev\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Result  - GC_TODO: add argument description\r
+  FdcDev  - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+CheckStatus3 (\r
+  IN UINT8 StatusRegister3\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  StatusRegister3 - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+UINTN\r
+GetTransferBlockCount (\r
+  IN FDC_BLK_IO_DEV  *FdcDev,\r
+  IN EFI_LBA         LBA,\r
+  IN UINTN           NumberOfBlocks\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FdcDev          - GC_TODO: add argument description\r
+  LBA             - GC_TODO: add argument description\r
+  NumberOfBlocks  - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+EFIAPI\r
+FddTimerProc (\r
+  IN EFI_EVENT  Event,\r
+  IN VOID       *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Event   - GC_TODO: add argument description\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+UINT8\r
+FdcReadPort (\r
+  IN FDC_BLK_IO_DEV  *FdcDev,\r
+  IN UINT32          Offset\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FdcDev  - GC_TODO: add argument description\r
+  Offset  - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+FdcWritePort (\r
+  IN FDC_BLK_IO_DEV  *FdcDev,\r
+  IN UINT32          Offset,\r
+  IN UINT8           Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FdcDev  - GC_TODO: add argument description\r
+  Offset  - GC_TODO: add argument description\r
+  Data    - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\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  UINTN                  BufferSize,\r
+  IN  BOOLEAN                Operation,\r
+  OUT VOID                   *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This        - GC_TODO: add argument description\r
+  MediaId     - GC_TODO: add argument description\r
+  LBA         - GC_TODO: add argument description\r
+  BufferSize  - GC_TODO: add argument description\r
+  Operation   - GC_TODO: add argument description\r
+  Buffer      - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+FdcFreeCache (\r
+  IN    FDC_BLK_IO_DEV  *FdcDev\r
+  )\r
+/*++\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
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppy.inf b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppy.inf
new file mode 100644 (file)
index 0000000..1351b0e
--- /dev/null
@@ -0,0 +1,104 @@
+#/** @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
+#  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
+#  All rights reserved. This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution.  The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#\r
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = IsaFloppy\r
+  FILE_GUID                      = 0abd8284-6da3-4616-971a-83a5148067ba\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  EDK_RELEASE_VERSION            = 0x00020000\r
+  EFI_SPECIFICATION_VERSION      = 0x00020000\r
+\r
+  ENTRY_POINT                    = InitializeIsaFloppy\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+#  DRIVER_BINDING                =  gFdcControllerDriver                         \r
+#  COMPONENT_NAME                =  gIsaFloppyComponentName                      \r
+#  Create Event Guid C Name:  Event Type: EVENT_TYPE_PERIODIC_TIMER\r
+#\r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+  ComponentName.c\r
+  ComponentName.h\r
+  IsaFloppyCtrl.c\r
+  IsaFloppyBlock.c\r
+  IsaFloppy.c\r
+  IsaFloppy.h\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+#                              this module.\r
+#\r
+################################################################################\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+#                         this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+  ReportStatusCodeLib\r
+  UefiBootServicesTableLib\r
+  MemoryAllocationLib\r
+  BaseMemoryLib\r
+  UefiLib\r
+  BaseLib\r
+  UefiDriverEntryPoint\r
+  DebugLib\r
+  TimerLib\r
+\r
+\r
+################################################################################\r
+#\r
+# Protocol C Name Section - list of Protocol and Protocol Notify C Names\r
+#                           that this module uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Protocols]\r
+  gEfiIsaIoProtocolGuid                         # PROTOCOL TO_START\r
+  gEfiBlockIoProtocolGuid                       # PROTOCOL BY_START\r
+  gEfiDevicePathProtocolGuid                    # PROTOCOL TO_START\r
+\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppy.msa b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppy.msa
new file mode 100644 (file)
index 0000000..dfe6989
--- /dev/null
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0  http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd" xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+  <MsaHeader>\r
+    <ModuleName>IsaFloppy</ModuleName>\r
+    <ModuleType>DXE_DRIVER</ModuleType>\r
+    <GuidValue>0abd8284-6da3-4616-971a-83a5148067ba</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Component description file for IsaFloppy module.</Abstract>\r
+    <Description>ISA Floppy Driver
+        1. Support two types diskette drive
+           1.44M drive and 2.88M drive (and now only support 1.44M)
+        2. Support two diskette drives
+        3. Use DMA channel 2 to transfer data
+        4. Do not use interrupt
+        5. Support diskette change line signal and write protect
+
+        Conforming to EFI driver model</Description>\r
+    <Copyright>Copyright (c) 2006 - 2007, Intel Corporation<BR></Copyright>\r
+    <License>\r
+      All rights reserved. This program and the accompanying materials\r
+      are licensed and made available under the terms and conditions of the BSD License\r
+      which accompanies this distribution.  The full text of the license may be found at\r
+      http://opensource.org/licenses/bsd-license.php\r
+\r
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+    </License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>IsaFloppy</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>TimerLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiDriverModelLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiDriverEntryPoint</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseMemoryLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>MemoryAllocationLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiBootServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>ReportStatusCodeLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>IsaFloppy.h</Filename>\r
+    <Filename>IsaFloppy.c</Filename>\r
+    <Filename>IsaFloppyBlock.c</Filename>\r
+    <Filename>IsaFloppyCtrl.c</Filename>\r
+    <Filename>ComponentName.h</Filename>\r
+    <Filename>ComponentName.c</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="TO_START">\r
+      <ProtocolCName>gEfiDevicePathProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="BY_START">\r
+      <ProtocolCName>gEfiBlockIoProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="TO_START">\r
+      <ProtocolCName>gEfiIsaIoProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+  </Protocols>\r
+  <Events>\r
+    <CreateEvents>\r
+      <EventTypes Usage="ALWAYS_CONSUMED">\r
+        <EventType>EVENT_TYPE_PERIODIC_TIMER</EventType>\r
+        <HelpText>Timer event for each Floppd Disk Controller to control the motor on and off.</HelpText>\r
+      </EventTypes>\r
+    </CreateEvents>\r
+  </Events>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+    <Extern>\r
+      <DriverBinding>gFdcControllerDriver</DriverBinding>\r
+      <ComponentName>gIsaFloppyComponentName</ComponentName>\r
+    </Extern>\r
+  </Externs>\r
+</ModuleSurfaceArea>
\ No newline at end of file
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyBlock.c b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyBlock.c
new file mode 100644 (file)
index 0000000..e6282ca
--- /dev/null
@@ -0,0 +1,458 @@
+/*++\r
+\r
+  Copyright (c) 2006 - 2007, 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
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  IsaFloppyBlock.c\r
+\r
+Abstract:\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
+  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
+  Implement the Block IO interface\r
+\r
+Revision History:\r
+\r
+--*/\r
+\r
+#include "IsaFloppy.h"\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FdcReset (\r
+  IN  EFI_BLOCK_IO_PROTOCOL  *This,\r
+  IN  BOOLEAN                ExtendedVerification\r
+  )\r
+/*++\r
+  \r
+  Routine Description:  Reset the Floppy Logic Drive, call the FddReset function   \r
+  Parameters:\r
+    This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface\r
+    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
+  Returns:\r
+    EFI_SUCCESS:      The Floppy Logic Drive is reset\r
+    EFI_DEVICE_ERROR: The Floppy Logic Drive is not functioning correctly \r
+                      and can not be reset\r
+\r
+--*/\r
+// GC_TODO: function comment is missing 'Arguments:'\r
+// GC_TODO:    This - add argument and description to function comment\r
+// GC_TODO:    ExtendedVerification - add argument and description to function comment\r
+{\r
+  FDC_BLK_IO_DEV  *FdcDev;\r
+\r
+  //\r
+  // Reset the Floppy Disk Controller\r
+  //\r
+  FdcDev = FDD_BLK_IO_FROM_THIS (This);\r
+\r
+  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+    EFI_PROGRESS_CODE,\r
+    EFI_P_PC_RESET | EFI_PERIPHERAL_REMOVABLE_MEDIA,\r
+    FdcDev->DevicePath\r
+    );\r
+\r
+  return FddReset (FdcDev);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FddFlushBlocks (\r
+  IN  EFI_BLOCK_IO_PROTOCOL  *This\r
+  )\r
+/*++\r
+  \r
+  Routine Description:  \r
+  Parameters:\r
+    This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface\r
+  Returns:\r
+    EFI_SUCCESS:    \r
+\r
+--*/\r
+// GC_TODO: function comment is missing 'Arguments:'\r
+// GC_TODO:    This - add argument and description to function comment\r
+{\r
+  //\r
+  // Not supported yet\r
+  //\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+VOID\r
+FddReportStatus (\r
+  IN  EFI_BLOCK_IO_PROTOCOL  *This,\r
+  IN  BOOLEAN                Read\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This  - GC_TODO: add argument description\r
+  Read  - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  FDC_BLK_IO_DEV  *FdcDev;\r
+\r
+  FdcDev = FDD_BLK_IO_FROM_THIS (This);\r
+\r
+  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+    EFI_ERROR_CODE,\r
+    ((Read) ? EFI_P_EC_INPUT_ERROR : EFI_P_EC_OUTPUT_ERROR) | EFI_PERIPHERAL_REMOVABLE_MEDIA,\r
+    FdcDev->DevicePath\r
+    );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FddReadBlocks (\r
+  IN  EFI_BLOCK_IO_PROTOCOL  *This,\r
+  IN  UINT32                 MediaId,\r
+  IN  EFI_LBA                LBA,\r
+  IN  UINTN                  BufferSize,\r
+  OUT VOID                   *Buffer\r
+  )\r
+/*++\r
+\r
+  Routine Description:  Read the requested number of blocks from the device   \r
+  Parameters:\r
+    This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface\r
+    MediaId UINT32:    The media id that the read request is for    \r
+    LBA EFI_LBA:     The starting logic block address to read from on the device\r
+    BufferSize UINTN:  The size of the Buffer in bytes\r
+    Buffer VOID *:     A pointer to the destination buffer for the data\r
+  Returns:\r
+    EFI_SUCCESS:     The data was read correctly from the device\r
+    EFI_DEVICE_ERROR:The device reported an error while attempting to perform\r
+                     the read operation\r
+    EFI_NO_MEDIA:    There is no media in the device\r
+    EFI_MEDIA_CHANGED:   The MediaId is not for the current media\r
+    EFI_BAD_BUFFER_SIZE: The BufferSize parameter is not a multiple of the \r
+                         intrinsic block size of the device\r
+    EFI_INVALID_PARAMETER:The read request contains LBAs that are not valid, \r
+                          or the buffer is not on proper alignment \r
+\r
+--*/\r
+// GC_TODO: function comment is missing 'Arguments:'\r
+// GC_TODO:    This - add argument and description to function comment\r
+// GC_TODO:    MediaId - add argument and description to function comment\r
+// GC_TODO:    LBA - add argument and description to function comment\r
+// GC_TODO:    BufferSize - add argument and description to function comment\r
+// GC_TODO:    Buffer - add argument and description to function comment\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  Status = FddReadWriteBlocks (This, MediaId, LBA, BufferSize, READ, Buffer);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    FddReportStatus (This, TRUE);\r
+  }\r
+\r
+  return Status;\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 UINTN                  BufferSize,\r
+  IN VOID                   *Buffer\r
+  )\r
+/*++\r
+\r
+  Routine Description:  Write a specified number of blocks to the device   \r
+  Parameters:\r
+    This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface\r
+    MediaId UINT32:    The media id that the write request is for   \r
+    LBA EFI_LBA:     The starting logic block address to be written\r
+    BufferSize UINTN:  The size in bytes in Buffer\r
+    Buffer VOID *:     A pointer to the source buffer for the data\r
+  Returns :\r
+    EFI_SUCCESS:     The data were written correctly to the device\r
+    EFI_WRITE_PROTECTED: The device can not be written to \r
+    EFI_NO_MEDIA:    There is no media in the device\r
+    EFI_MEDIA_CHANGED:   The MediaId is not for the current media\r
+    EFI_DEVICE_ERROR:  The device reported an error while attempting to perform \r
+                       the write operation \r
+    EFI_BAD_BUFFER_SIZE: The BufferSize parameter is not a multiple of the \r
+                         intrinsic block size of the device\r
+    EFI_INVALID_PARAMETER:The write request contains LBAs that are not valid, \r
+                          or the buffer is not on proper alignment \r
+\r
+--*/\r
+// GC_TODO: function comment is missing 'Arguments:'\r
+// GC_TODO: function comment is missing 'Returns:'\r
+// GC_TODO:    This - add argument and description to function comment\r
+// GC_TODO:    MediaId - add argument and description to function comment\r
+// GC_TODO:    LBA - add argument and description to function comment\r
+// GC_TODO:    BufferSize - add argument and description to function comment\r
+// GC_TODO:    Buffer - add argument and description to function comment\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  Status = FddReadWriteBlocks (This, MediaId, LBA, BufferSize, WRITE, Buffer);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    FddReportStatus (This, FALSE);\r
+  }\r
+\r
+  return Status;\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  UINTN                  BufferSize,\r
+  IN  BOOLEAN                Operation,\r
+  OUT VOID                   *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This        - GC_TODO: add argument description\r
+  MediaId     - GC_TODO: add argument description\r
+  LBA         - GC_TODO: add argument description\r
+  BufferSize  - GC_TODO: add argument description\r
+  Operation   - GC_TODO: add argument description\r
+  Buffer      - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  EFI_INVALID_PARAMETER - GC_TODO: Add description for return value\r
+  EFI_SUCCESS - GC_TODO: Add description for return value\r
+  EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
+  EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
+  EFI_NO_MEDIA - GC_TODO: Add description for return value\r
+  EFI_MEDIA_CHANGED - GC_TODO: Add description for return value\r
+  EFI_WRITE_PROTECTED - GC_TODO: Add description for return value\r
+  EFI_BAD_BUFFER_SIZE - GC_TODO: Add description for return value\r
+  EFI_INVALID_PARAMETER - GC_TODO: Add description for return value\r
+  EFI_INVALID_PARAMETER - GC_TODO: Add description for return value\r
+  EFI_SUCCESS - GC_TODO: Add description for return value\r
+  EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
+  EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
+  EFI_SUCCESS - GC_TODO: Add description for return value\r
+\r
+--*/\r
+{\r
+  EFI_BLOCK_IO_MEDIA  *Media;\r
+  FDC_BLK_IO_DEV      *FdcDev;\r
+  UINTN               BlockSize;\r
+  UINTN               NumberOfBlocks;\r
+  UINTN               BlockCount;\r
+  EFI_STATUS          Status;\r
+  //\r
+  //  EFI_STATUS            CacheStatus;\r
+  //\r
+  EFI_LBA             LBA0;\r
+  UINT8               *Pointer;\r
+\r
+  //\r
+  // Get the intrinsic block size\r
+  //\r
+  Media     = This->Media;\r
+  BlockSize = Media->BlockSize;\r
+  FdcDev    = FDD_BLK_IO_FROM_THIS (This);\r
+\r
+  if (Operation == WRITE) {\r
+    if (LBA == 0) {\r
+      FdcFreeCache (FdcDev);\r
+    }\r
+  }\r
+  //\r
+  // Check the Parameter is valid\r
+  //\r
+  if (Buffer == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (BufferSize == 0) {\r
+    return EFI_SUCCESS;\r
+  }\r
+  //\r
+  // Set the drive motor on\r
+  //\r
+  Status = MotorOn (FdcDev);\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+  //\r
+  // Check to see if media can be detected\r
+  //\r
+  Status = DetectMedia (FdcDev);\r
+  if (EFI_ERROR (Status)) {\r
+    MotorOff (FdcDev);\r
+    FdcFreeCache (FdcDev);\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+  //\r
+  // Check to see if media is present\r
+  //\r
+  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
+  // Check to see if media has been changed\r
+  //\r
+  if (MediaId != Media->MediaId) {\r
+    MotorOff (FdcDev);\r
+    FdcFreeCache (FdcDev);\r
+    return EFI_MEDIA_CHANGED;\r
+  }\r
+\r
+  if (Operation == WRITE) {\r
+    if (Media->ReadOnly) {\r
+      MotorOff (FdcDev);\r
+      return EFI_WRITE_PROTECTED;\r
+    }\r
+  }\r
+  //\r
+  // Check the parameters for this read/write operation\r
+  //\r
+  if (BufferSize % BlockSize != 0) {\r
+    MotorOff (FdcDev);\r
+    return EFI_BAD_BUFFER_SIZE;\r
+  }\r
+\r
+  if (LBA > Media->LastBlock) {\r
+    MotorOff (FdcDev);\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (((BufferSize / BlockSize) + LBA - 1) > Media->LastBlock) {\r
+    MotorOff (FdcDev);\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (Operation == READ) {\r
+    //\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
+        MotorOff (FdcDev);\r
+        CopyMem ((UINT8 *) Buffer, (UINT8 *) FdcDev->Cache, BlockSize);\r
+        return EFI_SUCCESS;\r
+      }\r
+    }\r
+  }\r
+  //\r
+  // Set up Floppy Disk Controller\r
+  //\r
+  Status = Setup (FdcDev);\r
+  if (EFI_ERROR (Status)) {\r
+    MotorOff (FdcDev);\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  NumberOfBlocks  = BufferSize / BlockSize;\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
+  while ((BlockCount != 0) && !EFI_ERROR (Status)) {\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
+    NumberOfBlocks -= BlockCount;\r
+    Buffer      = (VOID *) ((UINTN) Buffer + BlockCount * BlockSize);\r
+    BlockCount  = GetTransferBlockCount (FdcDev, LBA, NumberOfBlocks);\r
+  }\r
+\r
+  Buffer = Pointer;\r
+\r
+  //\r
+  // Turn the motor off\r
+  //\r
+  MotorOff (FdcDev);\r
+\r
+  if (Operation == READ) {\r
+    //\r
+    // Cache the data read\r
+    //\r
+    if (LBA0 == 0 && !FdcDev->Cache) {\r
+      FdcDev->Cache = AllocateCopyPool (BlockSize, Buffer);\r
+    }\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+\r
+}\r
+\r
+VOID\r
+FdcFreeCache (\r
+  IN    FDC_BLK_IO_DEV  *FdcDev\r
+  )\r
+/*++\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
+\r
+--*/\r
+{\r
+  if (FdcDev->Cache) {\r
+    gBS->FreePool (FdcDev->Cache);\r
+    FdcDev->Cache = NULL;\r
+  }\r
+}\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyCtrl.c b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyCtrl.c
new file mode 100644 (file)
index 0000000..2fd13c3
--- /dev/null
@@ -0,0 +1,1551 @@
+/*++\r
+\r
+  Copyright (c) 2006 - 2007, 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
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  IsaFloppyCtrl.c\r
+\r
+Abstract:\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
+  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
+\r
+Revision History:\r
+\r
+--*/\r
+\r
+#include "IsaFloppy.h"\r
+\r
+EFI_STATUS\r
+DiscoverFddDevice (\r
+  IN FDC_BLK_IO_DEV  *FdcDev\r
+  )\r
+/*++\r
+\r
+  Routine Description:  Detect the floppy drive is presented or not   \r
+  Parameters:\r
+    FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV       \r
+  Returns:\r
+    EFI_SUCCESS    Drive is presented \r
+    EFI_NOT_FOUND  Drive is not presented\r
+\r
+--*/\r
+// GC_TODO: function comment is missing 'Arguments:'\r
+// GC_TODO:    FdcDev - add argument and description to function comment\r
+{\r
+  EFI_STATUS  Status;\r
+\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
+  }\r
+\r
+  FdcDev->BlkIo.Reset               = FdcReset;\r
+  FdcDev->BlkIo.FlushBlocks         = FddFlushBlocks;\r
+  FdcDev->BlkIo.ReadBlocks          = FddReadBlocks;\r
+  FdcDev->BlkIo.WriteBlocks         = FddWriteBlocks;\r
+  FdcDev->BlkMedia.LogicalPartition = FALSE;\r
+  FdcDev->BlkMedia.WriteCaching     = FALSE;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+FddIdentify (\r
+  IN FDC_BLK_IO_DEV  *FdcDev\r
+  )\r
+/*++\r
+\r
+  Routine Description:   Do recalibrate  and see the drive is presented or not\r
+         Set the media parameters\r
+  Parameters:\r
+    FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV       \r
+  Returns:\r
+    EFI_SUCCESS:    \r
+    EFI_DEVICE_ERROR: \r
+\r
+--*/\r
+// GC_TODO: function comment is missing 'Arguments:'\r
+// GC_TODO:    FdcDev - add argument and description to function comment\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // Set Floppy Disk Controller's motor on\r
+  //\r
+  Status = MotorOn (FdcDev);\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  Status = Recalibrate (FdcDev);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    MotorOff (FdcDev);\r
+    FdcDev->ControllerState->NeedRecalibrate = TRUE;\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+  //\r
+  // Set Media Parameter\r
+  //\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
+  // Check Media\r
+  //\r
+  Status = DisketChanged (FdcDev);\r
+  switch (Status) {\r
+  case EFI_NO_MEDIA:\r
+    FdcDev->BlkIo.Media->MediaPresent = FALSE;\r
+    break;\r
+\r
+  case EFI_MEDIA_CHANGED:\r
+  case EFI_SUCCESS:\r
+    break;\r
+\r
+  default:\r
+    MotorOff (FdcDev);\r
+    return Status;\r
+  }\r
+  //\r
+  // Check Disk Write Protected\r
+  //\r
+  Status = SenseDrvStatus (FdcDev, 0);\r
+  switch (Status) {\r
+  case EFI_WRITE_PROTECTED:\r
+    FdcDev->BlkIo.Media->ReadOnly = TRUE;\r
+    break;\r
+\r
+  case EFI_SUCCESS:\r
+    FdcDev->BlkIo.Media->ReadOnly = FALSE;\r
+    break;\r
+\r
+  default:\r
+    return EFI_DEVICE_ERROR;\r
+    break;\r
+  }\r
+\r
+  MotorOff (FdcDev);\r
+\r
+  //\r
+  // Set Media Default Type\r
+  //\r
+  FdcDev->BlkIo.Media->BlockSize  = DISK_1440K_BYTEPERSECTOR;\r
+  FdcDev->BlkIo.Media->LastBlock  = DISK_1440K_EOT * 2 * (DISK_1440K_MAXTRACKNUM + 1) - 1;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+FddReset (\r
+  IN FDC_BLK_IO_DEV  *FdcDev\r
+  )\r
+/*++\r
+\r
+  Routine Description:  Reset the Floppy Logic Drive   \r
+  Parameters:\r
+    FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV       \r
+  Returns:\r
+    EFI_SUCCESS:    The Floppy Logic Drive is reset\r
+    EFI_DEVICE_ERROR: The Floppy Logic Drive is not functioning correctly and \r
+                      can not be reset\r
+\r
+--*/\r
+// GC_TODO: function comment is missing 'Arguments:'\r
+// GC_TODO:    FdcDev - add argument and description to function comment\r
+{\r
+  UINT8 data;\r
+  UINT8 StatusRegister0;\r
+  UINT8 PresentCylinderNumber;\r
+  UINTN Index;\r
+\r
+  //\r
+  // Report reset progress code\r
+  //\r
+  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+    EFI_PROGRESS_CODE,\r
+    EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_PC_RESET,\r
+    FdcDev->DevicePath\r
+    );\r
+\r
+  //\r
+  // Reset specified Floppy Logic Drive according to FdcDev -> Disk\r
+  // Set Digital Output Register(DOR) to do reset work\r
+  //   bit0 & bit1 of DOR : Drive Select\r
+  //   bit2 : Reset bit\r
+  //   bit3 : DMA and Int bit\r
+  // Reset : a "0" written to bit2 resets the FDC, this reset will remain\r
+  //         active until\r
+  //         a "1" is written to this bit.\r
+  // Reset step 1:\r
+  //         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
+\r
+  //\r
+  // wait some time,at least 120us\r
+  //\r
+  MicroSecondDelay (500);\r
+\r
+  //\r
+  // Reset step 2:\r
+  //   write "1" to bit2\r
+  //   write "1" to bit3 : enable DMA\r
+  //\r
+  data |= 0x0C;\r
+  FdcWritePort (FdcDev, FDC_REGISTER_DOR, data);\r
+\r
+  //\r
+  // Experience value\r
+  //\r
+  MicroSecondDelay (2000);\r
+\r
+  //\r
+  // wait specified floppy logic drive is not busy\r
+  //\r
+  if (EFI_ERROR (FddWaitForBSYClear (FdcDev, 1))) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+  //\r
+  // Set the Transfer Data Rate\r
+  //\r
+  FdcWritePort (FdcDev, FDC_REGISTER_CCR, 0x0);\r
+\r
+  //\r
+  // Experience value\r
+  //\r
+  MicroSecondDelay (100);\r
+\r
+  //\r
+  // Issue Sense interrupt command for each drive (total 4 drives)\r
+  //\r
+  for (Index = 0; Index < 4; Index++) {\r
+    if (EFI_ERROR (SenseIntStatus (FdcDev, &StatusRegister0, &PresentCylinderNumber))) {\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+  }\r
+  //\r
+  // issue Specify command\r
+  //\r
+  if (EFI_ERROR (Specify (FdcDev))) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+MotorOn (\r
+  IN FDC_BLK_IO_DEV  *FdcDev\r
+  )\r
+/*++\r
+\r
+  Routine Description:  Turn the drive's motor on\r
+        The drive's motor must be on before any command can be executed   \r
+  Parameters:\r
+    FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV       \r
+  Returns:\r
+    EFI_SUCCESS:       Turn the drive's motor on successfully\r
+    EFI_DEVICE_ERROR:    The drive is busy, so can not turn motor on \r
+    EFI_INVALID_PARAMETER: Fail to Set timer(Cancel timer)  \r
+\r
+--*/\r
+// GC_TODO: function comment is missing 'Arguments:'\r
+// GC_TODO:    FdcDev - add argument and description to function comment\r
+{\r
+  EFI_STATUS  Status;\r
+  UINT8       data;\r
+\r
+  //\r
+  // Control of the floppy drive motors is a big pain. If motor is off, you have\r
+  // to turn it on first. But you can not leave the motor on all the time, since\r
+  // that would wear out the disk. On the other hand, if you turn the motor off\r
+  // after each operation, the system performance will be awful. The compromise\r
+  // used in this driver is to leave the motor on for 2 seconds after\r
+  // each operation. If a new operation is started in that interval(2s),\r
+  // the motor need not be turned on again. If no new operation is started,\r
+  // a timer goes off and the motor is turned off\r
+  //\r
+  //\r
+  // Cancel the timer\r
+  //\r
+  Status = gBS->SetTimer (FdcDev->Event, TimerCancel, 0);\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
+\r
+  if (((FdcDev->Disk == FDC_DISK0) && ((data & 0x10) == 0x10)) ||\r
+      ((FdcDev->Disk == FDC_DISK1) && ((data & 0x21) == 0x21))\r
+      ) {\r
+    return EFI_SUCCESS;\r
+  }\r
+  //\r
+  // The drive's motor is off, so need turn it on\r
+  // first look at command and drive are busy or not\r
+  //\r
+  if (EFI_ERROR (FddWaitForBSYClear (FdcDev, 1))) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+  //\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
+    //\r
+    // drive A\r
+    //\r
+    data |= DRVA_MOTOR_ON;\r
+  } else {\r
+    //\r
+    // drive B\r
+    //\r
+    data |= DRVB_MOTOR_ON;\r
+  }\r
+\r
+  FdcWritePort (FdcDev, FDC_REGISTER_DOR, data);\r
+\r
+  //\r
+  // Experience value\r
+  //\r
+  MicroSecondDelay (4000);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+MotorOff (\r
+  IN FDC_BLK_IO_DEV  *FdcDev\r
+  )\r
+/*++\r
+\r
+  Routine Description:  Set a Timer and when Timer goes off, turn the motor off\r
+  Parameters:\r
+    FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV       \r
+  Returns:\r
+    EFI_SUCCESS:       Set the Timer successfully\r
+    EFI_INVALID_PARAMETER: Fail to Set the timer  \r
+\r
+--*/\r
+// GC_TODO: function comment is missing 'Arguments:'\r
+// GC_TODO:    FdcDev - add argument and description to function comment\r
+{\r
+  //\r
+  // Set the timer : 2s\r
+  //\r
+  return gBS->SetTimer (FdcDev->Event, TimerRelative, 20000000);\r
+}\r
+\r
+EFI_STATUS\r
+DisketChanged (\r
+  IN FDC_BLK_IO_DEV  *FdcDev\r
+  )\r
+/*++\r
+\r
+  Routine Description:  Detect the disk in the drive is changed or not\r
+  Parameters:\r
+    FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV   \r
+  Returns:\r
+    EFI_SUCCESS:    No disk media change\r
+    EFI_DEVICE_ERROR: Fail to do the recalibrate or seek operation\r
+    EFI_NO_MEDIA:   No disk in the drive\r
+    EFI_MEDIA_CHANGED:  There is a new disk in the drive\r
+\r
+--*/\r
+// GC_TODO: function comment is missing 'Arguments:'\r
+// GC_TODO:    FdcDev - add argument and description to function comment\r
+{\r
+  EFI_STATUS  Status;\r
+  UINT8       data;\r
+\r
+  //\r
+  // Check change line\r
+  //\r
+  data = FdcReadPort (FdcDev, FDC_REGISTER_DIR);\r
+\r
+  //\r
+  // Io delay\r
+  //\r
+  MicroSecondDelay (50);\r
+\r
+  if ((data & DIR_DCL) == 0x80) {\r
+    //\r
+    // disk change line is active\r
+    //\r
+    if (FdcDev->PresentCylinderNumber != 0) {\r
+      Status = Recalibrate (FdcDev);\r
+    } else {\r
+      Status = Seek (FdcDev, 0x30);\r
+    }\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      FdcDev->ControllerState->NeedRecalibrate = TRUE;\r
+      return EFI_DEVICE_ERROR;\r
+      //\r
+      // Fail to do the seek or recalibrate operation\r
+      //\r
+    }\r
+\r
+    data = FdcReadPort (FdcDev, FDC_REGISTER_DIR);\r
+\r
+    //\r
+    // Io delay\r
+    //\r
+    MicroSecondDelay (50);\r
+\r
+    if ((data & DIR_DCL) == 0x80) {\r
+      return EFI_NO_MEDIA;\r
+    }\r
+\r
+    return EFI_MEDIA_CHANGED;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+Specify (\r
+  IN FDC_BLK_IO_DEV  *FdcDev\r
+  )\r
+/*++\r
+\r
+  Routine Description:  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
+  Parameters:\r
+    None\r
+  Returns:\r
+    EFI_SUCCESS:    Execute the Specify command successfully\r
+    EFI_DEVICE_ERROR: Fail to execute the command\r
+\r
+--*/\r
+// GC_TODO: function comment is missing 'Arguments:'\r
+// GC_TODO:    FdcDev - add argument and description to function comment\r
+{\r
+  FDD_SPECIFY_CMD Command;\r
+  UINTN           Index;\r
+  UINT8           *CommandPointer;\r
+\r
+  ZeroMem (&Command, sizeof (FDD_SPECIFY_CMD));\r
+  Command.CommandCode = SPECIFY_CMD;\r
+  //\r
+  // set SRT, HUT\r
+  //\r
+  Command.SrtHut = 0xdf;\r
+  //\r
+  // 0xdf;\r
+  //\r
+  // set HLT and DMA\r
+  //\r
+  Command.HltNd   = 0x02;\r
+\r
+  CommandPointer  = (UINT8 *) (&Command);\r
+  for (Index = 0; Index < sizeof (FDD_SPECIFY_CMD); Index++) {\r
+    if (EFI_ERROR (DataOutByte (FdcDev, CommandPointer++))) {\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+Recalibrate (\r
+  IN FDC_BLK_IO_DEV  *FdcDev\r
+  )\r
+/*++\r
+\r
+  Routine Description:  Set the head of floppy drive to track 0\r
+  Parameters:\r
+    FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
+  Returns:\r
+    EFI_SUCCESS:    Execute the Recalibrate operation successfully\r
+    EFI_DEVICE_ERROR: Fail to execute the Recalibrate operation\r
+\r
+--*/\r
+// GC_TODO: function comment is missing 'Arguments:'\r
+// GC_TODO:    FdcDev - add argument and description to function comment\r
+{\r
+  FDD_COMMAND_PACKET2 Command;\r
+  UINTN               Index;\r
+  UINT8               StatusRegister0;\r
+  UINT8               PresentCylinderNumber;\r
+  UINT8               *CommandPointer;\r
+  UINT8               Count;\r
+\r
+  Count = 2;\r
+\r
+  while (Count > 0) {\r
+    ZeroMem (&Command, sizeof (FDD_COMMAND_PACKET2));\r
+    Command.CommandCode = RECALIBRATE_CMD;\r
+    //\r
+    // drive select\r
+    //\r
+    if (FdcDev->Disk == FDC_DISK0) {\r
+      Command.DiskHeadSel = 0;\r
+      //\r
+      // 0\r
+      //\r
+    } else {\r
+      Command.DiskHeadSel = 1;\r
+      //\r
+      // 1\r
+      //\r
+    }\r
+\r
+    CommandPointer = (UINT8 *) (&Command);\r
+    for (Index = 0; Index < sizeof (FDD_COMMAND_PACKET2); Index++) {\r
+      if (EFI_ERROR (DataOutByte (FdcDev, CommandPointer++))) {\r
+        return EFI_DEVICE_ERROR;\r
+      }\r
+    }\r
+    //\r
+    // Experience value\r
+    //\r
+    MicroSecondDelay (250000);\r
+    //\r
+    // need modify according to 1.44M or 2.88M\r
+    //\r
+    if (EFI_ERROR (SenseIntStatus (FdcDev, &StatusRegister0, &PresentCylinderNumber))) {\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+\r
+    if ((StatusRegister0 & 0xf0) == 0x20 && PresentCylinderNumber == 0) {\r
+      FdcDev->PresentCylinderNumber             = 0;\r
+      FdcDev->ControllerState->NeedRecalibrate  = FALSE;\r
+      return EFI_SUCCESS;\r
+    } else {\r
+      Count--;\r
+      if (Count == 0) {\r
+        return EFI_DEVICE_ERROR;\r
+      }\r
+    }\r
+  }\r
+  //\r
+  // end while\r
+  //\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+Seek (\r
+  IN FDC_BLK_IO_DEV  *FdcDev,\r
+  IN EFI_LBA         Lba\r
+  )\r
+/*++\r
+\r
+  Routine Description:  Set the head of floppy drive to the new cylinder\r
+  Parameters:\r
+    FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
+    Lba EFI_LBA     : The logic block address want to seek\r
+  Returns:\r
+    EFI_SUCCESS:    Execute the Seek operation successfully\r
+    EFI_DEVICE_ERROR: Fail to execute the Seek operation\r
+\r
+--*/\r
+// GC_TODO: function comment is missing 'Arguments:'\r
+// GC_TODO:    FdcDev - add argument and description to function comment\r
+// GC_TODO:    Lba - add argument and description to function comment\r
+{\r
+  FDD_SEEK_CMD  Command;\r
+  UINT8         EndOfTrack;\r
+  UINT8         Head;\r
+  UINT8         Cylinder;\r
+  UINT8         StatusRegister0;\r
+  UINT8         *CommandPointer;\r
+  UINT8         PresentCylinderNumber;\r
+  UINTN         Index;\r
+  UINT8         DelayTime;\r
+\r
+  if (FdcDev->ControllerState->NeedRecalibrate) {\r
+    if (EFI_ERROR (Recalibrate (FdcDev))) {\r
+      FdcDev->ControllerState->NeedRecalibrate = TRUE;\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+  }\r
+\r
+  EndOfTrack = DISK_1440K_EOT;\r
+  //\r
+  // Calculate cylinder based on Lba and EOT\r
+  //\r
+  Cylinder = (UINT8) ((UINTN) Lba / EndOfTrack / 2);\r
+\r
+  //\r
+  // if the destination cylinder is the present cylinder, unnecessary to do the\r
+  // seek operation\r
+  //\r
+  if (FdcDev->PresentCylinderNumber == Cylinder) {\r
+    return EFI_SUCCESS;\r
+  }\r
+  //\r
+  // Calculate the head : 0 or 1\r
+  //\r
+  Head = (UINT8) ((UINTN) Lba / EndOfTrack % 2);\r
+\r
+  ZeroMem (&Command, sizeof (FDD_SEEK_CMD));\r
+  Command.CommandCode = SEEK_CMD;\r
+  if (FdcDev->Disk == FDC_DISK0) {\r
+    Command.DiskHeadSel = 0;\r
+    //\r
+    // 0\r
+    //\r
+  } else {\r
+    Command.DiskHeadSel = 1;\r
+    //\r
+    // 1\r
+    //\r
+  }\r
+\r
+  Command.DiskHeadSel = (UINT8) (Command.DiskHeadSel | (Head << 2));\r
+  Command.NewCylinder = Cylinder;\r
+\r
+  CommandPointer      = (UINT8 *) (&Command);\r
+  for (Index = 0; Index < sizeof (FDD_SEEK_CMD); Index++) {\r
+    if (EFI_ERROR (DataOutByte (FdcDev, CommandPointer++))) {\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+  }\r
+  //\r
+  // Io delay\r
+  //\r
+  MicroSecondDelay (100);\r
+\r
+  //\r
+  // Calculate waiting time\r
+  //\r
+  if (FdcDev->PresentCylinderNumber > Cylinder) {\r
+    DelayTime = (UINT8) (FdcDev->PresentCylinderNumber - Cylinder);\r
+  } else {\r
+    DelayTime = (UINT8) (Cylinder - FdcDev->PresentCylinderNumber);\r
+  }\r
+\r
+  MicroSecondDelay ((DelayTime + 1) * 4000);\r
+\r
+  if (EFI_ERROR (SenseIntStatus (FdcDev, &StatusRegister0, &PresentCylinderNumber))) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  if ((StatusRegister0 & 0xf0) == 0x20) {\r
+    FdcDev->PresentCylinderNumber = Command.NewCylinder;\r
+    return EFI_SUCCESS;\r
+  } else {\r
+    FdcDev->ControllerState->NeedRecalibrate = TRUE;\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+}\r
+\r
+EFI_STATUS\r
+SenseIntStatus (\r
+  IN     FDC_BLK_IO_DEV  *FdcDev,\r
+  IN OUT UINT8           *StatusRegister0,\r
+  IN OUT UINT8           *PresentCylinderNumber\r
+  )\r
+/*++\r
+\r
+  Routine Description:  Do the Sense Interrupt Status command, this command \r
+                        resets the interrupt signal\r
+  Parameters:\r
+    StatusRegister0 UINT8 *: Be used to save Status Register 0 read from FDC   \r
+    PresentCylinderNumber  UINT8 *: Be used to save present cylinder number \r
+                                    read from FDC\r
+  Returns:\r
+    EFI_SUCCESS:    Execute the Sense Interrupt Status command successfully\r
+    EFI_DEVICE_ERROR: Fail to execute the command\r
+\r
+--*/\r
+// GC_TODO: function comment is missing 'Arguments:'\r
+// GC_TODO:    FdcDev - add argument and description to function comment\r
+// GC_TODO:    StatusRegister0 - add argument and description to function comment\r
+// GC_TODO:    PresentCylinderNumber - add argument and description to function comment\r
+{\r
+  UINT8 command;\r
+\r
+  command = SENSE_INT_STATUS_CMD;\r
+  if (EFI_ERROR (DataOutByte (FdcDev, &command))) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  if (EFI_ERROR (DataInByte (FdcDev, StatusRegister0))) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  if (EFI_ERROR (DataInByte (FdcDev, PresentCylinderNumber))) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+SenseDrvStatus (\r
+  IN FDC_BLK_IO_DEV  *FdcDev,\r
+  IN EFI_LBA         Lba\r
+  )\r
+/*++\r
+\r
+  Routine Description:  Do the Sense Drive Status command\r
+  Parameters:\r
+    FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV   \r
+    Lba EFI_LBA     : Logic block address\r
+  Returns:\r
+    EFI_SUCCESS:    Execute the Sense Drive Status command successfully\r
+    EFI_DEVICE_ERROR: Fail to execute the command\r
+    EFI_WRITE_PROTECTED:The disk is write protected \r
+\r
+--*/\r
+// GC_TODO: function comment is missing 'Arguments:'\r
+// GC_TODO:    FdcDev - add argument and description to function comment\r
+// GC_TODO:    Lba - add argument and description to function comment\r
+{\r
+  FDD_COMMAND_PACKET2 Command;\r
+  UINT8               Head;\r
+  UINT8               EndOfTrack;\r
+  UINTN               Index;\r
+  UINT8               StatusRegister3;\r
+  UINT8               *CommandPointer;\r
+\r
+  //\r
+  // Sense Drive Status command obtains drive status information,\r
+  // it has not execution phase and goes directly to the result phase from the\r
+  // command phase, Status Register 3 contains the drive status information\r
+  //\r
+  ZeroMem (&Command, sizeof (FDD_COMMAND_PACKET2));\r
+  Command.CommandCode = SENSE_DRV_STATUS_CMD;\r
+\r
+  if (FdcDev->Disk == FDC_DISK0) {\r
+    Command.DiskHeadSel = 0;\r
+  } else {\r
+    Command.DiskHeadSel = 1;\r
+  }\r
+\r
+  EndOfTrack  = DISK_1440K_EOT;\r
+  Head        = (UINT8) ((UINTN) Lba / EndOfTrack % 2);\r
+  Command.DiskHeadSel = (UINT8) (Command.DiskHeadSel | (Head << 2));\r
+\r
+  CommandPointer = (UINT8 *) (&Command);\r
+  for (Index = 0; Index < sizeof (FDD_COMMAND_PACKET2); Index++) {\r
+    if (EFI_ERROR (DataOutByte (FdcDev, CommandPointer++))) {\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+  }\r
+\r
+  if (EFI_ERROR (DataInByte (FdcDev, &StatusRegister3))) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+  //\r
+  // Io delay\r
+  //\r
+  MicroSecondDelay (50);\r
+\r
+  //\r
+  // Check Status Register 3 to get drive status information\r
+  //\r
+  return CheckStatus3 (StatusRegister3);\r
+}\r
+\r
+EFI_STATUS\r
+DetectMedia (\r
+  IN FDC_BLK_IO_DEV  *FdcDev\r
+  )\r
+/*++\r
+\r
+  Routine Description:  Update the disk media properties and if necessary \r
+                        reinstall Block I/O interface\r
+  Parameters:\r
+    FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV   \r
+  Returns:\r
+    EFI_SUCCESS:    Do the operation successfully\r
+    EFI_DEVICE_ERROR: Fail to the operation\r
+\r
+--*/\r
+// GC_TODO: function comment is missing 'Arguments:'\r
+// GC_TODO:    FdcDev - add argument and description to function comment\r
+{\r
+  EFI_STATUS  Status;\r
+  BOOLEAN     bReset;\r
+  BOOLEAN     bReadOnlyLastTime;\r
+  BOOLEAN     bMediaPresentLastTime;\r
+\r
+  bReset                = FALSE;\r
+  bReadOnlyLastTime     = FdcDev->BlkIo.Media->ReadOnly;\r
+  bMediaPresentLastTime = FdcDev->BlkIo.Media->MediaPresent;\r
+\r
+  //\r
+  // Check disk change\r
+  //\r
+  Status = DisketChanged (FdcDev);\r
+  switch (Status) {\r
+  case EFI_MEDIA_CHANGED:\r
+    FdcDev->BlkIo.Media->MediaId++;\r
+    FdcDev->BlkIo.Media->MediaPresent = TRUE;\r
+    bReset = TRUE;\r
+    break;\r
+\r
+  case EFI_NO_MEDIA:\r
+    FdcDev->BlkIo.Media->MediaPresent = FALSE;\r
+    break;\r
+\r
+  case EFI_SUCCESS:\r
+    break;\r
+\r
+  default:\r
+    MotorOff (FdcDev);\r
+    return Status;\r
+    //\r
+    // EFI_DEVICE_ERROR\r
+    //\r
+  }\r
+\r
+  if (FdcDev->BlkIo.Media->MediaPresent) {\r
+    //\r
+    // Check disk write protected\r
+    //\r
+    Status = SenseDrvStatus (FdcDev, 0);\r
+    if (Status == EFI_WRITE_PROTECTED) {\r
+      FdcDev->BlkIo.Media->ReadOnly = TRUE;\r
+    } else {\r
+      FdcDev->BlkIo.Media->ReadOnly = FALSE;\r
+    }\r
+  }\r
+\r
+  if (FdcDev->BlkIo.Media->MediaPresent && (bReadOnlyLastTime != FdcDev->BlkIo.Media->ReadOnly)) {\r
+    bReset = TRUE;\r
+  }\r
+\r
+  if (bMediaPresentLastTime != FdcDev->BlkIo.Media->MediaPresent) {\r
+    bReset = TRUE;\r
+  }\r
+\r
+  if (bReset) {\r
+    Status = gBS->ReinstallProtocolInterface (\r
+                    FdcDev->Handle,\r
+                    &gEfiBlockIoProtocolGuid,\r
+                    &FdcDev->BlkIo,\r
+                    &FdcDev->BlkIo\r
+                    );\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+Setup (\r
+  IN FDC_BLK_IO_DEV  *FdcDev\r
+  )\r
+/*++\r
+\r
+  Routine Description: Set the data rate and so on\r
+  Parameters:\r
+    None  \r
+  Returns:\r
+    EFI_SUCCESS:  \r
+\r
+--*/\r
+// GC_TODO: function comment is missing 'Arguments:'\r
+// GC_TODO:    FdcDev - add argument and description to function comment\r
+// GC_TODO:    EFI_DEVICE_ERROR - add return value to function comment\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // Set data rate 500kbs\r
+  //\r
+  FdcWritePort (FdcDev, FDC_REGISTER_CCR, 0x0);\r
+\r
+  //\r
+  // Io delay\r
+  //\r
+  MicroSecondDelay (50);\r
+\r
+  Status = Specify (FdcDev);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+ReadWriteDataSector (\r
+  IN  FDC_BLK_IO_DEV  *FdcDev,\r
+  IN  VOID            *HostAddress,\r
+  IN  EFI_LBA         Lba,\r
+  IN  UINTN           NumberOfBlocks,\r
+  IN  BOOLEAN         Read\r
+  )\r
+/*++\r
+\r
+  Routine Description: Read or Write a number of blocks in the same cylinder\r
+  Parameters:\r
+    FdcDev FDC_BLK_IO_DEV * : A pointer to Data Structure FDC_BLK_IO_DEV\r
+    Buffer VOID *:\r
+    Lba EFI_LBA:\r
+    NumberOfBlocks UINTN:\r
+    Read BOOLEAN:     \r
+  Returns:\r
+    EFI_SUCCESS:  \r
+\r
+--*/\r
+// GC_TODO: function comment is missing 'Arguments:'\r
+// GC_TODO:    FdcDev - add argument and description to function comment\r
+// GC_TODO:    HostAddress - add argument and description to function comment\r
+// GC_TODO:    Lba - add argument and description to function comment\r
+// GC_TODO:    NumberOfBlocks - add argument and description to function comment\r
+// GC_TODO:    Read - add argument and description to function comment\r
+// GC_TODO:    EFI_DEVICE_ERROR - add return value to function comment\r
+// GC_TODO:    EFI_DEVICE_ERROR - add return value to function comment\r
+// GC_TODO:    EFI_DEVICE_ERROR - add return value to function comment\r
+// GC_TODO:    EFI_TIMEOUT - add return value to function comment\r
+// GC_TODO:    EFI_DEVICE_ERROR - add return value to function comment\r
+{\r
+  EFI_STATUS                                    Status;\r
+  FDD_COMMAND_PACKET1                           Command;\r
+  FDD_RESULT_PACKET                             Result;\r
+  UINTN                                         Index;\r
+  UINTN                                         Times;\r
+  UINT8                                         *CommandPointer;\r
+\r
+  EFI_PHYSICAL_ADDRESS                          DeviceAddress;\r
+  EFI_ISA_IO_PROTOCOL                           *IsaIo;\r
+  UINTN                                         NumberofBytes;\r
+  VOID                                          *Mapping;\r
+  EFI_ISA_IO_PROTOCOL_OPERATION                 Operation;\r
+  EFI_STATUS                                    Status1;\r
+  UINT8                                         Channel;\r
+  EFI_ISA_ACPI_RESOURCE                         *ResourceItem;\r
+  UINT32                                        Attribute;\r
+\r
+  Status = Seek (FdcDev, Lba);\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+  //\r
+  // Map Dma\r
+  //\r
+  IsaIo         = FdcDev->IsaIo;\r
+  NumberofBytes = NumberOfBlocks * 512;\r
+  if (Read == READ) {\r
+    Operation = EfiIsaIoOperationSlaveWrite;\r
+  } else {\r
+    Operation = EfiIsaIoOperationSlaveRead;\r
+  }\r
+\r
+  ResourceItem  = IsaIo->ResourceList->ResourceItem;\r
+  Index         = 0;\r
+  while (ResourceItem[Index].Type != EfiIsaAcpiResourceEndOfList) {\r
+    if (ResourceItem[Index].Type == EfiIsaAcpiResourceDma) {\r
+      break;\r
+    }\r
+\r
+    Index++;\r
+  }\r
+\r
+  if (ResourceItem[Index].Type == EfiIsaAcpiResourceEndOfList) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  Channel   = (UINT8) IsaIo->ResourceList->ResourceItem[Index].StartRange;\r
+  Attribute = IsaIo->ResourceList->ResourceItem[Index].Attribute;\r
+\r
+  Status1 = IsaIo->Map (\r
+                    IsaIo,\r
+                    Operation,\r
+                    Channel,\r
+                    Attribute,\r
+                    HostAddress,\r
+                    &NumberofBytes,\r
+                    &DeviceAddress,\r
+                    &Mapping\r
+                    );\r
+  if (EFI_ERROR (Status1)) {\r
+    return Status1;\r
+  }\r
+\r
+  //\r
+  // Allocate Read or Write command packet\r
+  //\r
+  ZeroMem (&Command, sizeof (FDD_COMMAND_PACKET1));\r
+  if (Read == READ) {\r
+    Command.CommandCode = READ_DATA_CMD | CMD_MT | CMD_MFM | CMD_SK;\r
+  } else {\r
+    Command.CommandCode = WRITE_DATA_CMD | CMD_MT | CMD_MFM;\r
+  }\r
+\r
+  FillPara (FdcDev, Lba, &Command);\r
+\r
+  //\r
+  // Write command bytes to FDC\r
+  //\r
+  CommandPointer = (UINT8 *) (&Command);\r
+  for (Index = 0; Index < sizeof (FDD_COMMAND_PACKET1); Index++) {\r
+    if (EFI_ERROR (DataOutByte (FdcDev, CommandPointer++))) {\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+  }\r
+  //\r
+  // wait for some time\r
+  //\r
+  Times = (STALL_1_SECOND / 50) + 1;\r
+  do {\r
+    if ((FdcReadPort (FdcDev, FDC_REGISTER_MSR) & 0xc0) == 0xc0) {\r
+      break;\r
+    }\r
+\r
+    MicroSecondDelay (50);\r
+    Times = Times - 1;\r
+  } while (Times);\r
+\r
+  if (Times == 0) {\r
+    return EFI_TIMEOUT;\r
+  }\r
+  //\r
+  // Read result bytes from FDC\r
+  //\r
+  CommandPointer = (UINT8 *) (&Result);\r
+  for (Index = 0; Index < sizeof (FDD_RESULT_PACKET); Index++) {\r
+    if (EFI_ERROR (DataInByte (FdcDev, CommandPointer++))) {\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+  }\r
+  //\r
+  // Flush before Unmap\r
+  //\r
+  if (Read == READ) {\r
+    Status1 = IsaIo->Flush (IsaIo);\r
+    if (EFI_ERROR (Status1)) {\r
+      return Status1;\r
+    }\r
+  }\r
+  //\r
+  // Unmap Dma\r
+  //\r
+  Status1 = IsaIo->Unmap (IsaIo, Mapping);\r
+  if (EFI_ERROR (Status1)) {\r
+    return Status1;\r
+  }\r
+\r
+  return CheckResult (&Result, FdcDev);\r
+}\r
+\r
+VOID\r
+FillPara (\r
+  IN  FDC_BLK_IO_DEV       *FdcDev,\r
+  IN  EFI_LBA              Lba,\r
+  IN  FDD_COMMAND_PACKET1  *Command\r
+  )\r
+/*++\r
+\r
+  Routine Description: Fill in Parameter\r
+  Parameters:\r
+  Returns:\r
+    \r
+--*/\r
+// GC_TODO: function comment is missing 'Arguments:'\r
+// GC_TODO:    FdcDev - add argument and description to function comment\r
+// GC_TODO:    Lba - add argument and description to function comment\r
+// GC_TODO:    Command - add argument and description to function comment\r
+{\r
+  UINT8 EndOfTrack;\r
+\r
+  //\r
+  // Get EndOfTrack from the Para table\r
+  //\r
+  EndOfTrack = DISK_1440K_EOT;\r
+\r
+  //\r
+  // Fill the command parameter\r
+  //\r
+  if (FdcDev->Disk == FDC_DISK0) {\r
+    Command->DiskHeadSel = 0;\r
+  } else {\r
+    Command->DiskHeadSel = 1;\r
+  }\r
+\r
+  Command->Cylinder = (UINT8) ((UINTN) Lba / EndOfTrack / 2);\r
+  Command->Head     = (UINT8) ((UINTN) Lba / EndOfTrack % 2);\r
+  Command->Sector   = (UINT8) ((UINT8) ((UINTN) Lba % EndOfTrack) + 1);\r
+  Command->DiskHeadSel = (UINT8) (Command->DiskHeadSel | (Command->Head << 2));\r
+  Command->Number     = DISK_1440K_NUMBER;\r
+  Command->EndOfTrack = DISK_1440K_EOT;\r
+  Command->GapLength  = DISK_1440K_GPL;\r
+  Command->DataLength = DISK_1440K_DTL;\r
+}\r
+\r
+EFI_STATUS\r
+DataInByte (\r
+  IN     FDC_BLK_IO_DEV  *FdcDev,\r
+  IN OUT UINT8           *Pointer\r
+  )\r
+/*++\r
+\r
+  Routine Description:  Read result byte from Data Register of FDC\r
+  Parameters:\r
+    Pointer UINT8 *: Be used to save result byte read from FDC   \r
+  Returns:\r
+    EFI_SUCCESS:    Read result byte from FDC successfully\r
+    EFI_DEVICE_ERROR: The FDC is not ready to be read\r
+\r
+--*/\r
+// GC_TODO: function comment is missing 'Arguments:'\r
+// GC_TODO:    FdcDev - add argument and description to function comment\r
+// GC_TODO:    Pointer - add argument and description to function comment\r
+{\r
+  UINT8 data;\r
+\r
+  //\r
+  // wait for 1ms and detect the FDC is ready to be read\r
+  //\r
+  if (EFI_ERROR (FddDRQReady (FdcDev, DATA_IN, 1))) {\r
+    return EFI_DEVICE_ERROR;\r
+    //\r
+    // is not ready\r
+    //\r
+  }\r
+\r
+  data = FdcReadPort (FdcDev, FDC_REGISTER_DTR);\r
+\r
+  //\r
+  // Io delay\r
+  //\r
+  MicroSecondDelay (50);\r
+\r
+  *Pointer = data;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+DataOutByte (\r
+  IN FDC_BLK_IO_DEV  *FdcDev,\r
+  IN UINT8           *Pointer\r
+  )\r
+/*++\r
+\r
+  Routine Description:  Write command byte to Data Register of FDC\r
+  Parameters:\r
+    Pointer UINT8 *: Be used to save command byte written to FDC   \r
+  Returns:\r
+    EFI_SUCCESS:    Write command byte to FDC successfully\r
+    EFI_DEVICE_ERROR: The FDC is not ready to be written\r
+\r
+--*/\r
+// GC_TODO: function comment is missing 'Arguments:'\r
+// GC_TODO:    FdcDev - add argument and description to function comment\r
+// GC_TODO:    Pointer - add argument and description to function comment\r
+{\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
+    //\r
+  }\r
+\r
+  data = *Pointer;\r
+\r
+  FdcWritePort (FdcDev, FDC_REGISTER_DTR, data);\r
+\r
+  //\r
+  // Io delay\r
+  //\r
+  MicroSecondDelay (50);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+FddWaitForBSYClear (\r
+  IN FDC_BLK_IO_DEV  *FdcDev,\r
+  IN UINTN           TimeoutInSeconds\r
+  )\r
+/*++\r
+\r
+  Routine Description:  Detect the specified floppy logic drive is busy or \r
+                        not within a period of time\r
+  Parameters:\r
+    Disk EFI_FDC_DISK:    Indicate it is drive A or drive B\r
+    TimeoutInSeconds UINTN: the time period for waiting   \r
+  Returns:\r
+    EFI_SUCCESS:  The drive and command are not busy\r
+    EFI_TIMEOUT:  The drive or command is still busy after a period time that \r
+                  set by TimeoutInSeconds\r
+\r
+--*/\r
+// GC_TODO: function comment is missing 'Arguments:'\r
+// GC_TODO:    FdcDev - add argument and description to function comment\r
+// GC_TODO:    TimeoutInSeconds - add argument and description to function comment\r
+{\r
+  UINTN Delay;\r
+  UINT8 StatusRegister;\r
+  UINT8 Mask;\r
+\r
+  //\r
+  // How to determine drive and command are busy or not: by the bits of\r
+  // Main Status Register\r
+  // bit0: Drive 0 busy (drive A)\r
+  // bit1: Drive 1 busy (drive B)\r
+  // bit4: Command busy\r
+  //\r
+  //\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
+\r
+  Delay = ((TimeoutInSeconds * STALL_1_MSECOND) / 50) + 1;\r
+  do {\r
+    StatusRegister = FdcReadPort (FdcDev, FDC_REGISTER_MSR);\r
+    if ((StatusRegister & Mask) == 0x00) {\r
+      break;\r
+      //\r
+      // not busy\r
+      //\r
+    }\r
+\r
+    MicroSecondDelay (50);\r
+    Delay = Delay - 1;\r
+  } while (Delay);\r
+\r
+  if (Delay == 0) {\r
+    return EFI_TIMEOUT;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+FddDRQReady (\r
+  IN FDC_BLK_IO_DEV  *FdcDev,\r
+  IN BOOLEAN         Dio,\r
+  IN  UINTN          TimeoutInSeconds\r
+  )\r
+/*++\r
+\r
+  Routine Description:  Determine whether FDC is ready to write or read\r
+  Parameters:\r
+    Dio BOOLEAN:      Indicate the FDC is waiting to write or read\r
+    TimeoutInSeconds UINTN: The time period for waiting   \r
+  Returns:\r
+    EFI_SUCCESS:  FDC is ready to write or read\r
+    EFI_NOT_READY:  FDC is not ready within the specified time period\r
+\r
+--*/\r
+// GC_TODO: function comment is missing 'Arguments:'\r
+// GC_TODO:    FdcDev - add argument and description to function comment\r
+// GC_TODO:    Dio - add argument and description to function comment\r
+// GC_TODO:    TimeoutInSeconds - add argument and description to function comment\r
+{\r
+  UINTN Delay;\r
+  UINT8 StatusRegister;\r
+  UINT8 DataInOut;\r
+\r
+  //\r
+  // Before writing to FDC or reading from FDC, the Host must examine\r
+  // the bit7(RQM) and bit6(DIO) of the Main Status Register.\r
+  // That is to say:\r
+  //  command bytes can not be written to Data Register\r
+  //  unless RQM is 1 and DIO is 0\r
+  //  result bytes can not be read from Data Register\r
+  //  unless RQM is 1 and DIO is 1\r
+  //\r
+  DataInOut = (UINT8) (Dio << 6);\r
+  //\r
+  // in order to compare bit6\r
+  //\r
+  Delay = ((TimeoutInSeconds * STALL_1_MSECOND) / 50) + 1;\r
+  do {\r
+    StatusRegister = FdcReadPort (FdcDev, FDC_REGISTER_MSR);\r
+    if ((StatusRegister & MSR_RQM) == MSR_RQM && (StatusRegister & MSR_DIO) == DataInOut) {\r
+      break;\r
+      //\r
+      // FDC is ready\r
+      //\r
+    }\r
+\r
+    MicroSecondDelay (50);\r
+    //\r
+    // Stall for 50 us\r
+    //\r
+    Delay = Delay - 1;\r
+  } while (Delay);\r
+\r
+  if (Delay == 0) {\r
+    return EFI_NOT_READY;\r
+    //\r
+    // FDC is not ready within the specified time period\r
+    //\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+CheckResult (\r
+  IN     FDD_RESULT_PACKET  *Result,\r
+  IN OUT FDC_BLK_IO_DEV     *FdcDev\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Result  - GC_TODO: add argument description\r
+  FdcDev  - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
+  EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
+  EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
+  EFI_SUCCESS - GC_TODO: Add description for return value\r
+\r
+--*/\r
+{\r
+  //\r
+  // Check Status Register0\r
+  //\r
+  if ((Result->Status0 & STS0_IC) != IC_NT) {\r
+    if ((Result->Status0 & STS0_SE) == 0x20) {\r
+      //\r
+      // seek error\r
+      //\r
+      FdcDev->ControllerState->NeedRecalibrate = TRUE;\r
+    }\r
+\r
+    FdcDev->ControllerState->NeedRecalibrate = TRUE;\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+  //\r
+  // Check Status Register1\r
+  //\r
+  if (Result->Status1 & (STS1_EN | STS1_DE | STS1_OR | STS1_ND | STS1_NW | STS1_MA)) {\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
+    FdcDev->ControllerState->NeedRecalibrate = TRUE;\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+CheckStatus3 (\r
+  IN UINT8 StatusRegister3\r
+  )\r
+/*++\r
+\r
+  Routine Description:  Check the drive status information\r
+  Parameters:\r
+    StatusRegister3 UINT8: the value of Status Register 3    \r
+  Returns:\r
+    EFI_SUCCESS:     \r
+    EFI_WRITE_PROTECTED:  The disk is write protected\r
+\r
+--*/\r
+// GC_TODO: function comment is missing 'Arguments:'\r
+// GC_TODO:    StatusRegister3 - add argument and description to function comment\r
+{\r
+  if (StatusRegister3 & STS3_WP) {\r
+    return EFI_WRITE_PROTECTED;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+UINTN\r
+GetTransferBlockCount (\r
+  IN  FDC_BLK_IO_DEV  *FdcDev,\r
+  IN  EFI_LBA         LBA,\r
+  IN  UINTN           NumberOfBlocks\r
+  )\r
+/*++\r
+\r
+  Routine Description:  Calculate the number of block in the same cylinder \r
+                        according to LBA\r
+  Parameters:\r
+    FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
+    LBA EFI_LBA:      The starting logic block address            \r
+    NumberOfBlocks UINTN: The number of blocks\r
+  Returns:\r
+    UINTN : The number of blocks in the same cylinder which the starting \r
+        logic block address is LBA\r
+\r
+--*/\r
+// GC_TODO: function comment is missing 'Arguments:'\r
+// GC_TODO:    FdcDev - add argument and description to function comment\r
+// GC_TODO:    LBA - add argument and description to function comment\r
+// GC_TODO:    NumberOfBlocks - add argument and description to function comment\r
+{\r
+  UINT8 EndOfTrack;\r
+  UINT8 Head;\r
+  UINT8 SectorsInTrack;\r
+\r
+  //\r
+  // Calculate the number of block in the same cylinder\r
+  //\r
+  EndOfTrack      = DISK_1440K_EOT;\r
+  Head            = (UINT8) ((UINTN) LBA / EndOfTrack % 2);\r
+\r
+  SectorsInTrack  = (UINT8) (EndOfTrack * (2 - Head) - (UINT8) ((UINTN) LBA % EndOfTrack));\r
+  if (SectorsInTrack < NumberOfBlocks) {\r
+    return SectorsInTrack;\r
+  } else {\r
+    return NumberOfBlocks;\r
+  }\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+FddTimerProc (\r
+  IN EFI_EVENT  Event,\r
+  IN VOID       *Context\r
+  )\r
+/*++\r
+\r
+  Routine Description:  When the Timer(2s) off, turn the drive's motor off\r
+  Parameters:\r
+    Event EFI_EVENT: Event(the timer) whose notification function is being \r
+                     invoked\r
+    Context VOID *:  Pointer to the notification function's context \r
+  Returns:\r
+    VOID\r
+\r
+--*/\r
+// GC_TODO: function comment is missing 'Arguments:'\r
+// GC_TODO:    Event - add argument and description to function comment\r
+// GC_TODO:    Context - add argument and description to function comment\r
+{\r
+  FDC_BLK_IO_DEV  *FdcDev;\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
+\r
+  if (((FdcDev->Disk == FDC_DISK0) && ((data & 0x10) != 0x10)) ||\r
+      ((FdcDev->Disk == FDC_DISK1) && ((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
+  MicroSecondDelay (500);\r
+}\r
+\r
+UINT8\r
+FdcReadPort (\r
+  IN FDC_BLK_IO_DEV  *FdcDev,\r
+  IN UINT32          Offset\r
+  )\r
+/*++\r
+\r
+  Routine Description: Read I/O port for FDC  \r
+  Parameters:\r
+  Returns:\r
+    \r
+--*/\r
+// GC_TODO: function comment is missing 'Arguments:'\r
+// GC_TODO:    FdcDev - add argument and description to function comment\r
+// GC_TODO:    Offset - add argument and description to function comment\r
+{\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
+\r
+  return Data;\r
+}\r
+\r
+VOID\r
+FdcWritePort (\r
+  IN FDC_BLK_IO_DEV  *FdcDev,\r
+  IN UINT32          Offset,\r
+  IN UINT8           Data\r
+  )\r
+/*++\r
+\r
+  Routine Description: Write I/O port for FDC  \r
+  Parameters:\r
+  Returns:\r
+    \r
+--*/\r
+// GC_TODO: function comment is missing 'Arguments:'\r
+// GC_TODO:    FdcDev - add argument and description to function comment\r
+// GC_TODO:    Offset - add argument and description to function comment\r
+// GC_TODO:    Data - add argument and description to function comment\r
+{\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
+}\r