ZuluSCSI_initiator.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * ZuluSCSI™ - Copyright (c) 2022 Rabbit Hole Computing™
  3. *
  4. * ZuluSCSI™ firmware is licensed under the GPL version 3 or any later version. 
  5. *
  6. * https://www.gnu.org/licenses/gpl-3.0.html
  7. * ----
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version. 
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. * GNU General Public License for more details. 
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  20. **/
  21. // Main state machine for SCSI initiator mode
  22. #pragma once
  23. #include <stdint.h>
  24. #include <stdlib.h>
  25. #define SCSI_DEVICE_TYPE_CD 0x5
  26. #define SCSI_DEVICE_TYPE_MO 0x7
  27. #define SCSI_DEVICE_TYPE_DIRECT_ACCESS 0x0
  28. void scsiInitiatorInit();
  29. void scsiInitiatorMainLoop();
  30. // Select target and execute SCSI command
  31. int scsiInitiatorRunCommand(int target_id,
  32. const uint8_t *command, size_t cmdLen,
  33. uint8_t *bufIn, size_t bufInLen,
  34. const uint8_t *bufOut, size_t bufOutLen,
  35. bool returnDataPhase = false);
  36. // Execute READ CAPACITY command
  37. bool scsiInitiatorReadCapacity(int target_id, uint32_t *sectorcount, uint32_t *sectorsize);
  38. // Execute REQUEST SENSE command to get more information about error status
  39. bool scsiRequestSense(int target_id, uint8_t *sense_key);
  40. // Execute UNIT START STOP command to load/unload media
  41. bool scsiStartStopUnit(int target_id, bool start);
  42. // Execute INQUIRY command
  43. bool scsiInquiry(int target_id, uint8_t inquiry_data[36]);
  44. // Execute TEST UNIT READY command and handle unit attention state
  45. bool scsiTestUnitReady(int target_id);
  46. // Read a block of data from SCSI device and write to file on SD card
  47. class FsFile;
  48. bool scsiInitiatorReadDataToFile(int target_id, uint32_t start_sector, uint32_t sectorcount, uint32_t sectorsize,
  49. FsFile &file);