Exemple #1
0
        /// <summary>
        /// Returns the start address of the Layer 0 middle zone (DVD+R DL, DVD-R DL)
        /// </summary>
        /// <param name="isfixed">return value, if true, the middle zone start is changeable</param>
        /// <param name="location">return value, the location of the L0 middle zone</param>
        /// <returns>status of the command</returns>
        public CommandStatus ReadDvdMiddleZoneStartAddr(out bool isfixed, out uint location)
        {
            if (m_logger != null)
            {
                string args = "ReadDvdMiddleZoneStartAddr, out bool isfixed, out uint size";
                m_logger.LogMessage(new UserMessage(UserMessage.Category.Debug, 8, "Bwg.Scsi.Device.ReadDvdStructure(" + args + ")"));
            }

            location = 0;
            isfixed = false;

            using (Command cmd = new Command(ScsiCommandCode.ReadDvdStructure, 12, 12, Command.CmdDirection.In, 5 * 60))
            {
                cmd.SetCDB8(7, 0x21);
                cmd.SetCDB8(8, 12);

                CommandStatus st = SendCommand(cmd);
                if (st != CommandStatus.Success)
                    return st;

                if ((cmd.GetBuffer8(4) & 0x80) != 0)
                    isfixed = true;

                location = cmd.GetBuffer32(8);
            }

            return CommandStatus.Success;
        }
Exemple #2
0
        /// <summary>
        /// This method returns the remapping address (DVD-R DL(
        /// </summary>
        /// <param name="location">the remapping address</param>
        /// <returns>the command status</returns>
        public CommandStatus ReadDvdRemappingAddress(out uint location)
        {
            if (m_logger != null)
            {
                string args = "ReadDvdRemappingAddress, out uint size";
                m_logger.LogMessage(new UserMessage(UserMessage.Category.Debug, 8, "Bwg.Scsi.Device.ReadDvdStructure(" + args + ")"));
            }

            location = 0;

            using (Command cmd = new Command(ScsiCommandCode.ReadDvdStructure, 12, 12, Command.CmdDirection.In, 5 * 60))
            {
                cmd.SetCDB8(7, 0x24);
                cmd.SetCDB8(8, 12);

                CommandStatus st = SendCommand(cmd);
                if (st != CommandStatus.Success)
                    return st;

                location = cmd.GetBuffer32(8);
            }

            return CommandStatus.Success;
        }
Exemple #3
0
        /// <summary>
        /// Query the media for the spare sectors available
        /// </summary>
        /// <param name="primary">the number of primary spare sectors available</param>
        /// <param name="sec_avail">the number of secondary spare sectors available</param>
        /// <param name="sec_total">the number of secondary spare sectors total</param>
        /// <returns></returns>
        public CommandStatus ReadDVDRamSpareAreaInfo(out uint primary, out uint sec_avail, out uint sec_total)
        {
            primary = 0;
            sec_avail = 0;
            sec_total = 0;

            if (m_logger != null)
            {
                string args = "out primary, out sec_avail, out sec_total";
                m_logger.LogMessage(new UserMessage(UserMessage.Category.Debug, 8, "Bwg.Scsi.Device.ReadDVDRamSpareAreaInfo(" + args + ")"));
            }

            using (Command cmd = new Command(ScsiCommandCode.ReadDvdStructure, 12, 2048, Command.CmdDirection.In, 60))
            {
                cmd.SetCDB8(7, 0x0a);         // Read manufacturing information
                cmd.SetCDB16(8, 16);          // Up to 2k of data

                CommandStatus st = SendCommand(cmd);
                if (st != CommandStatus.Success)
                    return st;

                primary = cmd.GetBuffer32(4);
                sec_avail = cmd.GetBuffer32(8);
                sec_total = cmd.GetBuffer32(12);
            }

            return CommandStatus.Success;
        }
