trs80m1: rework the code to avoid banking fixup problems
authorAlan Cox <alan@linux.intel.com>
Fri, 21 Sep 2018 22:40:21 +0000 (23:40 +0100)
committerAlan Cox <alan@linux.intel.com>
Fri, 21 Sep 2018 22:40:21 +0000 (23:40 +0100)
Kernel/platform-trs80m1/devices.c
Kernel/platform-trs80m1/devstringy.c

index 5962de1..90159b4 100644 (file)
@@ -38,6 +38,10 @@ struct devsw dev_tab[] =  /* The device driver switch table */
   {  blkdev_open, no_close,     blkdev_read,   blkdev_write,   blkdev_ioctl  },
 };
 
+static struct devsw floppy3 = {
+  fd3_open,     no_close,     fd3_read,   fd3_write,   no_ioctl
+};
+
 bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
@@ -50,10 +54,6 @@ bool validdev(uint16_t dev)
 
 void floppy_setup(void)
 {
-  if (trs80_model == TRS80_MODEL3) {
-    dev_tab[1].dev_open = fd3_open;
-    dev_tab[1].dev_read = fd3_read;
-    dev_tab[1].dev_write = fd3_write;
-    dev_tab[8].dev_open = nxio_open;
-  }
+  if (trs80_model == TRS80_MODEL3)
+    memcpy(dev_tab + 1, &floppy3, sizeof(struct devsw));
 }
index 1b9169f..9b1a87d 100644 (file)
@@ -4,6 +4,7 @@
 #include <kdata.h>
 #include <devlpr.h>
 #include <printf.h>
+#include <trs80.h>
 #include <devstringy.h> 
 
 /*
@@ -62,7 +63,7 @@ int tape_open(uint8_t minor, uint16_t flag)
     uint8_t unit;
 
     /* Check for the floppy tape ROM */
-    if (*((uint16_t *)0x3034) != 0x3C3C) {
+    if (trs80_model == TRS80_MODEL3 || *((uint16_t *)0x3034) != 0x3C3C) {
         udata.u_error = ENODEV;
         return -1;
     }