ZuluSCSI_settings.h 4.7 KB

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