Disk.cpp File Reference


Detailed Description

Contains code for the disk base class.

Id
Disk.cpp,v 1.31 2008/04/02 13:28:29 iamcamiel Exp

X-1.31 Camiel Vanderhoeven 02-APR-2008 Fixed compiler warnings.

X-1.30 Camiel Vanderhoeven 16-MAR-2008 Always reset dati.read when setting dati.available.

X-1.29 Camiel Vanderhoeven 14-MAR-2008 Formatting.

X-1.28 Camiel Vanderhoeven 14-MAR-2008 1. More meaningful exceptions replace throwing (int) 1. 2. U64 macro replaces X64 macro.

X-1.27 Brian Wheeler 27-FEB-2008 Avoid compiler warnings.

X-1.26 David Leonard 20-FEB-2008 Return SYSTEM RESOURCE FAILURE sense if dato/dati buffer size is exceeded.

X-1.25 Brian Wheeler 20-FEB-2008 Support MSF in READ TOC scsi command.

X-1.24 Brian Wheeler 18-FEB-2008 Added vital product data page 0 (Required for Tru64).

X-1.23 Camiel Vanderhoeven 18-FEB-2008 Removed support for CD-R/RW specific SCSI commands.

X-1.22 Camiel Vanderhoeven 18-FEB-2008 READ CAPACITY returns the number of the last LBA (n-1); not the number of LBA's (n).

X-1.20 Camiel Vanderhoeven 17-FEB-2008 Set up sense data when error occurs.

X-1.19 Camiel Vanderhoeven 17-FEB-2008 Added REQUEST_SENSE scsi command.

X-1.18 Camiel Vanderhoeven 16-FEB-2008 Added READ_LONG scsi command, and support for MODE_SENSE changeable parameter pages.

X-1.17 Camiel Vanderhoeven 21-JAN-2008 OpenVMs doesn't like max 255 sectors.

X-1.16 Camiel Vanderhoeven 16-JAN-2008 Less messages without debugging enabled.

X-1.15 Brian Wheeler 14-JAN-2008 Corrected output from read track info and read toc.

X-1.14 Brian Wheeler/Camiel Vanderhoeven 14-JAN-2008 Added read_track_info command, completed read_toc command.

X-1.13 Camiel Vanderhoeven 13-JAN-2008 Determine best-fitting C/H/S lay-out.

X-1.11 Brian Wheeler 13-JAN-2008 More CD-ROM commands supported.

X-1.10 Camiel Vanderhoeven 12-JAN-2008 Include SCSI engine, because this is common to both SCSI and ATAPI devices.

X-1.9 Camiel Vanderhoeven 09-JAN-2008 Save disk state to state file.

X-1.8 Camiel Vanderhoeven 06-JAN-2008 Set default blocksize to 2048 for cd-rom devices.

X-1.7 Camiel Vanderhoeven 06-JAN-2008 Support changing the block size (required for SCSI, ATAPI).

X-1.6 Camiel Vanderhoeven 02-JAN-2008 Cleanup.

X-1.5 Camiel Vanderhoeven 29-DEC-2007 Fix memory-leak.

X-1.4 Camiel Vanderhoeven 28-DEC-2007 Throw exceptions rather than just exiting when errors occur.

X-1.3 Camiel Vanderhoeven 28-DEC-2007 Keep the compiler happy.

X-1.2 Brian Wheeler 16-DEC-2007 Fixed case of StdAfx.h.

X-1.1 Camiel Vanderhoeven 12-DEC-2007 Initial version in CVS.

Definition in file Disk.cpp.

#include "StdAfx.h"
#include "Disk.h"

Go to the source code of this file.

Defines

