ZuluSCSI_disk.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. // Index of image, for when image on-the-fly switching is used for CD drives
  46. int image_index;
  47. // Cue sheet file for CD-ROM images
  48. FsFile cuesheetfile;
  49. // Right-align vendor / product type strings (for Apple)
  50. // Standard SCSI uses left alignment
  51. // This field uses -1 for default when field is not set in .ini
  52. int rightAlignStrings;
  53. // Maximum amount of bytes to prefetch
  54. int prefetchbytes;
  55. // Warning about geometry settings
  56. bool geometrywarningprinted;
  57. };
  58. void scsiDiskResetImages();
  59. bool scsiDiskOpenHDDImage(int target_idx, const char *filename, int scsi_id, int scsi_lun, int blocksize, S2S_CFG_TYPE type = S2S_CFG_FIXED);
  60. void scsiDiskLoadConfig(int target_idx);
  61. // Clear the ROM drive header from flash
  62. bool scsiDiskClearRomDrive();
  63. // Program ROM drive and rename image file
  64. bool scsiDiskProgramRomDrive(const char *filename, int scsi_id, int blocksize, S2S_CFG_TYPE type);
  65. // Check if there is ROM drive configured in microcontroller flash
  66. bool scsiDiskCheckRomDrive();
  67. bool scsiDiskActivateRomDrive();
  68. // Returns true if there is at least one image active
  69. bool scsiDiskCheckAnyImagesConfigured();
  70. // Check if image file name is overridden in config,
  71. // including image index for multi-image CD-ROM emulation
  72. bool scsiDiskGetImageNameFromConfig(image_config_t &img, char *buf, size_t buflen);
  73. // Get pointer to extended image configuration based on target idx
  74. image_config_t &scsiDiskGetImageConfig(int target_idx);
  75. // Start data transfer from disk image to SCSI bus
  76. // Can be called by device type specific command implementations (such as READ CD)
  77. void scsiDiskStartRead(uint32_t lba, uint32_t blocks);
  78. // Start data transfer from SCSI bus to disk image
  79. void scsiDiskStartWrite(uint32_t lba, uint32_t blocks);