6809: unbitrot versus changes we've made elsewhere
authorAlan Cox <alan@etchedpixels.co.uk>
Mon, 10 Nov 2014 01:00:50 +0000 (01:00 +0000)
committerAlan Cox <alan@etchedpixels.co.uk>
Mon, 10 Nov 2014 01:00:50 +0000 (01:00 +0000)
Still not a "real" port, but it compiles again

Kernel/Makefile
Kernel/include/kernel.h
Kernel/platform-6809test/Makefile
Kernel/platform-6809test/config.h
Kernel/platform-6809test/devices.c
Kernel/platform-6809test/devrd.c
Kernel/platform-6809test/devtty.c
Kernel/platform-6809test/main.c
Kernel/swap.c
Kernel/usermem.c

index f98050e..145ea38 100644 (file)
@@ -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
 
index 017d5a0..c5e5fec 100644 (file)
@@ -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);
index 3f75014..8a2495b 100644 (file)
@@ -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
index 2d80c09..570fabc 100644 (file)
@@ -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 */
 
index 4f9e16b..0cfe40b 100644 (file)
@@ -2,10 +2,7 @@
 #include <version.h>
 #include <kdata.h>
 #include <devrd.h>
-#include <devmem.h>
-#include <devzero.h>
-#include <devnull.h>
-#include <devproc.h>
+#include <devsys.h>
 #include <devlpr.h>
 #include <tty.h>
 #include <devtty.h>
@@ -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)
 {
 }
index d71fe08..ddbf8b3 100644 (file)
@@ -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 */
index 2b8b486..c46f3a7 100644 (file)
@@ -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();
index eb35695..75ccedb 100644 (file)
@@ -48,3 +48,6 @@ void pagemap_init(void)
     pagemap_add(0x86);
 }
 
+void map_init(void)
+{
+}
index dfc345c..4f5af05 100644 (file)
@@ -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;
index 5619fcb..41bb3de 100644 (file)
@@ -9,7 +9,7 @@
 #include <printf.h>
 
 /* 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;