Skip to content

Commit

Permalink
Make prefetch buffer configurable in .ini (#66, #67)
Browse files Browse the repository at this point in the history
  • Loading branch information
PetteriAimonen authored and J. Morio Sakaguchi committed Aug 11, 2022
1 parent 409790c commit 4cfeb19
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/ZuluSCSI_disk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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));
Expand All @@ -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));
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions zuluscsi.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 4cfeb19

Please sign in to comment.