From 04bf2f6153608c0e6b7437cbb8eb4bdafe842254 Mon Sep 17 00:00:00 2001 From: beeanyew Date: Sun, 31 Jan 2021 12:14:16 +0100 Subject: [PATCH] [WIP] PiSCSI boot ROM disabled for now --- emulator.c | 22 + platforms/amiga/amiga-platform.c | 8 +- .../device_driver_amiga/2nd.scsi.device | Bin 0 -> 2900 bytes .../amiga/piscsi/device_driver_amiga/bootrom | Bin 536 -> 264 bytes .../piscsi/device_driver_amiga/bootrom.s | 479 +++++++++--------- .../amiga/piscsi/device_driver_amiga/build.sh | 6 +- .../piscsi/device_driver_amiga/makerom.c | 10 +- .../piscsi/device_driver_amiga/pi-scsi.device | Bin 2912 -> 2900 bytes .../piscsi/device_driver_amiga/piscsi-amiga.c | 16 +- .../piscsi/device_driver_amiga/scsi.device | Bin 0 -> 2916 bytes platforms/amiga/piscsi/piscsi-enums.h | 2 + platforms/amiga/piscsi/piscsi.c | 50 +- platforms/amiga/piscsi/piscsi.rom | Bin 16384 -> 16384 bytes 13 files changed, 327 insertions(+), 266 deletions(-) create mode 100644 platforms/amiga/piscsi/device_driver_amiga/2nd.scsi.device create mode 100644 platforms/amiga/piscsi/device_driver_amiga/scsi.device diff --git a/emulator.c b/emulator.c index 2fe2069..0de9337 100644 --- a/emulator.c +++ b/emulator.c @@ -344,6 +344,15 @@ int main(int argc, char *argv[]) { do_disasm = 1; printf("Real time disassembly is now %s\n", realtime_disassembly ? "on" : "off"); } + if (c == 'D') { + int r = get_mapped_item_by_address(cfg, 0x08000000); + if (r != -1) { + printf("Dumping first 16MB of mapped range %d.\n", r); + FILE *dmp = fopen("./memdmp.bin", "wb+"); + fwrite(cfg->map_data[r], 16 * SIZE_MEGA, 1, dmp); + fclose(dmp); + } + } if (c == 's' && realtime_disassembly) { do_disasm = 1; } @@ -436,6 +445,11 @@ unsigned int m68k_read_memory_8(unsigned int address) { return v; }*/ + /*if (m68k_get_reg(NULL, M68K_REG_PC) >= 0x080032F0 && m68k_get_reg(NULL, M68K_REG_PC) <= 0x080032F0 + 0x4000) { + stop_cpu_emulation(1); + }*/ + + if (mouse_hook_enabled) { if (address == CIAAPRA) { unsigned char result = (unsigned int)read8((uint32_t)address); @@ -482,6 +496,10 @@ unsigned int m68k_read_memory_8(unsigned int address) { unsigned int m68k_read_memory_16(unsigned int address) { PLATFORM_CHECK_READ(OP_TYPE_WORD); + /*if (m68k_get_reg(NULL, M68K_REG_PC) >= 0x080032F0 && m68k_get_reg(NULL, M68K_REG_PC) <= 0x080032F0 + 0x4000) { + stop_cpu_emulation(1); + }*/ + /*if (address >= 0xE90000 && address < 0xF00000) { printf("WORD read from DMAC @%.8X:", address); uint32_t v = cdtv_dmac_read(address & 0xFFFF, OP_TYPE_WORD); @@ -527,6 +545,10 @@ unsigned int m68k_read_memory_16(unsigned int address) { unsigned int m68k_read_memory_32(unsigned int address) { PLATFORM_CHECK_READ(OP_TYPE_LONGWORD); + /*if (m68k_get_reg(NULL, M68K_REG_PC) >= 0x080032F0 && m68k_get_reg(NULL, M68K_REG_PC) <= 0x080032F0 + 0x4000) { + stop_cpu_emulation(1); + }*/ + /*if (address >= 0xE90000 && address < 0xF00000) { printf("LONGWORD read from DMAC @%.8X:", address); uint32_t v = cdtv_dmac_read(address & 0xFFFF, OP_TYPE_LONGWORD); diff --git a/platforms/amiga/amiga-platform.c b/platforms/amiga/amiga-platform.c index 76621cd..da302ac 100644 --- a/platforms/amiga/amiga-platform.c +++ b/platforms/amiga/amiga-platform.c @@ -45,7 +45,7 @@ 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 uint8_t piscsi_diag_read; extern void stop_cpu_emulation(uint8_t disasm_cur); @@ -79,7 +79,7 @@ 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); + //stop_cpu_emulation(1); *val = handle_piscsi_read(addr, type); return 1; } @@ -342,8 +342,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++; + //ac_z2_type[ac_z2_pic_count] = ACTYPE_PSICSI; + //ac_z2_pic_count++; adjust_ranges_amiga(cfg); } if (piscsi_enabled) { diff --git a/platforms/amiga/piscsi/device_driver_amiga/2nd.scsi.device b/platforms/amiga/piscsi/device_driver_amiga/2nd.scsi.device new file mode 100644 index 0000000000000000000000000000000000000000..090a972c4ade3ebbc646e05ee63ee37ff8671151 GIT binary patch literal 2900 zcmai0VQgDh75?6{o4#0Y#&OdSAZuP6Cwg^V+f53Lu1wBLS|wKIL`hc)>h$6y&#t?~ zd9ve>Axk`W6B--RCLtkyAhaI{N(57c5Mom_h5gtsG*uNs{6H!bV`bGCsQjQbSc0b|YK0k*y*D1;I=STEQ>) z>>E-hTOGfRSh8I&LC?Mp$ahi+XtU`rr=eYXIj@Ej2!;TH6X#}}G z;7O9fq&h>pNhyf~w$`Tp4mIQCyX6G_g`luJllE-uX57qHAMEAv!k1|JXbnCn12y{o zDgxx%5d8eJA8(m452b2nV}fM-`&1Z&%V}3XzG5XDcbN0i)Emf9ru_}d$X_uyRKsDT zK3H?;cU1IkgJ;ZgN``e9!oZ)caYEt!bFvmQ-G^MwE2_^$kdXxE?6D#Oipb*t!=q?;f z29n6Z_lKit^eQoeax5QkW6ES-+xu2@xp6PP+}L$v{Y1MWLPpcpQNtd3g`OL^FDY|I z?L3K3M|9}+PNrT6YdWGTL692rLE}0!dpFuU=&s4gg?RKNLTl|VN_c;x-$1B8jn4iN zbPsJo>Ptg2(9%DkE4#Wu>V~P?^+0#-=Jdqug{he*wez`WEX~cSv0~*JO=OmK>c1M$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si/device_driver_amiga/bootrom index 1e806e7afd9011eb238d6f29de79cba2d0634cd5..15361d1c29827209dea21bf409cadb9569c4b451 100644 GIT binary patch literal 264 zcmbQh;K0BT#ITP+g8>M<{s0L+Ailt;$}9q;L82Bwe9tH^MXxxyI8!erwJb9^l_9`0 z*g4o!Aym&WCBIlNCo`!iv8a;4(aD*?uMh;4K_)RaFfb_SR4}k8*f6j#FcdNPt^02U zmOTKJaZqw7VgSiHzhumV=mN^m0%x1g1iGd;En-a&RJwOu~5F!PP zex=U8{x|up16tyskij74H^HxzL4ZMoL54x$|9=LR|Nnt}2Ilu&3=AysK4JcDnRzKe Wsl}Nosd*(pqZons2*^yJnoj_e(@4+& literal 536 zcmZWmJxc>Y5Pj!G3DLqrL`ZXhReVj3eth@`Qw z@<;dsthBMPQWR7Wtbz)HXkigF>+D5DaM+uu((9B^`b4hI z$e7toEq|uqvI-jLGxRKc$`E{j19rp*WBE0pNeg$y*$YBI$0;7(@^d>&;2$GYua=al zUjOAMsD&M)TZwDq>eLnG^?3(k8cjK*$@|`6zm9sLY4GQu`x^=bheBg&p)00nXek$O zPQY&DY_ME@43cnUTf*Em0*`4g@>y}gw=;7fC9Ks^X9{FhdgvZ@h!ZzK7n&S~t za<8(QrfR~L^f=r2dml9fn2C<}38A*t?CtV0s5g-l8}A!9<{cnNtjSm{i3!=T%M?ot~Fz?{$}ITyxFNIIbw686?6p`TZNH C6p$hS diff --git a/platforms/amiga/piscsi/device_driver_amiga/bootrom.s b/platforms/amiga/piscsi/device_driver_amiga/bootrom.s index 50c70c1..a8e8a5a 100644 --- a/platforms/amiga/piscsi/device_driver_amiga/bootrom.s +++ b/platforms/amiga/piscsi/device_driver_amiga/bootrom.s @@ -1,251 +1,228 @@ -/* ConfigDev passed in a3 */ -/* -struct ConfigDev { - struct Node cd_Node; // 0 2ptr,2byte,1ptr = 14byte - UBYTE cd_Flags; // 14 - UBYTE cd_Pad; // 15 - struct ExpansionRom cd_Rom; // 16 16bytes - APTR cd_BoardAddr; // 32 - ... -*/ -.set SysBase,4 -.set OpenLibrary,-552 -.set CloseLibrary,-414 -.set PutStr,-948 -.set VPrintf,-954 -.set AllocMem,-198 -.set FindResident,-96 - -start: - jmp realstart(pc) - handover: - jmp trampoline(pc) - -.align 4 -realstart: - movea.l SysBase,a6 /* allocate RAM for loading ourselves to */ - move.l #0x40000,d0 - moveq #0,d1 /* MEMF_ANY */ - jsr AllocMem(a6) - tst.l d0 - beq allocfail - - move.l d0, a4 /* load addr */ - - move.l (a7)+,a3 /* restore configdev address from stack */ - jmp 0x24(a4) /* jmp to handover at new memory location (0x20+0x04) */ - -.align 4 -allocfail: - move.l d1,0xdff180 - add.l #1,d1 - bra allocfail - -/* we will arrive here in our copy in amiga RAM */ -/* a0 contains board addr, a3 contains configdev addr */ -.align 4 -trampoline: - lea configdev(pc),a1 - move.l a3,(a1) /* store configdev pointer */ - - move.l a4, a0 /* board addr not needed anymore, keep loadaddr in a0 */ - - /* add resident ---------------------- */ - - /* mntsd.device is at loadaddr + 0x400 (skip 2 blocks) */ - move.l a0,-(a7) - add.l #0x400, a0 - /* relocate the binary (hunk) */ - jsr relocstart(pc) - move.l (a7)+, a0 /* address of loaded mntsd.device */ - move.l a0, a4 - move.l a4, a1 /* restore board addr */ - - add.l #0x400+0x180, a1 /* start of mntsd.device + $180 = romtag FIXME */ - move.l #0, d1 /* no seglist */ - move.l 4,a6 - jsr -102(a6) /* InitResident */ - /* object = InitResident(resident, segList) */ - /* D0 A1 D1 */ - - /* make dos node --------------------- */ - - jmp initdos(pc) - -.align 4 -configdev: - .long 0 - -segtprs: - .long 0 - .long 0 - - .align 4 - relocstart: - lea.l segptrs(pc), a1 - - move.l 8(a0), d4 /* number of hunks */ - move.l #0, d5 - - /* - a0: executable base addr - a1: segptrs - a2: addr of hunk0 - - d4: numhunks - d5: pass# - d6: current hunk addr - */ - - /* hunk 0 address in memory */ - move.l a0, d6 - add.l #0x24, d6 - move.l d6, a2 /* addr of first hunk */ - move.l d6, (a1) /* store pointer to this hunk in segptrs[1] */ - -relocpass: - move.l a2, a3 - move.l 0x14(a0), d0 /* ptr to first hunk size */ - - lsl.l #2, d0 /* firsthunk + first size */ - add.l d0, a3 /* end of first hunk, start of reloc table */ - - jsr reloctables(pc) - - add.l #4, a3 /* skip hunk_end */ - add.l #4, a3 /* skip hunk_data */ - move.l (a3)+, d0 /* size of data hunk */ - lsl.l #2, d0 - - move.l a3, 4(a1) /* store pointer to this hunk in segptrs[1] */ - move.l a3, d6 /* save current hunk ptr for patching CHECKME */ - add.l d0, a3 /* arrive at reloc tables of data hunk */ - - jsr reloctables(pc) - - cmp #1, d5 - bge rcomplete - - /* start pass 1 */ - move.l #1, d5 - move.l a2, d6 /* addr of first hunk */ - bra relocpass - -rcomplete: - rts - -.align 4 -reloctables: - move.l (a3)+, d2 /* skip 0000 03ec marker */ - reloctable: - move.l (a3)+, d2 /* number of relocs to process */ - - tst.w d2 - beq relocdone /* done if zero */ - - move.l (a3)+, d1 /* segment number to point to */ - - lsl.l #2, d1 - move.l (a1,d1), d1 /* offset to add to target slots */ - - bra rloop -relocloop: - move.l (a3)+, a4 - - tst.w d5 /* pass = 0? */ - beq rloop - - /* pass = 1, so patch */ - add.l d6, a4 /* add current hunk address */ - add.l d1, (a4) /* the actual patching */ - - move.l d1, 0xdff180 - rloop: - dbra d2, relocloop - jmp reloctable(pc) - relocdone: - rts - -.align 4 -initdos: - move.l 4,a6 - lea expansionname(pc),a1 - - moveq #37, d0 - jsr OpenLibrary(a6) /* open expansion.library */ - tst.l d0 - beq.s nodos - move.l d0,a6 - - /*movem.l a0-a6/d0-d6,-(a7) - move.l #0xbeef,d2 - lea.l fmtdebug(pc),a1 - jsr printf(pc) - movem.l (a7)+,a0-a6/d0-d6*/ - - lea dosnode(pc),a0 - lea diskname(pc),a1 - move.l a1,(a0) /* store in parmpkt */ - lea devicename(pc),a1 - move.l a1,4(a0) /* store in parmpkt */ - - jsr -144(a6) /* MakeDosNode */ - move.l d0, a0 /* fresh device node */ - - /* add boot node --------------------- */ - - move.l #0, d0 - move.l #0, d1 - move.l configdev(pc),a1 - /*move.l #0, a1*/ /* later put ConfigDev here (a3) */ - jsr -36(a6) /* AddBootNode */ - - move.l a6,a1 /* close expansion library */ - move.l 4,a6 - jsr CloseLibrary(a6) - moveq #1,d0 - move.l (a7)+,a6 - rts - -nodos: - move.l d1,0xdff180 - add.l #1,d1 - bra nodos - - moveq #1,d0 - move.l (a7)+,a6 - rts - -.align 4 -diskname: - .asciz "PDH0" - .align 4 -devicename: - .asciz "pi-scsi.device" - .align 4 -expansionname: - .asciz "expansion.library" - .align 4 -dosnode: - .long 0 /* dos disk name */ - .long 0 /* device file name */ - .long 0 /* unit */ - .long 0 /* flags */ - .long 16 /* length of node? */ - .long 128 /* longs in a block */ - .long 0 - .long 4 /* surfaces */ - .long 1 /* sectors per block */ - .long 256 /* blocks per track */ - .long 2 /* reserved bootblocks 256 = 128KB */ - .long 0 - .long 0 - .long 2 /* lowcyl FIXME */ - /*.long 2047*/ /* hicyl */ - .long 1023 - .long 10 /* buffers */ - .long 0 /* MEMF_ANY */ - .long 0x0001fe00 /* MAXTRANS */ - .long 0x7ffffffe /* Mask */ - .long -1 /* boot prio */ - .long 0x444f5303 /* dostype: DOS3 */ +** +** Sample autoboot code fragment +** +** These are the calling conventions for the Diag routine +** +** A7 -- points to at least 2K of stack +** A6 -- ExecBase +** A5 -- ExpansionBase +** A3 -- your board's ConfigDev structure +** A2 -- Base of diag/init area that was copied +** A0 -- Base of your board +** +** Your Diag routine should return a non-zero value in D0 for success. +** If this value is NULL, then the diag/init area that was copied +** will be returned to the free memory pool. +** + + INCLUDE "exec/types.i" + INCLUDE "exec/nodes.i" + INCLUDE "exec/resident.i" + INCLUDE "libraries/configvars.i" + + ; LVO's resolved by linking with library amiga.lib + XREF _LVOFindResident + +ROMINFO EQU 0 +ROMOFFS EQU $0 + +* ROMINFO defines whether you want the AUTOCONFIG information in +* the beginning of your ROM (set to 0 if you instead have PALS +* providing the AUTOCONFIG information instead) +* +* ROMOFFS is the offset from your board base where your ROMs appear. +* Your ROMs might appear at offset 0 and contain your AUTOCONFIG +* information in the high nibbles of the first $40 words ($80 bytes). +* Or, your autoconfig ID information may be in a PAL, with your +* ROMs possibly being addressed at some offset (for example $2000) +* from your board base. This ROMOFFS constant will be used as an +* additional offset from your configured board address when patching +* structures which require absolute pointers to ROM code or data. + +*----- We'll store Version and Revision in serial number +VERSION EQU 37 ; also the high word of serial number +REVISION EQU 1 ; also the low word of serial number + +* See the Addison-Wesley Amiga Hardware Manual for more info. + +MANUF_ID EQU 2011 ; CBM assigned (2011 for hackers only) +PRODUCT_ID EQU 1 ; Manufacturer picks product ID + +BOARDSIZE EQU $10000 ; How much address space board decodes +SIZE_FLAG EQU 3 ; Autoconfig 3-bit flag for BOARDSIZE + ; 0=$800000(8meg) 4=$80000(512K) + ; 1=$10000(64K) 5=$100000(1meg) + ; 2=$20000(128K) 6=$200000(2meg) + ; 3=$40000(256K) 7=$400000(4meg) + CODE + +AllocMem EQU -198 + +******* RomStart *************************************************** +********************************************************************** + +RomStart: + +******* DiagStart ************************************************** +DiagStart: ; This is the DiagArea structure whose relative offset from + ; your board base appears as the Init Diag vector in your + ; autoconfig ID information. This structure is designed + ; to use all relative pointers (no patching needed). + dc.b DAC_WORDWIDE+DAC_CONFIGTIME ; da_Config + dc.b 0 ; da_Flags + dc.w $4000 ; da_Size + dc.w DiagEntry-DiagStart ; da_DiagPoint + dc.w BootEntry-DiagStart ; da_BootPoint + dc.w DevName-DiagStart ; da_Name + dc.w 0 ; da_Reserved01 + dc.w 0 ; da_Reserved02 + +******* Resident Structure ***************************************** +Romtag: + dc.w RTC_MATCHWORD ; UWORD RT_MATCHWORD +rt_Match: dc.l Romtag-DiagStart ; APTR RT_MATCHTAG +rt_End: dc.l EndCopy-DiagStart ; APTR RT_ENDSKIP + dc.b RTW_COLDSTART ; UBYTE RT_FLAGS + dc.b VERSION ; UBYTE RT_VERSION + dc.b NT_DEVICE ; UBYTE RT_TYPE + dc.b 20 ; BYTE RT_PRI +rt_Name: dc.l DevName-DiagStart ; APTR RT_NAME +rt_Id: dc.l IdString-DiagStart ; APTR RT_IDSTRING +rt_Init: dc.l Init-RomStart ; APTR RT_INIT + + +******* Strings referenced in Diag Copy area ************************ +DevName: dc.b '2nd.scsi.device',0 ; Name string +IdString dc.b 'PISCSI ',48+VERSION,'.',48+REVISION ; Id string + +DosName: dc.b 'dos.library',0 ; DOS library name + +DosDevName: dc.b 'ABC',0 ; dos device name for MakeDosNode() + ; (dos device will be ABC:) + + ds.w 0 ; word align + +******* DiagEntry ************************************************** +********************************************************************** +* +* success = DiagEntry(BoardBase,DiagCopy, configDev) +* d0 a0 a2 a3 +* +* Called by expansion architecture to relocate any pointers +* in the copied diagnostic area. We will patch the romtag. +* If you have pre-coded your MakeDosNode packet, BootNode, +* or device initialization structures, they would also need +* to be within this copy area, and patched by this routine. +* +********************************************************************** + +DiagEntry: + nop + nop + nop + move.l #1,$80000020 + + movea.l 4,a6 + move.l #$40000,d0 + moveq #0,d1 + jsr AllocMem(a6) + + nop + nop + move.l d0,$80000040 + + move.l d0,a1 + move.l #0,d1 + movea.l 4,a6 + add.l #$16e,a1 + nop + nop + nop + jsr -102(a6) + nop + nop + bra.s endpatches + + + lea patchTable-RomStart(a0),a1 ; find patch table + adda.l #ROMOFFS,a1 ; adjusting for ROMOFFS + +* Patch relative pointers to labels within DiagCopy area +* by adding Diag RAM copy address. These pointers were coded as +* long relative offsets from base of the DiagArea structure. +* +dpatches: + move.l a2,d1 ;d1=base of ram Diag copy +dloop: + move.w (a1)+,d0 ;d0=word offs. into Diag needing patch + bmi.s bpatches ;-1 is end of word patch offset table + add.l d1,0(a2,d0.w) ;add DiagCopy addr to coded rel. offset + bra.s dloop + +* Patches relative pointers to labels within the ROM by adding +* the board base address + ROMOFFS. These pointers were coded as +* long relative offsets from RomStart. +* +bpatches: + move.l a0,d1 ;d1 = board base address + add.l #ROMOFFS,d1 ;add offset to where your ROMs are +rloop: + move.w (a1)+,d0 ;d0=word offs. into Diag needing patch + bmi.s endpatches ;-1 is end of patch offset table + add.l d1,0(a2,d0.w) ;add ROM address to coded relative offset + bra.s rloop + +endpatches: + moveq.l #1,d0 ; indicate "success" + rts + + +******* BootEntry ************************************************** +********************************************************************** + +BootEntry: lea DosName(PC),a1 ; 'dos.library',0 + jsr _LVOFindResident(a6) ; find the DOS resident tag + move.l d0,a0 ; in order to bootstrap + move.l RT_INIT(A0),a0 ; set vector to DOS INIT + jsr (a0) ; and initialize DOS + rts + +* +* End of the Diag copy area which is copied to RAM +* +EndCopy: +************************************************************************* + +************************************************************************* +* +* Beginning of ROM driver code and data that is accessed only in +* the ROM space. This must all be position-independent. +* + +patchTable: +* Word offsets into Diag area where pointers need Diag copy address added + dc.w rt_Match-DiagStart + dc.w rt_End-DiagStart + dc.w rt_Name-DiagStart + dc.w rt_Id-DiagStart + dc.w -1 + +* Word offsets into Diag area where pointers need boardbase+ROMOFFS added + dc.w rt_Init-DiagStart + dc.w -1 + +******* Romtag InitEntry ********************************************** +************************************************************************* + +Init: ; After Diag patching, our romtag will point to this + ; routine in ROM so that it can be called at Resident + ; initialization time. + ; This routine will be similar to a normal expansion device + ; initialization routine, but will MakeDosNode then set up a + ; BootNode, and Enqueue() on eb_MountList. + ; + rts + + ; Rest of your position-independent device code goes here. + + END diff --git a/platforms/amiga/piscsi/device_driver_amiga/build.sh b/platforms/amiga/piscsi/device_driver_amiga/build.sh index 9fd02f7..f75f35c 100644 --- a/platforms/amiga/piscsi/device_driver_amiga/build.sh +++ b/platforms/amiga/piscsi/device_driver_amiga/build.sh @@ -1,4 +1,8 @@ #m68k-amigaos-gcc piscsi-amiga.c -ramiga-dev -noixemul -fbaserel -O2 -o pi-scsi.device -ldebug -lamiga -m68020 m68k-amigaos-gcc -m68020 -O2 -o pi-scsi.device -ramiga-dev -noixemul -fbaserel piscsi-amiga.c -ldebug -lamiga -m68k-amigaos-as -m68000 bootrom.s && m68k-amigaos-objcopy --strip-all ./a.out ./bootrom +m68k-amigaos-gcc -m68020 -O2 -o scsi.device -ramiga-dev -noixemul -fbaserel piscsi-amiga.c -ldebug -lamiga -D_FSCSIDEV +m68k-amigaos-gcc -m68020 -O2 -o 2nd.scsi.device -ramiga-dev -noixemul -fbaserel piscsi-amiga.c -ldebug -lamiga -D_FSCSI2ND +vasmm68k_mot.exe -m68020 -Fhunk -I$VBCC/NDK39/include/include_i bootrom.s -o a.out +#m68k-amigaos-as -m68020 bootrom.s && +m68k-amigaos-objcopy --strip-all ./a.out ./bootrom rm ./a.out diff --git a/platforms/amiga/piscsi/device_driver_amiga/makerom.c b/platforms/amiga/piscsi/device_driver_amiga/makerom.c index 2c94fbe..0a5ccda 100644 --- a/platforms/amiga/piscsi/device_driver_amiga/makerom.c +++ b/platforms/amiga/piscsi/device_driver_amiga/makerom.c @@ -20,9 +20,15 @@ int main(int argc, char *argv[]) { fclose(rom); return 1; } - FILE *device = fopen("pi-scsi.device", "rb"); + FILE *device = NULL; + if (argc > 1) { + device = fopen(argv[1], "rb"); + } + else { + device = fopen("pi-scsi.device", "rb"); + } if (!device) { - printf("Could not open file pi-scsi.device for reading.\n"); + printf("Could not open device file for reading.\n"); fclose(rom); fclose(out); return 1; diff --git a/platforms/amiga/piscsi/device_driver_amiga/pi-scsi.device b/platforms/amiga/piscsi/device_driver_amiga/pi-scsi.device index cdb46356ab49cc7e70e7ed1916837cb6657dd493..4d44af8f254bfabd466f620e053ce2ebdf2f0dda 100644 GIT binary patch delta 156 zcmaDLc13K0IPXse1_mAm2IiLx42(Y~s^~Jl+8ET&$gIu4HTenS9wCKX1`gvt42%s7 z3<^p$K$2zhDyF2(0?g&CqECQYnd3pgF)6>O#M2+h^_V<|!=15U@)Hhy#y^uqIMo?H zOt#^aW_&U^g0qT=nQ8JBppeGoKb*>p?MY{8|?7&WD BEg}E_ delta 184 zcmca2_CRccIPVVz1_mAm2IiLx42(Y}s^~I4+8ET&$jr#VF!>4N9x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fw$_yT4JFtR@d-@Uf&AGL27 zu@l`AwG`dvY+z@LYdXRw6lZa62RBQ!;N>$aYkXRZPs^7O(*O{>q1#D~29i#+NXZtS z?@@-%;NkHWCgkLzP&i%B{{q!aY35{Y2Dbbsw-S_cL46vN<0%R69 z9&)c_?29{7bRC zoCnQ-=0HmjyovWB-oL~9X}tNK+W@@-dKWSY^ev2?j~d2LV0;Jk0EFiG2Y1Glxp8jO zs+Wr<3$cbo!!T>+W(~u`@1ye=+$Qqtm0Efh?6jkUb=lk+7V-BIYrv<=C0?`za_r9I z^H(jcm!WgRky$1FEE<(>g2Qp{=uNJ!SDoE)PeXRdXzN*KrLbOEGfL~M-?P`zPp>T0 zDy1^YoWIj;|8%ohDzkqg$8`uEujFbuCZl4mt}j<1b>s13?y0I-dFV0zAu#F0Fl(9c z7j@y-`$9Bb$670g1ev>W2SJhZ+a+&DLt+JT_U9mrV7~#GXsqQ* z959AlYiOQ(AhzENIt*egI4@iqh>P*{OydG>fk$&{w8tGgakHKb3V=eOFbJ((Z^qYj zv%Gxi$tu!E6a%rpjN64=e$_M#7CX&jte6`{KG&%Y7Z=0Goi<8trQz=onq04(XI`W_ V{K9ip-CgGLMzu4~I%uAI{{iONefmap_offset[r]; + uint32_t rt_offs = 0; + uint8_t *dst_data = cfg->map_data[r]; + memcpy(dst_data + addr, piscsi_rom_ptr + 0x400, 0x3C00); + + uint32_t base_offs = be32toh(*((uint32_t *)&dst_data[addr + 0x170])) + 2; + rt_offs = val + 0x16E; + printf ("Offset 1: %.8X -> %.8X\n", base_offs, rt_offs); + *((uint32_t *)&dst_data[addr + 0x170]) = htobe32(rt_offs); + + uint32_t offs = be32toh(*((uint32_t *)&dst_data[addr + 0x174])); + printf ("Offset 2: %.8X -> %.8X\n", offs, (offs - base_offs) + rt_offs); + *((uint32_t *)&dst_data[addr + 0x174]) = htobe32((offs - base_offs) + rt_offs); + + dst_data[addr + 0x178] |= 0x07; + + offs = be32toh(*((uint32_t *)&dst_data[addr + 0x17C])); + printf ("Offset 3: %.8X -> %.8X\n", offs, (offs - base_offs) + rt_offs); + *((uint32_t *)&dst_data[addr + 0x17C]) = htobe32((offs - base_offs) + rt_offs); + + offs = be32toh(*((uint32_t *)&dst_data[addr + 0x180])); + printf ("Offset 4: %.8X -> %.8X\n", offs, (offs - base_offs) + rt_offs); + *((uint32_t *)&dst_data[addr + 0x180]) = htobe32((offs - base_offs) + rt_offs); + + offs = be32toh(*((uint32_t *)&dst_data[addr + 0x184])); + printf ("Offset 5: %.8X -> %.8X\n", offs, (offs - base_offs) + rt_offs); + *((uint32_t *)&dst_data[addr + 0x184]) = htobe32((offs - base_offs) + rt_offs); + + } + else { + for (int i = 0; i < 0x3C00; i++) { + uint8_t src = piscsi_rom_ptr[0x400 + i]; + write8(addr + i, src); + } + } + break; + } default: printf("[PISCSI] Unhandled %s register write to %.8X: %d\n", op_type_names[type], addr, val); break; @@ -205,7 +251,7 @@ uint32_t handle_piscsi_read(uint32_t addr, uint8_t type) { if ((addr & 0xFFFF) >= PISCSI_CMD_ROM) { uint32_t romoffs = (addr & 0xFFFF) - PISCSI_CMD_ROM; - if (romoffs < 14 && !piscsi_diag_read) { + /*if (romoffs < 14 && !piscsi_diag_read) { printf("[PISCSI] %s read from DiagArea @$%.4X: ", op_type_names[type], romoffs); uint32_t v = 0; switch (type) { @@ -226,7 +272,7 @@ uint32_t handle_piscsi_read(uint32_t addr, uint8_t type) { 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; diff --git a/platforms/amiga/piscsi/piscsi.rom b/platforms/amiga/piscsi/piscsi.rom index 203c0b600ec8bc7d9eef80f4e96b67c7601fed83..96db6f657bae1231f00a4b7609db1005f7156160 100644 GIT binary patch delta 445 zcmYLE&npB`9RIwT*(L2vON+!|8bo38<03gMQ?%01ikz$;vt`0yb_pqyqYL$Ja&UHV zFjvXJA0S*gIV=YxIc!_wI~;sp-}gS>&*yzUujhHp^Vr@Il0X_)Xa&_si8h7$mNknB zIzzUX`l;Ko^xQ(u)~)QOy^zItYQmUEsgrt_wVKnH?Rj_3-NwM60dqZEjbRe=0JVJ! zlG+amaABSYeZT58DM>Bq?je+o7v}ug=)!S`W;LULTdktAZYg?y0nC1D<#(49iGOB| znHxqi*f-DVm880e8uQ59KpY7)Kn(&k1p&_`q^dfJPI@qh9mJXTNh6?^1xvWxGP~KDe`o^Qkc!NBK!?nC1C%Oc%<)6LJgt;{9?xEAVM~M-Zd@fv9#~k{j6@SCv}! g%6pZz${ETMGAnboLxA81&nqpFuQ1U+Ri?Xs0MfX6mjD0& delta 731 zcmYjOO=uHQ5T3WYi6JJzLR*w5tee;@nx^*RK|G}CR@+#%TB$@lS_f6!b5aS!c=PJ0Dr@uA@{(GD-o{&$6o>tKnHo-zL>UF00LriEGu^) z3J`e#pMF@2cXMF>nnu3R#yvN+_T?0MUFHSQPs}K+kf8U zJuk$QQ$5fzm*Th3OQ+{t@fx4ha2i70PT^Jd1bJ|&enBJgti1aFL*sNny1ywia77$AGao`Fm(@r44c)RpuFm|egG!K%N z^Jd;zSzRfsMOVO)eVPl_8KzJ7f-w@MTqttl3(`5HFByt1DQnYZ)xe