Exemple #4
0
        /// <summary>
        /// Returns the size of layer 0 for DL media (DVD+R DL and DVD-R DL)
        /// </summary>
        /// <param name="isfixed">return value, if true size of L0 is changable</param>
        /// <param name="size">return value, the current size of L0</param>
        /// <returns>status of the command</returns>
        public CommandStatus ReadDvdLayer0Size(out bool isfixed, out uint size)
        {
            if (m_logger != null)
            {
                string args = "ReadDvdLayer0Size, out bool isfixed, out uint size";
                m_logger.LogMessage(new UserMessage(UserMessage.Category.Debug, 8, "Bwg.Scsi.Device.ReadDvdStructure(" + args + ")"));
            }

            size = 0;
            isfixed = false;

            using (Command cmd = new Command(ScsiCommandCode.ReadDvdStructure, 12, 12, Command.CmdDirection.In, 5 * 60))
            {
                cmd.SetCDB8(7, 0x20);         // Read manufacturing information
                cmd.SetCDB8(8, 12);

                CommandStatus st = SendCommand(cmd);
                if (st != CommandStatus.Success)
                    return st;

                if ((cmd.GetBuffer8(4) & 0x80) != 0)
                    isfixed = true;

                size = cmd.GetBuffer32(8);
            }

            return CommandStatus.Success;
        }
Exemple #5
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="lba"></param>
        /// <param name="blocklen"></param>
        /// <returns></returns>
        public CommandStatus ReadCapacity(out uint lba, out uint blocklen)
        {
            if (m_logger != null)
            {
                string args = "out lba, out blocklen";
                m_logger.LogMessage(new UserMessage(UserMessage.Category.Debug, 8, "Bwg.Scsi.Device.ReadCapacity(" + args + ")"));
            }
            blocklen = 0;
            lba = 0;

            using (Command cmd = new Command(ScsiCommandCode.ReadCapacity, 10, 12, Command.CmdDirection.In, 60 * 5))
            {
                CommandStatus st = SendCommand(cmd);
                if (st != CommandStatus.Success)
                    return st;

                lba = cmd.GetBuffer32(0);
                blocklen = cmd.GetBuffer32(4);
            }

            return CommandStatus.Success;
        }
Exemple #6
0
        /// <summary>
        /// This method returns the buffer capacity for the pass through SCSI device. 
        /// </summary>
        /// <param name="blocks">if true, the length and available is given in blocks, otherwise bytes</param>
        /// <param name="length">return vaue, the length of the buffer</param>
        /// <param name="avail">return value, the available space in the buffer</param>
        /// <returns>status of the command</returns>
        public CommandStatus ReadBufferCapacity(bool blocks, out int length, out int avail)
        {
            if (m_logger != null)
            {
                string args = blocks.ToString() + ", out length, out available";
                m_logger.LogMessage(new UserMessage(UserMessage.Category.Debug, 9, "Bwg.Scsi.Device.ReadBufferCapacity(" + args + ")"));
            }
            length = 0;
            avail = 0;

            using (Command cmd = new Command(ScsiCommandCode.ReadBufferCapacity, 10, 12, Command.CmdDirection.In, 60 * 5))
            {
                cmd.SetCDB16(7, 12);
                if (blocks)
                    cmd.SetCDB8(1, 1);
                CommandStatus st = SendCommand(cmd);
                if (st != CommandStatus.Success)
                    return st;

                length = (int)cmd.GetBuffer32(4);
                avail = (int)cmd.GetBuffer32(8);
            }

            return CommandStatus.Success;
        }