#define SCSICMD_TEST_UNIT_READY   0x00
#define SCSICMD_REQUEST_SENSE   0x03
#define SCSICMD_INQUIRY   0x12
#define SCSICMD_READ   0x08
#define SCSICMD_READ_10   0x28
#define SCSICMD_READ_12   0xA8
#define SCSICMD_READ_16   0x88
#define SCSICMD_READ_32   0x7F
#define SCSICMD_READ_LONG   0x3E
#define SCSICMD_READ_CD   0xBE
#define SCSICMD_WRITE   0x0A
#define SCSICMD_WRITE_10   0x2A
#define SCSICMD_WRITE_12   0xAA
#define SCSICMD_WRITE_LONG   0x3F
#define SCSICMD_MODE_SELECT   0x15
#define SCSICMD_MODE_SENSE   0x1a
#define SCSICMD_START_STOP_UNIT   0x1b
#define SCSICMD_PREVENT_ALLOW_REMOVE   0x1e
#define SCSICMD_MODE_SENSE_10   0x5a
#define SCSICMD_SYNCHRONIZE_CACHE   0x35
#define SCSIBLOCKCMD_READ_CAPACITY   0x25
#define SCSICDROM_READ_SUBCHANNEL   0x42
#define SCSICDROM_READ_TOC   0x43
#define SCSICDRRW_FORMAT   0x04
#define SCSICDRRW_READ_DISC_INFO   0x51
#define SCSICDRRW_READ_TRACK_INFO   0x52
#define SCSICDRRW_RESERVE_TRACK   0x53
#define SCSICDRRW_SEND_OPC_INFO   0x54
#define SCSICDRRW_REPAIR_TRACK   0x58
#define SCSICDRRW_READ_MASTER_CUE   0x59
#define SCSICDRRW_CLOSE_TRACK   0x5b
#define SCSICDRRW_READ_BUFFER_CAP   0x5c
#define SCSICDRRW_SEND_CUE_SHEET   0x5d
#define SCSICDRRW_BLANK   0xa1
#define SCSICMD_REWIND   0x01
#define SCSICMD_READ_BLOCK_LIMITS   0x05
#define SCSICMD_SPACE   0x11
#define SCSIMP_VENDOR   0x00
#define SCSIMP_READ_WRITE_ERRREC   0x01
#define SCSIMP_DISCONNECT_RECONNECT   0x02
#define SCSIMP_FORMAT_PARAMS   0x03
#define SCSIMP_RIGID_GEOMETRY   0x04
#define SCSIMP_FLEX_PARAMS   0x05
#define SCSIMP_CACHING   0x08
#define SCSIMP_CDROM_CAP   0x2A
#define SCSI_OK   0
#define SCSI_ILL_CMD   - 1
#define SCSI_LBA_RANGE   - 2
#define SCSI_TOO_BIG   - 3
#define PREGAP_SECTORS   150
#define CD_FRAMES_PER_SEC   75
#define CD_MAX_LSN   450150
#define bin2bcd(x)   ((x / 10) << 4) | (x % 10)
#define MAX_HD   16
 Calculate optimal disk layout.
#define MAX_SEC   50

Functions

static u32 lba2msf (__int64 lba)
 Basic algorithm taken from libcdio for converting lba to msf.
static __int64 get_primes (__int64 value, int pri[54])

Variables

static u32 disk_magic1 = 0xD15D15D1
static u32 disk_magic2 = 0x15D15D5
static int primes_54 [54]
static int pri16 [16][6]


Define Documentation

#define bin2bcd (  )     ((x / 10) << 4) | (x % 10)

Referenced by lba2msf().

#define CD_FRAMES_PER_SEC   75

Referenced by lba2msf().

#define CD_MAX_LSN   450150

Referenced by lba2msf().

#define MAX_HD   16

Calculate optimal disk layout.

..

Definition at line 1712 of file Disk.cpp.

Referenced by CDisk::determine_layout().

#define MAX_SEC   50

Definition at line 1713 of file Disk.cpp.

Referenced by CDisk::determine_layout().

#define PREGAP_SECTORS   150

Referenced by lba2msf().

#define SCSI_ILL_CMD   - 1

Definition at line 591 of file Disk.cpp.

Referenced by CDisk::do_scsi_command(), and CDisk::do_scsi_error().

#define SCSI_LBA_RANGE   - 2

Definition at line 592 of file Disk.cpp.

Referenced by CDisk::do_scsi_command(), and CDisk::do_scsi_error().

#define SCSI_OK   0

Definition at line 590 of file Disk.cpp.

Referenced by CDisk::do_scsi_command(), and CDisk::do_scsi_error().

#define SCSI_TOO_BIG   - 3

Definition at line 593 of file Disk.cpp.

Referenced by CDisk::do_scsi_command(), and CDisk::do_scsi_error().

#define SCSIBLOCKCMD_READ_CAPACITY   0x25

Definition at line 556 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSICDROM_READ_SUBCHANNEL   0x42

Definition at line 559 of file Disk.cpp.

#define SCSICDROM_READ_TOC   0x43

Definition at line 560 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSICDRRW_BLANK   0xa1

Definition at line 573 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSICDRRW_CLOSE_TRACK   0x5b

Definition at line 570 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSICDRRW_FORMAT   0x04

Definition at line 563 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSICDRRW_READ_BUFFER_CAP   0x5c

Definition at line 571 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSICDRRW_READ_DISC_INFO   0x51

Definition at line 564 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSICDRRW_READ_MASTER_CUE   0x59

Definition at line 569 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSICDRRW_READ_TRACK_INFO   0x52

Definition at line 565 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSICDRRW_REPAIR_TRACK   0x58

Definition at line 568 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSICDRRW_RESERVE_TRACK   0x53

Definition at line 566 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSICDRRW_SEND_CUE_SHEET   0x5d

Definition at line 572 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSICDRRW_SEND_OPC_INFO   0x54

Definition at line 567 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSICMD_INQUIRY   0x12

Definition at line 532 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSICMD_MODE_SELECT   0x15

