changer.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #include <u.h>
  2. #include <libc.h>
  3. #include <disk.h>
  4. #include "scsireq.h"
  5. long
  6. SReinitialise(ScsiReq *rp)
  7. {
  8. uchar cmd[6];
  9. memset(cmd, 0, sizeof(cmd));
  10. cmd[0] = ScmdEInitialise;
  11. rp->cmd.p = cmd;
  12. rp->cmd.count = sizeof(cmd);
  13. rp->data.p = cmd;
  14. rp->data.count = 0;
  15. rp->data.write = 1;
  16. return SRrequest(rp);
  17. }
  18. long
  19. SRmmove(ScsiReq *rp, int transport, int source, int destination, int invert)
  20. {
  21. uchar cmd[12];
  22. memset(cmd, 0, sizeof(cmd));
  23. cmd[0] = ScmdMMove;
  24. cmd[2] = transport>>8;
  25. cmd[3] = transport;
  26. cmd[4] = source>>8;
  27. cmd[5] = source;
  28. cmd[6] = destination>>8;
  29. cmd[7] = destination;
  30. cmd[10] = invert & 0x01;
  31. rp->cmd.p = cmd;
  32. rp->cmd.count = sizeof(cmd);
  33. rp->data.p = cmd;
  34. rp->data.count = 0;
  35. rp->data.write = 1;
  36. return SRrequest(rp);
  37. }
  38. long
  39. SRestatus(ScsiReq *rp, uchar type, uchar *list, int nbytes)
  40. {
  41. uchar cmd[12];
  42. memset(cmd, 0, sizeof(cmd));
  43. cmd[0] = ScmdEStatus;
  44. cmd[1] = type & 0x07;
  45. cmd[4] = 0xFF;
  46. cmd[5] = 0xFF;
  47. cmd[7] = nbytes>>16;
  48. cmd[8] = nbytes>>8;
  49. cmd[9] = nbytes;
  50. rp->cmd.p = cmd;
  51. rp->cmd.count = sizeof(cmd);
  52. rp->data.p = list;
  53. rp->data.count = nbytes;
  54. rp->data.write = 0;
  55. return SRrequest(rp);
  56. }