BlueSCSI_disk.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /**
  2. * SCSI2SD V6 - Copyright (C) 2013 Michael McMaster <michael@codesrc.com>
  3. * Copyright (C) 2014 Doug Brown <doug@downtowndougbrown.com
  4. * ZuluSCSI™ - Copyright (c) 2022 Rabbit Hole Computing™
  5. *
  6. * It is derived from disk.h in SCSI2SD V6.
  7. *
  8. * This file is licensed under the GPL version 3 or any later version. 
  9. *
  10. * https://www.gnu.org/licenses/gpl-3.0.html
  11. * ----
  12. * This program is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation, either version 3 of the License, or
  15. * (at your option) any later version. 
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. * GNU General Public License for more details. 
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  24. **/
  25. // SCSI disk access routines
  26. // Implements both SCSI2SD V6 disk.h functions and some extra.
  27. #pragma once
  28. #include <stdint.h>
  29. #include <scsi2sd.h>
  30. #include <scsiPhy.h>
  31. #include "ImageBackingStore.h"
  32. extern "C" {
  33. #include <disk.h>
  34. #include <config.h>
  35. #include <scsi.h>
  36. }
  37. // Extended configuration stored alongside the normal SCSI2SD target information
  38. struct image_config_t: public S2S_TargetCfg
  39. {
  40. ImageBackingStore file;
  41. // For CD-ROM drive ejection
  42. bool ejected;
  43. uint8_t cdrom_events;
  44. bool reinsert_on_inquiry;
  45. // For tape drive emulation, current position in blocks
  46. uint32_t tape_pos;
  47. // Index of image, for when image on-the-fly switching is used for CD drives
  48. int image_index;
  49. // Cue sheet file for CD-ROM images
  50. FsFile cuesheetfile;
  51. // Right-align vendor / product type strings (for Apple)
  52. // Standard SCSI uses left alignment
  53. // This field uses -1 for default when field is not set in .ini
  54. int rightAlignStrings;
  55. // Maximum amount of bytes to prefetch
  56. int prefetchbytes;
  57. // Warning about geometry settings
  58. bool geometrywarningprinted;
  59. };
  60. // Reset all image configuration to empty reset state, close all images.
  61. void scsiDiskResetImages();
  62. // Close any files opened from SD card (prepare for remounting SD)
  63. void scsiDiskCloseSDCardImages();
  64. bool scsiDiskOpenHDDImage(int target_idx, const char *filename, int scsi_id, int scsi_lun, int blocksize, S2S_CFG_TYPE type = S2S_CFG_FIXED);
  65. void scsiDiskLoadConfig(int target_idx);
  66. // Clear the ROM drive header from flash
  67. bool scsiDiskClearRomDrive();
  68. // Program ROM drive and rename image file
  69. bool scsiDiskProgramRomDrive(const char *filename, int scsi_id, int blocksize, S2S_CFG_TYPE type);
  70. // Check if there is ROM drive configured in microcontroller flash
  71. bool scsiDiskCheckRomDrive();
  72. bool scsiDiskActivateRomDrive();
  73. // Returns true if there is at least one image active
  74. bool scsiDiskCheckAnyImagesConfigured();
  75. // Check if image file name is overridden in config,
  76. // including image index for multi-image CD-ROM emulation
  77. bool scsiDiskGetImageNameFromConfig(image_config_t &img, char *buf, size_t buflen);
  78. // Get pointer to extended image configuration based on target idx
  79. image_config_t &scsiDiskGetImageConfig(int target_idx);
  80. // Start data transfer from disk image to SCSI bus
  81. // Can be called by device type specific command implementations (such as READ CD)
  82. void scsiDiskStartRead(uint32_t lba, uint32_t blocks);
  83. // Start data transfer from SCSI bus to disk image
  84. void scsiDiskStartWrite(uint32_t lba, uint32_t blocks);