disk.h 3.5 KB

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