private bool currentDevice = false; // false = Master, true = slave

        public AtapiHandler(int BusToUse)
        {
            UsedBus = ATABus.Busses[BusToUse];
            if (GetStatus() == (Statuses)0xFF)
            {
                UsedBus = null;
                return;
            }
            UsedBus.Control.Byte = (byte)Controlles.nIEN;
            Identify();
        }
示例#2
0
        private void Identify()
        {
            SelectDrive(false, 0);
            UsedBus.LBA3.Byte = 0x00;
            UsedBus.LBA1.Byte = 0x00;
            UsedBus.LBA2.Byte = 0x00;
            SendCommand(Commands.Identify);
            Statuses status;

            if (UsedBus != null)
            {
                if (UsedBus.LBA2.Byte != 0x00 || UsedBus.LBA3.Byte != 0x00)
                {
                    //Device is not ATA
                    if (UsedBus.LBA2.Byte == 0x14 && UsedBus.LBA3.Byte == 0xEB)
                    {
                    }
                    UsedBus = null;
                }
            }
            if (UsedBus != null)
            {
                do
                {
                    status = GetStatus();
                    if ((status & Statuses.ERR) != 0)
                    {
                        UsedBus = null;
                        break;
                    }
                } while ((status & Statuses.DRQ) == 0);
            }
            if (UsedBus != null)
            {
                UInt16[] Buffer = new UInt16[256];
                UsedBus.Data.Read16(Buffer);
                mSerialNo = GetString(Buffer, 10, 20);
                Console.WriteLine(mSerialNo);
                mFirmwareRev = GetString(Buffer, 23, 8);
                mModelNo     = GetString(Buffer, 27, 40);

                mBlockCount = ((UInt32)Buffer[61] << 16 | Buffer[60]) - 1;

                bool xLba48Capable = (Buffer[83] & 0x400) != 0;
                if (xLba48Capable)
                {
                    mBlockCount = ((UInt64)Buffer[102] << 32 | (UInt64)Buffer[101] << 16 | (UInt64)Buffer[100]) - 1;
                    Mode        = AtapioMode.LBA48;
                }
            }
        }
        private void Identify()
        {
            SelectDrive(false, 0);
            UsedBus.LBA3.Byte = 0x00;
            UsedBus.LBA1.Byte = 0x00;
            UsedBus.LBA2.Byte = 0x00;
            //SendCommand(Commands.Packet);
            Statuses s = GetStatus();

            SendCommand(Commands.PacketIdentify);
            Statuses status;

            if (UsedBus != null)
            {
                if (UsedBus.LBA2.Byte != 0x00 || UsedBus.LBA3.Byte != 0x00)
                {
                    //Device is not ATA
                    if (UsedBus.LBA2.Byte == 0x14 && UsedBus.LBA3.Byte == 0xEB)
                    {
                    }
                }
            }
            if (UsedBus != null)
            {
                do
                {
                    status = GetStatus();
                    if ((status & Statuses.ERR) != 0)
                    {
                        UsedBus = null;
                        break;
                    }
                } while ((status & Statuses.DRQ) == 0);
            }
            if (UsedBus != null)
            {
                UInt16[] Buffer = new UInt16[256];
                UsedBus.Data.Read16(Buffer);
                mSerialNo    = GetString(Buffer, 10, 20);
                mFirmwareRev = GetString(Buffer, 23, 8);
                mModelNo     = GetString(Buffer, 27, 40);

                mBlockCount = ((UInt32)Buffer[61] << 16 | Buffer[60]) - 1;
            }
        }
示例#4
0
        private void SendCommand(Commands command)
        {
            UsedBus.Command.Byte = (byte)command;
            Statuses status;

            do
            {
                status = GetStatus();
                if (status == 0x00)
                {
                    UsedBus = null;
                    return;
                }
            } while ((status & Statuses.BSY) != 0);
            if ((status & Statuses.ERR) != 0)
            {
                throw new Exception("Ata error");
            }
        }