disk.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. /* SCSI interface */
  10. typedef struct Scsi Scsi;
  11. struct Scsi {
  12. QLock QLock;
  13. char* inquire;
  14. int rawfd;
  15. int nchange;
  16. unsigned long changetime;
  17. };
  18. enum {
  19. Sread = 0,
  20. Swrite,
  21. Snone,
  22. };
  23. char* scsierror(int, int);
  24. int scsicmd(Scsi*, uint8_t*, int, void*, int, int);
  25. int scsi(Scsi*, uint8_t*, int, void*, int, int);
  26. Scsi* openscsi(char*);
  27. void closescsi(Scsi*);
  28. int scsiready(Scsi*);
  29. extern int scsiverbose;
  30. /* disk partition interface */
  31. typedef struct Disk Disk;
  32. struct Disk {
  33. char *prefix;
  34. char *part;
  35. int fd;
  36. int wfd;
  37. int ctlfd;
  38. int rdonly;
  39. int type;
  40. int64_t secs;
  41. int64_t secsize;
  42. int64_t size;
  43. int64_t offset; /* within larger disk, perhaps */
  44. int width; /* of disk size in bytes as decimal string */
  45. int c;
  46. int h;
  47. int s;
  48. int chssrc;
  49. };
  50. Disk* opendisk(char*, int, int);
  51. enum {
  52. Tfile = 0,
  53. Tsd,
  54. Tfloppy,
  55. Gpart = 0, /* partition info source */
  56. Gdisk,
  57. Gguess,
  58. };
  59. enum { /* SCSI command codes */
  60. ScmdTur = 0x00, /* test unit ready */
  61. ScmdRewind = 0x01, /* rezero/rewind */
  62. ScmdRsense = 0x03, /* request sense */
  63. ScmdFormat = 0x04, /* format unit */
  64. ScmdRblimits = 0x05, /* read block limits */
  65. ScmdRead = 0x08, /* read */
  66. ScmdWrite = 0x0A, /* write */
  67. ScmdSeek = 0x0B, /* seek */
  68. ScmdFmark = 0x10, /* write filemarks */
  69. ScmdSpace = 0x11, /* space forward/backward */
  70. ScmdInq = 0x12, /* inquiry */
  71. ScmdMselect6 = 0x15, /* mode select */
  72. ScmdMselect10 = 0x55, /* mode select */
  73. ScmdMsense6 = 0x1A, /* mode sense */
  74. ScmdMsense10 = 0x5A, /* mode sense */
  75. ScmdStart = 0x1B, /* start/stop unit */
  76. ScmdRcapacity = 0x25, /* read capacity */
  77. ScmdRcapacity16 = 0x9e, /* long read capacity */
  78. ScmdRformatcap = 0x23, /* read format capacity */
  79. ScmdExtread = 0x28, /* extended read (10 bytes) */
  80. ScmdRead16 = 0x88, /* long read (16 bytes) */
  81. ScmdExtwrite = 0x2A, /* extended write (10 bytes) */
  82. ScmdExtwritever = 0x2E, /* extended write and verify (10) */
  83. ScmdWrite16 = 0x8A, /* long write (16 bytes) */
  84. ScmdExtseek = 0x2B, /* extended seek */
  85. ScmdSynccache = 0x35, /* flush cache */
  86. ScmdRTOC = 0x43, /* read TOC data */
  87. ScmdRdiscinfo = 0x51, /* read disc information */
  88. ScmdRtrackinfo = 0x52, /* read track information */
  89. ScmdReserve = 0x53, /* reserve track */
  90. ScmdBlank = 0xA1, /* blank *-RW media */
  91. ScmdCDpause = 0x4B, /* pause/resume */
  92. ScmdCDstop = 0x4E, /* stop play/scan */
  93. ScmdCDplay = 0xA5, /* play audio */
  94. ScmdCDload = 0xA6, /* load/unload */
  95. ScmdCDscan = 0xBA, /* fast forward/reverse */
  96. ScmdCDstatus = 0xBD, /* mechanism status */
  97. Scmdgetconf = 0x46, /* get configuration */
  98. ScmdEInitialise = 0x07, /* initialise element status */
  99. ScmdMMove = 0xA5, /* move medium */
  100. ScmdEStatus = 0xB8, /* read element status */
  101. ScmdMExchange = 0xA6, /* exchange medium */
  102. ScmdEposition = 0x2B, /* position to element */
  103. ScmdReadDVD = 0xAD, /* read dvd structure */
  104. ScmdReportKey = 0xA4, /* read dvd key */
  105. ScmdSendKey = 0xA3, /* write dvd key */
  106. ScmdClosetracksess= 0x5B,
  107. ScmdRead12 = 0xA8,
  108. ScmdSetcdspeed = 0xBB,
  109. ScmdReadcd = 0xBE,
  110. /* vendor-specific */
  111. ScmdFwaddr = 0xE2, /* first writeable address */
  112. ScmdTreserve = 0xE4, /* reserve track */
  113. ScmdTinfo = 0xE5, /* read track info */
  114. ScmdTwrite = 0xE6, /* write track */
  115. ScmdMload = 0xE7, /* medium load/unload */
  116. ScmdFixation = 0xE9, /* fixation */
  117. };
  118. /* proto file parsing */
  119. typedef void Protoenum(char *new, char *old, Dir *d, void *a);
  120. typedef void Protowarn(char *msg, void *a);
  121. int rdproto(char*, char*, Protoenum*, Protowarn*, void*);