disk.h 3.5 KB

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