gayle_free_units ();
}
+struct hardfiledata *get_hardfile_data_controller(int nr)
+{
+ UnitInfo *uip = mountinfo.ui;
+ for (int i = 0; i < MAX_FILESYSTEM_UNITS; i++) {
+ if (uip[i].open == 0 || is_virtual(i))
+ continue;
+ if (uip[i].hf.ci.controller_unit == nr)
+ return &uip[i].hf;
+ }
+ return NULL;
+}
struct hardfiledata *get_hardfile_data (int nr)
{
UnitInfo *uip = mountinfo.ui;
if (nr < 0 || nr >= MAX_FILESYSTEM_UNITS || uip[nr].open == 0 || is_virtual (nr))
- return 0;
+ return NULL;
return &uip[nr].hf;
}
return 1;
}
+#define FS_TEST_HACK 0
+#if FS_TEST_HACK
+static uae_u32 REGPARAM2 ks13patchstartup(TrapContext *ctx)
+{
+ uaecptr startup = trap_get_areg(ctx, 0);
+ uaecptr doslib = 0x00c06230;
+ uaecptr root = get_long(doslib + 34);
+ uaecptr node = (get_long(root + 24) << 2) + 4;
+ uaecptr dp_arg2 = get_long(startup + 24);
+ for (;;) {
+ node = get_long(node) << 2;
+ if (!node)
+ break;
+ if (get_long(node + 4) != 0)
+ continue;
+ if (get_long(node + 28) != dp_arg2)
+ continue;
+ put_long(startup + 20, get_long(node + 40)); // dp_Arg1 = dol_Node
+ put_long(startup + 28, node >> 2); // dp_Arg3 = dl
+ activate_debugger();
+ return dp_arg2 << 2;
+ }
+ return 0;
+}
+
+static void patchhackfs(uaecptr seg)
+{
+ int o = rtarea_base + 0xFEFA;
+ put_long(seg + 9806, 0x70ff70ff);
+ seg += 9632;
+ put_word(seg, 0x4eb9);
+ put_long(seg + 2, o);
+ put_word(seg + 6, 0x2440); // move.l d0,a2
+ org(o);
+ calltrap(deftrap2(ks13patchstartup, 0, _T("ks13patchstartup")));
+ dw(RTS);
+}
+#endif
+
static uae_u32 REGPARAM2 filesys_dev_bootfilesys (TrapContext *ctx)
{
uaecptr devicenode = trap_get_areg(ctx, 3);
return 0;
}
+ dostype = trap_get_long(ctx, parmpacket + 80);
if (trap_get_long(ctx, parmpacket + PP_FSPTR) && !trap_get_long(ctx, parmpacket + PP_ADDTOFSRES)) {
uaecptr fsptr = trap_get_long(ctx, parmpacket + PP_FSPTR);
uip->filesysseg = fsptr;
seglist = (trap_get_long(ctx, rtarea_base + bootrom_header + 4 + 6 * 4) + rtarea_base + bootrom_header) >> 2;
}
trap_put_long(ctx, devicenode + 4 + 7 * 4, seglist);
+ write_log(_T("Filesys %08x entry=%08x\n"), dostype, fsptr);
return 1;
}
- dostype = trap_get_long(ctx, parmpacket + 80);
fsnode = trap_get_long(ctx, fsres + 18);
while (trap_get_long(ctx, fsnode)) {
dostype2 = trap_get_long(ctx, fsnode + 14);
for (int i = 0; i < 32; i++) {
if (pf & (1 << i)) {
uae_u32 data = trap_get_long(ctx, fsnode + 22 + 4 + i * 4);
- if (i == 7 && bcplonlydos()) { // seglist
- // point seglist to bcpl wrapper and put original seglist in dn_Handler
- trap_put_long(ctx, devicenode + 4 + 3 * 4, trap_get_long(ctx, fsnode + 22 + 4 + 7 * 4));
- data = (trap_get_long(ctx, rtarea_base + bootrom_header + 4 + 6 * 4) + rtarea_base + bootrom_header) >> 2;
+ if (i == 7) {
+ if (bcplonlydos()) { // seglist
+ // point seglist to bcpl wrapper and put original seglist in dn_Handler
+ trap_put_long(ctx, devicenode + 4 + 3 * 4, trap_get_long(ctx, fsnode + 22 + 4 + 7 * 4));
+ data = (trap_get_long(ctx, rtarea_base + bootrom_header + 4 + 6 * 4) + rtarea_base + bootrom_header) >> 2;
+ }
+ write_log(_T("Filesys %08x entry=%08x\n"), dostype, data << 2);
+#if FS_TEST_HACK
+ patchhackfs(data << 2);
+#endif
}
trap_put_long(ctx, devicenode + 4 + i * 4, data);
}
trap_put_long(ctx, parmpacket + PP_FSSIZE, 0);
trap_put_long(ctx, parmpacket + PP_FSPTR, seg);
trap_put_long(ctx, parmpacket + PP_ADDTOFSRES, 0);
- write_log (_T("RDB: faked RDB filesystem '%s' reused\n"), uip->filesysdir);
+ write_log (_T("RDB: faked RDB filesystem '%s' reused, entry=%08x\n"), uip->filesysdir, seg << 2);
return FILESYS_HARDFILE;
}
}
trap_get_bytes(ctx, sd->cmd, scsi_cmd, sd->cmd_len);
for (int i = 0; i < sd->cmd_len; i++) {
- scsi_log (_T("%02X%c"), cmdbuf[i], i < sd->cmd_len - 1 ? '.' : ' ');
+ scsi_log (_T("%02X%c"), sd->cmd[i], i < sd->cmd_len - 1 ? '.' : ' ');
}
scsi_log (_T("\n"));
scsi_log (_T("RD:"));
int i = 0;
while (i < sd->reply_len && i < 24) {
- scsi_log (_T("%02X%c"), reply[i], i < reply_len - 1 ? '.' : ' ');
+ scsi_log (_T("%02X%c"), sd->reply[i], i < sd->reply_len - 1 ? '.' : ' ');
i++;
}
scsi_log (_T("\n"));
/* Check unit number */
if (unit >= 0 && unit < MAX_FILESYSTEM_UNITS) {
struct hardfileprivdata *hfpd = &hardfpd[unit];
- struct hardfiledata *hfd = get_hardfile_data (unit);
+ struct hardfiledata *hfd = get_hardfile_data_controller(unit);
if (hfd && (hfd->handle_valid || hfd->drive_empty) && start_thread (ctx, unit)) {
trap_put_word(ctx, hfpd->base + 32, trap_get_word(ctx, hfpd->base + 32) + 1);
trap_put_long(ctx, ioreq + 24, unit); /* io_Unit */
{
uae_u32 request = trap_get_areg (ctx, 1);
int unit = mangleunit (trap_get_long(ctx, request + 24));
- struct hardfiledata *hfd = get_hardfile_data (unit);
+ struct hardfiledata *hfd = get_hardfile_data_controller(unit);
struct hardfileprivdata *hfpd = &hardfpd[unit];
hf_log2 (_T("uaehf.device abortio "));
int cmd = get_word_host(iobuf + 28);
int unit = mangleunit(get_long_host(iobuf + 24));
- struct hardfiledata *hfd = get_hardfile_data(unit);
+ struct hardfiledata *hfd = get_hardfile_data_controller(unit);
struct hardfileprivdata *hfpd = &hardfpd[unit];
put_byte_host(iobuf + 8, NT_MESSAGE);
uae_sem_post (&hfpd->sync_sem);
uae_sem_post (&change_sem);
return 0;
- } else if (hardfile_do_io(ctx, get_hardfile_data (hfpd - &hardfpd[0]), hfpd, iobuf, request) == 0) {
+ } else if (hardfile_do_io(ctx, get_hardfile_data_controller(hfpd - &hardfpd[0]), hfpd, iobuf, request) == 0) {
put_byte_host(iobuf + 30, get_byte_host(iobuf + 30) & ~1);
trap_put_bytes(ctx, iobuf + 8, request + 8, 48 - 8);
release_async_request(hfpd, request);