disk.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright (C) 2013 Michael McMaster <michael@codesrc.com>
  2. //
  3. // This file is part of SCSI2SD.
  4. //
  5. // SCSI2SD is free software: you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation, either version 3 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // SCSI2SD is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. // GNU General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU General Public License
  16. // along with SCSI2SD. If not, see <http://www.gnu.org/licenses/>.
  17. #ifndef DISK_H
  18. #define DISK_H
  19. typedef enum
  20. {
  21. DISK_STARTED = 1, // Controlled via START STOP UNIT
  22. DISK_PRESENT = 2, // SD card is physically present
  23. DISK_INITIALISED = 4, // SD card responded to init sequence
  24. DISK_WP = 8 // Write-protect.
  25. } DISK_STATE;
  26. typedef enum
  27. {
  28. TRANSFER_READ,
  29. TRANSFER_WRITE
  30. } TRANSFER_DIR;
  31. typedef struct
  32. {
  33. int state;
  34. } BlockDevice;
  35. typedef struct
  36. {
  37. int multiBlock; // True if we're using a multi-block SPI transfer.
  38. uint32_t lba;
  39. uint32_t blocks;
  40. uint32_t currentBlock;
  41. } Transfer;
  42. extern BlockDevice blockDev;
  43. extern Transfer transfer;
  44. void scsiDiskInit(void);
  45. void scsiDiskReset(void);
  46. void scsiDiskPoll(void);
  47. int scsiDiskCommand(void);
  48. #endif