ZuluSCSI_settings.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. } scsi_system_settings_t;
  64. // This struct should only have new setting added to the end
  65. // as it maybe saved and restored directly from flash memory
  66. typedef struct __attribute__((__packed__)) scsi_device_settings_t
  67. {
  68. // Settings that can be set on all or specific device
  69. int prefetchBytes;
  70. uint16_t sectorsPerTrack;
  71. uint16_t headsPerCylinder;
  72. char prodId[16];
  73. char serial[16];
  74. char vendor[8];
  75. char revision[4];
  76. uint16_t vol;
  77. uint8_t deviceType;
  78. uint8_t deviceTypeModifier;
  79. uint8_t ejectButton;
  80. bool nameFromImage;
  81. bool rightAlignStrings;
  82. bool reinsertOnInquiry;
  83. bool reinsertAfterEject;
  84. bool disableMacSanityCheck;
  85. uint32_t sectorSDBegin;
  86. uint32_t sectorSDEnd;
  87. uint32_t vendorExtensions;
  88. uint32_t blockSize;
  89. } scsi_device_settings_t;
  90. class ZuluSCSISettings
  91. {
  92. public:
  93. // Initialize settings for all devices with a preset configuration,
  94. // or return the default config if unknown system type.
  95. // Then overwrite any settings with those in the CONFIGFILE
  96. scsi_system_settings_t *initSystem(const char *presetName);
  97. // Copy any shared device setting done the initSystemSettings as default settings,
  98. // or return the default config if unknown device type.
  99. // Then overwrite any settings with those in the CONFIGFILE
  100. scsi_device_settings_t *initDevice(uint8_t scsiId, S2S_CFG_TYPE type);
  101. // return the system settings struct to read values
  102. scsi_system_settings_t *getSystem();
  103. // return the device settings struct to read values
  104. scsi_device_settings_t *getDevice(uint8_t scsiId);
  105. // return the system preset enum
  106. scsi_system_preset_t getSystemPreset();
  107. // return the system preset name
  108. const char* getSystemPresetName();
  109. // return the device preset enum
  110. scsi_device_preset_t getDevicePreset(uint8_t scsiId);
  111. // return the device preset name
  112. const char* getDevicePresetName(uint8_t scsiId);
  113. protected:
  114. // Set default drive vendor / product info after the image file
  115. // is loaded and the device type is known.
  116. void setDefaultDriveInfo(uint8_t scsiId, const char *presetName, S2S_CFG_TYPE type);
  117. // Settings for the specific device
  118. const char **deviceInitST32430N(uint8_t scsiId);
  119. // Informative name of the preset configuration, or NULL for defaults
  120. scsi_system_preset_t m_sysPreset;
  121. // The last preset is for the device specific under [SCSI] in the CONFIGFILE
  122. // The rest are for corresponding SCSI Ids e.g. [SCSI0] in the CONFIGFILE.
  123. scsi_device_preset_t m_devPreset[8];
  124. // These are setting for host compatibility
  125. scsi_system_settings_t m_sys;
  126. // The last dev will be copied over the other dev scsi Id for device defaults.
  127. // It is set during when the system settings are initialized
  128. scsi_device_settings_t m_dev[9];
  129. } ;
  130. extern ZuluSCSISettings g_scsi_settings;
  131. #endif // __cplusplus