scsi_accel_target.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /**
  2. * ZuluSCSI™ - Copyright (c) 2022-2025 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. // Log current state of DMA & PIO hardware for debugging
  26. void scsi_accel_log_state();
  27. // Set SCSI access mode for synchronous transfers
  28. // Setting syncOffset = 0 enables asynchronous SCSI.
  29. // Setting syncOffset > 0 enables synchronous SCSI.
  30. // Returns false if busy, caller should issue bus reset to recover.
  31. bool scsi_accel_rp2040_setSyncMode(int syncOffset, int syncPeriod);
  32. // Queue a request to write data from the buffer to SCSI bus.
  33. // This function typically returns immediately and the request will complete in background.
  34. // If there are too many queued requests, this function will block until previous request finishes.
  35. void scsi_accel_rp2040_startWrite(const uint8_t* data, uint32_t count, volatile int *resetFlag);
  36. // Query whether the data at pointer has already been read, i.e. buffer can be reused.
  37. // If data is NULL, checks if all writes have completed.
  38. bool scsi_accel_rp2040_isWriteFinished(const uint8_t* data);
  39. // Wait for all write requests to finish and release the bus.
  40. // If resetFlag is non-zero, aborts write immediately.
  41. void scsi_accel_rp2040_finishWrite(volatile int *resetFlag);
  42. // Queue a request to read data from SCSI bus to the buffer.
  43. // This function typically returns immediately and the request will complete in background.
  44. // If there are too many queued requests, this function will block until previous request finishes.
  45. void scsi_accel_rp2040_startRead(uint8_t *data, uint32_t count, int *parityError, volatile int *resetFlag);
  46. // Query whether data at address is part of a queued read request.
  47. // Returns true if there is no outstanding request.
  48. // If data is NULL, checks if all reads have completed.
  49. bool scsi_accel_rp2040_isReadFinished(const uint8_t* data);
  50. // Wait for a read request to complete.
  51. // If buf is not NULL, waits only until the data at data[0] .. data[count-1] is valid.
  52. // If buf is NULL, waits for all read requests to complete.
  53. // If there are no further read requests, releases the bus.
  54. // If resetFlag is non-zero, aborts read immediately.
  55. // If a parity error has been noticed in any buffer since starting the read, parityError is set to 1.
  56. void scsi_accel_rp2040_finishRead(const uint8_t *data, uint32_t count, int *parityError, volatile int *resetFlag);