Ejemplo n.º 1
0
        public PATABase(ATAIOPorts anIO, ATA.ControllerID aControllerId, ATA.BusPosition aBusPosition)
        {
            IO           = anIO;
            controllerId = aControllerId;
            busPosition  = aBusPosition;

            // Disable IRQs, we use polling currently
            SelectDrive(0, false);
            IO.Control.Write_Byte((byte)0x02);

            mDriveType = DiscoverDrive();

            if (mDriveType == SpecLevel.PATAPI)
            {
                blockSize = 2048;
            }

            if (mDriveType == SpecLevel.PATA ||
                mDriveType == SpecLevel.PATAPI)
            {
                InitDrive();
                initialised = true;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initialises a particular drive on the ATA bus.
        /// </summary>
        /// <param name="ctrlId">The controller ID of the device.</param>
        /// <param name="busPos">The bus position of the device.</param>
        public static void InitDrive(ATA.ControllerID ctrlId, ATA.BusPosition busPos)
        {
            //Get the IO ports for the correct bus
            ATAIOPorts theIO = ctrlId == ATA.ControllerID.Primary ? ATAIO1 : ATAIO2;

            //Create / init the device on the bus
            try
            {
                PATABase ThePATABase = new PATABase(theIO, ctrlId, busPos);
                //If the device was detected as present:
                if (ThePATABase.DriveType != PATABase.SpecLevel.Null)
                {
                    //If the device was actually a PATA device:
                    if (ThePATABase.DriveType == PATABase.SpecLevel.PATA)
                    {
                        //Add it to the list of devices.
                        try
                        {
                            DeviceManager.AddDevice(new PATA(ThePATABase));
                        }
                        catch
                        {
                            ExceptionMethods.Throw(new FOS_System.Exception("Error initialising PATA device."));
                        }
                    }
                    else if (ThePATABase.DriveType == PATABase.SpecLevel.PATAPI)
                    {
                        // Add a PATAPI device
                        try
                        {
                            DeviceManager.AddDevice(new PATAPI(ThePATABase));
                        }
                        catch
                        {
                            ExceptionMethods.Throw(new FOS_System.Exception("Error initialising PATAPI device."));
                        }
                    }
                    //TODO: Remove the SATA/SATAPI initialisation from here. It should be done
                    //  in the ATAManager.Init method.
                    else if (ThePATABase.DriveType == PATABase.SpecLevel.SATA)
                    {
                        // Add a SATA device
                        try
                        {
                            DeviceManager.AddDevice(new SATA());
                        }
                        catch
                        {
                            ExceptionMethods.Throw(new FOS_System.Exception("Error initialising SATA device."));
                        }
                    }
                    else if (ThePATABase.DriveType == PATABase.SpecLevel.SATAPI)
                    {
                        // Add a SATAPI device
                        try
                        {
                            DeviceManager.AddDevice(new SATAPI());
                        }
                        catch
                        {
                            ExceptionMethods.Throw(new FOS_System.Exception("Error initialising SATAPI device."));
                        }
                    }
                }
            }
            catch
            {
                ExceptionMethods.Throw(new FOS_System.Exception((FOS_System.String) "Error initialising PATA Base device. Controller ID: " +
                                                                (ctrlId == ATA.ControllerID.Primary ? "Primary" : "Secondary") + " , Position: " +
                                                                (busPos == ATA.BusPosition.Master ? "Master" : "Slave")));
            }
        }