diff --git a/src/ZuluSCSI_disk.cpp b/src/ZuluSCSI_disk.cpp index 93d4b59..a998d21 100644 --- a/src/ZuluSCSI_disk.cpp +++ b/src/ZuluSCSI_disk.cpp @@ -64,6 +64,9 @@ struct image_config_t: public S2S_TargetCfg // Standard SCSI uses left alignment // This field uses -1 for default when field is not set in .ini int rightAlignStrings; + + // Maximum amount of bytes to prefetch + int prefetchbytes; }; static image_config_t g_DiskImages[S2S_MAX_TARGETS]; @@ -262,6 +265,7 @@ static void scsiDiskConfigDefaults(int target_idx) img.sectorsPerTrack = 63; img.headsPerCylinder = 255; img.quirks = S2S_CFG_QUIRKS_NONE; + img.prefetchbytes = PREFETCH_BUFFER_SIZE; memset(img.vendor, 0, sizeof(img.vendor)); memset(img.prodId, 0, sizeof(img.prodId)); memset(img.revision, 0, sizeof(img.revision)); @@ -279,6 +283,7 @@ static void scsiDiskLoadConfig(int target_idx, const char *section) img.headsPerCylinder = ini_getl(section, "HeadsPerCylinder", img.headsPerCylinder, CONFIGFILE); img.quirks = ini_getl(section, "Quirks", img.quirks, CONFIGFILE); img.rightAlignStrings = ini_getbool(section, "RightAlignStrings", -1, CONFIGFILE); + img.prefetchbytes = ini_getl(section, "PrefetchBytes", img.prefetchbytes, CONFIGFILE); char tmp[32]; memset(tmp, 0, sizeof(tmp)); @@ -1101,7 +1106,9 @@ static void diskDataIn() #ifdef PREFETCH_BUFFER_SIZE image_config_t &img = *(image_config_t*)scsiDev.target->cfg; - uint32_t prefetch_sectors = PREFETCH_BUFFER_SIZE / bytesPerSector; + int prefetchbytes = img.prefetchbytes; + if (prefetchbytes > PREFETCH_BUFFER_SIZE) prefetchbytes = PREFETCH_BUFFER_SIZE; + uint32_t prefetch_sectors = prefetchbytes / bytesPerSector; uint32_t img_sector_count = img.file.size() / bytesPerSector; g_scsi_prefetch.sector = transfer.lba + transfer.blocks; g_scsi_prefetch.bytes = 0; diff --git a/zuluscsi.ini b/zuluscsi.ini index 1e0f3cc..7d12a02 100644 --- a/zuluscsi.ini +++ b/zuluscsi.ini @@ -24,6 +24,7 @@ MaxSyncSpeed = 10 # Set to 5 or 10 to enable synchronous SCSI mode, 0 to disable #SectorsPerTrack = 63 #HeadsPerCylinder = 255 #RightAlignStrings = 0 # Right-align SCSI vendor / product strings, defaults on if Quirks = 1 +#PrefetchBytes = 8192 # Maximum number of bytes to prefetch after a read request, 0 to disable # Settings can be overriden for individual devices. [SCSI2]