scsiPhy.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Interface to SCSI physical interface.
  2. // This file is derived from scsiPhy.h in SCSI2SD-V6.
  3. #pragma once
  4. #include <stdint.h>
  5. #include <stdbool.h>
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. // Read SCSI status signals
  10. bool scsiStatusATN();
  11. bool scsiStatusBSY();
  12. bool scsiStatusSEL();
  13. // Parity not yet implemented
  14. #define scsiParityError() 0
  15. // Get SCSI selection status.
  16. // This is latched by interrupt when BSY is deasserted while SEL is asserted.
  17. // Lowest 3 bits are the selected target id.
  18. // Highest bits are status information.
  19. #define SCSI_STS_SELECTION_SUCCEEDED 0x40
  20. #define SCSI_STS_SELECTION_ATN 0x80
  21. extern volatile uint8_t g_scsi_sts_selection;
  22. #define SCSI_STS_SELECTED (&g_scsi_sts_selection)
  23. extern volatile uint8_t g_scsi_ctrl_bsy;
  24. #define SCSI_CTRL_BSY (&g_scsi_ctrl_bsy)
  25. // Called when SCSI RST signal has been asserted, should release bus.
  26. void scsiPhyReset(void);
  27. // Change MSG / CD / IO signal states and wait for necessary transition time.
  28. // Phase argument is one of SCSI_PHASE enum values.
  29. void scsiEnterPhase(int phase);
  30. // Change state and return nanosecond delay to wait
  31. uint32_t scsiEnterPhaseImmediate(int phase);
  32. // Release all signals
  33. void scsiEnterBusFree(void);
  34. // Blocking data transfer
  35. void scsiWrite(const uint8_t* data, uint32_t count);
  36. void scsiRead(uint8_t* data, uint32_t count, int* parityError);
  37. void scsiWriteByte(uint8_t value);
  38. uint8_t scsiReadByte(void);
  39. // Non-blocking data transfer.
  40. // Depending on platform support the start() function may block.
  41. // The start function can be called multiple times, it may internally
  42. // either combine transfers or block until previous transfer completes.
  43. void scsiStartWrite(const uint8_t* data, uint32_t count);
  44. void scsiFinishWrite();
  45. // Query whether the data at pointer has already been read, i.e. buffer can be reused.
  46. // If data is NULL, checks if all writes have completed.
  47. bool scsiIsWriteFinished(const uint8_t *data);
  48. #define s2s_getScsiRateKBs() 0
  49. #ifdef __cplusplus
  50. }
  51. #endif