ZuluSCSI_initiator.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. void scsiInitiatorInit();
  26. void scsiInitiatorMainLoop();
  27. // Select target and execute SCSI command
  28. int scsiInitiatorRunCommand(int target_id,
  29. const uint8_t *command, size_t cmdLen,
  30. uint8_t *bufIn, size_t bufInLen,
  31. const uint8_t *bufOut, size_t bufOutLen,
  32. bool returnDataPhase = false);
  33. // Execute READ CAPACITY command
  34. bool scsiInitiatorReadCapacity(int target_id, uint32_t *sectorcount, uint32_t *sectorsize);
  35. // Execute REQUEST SENSE command to get more information about error status
  36. bool scsiRequestSense(int target_id, uint8_t *sense_key);
  37. // Execute UNIT START STOP command to load/unload media
  38. bool scsiStartStopUnit(int target_id, bool start);
  39. // Execute INQUIRY command
  40. bool scsiInquiry(int target_id, uint8_t inquiry_data[36]);
  41. // Execute TEST UNIT READY command and handle unit attention state
  42. bool scsiTestUnitReady(int target_id);
  43. // Read a block of data from SCSI device and write to file on SD card
  44. class FsFile;
  45. bool scsiInitiatorReadDataToFile(int target_id, uint32_t start_sector, uint32_t sectorcount, uint32_t sectorsize,
  46. FsFile &file);