scsiHostPhy.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. // Host side SCSI physical interface.
  22. // Used in initiator to interface to an SCSI drive.
  23. #pragma once
  24. #include <stdint.h>
  25. #include <stdbool.h>
  26. // Request to stop activity and reset the bus
  27. extern volatile int g_scsiHostPhyReset;
  28. // Release bus and pulse RST signal, initialize PHY to host mode.
  29. void scsiHostPhyReset(void);
  30. // Select a device, id 0-7.
  31. // target_id - target device id 0-7
  32. // initiator_id - host device id 0-7
  33. // Returns true if the target answers to selection request.
  34. bool scsiHostPhySelect(int target_id, uint8_t initiator_id);
  35. // Read the current communication phase as signaled by the target
  36. // Matches SCSI_PHASE enumeration from scsi.h.
  37. int scsiHostPhyGetPhase();
  38. // Returns true if the device has asserted REQ signal, i.e. data waiting
  39. bool scsiHostRequestWaiting();
  40. // Blocking data transfer
  41. // These return the actual number of bytes transferred.
  42. uint32_t scsiHostWrite(const uint8_t *data, uint32_t count);
  43. uint32_t scsiHostRead(uint8_t *data, uint32_t count);
  44. // Release bus signals and expect the target to do the same.
  45. // Cycles ACK in case target still holds BSY and REQ.
  46. void scsiHostWaitBusFree();
  47. // Release all bus signals
  48. void scsiHostPhyRelease();