- Fix floppy controller detection
[reactos.git] / reactos / drivers / storage / floppy / floppy.c
index 75cff27..dcb79e0 100644 (file)
@@ -12,9 +12,9 @@
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
  *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
  * PROJECT:         ReactOS Floppy Driver
  * FILE:            floppy.c
@@ -520,7 +520,7 @@ static NTSTATUS NTAPI ConfigCallback(PVOID Context,
           if(AddressSpace == 0)
               gControllerInfo[gNumberOfControllers].BaseAddress = MmMapIoSpace(TranslatedAddress, FDC_PORT_BYTES, MmNonCached);
           else
-              gControllerInfo[gNumberOfControllers].BaseAddress = (PUCHAR)(ULONG_PTR)TranslatedAddress.QuadPart;
+              gControllerInfo[gNumberOfControllers].BaseAddress = (PUCHAR)TranslatedAddress.u.LowPart;
         }
 
       else if(PartialDescriptor->Type == CmResourceTypeDma)
@@ -686,19 +686,20 @@ static NTSTATUS NTAPI InitController(PCONTROLLER_INFO ControllerInfo)
       return STATUS_IO_DEVICE_ERROR;
     }
 
-/* Check if floppy drive exists */
-  if(HwSenseInterruptStatus(ControllerInfo) != STATUS_SUCCESS)
-       {
-         WARN_(FLOPPY, "Floppy drive not detected! Returning STATUS_IO_DEVICE_ERROR\n");
-         return STATUS_IO_DEVICE_ERROR;
-       }
-
-  INFO_(FLOPPY, "InitController: resetting the controller after floppy detection\n");
+  /* All controllers should support this so
+   * if we get something strange back then we
+   * know that this isn't a floppy controller
+   */
+  if (HwGetVersion(ControllerInfo) <= 0)
+    {
+      WARN_(FLOPPY, "InitController: unable to contact controller\n");
+      return STATUS_NO_SUCH_DEVICE;
+    }
 
-  /* Reset the controller */
+  /* Reset the controller to avoid interrupt garbage on certain controllers */
   if(HwReset(ControllerInfo) != STATUS_SUCCESS)
     {
-      WARN_(FLOPPY, "InitController: unable to reset controller\n");
+      WARN_(FLOPPY, "InitController: unable to reset controller #2\n");
       return STATUS_IO_DEVICE_ERROR;
     }
 
@@ -984,6 +985,9 @@ static BOOLEAN NTAPI AddControllers(PDRIVER_OBJECT DriverObject)
 
          /* 3i: Now that we're done, set the Initialized flag so we know to free this in Unload */
          gControllerInfo[i].DriveInfo[j].Initialized = TRUE;
+
+         /* 3j: Clear the DO_DEVICE_INITIALIZING flag */
+      gControllerInfo[i].DriveInfo[j].DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
         }
     }