BlueSCSI_settings.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /**
  2. * This file is originally part of ZuluSCSI adopted for BlueSCSI
  3. *
  4. * ZuluSCSI™ - Copyright (c) 2023-2025 Rabbit Hole Computing™
  5. * Copyright (c) 2023 Eric Helgeson
  6. *
  7. * This file is licensed under the GPL version 3 or any later version.  
  8. *
  9. * https://www.gnu.org/licenses/gpl-3.0.html
  10. * ----
  11. * This program is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation, either version 3 of the License, or
  14. * (at your option) any later version. 
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. * GNU General Public License for more details. 
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  23. **/
  24. #pragma once
  25. // must be in the same order as speed_grade_strings[] in BlueSCSI_settings.cpp
  26. typedef enum
  27. {
  28. SPEED_GRADE_DEFAULT = 0,
  29. SPEED_GRADE_MAX,
  30. SPEED_GRADE_CUSTOM,
  31. SPEED_GRADE_AUDIO_SPDIF,
  32. SPEED_GRADE_AUDIO_I2S,
  33. SPEED_GRADE_A,
  34. SPEED_GRADE_B,
  35. SPEED_GRADE_C,
  36. SPEED_GRADE_WIFI_RM2
  37. } bluescsi_speed_grade_t;
  38. #ifdef __cplusplus
  39. #include <stdint.h>
  40. #include <stddef.h>
  41. #include <scsi2sd.h>
  42. // Index 8 is the system defaults
  43. // Index 0-7 represent device settings
  44. #define SCSI_SETTINGS_SYS_IDX 8
  45. typedef enum
  46. {
  47. SYS_PRESET_NONE = 0,
  48. SYS_PRESET_MAC,
  49. SYS_PRESET_MACPLUS,
  50. SYS_PRESET_MPC3000,
  51. SYS_PRESET_MEGASTE,
  52. SYS_PRESET_X68000,
  53. SYS_PRESET_X68000_SCSI,
  54. SYS_PRESET_X68000_SASI,
  55. SYS_PRESET_NeXT,
  56. SYS_PRESET_GENERIC,
  57. } scsi_system_preset_t;
  58. typedef enum
  59. {
  60. DEV_PRESET_NONE = 0,
  61. DEV_PRESET_ST32430N
  62. } scsi_device_preset_t;
  63. // This struct should only have new settings added to the end
  64. // as it maybe saved and restored directly from flash memory
  65. typedef struct __attribute__((__packed__)) scsi_system_settings_t
  66. {
  67. // Settings for host compatibility
  68. uint8_t quirks;
  69. uint8_t selectionDelay;
  70. uint8_t maxSyncSpeed;
  71. uint8_t phyMode;
  72. uint16_t initPreDelay;
  73. uint16_t initPostDelay;
  74. bool enableUnitAttention;
  75. bool enableSCSI2;
  76. bool enableSelLatch;
  77. bool mapLunsToIDs;
  78. bool enableParity;
  79. bool useFATAllocSize;
  80. bool enableCDAudio;
  81. uint8_t maxVolume;
  82. bool enableUSBMassStorage;
  83. uint16_t usbMassStorageWaitPeriod;
  84. bool usbMassStoragePresentImages;
  85. bool invertStatusLed;
  86. uint8_t speedGrade; // memory allocation for bluescsi_speed_grade_t enum
  87. } scsi_system_settings_t;
  88. // This struct should only have new setting added to the end
  89. // as it maybe saved and restored directly from flash memory
  90. typedef struct __attribute__((__packed__)) scsi_device_settings_t
  91. {
  92. // Settings that can be set on all or specific device
  93. int prefetchBytes;
  94. uint16_t sectorsPerTrack;
  95. uint16_t headsPerCylinder;
  96. char prodId[16];
  97. char serial[16];
  98. char vendor[8];
  99. char revision[4];
  100. uint16_t vol;
  101. uint8_t deviceType;
  102. uint8_t deviceTypeModifier;
  103. uint8_t ejectButton;
  104. uint32_t ejectBlinkTimes;
  105. uint32_t ejectBlinkPeriod;
  106. bool nameFromImage;
  107. bool rightAlignStrings;
  108. bool reinsertOnInquiry;
  109. bool reinsertAfterEject;
  110. bool startEjected;
  111. bool disableMacSanityCheck;
  112. uint32_t sectorSDBegin;
  113. uint32_t sectorSDEnd;
  114. uint32_t vendorExtensions;
  115. uint32_t blockSize;
  116. } scsi_device_settings_t;
  117. class BlueSCSISettings
  118. {
  119. public:
  120. // Initialize settings for all devices with a preset configuration,
  121. // or return the default config if unknown system type.
  122. // Then overwrite any settings with those in the CONFIGFILE
  123. scsi_system_settings_t *initSystem(const char *presetName);
  124. // Copy any shared device setting done the initSystemSettings as default settings,
  125. // or return the default config if unknown device type.
  126. // Then overwrite any settings with those in the CONFIGFILE
  127. scsi_device_settings_t *initDevice(uint8_t scsiId, S2S_CFG_TYPE type);
  128. // return the system settings struct to read values
  129. scsi_system_settings_t *getSystem();
  130. // return the device settings struct to read values
  131. scsi_device_settings_t *getDevice(uint8_t scsiId);
  132. // return the system preset enum
  133. scsi_system_preset_t getSystemPreset();
  134. // return the system preset name
  135. const char* getSystemPresetName();
  136. // return the device preset enum
  137. scsi_device_preset_t getDevicePreset(uint8_t scsiId);
  138. // return the device preset name
  139. const char* getDevicePresetName(uint8_t scsiId);
  140. // convert string to speed grade
  141. bluescsi_speed_grade_t stringToSpeedGrade(const char *speed_grade_str, size_t length);
  142. const char* getSpeedGradeString();
  143. // see if any SCSI devices have an eject button set
  144. const bool isEjectButtonSet();
  145. protected:
  146. // Set default drive vendor / product info after the image file
  147. // is loaded and the device type is known.
  148. void setDefaultDriveInfo(uint8_t scsiId, const char *presetName, S2S_CFG_TYPE type);
  149. // Settings for the specific device
  150. const char **deviceInitST32430N(uint8_t scsiId);
  151. // Informative name of the preset configuration, or NULL for defaults
  152. scsi_system_preset_t m_sysPreset;
  153. // The last preset is for the device specific under [SCSI] in the CONFIGFILE
  154. // The rest are for corresponding SCSI Ids e.g. [SCSI0] in the CONFIGFILE.
  155. scsi_device_preset_t m_devPreset[S2S_MAX_TARGETS];
  156. // These are setting for host compatibility
  157. scsi_system_settings_t m_sys;
  158. // The last dev will be copied over the other dev scsi Id for device defaults.
  159. // It is set during when the system settings are initialized
  160. scsi_device_settings_t m_dev[S2S_MAX_TARGETS+1];
  161. } ;
  162. extern BlueSCSISettings g_scsi_settings;
  163. #endif // __cplusplus