scsi_accel_rp2040.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. // Accelerated SCSI subroutines using RP2040 hardware PIO peripheral.
  22. #pragma once
  23. #include <stdint.h>
  24. void scsi_accel_rp2040_init();
  25. // Set SCSI access mode for synchronous transfers
  26. // Setting syncOffset = 0 enables asynchronous SCSI.
  27. // Setting syncOffset > 0 enables synchronous SCSI.
  28. void scsi_accel_rp2040_setSyncMode(int syncOffset, int syncPeriod);
  29. // Queue a request to write data from the buffer to SCSI bus.
  30. // This function typically returns immediately and the request will complete in background.
  31. // If there are too many queued requests, this function will block until previous request finishes.
  32. void scsi_accel_rp2040_startWrite(const uint8_t* data, uint32_t count, volatile int *resetFlag);
  33. // Query whether the data at pointer has already been read, i.e. buffer can be reused.
  34. // If data is NULL, checks if all writes have completed.
  35. bool scsi_accel_rp2040_isWriteFinished(const uint8_t* data);
  36. // Wait for all write requests to finish and release the bus.
  37. // If resetFlag is non-zero, aborts write immediately.
  38. void scsi_accel_rp2040_finishWrite(volatile int *resetFlag);
  39. // Queue a request to read data from SCSI bus to the buffer.
  40. // This function typically returns immediately and the request will complete in background.
  41. // If there are too many queued requests, this function will block until previous request finishes.
  42. void scsi_accel_rp2040_startRead(uint8_t *data, uint32_t count, int *parityError, volatile int *resetFlag);
  43. // Query whether data at address is part of a queued read request.
  44. // Returns true if there is no outstanding request.
  45. // If data is NULL, checks if all reads have completed.
  46. bool scsi_accel_rp2040_isReadFinished(const uint8_t* data);
  47. // Wait for a read request to complete.
  48. // If buf is not NULL, waits only until the data at data[0] .. data[count-1] is valid.
  49. // If buf is NULL, waits for all read requests to complete.
  50. // If there are no further read requests, releases the bus.
  51. // If resetFlag is non-zero, aborts read immediately.
  52. // If a parity error has been noticed in any buffer since starting the read, parityError is set to 1.
  53. void scsi_accel_rp2040_finishRead(const uint8_t *data, uint32_t count, int *parityError, volatile int *resetFlag);