BlueSCSI_initiator.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Main state machine for SCSI initiator mode
  2. #pragma once
  3. #include <stdint.h>
  4. #include <stdlib.h>
  5. #define DEVICE_TYPE_CD 5
  6. #define DEVICE_TYPE_DIRECT_ACCESS 0
  7. void scsiInitiatorInit();
  8. void scsiInitiatorMainLoop();
  9. // Select target and execute SCSI command
  10. int scsiInitiatorRunCommand(int target_id,
  11. const uint8_t *command, size_t cmdLen,
  12. uint8_t *bufIn, size_t bufInLen,
  13. const uint8_t *bufOut, size_t bufOutLen,
  14. bool returnDataPhase = false);
  15. // Execute READ CAPACITY command
  16. bool scsiInitiatorReadCapacity(int target_id, uint32_t *sectorcount, uint32_t *sectorsize);
  17. // Execute REQUEST SENSE command to get more information about error status
  18. bool scsiRequestSense(int target_id, uint8_t *sense_key);
  19. // Execute UNIT START STOP command to load/unload media
  20. bool scsiStartStopUnit(int target_id, bool start);
  21. // Execute INQUIRY command
  22. bool scsiInquiry(int target_id, uint8_t inquiry_data[36]);
  23. // Execute TEST UNIT READY command and handle unit attention state
  24. bool scsiTestUnitReady(int target_id);
  25. // Read a block of data from SCSI device and write to file on SD card
  26. class FsFile;
  27. bool scsiInitiatorReadDataToFile(int target_id, uint32_t start_sector, uint32_t sectorcount, uint32_t sectorsize,
  28. FsFile &file);