scsi_accel_rp2040.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Accelerated SCSI subroutines using RP2040 hardware PIO peripheral.
  2. #pragma once
  3. #include <stdint.h>
  4. void scsi_accel_rp2040_init();
  5. // Log current state of DMA & PIO hardware for debugging
  6. void scsi_accel_log_state();
  7. // Set SCSI access mode for synchronous transfers
  8. // Setting syncOffset = 0 enables asynchronous SCSI.
  9. // Setting syncOffset > 0 enables synchronous SCSI.
  10. // Returns false if busy, caller should issue bus reset to recover.
  11. bool scsi_accel_rp2040_setSyncMode(int syncOffset, int syncPeriod);
  12. // Queue a request to write data from the buffer to SCSI bus.
  13. // This function typically returns immediately and the request will complete in background.
  14. // If there are too many queued requests, this function will block until previous request finishes.
  15. void scsi_accel_rp2040_startWrite(const uint8_t* data, uint32_t count, volatile int *resetFlag);
  16. // Query whether the data at pointer has already been read, i.e. buffer can be reused.
  17. // If data is NULL, checks if all writes have completed.
  18. bool scsi_accel_rp2040_isWriteFinished(const uint8_t* data);
  19. // Wait for all write requests to finish and release the bus.
  20. // If resetFlag is non-zero, aborts write immediately.
  21. void scsi_accel_rp2040_finishWrite(volatile int *resetFlag);
  22. // Queue a request to read data from SCSI bus to the buffer.
  23. // This function typically returns immediately and the request will complete in background.
  24. // If there are too many queued requests, this function will block until previous request finishes.
  25. void scsi_accel_rp2040_startRead(uint8_t *data, uint32_t count, int *parityError, volatile int *resetFlag);
  26. // Query whether data at address is part of a queued read request.
  27. // Returns true if there is no outstanding request.
  28. // If data is NULL, checks if all reads have completed.
  29. bool scsi_accel_rp2040_isReadFinished(const uint8_t* data);
  30. // Wait for a read request to complete.
  31. // If buf is not NULL, waits only until the data at data[0] .. data[count-1] is valid.
  32. // If buf is NULL, waits for all read requests to complete.
  33. // If there are no further read requests, releases the bus.
  34. // If resetFlag is non-zero, aborts read immediately.
  35. // If a parity error has been noticed in any buffer since starting the read, parityError is set to 1.
  36. void scsi_accel_rp2040_finishRead(const uint8_t *data, uint32_t count, int *parityError, volatile int *resetFlag);