From 28cb7a23cedf14c3d25da1276f25fda20f55ca74 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 11 Nov 2014 12:37:49 +0000 Subject: [PATCH] 6502: unbitrot --- Kernel/platform-6502test/Makefile | 4 ++-- Kernel/platform-6502test/config.h | 1 + Kernel/platform-6502test/devices.c | 37 ++++++++++++++---------------- Kernel/platform-6502test/devrd.c | 2 +- Kernel/platform-6502test/devtty.c | 18 +++++++++++---- Kernel/platform-6502test/main.c | 3 +++ 6 files changed, 37 insertions(+), 28 deletions(-) diff --git a/Kernel/platform-6502test/Makefile b/Kernel/platform-6502test/Makefile index a3bec2e0..4996fbca 100644 --- a/Kernel/platform-6502test/Makefile +++ b/Kernel/platform-6502test/Makefile @@ -23,10 +23,10 @@ clean: rm -f $(OBJS) $(JUNK) core *~ image: - $(CROSS_LD) -o uzi.bin --mapfile uzi.map -C ld65.cfg crt0.o commonmem.o \ + $(CROSS_LD) -o ../fuzix.bin --mapfile ../uzi.map -C ld65.cfg crt0.o commonmem.o \ p6502.o ../start.o ../version.o ../lowlevel-6502.o \ tricks.o main.o ../timer.o ../kdata.o devrd.o devices.o \ ../devio.o ../filesys.o ../process.o ../inode.o ../syscall_fs.o \ ../syscall_proc.o ../syscall_other.o ../mm.o ../swap.o ../bank16k.o \ - ../tty.o ../devnull.o ../devzero.o ../devproc.o ../devmem.o \ + ../tty.o ../devsys.o ../syscall_fs2.o ../syscall_exec.o \ ../usermem.o devlpr.o devtty.o libc.o diff --git a/Kernel/platform-6502test/config.h b/Kernel/platform-6502test/config.h index 25532a88..b82b50cf 100644 --- a/Kernel/platform-6502test/config.h +++ b/Kernel/platform-6502test/config.h @@ -15,6 +15,7 @@ /* TODO: these need to be defined as the code to flip the banks over */ #define BANK_PROCESS #define BANK_KERNEL +#define CONFIG_BANKS 1 /* We use flexible 16K banks so use the helper */ #define CONFIG_BANK16 diff --git a/Kernel/platform-6502test/devices.c b/Kernel/platform-6502test/devices.c index 4f9e16b4..c4b52863 100644 --- a/Kernel/platform-6502test/devices.c +++ b/Kernel/platform-6502test/devices.c @@ -2,10 +2,7 @@ #include #include #include -#include -#include -#include -#include +#include #include #include #include @@ -14,25 +11,25 @@ struct devsw dev_tab[] = /* The device driver switch table */ { // minor open close read write ioctl // ----------------------------------------------------------------- - /* Memory disk block devices */ - { 0, rd_open, no_close, rd_read, rd_write, no_ioctl }, // 0 /dev/rd0 - - /* devices below here are not mountable (as per NDEVS) */ - { 0, lpr_open, lpr_close, no_rdwr, lpr_write, no_ioctl }, // 1 /dev/lp - { 0, tty_open, tty_close, tty_read, tty_write, tty_ioctl }, // 2 /dev/tty - { 1, tty_open, tty_close, tty_read, tty_write, tty_ioctl }, // 3 /dev/tty1 - { 2, tty_open, tty_close, tty_read, tty_write, tty_ioctl }, // 4 /dev/tty2 - { 0, no_open, no_close, null_read, null_write, no_ioctl }, // 5 /dev/null - { 0, no_open, no_close, zero_read, no_rdwr, no_ioctl }, // 6 /dev/zero - { 0, no_open, no_close, mem_read, mem_write, no_ioctl }, // 7 /dev/kmem - { 0, no_open, no_close, proc_read, no_rdwr, proc_ioctl} // 8 /dev/proc - /* Add more tty channels here if available, incrementing minor# */ + /* 0: /dev/fd Floppy disc block devices */ + { rd_open, no_close, rd_read, rd_write, no_ioctl }, + /* 1: /dev/hd Hard disc block devices (absent) */ + { nxio_open, no_close, no_rdwr, no_rdwr, 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-6502test/devrd.c b/Kernel/platform-6502test/devrd.c index d71fe088..ddbf8b3c 100644 --- a/Kernel/platform-6502test/devrd.c +++ b/Kernel/platform-6502test/devrd.c @@ -25,7 +25,7 @@ static int rd_transfer(bool is_read, uint8_t rawflag) udata.u_error = EIO; return -1; } - block = udata.u_offset.o_blkno; + block = udata.u_offset >> 9; block_xfer = dlen >> 9; map = 1; } else { /* rawflag == 0 */ diff --git a/Kernel/platform-6502test/devtty.c b/Kernel/platform-6502test/devtty.c index e217f60e..2abb5146 100644 --- a/Kernel/platform-6502test/devtty.c +++ b/Kernel/platform-6502test/devtty.c @@ -23,10 +23,6 @@ struct s_queue ttyinq[NUM_DEV_TTY + 1] = { /* ttyinq[0] is never used */ PTY_QUEUES }; -static void nap(void) -{ -} - /* tty1 is the screen tty2 is the serial port */ /* Output for the system console (kprintf etc) */ @@ -46,7 +42,7 @@ bool tty_writeready(uint8_t minor) return c & 1; } -void tty_putc(uint8_t minor, char c) +void tty_putc(uint8_t minor, unsigned char c) { minor; #if 0 @@ -58,6 +54,18 @@ void tty_putc(uint8_t minor, char c) *uarta = c; } +void tty_setup(uint8_t minor) +{ + minor; +} + +/* For the moment */ +int tty_carrier(uint8_t minor) +{ + minor; + return 1; +} + void platform_interrupt(void) { timer_interrupt(); diff --git a/Kernel/platform-6502test/main.c b/Kernel/platform-6502test/main.c index eb356953..75ccedbc 100644 --- a/Kernel/platform-6502test/main.c +++ b/Kernel/platform-6502test/main.c @@ -48,3 +48,6 @@ void pagemap_init(void) pagemap_add(0x86); } +void map_init(void) +{ +} -- 2.34.1