Exemple #7
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public CommandStatus GetPerformance(uint lba, PerformanceList.DataType rwtype, PerformanceList.ExceptType extype, out PerformanceList list)
        {
            list = null;

            if (m_logger != null)
            {
                string args = rwtype.ToString() + ", " + extype.ToString() + ", list";
                m_logger.LogMessage(new UserMessage(UserMessage.Category.Debug, 8, "Bwg.Scsi.Device.GetPerformance(" + args + ")"));
            }

            uint len = 0;
            using (Command cmd = new Command(ScsiCommandCode.GetPerformance, 12, 24, Command.CmdDirection.In, 10))
            {
                byte b = 0x10;
                if (rwtype == PerformanceList.DataType.WriteData)
                    b |= 0x04 ;

                b |= (byte)extype;

                cmd.SetCDB8(1, b);
                cmd.SetCDB16(8, 1);

                if (extype == PerformanceList.ExceptType.Entire)
                    cmd.SetCDB32(2, lba);

                CommandStatus st = SendCommand(cmd);
                if (st != CommandStatus.Success)
                    return st;

                len = cmd.GetBuffer32(0);
                len += 4;       // For the length field
            }

            using (Command cmd = new Command(ScsiCommandCode.GetPerformance, 12, (ushort)len, Command.CmdDirection.In, 10))
            {
                byte b = 0x10;
                if (rwtype == PerformanceList.DataType.WriteData)
                    b |= 0x04;

                b |= (byte)extype;

                cmd.SetCDB8(1, b);

                if (extype == PerformanceList.ExceptType.Entire)
                    cmd.SetCDB32(2, lba);

                cmd.SetCDB16(8, (ushort)((len - 8) / 16));

                CommandStatus st = SendCommand(cmd);
                if (st != CommandStatus.Success)
                    return st;

                list = new PerformanceList(cmd.GetBuffer(), cmd.BufferSize);
            }

            return CommandStatus.Success;
        }
Exemple #8
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public CommandStatus GetSpeed(out SpeedDescriptorList list)
        {
            ushort initial_size = 8 + 4 * 16;
            list = null;

            if (m_logger != null)
            {
                string args = string.Empty;
                m_logger.LogMessage(new UserMessage(UserMessage.Category.Debug, 8, "Bwg.Scsi.Device.GetWriteSpeed(" + args + ")"));
            }

            uint len = 0;
            using (Command cmd = new Command(ScsiCommandCode.GetPerformance, 12, initial_size, Command.CmdDirection.In, 10 * 60))
            {
                cmd.SetCDB16(8, (ushort)((initial_size - 8) / 16));
                cmd.SetCDB8(10, 3);

                CommandStatus st = SendCommand(cmd);
                if (st != CommandStatus.Success)
                    return st;

                len = cmd.GetBuffer32(0);
                len += 4;                       // For the length field
            }

            using (Command cmd = new Command(ScsiCommandCode.GetPerformance, 12, (ushort)len, Command.CmdDirection.In, 10 * 60))
            {
                cmd.SetCDB16(8, (ushort)((len - 8) / 16));
                cmd.SetCDB8(10, 3);

                CommandStatus st = SendCommand(cmd);
                if (st != CommandStatus.Success)
                    return st;


                list = new SpeedDescriptorList(cmd.GetBuffer(), cmd.BufferSize);
            }

            return CommandStatus.Success;
        }
Exemple #9
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="type"></param>
        /// <param name="start"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        public CommandStatus GetConfiguration(GetConfigType type, ushort start, out FeatureList result)
        {
            if (m_logger != null)
            {
                string args = type.ToString() + ", " + start.ToString() + ", out result";
                m_logger.LogMessage(new UserMessage(UserMessage.Category.Debug, 8, "Bwg.Scsi.Device.GetConfiguration(" + args + ")"));
            }

            uint len = 0;
            result = null;

            if (type == GetConfigType.Reserved)
                throw new Exception("cannot use reserved value") ;

            using (Command cmd = new Command(ScsiCommandCode.GetConfiguration, 10, 8, Command.CmdDirection.In, 10))
            {
                cmd.SetCDB8(1, (byte)type);
                cmd.SetCDB16(2, start);
                cmd.SetCDB16(7, 8);

                CommandStatus st = SendCommand(cmd);
                if (st != CommandStatus.Success)
                    return st;

                len = cmd.GetBuffer32(0);
                len += 4;       // Add four for the length field
            }

            using (Command cmd = new Command(ScsiCommandCode.GetConfiguration, 10, (ushort)len, Command.CmdDirection.In, 10))
            {
                cmd.SetCDB8(1, (byte)type);
                cmd.SetCDB16(2, start);
                cmd.SetCDB16(7, (ushort)len);

                CommandStatus st = SendCommand(cmd);
                if (st != CommandStatus.Success)
                    return st;

                result = new FeatureList(cmd.GetBuffer(), cmd.BufferSize);
            }

            return CommandStatus.Success;
        }