From 61184cf4a82ba63e5dda007a05e800d85c2b7c8c Mon Sep 17 00:00:00 2001 From: Will Sowerbutts Date: Thu, 12 Feb 2015 14:33:57 +0000 Subject: [PATCH] Kernel: readi() now does direct transfers only if CONFIG_LARGE_IO_DIRECT is defined in the platform config.h --- Kernel/inode.c | 9 ++++++--- Kernel/platform-n8vem-mark4/config.h | 2 ++ Kernel/platform-p112/config.h | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Kernel/inode.c b/Kernel/inode.c index 22e883a1..d64195ed 100644 --- a/Kernel/inode.c +++ b/Kernel/inode.c @@ -11,8 +11,6 @@ void readi(inoptr ino, uint8_t flag) unsigned char *bp; uint16_t dev; bool ispipe; - off_t uostash; - usize_t ucstash; dev = ino->c_dev; ispipe = false; @@ -56,8 +54,11 @@ void readi(inoptr ino, uint8_t flag) amount = min(toread, BLKSIZE - (udata.u_offset&BLKMASK)); pblk = bmap(ino, udata.u_offset >> BLKSHIFT, 1); +#ifdef CONFIG_LARGE_IO_DIRECT if(!ispipe && amount == BLKSIZE && !udata.u_sysio && bfind(dev, pblk) == 0){ /* we can transfer direct from disk to the userspace buffer */ + off_t uostash; + usize_t ucstash; uostash = udata.u_offset; /* stash file offset */ ucstash = udata.u_count; /* stash byte count */ udata.u_count = amount; /* transfer one sector */ @@ -65,7 +66,9 @@ void readi(inoptr ino, uint8_t flag) ((*dev_tab[major(dev)].dev_read) (minor(dev), 1, 0)); /* read */ udata.u_offset = uostash; /* restore file offset */ udata.u_count = ucstash; /* restore byte count */ - }else{ + }else +#endif + { /* we transfer through the buffer pool */ if (pblk == NULLBLK) bp = zerobuf(); diff --git a/Kernel/platform-n8vem-mark4/config.h b/Kernel/platform-n8vem-mark4/config.h index 75cb75b2..38bb6ac9 100644 --- a/Kernel/platform-n8vem-mark4/config.h +++ b/Kernel/platform-n8vem-mark4/config.h @@ -12,6 +12,8 @@ #undef CONFIG_CPM_EMU /* Fixed banking */ #define CONFIG_BANK_FIXED +/* Permit large I/O requests to bypass cache and go direct to userspace */ +#define CONFIG_LARGE_IO_DIRECT /* 8 60K banks, 1 is kernel */ #define MAX_MAPS 8 #define MAP_SIZE 0xF000U diff --git a/Kernel/platform-p112/config.h b/Kernel/platform-p112/config.h index 72aa2b56..d1b06d0c 100644 --- a/Kernel/platform-p112/config.h +++ b/Kernel/platform-p112/config.h @@ -12,6 +12,8 @@ #undef CONFIG_CPM_EMU /* Fixed banking */ #define CONFIG_BANK_FIXED +/* Permit large I/O requests to bypass cache and go direct to userspace */ +#define CONFIG_LARGE_IO_DIRECT /* 8 60K banks, 1 is kernel */ #define MAX_MAPS 16 #define MAP_SIZE 0xF000U -- 2.34.1