예제 #1
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="submode">subchannel mode</param>
		/// <param name="start"></param>
		/// <param name="length"></param>
		/// <param name="data">the memory area </param>
		/// <param name="timeout">timeout (in seconds)</param>
		/// <returns></returns>
		public CommandStatus ReadCDDA(SubChannelMode submode, uint start, uint length, IntPtr data, int timeout)
		{
			if (m_logger != null)
			{
				string args = start.ToString() + ", " + length.ToString() + ", data";
				m_logger.LogMessage(new UserMessage(UserMessage.Category.Debug, 8, "Bwg.Scsi.Device.ReadCDDA(" + args + ")"));
			}

			byte mode = (byte)(submode == SubChannelMode.QOnly ? 1 : submode == SubChannelMode.RWMode ? 2 : 0);
			int size = 4 * 588 + (submode == SubChannelMode.QOnly ? 16 : submode == SubChannelMode.RWMode ? 96 : 0);

			using (Command cmd = new Command(ScsiCommandCode.ReadCDDA, 12, data, (int)length * size, Command.CmdDirection.In, timeout))
			{
				cmd.SetCDB8(1, 0 << 5); // lun
				cmd.SetCDB32(2, start);
				cmd.SetCDB24(7, length);
				cmd.SetCDB8(10, mode); // Subchannel

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

			return CommandStatus.Success;
		}
예제 #2
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="mainmode">main channel mode</param>
		/// <param name="submode">subchannel mode</param>
		/// <param name="c2mode">C2 errors report mode</param>
		/// <param name="exp">expected sector type</param>
		/// <param name="dap"></param>
		/// <param name="start"></param>
		/// <param name="length"></param>
		/// <param name="data">the memory area </param>
		/// <param name="timeout">timeout (in seconds)</param>
		/// <returns></returns>
		public CommandStatus ReadCDAndSubChannel(MainChannelSelection mainmode, SubChannelMode submode, C2ErrorMode c2mode, byte exp, bool dap, uint start, uint length, IntPtr data, int timeout)
		{
			if (m_logger != null)
			{
				string args = exp.ToString() + ", " + dap.ToString() + ", " + start.ToString() + ", " + length.ToString() + ", data";
				m_logger.LogMessage(new UserMessage(UserMessage.Category.Debug, 8, "Bwg.Scsi.Device.ReadCD(" + args + ")"));
			}

			int size = (4 * 588 +
				(submode == SubChannelMode.QOnly ? 16 : submode == SubChannelMode.RWMode ? 96 : 0) +
				(c2mode == C2ErrorMode.Mode294 ? 294 : c2mode == C2ErrorMode.Mode296 ? 296 : 0)) * (int) length;

			byte mode = (byte) (submode == SubChannelMode.QOnly ? 2 : submode == SubChannelMode.RWMode ? 4 : 0);

			if (exp != 1 && exp != 2 && exp != 3 && exp != 4 && exp != 5)
				return CommandStatus.NotSupported;

			using (Command cmd = new Command(ScsiCommandCode.ReadCd, 12, data, size, Command.CmdDirection.In, timeout))
			{
				byte b = (byte)((exp & 0x07) << 2);
				if (dap)
					b |= 0x02;
                byte byte9 = (byte)(mainmode == MainChannelSelection.UserData ? 0x10 : mainmode == MainChannelSelection.F8h ? 0xF8 : 0);
				if (c2mode == C2ErrorMode.Mode294)
					byte9 |= 0x02;
				else if (c2mode == C2ErrorMode.Mode296)
					byte9 |= 0x04;
				cmd.SetCDB8(1, b);
				cmd.SetCDB32(2, start);
				cmd.SetCDB24(6, length);
				cmd.SetCDB8(9, byte9); // User data + possibly c2 errors
				cmd.SetCDB8(10, mode);          // Subchannel
                CommandStatus st = SendCommand(cmd);
				if (st != CommandStatus.Success)
					return st;
			}

			return CommandStatus.Success;
		}