mirror of
https://github.com/captain-amygdala/pistorm.git
synced 2026-04-28 20:58:06 +00:00
Fix direct SCSI reads/writes
This commit is contained in:
@@ -138,10 +138,6 @@ void adjust_ranges_amiga(struct emulator_config *cfg) {
|
||||
cfg->custom_low = 0;
|
||||
|
||||
// Set up the min/max ranges for mapped reads/writes
|
||||
if (gayle_emulation_enabled) {
|
||||
cfg->mapped_low = GAYLEBASE;
|
||||
cfg->mapped_high = GAYLEBASE + GAYLESIZE;
|
||||
}
|
||||
for (int i = 0; i < MAX_NUM_MAPPED_ITEMS; i++) {
|
||||
if (cfg->map_type[i] != MAPTYPE_NONE) {
|
||||
if ((cfg->map_offset[i] != 0 && cfg->map_offset[i] < cfg->mapped_low) || cfg->mapped_low == 0)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -91,10 +91,10 @@ uint8_t piscsi_perform_io(struct piscsi_unit *u, struct IORequest *io);
|
||||
uint8_t piscsi_rw(struct piscsi_unit *u, struct IORequest *io);
|
||||
uint8_t piscsi_scsi(struct piscsi_unit *u, struct IORequest *io);
|
||||
|
||||
//#define debug(...)
|
||||
//#define debugval(...)
|
||||
#define debug(c, v) WRITESHORT(c, v)
|
||||
#define debugval(c, v) WRITELONG(c, v)
|
||||
#define debug(...)
|
||||
#define debugval(...)
|
||||
//#define debug(c, v) WRITESHORT(c, v)
|
||||
//#define debugval(c, v) WRITELONG(c, v)
|
||||
|
||||
struct piscsi_base *dev_base = NULL;
|
||||
|
||||
@@ -362,24 +362,28 @@ uint8_t piscsi_scsi(struct piscsi_unit *u, struct IORequest *io)
|
||||
case SCSICMD_WRITE_6:
|
||||
write = 1;
|
||||
case SCSICMD_READ_6:
|
||||
block = *(uint32_t *)(&scsi->scsi_Command[0]) & 0x001FFFFF;
|
||||
/*block = scsi->scsi_Command[1] & 0x1f;
|
||||
//block = *(uint32_t *)(&scsi->scsi_Command[0]) & 0x001FFFFF;
|
||||
block = scsi->scsi_Command[1] & 0x1f;
|
||||
block = (block << 8) | scsi->scsi_Command[2];
|
||||
block = (block << 8) | scsi->scsi_Command[3];*/
|
||||
block = (block << 8) | scsi->scsi_Command[3];
|
||||
blocks = scsi->scsi_Command[4];
|
||||
debugval(PISCSI_DBG_VAL1, (uint32_t)scsi->scsi_Command);
|
||||
debug(PISCSI_DBG_MSG, DBG_SCSICMD_RW6);
|
||||
goto scsireadwrite;
|
||||
case SCSICMD_WRITE_10:
|
||||
write = 1;
|
||||
case SCSICMD_READ_10:
|
||||
block = *(uint32_t *)(&scsi->scsi_Command[2]);
|
||||
/*block = scsi->scsi_Command[2];
|
||||
debugval(PISCSI_DBG_VAL1, (uint32_t)scsi->scsi_Command);
|
||||
debug(PISCSI_DBG_MSG, DBG_SCSICMD_RW10);
|
||||
//block = *(uint32_t *)(&scsi->scsi_Command[2]);
|
||||
block = scsi->scsi_Command[2];
|
||||
block = (block << 8) | scsi->scsi_Command[3];
|
||||
block = (block << 8) | scsi->scsi_Command[4];
|
||||
block = (block << 8) | scsi->scsi_Command[5];*/
|
||||
block = (block << 8) | scsi->scsi_Command[5];
|
||||
|
||||
blocks = *(uint16_t *)(&scsi->scsi_Command[7]);
|
||||
/*blocks = scsi->scsi_Command[7];
|
||||
blocks = (blocks << 8) | scsi->scsi_Command[8];*/
|
||||
//blocks = *(uint16_t *)(&scsi->scsi_Command[7]);
|
||||
blocks = scsi->scsi_Command[7];
|
||||
blocks = (blocks << 8) | scsi->scsi_Command[8];
|
||||
|
||||
scsireadwrite:;
|
||||
WRITESHORT(PISCSI_CMD_DRVNUM, (u->scsi_num));
|
||||
@@ -394,13 +398,13 @@ scsireadwrite:;
|
||||
}
|
||||
|
||||
if (write == 0) {
|
||||
WRITELONG(PISCSI_CMD_ADDR2, block);
|
||||
WRITELONG(PISCSI_CMD_ADDR1, block);
|
||||
WRITELONG(PISCSI_CMD_ADDR2, (blocks << 9));
|
||||
WRITELONG(PISCSI_CMD_ADDR3, (uint32_t)data);
|
||||
WRITESHORT(PISCSI_CMD_READ, u->unit_num);
|
||||
}
|
||||
else {
|
||||
WRITELONG(PISCSI_CMD_ADDR2, block);
|
||||
WRITELONG(PISCSI_CMD_ADDR1, block);
|
||||
WRITELONG(PISCSI_CMD_ADDR2, (blocks << 9));
|
||||
WRITELONG(PISCSI_CMD_ADDR3, (uint32_t)data);
|
||||
WRITESHORT(PISCSI_CMD_WRITE, u->unit_num);
|
||||
|
||||
@@ -72,6 +72,8 @@ enum piscsi_dbg_msgs {
|
||||
DBG_IOCMD_UNHANDLED,
|
||||
DBG_SCSI_DEBUG_MODESENSE_6,
|
||||
DBG_SCSI_DEBUG_MODESENSE_10,
|
||||
DBG_SCSICMD_RW6,
|
||||
DBG_SCSICMD_RW10,
|
||||
};
|
||||
|
||||
enum scsi_commands {
|
||||
|
||||
@@ -14,19 +14,33 @@
|
||||
#define BE(val) be32toh(val)
|
||||
#define BE16(val) be16toh(val)
|
||||
|
||||
// Comment these lines to restore debug output:
|
||||
#define DEBUG(...)
|
||||
//#define DEBUG printf
|
||||
#define DEBUG_TRIVIAL(...)
|
||||
// Uncomment the line below to enable debug output
|
||||
//#define PISCSI_DEBUG
|
||||
|
||||
#ifdef PISCSI_DEBUG
|
||||
#define DEBUG printf
|
||||
//#define DEBUG_TRIVIAL printf
|
||||
#define DEBUG_TRVIAL(...)
|
||||
|
||||
extern void stop_cpu_emulation(uint8_t disasm_cur);
|
||||
|
||||
static const char *op_type_names[4] = {
|
||||
"BYTE",
|
||||
"WORD",
|
||||
"LONGWORD",
|
||||
"MEM",
|
||||
};
|
||||
#else
|
||||
#define DEBUG(...)
|
||||
#define DEBUG_TRIVIAL(...)
|
||||
#define stop_cpu_emulation(...)
|
||||
#endif
|
||||
|
||||
#ifdef FAKESTORM
|
||||
#define lseek64 lseek
|
||||
#endif
|
||||
|
||||
extern struct emulator_config *cfg;
|
||||
extern void stop_cpu_emulation(uint8_t disasm_cur);
|
||||
|
||||
struct piscsi_dev devs[8];
|
||||
struct piscsi_fs filesystems[NUM_FILESYSTEMS];
|
||||
@@ -44,17 +58,8 @@ uint32_t rom_partition_prio[128];
|
||||
uint32_t rom_partition_dostype[128];
|
||||
uint32_t rom_cur_partition = 0, rom_cur_fs = 0;
|
||||
|
||||
|
||||
|
||||
extern unsigned char ac_piscsi_rom[];
|
||||
|
||||
static const char *op_type_names[4] = {
|
||||
"BYTE",
|
||||
"WORD",
|
||||
"LONGWORD",
|
||||
"MEM",
|
||||
};
|
||||
|
||||
//static const char *partition_marker = "PART";
|
||||
|
||||
struct hunk_info piscsi_hinfo;
|
||||
@@ -220,6 +225,7 @@ void piscsi_find_filesystems(struct piscsi_dev *d) {
|
||||
|
||||
while (BE(fhb->fhb_ID) == FS_IDENTIFIER) {
|
||||
char *dosID = (char *)&fhb->fhb_DosType;
|
||||
#ifdef PISCSI_DEBUG
|
||||
uint16_t *fsVer = (uint16_t *)&fhb->fhb_Version;
|
||||
|
||||
DEBUG("[FSHD] FSHD Block found.\n");
|
||||
@@ -232,6 +238,7 @@ void piscsi_find_filesystems(struct piscsi_dev *d) {
|
||||
DEBUG("[FSHD] Prio: %d Startup: %d\n", BE(fhb->fhb_Priority), BE(fhb->fhb_Startup));
|
||||
DEBUG("[FSHD] SegListBlocks: %d GlobalVec: %d\n", BE(fhb->fhb_Priority), BE(fhb->fhb_Startup));
|
||||
DEBUG("[FSHD] FileSysName: %s\n", fhb->fhb_FileSysName + 1);
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < NUM_FILESYSTEMS; i++) {
|
||||
if (filesystems[i].FS_ID == fhb->fhb_DosType) {
|
||||
@@ -414,10 +421,36 @@ void print_piscsi_debug_message(int index) {
|
||||
case DBG_SCSI_RDG:
|
||||
DEBUG("[PISCSI] Get SCSI RDG MODE SENSE.\n");
|
||||
break;
|
||||
case DBG_SCSICMD_RW10:
|
||||
#ifdef PISCSI_DEBUG
|
||||
r = get_mapped_item_by_address(cfg, piscsi_dbg[0]);
|
||||
struct SCSICmd_RW10 *rwdat = NULL;
|
||||
char data[10];
|
||||
if (r != -1) {
|
||||
uint32_t addr = piscsi_dbg[0] - cfg->map_offset[r];
|
||||
rwdat = (struct SCSICmd_RW10 *)(&cfg->map_data[r][addr]);
|
||||
}
|
||||
else {
|
||||
DEBUG_TRIVIAL("[RW10] scsiData: %.8X\n", piscsi_dbg[0]);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
data[i] = read8(piscsi_dbg[0] + i);
|
||||
}
|
||||
rwdat = data;
|
||||
}
|
||||
if (rwdat) {
|
||||
DEBUG_TRIVIAL("[RW10] CMD: %.2X\n", rwdat->opcode);
|
||||
DEBUG_TRIVIAL("[RW10] RDP: %.2X\n", rwdat->rdprotect_flags);
|
||||
DEBUG_TRIVIAL("[RW10] Block: %d (%d)\n", rwdat->block, BE(rwdat->block));
|
||||
DEBUG_TRIVIAL("[RW10] Res_Group: %.2X\n", rwdat->res_groupnum);
|
||||
DEBUG_TRIVIAL("[RW10] Len: %d (%d)\n", rwdat->len, BE16(rwdat->len));
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case DBG_SCSI_DEBUG_MODESENSE_6:
|
||||
DEBUG_TRIVIAL("[PISCSI] SCSI ModeSense debug. Data: %.8X\n", piscsi_dbg[0]);
|
||||
r = get_mapped_item_by_address(cfg, piscsi_dbg[0]);
|
||||
if (r != -1) {
|
||||
#ifdef PISCSI_DEBUG
|
||||
uint32_t addr = piscsi_dbg[0] - cfg->map_offset[r];
|
||||
struct SCSICmd_ModeSense6 *sense = (struct SCSICmd_ModeSense6 *)(&cfg->map_data[r][addr]);
|
||||
DEBUG_TRIVIAL("[SenseData] CMD: %.2X\n", sense->opcode);
|
||||
@@ -426,6 +459,7 @@ void print_piscsi_debug_message(int index) {
|
||||
DEBUG_TRIVIAL("[SenseData] PageCodes: %.2X %.2X\n", (sense->pc_pagecode & 0x3F), sense->subpage_code);
|
||||
DEBUG_TRIVIAL("[SenseData] AllocLen: %d\n", sense->alloc_len);
|
||||
DEBUG_TRIVIAL("[SenseData] Control: %.2X (%d)\n", sense->control, sense->control);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
DEBUG("[!!!PISCSI] ModeSense data not immediately available.\n");
|
||||
@@ -471,6 +505,9 @@ void piscsi_debugme(uint32_t index) {
|
||||
|
||||
void handle_piscsi_write(uint32_t addr, uint32_t val, uint8_t type) {
|
||||
int32_t r;
|
||||
#ifndef PISCSI_DEBUG
|
||||
if (type) {}
|
||||
#endif
|
||||
|
||||
struct piscsi_dev *d = &devs[piscsi_cur_drive];
|
||||
|
||||
@@ -678,7 +715,9 @@ skip_disk:;
|
||||
if (r != -1) {
|
||||
uint32_t addr = val - cfg->map_offset[r];
|
||||
struct DeviceNode *node = (struct DeviceNode *)(cfg->map_data[r] + addr);
|
||||
#ifdef PISCSI_DEBUG
|
||||
char *dosID = (char *)&rom_partition_dostype[rom_cur_partition];
|
||||
#endif
|
||||
DEBUG("[PISCSI] Partition DOSType is %c%c%c/%d\n", dosID[0], dosID[1], dosID[2], dosID[3]);
|
||||
for (i = 0; i < piscsi_num_fs; i++) {
|
||||
if (rom_partition_dostype[rom_cur_partition] == filesystems[i].FS_ID) {
|
||||
|
||||
@@ -215,6 +215,15 @@ struct SCSICmd_ModeSense6 {
|
||||
uint8_t control;
|
||||
};
|
||||
|
||||
struct SCSICmd_RW10 {
|
||||
uint8_t opcode;
|
||||
uint8_t rdprotect_flags;
|
||||
uint32_t block;
|
||||
uint8_t res_groupnum;
|
||||
uint16_t len;
|
||||
uint8_t control;
|
||||
};
|
||||
|
||||
struct FileSysHeaderBlock {
|
||||
uint32_t fhb_ID;
|
||||
uint32_t fhb_SummedLongs;
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user