ZuluSCSI_settings.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. // Index 8 is the system defaults
  26. // Index 0-7 represent device settings
  27. #define SCSI_SETTINGS_SYS_IDX 8
  28. typedef enum
  29. {
  30. SYS_PRESET_NONE = 0,
  31. SYS_PRESET_MAC,
  32. SYS_PRESET_MACPLUS,
  33. SYS_PRESET_MPC3000,
  34. SYS_PRESET_MEGASTE,
  35. SYS_PRESET_X68000
  36. } scsi_system_preset_t;
  37. typedef enum
  38. {
  39. DEV_PRESET_NONE = 0,
  40. DEV_PRESET_ST32430N
  41. } scsi_device_preset_t;
  42. // This struct should only have new settings added to the end
  43. // as it maybe saved and restored directly from flash memory
  44. typedef struct __attribute__((__packed__)) scsi_system_settings_t
  45. {
  46. // Settings for host compatibility
  47. uint8_t quirks;
  48. uint8_t selectionDelay;
  49. uint8_t maxSyncSpeed;
  50. uint8_t phyMode;
  51. uint16_t initPreDelay;
  52. uint16_t initPostDelay;
  53. bool enableUnitAttention;
  54. bool enableSCSI2;
  55. bool enableSelLatch;
  56. bool mapLunsToIDs;
  57. bool enableParity;
  58. bool useFATAllocSize;
  59. } scsi_system_settings_t;
  60. // This struct should only have new setting added to the end
  61. // as it maybe saved and restored directly from flash memory
  62. typedef struct __attribute__((__packed__)) scsi_device_settings_t
  63. {
  64. // Settings that can be set on all or specific device
  65. int prefetchBytes;
  66. uint16_t sectorsPerTrack;
  67. uint16_t headsPerCylinder;
  68. char prodId[16];
  69. char serial[16];
  70. char vendor[8];
  71. char revision[4];
  72. uint16_t vol;
  73. uint8_t deviceType;
  74. uint8_t deviceTypeModifier;
  75. uint8_t ejectButton;
  76. bool nameFromImage;
  77. bool rightAlignStrings;
  78. bool reinsertOnInquiry;
  79. bool reinsertAfterEject;
  80. bool disableMacSanityCheck;
  81. } scsi_device_settings_t;
  82. class ZuluSCSISettings
  83. {
  84. public:
  85. // Initialize settings for all devices with a preset configuration,
  86. // or return the default config if unknown system type.
  87. // Then overwrite any settings with those in the CONFIGFILE
  88. scsi_system_settings_t *initSystem(const char *presetName);
  89. // Copy any shared device setting done the initSystemSettings as default settings,
  90. // or return the default config if unknown device type.
  91. // Then overwrite any settings with those in the CONFIGFILE
  92. scsi_device_settings_t *initDevicePName(uint8_t scsiId, const char *presetName);
  93. scsi_device_settings_t *initDevicePreset(uint8_t scsiId, const scsi_device_preset_t preset);
  94. // return the system settings struct to read values
  95. scsi_system_settings_t *getSystem();
  96. // return the device settings struct to read values
  97. scsi_device_settings_t *getDevice(uint8_t scsiId);
  98. // return the system preset enum
  99. scsi_system_preset_t getSystemPreset();
  100. // return the system preset name
  101. const char* getSystemPresetName();
  102. // return the device preset enum
  103. scsi_device_preset_t getDevicePreset(uint8_t scsiId);
  104. // return the device preset name
  105. const char* getDevicePresetName(uint8_t scsiId);
  106. protected:
  107. // Set default drive vendor / product info after the image file
  108. // is loaded and the device type is known.
  109. void setDefaultDriveInfo(uint8_t scsiId, const char *presetName);
  110. // Settings for the specific device
  111. const char **deviceInitST32430N(uint8_t scsiId);
  112. // Informative name of the preset configuration, or NULL for defaults
  113. // The last presetName is for the System preset name. The rest are for
  114. // corresponding SCSI Ids.
  115. scsi_system_preset_t m_sysPreset;
  116. scsi_device_preset_t m_devPreset[8];
  117. // These are setting for host compatibility
  118. scsi_system_settings_t m_sys;
  119. // The last dev will be copied over the other dev scsi Id for device defaults.
  120. // It is set during when the system settings are initialized
  121. scsi_device_settings_t m_dev[9];
  122. } ;
  123. extern ZuluSCSISettings g_scsi_settings;
  124. #endif // __cplusplus