|  | @@ -9,6 +9,7 @@
 | 
											
												
													
														|  |  #include "BlueSCSI_disk.h"
 |  |  #include "BlueSCSI_disk.h"
 | 
											
												
													
														|  |  #include "BlueSCSI_log.h"
 |  |  #include "BlueSCSI_log.h"
 | 
											
												
													
														|  |  #include "BlueSCSI_config.h"
 |  |  #include "BlueSCSI_config.h"
 | 
											
												
													
														|  | 
 |  | +#include "BlueSCSI_presets.h"
 | 
											
												
													
														|  |  #include <minIni.h>
 |  |  #include <minIni.h>
 | 
											
												
													
														|  |  #include <string.h>
 |  |  #include <string.h>
 | 
											
												
													
														|  |  #include <strings.h>
 |  |  #include <strings.h>
 | 
											
										
											
												
													
														|  | @@ -829,13 +830,18 @@ static void checkDiskGeometryDivisible(image_config_t &img)
 | 
											
												
													
														|  |  // Set target configuration to default values
 |  |  // Set target configuration to default values
 | 
											
												
													
														|  |  static void scsiDiskConfigDefaults(int target_idx)
 |  |  static void scsiDiskConfigDefaults(int target_idx)
 | 
											
												
													
														|  |  {
 |  |  {
 | 
											
												
													
														|  | 
 |  | +    // Get default values from system preset, if any
 | 
											
												
													
														|  | 
 |  | +    char presetName[32];
 | 
											
												
													
														|  | 
 |  | +    ini_gets("SCSI", "System", "", presetName, sizeof(presetName), CONFIGFILE);
 | 
											
												
													
														|  | 
 |  | +    preset_config_t defaults = getSystemPreset(presetName);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      image_config_t &img = g_DiskImages[target_idx];
 |  |      image_config_t &img = g_DiskImages[target_idx];
 | 
											
												
													
														|  |      img.deviceType = S2S_CFG_FIXED;
 |  |      img.deviceType = S2S_CFG_FIXED;
 | 
											
												
													
														|  | -    img.deviceTypeModifier = 0;
 |  | 
 | 
											
												
													
														|  | -    img.sectorsPerTrack = 63;
 |  | 
 | 
											
												
													
														|  | -    img.headsPerCylinder = 255;
 |  | 
 | 
											
												
													
														|  | -    img.quirks = S2S_CFG_QUIRKS_APPLE;
 |  | 
 | 
											
												
													
														|  | -    img.prefetchbytes = PREFETCH_BUFFER_SIZE;
 |  | 
 | 
											
												
													
														|  | 
 |  | +    img.deviceTypeModifier = defaults.deviceTypeModifier;
 | 
											
												
													
														|  | 
 |  | +    img.sectorsPerTrack = defaults.sectorsPerTrack;
 | 
											
												
													
														|  | 
 |  | +    img.headsPerCylinder = defaults.headsPerCylinder;
 | 
											
												
													
														|  | 
 |  | +    img.quirks = defaults.quirks;
 | 
											
												
													
														|  | 
 |  | +    img.prefetchbytes = defaults.prefetchBytes;
 | 
											
												
													
														|  |      memset(img.vendor, 0, sizeof(img.vendor));
 |  |      memset(img.vendor, 0, sizeof(img.vendor));
 | 
											
												
													
														|  |      memset(img.prodId, 0, sizeof(img.prodId));
 |  |      memset(img.prodId, 0, sizeof(img.prodId));
 | 
											
												
													
														|  |      memset(img.revision, 0, sizeof(img.revision));
 |  |      memset(img.revision, 0, sizeof(img.revision));
 | 
											
										
											
												
													
														|  | @@ -943,21 +949,35 @@ void s2s_configInit(S2S_BoardCfg* config)
 | 
											
												
													
														|  |          log("Config file " CONFIGFILE " not found, using defaults");
 |  |          log("Config file " CONFIGFILE " not found, using defaults");
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +    // Get default values from system preset, if any
 | 
											
												
													
														|  | 
 |  | +    char presetName[32];
 | 
											
												
													
														|  | 
 |  | +    ini_gets("SCSI", "System", "", presetName, sizeof(presetName), CONFIGFILE);
 | 
											
												
													
														|  | 
 |  | +    preset_config_t defaults = getSystemPreset(presetName);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    if (defaults.presetName)
 | 
											
												
													
														|  | 
 |  | +    {
 | 
											
												
													
														|  | 
 |  | +        log("Active configuration (using system preset \"", defaults.presetName, "\"):");
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +    else
 | 
											
												
													
														|  | 
 |  | +    {
 | 
											
												
													
														|  | 
 |  | +        log("Active configuration:");
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      memset(config, 0, sizeof(S2S_BoardCfg));
 |  |      memset(config, 0, sizeof(S2S_BoardCfg));
 | 
											
												
													
														|  |      memcpy(config->magic, "BCFG", 4);
 |  |      memcpy(config->magic, "BCFG", 4);
 | 
											
												
													
														|  |      config->flags = 0;
 |  |      config->flags = 0;
 | 
											
												
													
														|  |      config->startupDelay = 0;
 |  |      config->startupDelay = 0;
 | 
											
												
													
														|  | -    config->selectionDelay = ini_getl("SCSI", "SelectionDelay", 255, CONFIGFILE);
 |  | 
 | 
											
												
													
														|  | 
 |  | +    config->selectionDelay = ini_getl("SCSI", "SelectionDelay", defaults.selectionDelay, CONFIGFILE);
 | 
											
												
													
														|  |      config->flags6 = 0;
 |  |      config->flags6 = 0;
 | 
											
												
													
														|  |      config->scsiSpeed = PLATFORM_MAX_SCSI_SPEED;
 |  |      config->scsiSpeed = PLATFORM_MAX_SCSI_SPEED;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    int maxSyncSpeed = ini_getl("SCSI", "MaxSyncSpeed", 10, CONFIGFILE);
 |  | 
 | 
											
												
													
														|  | 
 |  | +    int maxSyncSpeed = ini_getl("SCSI", "MaxSyncSpeed", defaults.maxSyncSpeed, CONFIGFILE);
 | 
											
												
													
														|  |      if (maxSyncSpeed < 5 && config->scsiSpeed > S2S_CFG_SPEED_ASYNC_50)
 |  |      if (maxSyncSpeed < 5 && config->scsiSpeed > S2S_CFG_SPEED_ASYNC_50)
 | 
											
												
													
														|  |          config->scsiSpeed = S2S_CFG_SPEED_ASYNC_50;
 |  |          config->scsiSpeed = S2S_CFG_SPEED_ASYNC_50;
 | 
											
												
													
														|  |      else if (maxSyncSpeed < 10 && config->scsiSpeed > S2S_CFG_SPEED_SYNC_5)
 |  |      else if (maxSyncSpeed < 10 && config->scsiSpeed > S2S_CFG_SPEED_SYNC_5)
 | 
											
												
													
														|  |          config->scsiSpeed = S2S_CFG_SPEED_SYNC_5;
 |  |          config->scsiSpeed = S2S_CFG_SPEED_SYNC_5;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    if ((int)config->selectionDelay == 255)
 |  | 
 | 
											
												
													
														|  | 
 |  | +    if ((int)config->selectionDelay == defaults.selectionDelay)
 | 
											
												
													
														|  |      {
 |  |      {
 | 
											
												
													
														|  |          debuglog("-- SelectionDelay: ", (int)config->selectionDelay);
 |  |          debuglog("-- SelectionDelay: ", (int)config->selectionDelay);
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
										
											
												
													
														|  | @@ -966,7 +986,7 @@ void s2s_configInit(S2S_BoardCfg* config)
 | 
											
												
													
														|  |          log("-- SelectionDelay: ", (int)config->selectionDelay);
 |  |          log("-- SelectionDelay: ", (int)config->selectionDelay);
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    if (ini_getbool("SCSI", "EnableUnitAttention", false, CONFIGFILE))
 |  | 
 | 
											
												
													
														|  | 
 |  | +    if (ini_getbool("SCSI", "EnableUnitAttention", defaults.enableUnitAttention, CONFIGFILE))
 | 
											
												
													
														|  |      {
 |  |      {
 | 
											
												
													
														|  |          log("-- EnableUnitAttention is on");
 |  |          log("-- EnableUnitAttention is on");
 | 
											
												
													
														|  |          config->flags |= S2S_CFG_ENABLE_UNIT_ATTENTION;
 |  |          config->flags |= S2S_CFG_ENABLE_UNIT_ATTENTION;
 | 
											
										
											
												
													
														|  | @@ -976,7 +996,7 @@ void s2s_configInit(S2S_BoardCfg* config)
 | 
											
												
													
														|  |          debuglog("-- EnableUnitAttention is off");
 |  |          debuglog("-- EnableUnitAttention is off");
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    if (ini_getbool("SCSI", "EnableSCSI2", true, CONFIGFILE))
 |  | 
 | 
											
												
													
														|  | 
 |  | +    if (ini_getbool("SCSI", "EnableSCSI2", defaults.enableSCSI2, CONFIGFILE))
 | 
											
												
													
														|  |      {
 |  |      {
 | 
											
												
													
														|  |          debuglog("-- EnableSCSI2 is on");
 |  |          debuglog("-- EnableSCSI2 is on");
 | 
											
												
													
														|  |          config->flags |= S2S_CFG_ENABLE_SCSI2;
 |  |          config->flags |= S2S_CFG_ENABLE_SCSI2;
 | 
											
										
											
												
													
														|  | @@ -986,7 +1006,7 @@ void s2s_configInit(S2S_BoardCfg* config)
 | 
											
												
													
														|  |          log("-- EnableSCSI2 is off");
 |  |          log("-- EnableSCSI2 is off");
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    if (ini_getbool("SCSI", "EnableSelLatch", false, CONFIGFILE))
 |  | 
 | 
											
												
													
														|  | 
 |  | +    if (ini_getbool("SCSI", "EnableSelLatch", defaults.enableSelLatch, CONFIGFILE))
 | 
											
												
													
														|  |      {
 |  |      {
 | 
											
												
													
														|  |          log("-- EnableSelLatch is on");
 |  |          log("-- EnableSelLatch is on");
 | 
											
												
													
														|  |          config->flags |= S2S_CFG_ENABLE_SEL_LATCH;
 |  |          config->flags |= S2S_CFG_ENABLE_SEL_LATCH;
 | 
											
										
											
												
													
														|  | @@ -996,7 +1016,7 @@ void s2s_configInit(S2S_BoardCfg* config)
 | 
											
												
													
														|  |          debuglog("-- EnableSelLatch is off");
 |  |          debuglog("-- EnableSelLatch is off");
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    if (ini_getbool("SCSI", "MapLunsToIDs", false, CONFIGFILE))
 |  | 
 | 
											
												
													
														|  | 
 |  | +    if (ini_getbool("SCSI", "MapLunsToIDs", defaults.mapLunsToIDs, CONFIGFILE))
 | 
											
												
													
														|  |      {
 |  |      {
 | 
											
												
													
														|  |          log("-- MapLunsToIDs is on");
 |  |          log("-- MapLunsToIDs is on");
 | 
											
												
													
														|  |          config->flags |= S2S_CFG_MAP_LUNS_TO_IDS;
 |  |          config->flags |= S2S_CFG_MAP_LUNS_TO_IDS;
 | 
											
										
											
												
													
														|  | @@ -1011,7 +1031,7 @@ void s2s_configInit(S2S_BoardCfg* config)
 | 
											
												
													
														|  |          log("-- Debug is enabled");
 |  |          log("-- Debug is enabled");
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    if (ini_getbool("SCSI", "Parity", true, CONFIGFILE))
 |  | 
 | 
											
												
													
														|  | 
 |  | +    if (ini_getbool("SCSI", "Parity", defaults.enableParity, CONFIGFILE))
 | 
											
												
													
														|  |      {
 |  |      {
 | 
											
												
													
														|  |          debuglog("-- Parity is enabled");
 |  |          debuglog("-- Parity is enabled");
 | 
											
												
													
														|  |          config->flags |= S2S_CFG_ENABLE_PARITY;
 |  |          config->flags |= S2S_CFG_ENABLE_PARITY;
 | 
											
										
											
												
													
														|  | @@ -1021,7 +1041,7 @@ void s2s_configInit(S2S_BoardCfg* config)
 | 
											
												
													
														|  |          log("-- Parity is disabled");
 |  |          log("-- Parity is disabled");
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    if (ini_getbool("SCSI", "ReinsertCDOnInquiry", 0, CONFIGFILE))
 |  | 
 | 
											
												
													
														|  | 
 |  | +    if (ini_getbool("SCSI", "ReinsertCDOnInquiry", defaults.reinsertOnInquiry, CONFIGFILE))
 | 
											
												
													
														|  |      {
 |  |      {
 | 
											
												
													
														|  |          log("-- ReinsertCDOnInquiry is enabled");
 |  |          log("-- ReinsertCDOnInquiry is enabled");
 | 
											
												
													
														|  |      }
 |  |      }
 |