Skip to content

Commit

Permalink
Don't invalidate cache on writes unless operating on current cached d…
Browse files Browse the repository at this point in the history
…rive

Set TRACKSEGSZ 0 unless CONFIG_TRACK_CACHE or DF
Indentation cleanup
  • Loading branch information
ghaerr committed Nov 5, 2024
1 parent 152aaae commit 9222e05
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 26 deletions.
45 changes: 23 additions & 22 deletions elks/arch/i86/drivers/block/bioshd.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,25 +560,25 @@ static int BFPROC do_readwrite(struct drive_infot *drivep, sector_t start, char
drive, start, this_pass);

#pragma GCC diagnostic ignored "-Wshift-count-overflow"
usedmaseg = seg >> 16; /* will be nonzero only if XMS configured and XMS buffer */
if (!usedmaseg) {
/* check for 64k I/O overlap */
physaddr = (seg << 4) + (unsigned int)buf;
end = this_pass * drivep->sector_size - 1;
usedmaseg = (physaddr + end < physaddr);
debug_blk("bioshd: %p:%p = %p count %d wrap %d\n",
(unsigned int)seg, buf, physaddr, this_pass, usedmaseg);
}
if (usedmaseg) {
segment = DMASEG; /* if xms buffer use DMASEG*/
offset = 0;
if (cmd == WRITE) /* copy xms buffer down before write*/
xms_fmemcpyw(0, DMASEG, buf, seg, this_pass*(drivep->sector_size >> 1));
//set_cache_invalid(); /* don't invalidate cache - not shared */
} else {
segment = (seg_t)seg;
offset = (unsigned) buf;
}
usedmaseg = seg >> 16; /* will be nonzero only if XMS configured and XMS buffer */
if (!usedmaseg) {
/* check for 64k I/O overlap */
physaddr = (seg << 4) + (unsigned int)buf;
end = this_pass * drivep->sector_size - 1;
usedmaseg = (physaddr + end < physaddr);
debug_blk("bioshd: %p:%p = %p count %d wrap %d\n",
(unsigned int)seg, buf, physaddr, this_pass, usedmaseg);
}
if (usedmaseg) {
segment = DMASEG; /* if xms buffer use DMASEG*/
offset = 0;
if (cmd == WRITE) /* copy xms buffer down before write*/
xms_fmemcpyw(0, DMASEG, buf, seg, this_pass*(drivep->sector_size >> 1));
//set_cache_invalid(); /* don't invalidate cache - not shared */
} else {
segment = (seg_t)seg;
offset = (unsigned) buf;
}
errs = MAX_ERRS; /* BIOS disk reads should be retried at least five times */
do {
debug_cache("%s%s%d CHS %d/%d/%d count %d\n",
Expand All @@ -598,15 +598,16 @@ static int BFPROC do_readwrite(struct drive_infot *drivep, sector_t start, char
} while (error && --errs); /* On error, retry up to MAX_ERRS times */
last_drive = drivep;

if (cmd == WRITE && drivep == cache_drive)
set_cache_invalid(); /* cache not updated on write so invalidate */

if (error) return 0; /* error message in blk.h */

if (usedmaseg) {
if (cmd == READ) /* copy DMASEG up to xms*/
xms_fmemcpyw(buf, seg, 0, DMASEG, this_pass*(drivep->sector_size >> 1));
//set_cache_invalid(); /* don't invalidate cache - not shared */
}
if (cmd == WRITE && drivep == cache_drive)
set_cache_invalid(); /* cache isn't updated on writes */
return this_pass;
}

Expand Down Expand Up @@ -689,8 +690,8 @@ static int BFPROC do_cache_read(struct drive_infot *drivep, sector_t start, char
do_readtrack(drivep, start); /* read whole track*/
if (cache_valid(drivep, start, buf, seg)) /* try cache again*/
return 1;
//set_cache_invalid(); /* old code invalidated cache on failure */
}
set_cache_invalid();
return 0;
}
#endif
Expand Down
10 changes: 7 additions & 3 deletions elks/include/linuxmt/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,21 @@
* outside its track cache; thus the complicated defines below.
*/

#if defined(CONFIG_BLK_DEV_BFD) || defined(CONFIG_BLK_DEV_BHD)
#if defined(CONFIG_BLK_DEV_BFD) || defined(CONFIG_BLK_DEV_BHD) /* BIOS driver */
#define DMASEGSZ 0x0400 /* BLOCK_SIZE (1024) for external XMS/DMA buffer */
#else
#define DMASEGSZ 0 /* no external XMS/DMA buffer */
#endif

#if defined(CONFIG_BLK_DEV_BFD) || defined(CONFIG_BLK_DEV_BHD) || defined(CONFIG_BLK_FD)
#ifdef CONFIG_TRACK_CACHE /* floppy track buffer in low mem */
#define TRACKSEGSZ 0x2400 /* SECTOR_SIZE * 18 (9216) */
# define TRACKSEGSZ 0x2400 /* SECTOR_SIZE * 18 (9216) */
#else
#define TRACKSEGSZ 0x0400 /* BLOCK_SIZE (1024) */
# ifdef CONFIG_BLK_FD
# define TRACKSEGSZ 0x0400 /* DF driver requires DMASEG internal to TRACKSEG */
# else
# define TRACKSEGSZ 0 /* no TRACKSEG buffer */
# endif
#endif
#define TRACKSEG (DMASEG+(DMASEGSZ>>4))
#define DMASEGEND (DMASEG+(DMASEGSZ>>4)+(TRACKSEGSZ>>4))
Expand Down
2 changes: 1 addition & 1 deletion emu86.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ exec emu86 -w 0xe0000 -f image/rom-8088.bin -w 0x80000 -f image/romfs-8088.bin $
# For ELKS Full ROM Configuration:
# ELKS must be configured minimally with 'cp emu86-rom-full.config .config'
# This adds MINIX/FAT filesytems with BIOS driver
#exec emu86 -w 0xe0000 -f rom-8088.bin -w 0x80000 -f image/romfs.bin -I image/fd1440.img ${1+"$@"}
#exec emu86 -w 0xe0000 -f image/rom-8088.bin -w 0x80000 -f image/romfs-8088.bin -I image/fd1440.img ${1+"$@"}

# For ELKS disk image Configuration:
# ELKS must be configured with 'cp emu86-disk.config .config'
Expand Down

0 comments on commit 9222e05

Please sign in to comment.