From 9d0a0975fd359760f8a3eafef630a4146484d433 Mon Sep 17 00:00:00 2001 From: beeanyew Date: Fri, 19 Feb 2021 12:32:29 +0100 Subject: [PATCH] Fix direct SCSI reads/writes --- README.md | 16 ++++- platforms/amiga/amiga-platform.c | 4 -- .../amiga/piscsi/device_driver_amiga/bootrom | Bin 1864 -> 1824 bytes .../piscsi/device_driver_amiga/pi-scsi.device | Bin 3088 -> 2856 bytes .../device_driver_amiga/piscsi-amiga-2.c | 34 +++++---- platforms/amiga/piscsi/piscsi-enums.h | 2 + platforms/amiga/piscsi/piscsi.c | 65 ++++++++++++++---- platforms/amiga/piscsi/piscsi.h | 9 +++ platforms/amiga/piscsi/piscsi.rom | Bin 16384 -> 16384 bytes 9 files changed, 96 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 522176c..63a067c 100644 --- a/README.md +++ b/README.md @@ -8,11 +8,21 @@ * Hardware files are in Hardware.zip, using the hardware design or parts of it in a commercial product (aka selling with profit) needs a explicit approval from me! * Even selling blank PCBs at eBay or so without my approval might makes me pretty mad and probably leads to the forthcomming related projects to be closed source. You have been warned :) +# wip-crap tutorial/quickstart -Simple quickstart +In order to successfully use the features on the wip-crap branch, you need to take a few additional steps: +* Follow the steps in the "Simple quickstart" below up to `sudo apt-install git`, then do this: +* `git clone https://github.com/beeanyew/pistorm.git` +* `cd pistorm` +* `git checkout wip-crap` +* `sudo apt-get install libsdl2-dev` +* `make` +* Follow the instructions for `FPGA bitstream update` below the quickstart. This is very important, as the latest commit on the branch uses the updated proto3 firmware. +# Simple quickstart + * Download Raspberry OS from https://www.raspberrypi.org/software/operating-systems/ , the Lite version is sufficent * Write the Image to a SD Card (8GB sized is plenty, for larger HDD Images pick a bigger one) * Install the pistorm adapter inplace of the orignal CPU into the Amiga500. Make sure the pistorm sits flush and correct in the Amiga. @@ -54,7 +64,9 @@ to exit emulation The IDE emulation can take both hard drive images generated using `makedisk` in the `ide` directory (these have a 1KB header) or headerless RDSK/RDB images created for instance in WinUAE or as empty files. The IDE emulation currently has a quirk that may require you to reduce/increase the size of the image file by 2MB in order for it to work. -** FPGA bitstream update : +Since PiSCSI can now autoboot RDSK hard drive images, using the IDE controller emulation is not recommended unless you already have a suitable .img file set up for it. + +# FPGA bitstream update : install openocd `sudo apt-get install openocd` diff --git a/platforms/amiga/amiga-platform.c b/platforms/amiga/amiga-platform.c index 8230179..b284789 100644 --- a/platforms/amiga/amiga-platform.c +++ b/platforms/amiga/amiga-platform.c @@ -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) diff --git a/platforms/amiga/piscsi/device_driver_amiga/bootrom b/platforms/amiga/piscsi/device_driver_amiga/bootrom index ab7cf16eeb0d0a79f3878438e175f277e5d9f873..fe3d33a7be850f347fcb8d7203d478fb2d29b1be 100644 GIT binary patch delta 8 PcmX@Xw}5Y>h5|bP4l@FU delta 48 wcmZ3$cY;rYfr0rs1CU6{&o3#;&($jia)8_yK!VZP-^CTkehFm1+MvJ=023Pu@c;k- diff --git a/platforms/amiga/piscsi/device_driver_amiga/pi-scsi.device b/platforms/amiga/piscsi/device_driver_amiga/pi-scsi.device index c57df2bd9171447eeb8746f03382b1a36fd5a8b3..05c9b311a095bc7ac47ccbfa1635b950a5581e6a 100644 GIT binary patch delta 1464 zcmb7EUuaup6#v~Xx5-U*n zHQ1!Sv?#9iiVPn`q?97Vm4Z-4(IRCODMfq|N9TiX`s9P?y0-pqn@PJT<#N9B=R41CfE+~2cidE_vklTW)8&S-as_aN z%~cJVtFx!7Es`VZamOH&>PS|19QMvra3oMro1cTL^I52!{cxsd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Wf>X8wOgO9?X8#VmjyoVJ50@+_4NVYQCmlB zg0dp>7CYDD{J*DFO?133>5UadFXZYLafCmL7%RoaE)C&4B9`rNjlvM`E;V4k5VTp&J!YNUwzscsi_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); diff --git a/platforms/amiga/piscsi/piscsi-enums.h b/platforms/amiga/piscsi/piscsi-enums.h index 5d4efa4..9fc9bd8 100644 --- a/platforms/amiga/piscsi/piscsi-enums.h +++ b/platforms/amiga/piscsi/piscsi-enums.h @@ -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 { diff --git a/platforms/amiga/piscsi/piscsi.c b/platforms/amiga/piscsi/piscsi.c index c78650c..3f354dd 100644 --- a/platforms/amiga/piscsi/piscsi.c +++ b/platforms/amiga/piscsi/piscsi.c @@ -14,19 +14,33 @@ #define BE(val) be32toh(val) #define BE16(val) be16toh(val) -// Comment these lines to restore debug output: +// 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 printf #define DEBUG_TRIVIAL(...) -//#define DEBUG_TRIVIAL printf #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) { diff --git a/platforms/amiga/piscsi/piscsi.h b/platforms/amiga/piscsi/piscsi.h index d327125..5ed0078 100644 --- a/platforms/amiga/piscsi/piscsi.h +++ b/platforms/amiga/piscsi/piscsi.h @@ -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; diff --git a/platforms/amiga/piscsi/piscsi.rom b/platforms/amiga/piscsi/piscsi.rom index 67af5f82e18b5fca07dbd56b536f7dcfcea5c6ca..85add466bc9ff7cd101f6efebaac9c0fc647e0d1 100644 GIT binary patch delta 1474 zcmb7EZ%kWN6#w1ZM|rSE_gcHs;*dvyQtGq?4AZzQ<;6^FNYiv^W=w2Tpr!uX3w!9) zMqcp?jm9lLV~ih-F@z9993e3w3sGXoLJT3sPsWA$!EO4<4@SoT&xOvwK51UgJ%8>w z=l;&Q=RV6~mc`~9RksSDg-8M%w*ao%VYS(<4E!29ec~dd5Zb<{UD?j60rst3QUjAE z3#gBXRSApL)mPS*h$H54#~~5b5INmC>bm<;pFlxreGY2(vrxK+;7ZTH>m+;sO`JYk zNpr0(e^qk~UN0%h2?NQA=#gl>Ch|&}6;!o1DKWIVf^InH%dei&nDpE9<+A;XI~H%x zgfhvA)bayyv}mdH7_@y$H70eIEF$Ccm!hu3*CJ0LLYYEZ5q?cBJY-9rlMNrHE(Om+ z%B~ta*_A6P&u45h7Sqm?#~8w~FjR%=$;rmu!Rrbk430qw))j!C+Ee-rWW|km4*bSA zJnoHh&y#*2?M>9zm#woQsgZ|#?(a|3D@co3Tv;*Ke6k4sfvW0k3}F4TtD=6l5D zsdq!-YPiUCvWOUX2*H=({IR@P$$?!!|1#jk z(|5Mlyx*j)ba}r+J2y;e!5Rf~wd04Wp0~qvm6thua1nV>Z-%q$rj=bYd3IIj*%j{+ z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