From f171b5016f6760bab5285ec40af7b82fa4f4bdda Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 8 Jan 2019 23:38:13 +0000 Subject: [PATCH] kernel: allow per major decision on direct to user space This is useful if you've got a hard disk and a floppy. For all current platforms it resolves down to the same code as before but the flexibility is now there if you need it. --- Kernel/inode.c | 6 +++--- Kernel/platform-amstradnc/config.h | 4 ++-- Kernel/platform-coco2/config.h | 2 +- Kernel/platform-coco2cart/config.h | 2 +- Kernel/platform-cromemco/config.h | 2 +- Kernel/platform-dragon-mooh/config.h | 2 +- Kernel/platform-dragon-nx32/config.h | 2 +- Kernel/platform-genie-eg64/config.h | 2 +- Kernel/platform-linc80/config.h | 2 +- Kernel/platform-msx1/config.h | 2 +- Kernel/platform-n8vem-mark4/config.h | 2 +- Kernel/platform-nascom/config.h | 2 +- Kernel/platform-p112/config.h | 2 +- Kernel/platform-pcw8256/config.h | 2 +- Kernel/platform-rc2014-tiny/config.h | 2 +- Kernel/platform-rc2014/config.h | 2 +- Kernel/platform-sbcv2/config.h | 2 +- Kernel/platform-sc108/config.h | 2 +- Kernel/platform-socz80/config.h | 2 +- Kernel/platform-tbblue/config.h | 2 +- Kernel/platform-tc2068/config.h | 2 +- Kernel/platform-trs80/config.h | 2 +- Kernel/platform-trs80m1/config.h | 2 +- Kernel/platform-ubee/config.h | 2 +- Kernel/platform-z280rc/config.h | 2 +- Kernel/platform-z80pack/config.h | 2 +- Kernel/platform-zeta-v2/config.h | 2 +- Kernel/platform-zx+3/config.h | 2 +- Kernel/platform-zxdiv/config.h | 2 +- 29 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Kernel/inode.c b/Kernel/inode.c index 7d7805bc..2e7be071 100644 --- a/Kernel/inode.c +++ b/Kernel/inode.c @@ -5,9 +5,9 @@ #include #if defined(CONFIG_LARGE_IO_DIRECT) -#define read_direct(flag) (!udata.u_sysio) +#define read_direct(dev, flag) (!udata.u_sysio && CONFIG_LARGE_IO_DIRECT(dev)) #elif (NBUFS >= 32) -#define read_direct(flag) (flag & O_DIRECT) +#define read_direct(dev, flag) (flag & O_DIRECT) #endif /* This assumes it's called once before we do I/O. That's wrong and we @@ -95,7 +95,7 @@ void readi(regptr inoptr ino, uint8_t flag) #if !defined(read_direct) bp = NULL; #else - if (pblk != NULLBLK && (bp = bfind(dev, pblk)) == NULL && !ispipe && amount == BLKSIZE && read_direct(flag)) { + if (pblk != NULLBLK && (bp = bfind(dev, pblk)) == NULL && !ispipe && amount == BLKSIZE && read_direct(major(dev), flag)) { /* we can transfer direct from disk to the userspace buffer */ /* FIXME: allow for async queued I/O here. We want an API something like breadasync() that either diff --git a/Kernel/platform-amstradnc/config.h b/Kernel/platform-amstradnc/config.h index ba0009af..19a25108 100644 --- a/Kernel/platform-amstradnc/config.h +++ b/Kernel/platform-amstradnc/config.h @@ -66,7 +66,7 @@ #define BOOTDEVICE 0x0100 /* Only one possible option */ #endif -#define CONFIG_LARGE_IO_DIRECT /* Definite win as our I/O is as fast as a - memcpy! */ +#define CONFIG_LARGE_IO_DIRECT(m) 1 + /* Definite win as our I/O is as fast as a memcpy! */ #define platform_discard() #define platform_copyright() diff --git a/Kernel/platform-coco2/config.h b/Kernel/platform-coco2/config.h index 64c29682..db11fe21 100644 --- a/Kernel/platform-coco2/config.h +++ b/Kernel/platform-coco2/config.h @@ -26,7 +26,7 @@ #define MAX_SWAPS 32 /* Permit large I/O requests to bypass cache and go direct to userspace */ -#define CONFIG_LARGE_IO_DIRECT +#define CONFIG_LARGE_IO_DIRECT(x) 1 /* Video terminal, not a serial tty */ #define CONFIG_VT diff --git a/Kernel/platform-coco2cart/config.h b/Kernel/platform-coco2cart/config.h index adc33cd2..24169c2d 100644 --- a/Kernel/platform-coco2cart/config.h +++ b/Kernel/platform-coco2cart/config.h @@ -26,7 +26,7 @@ extern unsigned int cocoswap_dev; #define MAX_SWAPS 32 /* Permit large I/O requests to bypass cache and go direct to userspace */ -#define CONFIG_LARGE_IO_DIRECT +#define CONFIG_LARGE_IO_DIRECT(x) 1 /* Video terminal, not a serial tty */ #define CONFIG_VT diff --git a/Kernel/platform-cromemco/config.h b/Kernel/platform-cromemco/config.h index f485e484..cb9cf8ca 100644 --- a/Kernel/platform-cromemco/config.h +++ b/Kernel/platform-cromemco/config.h @@ -37,7 +37,7 @@ #define NMOUNTS 4 /* Number of mounts at a time */ #define CONFIG_DYNAMIC_BUFPOOL -#define CONFIG_LARGE_IO_DIRECT +#define CONFIG_LARGE_IO_DIRECT(x) 1 #define platform_copyright() diff --git a/Kernel/platform-dragon-mooh/config.h b/Kernel/platform-dragon-mooh/config.h index da695d2e..ee58ade0 100644 --- a/Kernel/platform-dragon-mooh/config.h +++ b/Kernel/platform-dragon-mooh/config.h @@ -26,7 +26,7 @@ #define MAX_SWAPS 32 /* Permit large I/O requests to bypass cache and go direct to userspace */ -#define CONFIG_LARGE_IO_DIRECT +#define CONFIG_LARGE_IO_DIRECT(x) 1 /* Reclaim the discard space for buffers */ #define CONFIG_DYNAMIC_BUFPOOL diff --git a/Kernel/platform-dragon-nx32/config.h b/Kernel/platform-dragon-nx32/config.h index 66a36b3c..f0dd64ae 100644 --- a/Kernel/platform-dragon-nx32/config.h +++ b/Kernel/platform-dragon-nx32/config.h @@ -23,7 +23,7 @@ #define MAX_SWAPS 32 /* Permit large I/O requests to bypass cache and go direct to userspace */ -#define CONFIG_LARGE_IO_DIRECT +#define CONFIG_LARGE_IO_DIRECT(x) 1 /* Reclaim the discard space for buffers */ #define CONFIG_DYNAMIC_BUFPOOL diff --git a/Kernel/platform-genie-eg64/config.h b/Kernel/platform-genie-eg64/config.h index fc3ca34b..73026496 100644 --- a/Kernel/platform-genie-eg64/config.h +++ b/Kernel/platform-genie-eg64/config.h @@ -21,7 +21,7 @@ #define UDATA_SIZE 0x200 #define MAXTICKS 20 /* Direct I/O support */ -#define CONFIG_LARGE_IO_DIRECT +#define CONFIG_LARGE_IO_DIRECT(x) 1 /* Raw input layer */ #define CONFIG_INPUT /* Full keycode level grabbing supported */ diff --git a/Kernel/platform-linc80/config.h b/Kernel/platform-linc80/config.h index 15e3fbe6..a876a5f1 100644 --- a/Kernel/platform-linc80/config.h +++ b/Kernel/platform-linc80/config.h @@ -11,7 +11,7 @@ #define CONFIG_PARENT_FIRST #define MAXTICKS 20 /* Permit large I/O requests to bypass cache and go direct to userspace */ -#define CONFIG_LARGE_IO_DIRECT +#define CONFIG_LARGE_IO_DIRECT(x) 1 /* One memory bank */ #define CONFIG_BANKS 1 #define TICKSPERSEC 10 /* Ticks per second */ diff --git a/Kernel/platform-msx1/config.h b/Kernel/platform-msx1/config.h index d52337a0..53f0694d 100644 --- a/Kernel/platform-msx1/config.h +++ b/Kernel/platform-msx1/config.h @@ -9,7 +9,7 @@ /* Swap based one process in RAM */ #define CONFIG_SWAP_ONLY /* Permit large I/O requests to bypass cache and go direct to userspace */ -#define CONFIG_LARGE_IO_DIRECT +#define CONFIG_LARGE_IO_DIRECT(x) 1 /* One memory bank */ #define CONFIG_BANKS 1 #define TICKSPERSEC 50 /* Ticks per second */ diff --git a/Kernel/platform-n8vem-mark4/config.h b/Kernel/platform-n8vem-mark4/config.h index 6737bcc6..fb682333 100644 --- a/Kernel/platform-n8vem-mark4/config.h +++ b/Kernel/platform-n8vem-mark4/config.h @@ -13,7 +13,7 @@ /* Fixed banking: 8 x 64K banks, top 4KB is shared with kernel, 60KB-62KB is user memory */ #define CONFIG_BANK_FIXED /* Permit large I/O requests to bypass cache and go direct to userspace */ -#define CONFIG_LARGE_IO_DIRECT +#define CONFIG_LARGE_IO_DIRECT(x) 1 /* 8 60K banks, 1 is kernel */ #define MAX_MAPS 8 #define MAP_SIZE PROGTOP /* WRS: I feel this should be 60KB, but setting it so breaks pagemap_realloc() when exec calls it */ diff --git a/Kernel/platform-nascom/config.h b/Kernel/platform-nascom/config.h index 54016c44..8540a3dd 100644 --- a/Kernel/platform-nascom/config.h +++ b/Kernel/platform-nascom/config.h @@ -66,7 +66,7 @@ #define NMOUNTS 4 /* Number of mounts at a time */ /* Do I/O direct to user space */ -#define CONFIG_LARGE_IO_DIRECT +#define CONFIG_LARGE_IO_DIRECT(x) 1 /* Reclaim the discard space for buffers */ #define CONFIG_DYNAMIC_BUFPOOL diff --git a/Kernel/platform-p112/config.h b/Kernel/platform-p112/config.h index ea706645..fe5cd24e 100644 --- a/Kernel/platform-p112/config.h +++ b/Kernel/platform-p112/config.h @@ -13,7 +13,7 @@ /* Fixed banking: 8 x 64K banks, top 4KB is shared with kernel */ #define CONFIG_BANK_FIXED /* Permit large I/O requests to bypass cache and go direct to userspace */ -#define CONFIG_LARGE_IO_DIRECT +#define CONFIG_LARGE_IO_DIRECT(x) 1 /* 8 60K banks, 1 is kernel */ #define MAX_MAPS 16 #define MAP_SIZE PROGTOP /* 0xF000 breaks pagemap_realloc() / exec() */ diff --git a/Kernel/platform-pcw8256/config.h b/Kernel/platform-pcw8256/config.h index 7f2c507c..666a3341 100644 --- a/Kernel/platform-pcw8256/config.h +++ b/Kernel/platform-pcw8256/config.h @@ -59,7 +59,7 @@ #define NBUFS 6 /* Number of block buffers */ #define NMOUNTS 2 /* Number of mounts at a time */ -#define CONFIG_LARGE_IO_DIRECT +#define CONFIG_LARGE_IO_DIRECT(x) 1 #define swap_map(x) (uint8_t *)(0x4000 + ((x) & 0x3FFF)) /* For now */ diff --git a/Kernel/platform-rc2014-tiny/config.h b/Kernel/platform-rc2014-tiny/config.h index 647af6d5..d9849ac9 100644 --- a/Kernel/platform-rc2014-tiny/config.h +++ b/Kernel/platform-rc2014-tiny/config.h @@ -9,7 +9,7 @@ /* Swap based one process in RAM */ #define CONFIG_SWAP_ONLY /* Permit large I/O requests to bypass cache and go direct to userspace */ -#define CONFIG_LARGE_IO_DIRECT +#define CONFIG_LARGE_IO_DIRECT(x) 1 /* One memory bank */ #define CONFIG_BANKS 1 #define TICKSPERSEC 10 /* Ticks per second */ diff --git a/Kernel/platform-rc2014/config.h b/Kernel/platform-rc2014/config.h index 5f2df831..6de7c589 100644 --- a/Kernel/platform-rc2014/config.h +++ b/Kernel/platform-rc2014/config.h @@ -49,7 +49,7 @@ /* Flexible 4x16K banking */ #define CONFIG_BANK16 /* Permit large I/O requests to bypass cache and go direct to userspace */ -#define CONFIG_LARGE_IO_DIRECT +#define CONFIG_LARGE_IO_DIRECT(x) 1 /* 32 x 16K pages, 3 pages for kernel, whatever the RAM disk uses */ #define MAX_MAPS (32 - 3) diff --git a/Kernel/platform-sbcv2/config.h b/Kernel/platform-sbcv2/config.h index a9cbf6cf..722804ef 100644 --- a/Kernel/platform-sbcv2/config.h +++ b/Kernel/platform-sbcv2/config.h @@ -67,7 +67,7 @@ extern unsigned int swap_dev; the buffer cache. For all small (eg bit) systems this is the right setting as it avoids polluting the small cache with data when it needs to be full of directory and inode information */ -#define CONFIG_LARGE_IO_DIRECT +#define CONFIG_LARGE_IO_DIRECT(x) 1 /* Specify this if there is a real time clock capable of reporting seconds. It will be used to lock the kernel time better to reality. Other details like diff --git a/Kernel/platform-sc108/config.h b/Kernel/platform-sc108/config.h index 0e6957db..349ffb43 100644 --- a/Kernel/platform-sc108/config.h +++ b/Kernel/platform-sc108/config.h @@ -11,7 +11,7 @@ #define CONFIG_PARENT_FIRST #define MAXTICKS 20 /* Permit large I/O requests to bypass cache and go direct to userspace */ -#define CONFIG_LARGE_IO_DIRECT +#define CONFIG_LARGE_IO_DIRECT(x) 1 /* One memory bank */ #define CONFIG_BANKS 1 #define TICKSPERSEC 10 /* Ticks per second */ diff --git a/Kernel/platform-socz80/config.h b/Kernel/platform-socz80/config.h index e879719d..ffb76ac5 100644 --- a/Kernel/platform-socz80/config.h +++ b/Kernel/platform-socz80/config.h @@ -38,7 +38,7 @@ #define MAX_BLKDEV 1 /* Only the one SPI supported for now */ #define SD_DRIVE_COUNT 1 -#define CONFIG_LARGE_IO_DIRECT +#define CONFIG_LARGE_IO_DIRECT(x) 1 #define platform_discard() #define platform_copyright() diff --git a/Kernel/platform-tbblue/config.h b/Kernel/platform-tbblue/config.h index e48399df..81ea424b 100644 --- a/Kernel/platform-tbblue/config.h +++ b/Kernel/platform-tbblue/config.h @@ -62,7 +62,7 @@ the buffer cache. For all small (eg bit) systems this is the right setting as it avoids polluting the small cache with data when it needs to be full of directory and inode information */ -#define CONFIG_LARGE_IO_DIRECT +#define CONFIG_LARGE_IO_DIRECT(x) 1 /* Specify this if there is a real time clock capable of reporting seconds. It will be used to lock the kernel time better to reality. Other details like diff --git a/Kernel/platform-tc2068/config.h b/Kernel/platform-tc2068/config.h index afcbbfbf..fc3d390e 100644 --- a/Kernel/platform-tc2068/config.h +++ b/Kernel/platform-tc2068/config.h @@ -1,5 +1,5 @@ #define CONFIG_IDE -#define CONFIG_LARGE_IO_DIRECT /* We support direct to user I/O */ +#define CONFIG_LARGE_IO_DIRECT(x) 1 /* We support direct to user I/O */ /* Enable to make ^Z dump the inode table for debug */ #undef CONFIG_IDUMP /* Enable to make ^A drop back into the monitor */ diff --git a/Kernel/platform-trs80/config.h b/Kernel/platform-trs80/config.h index 64b21a67..03fccad3 100644 --- a/Kernel/platform-trs80/config.h +++ b/Kernel/platform-trs80/config.h @@ -65,7 +65,7 @@ /* Reclaim the discard space for buffers */ #define CONFIG_DYNAMIC_BUFPOOL /* Use large I/O */ -#define CONFIG_LARGE_IO_DIRECT +#define CONFIG_LARGE_IO_DIRECT(x) 1 extern void platform_discard(void); #define platform_copyright() diff --git a/Kernel/platform-trs80m1/config.h b/Kernel/platform-trs80m1/config.h index 7d468be0..4c23ed83 100644 --- a/Kernel/platform-trs80m1/config.h +++ b/Kernel/platform-trs80m1/config.h @@ -18,7 +18,7 @@ /* Banked memory set up */ #define CONFIG_BANK_FIXED /* Direct I/O support */ -#define CONFIG_LARGE_IO_DIRECT +#define CONFIG_LARGE_IO_DIRECT(x) 1 /* Raw input layer */ #define CONFIG_INPUT /* Full keycode level grabbing supported */ diff --git a/Kernel/platform-ubee/config.h b/Kernel/platform-ubee/config.h index 380daec4..8a81a90a 100644 --- a/Kernel/platform-ubee/config.h +++ b/Kernel/platform-ubee/config.h @@ -25,7 +25,7 @@ #define CONFIG_DYNAMIC_BUFPOOL #define CONFIG_DYNAMIC_SWAP -#define CONFIG_LARGE_IO_DIRECT +#define CONFIG_LARGE_IO_DIRECT(x) 1 #define MAX_BLKDEV 4 diff --git a/Kernel/platform-z280rc/config.h b/Kernel/platform-z280rc/config.h index 19d43f24..6903e3a4 100644 --- a/Kernel/platform-z280rc/config.h +++ b/Kernel/platform-z280rc/config.h @@ -69,7 +69,7 @@ extern unsigned int swap_dev; the buffer cache. For all small (eg bit) systems this is the right setting as it avoids polluting the small cache with data when it needs to be full of directory and inode information */ -#define CONFIG_LARGE_IO_DIRECT +#define CONFIG_LARGE_IO_DIRECT(x) 1 /* Specify this if there is a real time clock capable of reporting seconds. It will be used to lock the kernel time better to reality. Other details like diff --git a/Kernel/platform-z80pack/config.h b/Kernel/platform-z80pack/config.h index 265d3280..aa5f3e27 100644 --- a/Kernel/platform-z80pack/config.h +++ b/Kernel/platform-z80pack/config.h @@ -23,7 +23,7 @@ #define CONFIG_NET #define CONFIG_NET_NATIVE /* Read processes and big I/O direct into process space */ -#define CONFIG_LARGE_IO_DIRECT +#define CONFIG_LARGE_IO_DIRECT(x) 1 /* Banks as reported to user space */ #define CONFIG_BANKS 1 diff --git a/Kernel/platform-zeta-v2/config.h b/Kernel/platform-zeta-v2/config.h index 8ebd6679..723062c3 100644 --- a/Kernel/platform-zeta-v2/config.h +++ b/Kernel/platform-zeta-v2/config.h @@ -13,7 +13,7 @@ /* Flexible 4x16K banking */ #define CONFIG_BANK16 /* Permit large I/O requests to bypass cache and go direct to userspace */ -#define CONFIG_LARGE_IO_DIRECT +#define CONFIG_LARGE_IO_DIRECT(x) 1 /* 32 x 16K pages, 3 pages for kernel, whatever the RAM disk uses */ #define MAX_MAPS (32 - 3 - DEV_RD_RAM_PAGES) diff --git a/Kernel/platform-zx+3/config.h b/Kernel/platform-zx+3/config.h index 97a14716..05995407 100644 --- a/Kernel/platform-zx+3/config.h +++ b/Kernel/platform-zx+3/config.h @@ -1,5 +1,5 @@ #define CONFIG_IDE -#define CONFIG_LARGE_IO_DIRECT /* We support direct to user I/O */ +#define CONFIG_LARGE_IO_DIRECT(x) 1 /* We support direct to user I/O */ #define CONFIG_SD #define SD_DRIVE_COUNT 2 /* Enable to make ^Z dump the inode table for debug */ diff --git a/Kernel/platform-zxdiv/config.h b/Kernel/platform-zxdiv/config.h index e4ed432f..00b862f4 100644 --- a/Kernel/platform-zxdiv/config.h +++ b/Kernel/platform-zxdiv/config.h @@ -1,7 +1,7 @@ #define CONFIG_IDE #define CONFIG_SD #define SD_DRIVE_COUNT 2 -#define CONFIG_LARGE_IO_DIRECT /* We support direct to user I/O */ +#define CONFIG_LARGE_IO_DIRECT(x) 1 /* We support direct to user I/O */ /* Enable to make ^Z dump the inode table for debug */ #undef CONFIG_IDUMP -- 2.34.1