]> git.sesse.net Git - pistorm/commitdiff
Update amiga-autoconf.c, amiga-autoconf.h, and 3 more files...
authorbeeanyew <beeanyew@gmail.com>
Thu, 28 Jan 2021 12:11:19 +0000 (13:11 +0100)
committerbeeanyew <beeanyew@gmail.com>
Thu, 28 Jan 2021 12:11:19 +0000 (13:11 +0100)
platforms/amiga/amiga-autoconf.c
platforms/amiga/amiga-autoconf.h
platforms/amiga/amiga-platform.c
platforms/amiga/piscsi/piscsi-enums.h
platforms/amiga/piscsi/piscsi.c

index 68f1252469fe9a95c88ef484b21e4e39844eaa00..de9d933d45cfbbfb3e9af1fe0442a06b291adb72 100644 (file)
@@ -4,13 +4,28 @@
 #include <stdlib.h>
 #include <string.h>
 
+#define Z2_Z2      0xC
+#define Z2_FAST    0x2
+#define Z2_BOOTROM 0x1
+
 static unsigned char ac_fast_ram_rom[] = {
-    0xe, AC_MEM_SIZE_8MB,                   // 00/02, link into memory free list, 8 MB
-    0x6, 0x9,                               // 04/06, product id
+    Z2_Z2 | Z2_FAST, AC_MEM_SIZE_8MB,       // 00/02, link into memory free list, 8 MB
+    0x6, 0x9,                               // 06/09, product id
     0x8, 0x0,                               // 08/0a, preference to 8 MB space
     0x0, 0x0,                               // 0c/0e, reserved
-    0x0, 0x7, 0xd, 0xb,                     // 10/12/14/16, mfg id
-    0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x2, 0x0  // 18/.../26, serial
+    0x0, 0x7, 0xD, 0xB,                     // 10/12/14/16, mfg id
+    0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x2, 0x0, // 18/.../26, serial
+    0x0, 0x0, 0x0, 0x0,                     // Optional BOOT ROM vector
+};
+
+unsigned char ac_piscsi_rom[] = {
+    Z2_Z2 | Z2_BOOTROM, AC_MEM_SIZE_64KB,   // 00/01, Z2, bootrom, 64 KB
+    0x6, 0xA,                               // 06/0A, product id
+    0x0, 0x0,                               // 00/0a, any space where it fits
+    0x0, 0x0,                               // 0c/0e, reserved
+    0x0, 0x7, 0xD, 0xB,                     // 10/12/14/16, mfg id
+    0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x2, 0x1, // 18/.../26, serial
+    0x0, 0x0, 0x0, 0x0,                     // Optional BOOT ROM vector
 };
 
 static unsigned char ac_a314_rom[] = {
@@ -19,7 +34,8 @@ static unsigned char ac_a314_rom[] = {
     0x0, 0x0,                               // 08/0a, any space okay
     0x0, 0x0,                               // 0c/0e, reserved
     0x0, 0x7, 0xd, 0xb,                     // 10/12/14/16, mfg id
-    0xa, 0x3, 0x1, 0x4, 0x0, 0x0, 0x0, 0x0  // 18/.../26, serial
+    0xa, 0x3, 0x1, 0x4, 0x0, 0x0, 0x0, 0x0, // 18/.../26, serial
+    0x0, 0x0, 0x0, 0x0,                     // Optional BOOT ROM vector
 };
 
 int ac_z2_current_pic = 0;
@@ -35,6 +51,8 @@ int ac_z3_done = 0;
 int ac_z3_type[AC_PIC_LIMIT];
 int ac_z3_index[AC_PIC_LIMIT];
 
+uint32_t piscsi_base = 0;
+extern uint8_t *piscsi_rom_ptr;
 
 unsigned char get_autoconf_size(int size) {
   if (size == 8 * SIZE_MEGA)
@@ -237,6 +255,9 @@ unsigned int autoconfig_read_memory_8(struct emulator_config *cfg, unsigned int
     case ACTYPE_A314:
       rom = ac_a314_rom;
       break;
+    case ACTYPE_PSICSI:
+      rom = ac_piscsi_rom;
+      break;
     default:
       return 0;
       break;
@@ -274,6 +295,9 @@ void autoconfig_write_memory_8(struct emulator_config *cfg, unsigned int address
     case ACTYPE_A314:
       //base = &a314_base;
       break;
+    case ACTYPE_PSICSI:
+      base = &piscsi_base;
+      break;
     default:
       break;
   }
@@ -300,11 +324,21 @@ void autoconfig_write_memory_8(struct emulator_config *cfg, unsigned int address
   }
 
   if (done) {
-    printf("Address of Z2 autoconf RAM assigned to $%.8x\n", ac_base[ac_z2_current_pic]);
     cfg->map_offset[index] = ac_base[ac_z2_current_pic];
     cfg->map_high[index] = cfg->map_offset[index] + cfg->map_size[index];
-    m68k_add_ram_range(cfg->map_offset[index], cfg->map_high[index], cfg->map_data[index]);
-    printf("Z2 PIC %d at $%.8lX-%.8lX, Size: %d MB\n", ac_z2_current_pic, cfg->map_offset[index], cfg->map_high[index], cfg->map_size[index] / SIZE_MEGA);
+    switch (ac_z2_type[ac_z2_current_pic]) {
+      case ACTYPE_MAPFAST_Z2:
+        printf("Address of Z2 autoconf RAM assigned to $%.8x\n", ac_base[ac_z2_current_pic]);
+        m68k_add_ram_range(cfg->map_offset[index], cfg->map_high[index], cfg->map_data[index]);
+        printf("Z2 PIC %d at $%.8lX-%.8lX, Size: %d MB\n", ac_z2_current_pic, cfg->map_offset[index], cfg->map_high[index], cfg->map_size[index] / SIZE_MEGA);
+        break;
+      case ACTYPE_PSICSI:
+        printf("PiSCSI Z2 device assigned to $%.8x\n", ac_base[ac_z2_current_pic]);
+        m68k_add_rom_range(piscsi_base + (16 * SIZE_KILO), piscsi_base + (32 * SIZE_KILO), piscsi_rom_ptr);
+        break;
+      default:
+        break;
+    }
     ac_z2_current_pic++;
     if (ac_z2_current_pic == ac_z2_pic_count) {
       ac_z2_done = 1;
index c39fdf158fa36c9d925cd0e38516d842b983a305..3ff8432afd00e43b999f390bd58493e43b6bc7eb 100644 (file)
@@ -25,6 +25,7 @@ enum autoconf_types {
     ACTYPE_MAPFAST_Z2,
     ACTYPE_MAPFAST_Z3,
     ACTYPE_A314,
+    ACTYPE_PSICSI,
     ACTYPE_NUM,
 };
 
index c4bcf0041f2a37e28e0eeef21885d15d6e8ec191..269acb5aa25909a274bf990f2bb53af86149c458 100644 (file)
@@ -319,6 +319,8 @@ void setvar_amiga(struct emulator_config *cfg, char *var, char *val) {
         printf("[AMIGA] PISCSI Interface Enabled.\n");
         piscsi_enabled = 1;
         piscsi_init();
+        ac_z2_type[ac_z2_pic_count] = ACTYPE_PSICSI;
+        ac_z2_pic_count++;
         adjust_ranges_amiga(cfg);
     }
     if (piscsi_enabled) {
index b56d39c4123a8daa2dfec83cee303b7964a4a264..1cd6fee46f356eda7188441f4d37eb553b4cf5bc 100644 (file)
@@ -30,4 +30,5 @@ enum piscsi_cmds {
     PISCSI_CMD_ADDR2    = 0x14,
     PISCSI_CMD_ADDR3    = 0x18,
     PISCSI_CMD_ADDR4    = 0x1C,
+    PISCSI_CMD_ROM      = 0x8000,
 };
\ No newline at end of file
index 52d1fdb8a53a5acd2166cbaae4d38769530afe98..145b353f477ef792bef16b09c5b320b537030af3 100644 (file)
@@ -1,5 +1,7 @@
 #include <stdio.h>
 #include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <endian.h>
 struct piscsi_dev devs[8];
 uint8_t piscsi_cur_drive = 0;
 uint32_t piscsi_u32[4];
+uint32_t piscsi_rom_size = 0;
+uint8_t *piscsi_rom_ptr;
+
+extern unsigned char ac_piscsi_rom[];
 
 static const char *op_type_names[4] = {
     "BYTE",
@@ -24,6 +30,23 @@ void piscsi_init() {
         devs[i].fd = -1;
         devs[i].c = devs[i].h = devs[i].s = 0;
     }
+
+    FILE *in = fopen("./platforms/amiga/piscsi/piscsi.rom", "rb");
+    if (in == NULL) {
+        printf("[PISCSI] Could not open PISCSI Boot ROM file for reading.\n");
+        ac_piscsi_rom[20] = 0;
+        ac_piscsi_rom[21] = 0;
+        ac_piscsi_rom[22] = 0;
+        ac_piscsi_rom[23] = 0;
+        return;
+    }
+    fseek(in, 0, SEEK_END);
+    piscsi_rom_size = ftell(in);
+    fseek(in, 0, SEEK_SET);
+    piscsi_rom_ptr = malloc(piscsi_rom_size);
+    fread(piscsi_rom_ptr, piscsi_rom_size, 1, in);
+    fclose(in);
+    printf("[PISCSI] Loaded Boot ROM.\n");
 }
 
 void piscsi_map_drive(char *filename, uint8_t index) {
@@ -152,6 +175,27 @@ void handle_piscsi_write(uint32_t addr, uint32_t val, uint8_t type) {
 
 uint32_t handle_piscsi_read(uint32_t addr, uint8_t type) {
     if (type) {}
+
+    if ((addr & 0xFFFF) >= PISCSI_CMD_ROM) {
+        uint32_t romoffs = (addr & 0xFFFF) - PISCSI_CMD_ROM;
+        if (romoffs < piscsi_rom_size) {
+            printf("[PISCSI] %s read from Boot ROM @$%.4X (%.8X)\n", op_type_names[type], romoffs, addr);
+            uint32_t v = 0;
+            switch (type) {
+                case OP_TYPE_BYTE:
+                    v = piscsi_rom_ptr[romoffs];
+                    break;
+                case OP_TYPE_WORD:
+                    v = *((uint16_t *)&piscsi_rom_ptr[romoffs]);
+                    break;
+                case OP_TYPE_LONGWORD:
+                    v = *((uint32_t *)&piscsi_rom_ptr[romoffs]);
+                    break;
+            }
+            return v;
+        }
+        return 0;
+    }
     
     switch (addr & 0xFFFF) {
         case PISCSI_CMD_DRVTYPE: