From: Alan Cox Date: Mon, 10 Nov 2014 01:00:50 +0000 (+0000) Subject: 6809: unbitrot versus changes we've made elsewhere X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=3931d82d827ee226383afa525ae23c466d8e25b7;p=FUZIX.git 6809: unbitrot versus changes we've made elsewhere Still not a "real" port, but it compiles again --- diff --git a/Kernel/Makefile b/Kernel/Makefile index f98050e9..145ea389 100644 --- a/Kernel/Makefile +++ b/Kernel/Makefile @@ -1,9 +1,9 @@ -TARGET_LIST = platform-nc100 platform-micropack platform-pcw8256 platform-socz80 platform-spec3 platform-trs80 platform-z80pack platform-z80pack-lite +TARGET_LIST = platform-nc100 platform-micropack platform-pcw8256 platform-socz80 platform-zx128 platform-trs80 platform-z80pack platform-z80pack-lite -export TARGET= msx2 -export CPU = z80 -#export TARGET = 6809test -#export CPU = 6809 +#export TARGET= zx128 +#export CPU = z80 +export TARGET = 6809test +export CPU = 6809 #export TARGET = 6502test #export CPU = 6502 export VERSION = "0.1" @@ -47,6 +47,7 @@ export CROSS_CC = m6809-unknown-gcc #export CROSS_CCOPTS=-Wall -O2 -I$(ROOT_DIR)/cpu-6809 -I$(ROOT_DIR)/platform-$(TARGET) -I$(ROOT_DIR)/include export CROSS_CCOPTS=-c -Wall -O2 -I$(ROOT_DIR)/cpu-6809 -I$(ROOT_DIR)/platform-$(TARGET) -I$(ROOT_DIR)/include export ASOPTS= +export BINEXT = .o endif ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) @@ -156,7 +157,7 @@ fuzix.bin: uzi.ihx tools/analysemap tools/memhogs tools/binman tools/binman uzi.tmp uzi.map fuzix.bin $(MAKE) -C platform-$(TARGET) image else -uzi.bin: target $(OBJS) +fuzix.bin: target $(OBJS) $(MAKE) -C platform-$(TARGET) image endif diff --git a/Kernel/include/kernel.h b/Kernel/include/kernel.h index 017d5a0b..c5e5fec3 100644 --- a/Kernel/include/kernel.h +++ b/Kernel/include/kernel.h @@ -536,7 +536,7 @@ void idump(void); bool validdev(uint16_t dev); /* usermem.c */ -usize_t valaddr(char *base, usize_t size); +usize_t valaddr(const char *base, usize_t size); int uget(const void *userspace_source, void *dest, usize_t count); int16_t ugetc(const void *userspace_source); uint16_t ugetw(const void *userspace_source); @@ -685,7 +685,7 @@ void updoff(void); int stcpy(inoptr ino, char *buf); bool rargs (char **userspace_argv, struct s_argblk *argbuf); char **wargs(char *userspace_ptr, struct s_argblk *argbuf, int *cnt); -extern int unlinki(inoptr ino, inoptr pino, char *fname); +extern int16_t unlinki(inoptr ino, inoptr pino, char *fname); /* timer.c */ void rdtime(time_t *tloc); diff --git a/Kernel/platform-6809test/Makefile b/Kernel/platform-6809test/Makefile index 3f75014b..8a2495b1 100644 --- a/Kernel/platform-6809test/Makefile +++ b/Kernel/platform-6809test/Makefile @@ -17,16 +17,16 @@ $(COBJS): %$(BINEXT): %.c $(CROSS_CC) $(CROSS_CCOPTS) -c $< $(AOBJS): %$(BINEXT): %.s - $(CROSS_AS) $(ASOPTS) $< -o $*$(BINEXT) + $(CROSS_AS) $(ASOPTS) $< -o $*.o clean: rm -f $(OBJS) $(JUNK) core *~ image: - $(CROSS_LD) -o uzi.bin --map uzi.map -nostdlib crt0.o commonmem.o \ + $(CROSS_LD) -o ../fuzix.bin --map ../uzi.map -nostdlib crt0.o commonmem.o \ p6809.o ../start.o ../version.o ../lowlevel-6809.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 ../usermem.o ../syscall_fs2.o \ ../usermem_std-6809.o devlpr.o devtty.o libc.o diff --git a/Kernel/platform-6809test/config.h b/Kernel/platform-6809test/config.h index 2d80c095..570fabce 100644 --- a/Kernel/platform-6809test/config.h +++ b/Kernel/platform-6809test/config.h @@ -14,6 +14,7 @@ #define BANK_KERNEL *((volatile uint8_t *)0xff91) |= 1 /* We use flexible 16K banks so use the helper */ #define CONFIG_BANK16 +#define CONFIG_BANKS 4 #define MAX_MAPS 16 /* And swapping */ #define SWAPDEV 6 /* FIXME */ @@ -39,7 +40,7 @@ #define PROGBASE ((char *)(0x0100)) /* also data base */ #define PROGTOP ((char *)(0xF000)) /* Top of program, base of U_DATA */ -#define BOOT_TTY 3 /* Set this to default device for stdio, stderr */ +#define BOOT_TTY (512 + 1) /* Set this to default device for stdio, stderr */ /* In this case, the default is the first TTY device */ /* Temp FIXME set to serial port for debug ease */ diff --git a/Kernel/platform-6809test/devices.c b/Kernel/platform-6809test/devices.c index 4f9e16b4..0cfe40bf 100644 --- a/Kernel/platform-6809test/devices.c +++ b/Kernel/platform-6809test/devices.c @@ -2,10 +2,7 @@ #include #include #include -#include -#include -#include -#include +#include #include #include #include @@ -14,29 +11,28 @@ 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; } - void device_init(void) { } diff --git a/Kernel/platform-6809test/devrd.c b/Kernel/platform-6809test/devrd.c index d71fe088..ddbf8b3c 100644 --- a/Kernel/platform-6809test/devrd.c +++ b/Kernel/platform-6809test/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-6809test/devtty.c b/Kernel/platform-6809test/devtty.c index 2b8b486b..c46f3a7f 100644 --- a/Kernel/platform-6809test/devtty.c +++ b/Kernel/platform-6809test/devtty.c @@ -44,7 +44,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 @@ -56,6 +56,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-6809test/main.c b/Kernel/platform-6809test/main.c index eb356953..75ccedbc 100644 --- a/Kernel/platform-6809test/main.c +++ b/Kernel/platform-6809test/main.c @@ -48,3 +48,6 @@ void pagemap_init(void) pagemap_add(0x86); } +void map_init(void) +{ +} diff --git a/Kernel/swap.c b/Kernel/swap.c index dfc345c7..4f5af056 100644 --- a/Kernel/swap.c +++ b/Kernel/swap.c @@ -33,7 +33,8 @@ void swapmap_add(uint8_t swap) swapmap[swapptr++] = swap; } -static int swapread(uint16_t dev, blkno_t blkno, unsigned int nbytes, char *buf) +static int swapread(uint16_t dev, blkno_t blkno, unsigned int nbytes, + uint8_t *buf) { swapbase = buf; swapcnt = nbytes; @@ -43,7 +44,7 @@ static int swapread(uint16_t dev, blkno_t blkno, unsigned int nbytes, char *buf) static int swapwrite(uint16_t dev, blkno_t blkno, unsigned int nbytes, - char *buf) + uint8_t *buf) { swapbase = buf; swapcnt = nbytes; diff --git a/Kernel/usermem.c b/Kernel/usermem.c index 5619fcbd..41bb3de1 100644 --- a/Kernel/usermem.c +++ b/Kernel/usermem.c @@ -9,7 +9,7 @@ #include /* This checks to see if a user-supplied address is legitimate */ -usize_t valaddr(char *base, usize_t size) +usize_t valaddr(const char *base, usize_t size) { if (base < (char *)PROGBASE || base + size < base) size = 0; @@ -141,7 +141,7 @@ int _uput(const uint8_t *source, uint8_t *user, usize_t count) { uint8_t tmp; while(count--) { - tmp = *source++ + tmp = *source++; BANK_PROCESS; *user++ = tmp; BANK_KERNEL;