ubee: disk probing
authorAlan Cox <alan@linux.intel.com>
Thu, 8 Feb 2018 23:07:33 +0000 (23:07 +0000)
committerAlan Cox <alan@linux.intel.com>
Thu, 8 Feb 2018 23:07:33 +0000 (23:07 +0000)
With these patches I can build a .ds82 image for the rootfs in the B drive
and boot it with "1 ro". Read/write seems to eat the disk, so that needs a bit
of debugging!

Kernel/platform-ubee/devices.c
Kernel/platform-ubee/main.c

index 7eb72f7..3b07134 100644 (file)
@@ -7,6 +7,7 @@
 #include <devsys.h>
 #include <devlpr.h>
 #include <devtty.h>
+#include <ubee.h>
 
 struct devsw dev_tab[] =  /* The device driver switch table */
 {
@@ -38,6 +39,8 @@ void device_init(void)
   int i;
   /* Time of day clock */
   inittod();
+  /* Figure out what disks we have */
+  diskprobe();
   /* Add 64 swaps (2MB) */
   for (i = MAX_SWAPS - 1 ; i >= 0; i--)
     swapmap_init(i);
index dc73c82..93fb598 100644 (file)
@@ -65,6 +65,69 @@ void map_init(void)
 
 }
 
+uint8_t disk_type[2];
+
+/* More _DISCARD material */
+
+__sfr __at 0x58 portswitch;
+__sfr __at 0x45 probe_reg;
+__sfr __at 0x41 fdc_cyl;
+__sfr __at 0x48 fdc_stat;
+
+void do_diskprobe(uint8_t *p)
+{
+       probe_reg = 0x5A;
+       /* probe_reg is read/write same value for both controllers so if it
+          doesn't work we have no disk */
+       if (probe_reg != 0x5A)
+               return;
+       /* If it mirrored check if a second value mirrors */
+       if (fdc_cyl == 0x5A) {
+               probe_reg = 0x22;
+               if (fdc_cyl == 0x22) {
+                       /* It's a floppy */
+                       if (fdc_stat & 0x0F)
+                               *p = DISK_TYPE_FDC_D;   /* Dream disc */
+                       else
+                               *p = DISK_TYPE_FDC;
+                       return;
+               }
+       }
+       /* Double check */
+       probe_reg = 0x22;
+       if (probe_reg != 0x22)
+               return;
+       *p = DISK_TYPE_HDC;
+}
+
+static const char dcstr[] = "Disk controller %d: %s\n";
+static const char *diskname[4] = { NULL, "2793", "DreamDisc", "WD1010" };
+
+void diskprobe(void)
+{
+       portswitch = 0;
+       do_diskprobe(disk_type);
+       portswitch = 1;
+       do_diskprobe(disk_type + 1);
+       /* Hard case: two of the same */
+       if (disk_type[0] == disk_type[1]) {
+               /* No disk at all - we don't care if port 58 works */
+               if (!disk_type[0])
+                       return;
+               /* We might have internal and external the same ? */
+               probe_reg = 0x5C;
+               portswitch = 0;
+               probe_reg = 0x00;
+               portswitch = 1;
+               if (probe_reg != 0x5C)
+                       disk_type[1] = 0;
+       }
+       kprintf(dcstr, 0, diskname[disk_type[0]]);
+       if (disk_type[1])
+               kprintf(dcstr, 1, diskname[disk_type[1]]);
+}
+
+
 /* The bank bits are not laid out nicely for historical reasons
 
    A classic uBee has the bank selection in bits 0/1