From f33026d934da966c23f5955709bde4d134450d11 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sun, 23 Nov 2014 00:39:56 +0000 Subject: [PATCH] z80pack-lite: bring up to date a bit more --- Kernel/platform-z80pack-lite/devices.c | 47 ++++++++++---------------- Kernel/platform-z80pack-lite/devtty.c | 4 +-- 2 files changed, 20 insertions(+), 31 deletions(-) diff --git a/Kernel/platform-z80pack-lite/devices.c b/Kernel/platform-z80pack-lite/devices.c index 02b96ec4..09783023 100644 --- a/Kernel/platform-z80pack-lite/devices.c +++ b/Kernel/platform-z80pack-lite/devices.c @@ -1,46 +1,35 @@ #include #include #include +#include #include -#include -#include -#include -#include +#include #include #include - struct devsw dev_tab[] = /* The device driver switch table */ { // minor open close read write ioctl // ----------------------------------------------------------------- - /* Floppy disc block devices */ - { 0, fd_open, no_close, fd_read, fd_write, no_ioctl }, // 0 /dev/fd0 - { 1, fd_open, no_close, fd_read, fd_write, no_ioctl }, // 1 /dev/fd1 - { 2, fd_open, no_close, fd_read, fd_write, no_ioctl }, // 2 /dev/rd2 - { 3, fd_open, no_close, fd_read, fd_write, no_ioctl }, // 3 /dev/rd3 - /* Hard disc block devices */ - { 8, fd_open, no_close, fd_read, fd_write, no_ioctl }, // 4 /dev/sd0 - { 9, fd_open, no_close, fd_read, fd_write, no_ioctl }, // 5 /dev/sd1 - { 10, fd_open, no_close, fd_read, fd_write, no_ioctl }, // 6 /dev/sd2 - /* Devices below here are not mountable (as per NDEVS) */ - { 0, lpr_open, lpr_close, no_rdwr, lpr_write, no_ioctl }, // 7 /dev/lp - { 0, tty_open, tty_close, tty_read, tty_write, tty_ioctl }, // 8 /dev/tty - { 1, tty_open, tty_close, tty_read, tty_write, tty_ioctl }, // 9 /dev/tty1 - { 2, tty_open, tty_close, tty_read, tty_write, tty_ioctl }, // 10 /dev/tty2 - { 3, tty_open, tty_close, tty_read, tty_write, tty_ioctl }, // 11 /dev/tty3 - { 4, tty_open, tty_close, tty_read, tty_write, tty_ioctl }, // 12 /dev/tty4 - { 0, no_open, no_close, null_read, null_write, no_ioctl }, // 13 /dev/null - { 0, no_open, no_close, zero_read, no_rdwr, no_ioctl }, // 14 /dev/zero - { 0, no_open, no_close, mem_read, mem_write, no_ioctl }, // 15 /dev/kmem - { 0, no_open, no_close, proc_read, no_rdwr, proc_ioctl} // 16 /dev/proc - /* Add more tty channels here if available, incrementing minor# */ + /* 0: /dev/fd Floppy disc block devices */ + { fd_open, no_close, fd_read, fd_write, no_ioctl }, + /* 1: /dev/hd Hard disc block devices (absent) */ + { hd_open, no_close, hd_read, hd_write, no_ioctl }, + /* 2: /dev/tty TTY devices */ + { tty_open, tty_close, tty_read, tty_write, tty_ioctl }, + /* 3: /dev/lpr Printer devices */ + { lpr_open, lpr_close, no_rdwr, lpr_write, no_ioctl }, + /* 4: /dev/mem etc System devices (one offs) */ + { no_open, no_close, sys_read, sys_write, sys_ioctl }, + /* Pack to 7 with nxio if adding private devices and start at 8 */ }; -bool validdev(uint8_t dev) +bool validdev(uint16_t dev) { - if(dev >= (sizeof(dev_tab)/sizeof(struct devsw))) - return false; + /* This is a bit uglier than needed but the right hand side is + a constant this way */ + if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255) + return false; else return true; } diff --git a/Kernel/platform-z80pack-lite/devtty.c b/Kernel/platform-z80pack-lite/devtty.c index f8487793..3bc8980a 100644 --- a/Kernel/platform-z80pack-lite/devtty.c +++ b/Kernel/platform-z80pack-lite/devtty.c @@ -19,7 +19,7 @@ char tbuf3[TTYSIZ]; struct s_queue ttyinq[NUM_DEV_TTY+1] = { /* ttyinq[0] is never used */ { NULL, NULL, NULL, 0, 0, 0 }, { tbuf1, tbuf1, tbuf1, TTYSIZ, 0, TTYSIZ/2 }, - { tbuf2, tbuf2, tbuf2, TTYSIZ, 0, TTYSIZ/2 } + { tbuf2, tbuf2, tbuf2, TTYSIZ, 0, TTYSIZ/2 }, { tbuf3, tbuf3, tbuf3, TTYSIZ, 0, TTYSIZ/2 } }; @@ -45,7 +45,7 @@ static bool tty_writeready(uint8_t minor) return s & 2; } -void tty_putc(uint8_t minor, char c) +void tty_putc(uint8_t minor, unsigned char c) { if (minor == 1) tty1data = c; -- 2.34.1