disk.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. ScmdExtread = 0x28, /* extended read (10 bytes) */
  73. ScmdRead16 = 0x88, /* long read (16 bytes) */
  74. ScmdWrite16 = 0x8A, /* long write (16 bytes) */
  75. ScmdExtwrite = 0x2A, /* extended write (10 bytes) */
  76. ScmdExtseek = 0x2B, /* extended seek */
  77. ScmdSynccache = 0x35, /* flush cache */
  78. ScmdRTOC = 0x43, /* read TOC data */
  79. ScmdRdiscinfo = 0x51, /* read disc information */
  80. ScmdRtrackinfo = 0x52, /* read track information */
  81. ScmdReserve = 0x53, /* reserve track */
  82. ScmdBlank = 0xA1, /* blank *-RW media */
  83. ScmdCDpause = 0x4B, /* pause/resume */
  84. ScmdCDstop = 0x4E, /* stop play/scan */
  85. ScmdCDplay = 0xA5, /* play audio */
  86. ScmdCDload = 0xA6, /* load/unload */
  87. ScmdCDscan = 0xBA, /* fast forward/reverse */
  88. ScmdCDstatus = 0xBD, /* mechanism status */
  89. Scmdgetconf = 0x46, /* get configuration */
  90. ScmdEInitialise = 0x07, /* initialise element status */
  91. ScmdMMove = 0xA5, /* move medium */
  92. ScmdEStatus = 0xB8, /* read element status */
  93. ScmdMExchange = 0xA6, /* exchange medium */
  94. ScmdEposition = 0x2B, /* position to element */
  95. ScmdReadDVD = 0xAD, /* read dvd structure */
  96. ScmdReportKey = 0xA4, /* read dvd key */
  97. ScmdSendKey = 0xA3, /* write dvd key */
  98. ScmdClosetracksess= 0x5B,
  99. ScmdRead12 = 0xA8,
  100. ScmdSetcdspeed = 0xBB,
  101. ScmdReadcd = 0xBE,
  102. /* vendor-specific */
  103. ScmdFwaddr = 0xE2, /* first writeable address */
  104. ScmdTreserve = 0xE4, /* reserve track */
  105. ScmdTinfo = 0xE5, /* read track info */
  106. ScmdTwrite = 0xE6, /* write track */
  107. ScmdMload = 0xE7, /* medium load/unload */
  108. ScmdFixation = 0xE9, /* fixation */
  109. };
  110. /* proto file parsing */
  111. typedef void Protoenum(char *new, char *old, Dir *d, void *a);
  112. typedef void Protowarn(char *msg, void *a);
  113. int rdproto(char*, char*, Protoenum*, Protowarn*, void*);