ZuluSCSI_settings.h 4.7 KB

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