changer.c 1.5 KB

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