msx1: scan for AB rom signatures, hash the first 2K
authorAlan Cox <alan@etchedpixels.co.uk>
Sat, 8 Nov 2014 23:25:06 +0000 (23:25 +0000)
committerAlan Cox <alan@etchedpixels.co.uk>
Sat, 8 Nov 2014 23:25:06 +0000 (23:25 +0000)
First steps to detecting the disks etc

Kernel/platform-msx1/devices.c
Kernel/platform-msx1/devices.h [new file with mode: 0644]
Kernel/platform-msx1/msx1.s

index b5805f1..d8e373a 100644 (file)
@@ -1,6 +1,8 @@
 #include <kernel.h>
+#include <printf.h>
 #include <version.h>
 #include <kdata.h>
+#include <devices.h>
 #include <devhd.h>
 #include <devfd.h>
 #include <devlpr.h>
@@ -33,6 +35,18 @@ bool validdev(uint16_t dev)
         return true;
 }
 
+/*
+ *     We may want to do this differently in the end but report the
+ *     cartridge hashes found.
+ *
+ *     A4B6 = Sony HBD-F1
+ *     3B49 = Sony HBK-30
+ */
 void device_init(void)
 {
+  int i;
+  for (i = 0; i < 16; i++) {
+    if (slot_table[i])
+      kprintf("%d.%d: %x\n", (i>>2) & 3, i & 3, slot_table[i]);
+  }
 }
diff --git a/Kernel/platform-msx1/devices.h b/Kernel/platform-msx1/devices.h
new file mode 100644 (file)
index 0000000..53a0965
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef _PLATFORM_DEVICES_H
+#define _PLATFORM_DEVICES_H
+
+extern uint16_t slot_table[16];
+
+#endif
\ No newline at end of file
index 716bbe3..61b703b 100644 (file)
@@ -14,6 +14,7 @@
            .globl map_process_always
            .globl map_save
            .globl map_restore
+           .globl _slot_table
 
            ; video driver
            .globl _vtinit
@@ -143,6 +144,7 @@ size_memory:
            ld de, #0x40                ; main memory for kernel
            add hl, de
            ld (_ramsize), hl
+           call rom_scan
            ret
 
 _program_vectors:
@@ -637,3 +639,75 @@ map_megaram:
            pop de
            call setslot1
            ret
+
+;
+;      Find each rom and insert it by hash code into the slot table. We
+;      can then use this to find out where things like floppy drives have
+;      been hidden. Right now we are only scanning 0x4000-0x7FFF, but we
+;      will probably need to scan 0x8000-0xBFFF as well eventually (which
+;      will be a right PITA as we'll need slotscan2 and all the supporting
+;      logic to be in 0x0000-0x3FFF!)
+;
+rom_scan:
+           ld hl, #rom_scan_f
+           exx
+           call slotscan1
+           ret
+
+rom_scan_f:
+           ld a, #'*'
+           out (0x2f), a
+           ld a, (0x4000)
+           cp #'A'
+           ret nz
+           ld a, (0x4001)
+           cp #'B'
+           ret nz
+           ;
+           ; ROM found. Preserve HL as its the call vector
+           ;
+           ld a, #'R'
+           out (0x2f), a
+           push hl
+           ld hl, #0x4002
+           ld bc, #2048
+           ld de, #0
+           ; Use the low 2K as a checksum identifier
+rom_scan_1:
+           ld a, (hl)
+           add e
+           ld e, a
+           ld a, d
+           adc #0
+           ld d, a
+           inc hl
+           djnz rom_scan_1
+           dec c
+           jr nz,rom_scan_1
+           exx
+           push de     ;slot info
+           exx
+           pop bc
+           ld a, b
+           and #0x0C
+           ld b, a
+           ld a, c
+           and #0x03
+            or b
+           add a
+           ld c, a
+           ld b, #0
+           ld hl, #_slot_table
+           add hl, bc
+           ld (hl), e
+           inc hl
+           ld (hl), d
+           pop hl
+           ret
+
+; Needs to be outside of 0x4000-0x7FFF
+_slot_table:
+           .dw 0,0,0,0
+           .dw 0,0,0,0
+           .dw 0,0,0,0
+           .dw 0,0,0,0