]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyCtrl.c
Fix a bug which leave BLOCKSIZE of BloIO produced by IsaFloppy to be zero when the...
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Isa / IsaFloppyDxe / IsaFloppyCtrl.c
index 2fd13c3a4b8ebdff492b1afc8d4c92ca2c8554e3..a2f0ca924713045f10d97ac23bf92a91df319a73 100644 (file)
@@ -1,33 +1,24 @@
-/*++\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
+/**@file\r
   ISA Floppy Driver\r
-  1. Support two types diskette drive  \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
+\r
   The internal function for the floppy driver\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
-Revision History:\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
+**/\r
 \r
 #include "IsaFloppy.h"\r
 \r
@@ -37,11 +28,11 @@ DiscoverFddDevice (
   )\r
 /*++\r
 \r
-  Routine Description:  Detect the floppy drive is presented or not   \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
+    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_SUCCESS    Drive is presented\r
     EFI_NOT_FOUND  Drive is not presented\r
 \r
 --*/\r
@@ -79,10 +70,10 @@ FddIdentify (
   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
+    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
+    EFI_SUCCESS:\r
+    EFI_DEVICE_ERROR:\r
 \r
 --*/\r
 // GC_TODO: function comment is missing 'Arguments:'\r
@@ -119,35 +110,26 @@ FddIdentify (
   // 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
+  if (Status == EFI_NO_MEDIA) {\r
+    FdcDev->BlkIo.Media->MediaPresent = FALSE;\r
+  } else if ((Status != EFI_MEDIA_CHANGED) &&\r
+             (Status != EFI_SUCCESS)) {\r
     MotorOff (FdcDev);\r
     return Status;\r
   }\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
+  if (Status == EFI_WRITE_PROTECTED) {\r
+    FdcDev->BlkIo.Media->ReadOnly = TRUE;\r
+  } else if (Status == EFI_SUCCESS) {\r
     FdcDev->BlkIo.Media->ReadOnly = FALSE;\r
-    break;\r
-\r
-  default:\r
+  } else {\r
     return EFI_DEVICE_ERROR;\r
-    break;\r
   }\r
 \r
   MotorOff (FdcDev);\r
@@ -167,12 +149,12 @@ FddReset (
   )\r
 /*++\r
 \r
-  Routine Description:  Reset the Floppy Logic Drive   \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
+    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
+    EFI_DEVICE_ERROR: The Floppy Logic Drive is not functioning correctly and\r
                       can not be reset\r
 \r
 --*/\r
@@ -269,13 +251,13 @@ MotorOn (
 /*++\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
+        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
+    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
+    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
@@ -354,10 +336,10 @@ MotorOff (
 \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
+    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
+    EFI_INVALID_PARAMETER: Fail to Set the timer\r
 \r
 --*/\r
 // GC_TODO: function comment is missing 'Arguments:'\r
@@ -377,7 +359,7 @@ DisketChanged (
 \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
+    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
@@ -443,7 +425,7 @@ Specify (
 /*++\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
+                        and the initial values for each of the three internal\r
                         times: HUT, SRT and HLT\r
   Parameters:\r
     None\r
@@ -675,11 +657,11 @@ SenseIntStatus (
   )\r
 /*++\r
 \r
-  Routine Description:  Do the Sense Interrupt Status command, this command \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
+    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
@@ -718,12 +700,12 @@ SenseDrvStatus (
 \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
+    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
+    EFI_WRITE_PROTECTED:The disk is write protected\r
 \r
 --*/\r
 // GC_TODO: function comment is missing 'Arguments:'\r
@@ -782,10 +764,10 @@ DetectMedia (
   )\r
 /*++\r
 \r
-  Routine Description:  Update the disk media properties and if necessary \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
+    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
@@ -807,21 +789,14 @@ DetectMedia (
   // Check disk change\r
   //\r
   Status = DisketChanged (FdcDev);\r
-  switch (Status) {\r
-  case EFI_MEDIA_CHANGED:\r
+\r
+  if (Status == 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
+  } else if (Status == EFI_NO_MEDIA) {\r
     FdcDev->BlkIo.Media->MediaPresent = FALSE;\r
-    break;\r
-\r
-  case EFI_SUCCESS:\r
-    break;\r
-\r
-  default:\r
+  } else if (Status != EFI_SUCCESS) {\r
     MotorOff (FdcDev);\r
     return Status;\r
     //\r
@@ -873,9 +848,9 @@ Setup (
 \r
   Routine Description: Set the data rate and so on\r
   Parameters:\r
-    None  \r
+    None\r
   Returns:\r
-    EFI_SUCCESS:  \r
+    EFI_SUCCESS:\r
 \r
 --*/\r
 // GC_TODO: function comment is missing 'Arguments:'\r
@@ -919,9 +894,9 @@ ReadWriteDataSector (
     Buffer VOID *:\r
     Lba EFI_LBA:\r
     NumberOfBlocks UINTN:\r
-    Read BOOLEAN:     \r
+    Read BOOLEAN:\r
   Returns:\r
-    EFI_SUCCESS:  \r
+    EFI_SUCCESS:\r
 \r
 --*/\r
 // GC_TODO: function comment is missing 'Arguments:'\r
@@ -1076,7 +1051,7 @@ FillPara (
   Routine Description: Fill in Parameter\r
   Parameters:\r
   Returns:\r
-    \r
+\r
 --*/\r
 // GC_TODO: function comment is missing 'Arguments:'\r
 // GC_TODO:    FdcDev - add argument and description to function comment\r
@@ -1118,7 +1093,7 @@ DataInByte (
 \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
+    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
@@ -1160,7 +1135,7 @@ DataOutByte (
 \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
+    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
@@ -1201,14 +1176,14 @@ FddWaitForBSYClear (
   )\r
 /*++\r
 \r
-  Routine Description:  Detect the specified floppy logic drive is busy or \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
+    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
+    EFI_TIMEOUT:  The drive or command is still busy after a period time that\r
                   set by TimeoutInSeconds\r
 \r
 --*/\r
@@ -1264,7 +1239,7 @@ FddDRQReady (
   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
+    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
@@ -1384,9 +1359,9 @@ CheckStatus3 (
 \r
   Routine Description:  Check the drive status information\r
   Parameters:\r
-    StatusRegister3 UINT8: the value of Status Register 3    \r
+    StatusRegister3 UINT8: the value of Status Register 3\r
   Returns:\r
-    EFI_SUCCESS:     \r
+    EFI_SUCCESS:\r
     EFI_WRITE_PROTECTED:  The disk is write protected\r
 \r
 --*/\r
@@ -1408,14 +1383,14 @@ GetTransferBlockCount (
   )\r
 /*++\r
 \r
-  Routine Description:  Calculate the number of block in the same cylinder \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
+    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
+    UINTN : The number of blocks in the same cylinder which the starting\r
         logic block address is LBA\r
 \r
 --*/\r
@@ -1452,9 +1427,9 @@ FddTimerProc (
 \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
+    Event EFI_EVENT: Event(the timer) whose notification function is being\r
                      invoked\r
-    Context VOID *:  Pointer to the notification function's context \r
+    Context VOID *:  Pointer to the notification function's context\r
   Returns:\r
     VOID\r
 \r
@@ -1494,10 +1469,10 @@ FdcReadPort (
   )\r
 /*++\r
 \r
-  Routine Description: Read I/O port for FDC  \r
+  Routine Description: Read I/O port for FDC\r
   Parameters:\r
   Returns:\r
-    \r
+\r
 --*/\r
 // GC_TODO: function comment is missing 'Arguments:'\r
 // GC_TODO:    FdcDev - add argument and description to function comment\r
@@ -1527,10 +1502,10 @@ FdcWritePort (
   )\r
 /*++\r
 \r
-  Routine Description: Write I/O port for FDC  \r
+  Routine Description: Write I/O port for FDC\r
   Parameters:\r
   Returns:\r
-    \r
+\r
 --*/\r
 // GC_TODO: function comment is missing 'Arguments:'\r
 // GC_TODO:    FdcDev - add argument and description to function comment\r