Definition at line 547 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSICMD_MODE_SENSE   0x1a

Definition at line 548 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSICMD_MODE_SENSE_10   0x5a

Definition at line 551 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSICMD_PREVENT_ALLOW_REMOVE   0x1e

Definition at line 550 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSICMD_READ   0x08

Definition at line 534 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSICMD_READ_10   0x28

Definition at line 535 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSICMD_READ_12   0xA8

Definition at line 536 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSICMD_READ_16   0x88

Definition at line 537 of file Disk.cpp.

#define SCSICMD_READ_32   0x7F

Definition at line 538 of file Disk.cpp.

#define SCSICMD_READ_BLOCK_LIMITS   0x05

Definition at line 577 of file Disk.cpp.

#define SCSICMD_READ_CD   0xBE

Definition at line 540 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSICMD_READ_LONG   0x3E

Definition at line 539 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSICMD_REQUEST_SENSE   0x03

Definition at line 531 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSICMD_REWIND   0x01

Definition at line 576 of file Disk.cpp.

#define SCSICMD_SPACE   0x11

Definition at line 578 of file Disk.cpp.

#define SCSICMD_START_STOP_UNIT   0x1b

Definition at line 549 of file Disk.cpp.

#define SCSICMD_SYNCHRONIZE_CACHE   0x35

Definition at line 553 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSICMD_TEST_UNIT_READY   0x00

Definition at line 530 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSICMD_WRITE   0x0A

Definition at line 542 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSICMD_WRITE_10   0x2A

Definition at line 543 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSICMD_WRITE_12   0xAA

Definition at line 544 of file Disk.cpp.

#define SCSICMD_WRITE_LONG   0x3F

Definition at line 545 of file Disk.cpp.

#define SCSIMP_CACHING   0x08

Definition at line 587 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSIMP_CDROM_CAP   0x2A

Definition at line 588 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSIMP_DISCONNECT_RECONNECT   0x02

Definition at line 583 of file Disk.cpp.

#define SCSIMP_FLEX_PARAMS   0x05

Definition at line 586 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSIMP_FORMAT_PARAMS   0x03

Definition at line 584 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSIMP_READ_WRITE_ERRREC   0x01

Definition at line 582 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSIMP_RIGID_GEOMETRY   0x04

Definition at line 585 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().

#define SCSIMP_VENDOR   0x00

Definition at line 581 of file Disk.cpp.

Referenced by CDisk::do_scsi_command().


Function Documentation

static __int64 get_primes ( __int64  value,
int  pri[54] 
) [static]

Definition at line 1693 of file Disk.cpp.

References primes_54.

Referenced by CDisk::determine_layout().

static u32 lba2msf ( __int64  lba  )  [static]

Basic algorithm taken from libcdio for converting lba to msf.

Definition at line 666 of file Disk.cpp.

References bin2bcd, CD_FRAMES_PER_SEC, CD_MAX_LSN, and PREGAP_SECTORS.

Referenced by CDisk::do_scsi_command().


Variable Documentation

u32 disk_magic1 = 0xD15D15D1 [static]

Definition at line 214 of file Disk.cpp.

Referenced by CDisk::RestoreState(), and CDisk::SaveState().

u32 disk_magic2 = 0x15D15D5 [static]

Definition at line 215 of file Disk.cpp.

Referenced by CDisk::RestoreState(), and CDisk::SaveState().

int pri16[16][6] [static]

Initial value:

 { {4,0,0,0, 0, 0}, 
  {0,1,1,0, 0, 0},  
  {1,0,0,1, 0, 0},  
  {0,0,0,0, 0, 1},  
  {2,1,0,0, 0, 0},  
  {0,0,0,0, 1, 0},  
  {1,0,1,0, 0, 0},  
  {0,2,0,0, 0, 0},  
  {3,0,0,0, 0, 0},  
  {0,0,0,1, 0, 0},  
  {1,1,0,0, 0, 0},  
  {0,0,1,0, 0, 0},  
  {2,0,0,0, 0, 0},  
  {0,1,0,0, 0, 0},  
  {1,0,0,0, 0, 0},  
  {0,0,0,0, 0, 0}}

Definition at line 1677 of file Disk.cpp.

Referenced by CDisk::determine_layout().

int primes_54[54] [static]

Initial value:

 { 2,  3,    5,   7,  11,  13,  17,  19,  23,  29,
  31,  37,  41,  43,  47,  53,  59,  61,  67,  71,
  73,  79,  83,  89,  97, 101, 103, 107, 109, 113,
  127, 131, 137, 139, 149, 151, 157, 163, 167, 173,
  179, 181, 191, 193, 197, 199, 211, 223, 227, 229,
  233, 239, 241, 251}

Definition at line 1669 of file Disk.cpp.

Referenced by get_primes().


SourceForge.net Logo
Project space on SourceForge.net