ROMDrive.h 954 B

1234567891011121314151617181920212223242526272829303132
  1. /* Access layer to microcontroller internal flash ROM drive storage.
  2. * Can store a small disk image.
  3. */
  4. #pragma once
  5. #include <stdint.h>
  6. #include <unistd.h>
  7. #include <scsi2sd.h>
  8. // Header used for storing the rom drive parameters in flash
  9. struct romdrive_hdr_t {
  10. char magic[8]; // "ROMDRIVE"
  11. int scsi_id;
  12. uint32_t imagesize;
  13. uint32_t blocksize;
  14. S2S_CFG_TYPE drivetype;
  15. uint32_t reserved[32];
  16. };
  17. // Return true if ROM drive is found.
  18. // If hdr is not NULL, it will receive the ROM drive header information.
  19. // If flash is empty, returns false.
  20. bool romDriveCheckPresent(romdrive_hdr_t *hdr = nullptr);
  21. // Clear any existing ROM drive, returning flash to empty state
  22. bool romDriveClear();
  23. // Program ROM drive image to flash
  24. bool romDriveProgram(const char *filename, int scsi_id, int blocksize, S2S_CFG_TYPE type);
  25. // Read data from rom drive main data area
  26. bool romDriveRead(uint8_t *buf, uint32_t start, uint32_t count);