scsiPhy.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. //void scsiSetDataCount(uint32_t count);
  35. //int scsiFifoReady(void);
  36. // Blocking data transfer
  37. void scsiWrite(const uint8_t* data, uint32_t count);
  38. void scsiRead(uint8_t* data, uint32_t count, int* parityError);
  39. void scsiWriteByte(uint8_t value);
  40. uint8_t scsiReadByte(void);
  41. // Non-blocking data transfer.
  42. // Depending on platform support the start() function may block.
  43. // The start function can be called multiple times, it may internally
  44. // either combine transfers or block until previous transfer completes.
  45. void scsiStartWrite(const uint8_t* data, uint32_t count);
  46. void scsiFinishWrite();
  47. // Query whether the data at pointer has already been read, i.e. buffer can be reused.
  48. // If data is NULL, checks if all writes have completed.
  49. bool scsiIsWriteFinished(const uint8_t *data);
  50. #define s2s_getScsiRateKBs() 0
  51. #ifdef __cplusplus
  52. }
  53. #endif