}
+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