[WIP] PiSCSI boot ROM experiments

This commit is contained in:
beeanyew
2021-01-29 01:37:40 +01:00
parent 3bf2b2c823
commit 0d0bb0355d
9 changed files with 180 additions and 29 deletions

View File

@@ -25,7 +25,7 @@ unsigned char ac_piscsi_rom[] = {
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
0x4, 0x0, 0x0, 0x0, // Optional BOOT ROM vector
};
static unsigned char ac_a314_rom[] = {
@@ -275,7 +275,7 @@ unsigned int autoconfig_read_memory_8(struct emulator_config *cfg, unsigned int
//printf("Read byte %d from Z2 autoconf for PIC %d (%.2X).\n", address/2, ac_z2_current_pic, val);
}
val <<= 4;
if (address != 0 && address != 2 && address != 40 && address != 42)
if (address != 0 && address != 2 && address != 0x40 && address != 0x42)
val ^= 0xff;
return (unsigned int)val;
@@ -324,17 +324,17 @@ void autoconfig_write_memory_8(struct emulator_config *cfg, unsigned int address
}
if (done) {
cfg->map_offset[index] = ac_base[ac_z2_current_pic];
cfg->map_high[index] = cfg->map_offset[index] + cfg->map_size[index];
switch (ac_z2_type[ac_z2_current_pic]) {
case ACTYPE_MAPFAST_Z2:
cfg->map_offset[index] = ac_base[ac_z2_current_pic];
cfg->map_high[index] = cfg->map_offset[index] + cfg->map_size[index];
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);
printf("PiSCSI Z2 device assigned to $%.8x\n", piscsi_base);
//m68k_add_rom_range(piscsi_base + (16 * SIZE_KILO), piscsi_base + (32 * SIZE_KILO), piscsi_rom_ptr);
break;
default:
break;

View File

@@ -16,11 +16,13 @@ int handle_register_read_amiga(unsigned int addr, unsigned char type, unsigned i
int handle_register_write_amiga(unsigned int addr, unsigned int value, unsigned char type);
int init_rtg_data();
extern int ac_z2_current_pic;
extern int ac_z2_done;
extern int ac_z2_pic_count;
extern int ac_z2_type[AC_PIC_LIMIT];
extern int ac_z2_index[AC_PIC_LIMIT];
extern int ac_z3_current_pic;
extern int ac_z3_pic_count;
extern int ac_z3_done;
extern int ac_z3_type[AC_PIC_LIMIT];
@@ -42,6 +44,11 @@ extern unsigned char cdtv_sram[32 * SIZE_KILO];
static uint8_t rtg_enabled = 0, piscsi_enabled = 0, pinet_enabled = 0;
extern uint32_t piscsi_base;
extern uint8_t piscsi_diag_read = 0;
extern void stop_cpu_emulation(uint8_t disasm_cur);
inline int custom_read_amiga(struct emulator_config *cfg, unsigned int addr, unsigned int *val, unsigned char type) {
if (!ac_z2_done && addr >= AC_Z2_BASE && addr < AC_Z2_BASE + AC_SIZE) {
if (ac_z2_pic_count == 0) {
@@ -70,6 +77,13 @@ inline int custom_read_amiga(struct emulator_config *cfg, unsigned int addr, uns
}
}
if (addr >= piscsi_base && addr < piscsi_base + (64 * SIZE_KILO)) {
printf("[Amiga-Custom] %s read from PISCSI base @$%.8X.\n", op_type_names[type], addr);
stop_cpu_emulation(1);
*val = handle_piscsi_read(addr, type);
return 1;
}
return -1;
}
@@ -108,6 +122,12 @@ inline int custom_write_amiga(struct emulator_config *cfg, unsigned int addr, un
}
}
if (addr >= piscsi_base && addr < piscsi_base + (64 * SIZE_KILO)) {
printf("[Amiga-Custom] %s write to PISCSI base @$%.8x: %.8X\n", op_type_names[type], addr, val);
handle_piscsi_write(addr, val, type);
return 1;
}
return -1;
}
@@ -158,6 +178,9 @@ void adjust_ranges_amiga(struct emulator_config *cfg) {
else
cfg->custom_low = min(cfg->custom_low, PISCSI_OFFSET);
cfg->custom_high = max(cfg->custom_high, PISCSI_UPPER);
if (piscsi_base != 0) {
cfg->custom_low = min(cfg->custom_low, piscsi_base);
}
}
if (pinet_enabled) {
if (cfg->custom_low == 0)
@@ -373,6 +396,9 @@ void setvar_amiga(struct emulator_config *cfg, char *var, char *val) {
void handle_reset_amiga(struct emulator_config *cfg) {
ac_z3_done = 0;
ac_z2_done = 0;
ac_z2_current_pic = 0;
ac_z3_current_pic = 0;
piscsi_diag_read = 0;
adjust_ranges_amiga(cfg);
}

View File

@@ -4,6 +4,7 @@
#include <stdlib.h>
#define BOOTLDR_SIZE 0x400
#define DIAG_TOTAL_SIZE 0x4000
char *rombuf, *zerobuf, *devicebuf;
@@ -48,6 +49,11 @@ int main(int argc, char *argv[]) {
fwrite(zerobuf, pad_size, 1, out);
fwrite(devicebuf, device_size, 1, out);
free(zerobuf);
zerobuf = malloc(DIAG_TOTAL_SIZE - (rom_size + pad_size + device_size));
memset(zerobuf, 0x00, DIAG_TOTAL_SIZE - (rom_size + pad_size + device_size));
fwrite(zerobuf, DIAG_TOTAL_SIZE - (rom_size + pad_size + device_size), 1, out);
printf("piscsi.rom successfully created.\n");
free(rombuf);

View File

@@ -30,5 +30,5 @@ enum piscsi_cmds {
PISCSI_CMD_ADDR2 = 0x14,
PISCSI_CMD_ADDR3 = 0x18,
PISCSI_CMD_ADDR4 = 0x1C,
PISCSI_CMD_ROM = 0x8000,
PISCSI_CMD_ROM = 0x4000,
};

View File

@@ -173,23 +173,76 @@ void handle_piscsi_write(uint32_t addr, uint32_t val, uint8_t type) {
}
}
uint8_t piscsi_diag_area[] = {
0x90,
0x00,
0x00, 0x40,
0x2C, 0x00,
0x2C, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
};
uint8_t fastata_diag_area[] = {
0x90,
0x00,
0x00, 0x10,
0x9e, 0x08,
0x00, 0x00,
0x00, 0x00,
0x00, 0x02,
0x00, 0x00,
};
uint8_t piscsi_diag_read;
#define PIB 0x00
uint32_t handle_piscsi_read(uint32_t addr, uint8_t type) {
if (type) {}
uint8_t *diag_area = piscsi_diag_area;
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);
if (romoffs < 14 && !piscsi_diag_read) {
printf("[PISCSI] %s read from DiagArea @$%.4X: ", op_type_names[type], romoffs);
uint32_t v = 0;
switch (type) {
case OP_TYPE_BYTE:
v = piscsi_rom_ptr[romoffs];
v = diag_area[romoffs];
printf("%.2X\n", v);
break;
case OP_TYPE_WORD:
v = *((uint16_t *)&piscsi_rom_ptr[romoffs]);
v = *((uint16_t *)&diag_area[romoffs]);
printf("%.4X\n", v);
break;
case OP_TYPE_LONGWORD:
v = *((uint32_t *)&piscsi_rom_ptr[romoffs]);
v = (*((uint16_t *)&diag_area[romoffs]) << 16) | *((uint16_t *)&diag_area[romoffs + 2]);
//v = *((uint32_t *)&diag_area[romoffs]);
printf("%.8X\n", v);
break;
}
if (romoffs == 0x0D)
piscsi_diag_read = 1;
return v;
}
if (romoffs < (piscsi_rom_size + PIB)) {
printf("[PISCSI] %s read from Boot ROM @$%.4X (%.8X): ", op_type_names[type], romoffs, addr);
uint32_t v = 0;
switch (type) {
case OP_TYPE_BYTE:
v = piscsi_rom_ptr[romoffs - PIB];
printf("%.2X\n", v);
break;
case OP_TYPE_WORD:
v = be16toh(*((uint16_t *)&piscsi_rom_ptr[romoffs - PIB]));
printf("%.4X\n", v);
break;
case OP_TYPE_LONGWORD:
//v = (*((uint16_t *)&diag_area[romoffs - 14]) << 16) | *((uint16_t *)&diag_area[romoffs - 12]);
v = be32toh(*((uint32_t *)&diag_area[romoffs - PIB]));
printf("%.8X\n", v);
break;
}
return v;

Binary file not shown.

Binary file not shown.