ZuluSCSI_settings.h 4.8 KB

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