dragon-nx32: report cartridge hashes and MPI (needs xroar fixes)
authorAlan Cox <alan@linux.intel.com>
Thu, 4 Jun 2015 22:02:55 +0000 (23:02 +0100)
committerAlan Cox <alan@linux.intel.com>
Thu, 4 Jun 2015 22:02:55 +0000 (23:02 +0100)
This is the start of an small experiment to see if we can autodetect some
cartridges by spotting their ROMs.

Kernel/platform-dragon-nx32/main.c

index 248cb5f..cbeaf88 100644 (file)
@@ -2,10 +2,14 @@
 #include <timer.h>
 #include <kdata.h>
 #include <printf.h>
+#include <device.h>
 #include <devtty.h>
 
 uint8_t membanks;
 uint8_t system_id;
+uint8_t cartslots = 1;
+uint16_t carthash[4];
+uint8_t bootslot = 0;
 
 void platform_idle(void)
 {
@@ -15,6 +19,9 @@ void do_beep(void)
 {
 }
 
+
+/* ------------- Below bits can all move to discard if needed ------------ */
+
 /*
  * Map handling: We have flexible paging. Each map table consists of a set of pages
  * with the last page repeated to fill any holes.
@@ -33,6 +40,24 @@ void pagemap_init(void)
 #endif
 }
 
+static const char *sysname[] = {"Dragon", "COCO", "COCO3", "Unknown"};
+
 void map_init(void)
 {
+       uint8_t i;
+
+       kprintf("%s system.\n", sysname[system_id]);
+       if (mpi_present()) {
+               kputs("MPI cartridge detected.\n");
+               cartslots = 4;
+               bootslot = mpi_set_slot(0);
+       }
+       for (i = 0; i < cartslots; i++) {
+               mpi_set_slot((i << 4) | i);
+               carthash[i] = cart_hash();
+               kprintf("%d: %x %c\n",
+                       i, carthash[i],
+                       i == bootslot ? '*':' ');
+       }
+       mpi_set_slot(bootslot);
 }