From: Toni Wilen Date: Sun, 31 Jan 2016 13:52:27 +0000 (+0200) Subject: Indirect trap system support. X-Git-Tag: 3300~99 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=7da6a52378d074a4b030aca951172cf183286045;p=francis%2Fwinuae.git Indirect trap system support. --- diff --git a/autoconf.cpp b/autoconf.cpp index c7e2adb6..7e38e2b8 100644 --- a/autoconf.cpp +++ b/autoconf.cpp @@ -18,6 +18,9 @@ #include "newcpu.h" #include "autoconf.h" #include "traps.h" +#include "debug.h" +#include "threaddep/thread.h" +#include "native2amiga.h" /* Commonly used autoconfig strings */ @@ -28,6 +31,11 @@ uaecptr EXPANSION_bootcode, EXPANSION_nullfunc; /* ROM tag area memory access */ uaecptr rtarea_base = RTAREA_DEFAULT; +HANDLE hardware_trap_event[RTAREA_TRAP_DATA_SIZE / RTAREA_TRAP_DATA_SLOT_SIZE]; + +static uaecptr rt_trampoline_ptr, trap_entry; +extern volatile uae_atomic hwtrap_waiting; +extern int filesystem_state; DECLARE_MEMORY_FUNCTIONS(rtarea); addrbank rtarea_bank = { @@ -35,9 +43,60 @@ addrbank rtarea_bank = { rtarea_lput, rtarea_wput, rtarea_bput, rtarea_xlate, rtarea_check, NULL, _T("rtarea"), _T("UAE Boot ROM"), rtarea_lget, rtarea_wget, - ABFLAG_ROMIN, S_READ, S_WRITE + ABFLAG_ROMIN | ABFLAG_PPCIOSPACE, S_READ, S_WRITE }; +static void hwtrap_check_int(void) +{ + if (hwtrap_waiting == 0) { + atomic_and(&uae_int_requested, ~0x2000); + } else { + atomic_or(&uae_int_requested, 0x2000); + set_special_exter(SPCFLAG_UAEINT); + } +} + +static bool istrapwait(void) +{ + for (int i = 0; i < RTAREA_TRAP_DATA_NUM; i++) { + uae_u8 *data = rtarea_bank.baseaddr + RTAREA_TRAP_DATA + i * RTAREA_TRAP_DATA_SLOT_SIZE; + uae_u8 *status = rtarea_bank.baseaddr + RTAREA_TRAP_STATUS + i * RTAREA_TRAP_STATUS_SIZE; + if (get_long_host(data + RTAREA_TRAP_DATA_TASKWAIT) && status[3] && status[2] >= 0x80) { + return true; + } + } + return false; +} + +bool rethink_traps(void) +{ + if (currprefs.uaeboard < 2) + return false; + if (istrapwait()) { + atomic_or(&uae_int_requested, 0x4000); + set_special_exter(SPCFLAG_UAEINT); + return true; + } else { + atomic_and(&uae_int_requested, ~0x4000); + return false; + } +} + +#define RTAREA_WRITEOFFSET 0xfff0 + +static bool rtarea_trap_data(uaecptr addr) +{ + if (addr >= RTAREA_TRAP_DATA && addr < RTAREA_TRAP_DATA + RTAREA_TRAP_DATA_SIZE) + return true; + return false; +} +static bool rtarea_trap_status(uaecptr addr) +{ + if (addr >= RTAREA_TRAP_STATUS && addr < RTAREA_TRAP_STATUS + RTAREA_TRAP_DATA_NUM * RTAREA_TRAP_STATUS_SIZE) + return true; + return false; +} + static uae_u8 *REGPARAM2 rtarea_xlate (uaecptr addr) { addr &= 0xFFFF; @@ -53,7 +112,8 @@ static int REGPARAM2 rtarea_check (uaecptr addr, uae_u32 size) static uae_u32 REGPARAM2 rtarea_lget (uaecptr addr) { addr &= 0xFFFF; - return (uae_u32)(rtarea_wget (addr) << 16) + rtarea_wget (addr + 2); + return (rtarea_bank.baseaddr[addr + 0] << 24) | (rtarea_bank.baseaddr[addr + 1] << 16) | + (rtarea_bank.baseaddr[addr + 2] << 8) | (rtarea_bank.baseaddr[addr + 3] << 0); } static uae_u32 REGPARAM2 rtarea_wget (uaecptr addr) { @@ -63,33 +123,100 @@ static uae_u32 REGPARAM2 rtarea_wget (uaecptr addr) static uae_u32 REGPARAM2 rtarea_bget (uaecptr addr) { addr &= 0xFFFF; + + if (rtarea_trap_status(addr)) { + uaecptr addr2 = addr - RTAREA_TRAP_STATUS; + int trap_offset = addr2 & (RTAREA_TRAP_STATUS_SIZE - 1); + int trap_slot = addr2 / RTAREA_TRAP_STATUS_SIZE; + if (trap_offset == 0) { + // 0 = busy wait, 1 = Wait() + rtarea_bank.baseaddr[addr] = filesystem_state ? 1 : 0; + } + } else if (addr == RTAREA_INTREQ + 0) { + rtarea_bank.baseaddr[addr] = atomic_bit_test_and_reset(&uae_int_requested, 0); + //write_log(rtarea_bank.baseaddr[addr] ? _T("+") : _T("-")); + } else if (addr == RTAREA_INTREQ + 1) { + rtarea_bank.baseaddr[addr] = hwtrap_waiting != 0; + } else if (addr == RTAREA_INTREQ + 2) { + if (rethink_traps()) { + rtarea_bank.baseaddr[addr] = 1; + } else { + rtarea_bank.baseaddr[addr] = 0; + } + } + hwtrap_check_int(); return rtarea_bank.baseaddr[addr]; } -#define RTAREA_WRITEOFFSET 0xfff0 +static bool rtarea_write(uaecptr addr) +{ + if (addr >= RTAREA_WRITEOFFSET) + return true; + if (addr >= RTAREA_SYSBASE && addr < RTAREA_SYSBASE + 4) + return true; + return rtarea_trap_data(addr) || rtarea_trap_status(addr); +} static void REGPARAM2 rtarea_bput (uaecptr addr, uae_u32 value) { addr &= 0xffff; - if (addr < RTAREA_WRITEOFFSET) + if (!rtarea_write(addr)) return; rtarea_bank.baseaddr[addr] = value; + if (!rtarea_trap_status(addr)) + return; + addr -= RTAREA_TRAP_STATUS; + int trap_offset = addr & (RTAREA_TRAP_STATUS_SIZE - 1); + int trap_slot = addr / RTAREA_TRAP_STATUS_SIZE; + if (trap_offset == RTAREA_TRAP_STATUS_SECOND + 3) { + uae_u8 v = (uae_u8)value; + if (v != 0xff && v != 0xfe && v != 0x01 && v != 02) + write_log(_T("trap %d status = %02x\n"), trap_slot, v); + if (v == 0xfe) + atomic_dec(&hwtrap_waiting); + if (v == 0x01) + atomic_dec(&hwtrap_waiting); + if (v == 0x01 || v == 0x02) { + // signal call_hardware_trap_back() + // FIXME: OS specific code! + SetEvent(hardware_trap_event[trap_slot]); + } + } } + static void REGPARAM2 rtarea_wput (uaecptr addr, uae_u32 value) { addr &= 0xffff; - if (addr < RTAREA_WRITEOFFSET) + value &= 0xffff; + if (!rtarea_write(addr)) return; rtarea_bput (addr, value >> 8); rtarea_bput (addr + 1, value & 0xff); + if (!rtarea_trap_status(addr)) + return; + addr -= RTAREA_TRAP_STATUS; + int trap_offset = addr & (RTAREA_TRAP_STATUS_SIZE - 1); + int trap_slot = addr / RTAREA_TRAP_STATUS_SIZE; + if (trap_offset == 0) { + //write_log(_T("TRAP %d (%d)\n"), trap_slot, value); + call_hardware_trap(rtarea_bank.baseaddr, rtarea_base, trap_slot); + } } static void REGPARAM2 rtarea_lput (uaecptr addr, uae_u32 value) { addr &= 0xffff; - if (addr < RTAREA_WRITEOFFSET) + if (!rtarea_write(addr)) return; - rtarea_wput (addr, value >> 16); - rtarea_wput (addr + 2, value & 0xffff); + rtarea_bank.baseaddr[addr + 0] = value >> 24; + rtarea_bank.baseaddr[addr + 1] = value >> 16; + rtarea_bank.baseaddr[addr + 2] = value >> 8; + rtarea_bank.baseaddr[addr + 3] = value >> 0; +} + +void rtarea_reset(void) +{ + memset(rtarea_bank.baseaddr + RTAREA_TRAP_DATA, 0, RTAREA_TRAP_DATA_SIZE); + memset(rtarea_bank.baseaddr + RTAREA_TRAP_STATUS, 0, RTAREA_TRAP_STATUS_SIZE * RTAREA_TRAP_DATA_NUM); } /* some quick & dirty code to fill in the rt area and save me a lot of @@ -168,7 +295,20 @@ uae_u32 ds_bstr_ansi (const uae_char *str) void calltrap (uae_u32 n) { - dw(0xA000 + n); + if (currprefs.uaeboard > 2) { + dw(0x4eb9); // JSR rt_trampoline_ptr + dl(rt_trampoline_ptr); + uaecptr a = here(); + org(rt_trampoline_ptr); + dw(0x3f3c); // MOVE.W #n,-(SP) + dw(n); + dw(0x4ef9); // JMP rt_trampoline_entry + dl(trap_entry); + org(a); + rt_trampoline_ptr += 3 * 2 + 1 * 4; + } else { + dw(0xA000 + n); + } } void org (uae_u32 a) @@ -188,27 +328,32 @@ void align (int b) rt_addr = (rt_addr + b - 1) & ~(b - 1); } -static uae_u32 REGPARAM2 nullfunc (TrapContext *context) +static uae_u32 REGPARAM2 nullfunc (TrapContext *ctx) { write_log (_T("Null function called\n")); return 0; } -static uae_u32 REGPARAM2 getchipmemsize (TrapContext *context) +static uae_u32 REGPARAM2 getchipmemsize (TrapContext *ctx) { - m68k_dreg (regs, 1) = z3chipmem_bank.allocated; - m68k_areg (regs, 1) = z3chipmem_bank.start; + trap_set_dreg(ctx, 1, z3chipmem_bank.allocated); + trap_set_areg(ctx, 1, z3chipmem_bank.start); return chipmem_bank.allocated; } -static uae_u32 REGPARAM2 uae_puts (TrapContext *context) +static uae_u32 REGPARAM2 uae_puts (TrapContext *ctx) { - puts ((char*)get_real_address (m68k_areg (regs, 0))); + puts ((char*)get_real_address(trap_get_areg(ctx, 0))); return 0; } void rtarea_init_mem (void) { + if (need_uae_boot_rom()) { + rtarea_bank.flags &= ~ABFLAG_ALLOCINDIRECT; + } else { + rtarea_bank.flags |= ABFLAG_ALLOCINDIRECT; + } rtarea_bank.allocated = RTAREA_SIZE; if (!mapped_malloc (&rtarea_bank)) { write_log (_T("virtual memory exhausted (rtarea)!\n")); @@ -216,7 +361,13 @@ void rtarea_init_mem (void) } } -void rtarea_init (void) +void rtarea_free(void) +{ + mapped_free(&rtarea_bank); + free_traps(); +} + +void rtarea_init(void) { uae_u32 a; TCHAR uaever[100]; @@ -224,6 +375,9 @@ void rtarea_init (void) rt_straddr = 0xFF00 - 2; rt_addr = 0; + rt_trampoline_ptr = rtarea_base + RTAREA_TRAMPOLINE; + trap_entry = 0; + init_traps (); rtarea_init_mem (); @@ -236,11 +390,23 @@ void rtarea_init (void) EXPANSION_doslibname = ds (_T("dos.library")); EXPANSION_uaedevname = ds (_T("uae.device")); - deftrap (NULL); /* Generic emulator trap */ - dw (0); dw (0); +#ifdef FILESYS + filesys_install_code(); + + trap_entry = filesys_get_entry(10); + write_log(_T("TRAP_ENTRY = %08x\n"), trap_entry); + + for (int i = 0; i < RTAREA_TRAP_DATA_SIZE / RTAREA_TRAP_DATA_SLOT_SIZE; i++) { + hardware_trap_event[i] = CreateEvent(NULL, FALSE, FALSE, NULL); + } + +#endif + + deftrap(NULL); /* Generic emulator trap */ + a = here (); /* Dummy trap - removing this breaks the filesys emulation. */ org (rtarea_base + 0xFF00); @@ -248,6 +414,7 @@ void rtarea_init (void) org (rtarea_base + 0xFF80); calltrap (deftrapres (getchipmemsize, TRAPFLAG_DORET, _T("getchipmemsize"))); + dw(RTS); org (rtarea_base + 0xFF10); calltrap (deftrapres (uae_puts, TRAPFLAG_NO_RETVAL, _T("uae_puts"))); @@ -255,10 +422,6 @@ void rtarea_init (void) org (a); -#ifdef FILESYS - filesys_install_code (); -#endif - uae_boot_rom_size = here () - rtarea_base; if (uae_boot_rom_size >= RTAREA_TRAPS) { write_log (_T("RTAREA_TRAPS needs to be increased!")); @@ -273,12 +436,7 @@ void rtarea_init (void) init_extended_traps (); } -volatile int uae_int_requested = 0; - -void set_uae_int_flag (void) -{ - rtarea_bank.baseaddr[RTAREA_INT] = uae_int_requested & 1; -} +volatile uae_atomic uae_int_requested = 0; void rtarea_setup (void) { diff --git a/blkdev.cpp b/blkdev.cpp index 168cece8..0bf0eeb3 100644 --- a/blkdev.cpp +++ b/blkdev.cpp @@ -12,6 +12,7 @@ #include "options.h" #include "memory.h" +#include "traps.h" #include "blkdev.h" #include "scsidev.h" #include "savestate.h" diff --git a/blkdev_cdimage.cpp b/blkdev_cdimage.cpp index 1c254c92..c5849f7c 100644 --- a/blkdev_cdimage.cpp +++ b/blkdev_cdimage.cpp @@ -17,6 +17,7 @@ #include #include "options.h" +#include "traps.h" #include "blkdev.h" #include "zfile.h" #include "gui.h" diff --git a/bsdsocket.cpp b/bsdsocket.cpp index 7bb42386..32702629 100644 --- a/bsdsocket.cpp +++ b/bsdsocket.cpp @@ -26,6 +26,8 @@ #ifdef BSDSOCKET +#define NEWTRAP 1 + int log_bsd = 0; struct socketbase *socketbases; static uae_u32 SockLibBase; @@ -91,69 +93,73 @@ uae_u32 addmem (uae_u32 * dst, const uae_char *src, int len) } /* Get current task */ -static uae_u32 gettask (TrapContext *context) +static uae_u32 gettask (TrapContext *ctx) { - uae_u32 currtask, a1 = m68k_areg (regs, 1); + uae_u32 currtask, a1 = trap_get_areg(ctx, 1); TCHAR *tskname; - m68k_areg (regs, 1) = 0; - currtask = CallLib (context, get_long (4), -0x126); /* FindTask */ + trap_call_add_areg(ctx, 1, 0); + currtask = trap_call_lib(ctx, trap_get_long(ctx, 4), -0x126); /* FindTask */ - m68k_areg (regs, 1) = a1; + trap_set_areg(ctx, 1, a1); - tskname = au((char*)get_real_address (get_long (currtask + 10))); - BSDTRACE ((_T("[%s] "), tskname)); - xfree (tskname); + if (ISBSDTRACE) { + tskname = au((char*)get_real_address (trap_get_long(ctx, currtask + 10))); + BSDTRACE ((_T("[%s] "), tskname)); + xfree (tskname); + } return currtask; } /* errno/herrno setting */ -void bsdsocklib_seterrno (SB, int sb_errno) +void bsdsocklib_seterrno (TrapContext *ctx, SB, int sb_errno) { sb->sb_errno = sb_errno; if (sb->sb_errno >= 1001 && sb->sb_errno <= 1005) - bsdsocklib_setherrno(sb,sb->sb_errno-1000); + bsdsocklib_setherrno(ctx, sb,sb->sb_errno-1000); if (sb->errnoptr) { switch (sb->errnosize) { case 1: - put_byte (sb->errnoptr, sb_errno); - break; + trap_put_byte(ctx, sb->errnoptr, sb_errno); + break; case 2: - put_word (sb->errnoptr, sb_errno); - break; + trap_put_word(ctx, sb->errnoptr, sb_errno); + break; case 4: - put_long (sb->errnoptr, sb_errno); + trap_put_long(ctx, sb->errnoptr, sb_errno); + break; } } } -void bsdsocklib_setherrno (SB, int sb_herrno) +void bsdsocklib_setherrno(TrapContext *ctx, SB, int sb_herrno) { sb->sb_herrno = sb_herrno; if (sb->herrnoptr) { switch (sb->herrnosize) { case 1: - put_byte (sb->herrnoptr, sb_herrno); - break; + trap_put_byte(ctx, sb->herrnoptr, sb_herrno); + break; case 2: - put_word (sb->herrnoptr, sb_herrno); - break; + trap_put_word(ctx, sb->herrnoptr, sb_herrno); + break; case 4: - put_long (sb->herrnoptr, sb_herrno); + trap_put_long(ctx, sb->herrnoptr, sb_herrno); + break; } } } -uae_u32 callfdcallback (TrapContext *context, SB, uae_u32 fd, uae_u32 action) +uae_u32 callfdcallback (TrapContext *ctx, SB, uae_u32 fd, uae_u32 action) { uae_u32 v; if (!sb->fdcallback) return 0; BSDTRACE((_T("FD_CALLBACK(%d,%d) "), fd, action)); - m68k_dreg (regs, 0) = fd; - m68k_dreg (regs, 1) = action; - v = CallFunc (context, sb->fdcallback); + trap_call_add_dreg(ctx, 0, fd); + trap_call_add_dreg(ctx, 1, action); + v = trap_call_func(ctx, sb->fdcallback); BSDTRACE((_T("-> %d\n"), v)); return v; } @@ -182,14 +188,14 @@ bool checksd(TrapContext *context, SB, int sd) return false; } -void setsd(TrapContext *context, SB, int sd, SOCKET_TYPE s) +void setsd(TrapContext *ctx, SB, int sd, SOCKET_TYPE s) { - callfdcallback (context, sb, sd - 1, FDCB_ALLOC); + callfdcallback(ctx, sb, sd - 1, FDCB_ALLOC); sb->dtable[sd - 1] = s; } /* Socket descriptor/opaque socket handle management */ -int getsd (TrapContext *context, SB, SOCKET_TYPE s) +int getsd (TrapContext *ctx, SB, SOCKET_TYPE s) { int i, fdcb; SOCKET_TYPE *dt = sb->dtable; @@ -204,7 +210,7 @@ int getsd (TrapContext *context, SB, SOCKET_TYPE s) fdcb = 0; for (i = 0; i < sb->dtablesize; i++) { if (dt[i] == -1) { - if (callfdcallback (context, sb, i, FDCB_CHECK)) { + if (callfdcallback(ctx, sb, i, FDCB_CHECK)) { /* fd was allocated by link lib */ dt[i] = -2; continue; @@ -220,7 +226,7 @@ int getsd (TrapContext *context, SB, SOCKET_TYPE s) if (fdcb) { for (i = 0; i < sb->dtablesize; i++) { if (dt[i] == -2) { - if (!callfdcallback (context, sb, i, FDCB_CHECK)) { + if (!callfdcallback(ctx, sb, i, FDCB_CHECK)) { dt[i] = s; sb->ftable[i] = SF_BLOCKING; return i + 1; @@ -230,7 +236,7 @@ int getsd (TrapContext *context, SB, SOCKET_TYPE s) } /* descriptor table full. */ - bsdsocklib_seterrno (sb, 24); /* EMFILE */ + bsdsocklib_seterrno(ctx, sb, 24); /* EMFILE */ return -1; } @@ -239,7 +245,7 @@ SOCKET_TYPE getsock (SB, int sd) { if ((unsigned int) (sd - 1) >= (unsigned int) sb->dtablesize) { BSDTRACE ((_T("Invalid Socket Descriptor (%d)\n"), sd)); - bsdsocklib_seterrno (sb, 38); /* ENOTSOCK */ + bsdsocklib_seterrno(NULL, sb, 38); /* ENOTSOCK */ return -1; } if (sb->dtable[sd - 1] == INVALID_SOCKET) { @@ -269,11 +275,11 @@ SOCKET_TYPE getsock (SB, int sd) return sb->dtable[sd - 1]; } -void releasesock (TrapContext *context, SB, int sd) +void releasesock (TrapContext *ctx, SB, int sd) { if ((unsigned int) (sd - 1) < (unsigned int) sb->dtablesize) { sb->dtable[sd - 1] = -1; - callfdcallback (context, sb, sd - 1, FDCB_FREE); + callfdcallback(ctx, sb, sd - 1, FDCB_FREE); } } @@ -328,56 +334,56 @@ void bsdsock_fake_int_handler(void) unlocksigqueue (); } -void waitsig (TrapContext *context, SB) +void waitsig (TrapContext *ctx, SB) { long sigs; - m68k_dreg (regs, 0) = (((uae_u32) 1) << sb->signal) | sb->eintrsigs; - if ((sigs = CallLib (context, sb->sysbase, -0x13e)) & sb->eintrsigs) { /* Wait */ + trap_call_add_dreg(ctx, 0, (((uae_u32) 1) << sb->signal) | sb->eintrsigs); + if ((sigs = trap_call_lib(ctx, sb->sysbase, -0x13e)) & sb->eintrsigs) { /* Wait */ sockabort (sb); - bsdsocklib_seterrno (sb, 4); /* EINTR */ + bsdsocklib_seterrno(ctx, sb, 4); /* EINTR */ // Set signal - m68k_dreg (regs, 0) = sigs; - m68k_dreg (regs, 1) = sb->eintrsigs; - sigs = CallLib (context, sb->sysbase, -0x132); /* SetSignal() */ + trap_call_add_dreg(ctx, 0, sigs); + trap_call_add_dreg(ctx, 1, sb->eintrsigs); + sigs = trap_call_lib(ctx, sb->sysbase, -0x132); /* SetSignal() */ sb->eintr = 1; } else sb->eintr = 0; } -void cancelsig (TrapContext *context, SB) +void cancelsig (TrapContext *ctx, SB) { locksigqueue (); if (sb->dosignal) sb->dosignal = 2; unlocksigqueue (); - m68k_dreg (regs, 0) = 0; - m68k_dreg (regs, 1) = ((uae_u32) 1) << sb->signal; - CallLib (context, sb->sysbase, -0x132); /* SetSignal() */ + trap_call_add_dreg(ctx, 0, 0); + trap_call_add_dreg(ctx, 1, ((uae_u32) 1) << sb->signal); + trap_call_lib(ctx, sb->sysbase, -0x132); /* SetSignal() */ } /* Allocate and initialize per-task state structure */ -static struct socketbase *alloc_socketbase (TrapContext *context) +static struct socketbase *alloc_socketbase (TrapContext *ctx) { SB; int i; if ((sb = xcalloc (struct socketbase, 1)) != NULL) { - sb->ownertask = gettask (context); - sb->sysbase = get_long (4); + sb->ownertask = gettask(ctx); + sb->sysbase = trap_get_long(ctx, 4); - m68k_dreg (regs, 0) = -1; - sb->signal = CallLib (context, sb->sysbase, -0x14A); /* AllocSignal */ + trap_call_add_dreg(ctx, 0, -1); + sb->signal = trap_call_lib(ctx, sb->sysbase, -0x14A); /* AllocSignal */ if (sb->signal == -1) { write_log (_T("bsdsocket: ERROR: Couldn't allocate signal for task 0x%08x.\n"), sb->ownertask); free (sb); return NULL; } - m68k_dreg (regs, 0) = SCRATCHBUFSIZE; - m68k_dreg (regs, 1) = 0; +// trap_get_dreg(ctx, 0) = SCRATCHBUFSIZE; +// trap_get_dreg(ctx, 1) = 0; sb->dtablesize = DEFAULT_DTABLE_SIZE; /* @@@ check malloc() result */ @@ -392,7 +398,7 @@ static struct socketbase *alloc_socketbase (TrapContext *context) sb->logfacility = 1 << 3; /* LOG_USER */ sb->logmask = 0xff; - if (!host_sbinit (context, sb)) { + if (!host_sbinit(ctx, sb)) { /* @@@ free everything */ } @@ -409,35 +415,35 @@ static struct socketbase *alloc_socketbase (TrapContext *context) return NULL; } -STATIC_INLINE struct socketbase *get_socketbase (TrapContext *context) +STATIC_INLINE struct socketbase *get_socketbase (TrapContext *ctx) { - return (struct socketbase*)get_pointer (m68k_areg (regs, 6) + offsetof (struct UAEBSDBase, sb)); + return (struct socketbase*)get_pointer (trap_get_areg(ctx, 6) + offsetof (struct UAEBSDBase, sb)); } -static void free_socketbase (TrapContext *context) +static void free_socketbase (TrapContext *ctx) { struct socketbase *sb, *nsb; - if ((sb = get_socketbase (context)) != NULL) { - m68k_dreg (regs, 0) = sb->signal; - CallLib (context, sb->sysbase, -0x150); /* FreeSignal */ + if ((sb = get_socketbase (ctx)) != NULL) { + trap_call_add_dreg(ctx, 0, sb->signal); + trap_call_lib(ctx, sb->sysbase, -0x150); /* FreeSignal */ if (sb->hostent) { - m68k_areg (regs, 1) = sb->hostent; - m68k_dreg (regs, 0) = sb->hostentsize; - CallLib (context, sb->sysbase, -0xD2); /* FreeMem */ + trap_call_add_areg(ctx, 1, sb->hostent); + trap_call_add_dreg(ctx, 0, sb->hostentsize); + trap_call_lib(ctx, sb->sysbase, -0xD2); /* FreeMem */ } if (sb->protoent) { - m68k_areg (regs, 1) = sb->protoent; - m68k_dreg (regs, 0) = sb->protoentsize; - CallLib (context, sb->sysbase, -0xD2); /* FreeMem */ + trap_call_add_areg(ctx, 1, sb->protoent); + trap_call_add_dreg(ctx, 0, sb->protoentsize); + trap_call_lib(ctx, sb->sysbase, -0xD2); /* FreeMem */ } if (sb->servent) { - m68k_areg (regs, 1) = sb->servent; - m68k_dreg (regs, 0) = sb->serventsize; - CallLib (context, sb->sysbase, -0xD2); /* FreeMem */ + trap_call_add_areg(ctx, 1, sb->servent); + trap_call_add_dreg(ctx, 0, sb->serventsize); + trap_call_lib(ctx, sb->sysbase, -0xD2); /* FreeMem */ } host_sbcleanup (sb); @@ -477,7 +483,7 @@ static void free_socketbase (TrapContext *context) } } -static uae_u32 REGPARAM2 bsdsocklib_Expunge (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_Expunge (TrapContext *ctx) { BSDTRACE ((_T("Expunge() -> [ignored]\n"))); return 0; @@ -485,7 +491,7 @@ static uae_u32 REGPARAM2 bsdsocklib_Expunge (TrapContext *context) static uae_u32 functable, datatable, inittable; -static uae_u32 REGPARAM2 bsdsocklib_Open (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_Open (TrapContext *ctx) { uae_u32 result = 0; int opencount; @@ -493,17 +499,18 @@ static uae_u32 REGPARAM2 bsdsocklib_Open (TrapContext *context) BSDTRACE ((_T("OpenLibrary() -> "))); - if ((sb = alloc_socketbase (context)) != NULL) { - put_word (SockLibBase + 32, opencount = get_word (SockLibBase + 32) + 1); + if ((sb = alloc_socketbase(ctx)) != NULL) { + trap_put_word(ctx, SockLibBase + 32, opencount = trap_get_word(ctx, SockLibBase + 32) + 1); - m68k_areg (regs, 0) = functable; - m68k_areg (regs, 1) = datatable; - m68k_areg (regs, 2) = 0; - m68k_dreg (regs, 0) = sizeof (struct UAEBSDBase); - m68k_dreg (regs, 1) = 0; - result = CallLib (context, sb->sysbase, -0x54); /* MakeLibrary */ + + trap_call_add_areg(ctx, 0, functable); + trap_call_add_areg(ctx, 1, datatable); + trap_call_add_areg(ctx, 2, 0); + trap_call_add_dreg(ctx, 0, sizeof (struct UAEBSDBase)); + trap_call_add_dreg(ctx, 1, 0); + result = trap_call_lib(ctx, sb->sysbase, -0x54); /* MakeLibrary */ - put_pointer (result + offsetof (struct UAEBSDBase, sb), sb); + put_pointer(result + offsetof(struct UAEBSDBase, sb), sb); BSDTRACE ((_T("%0x [%d]\n"), result, opencount)); } else @@ -512,20 +519,20 @@ static uae_u32 REGPARAM2 bsdsocklib_Open (TrapContext *context) return result; } -static uae_u32 REGPARAM2 bsdsocklib_Close (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_Close (TrapContext *ctx) { int opencount; - uae_u32 base = m68k_areg (regs, 6); + uae_u32 base = trap_get_areg(ctx, 6); uae_u32 negsize = get_word (base + 16); - free_socketbase (context); + free_socketbase(ctx); - put_word (SockLibBase + 32, opencount = get_word (SockLibBase + 32) - 1); + trap_put_word(ctx, SockLibBase + 32, opencount = trap_get_word(ctx, SockLibBase + 32) - 1); - m68k_areg (regs, 1) = base - negsize; - m68k_dreg (regs, 0) = negsize + get_word (base + 18); - CallLib (context, get_long (4), -0xD2); /* FreeMem */ + trap_call_add_areg(ctx, 1, base - negsize); + trap_call_add_dreg(ctx, 0, negsize + trap_get_word(ctx, base + 18)); + trap_call_lib(ctx, trap_get_long(ctx, 4), -0xD2); /* FreeMem */ BSDTRACE ((_T("CloseLibrary() -> [%d]\n"), opencount)); @@ -533,151 +540,151 @@ static uae_u32 REGPARAM2 bsdsocklib_Close (TrapContext *context) } /* socket(domain, type, protocol)(d0/d1/d2) */ -static uae_u32 REGPARAM2 bsdsocklib_socket (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_socket (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); - return host_socket (context, sb, m68k_dreg (regs, 0), m68k_dreg (regs, 1), - m68k_dreg (regs, 2)); + struct socketbase *sb = get_socketbase (ctx); + return host_socket(ctx, sb, trap_get_dreg(ctx, 0), trap_get_dreg(ctx, 1), + trap_get_dreg(ctx, 2)); } /* bind(s, name, namelen)(d0/a0/d1) */ -static uae_u32 REGPARAM2 bsdsocklib_bind (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_bind (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); - return host_bind (context, sb, m68k_dreg (regs, 0), m68k_areg (regs, 0), - m68k_dreg (regs, 1)); + struct socketbase *sb = get_socketbase (ctx); + return host_bind(ctx, sb, trap_get_dreg(ctx, 0), trap_get_areg(ctx, 0), + trap_get_dreg(ctx, 1)); } /* listen(s, backlog)(d0/d1) */ -static uae_u32 REGPARAM2 bsdsocklib_listen (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_listen (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); - return host_listen (context, sb, m68k_dreg (regs, 0), m68k_dreg (regs, 1)); + struct socketbase *sb = get_socketbase (ctx); + return host_listen(ctx, sb, trap_get_dreg(ctx, 0), trap_get_dreg(ctx, 1)); } /* accept(s, addr, addrlen)(d0/a0/a1) */ -static uae_u32 REGPARAM2 bsdsocklib_accept (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_accept (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); - host_accept (context, sb, m68k_dreg (regs, 0), m68k_areg (regs, 0), m68k_areg (regs, 1)); + struct socketbase *sb = get_socketbase (ctx); + host_accept(ctx, sb, trap_get_dreg(ctx, 0), trap_get_areg(ctx, 0), trap_get_areg(ctx, 1)); return sb->resultval; } /* connect(s, name, namelen)(d0/a0/d1) */ -static uae_u32 REGPARAM2 bsdsocklib_connect (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_connect (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); - host_connect (context, sb, m68k_dreg (regs, 0), m68k_areg (regs, 0), m68k_dreg (regs, 1)); + struct socketbase *sb = get_socketbase (ctx); + host_connect(ctx, sb, trap_get_dreg(ctx, 0), trap_get_areg(ctx, 0), trap_get_dreg(ctx, 1)); return sb->sb_errno ? -1 : 0; } /* sendto(s, msg, len, flags, to, tolen)(d0/a0/d1/d2/a1/d3) */ -static uae_u32 REGPARAM2 bsdsocklib_sendto (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_sendto (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); - host_sendto (context, sb, m68k_dreg (regs, 0), m68k_areg (regs, 0), m68k_dreg (regs, 1), - m68k_dreg (regs, 2), m68k_areg (regs, 1), m68k_dreg (regs, 3)); + struct socketbase *sb = get_socketbase (ctx); + host_sendto(ctx, sb, trap_get_dreg(ctx, 0), trap_get_areg(ctx, 0), trap_get_dreg(ctx, 1), + trap_get_dreg(ctx, 2), trap_get_areg(ctx, 1), trap_get_dreg(ctx, 3)); return sb->resultval; } /* send(s, msg, len, flags)(d0/a0/d1/d2) */ -static uae_u32 REGPARAM2 bsdsocklib_send (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_send (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); - host_sendto (context, sb, m68k_dreg (regs, 0), m68k_areg (regs, 0), m68k_dreg (regs, 1), - m68k_dreg (regs, 2), 0, 0); + struct socketbase *sb = get_socketbase (ctx); + host_sendto(ctx, sb, trap_get_dreg(ctx, 0), trap_get_areg(ctx, 0), trap_get_dreg(ctx, 1), + trap_get_dreg(ctx, 2), 0, 0); return sb->resultval; } /* recvfrom(s, buf, len, flags, from, fromlen)(d0/a0/d1/d2/a1/a2) */ -static uae_u32 REGPARAM2 bsdsocklib_recvfrom (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_recvfrom (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); - host_recvfrom (context, sb, m68k_dreg (regs, 0), m68k_areg (regs, 0), m68k_dreg (regs, 1), - m68k_dreg (regs, 2), m68k_areg (regs, 1), m68k_areg (regs, 2)); + struct socketbase *sb = get_socketbase (ctx); + host_recvfrom(ctx, sb, trap_get_dreg(ctx, 0), trap_get_areg(ctx, 0), trap_get_dreg(ctx, 1), + trap_get_dreg(ctx, 2), trap_get_areg(ctx, 1), trap_get_areg(ctx, 2)); return sb->resultval; } /* recv(s, buf, len, flags)(d0/a0/d1/d2) */ -static uae_u32 REGPARAM2 bsdsocklib_recv (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_recv (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); - host_recvfrom (context, sb, m68k_dreg (regs, 0), m68k_areg (regs, 0), m68k_dreg (regs, 1), - m68k_dreg (regs, 2), 0, 0); + struct socketbase *sb = get_socketbase (ctx); + host_recvfrom(ctx, sb, trap_get_dreg(ctx, 0), trap_get_areg(ctx, 0), trap_get_dreg(ctx, 1), + trap_get_dreg(ctx, 2), 0, 0); return sb->resultval; } /* shutdown(s, how)(d0/d1) */ -static uae_u32 REGPARAM2 bsdsocklib_shutdown (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_shutdown (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); - return host_shutdown (sb, m68k_dreg (regs, 0), m68k_dreg (regs, 1)); + struct socketbase *sb = get_socketbase (ctx); + return host_shutdown (sb, trap_get_dreg(ctx, 0), trap_get_dreg(ctx, 1)); } /* setsockopt(s, level, optname, optval, optlen)(d0/d1/d2/a0/d3) */ -static uae_u32 REGPARAM2 bsdsocklib_setsockopt (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_setsockopt (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); - host_setsockopt (sb, m68k_dreg (regs, 0), m68k_dreg (regs, 1), m68k_dreg (regs, 2), - m68k_areg (regs, 0), m68k_dreg (regs, 3)); + struct socketbase *sb = get_socketbase (ctx); + host_setsockopt (sb, trap_get_dreg(ctx, 0), trap_get_dreg(ctx, 1), trap_get_dreg(ctx, 2), + trap_get_areg(ctx, 0), trap_get_dreg(ctx, 3)); return sb->resultval; } /* getsockopt(s, level, optname, optval, optlen)(d0/d1/d2/a0/a1) */ -static uae_u32 REGPARAM2 bsdsocklib_getsockopt (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_getsockopt (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); - return host_getsockopt (sb, m68k_dreg (regs, 0), m68k_dreg (regs, 1), m68k_dreg (regs, 2), - m68k_areg (regs, 0), m68k_areg (regs, 1)); + struct socketbase *sb = get_socketbase (ctx); + return host_getsockopt (sb, trap_get_dreg(ctx, 0), trap_get_dreg(ctx, 1), trap_get_dreg(ctx, 2), + trap_get_areg(ctx, 0), trap_get_areg(ctx, 1)); } /* getsockname(s, hostname, namelen)(d0/a0/a1) */ -static uae_u32 REGPARAM2 bsdsocklib_getsockname (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_getsockname (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); - return host_getsockname (sb, m68k_dreg (regs, 0), m68k_areg (regs, 0), m68k_areg (regs, 1)); + struct socketbase *sb = get_socketbase (ctx); + return host_getsockname (sb, trap_get_dreg(ctx, 0), trap_get_areg(ctx, 0), trap_get_areg(ctx, 1)); } /* getpeername(s, hostname, namelen)(d0/a0/a1) */ -static uae_u32 REGPARAM2 bsdsocklib_getpeername (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_getpeername (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); - return host_getpeername (sb, m68k_dreg (regs, 0), m68k_areg (regs, 0), m68k_areg (regs, 1)); + struct socketbase *sb = get_socketbase (ctx); + return host_getpeername (sb, trap_get_dreg(ctx, 0), trap_get_areg(ctx, 0), trap_get_areg(ctx, 1)); } /* *------ generic system calls related to sockets */ /* IoctlSocket(d, request, argp)(d0/d1/a0) */ -static uae_u32 REGPARAM2 bsdsocklib_IoctlSocket (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_IoctlSocket (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); - return host_IoctlSocket (context, sb, m68k_dreg (regs, 0), m68k_dreg (regs, 1), m68k_areg (regs, 0)); + struct socketbase *sb = get_socketbase (ctx); + return host_IoctlSocket(ctx, sb, trap_get_dreg(ctx, 0), trap_get_dreg(ctx, 1), trap_get_areg(ctx, 0)); } /* *------ AmiTCP/IP specific stuff */ /* CloseSocket(d)(d0) */ -static uae_u32 REGPARAM2 bsdsocklib_CloseSocket (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_CloseSocket (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); - return host_CloseSocket (context, sb, m68k_dreg (regs, 0)); + struct socketbase *sb = get_socketbase (ctx); + return host_CloseSocket(ctx, sb, trap_get_dreg(ctx, 0)); } /* WaitSelect(nfds, readfds, writefds, execptfds, timeout, maskp)(d0/a0/a1/a2/a3/d1) */ -static uae_u32 REGPARAM2 bsdsocklib_WaitSelect (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_WaitSelect (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); - host_WaitSelect (context, sb, m68k_dreg (regs, 0), m68k_areg (regs, 0), m68k_areg (regs, 1), - m68k_areg (regs, 2), m68k_areg (regs, 3), m68k_dreg (regs, 1)); + struct socketbase *sb = get_socketbase (ctx); + host_WaitSelect(ctx, sb, trap_get_dreg(ctx, 0), trap_get_areg(ctx, 0), trap_get_areg(ctx, 1), + trap_get_areg(ctx, 2), trap_get_areg(ctx, 3), trap_get_dreg(ctx, 1)); return sb->resultval; } /* SetSocketSignals(SIGINTR, SIGIO, SIGURG)(d0/d1/d2) */ -static uae_u32 REGPARAM2 bsdsocklib_SetSocketSignals (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_SetSocketSignals (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); + struct socketbase *sb = get_socketbase (ctx); - BSDTRACE ((_T("SetSocketSignals(0x%08x,0x%08x,0x%08x) -> "), m68k_dreg (regs, 0), m68k_dreg (regs, 1), m68k_dreg (regs, 2))); - sb->eintrsigs = m68k_dreg (regs, 0); - sb->eventsigs = m68k_dreg (regs, 1); + BSDTRACE ((_T("SetSocketSignals(0x%08x,0x%08x,0x%08x) -> "), trap_get_dreg(ctx, 0), trap_get_dreg(ctx, 1), trap_get_dreg(ctx, 2))); + sb->eintrsigs = trap_get_dreg(ctx, 0); + sb->eventsigs = trap_get_dreg(ctx, 1); return 0; } @@ -685,6 +692,7 @@ static uae_u32 REGPARAM2 bsdsocklib_SetSocketSignals (TrapContext *context) /* SetDTableSize(size)(d0) */ static uae_u32 bsdsocklib_SetDTableSize (SB, int newSize) { + TrapContext *ctx = NULL; int *newdtable; int *newftable; unsigned int *newmtable; @@ -701,7 +709,7 @@ static uae_u32 bsdsocklib_SetDTableSize (SB, int newSize) if (newdtable == NULL || newftable == NULL || newmtable == NULL) { sb->resultval = -1; - bsdsocklib_seterrno(sb, ENOMEM); + bsdsocklib_seterrno(ctx, sb, ENOMEM); free (newdtable); free (newftable); free (newmtable); @@ -737,17 +745,17 @@ static int sockpoolindex (long id) } /* ObtainSocket(id, domain, type, protocol)(d0/d1/d2/d3) */ -static uae_u32 REGPARAM2 bsdsocklib_ObtainSocket (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_ObtainSocket (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); + struct socketbase *sb = get_socketbase (ctx); int sd; int id; SOCKET_TYPE s; int i; - id = m68k_dreg (regs, 0); + id = trap_get_dreg(ctx, 0); - BSDTRACE ((_T("ObtainSocket(%d,%d,%d,%d) -> "), id, m68k_dreg (regs, 1), m68k_dreg (regs, 2), m68k_dreg (regs, 3))); + BSDTRACE ((_T("ObtainSocket(%d,%d,%d,%d) -> "), id, trap_get_dreg(ctx, 1), trap_get_dreg(ctx, 2), trap_get_dreg(ctx, 3))); i = sockpoolindex (id); @@ -757,13 +765,13 @@ static uae_u32 REGPARAM2 bsdsocklib_ObtainSocket (TrapContext *context) } s = sockdata->sockpoolsocks[i]; - sd = getsd (context, sb, s); + sd = getsd(ctx, sb, s); BSDTRACE ((_T(" -> Socket=%d\n"), sd)); if (sd != -1) { sb->ftable[sd - 1] = sockdata->sockpoolflags[i]; - callfdcallback (context, sb, sd - 1, FDCB_ALLOC); + callfdcallback(ctx, sb, sd - 1, FDCB_ALLOC); sockdata->sockpoolids[i] = UNIQUE_ID; return sd - 1; } @@ -772,17 +780,17 @@ static uae_u32 REGPARAM2 bsdsocklib_ObtainSocket (TrapContext *context) } /* ReleaseSocket(fd, id)(d0/d1) */ -static uae_u32 REGPARAM2 bsdsocklib_ReleaseSocket (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_ReleaseSocket (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); + struct socketbase *sb = get_socketbase (ctx); int sd; int id; SOCKET_TYPE s; int i; uae_u32 flags; - sd = m68k_dreg (regs, 0); - id = m68k_dreg (regs, 1); + sd = trap_get_dreg(ctx, 0); + id = trap_get_dreg(ctx, 1); sd++; BSDTRACE ((_T("ReleaseSocket(%d,%d) -> "), sd, id)); @@ -796,7 +804,7 @@ static uae_u32 REGPARAM2 bsdsocklib_ReleaseSocket (TrapContext *context) write_log (_T("bsdsocket: ERROR: ReleaseSocket() is not supported for sockets with async event notification enabled!\n")); return -1; } - releasesock (context, sb, sd); + releasesock(ctx, sb, sd); if (id == UNIQUE_ID) { for (;;) { @@ -835,17 +843,17 @@ static uae_u32 REGPARAM2 bsdsocklib_ReleaseSocket (TrapContext *context) } /* ReleaseCopyOfSocket(fd, id)(d0/d1) */ -static uae_u32 REGPARAM2 bsdsocklib_ReleaseCopyOfSocket (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_ReleaseCopyOfSocket (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); + struct socketbase *sb = get_socketbase (ctx); int sd; int id; SOCKET_TYPE s; int i; uae_u32 flags; - sd = m68k_dreg (regs, 0); - id = m68k_dreg (regs, 1); + sd = trap_get_dreg(ctx, 0); + id = trap_get_dreg(ctx, 1); sd++; BSDTRACE ((_T("ReleaseSocket(%d,%d) -> "), sd, id)); @@ -897,18 +905,18 @@ static uae_u32 REGPARAM2 bsdsocklib_ReleaseCopyOfSocket (TrapContext *context) } /* Errno()() */ -static uae_u32 REGPARAM2 bsdsocklib_Errno (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_Errno (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); + struct socketbase *sb = get_socketbase (ctx); BSDTRACE ((_T("Errno() -> %d\n"), sb->sb_errno)); return sb->sb_errno; } /* SetErrnoPtr(errno_p, size)(a0/d0) */ -static uae_u32 REGPARAM2 bsdsocklib_SetErrnoPtr (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_SetErrnoPtr (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); - uae_u32 errnoptr = m68k_areg (regs, 0), size = m68k_dreg (regs, 0); + struct socketbase *sb = get_socketbase (ctx); + uae_u32 errnoptr = trap_get_areg(ctx, 0), size = trap_get_dreg(ctx, 0); BSDTRACE ((_T("SetErrnoPtr(0x%08x,%d) -> "), errnoptr, size)); @@ -918,144 +926,144 @@ static uae_u32 REGPARAM2 bsdsocklib_SetErrnoPtr (TrapContext *context) BSDTRACE ((_T("OK\n"))); return 0; } - bsdsocklib_seterrno (sb, 22); /* EINVAL */ + bsdsocklib_seterrno(ctx, sb, 22); /* EINVAL */ return -1; } /* *------ inet library calls related to inet address manipulation */ /* Inet_NtoA(in)(d0) */ -static uae_u32 REGPARAM2 bsdsocklib_Inet_NtoA (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_Inet_NtoA (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); - return host_Inet_NtoA (context, sb, m68k_dreg (regs, 0)); + struct socketbase *sb = get_socketbase (ctx); + return host_Inet_NtoA(ctx, sb, trap_get_dreg(ctx, 0)); } /* inet_addr(cp)(a0) */ -static uae_u32 REGPARAM2 bsdsocklib_inet_addr (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_inet_addr (TrapContext *ctx) { - return host_inet_addr (m68k_areg (regs, 0)); + return host_inet_addr (trap_get_areg(ctx, 0)); } /* Inet_LnaOf(in)(d0) */ -static uae_u32 REGPARAM2 bsdsocklib_Inet_LnaOf (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_Inet_LnaOf (TrapContext *ctx) { write_log (_T("bsdsocket: UNSUPPORTED: Inet_LnaOf()\n")); return 0; } /* Inet_NetOf(in)(d0) */ -static uae_u32 REGPARAM2 bsdsocklib_Inet_NetOf (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_Inet_NetOf (TrapContext *ctx) { write_log (_T("bsdsocket: UNSUPPORTED: Inet_NetOf()\n")); return 0; } /* Inet_MakeAddr(net, host)(d0/d1) */ -static uae_u32 REGPARAM2 bsdsocklib_Inet_MakeAddr (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_Inet_MakeAddr (TrapContext *ctx) { write_log (_T("bsdsocket: UNSUPPORTED: Inet_MakeAddr()\n")); return 0; } /* inet_network(cp)(a0) */ -static uae_u32 REGPARAM2 bsdsocklib_inet_network (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_inet_network (TrapContext *ctx) { - return host_inet_addr (m68k_areg (regs, 0)); + return host_inet_addr (trap_get_areg(ctx, 0)); } /* *------ gethostbyname etc */ /* gethostbyname(name)(a0) */ -static uae_u32 REGPARAM2 bsdsocklib_gethostbyname (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_gethostbyname (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); - host_gethostbynameaddr (context, sb, m68k_areg (regs, 0), 0, -1); + struct socketbase *sb = get_socketbase (ctx); + host_gethostbynameaddr(ctx, sb, trap_get_areg(ctx, 0), 0, -1); return sb->sb_herrno ? 0 : sb->hostent; } /* gethostbyaddr(addr, len, type)(a0/d0/d1) */ -static uae_u32 REGPARAM2 bsdsocklib_gethostbyaddr (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_gethostbyaddr (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); - host_gethostbynameaddr (context, sb, m68k_areg (regs, 0), m68k_dreg (regs, 0), m68k_dreg (regs, 1)); + struct socketbase *sb = get_socketbase (ctx); + host_gethostbynameaddr(ctx, sb, trap_get_areg(ctx, 0), trap_get_dreg(ctx, 0), trap_get_dreg(ctx, 1)); return sb->sb_herrno ? 0 : sb->hostent; } /* getnetbyname(name)(a0) */ -static uae_u32 REGPARAM2 bsdsocklib_getnetbyname (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_getnetbyname (TrapContext *ctx) { write_log (_T("bsdsocket: UNSUPPORTED: getnetbyname()\n")); return 0; } /* getnetbyaddr(net, type)(d0/d1) */ -static uae_u32 REGPARAM2 bsdsocklib_getnetbyaddr (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_getnetbyaddr (TrapContext *ctx) { write_log (_T("bsdsocket: UNSUPPORTED: getnetbyaddr()\n")); return 0; } /* getservbyname(name, proto)(a0/a1) */ -static uae_u32 REGPARAM2 bsdsocklib_getservbyname (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_getservbyname (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); - host_getservbynameport (context, sb, m68k_areg (regs, 0), m68k_areg (regs, 1), 0); + struct socketbase *sb = get_socketbase (ctx); + host_getservbynameport(ctx, sb, trap_get_areg(ctx, 0), trap_get_areg(ctx, 1), 0); return sb->sb_errno ? 0 : sb->servent; } /* getservbyport(port, proto)(d0/a0) */ -static uae_u32 REGPARAM2 bsdsocklib_getservbyport (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_getservbyport (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); - host_getservbynameport (context, sb, m68k_dreg (regs, 0), m68k_areg (regs, 0), 1); + struct socketbase *sb = get_socketbase (ctx); + host_getservbynameport(ctx, sb, trap_get_dreg(ctx, 0), trap_get_areg(ctx, 0), 1); return sb->sb_errno ? 0 : sb->servent; } /* getprotobyname(name)(a0) */ -static uae_u32 REGPARAM2 bsdsocklib_getprotobyname (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_getprotobyname (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); - host_getprotobyname (context, sb, m68k_areg (regs, 0)); + struct socketbase *sb = get_socketbase (ctx); + host_getprotobyname(ctx, sb, trap_get_areg(ctx, 0)); return sb->sb_errno ? 0 : sb->protoent; } /* getprotobynumber(proto)(d0) */ -static uae_u32 REGPARAM2 bsdsocklib_getprotobynumber (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_getprotobynumber (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); - host_getprotobynumber (context, sb, m68k_dreg (regs, 0)); + struct socketbase *sb = get_socketbase (ctx); + host_getprotobynumber(ctx, sb, trap_get_dreg(ctx, 0)); return sb->sb_errno ? 0 : sb->protoent; } /* *------ AmiTCP/IP 1.1 extensions */ /* Dup2Socket(fd1, fd2)(d0/d1) */ -static uae_u32 REGPARAM2 bsdsocklib_Dup2Socket (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_Dup2Socket (TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); - return host_dup2socket (context, sb, m68k_dreg (regs, 0), m68k_dreg (regs, 1)); + struct socketbase *sb = get_socketbase (ctx); + return host_dup2socket(ctx, sb, trap_get_dreg(ctx, 0), trap_get_dreg(ctx, 1)); } -static uae_u32 REGPARAM2 bsdsocklib_sendmsg (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_sendmsg (TrapContext *ctx) { write_log (_T("bsdsocket: UNSUPPORTED: sendmsg()\n")); return 0; } -static uae_u32 REGPARAM2 bsdsocklib_recvmsg (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_recvmsg (TrapContext *ctx) { write_log (_T("bsdsocket: UNSUPPORTED: recvmsg()\n")); return 0; } -static uae_u32 REGPARAM2 bsdsocklib_gethostname (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_gethostname (TrapContext *ctx) { - return host_gethostname (m68k_areg (regs, 0), m68k_dreg (regs, 0)); + return host_gethostname (trap_get_areg(ctx, 0), trap_get_dreg(ctx, 0)); } -static uae_u32 REGPARAM2 bsdsocklib_gethostid (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_gethostid (TrapContext *ctx) { write_log (_T("bsdsocket: WARNING: Process '%s' calls deprecated function gethostid() - returning 127.0.0.1\n"), - get_real_address (get_long (gettask (context) + 10))); + get_real_address (get_long (gettask(ctx) + 10))); return 0x7f000001; } @@ -1091,10 +1099,10 @@ static const uae_u32 number_sys_error = sizeof (errortexts) / sizeof (*errortext /* *------ syslog functions */ /* Syslog(level, format, ap)(d0/a0/a1) */ -static uae_u32 REGPARAM2 bsdsocklib_vsyslog (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_vsyslog (TrapContext *ctx) { #if 0 - struct socketbase *sb = get_socketbase (context); + struct socketbase *sb = get_socketbase (ctx); uae_char format_dst[512]; char out[256]; TCHAR *s; @@ -1102,9 +1110,9 @@ static uae_u32 REGPARAM2 bsdsocklib_vsyslog (TrapContext *context) int paramcnt, len; uae_char *found = NULL; - uae_u32 level = m68k_dreg (regs, 0); - uaecptr format = m68k_areg (regs, 0); - uaecptr params = m68k_areg (regs, 1); + uae_u32 level = trap_get_dreg(ctx, 0); + uaecptr format = trap_get_areg(ctx, 0); + uaecptr params = trap_get_areg(ctx, 1); strcpyah_safe (format_dst, format, sizeof format_dst); @@ -1289,15 +1297,15 @@ static uae_u32 strErrptr; #define LOG_FACMASK 0x03f8 -static void tagcopy (uae_u32 currtag, uae_u32 currval, uae_u32 tagptr, uae_u32 * ptr) +static void tagcopy(TrapContext *ctx, uae_u32 currtag, uae_u32 currval, uae_u32 tagptr, uae_u32 * ptr) { switch (currtag & 0x8001) { case 0x0000: /* SBTM_GETVAL */ - put_long (tagptr + 4, ptr ? *ptr : 0); + trap_put_long(ctx, tagptr + 4, ptr ? *ptr : 0); break; case 0x8000: /* SBTM_GETREF */ - put_long (currval, ptr ? *ptr : 0); + trap_put_long(ctx, currval, ptr ? *ptr : 0); break; case 0x0001: /* SBTM_SETVAL */ if (ptr) @@ -1305,15 +1313,15 @@ static void tagcopy (uae_u32 currtag, uae_u32 currval, uae_u32 tagptr, uae_u32 * break; default: /* SBTM_SETREF */ if (ptr) - *ptr = get_long (currval); + *ptr = trap_get_long(ctx, currval); break; } } -static uae_u32 REGPARAM2 bsdsocklib_SocketBaseTagList (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_SocketBaseTagList(TrapContext *ctx) { - struct socketbase *sb = get_socketbase (context); - uae_u32 tagptr = m68k_areg (regs, 0); + struct socketbase *sb = get_socketbase(ctx); + uae_u32 tagptr = trap_get_areg(ctx, 0); uae_u32 tagsprocessed = 0; uae_u32 currtag; uae_u32 currval; @@ -1321,8 +1329,8 @@ static uae_u32 REGPARAM2 bsdsocklib_SocketBaseTagList (TrapContext *context) BSDTRACE ((_T("SocketBaseTagList("))); for (;;) { - currtag = get_long (tagptr); - currval = get_long (tagptr + 4); + currtag = trap_get_long(ctx, tagptr); + currval = trap_get_long(ctx, tagptr + 4); tagsprocessed++; if (!(currtag & TAG_USER)) { @@ -1346,7 +1354,7 @@ static uae_u32 REGPARAM2 bsdsocklib_SocketBaseTagList (TrapContext *context) break; default: write_log (_T("bsdsocket: WARNING: Unsupported tag type (%08x) in SocketBaseTagList(%x)\n"), - currtag, m68k_areg (regs, 0)); + currtag, trap_get_areg(ctx, 0)); goto done; } @@ -1360,26 +1368,26 @@ static uae_u32 REGPARAM2 bsdsocklib_SocketBaseTagList (TrapContext *context) { case SBTC_BREAKMASK: BSDTRACE ((_T("SBTC_BREAKMASK),0x%x,0x%x"), currval, sb->eintrsigs)); - tagcopy (currtag, currval, tagptr, &sb->eintrsigs); + tagcopy(ctx, currtag, currval, tagptr, &sb->eintrsigs); break; case SBTC_SIGIOMASK: BSDTRACE ((_T("SBTC_SIGIOMASK),0x%x,0x%x"), currval, sb->eventsigs)); - tagcopy (currtag, currval, tagptr, &sb->eventsigs); + tagcopy(ctx, currtag, currval, tagptr, &sb->eventsigs); break; case SBTC_SIGURGMASK: BSDTRACE ((_T("SBTC_SIGURGMASK),0x%x"), currval)); break; case SBTC_SIGEVENTMASK: BSDTRACE ((_T("SBTC_SIGEVENTMASK),0x%x,0x%x"), currval, sb->eventsigs)); - tagcopy (currtag, currval, tagptr, &sb->eventsigs); + tagcopy(ctx, currtag, currval, tagptr, &sb->eventsigs); break; case SBTC_ERRNO: BSDTRACE ((_T("SBTC_ERRNO),%x,%d"), currval, sb->sb_errno)); - tagcopy (currtag, currval, tagptr, (uae_u32*)&sb->sb_errno); + tagcopy(ctx, currtag, currval, tagptr, (uae_u32*)&sb->sb_errno); break; case SBTC_HERRNO: BSDTRACE ((_T("SBTC_HERRNO),%x,%d"), currval, sb->sb_herrno)); - tagcopy (currtag, currval, tagptr, (uae_u32*)&sb->sb_herrno); + tagcopy(ctx, currtag, currval, tagptr, (uae_u32*)&sb->sb_herrno); break; case SBTC_DTABLESIZE: BSDTRACE ((_T("SBTC_DTABLESIZE),0x%x"), currval)); @@ -1392,26 +1400,26 @@ static uae_u32 REGPARAM2 bsdsocklib_SocketBaseTagList (TrapContext *context) case SBTC_FDCALLBACK: BSDTRACE ((_T("SBTC_FDCALLBACK),%08x"), currval)); - tagcopy (currtag, currval, tagptr, &sb->fdcallback); + tagcopy(ctx, currtag, currval, tagptr, &sb->fdcallback); break; case SBTC_LOGSTAT: BSDTRACE ((_T("SBTC_LOGSTAT),%08x"), currval)); - tagcopy (currtag, currval, tagptr, &sb->logstat); + tagcopy(ctx, currtag, currval, tagptr, &sb->logstat); sb->logstat &= 0xff; break; case SBTC_LOGTAGPTR: BSDTRACE ((_T("SBTC_LOGTAGPTR),%08x"), currval)); - tagcopy (currtag, currval, tagptr, &sb->logptr); + tagcopy(ctx, currtag, currval, tagptr, &sb->logptr); break; case SBTC_LOGFACILITY: BSDTRACE ((_T("SBTC_LOGFACILITY),%08x"), currval)); if (((currtag & 1) && currval != 0 && (currval & ~LOG_FACMASK)) || !(currtag & 1)) - tagcopy (currtag, currval, tagptr, &sb->logfacility); + tagcopy(ctx, currtag, currval, tagptr, &sb->logfacility); break; case SBTC_LOGMASK: BSDTRACE ((_T("SBTC_LOGMASK),%08x"), currval)); - tagcopy (currtag, currval, tagptr, &sb->logmask); + tagcopy(ctx, currtag, currval, tagptr, &sb->logmask); sb->logmask &= 0xff; break; @@ -1422,15 +1430,15 @@ static uae_u32 REGPARAM2 bsdsocklib_SocketBaseTagList (TrapContext *context) } else { unsigned long ulTmp; if (currtag & 0x8000) { /* SBTM_GETREF */ - ulTmp = get_long (currval); + ulTmp = trap_get_long(ctx, currval); } else { /* SBTM_GETVAL */ ulTmp = currval; } BSDTRACE ((_T("IOERRNOSTRPTR),%lu"), ulTmp)); if (ulTmp < number_sys_error) { - tagcopy (currtag, currval, tagptr, &iotextptrs[ulTmp]); + tagcopy(ctx, currtag, currval, tagptr, &iotextptrs[ulTmp]); } else { - tagcopy (currtag, currval, tagptr, &strErrptr); + tagcopy(ctx, currtag, currval, tagptr, &strErrptr); } } break; @@ -1441,15 +1449,15 @@ static uae_u32 REGPARAM2 bsdsocklib_SocketBaseTagList (TrapContext *context) } else { unsigned long ulTmp; if (currtag & 0x8000) { /* SBTM_GETREF */ - ulTmp = get_long (currval); + ulTmp = trap_get_long(ctx, currval); } else { /* SBTM_GETVAL */ ulTmp = currval; } BSDTRACE ((_T("S2ERRNOSTRPTR),%lu"), ulTmp)); if (ulTmp < number_sys_error) { - tagcopy (currtag, currval, tagptr, &sana2iotextptrs[ulTmp]); + tagcopy(ctx, currtag, currval, tagptr, &sana2iotextptrs[ulTmp]); } else { - tagcopy (currtag, currval, tagptr, &strErrptr); + tagcopy(ctx, currtag, currval, tagptr, &strErrptr); } } break; @@ -1460,15 +1468,15 @@ static uae_u32 REGPARAM2 bsdsocklib_SocketBaseTagList (TrapContext *context) } else { unsigned long ulTmp; if (currtag & 0x8000) { /* SBTM_GETREF */ - ulTmp = get_long (currval); + ulTmp = trap_get_long(ctx, currval); } else { /* SBTM_GETVAL */ ulTmp = currval; } BSDTRACE ((_T("S2WERRNOSTRPTR),%lu"), ulTmp)); if (ulTmp < number_sys_error) { - tagcopy (currtag, currval, tagptr, &sana2wiretextptrs[ulTmp]); + tagcopy(ctx, currtag, currval, tagptr, &sana2wiretextptrs[ulTmp]); } else { - tagcopy (currtag, currval, tagptr, &strErrptr); + tagcopy(ctx, currtag, currval, tagptr, &strErrptr); } } break; @@ -1479,15 +1487,15 @@ static uae_u32 REGPARAM2 bsdsocklib_SocketBaseTagList (TrapContext *context) } else { unsigned long ulTmp; if (currtag & 0x8000) { /* SBTM_GETREF */ - ulTmp = get_long (currval); + ulTmp = trap_get_long(ctx, currval); } else { /* SBTM_GETVAL */ ulTmp = currval; } BSDTRACE ((_T("ERRNOSTRPTR),%lu"), ulTmp)); if (ulTmp < number_sys_error) { - tagcopy (currtag, currval, tagptr, &errnotextptrs[ulTmp]); + tagcopy(ctx, currtag, currval, tagptr, &errnotextptrs[ulTmp]); } else { - tagcopy (currtag, currval, tagptr, &strErrptr); + tagcopy(ctx, currtag, currval, tagptr, &strErrptr); } } break; @@ -1498,42 +1506,42 @@ static uae_u32 REGPARAM2 bsdsocklib_SocketBaseTagList (TrapContext *context) } else { unsigned long ulTmp; if (currtag & 0x8000) { /* SBTM_GETREF */ - ulTmp = get_long (currval); + ulTmp = trap_get_long(ctx, currval); } else { /* SBTM_GETVAL */ ulTmp = currval; } BSDTRACE ((_T("HERRNOSTRPTR),%lu"), ulTmp)); if (ulTmp < number_host_error) { - tagcopy (currtag, currval, tagptr, &herrnotextptrs[ulTmp]); + tagcopy(ctx, currtag, currval, tagptr, &herrnotextptrs[ulTmp]); } else { - tagcopy (currtag, currval, tagptr, &strErrptr); + tagcopy(ctx, currtag, currval, tagptr, &strErrptr); } } break; case SBTC_ERRNOBYTEPTR: BSDTRACE ((_T("SBTC_ERRNOBYTEPTR),0x%x"), currval)); - tagcopy (currtag, currval, tagptr, &sb->errnoptr); + tagcopy(ctx, currtag, currval, tagptr, &sb->errnoptr); sb->errnosize = 1; break; case SBTC_ERRNOWORDPTR: BSDTRACE ((_T("SBTC_ERRNOWORDPTR),0x%x"), currval)); - tagcopy (currtag, currval, tagptr, &sb->errnoptr); + tagcopy(ctx, currtag, currval, tagptr, &sb->errnoptr); sb->errnosize = 2; break; case SBTC_ERRNOLONGPTR: BSDTRACE ((_T("SBTC_ERRNOLONGPTR),0x%x"), currval)); - tagcopy (currtag, currval, tagptr, &sb->errnoptr); + tagcopy(ctx, currtag, currval, tagptr, &sb->errnoptr); sb->errnosize = 4; break; case SBTC_HERRNOLONGPTR: BSDTRACE ((_T("SBTC_HERRNOLONGPTR),0x%x"), currval)); - tagcopy (currtag, currval, tagptr, &sb->herrnoptr); + tagcopy(ctx, currtag, currval, tagptr, &sb->herrnoptr); sb->herrnosize = 4; break; default: write_log (_T("bsdsocket: WARNING: Unsupported tag type (%08x=%d) in SocketBaseTagList(%x)\n"), - currtag, (currtag / 2) & SBTS_CODE, m68k_areg (regs, 0)); + currtag, (currtag / 2) & SBTS_CODE, trap_get_areg(ctx, 0)); goto done; } } @@ -1548,13 +1556,13 @@ done: return tagsprocessed; } -static uae_u32 REGPARAM2 bsdsocklib_GetSocketEvents (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_GetSocketEvents(TrapContext *ctx) { #ifdef _WIN32 - struct socketbase *sb = get_socketbase (context); + struct socketbase *sb = get_socketbase(ctx); int i; int flags; - uae_u32 ptr = m68k_areg (regs, 0); + uae_u32 ptr = trap_get_areg(ctx, 0); BSDTRACE ((_T("GetSocketEvents(0x%x) -> "), ptr)); @@ -1566,7 +1574,7 @@ static uae_u32 REGPARAM2 bsdsocklib_GetSocketEvents (TrapContext *context) flags = sb->ftable[sb->eventindex] & SET_ALL; if (flags) { sb->ftable[sb->eventindex] &= ~SET_ALL; - put_long (m68k_areg (regs, 0), flags >> 8); + trap_put_long(ctx, trap_get_areg(ctx, 0), flags >> 8); BSDTRACE ((_T("%d (0x%x)\n"), sb->eventindex + 1, flags >> 8)); return sb->eventindex; // xxx } @@ -1577,17 +1585,17 @@ static uae_u32 REGPARAM2 bsdsocklib_GetSocketEvents (TrapContext *context) return -1; } -static uae_u32 REGPARAM2 bsdsocklib_getdtablesize (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_getdtablesize(TrapContext *ctx) { - return get_socketbase (context)->dtablesize; + return get_socketbase(ctx)->dtablesize; } -static uae_u32 REGPARAM2 bsdsocklib_null (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_null(TrapContext *ctx) { return 0; } -static uae_u32 REGPARAM2 bsdsocklib_init (TrapContext *context) +static uae_u32 REGPARAM2 bsdsocklib_init(TrapContext *ctx) { uae_u32 tmp1; int i; @@ -1596,19 +1604,35 @@ static uae_u32 REGPARAM2 bsdsocklib_init (TrapContext *context) if (SockLibBase) bsdlib_reset (); - m68k_areg (regs, 0) = functable; - m68k_areg (regs, 1) = datatable; - m68k_areg (regs, 2) = 0; - m68k_dreg (regs, 0) = LIBRARY_SIZEOF; - m68k_dreg (regs, 1) = 0; - tmp1 = CallLib (context, m68k_areg (regs, 6), -0x54); /* MakeLibrary */ +#if NEWTRAP + trap_call_add_areg(ctx, 0, functable); + trap_call_add_areg(ctx, 1, datatable); + trap_call_add_areg(ctx, 2, 0); + trap_call_add_dreg(ctx, 0, LIBRARY_SIZEOF); + trap_call_add_dreg(ctx, 1, 0); + tmp1 = trap_call_lib(ctx, trap_get_areg(ctx, 6), -0x54); /* MakeLibrary */ +#else + trap_get_areg(ctx, 0) = functable; + trap_get_areg(ctx, 1) = datatable; + trap_get_areg(ctx, 2) = 0; + trap_get_dreg(ctx, 0) = LIBRARY_SIZEOF; + trap_get_dreg(ctx, 1) = 0; + tmp1 = CallLib(ctx, trap_get_areg(ctx, 6), -0x54); /* MakeLibrary */ +#endif if (!tmp1) { write_log (_T("bsdoscket: FATAL: Cannot create bsdsocket.library!\n")); return 0; } - m68k_areg (regs, 1) = tmp1; - CallLib (context, m68k_areg (regs, 6), -0x18c); /* AddLibrary */ + +#if NEWTRAP + trap_call_add_areg(ctx, 1, tmp1); + trap_call_lib(ctx, trap_get_areg(ctx, 6), -0x18c); /* AddLibrary */ +#else + trap_get_areg(ctx, 1) = tmp1; + CallLib (ctx, trap_get_areg(ctx, 6), -0x18c); /* AddLibrary */ +#endif + SockLibBase = tmp1; /* Install error strings in Amiga memory */ @@ -1623,9 +1647,15 @@ static uae_u32 REGPARAM2 bsdsocklib_init (TrapContext *context) tmp1 += _tcslen (sana2wire_errlist[i]) + 1; tmp1 += _tcslen (strErr) + 1; - m68k_dreg (regs, 0) = tmp1; - m68k_dreg (regs, 1) = 0; - tmp1 = CallLib (context, m68k_areg (regs, 6), -0xC6); /* AllocMem */ +#if NEWTRAP + trap_call_add_dreg(ctx, 0, tmp1); + trap_call_add_dreg(ctx, 1, 0); + tmp1 = trap_call_lib(ctx, trap_get_areg(ctx, 6), -0xC6); /* AllocMem */ +#else + trap_get_dreg(ctx, 0) = tmp1; + trap_get_dreg(ctx, 1) = 0; + tmp1 = CallLib (ctx, trap_get_areg(ctx, 6), -0xC6); /* AllocMem */ +#endif if (!tmp1) { write_log (_T("bsdsocket: FATAL: Ran out of memory while creating bsdsocket.library!\n")); @@ -1651,7 +1681,7 @@ static uae_u32 REGPARAM2 bsdsocklib_init (TrapContext *context) put_long (context->regs.vbr + 0x78, tmp1); #endif - m68k_dreg (regs, 0) = 1; + trap_set_dreg(ctx, 0, 1); return 0; } @@ -1732,18 +1762,18 @@ static uae_u32 sockfuncvecs[sizeof (sockfuncs) / sizeof (*sockfuncs)]; static uae_u32 res_name, res_id, res_init; -uaecptr bsdlib_startup (uaecptr resaddr) +uaecptr bsdlib_startup (TrapContext *ctx, uaecptr resaddr) { if (res_name == 0 || !currprefs.socket_emu) return resaddr; - put_word (resaddr + 0x0, 0x4AFC); - put_long (resaddr + 0x2, resaddr); - put_long (resaddr + 0x6, resaddr + 0x1A); /* Continue scan here */ - put_word (resaddr + 0xA, 0x8004); /* RTF_AUTOINIT, RT_VERSION */ - put_word (resaddr + 0xC, 0x0970); /* NT_LIBRARY, RT_PRI */ - put_long (resaddr + 0xE, res_name); - put_long (resaddr + 0x12, res_id); - put_long (resaddr + 0x16, res_init); + trap_put_word(ctx, resaddr + 0x0, 0x4AFC); + trap_put_long(ctx, resaddr + 0x2, resaddr); + trap_put_long(ctx, resaddr + 0x6, resaddr + 0x1A); /* Continue scan here */ + trap_put_word(ctx, resaddr + 0xA, 0x8004); /* RTF_AUTOINIT, RT_VERSION */ + trap_put_word(ctx, resaddr + 0xC, 0x0970); /* NT_LIBRARY, RT_PRI */ + trap_put_long(ctx, resaddr + 0xE, res_name); + trap_put_long(ctx, resaddr + 0x12, res_id); + trap_put_long(ctx, resaddr + 0x16, res_init); resaddr += 0x1A; return resaddr; } diff --git a/devices.cpp b/devices.cpp index 2a82df16..2428544a 100644 --- a/devices.cpp +++ b/devices.cpp @@ -98,6 +98,7 @@ void devices_reset(int hardreset) #endif #ifdef AUTOCONFIG expamem_reset (); + rtarea_reset(); #endif uae_int_requested = 0; } @@ -112,6 +113,7 @@ void devices_vsync_pre(void) filesys_vsync (); sampler_vsync (); clipboard_vsync (); + uaenet_vsync(); #ifdef RETROPLATFORM rp_vsync (); #endif @@ -222,6 +224,8 @@ void devices_rethink(void) #endif rethink_gayle (); idecontroller_rethink(); + rethink_uae_int(); + rethink_traps(); /* cpuboard_rethink must be last */ cpuboard_rethink(); } @@ -360,6 +364,7 @@ void do_leave_program (void) machdep_free (); driveclick_free(); ethernet_enumerate_free(); + rtarea_free(); } void virtualdevice_init (void) diff --git a/ethernet.cpp b/ethernet.cpp index 43c09989..18b182b4 100644 --- a/ethernet.cpp +++ b/ethernet.cpp @@ -7,6 +7,7 @@ #endif #include "threaddep/thread.h" #include "options.h" +#include "traps.h" #include "sana2.h" #include "uae/slirp.h" diff --git a/expansion.cpp b/expansion.cpp index 2f34fec2..b2f82274 100644 --- a/expansion.cpp +++ b/expansion.cpp @@ -14,6 +14,7 @@ #include "options.h" #include "uae.h" +#include "traps.h" #include "memory.h" #include "rommgr.h" #include "custom.h" @@ -164,6 +165,10 @@ int uae_boot_rom_type; int uae_boot_rom_size; /* size = code size only */ static bool chipdone; +#define FILESYS_DIAGPOINT 0x01e0 +#define FILESYS_BOOTPOINT 0x01e6 +#define FILESYS_DIAGAREA 0x2000 + /* ********************************************************** */ struct card_data @@ -1004,8 +1009,8 @@ DECLARE_MEMORY_FUNCTIONS(filesys); addrbank filesys_bank = { filesys_lget, filesys_wget, filesys_bget, filesys_lput, filesys_wput, filesys_bput, - default_xlate, default_check, NULL, _T("filesys"), _T("Filesystem autoconfig"), - dummy_lgeti, dummy_wgeti, + filesys_xlate, filesys_check, NULL, _T("filesys"), _T("Filesystem autoconfig"), + filesys_lget, filesys_wget, ABFLAG_IO | ABFLAG_SAFE | ABFLAG_PPCIOSPACE, S_READ, S_WRITE }; @@ -1061,6 +1066,18 @@ static void REGPARAM2 filesys_bput (uaecptr addr, uae_u32 b) write_log (_T("filesys_bput %x %x\n"), addr, b); #endif } +static int REGPARAM2 filesys_check(uaecptr addr, uae_u32 size) +{ + addr -= filesys_bank.start & 65535; + addr &= 65535; + return (addr + size) <= filesys_bank.allocated; +} +static uae_u8 *REGPARAM2 filesys_xlate(uaecptr addr) +{ + addr -= filesys_bank.start & 65535; + addr &= 65535; + return filesys_bank.baseaddr + addr; +} #endif /* FILESYS */ @@ -1070,7 +1087,7 @@ DECLARE_MEMORY_FUNCTIONS(uaeboard); addrbank uaeboard_bank = { uaeboard_lget, uaeboard_wget, uaeboard_bget, uaeboard_lput, uaeboard_wput, uaeboard_bput, - default_xlate, default_check, NULL, _T("uaeboard"), _T("uae x autoconfig board"), + default_xlate, default_check, NULL, _T("uaeboard"), _T("UAE Board"), dummy_lgeti, dummy_wgeti, ABFLAG_IO | ABFLAG_SAFE | ABFLAG_PPCIOSPACE, S_READ, S_WRITE }; @@ -1162,8 +1179,8 @@ static void REGPARAM2 uaeboard_wput(uaecptr addr, uae_u32 w) if (addr >= 0x200 + 0x20 && addr < 0x200 + 0x24) { mousehack_write(addr - 0x200, w); } else if (addr >= UAEBOARD_IO_INTERFACE) { - uae_u16 *m = (uae_u16 *)(uaeboard_bank.baseaddr + addr); - do_put_mem_word(m, w); + uae_u8 *m = uaeboard_bank.baseaddr + addr; + put_word_host(m, w); if (uaeboard_io_state) { if (addr == UAEBOARD_IO_INTERFACE + 4) uaeboard_io_state |= 2; @@ -1180,10 +1197,13 @@ static void REGPARAM2 uaeboard_wput(uaecptr addr, uae_u32 w) if (addr == uaeboard_mem_use) { w &= 0xffff; if (w != 0xffff && w != 0) { - uae_u32 *m2 = (uae_u32 *)(uaeboard_bank.baseaddr + addr); - do_put_mem_long(m2 + 1, uaeboard_demux(m2)); + uae_u8 *m2 = uaeboard_bank.baseaddr + addr; + put_long_host(m2 + 4, uaeboard_demux((uae_u32*)m2)); } } + } else if (addr >= 0x2000 && addr <= 0x3000) { + uae_u8 *m = uaeboard_bank.baseaddr + addr; + put_word_host(m, w); } #if EXP_DEBUG write_log(_T("uaeboard_wput %08x = %04x PC=%08x\n"), addr, w, M68K_GETPC); @@ -1215,7 +1235,7 @@ static void REGPARAM2 uaeboard_bput(uaecptr addr, uae_u32 b) uaeboard_mem_use = 0; uaeboard_io_state = 0; } - if (addr >= UAEBOARD_RAM_OFFSET) { + if (addr >= UAEBOARD_RAM_OFFSET || (addr >= 0x2000 && addr <= 0x3000)) { uaeboard_bank.baseaddr[addr] = b; } #if EXP_DEBUG @@ -1227,14 +1247,18 @@ static addrbank *expamem_map_uaeboard(void) { uaeboard_start = expamem_z2_pointer; map_banks_z2(&uaeboard_bank, uaeboard_start >> 16, 1); + if (currprefs.uaeboard > 1) + map_banks_z2(&rtarea_bank, (uaeboard_start + 65536) >> 16, 1); return &uaeboard_bank; } static addrbank* expamem_init_uaeboard(int devnum) { - uae_u8 *p = uaeboard_bank.baseaddr; + bool ks12 = ks12orolder(); + bool hide = currprefs.uae_hide_autoconfig; + bool rom = currprefs.uaeboard > 1; expamem_init_clear(); - expamem_write(0x00, (currprefs.uaeboard > 1 ? Z2_MEM_128KB : Z2_MEM_64KB) | zorroII); + expamem_write(0x00, (currprefs.uaeboard > 1 ? Z2_MEM_128KB : Z2_MEM_64KB) | zorroII | (ks12 || !rom ? 0 : rom_card)); expamem_write(0x08, no_shutup); @@ -1245,11 +1269,54 @@ static addrbank* expamem_init_uaeboard(int devnum) expamem_write(0x18, 0x00); /* ser.no. Byte 0 */ expamem_write(0x1c, 0x00); /* ser.no. Byte 1 */ expamem_write(0x20, 0x00); /* ser.no. Byte 2 */ - expamem_write(0x24, 0x01); /* ser.no. Byte 3 */ + expamem_write(0x24, 0x02); /* ser.no. Byte 3 */ - /* er_InitDiagVec */ - expamem_write(0x28, 0x00); /* Rom-Offset hi */ - expamem_write(0x2c, 0x00); /* ROM-Offset lo */ + uae_u8 *p = uaeboard_bank.baseaddr; + + if (rom) { + + int diagoffset = 0x80; + int diagpoint = 24; + int bootpoint = diagpoint + 16; + /* struct DiagArea - the size has to be large enough to store several device ROMTags */ + const uae_u8 diagarea[] = { + 0x90, 0x00, /* da_Config, da_Flags */ + 0x03, 0x00, /* da_Size */ + (uae_u8)(diagpoint >> 8), (uae_u8)diagpoint, + (uae_u8)(bootpoint >> 8), (uae_u8)bootpoint, + 0, (uae_u8)(hide ? 0 : 14), // Name offset + 0, 0, 0, 0, + (uae_u8)(hide ? 0 : 'U'), (uae_u8)(hide ? 0 : 'A'), (uae_u8)(hide ? 0 : 'E'), 0 + }; + expamem_write(0x28, diagoffset >> 8); /* ROM-Offset hi */ + expamem_write(0x2c, diagoffset & 0xff); /* ROM-Offset lo */ + /* Build a DiagArea */ + memcpy(expamem + diagoffset, diagarea, sizeof diagarea); + diagpoint += diagoffset; + bootpoint += diagoffset; + + if (currprefs.uaeboard > 2) { + /* Call hwtrap_install */ + put_word_host(expamem + diagpoint + 0, 0x4EB9); /* JSR */ + put_long_host(expamem + diagpoint + 2, filesys_get_entry(9)); + diagpoint += 6; + } + /* Call DiagEntry */ + put_word_host(expamem + diagpoint + 0, 0x4EF9); /* JMP */ + put_long_host(expamem + diagpoint + 2, ROM_filesys_diagentry); + + /* What comes next is a plain bootblock */ + put_word_host(expamem + bootpoint + 0, 0x4EF9); /* JMP */ + put_long_host(expamem + bootpoint + 2, EXPANSION_bootcode); + + put_long_host(rtarea_bank.baseaddr + RTAREA_FSBOARD, 0xea0000 + 0x2000); + + } else { + + expamem_write(0x28, 0x00); /* ROM-Offset hi */ + expamem_write(0x2c, 0x00); /* ROM-Offset lo */ + + } memcpy(p, expamem, 0x100); @@ -1509,10 +1576,6 @@ static addrbank *expamem_map_filesys (void) return &filesys_bank; } -#define FILESYS_DIAGPOINT 0x01e0 -#define FILESYS_BOOTPOINT 0x01e6 -#define FILESYS_DIAGAREA 0x2000 - #if KS12_BOOT_HACK static void add_ks12_boot_hack(void) { @@ -1553,13 +1616,14 @@ static addrbank* expamem_init_filesys (int devnum) bool hide = currprefs.uae_hide_autoconfig; /* struct DiagArea - the size has to be large enough to store several device ROMTags */ - uae_u8 diagarea[] = { 0x90, 0x00, /* da_Config, da_Flags */ + const uae_u8 diagarea[] = { + 0x90, 0x00, /* da_Config, da_Flags */ 0x02, 0x00, /* da_Size */ FILESYS_DIAGPOINT >> 8, FILESYS_DIAGPOINT & 0xff, FILESYS_BOOTPOINT >> 8, FILESYS_BOOTPOINT & 0xff, - 0, hide ? 0 : 14, // Name offset + 0, (uae_u8)(hide ? 0 : 14), // Name offset 0, 0, 0, 0, - hide ? 0 : 'U', hide ? 0 : 'A', hide ? 0 : 'E', 0 + (uae_u8)(hide ? 0 : 'U'), (uae_u8)(hide ? 0 : 'A'), (uae_u8)(hide ? 0 : 'E'), 0 }; expamem_init_clear (); @@ -1586,12 +1650,12 @@ static addrbank* expamem_init_filesys (int devnum) memcpy (expamem + FILESYS_DIAGAREA, diagarea, sizeof diagarea); /* Call DiagEntry */ - do_put_mem_word ((uae_u16 *)(expamem + FILESYS_DIAGAREA + FILESYS_DIAGPOINT), 0x4EF9); /* JMP */ - do_put_mem_long ((uae_u32 *)(expamem + FILESYS_DIAGAREA + FILESYS_DIAGPOINT + 2), ROM_filesys_diagentry); + put_word_host(expamem + FILESYS_DIAGAREA + FILESYS_DIAGPOINT, 0x4EF9); /* JMP */ + put_long_host(expamem + FILESYS_DIAGAREA + FILESYS_DIAGPOINT + 2, ROM_filesys_diagentry); /* What comes next is a plain bootblock */ - do_put_mem_word ((uae_u16 *)(expamem + FILESYS_DIAGAREA + FILESYS_BOOTPOINT), 0x4EF9); /* JMP */ - do_put_mem_long ((uae_u32 *)(expamem + FILESYS_DIAGAREA + FILESYS_BOOTPOINT + 2), EXPANSION_bootcode); + put_word_host(expamem + FILESYS_DIAGAREA + FILESYS_BOOTPOINT, 0x4EF9); /* JMP */ + put_long_host(expamem + FILESYS_DIAGAREA + FILESYS_BOOTPOINT + 2, EXPANSION_bootcode); if (ks12) add_ks12_boot_hack(); @@ -1946,6 +2010,10 @@ static uaecptr check_boot_rom (int *boot_rom_type) uaecptr b = RTAREA_DEFAULT; addrbank *ab; + if (currprefs.uaeboard > 1) { + *boot_rom_type = 2; + return 0x00eb0000; // FIXME! + } *boot_rom_type = 0; if (currprefs.boot_rom == 1) return 0; @@ -2106,7 +2174,7 @@ void expamem_reset (void) do_mount = 0; /* check if Kickstart version is below 1.3 */ - if (ks12orolder() && do_mount) { + if (ks12orolder() && do_mount && currprefs.uaeboard < 2) { /* warn user */ #if KS12_BOOT_HACK do_mount = -1; @@ -2201,7 +2269,7 @@ void expamem_reset (void) } #endif #ifdef FILESYS - if (do_mount) { + if (do_mount && currprefs.uaeboard < 2) { cards[cardno].flags = 0; cards[cardno].name = _T("UAEFS"); cards[cardno].initnum = expamem_init_filesys; @@ -2373,10 +2441,12 @@ void expansion_init (void) allocate_expamem (); #ifdef FILESYS - filesys_bank.allocated = 0x10000; - if (!mapped_malloc (&filesys_bank)) { - write_log (_T("virtual memory exhausted (filesysory)!\n")); - exit (0); + if (currprefs.uaeboard < 2) { + filesys_bank.allocated = 0x10000; + if (!mapped_malloc (&filesys_bank)) { + write_log (_T("virtual memory exhausted (filesysory)!\n")); + exit (0); + } } #endif if (currprefs.uaeboard) { diff --git a/filesys.cpp b/filesys.cpp index 6dabce31..dc38769f 100644 --- a/filesys.cpp +++ b/filesys.cpp @@ -27,6 +27,7 @@ #include "threaddep/thread.h" #include "options.h" +#include "traps.h" #include "uae.h" #include "memory.h" #include "custom.h" @@ -34,7 +35,6 @@ #include "newcpu.h" #include "filesys.h" #include "autoconf.h" -#include "traps.h" #include "fsusage.h" #include "native2amiga.h" #include "scsidev.h" @@ -72,6 +72,10 @@ #define TRACING_ENABLED 1 int log_filesys = 0; +int filesystem_state; + +#define TRAPMD 1 + #if TRACING_ENABLED #if 0 #define TRACE(x) if (log_filesys > 0 && (unit->volflags & MYVOLUMEINFO_CDFS)) { write_log x; } @@ -81,10 +85,10 @@ int log_filesys = 0; #define TRACEI(x) if (log_filesys > 0) { write_log x; } #define TRACE2(x) if (log_filesys >= 2) { write_log x; } #define TRACE3(x) if (log_filesys >= 3) { write_log x; } -#define DUMPLOCK(u,x) dumplock(u,x) +#define DUMPLOCK(c,u,x) dumplock(c,u,x) #else #define TRACE(x) -#define DUMPLOCK(u,x) +#define DUMPLOCK(c,u,x) #define TRACE2(x) #define TRACE3(x) #endif @@ -93,8 +97,6 @@ int log_filesys = 0; #define UNIT_LED(unit) ((unit)->ui.unit_type == UNIT_CDFS ? LED_CD : LED_HD) -#define RTAREA_HEARTBEAT 0xFFFC - static uae_sem_t test_sem; static int bootrom_header; @@ -135,6 +137,7 @@ static void aino_test_init (a_inode *aino) uaecptr filesys_initcode, filesys_initcode_ptr; +static uaecptr bootrom_start; static uae_u32 fsdevname, fshandlername, filesys_configdev; static uae_u32 cdfs_devname, cdfs_handlername; static int filesys_in_interrupt; @@ -1129,6 +1132,8 @@ struct hardfiledata *get_hardfile_data (int nr) #define dp64_Arg4 52 #define dp64_Arg5 56 +#define dp_Max 60 + /* result codes */ #define DOS_TRUE ((uae_u32)-1L) #define DOS_FALSE (0L) @@ -1232,6 +1237,11 @@ struct hardfiledata *get_hardfile_data (int nr) #define DISK_TYPE_DOS_FFS 0x444f5301 /* DOS\1 */ #define CDFS_DOSTYPE 0x43440000 /* CDxx */ +typedef struct _dpacket { + uaecptr packet_addr; + uae_u8 packet_data[dp_Max]; +} dpacket; + typedef struct { uae_u32 uniq; /* The directory we're going through. */ @@ -1243,7 +1253,7 @@ typedef struct { struct lockrecord { struct lockrecord *next; - uae_u32 packet; + dpacket *packet; uae_u64 pos; uae_u64 len; uae_u32 mode; @@ -1357,93 +1367,114 @@ typedef struct _unit { static uae_u32 a_uniq, key_uniq; -static void set_quadp(uaecptr p, uae_s64 v) + +static void readdpacket(TrapContext *ctx, dpacket *packet, uaecptr pck) { - if (!valid_address(p, 8)) + packet->packet_addr = pck; + trap_get_bytes(ctx, packet->packet_data, pck, 48); +} +static void writedpacket(TrapContext *ctx, dpacket *packet) +{ + trap_put_bytes(ctx, packet->packet_data, packet->packet_addr, 48); +} + +static void set_quadp(TrapContext *ctx, uaecptr p, uae_s64 v) +{ + if (!trap_valid_address(ctx, p, 8)) return; put_long(p, v >> 32); put_long(p + 4, (uae_u64)v); } -static uae_u64 get_quadp(uaecptr p) +static uae_u64 get_quadp(TrapContext *ctx, uaecptr p) { - if (!valid_address(p, 8)) + if (!trap_valid_address(ctx, p, 8)) return 0; - return ((uae_u64)get_long(p) << 32) | get_long(p + 4); -} - -typedef uaecptr dpacket; -#define PUT_PCK_RES1(p,v) do { put_long ((p) + dp_Res1, (v)); } while (0) -#define PUT_PCK_RES2(p,v) do { put_long ((p) + dp_Res2, (v)); } while (0) -#define GET_PCK_TYPE(p) ((uae_s32)(get_long ((p) + dp_Type))) -#define GET_PCK_RES1(p) ((uae_s32)(get_long ((p) + dp_Res1))) -#define GET_PCK_RES2(p) ((uae_s32)(get_long ((p) + dp_Res2))) -#define GET_PCK_ARG1(p) ((uae_s32)(get_long ((p) + dp_Arg1))) -#define GET_PCK_ARG2(p) ((uae_s32)(get_long ((p) + dp_Arg2))) -#define GET_PCK_ARG3(p) ((uae_s32)(get_long ((p) + dp_Arg3))) -#define GET_PCK_ARG4(p) ((uae_s32)(get_long ((p) + dp_Arg4))) -#define GET_PCK_ARG5(p) ((uae_s32)(get_long ((p) + dp_Arg5))) - -#define PUT_PCK64_RES0(p,v) do { put_long ((p) + dp64_Res0, (v)); } while (0) -#define PUT_PCK64_RES1(p,v) do { put_long ((p) + dp64_Res1, (((uae_u64)v) >> 32)); put_long ((p) + dp64_Res1 + 4, ((uae_u32)v)); } while (0) -#define PUT_PCK64_RES2(p,v) do { put_long ((p) + dp64_Res2, (v)); } while (0) - -#define GET_PCK64_TYPE(p) ((uae_s32)(get_long ((p) + dp64_Type))) -#define GET_PCK64_RES0(p) ((uae_s32)(get_long ((p) + dp64_Res0))) -#define GET_PCK64_RES1(p) ( (((uae_s64)(get_long ((p) + dp64_Res1))) << 32) | (((uae_s64)(get_long ((p) + dp64_Res1 + 4))) << 0) ) -#define GET_PCK64_ARG1(p) ((uae_s32)(get_long ((p) + dp64_Arg1))) -#define GET_PCK64_ARG2(p) ( (((uae_s64)(get_long ((p) + dp64_Arg2))) << 32) | (((uae_s64)(get_long ((p) + dp64_Arg2 + 4))) << 0) ) -#define GET_PCK64_ARG3(p) ((uae_s32)(get_long ((p) + dp64_Arg3))) -#define GET_PCK64_ARG4(p) ((uae_s32)(get_long ((p) + dp64_Arg4))) -#define GET_PCK64_ARG5(p) ( (((uae_s64)(get_long ((p) + dp64_Arg5))) << 32) | (((uae_s64)(get_long ((p) + dp64_Arg5 + 4))) << 0) ) + return ((uae_u64)trap_get_long(ctx, p) << 32) | trap_get_long(ctx, p + 4); +} + +#define PUT_PCK_RES1(p,v) do { put_long_host((p)->packet_data + dp_Res1, (v)); } while (0) +#define PUT_PCK_RES2(p,v) do { put_long_host((p)->packet_data + dp_Res2, (v)); } while (0) +#define GET_PCK_TYPE(p) ((uae_s32)(get_long_host((p)->packet_data + dp_Type))) +#define GET_PCK_RES1(p) ((uae_s32)(get_long_host((p)->packet_data + dp_Res1))) +#define GET_PCK_RES2(p) ((uae_s32)(get_long_host((p)->packet_data + dp_Res2))) +#define GET_PCK_ARG1(p) ((uae_s32)(get_long_host((p)->packet_data + dp_Arg1))) +#define GET_PCK_ARG2(p) ((uae_s32)(get_long_host((p)->packet_data + dp_Arg2))) +#define GET_PCK_ARG3(p) ((uae_s32)(get_long_host((p)->packet_data + dp_Arg3))) +#define GET_PCK_ARG4(p) ((uae_s32)(get_long_host((p)->packet_data + dp_Arg4))) +#define GET_PCK_ARG5(p) ((uae_s32)(get_long_host((p)->packet_data + dp_Arg5))) + +#define PUT_PCK64_RES0(p,v) do { put_long_host((p)->packet_data + dp64_Res0, (v)); } while (0) +#define PUT_PCK64_RES1(p,v) do { put_long_host((p)->packet_data + dp64_Res1, (((uae_u64)v) >> 32)); put_long_host((p)->packet_data + dp64_Res1 + 4, ((uae_u32)v)); } while (0) +#define PUT_PCK64_RES2(p,v) do { put_long_host((p)->packet_data + dp64_Res2, (v)); } while (0) + +#define GET_PCK64_TYPE(p) ((uae_s32)(get_long_host((p)->packet_data + dp64_Type))) +#define GET_PCK64_RES0(p) ((uae_s32)(get_long_host((p)->packet_data + dp64_Res0))) +#define GET_PCK64_RES1(p) ( (((uae_s64)(get_long_host((p)->packet_data + dp64_Res1))) << 32) | (((uae_s64)(get_long_host((p)->packet_data + dp64_Res1 + 4))) << 0) ) +#define GET_PCK64_ARG1(p) ((uae_s32)(get_long_host((p)->packet_data + dp64_Arg1))) +#define GET_PCK64_ARG2(p) ( (((uae_s64)(get_long_host((p)->packet_data + dp64_Arg2))) << 32) | (((uae_s64)(get_long_host((p)->packet_data + dp64_Arg2 + 4))) << 0) ) +#define GET_PCK64_ARG3(p) ((uae_s32)(get_long_host((p)->packet_data + dp64_Arg3))) +#define GET_PCK64_ARG4(p) ((uae_s32)(get_long_host((p)->packet_data + dp64_Arg4))) +#define GET_PCK64_ARG5(p) ( (((uae_s64)(get_long_host((p)->packet_data + dp64_Arg5))) << 32) | (((uae_s64)(get_long_host((p)->packet_data + dp64_Arg5 + 4))) << 0) ) static int flush_cache (Unit *unit, int num); -static TCHAR *char1 (uaecptr addr) +static TCHAR *char1(TrapContext *ctx, uaecptr addr) { static uae_char buf[1024]; static TCHAR bufx[1024]; + +#if TRAPMD + trap_get_string(ctx, (uae_u8*)buf, addr, sizeof(buf)); +#else unsigned int i = 0; do { - buf[i] = get_byte (addr); + buf[i] = trap_get_byte(ctx, addr); addr++; } while (buf[i++] && i < sizeof (buf)); +#endif return au_fs_copy (bufx, sizeof (bufx) / sizeof (TCHAR), buf); } -static TCHAR *bstr1 (uaecptr addr) +static TCHAR *bstr1(TrapContext *ctx, uaecptr addr) { static TCHAR bufx[257]; static uae_char buf[257]; - int i; - int n = get_byte (addr); - addr++; + int n = trap_get_byte(ctx, addr); - for (i = 0; i < n; i++, addr++) - buf[i] = get_byte (addr); - buf[i] = 0; + addr++; +#if TRAPMD + trap_get_bytes(ctx, (uae_u8*)buf, addr, n); +#else + for (int i = 0; i < n; i++, addr++) + buf[i] = trap_get_byte(ctx, addr); +#endif + buf[n] = 0; return au_fs_copy (bufx, sizeof (bufx) / sizeof (TCHAR), buf); } -static TCHAR *bstr (Unit *unit, uaecptr addr) +static TCHAR *bstr(TrapContext *ctx, Unit *unit, uaecptr addr) { - int i; - int n = get_byte (addr); + int n = trap_get_byte(ctx, addr); uae_char buf[257]; addr++; - for (i = 0; i < n; i++, addr++) - buf[i] = get_byte (addr); - buf[i] = 0; +#if TRAPMD + trap_get_bytes(ctx, (uae_u8*)buf, addr, n); +#else + for (int i = 0; i < n; i++, addr++) + buf[i] = trap_get_byte(ctx, addr); +#endif + buf[n] = 0; au_fs_copy (unit->tmpbuf3, sizeof (unit->tmpbuf3) / sizeof (TCHAR), buf); return unit->tmpbuf3; } -static TCHAR *cstr (Unit *unit, uaecptr addr) +static TCHAR *cstr(TrapContext *ctx, Unit *unit, uaecptr addr) { int i; uae_char buf[257]; for (i = 0;;i++,addr++) { - buf[i] = get_byte (addr); + buf[i] = trap_get_byte(ctx, addr); if (!buf[i]) break; } @@ -1451,17 +1482,17 @@ static TCHAR *cstr (Unit *unit, uaecptr addr) return unit->tmpbuf3; } -static TCHAR *bstr_cut (Unit *unit, uaecptr addr) +static TCHAR *bstr_cut(TrapContext *ctx, Unit *unit, uaecptr addr) { TCHAR *p = unit->tmpbuf3; int i, colon_seen = 0, off; - int n = get_byte (addr); + int n = trap_get_byte(ctx, addr); uae_char buf[257]; off = 0; addr++; for (i = 0; i < n; i++, addr++) { - uae_u8 c = get_byte (addr); + uae_u8 c = trap_get_byte(ctx, addr); buf[i] = c; if (c == '/' || (c == ':' && colon_seen++ == 0)) off = i + 1; @@ -1517,8 +1548,7 @@ void amiga_to_timeval (struct mytimeval *tv, int days, int mins, int ticks, int static Unit *units = 0; -static Unit* - find_unit (uaecptr port) +static Unit *find_unit (uaecptr port) { Unit* u; for (u = units; u; u = u->next) @@ -1656,14 +1686,14 @@ static uae_s64 key_seek(Key *k, uae_s64 offset, int whence) return fs_lseek64 (k->fd, offset, whence); } -static void set_highcyl (UnitInfo *ui, uae_u32 blocks) +static void set_highcyl(TrapContext *ctx, UnitInfo *ui, uae_u32 blocks) { - uaecptr startup = get_long (ui->devicenode + 7 * 4) << 2; - uaecptr env = get_long (startup + 8) << 2; - put_long (env + 10 * 4, blocks); + uaecptr startup = trap_get_long(ctx, ui->devicenode + 7 * 4) << 2; + uaecptr env = trap_get_long(ctx, startup + 8) << 2; + trap_put_long(ctx, env + 10 * 4, blocks); } -static void set_volume_name (Unit *unit, struct mytimeval *tv) +static void set_volume_name(TrapContext *ctx, Unit *unit, struct mytimeval *tv) { int namelen; int i; @@ -1671,16 +1701,16 @@ static void set_volume_name (Unit *unit, struct mytimeval *tv) s = ua_fs (unit->ui.volname, -1); namelen = strlen (s); - put_byte (unit->volume + 44, namelen); + trap_put_byte(ctx, unit->volume + 44, namelen); for (i = 0; i < namelen; i++) - put_byte (unit->volume + 45 + i, s[i]); - put_byte (unit->volume + 45 + namelen, 0); + trap_put_byte(ctx, unit->volume + 45 + i, s[i]); + trap_put_byte(ctx, unit->volume + 45 + namelen, 0); if (tv && (tv->tv_sec || tv->tv_usec)) { int days, mins, ticks; timeval_to_amiga (tv, &days, &mins, &ticks, 50); - put_long (unit->volume + 16, days); - put_long (unit->volume + 20, mins); - put_long (unit->volume + 24, ticks); + trap_put_long(ctx, unit->volume + 16, days); + trap_put_long(ctx, unit->volume + 20, mins); + trap_put_long(ctx, unit->volume + 24, ticks); } xfree (s); unit->rootnode.aname = unit->ui.volname; @@ -1688,11 +1718,11 @@ static void set_volume_name (Unit *unit, struct mytimeval *tv) unit->rootnode.mountcount = unit->mountcount; } -static int filesys_isvolume (Unit *unit) +static int filesys_isvolume(TrapContext *ctx, Unit *unit) { if (!unit->volume) return 0; - return get_byte (unit->volume + 44) || unit->ui.unknown_media; + return trap_get_byte(ctx, unit->volume + 44) || unit->ui.unknown_media; } static void clear_exkeys (Unit *unit) @@ -1741,10 +1771,11 @@ static void filesys_delayed_change (Unit *u, int frames, const TCHAR *rootdir, c write_log (_T("FILESYS: delayed insert %d: '%s' ('%s')\n"), u->unit, volume ? volume : _T(""), rootdir); } -int filesys_eject (int nr) +int filesys_eject(int nr) { UnitInfo *ui = &mountinfo.ui[nr]; Unit *u = ui->self; + TrapContext *ctx = NULL; if (!mountertask || u->mount_changed) return 0; @@ -1752,14 +1783,14 @@ int filesys_eject (int nr) return 0; if (!is_virtual (nr)) return 0; - if (!filesys_isvolume (u)) + if (!filesys_isvolume(ctx, u)) return 0; u->mount_changed = -1; u->mountcount++; write_log (_T("FILESYS: volume '%s' removal request\n"), u->ui.volname); // -1 = remove, -2 = remove + remove device node - put_byte (u->volume + 172 - 32, ui->unit_type == UNIT_CDFS ? -1 : -2); - uae_Signal (get_long (u->volume + 176 - 32), 1 << 13); + trap_put_byte(ctx, u->volume + 172 - 32, ui->unit_type == UNIT_CDFS ? -1 : -2); + uae_Signal(trap_get_long(ctx, u->volume + 176 - 32), 1 << 13); return 1; } @@ -1770,9 +1801,11 @@ static int heartbeat_task; // This uses filesystem process to reduce resource usage void setsystime (void) { + TrapContext *ctx = NULL; + if (!currprefs.tod_hack || !rtarea_base) return; - heartbeat = get_long (rtarea_base + RTAREA_HEARTBEAT); + heartbeat = trap_get_long(ctx, rtarea_base + RTAREA_HEARTBEAT); heartbeat_task = 1; heartbeat_count = 10; } @@ -1780,18 +1813,20 @@ void setsystime (void) static void setsystime_vblank (void) { Unit *u; + TrapContext *ctx = NULL; + for (u = units; u; u = u->next) { - if (is_virtual (u->unit) && filesys_isvolume (u)) { - put_byte (u->volume + 173 - 32, get_byte(u->volume + 173 - 32) | 1); - uae_Signal (get_long (u->volume + 176 - 32), 1 << 13); + if (is_virtual(u->unit) && filesys_isvolume(ctx, u)) { + trap_put_byte(ctx, u->volume + 173 - 32, trap_get_byte(ctx, u->volume + 173 - 32) | 1); + uae_Signal(trap_get_long(ctx, u->volume + 176 - 32), 1 << 13); break; } } } -static uae_u32 REGPARAM2 debugger_helper(TrapContext *context) +static uae_u32 REGPARAM2 debugger_helper(TrapContext *ctx) { - int mode = m68k_dreg(regs, 1); + int mode = trap_get_dreg(ctx, 1); switch (mode) { case 1: @@ -1815,10 +1850,12 @@ static uae_u32 REGPARAM2 debugger_helper(TrapContext *context) static void debugger_boot(void) { Unit *u; + TrapContext *ctx = NULL; + for (u = units; u; u = u->next) { - if (is_virtual(u->unit) && filesys_isvolume(u)) { - put_byte(u->volume + 173 - 32, get_byte(u->volume + 173 - 32) | 2); - uae_Signal(get_long(u->volume + 176 - 32), 1 << 13); + if (is_virtual(u->unit) && filesys_isvolume(ctx, u)) { + trap_put_byte(ctx, u->volume + 173 - 32, trap_get_byte(ctx, u->volume + 173 - 32) | 2); + uae_Signal(trap_get_long(ctx, u->volume + 176 - 32), 1 << 13); break; } } @@ -1828,6 +1865,7 @@ int filesys_insert (int nr, const TCHAR *volume, const TCHAR *rootdir, bool read { UnitInfo *ui; Unit *u; + TrapContext *ctx = NULL; if (!mountertask) return 0; @@ -1837,7 +1875,7 @@ int filesys_insert (int nr, const TCHAR *volume, const TCHAR *rootdir, bool read if (nr < 0) { for (u = units; u; u = u->next) { if (is_virtual (u->unit)) { - if (!filesys_isvolume (u) && mountinfo.ui[u->unit].canremove) + if (!filesys_isvolume(ctx, u) && mountinfo.ui[u->unit].canremove) break; } } @@ -1862,9 +1900,9 @@ int filesys_insert (int nr, const TCHAR *volume, const TCHAR *rootdir, bool read return 0; if (u->reinsertdelay) return -1; - if (!is_virtual (nr)) + if (!is_virtual(nr)) return 0; - if (filesys_isvolume (u)) { + if (filesys_isvolume(ctx, u)) { filesys_delayed_change (u, 50, rootdir, volume, readonly, flags); return -1; } @@ -1877,8 +1915,8 @@ int filesys_insert (int nr, const TCHAR *volume, const TCHAR *rootdir, bool read write_log (_T("filesys_insert %d done!\n"), nr); - put_byte (u->volume + 172 - 32, -3); // wait for insert - uae_Signal (get_long (u->volume + 176 - 32), 1 << 13); + trap_put_byte(ctx, u->volume + 172 - 32, -3); // wait for insert + uae_Signal (trap_get_long(ctx, u->volume + 176 - 32), 1 << 13); return 100 + nr; } @@ -1941,7 +1979,7 @@ static uae_u32 filesys_media_change_reply (TrapContext *ctx, int mode) if (!u->ui.cdfs_superblock) return 0; struct isofs_info ii; - set_highcyl (ui, 0); + set_highcyl(ctx, ui, 0); bool r = isofs_mediainfo (ui->cdfs_superblock, &ii); if (r && ii.media) { u->ui.unknown_media = ii.unknown_media; @@ -1949,7 +1987,7 @@ static uae_u32 filesys_media_change_reply (TrapContext *ctx, int mode) u->ui.volname = ui->volname = my_strdup (ii.volumename); ctime.tv_sec = ii.creation; ctime.tv_usec = 0; - set_highcyl (ui, ii.blocks); + set_highcyl(ctx, ui, ii.blocks); #ifdef RETROPLATFORM rp_cd_image_change (ui->cddevno, ii.devname); #endif @@ -1971,7 +2009,7 @@ static uae_u32 filesys_media_change_reply (TrapContext *ctx, int mode) write_log (_T("FILESYS: inserted unreadable volume NR=%d RO=%d\n"), nr, u->mount_readonly); } else { write_log (_T("FILESYS: inserted volume NR=%d RO=%d '%s' ('%s')\n"), nr, u->mount_readonly, ui->volname, u->mount_rootdir); - set_volume_name (u, &ctime); + set_volume_name(ctx, u, &ctime); if (u->mount_flags >= 0) ui->volflags = u->volflags = u->ui.volflags = u->mount_flags; if (uci != NULL) { @@ -1983,8 +2021,8 @@ static uae_u32 filesys_media_change_reply (TrapContext *ctx, int mode) if (uci != NULL) uci->ci.readonly = u->mount_readonly; } - put_byte (u->volume + 44, 0); - put_byte (u->volume + 172 - 32, 1); + trap_put_byte(ctx, u->volume + 44, 0); + trap_put_byte(ctx, u->volume + 172 - 32, 1); } xfree (u->mount_volume); @@ -2008,6 +2046,7 @@ int filesys_media_change (const TCHAR *rootdir, int inserted, struct uaedev_conf int nr = -1; TCHAR volname[MAX_DPATH], *volptr; TCHAR devname[MAX_DPATH]; + TrapContext *ctx = NULL; if (!mountertask) return 0; @@ -2022,8 +2061,8 @@ int filesys_media_change (const TCHAR *rootdir, int inserted, struct uaedev_conf ui = &mountinfo.ui[u->unit]; // inserted == 2: drag&drop insert, do not replace existing normal drives if (inserted < 2 && ui->rootdir && !memcmp (ui->rootdir, rootdir, _tcslen (rootdir)) && _tcslen (rootdir) + 3 >= _tcslen (ui->rootdir)) { - if (filesys_isvolume (u) && inserted) { - if (uci) + if (filesys_isvolume(ctx, u) && inserted) { + if (uci)ctx, filesys_delayed_change (u, 50, rootdir, uci->ci.volname, uci->ci.readonly, 0); return 0; } @@ -2067,8 +2106,8 @@ int filesys_media_change (const TCHAR *rootdir, int inserted, struct uaedev_conf /* new volume inserted and it was previously mounted? */ if (nr >= 0) { - if (!filesys_isvolume (u)) /* not going to mount twice */ - return filesys_insert (nr, volptr, rootdir, false, -1); + if (!filesys_isvolume(ctx, u)) /* not going to mount twice */ + return filesys_insert(nr, volptr, rootdir, false, -1); return 0; } if (inserted < 0) /* -1 = only mount if already exists */ @@ -2191,16 +2230,17 @@ bool filesys_do_disk_change (int cdunitnum, bool insert) int nr = cdunitnum + cd_unit_offset; UnitInfo *ui = &mountinfo.ui[nr]; Unit *u = ui->self; + TrapContext *ctx = NULL; if (!ui->cd_open) return false; if (insert) { - if (filesys_isvolume (u)) + if (filesys_isvolume(ctx, u)) return false; filesys_insert (nr, NULL, _T("/"), true, MYVOLUMEINFO_CDFS | MYVOLUMEINFO_READONLY); return true; } else { - if (!filesys_isvolume (u)) + if (!filesys_isvolume(ctx, u)) return false; filesys_eject (nr); return true; @@ -2488,9 +2528,9 @@ static a_inode *lookup_aino (Unit *unit, uae_u32 uniq) aino_test (a); return a; } -static a_inode *aino_from_lock (Unit *unit, uaecptr lock) +static a_inode *aino_from_lock(TrapContext *ctx, Unit *unit, uaecptr lock) { - return lookup_aino (unit, get_long (lock + 4)); + return lookup_aino (unit, trap_get_long(ctx, lock + 4)); } TCHAR *build_nname (const TCHAR *d, const TCHAR *n) @@ -2628,7 +2668,7 @@ static int test_softlink (a_inode *aino) err = ERROR_OBJECT_NOT_AROUND; return err; } -static void handle_softlink (Unit *unit, dpacket packet, a_inode *aino) +static void handle_softlink(TrapContext *ctx, Unit *unit, dpacket *packet, a_inode *aino) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, test_softlink (aino)); @@ -2955,7 +2995,7 @@ static void startup_update_unit (Unit *unit, UnitInfo *uinfo) unit->ui.volname = my_strdup (uinfo->volname); /* might free later for rename */ } -static Unit *startup_create_unit (UnitInfo *uinfo, int num) +static Unit *startup_create_unit(TrapContext *ctx, UnitInfo *uinfo, int num) { int i; Unit *unit, *u; @@ -2973,7 +3013,7 @@ static Unit *startup_create_unit (UnitInfo *uinfo, int num) uinfo->self = unit; unit->volume = 0; - unit->port = m68k_areg (regs, 5); + unit->port = trap_get_areg(ctx, 5); unit->unit = num; startup_update_unit (unit, uinfo); @@ -3018,7 +3058,7 @@ static Unit *startup_create_unit (UnitInfo *uinfo, int num) } -static bool mount_cd (UnitInfo *uinfo, int nr, struct mytimeval *ctime, uae_u64 *uniq) +static bool mount_cd(TrapContext *ctx, UnitInfo *uinfo, int nr, struct mytimeval *ctime, uae_u64 *uniq) { uinfo->cddevno = nr - cd_unit_offset; if (!sys_command_open (uinfo->cddevno)) { @@ -3041,7 +3081,7 @@ static bool mount_cd (UnitInfo *uinfo, int nr, struct mytimeval *ctime, uae_u64 ctime->tv_sec = ii.creation; ctime->tv_usec = 0; } - set_highcyl (uinfo, ii.totalblocks); + set_highcyl(ctx, uinfo, ii.totalblocks); #ifdef RETROPLATFORM rp_cd_image_change (uinfo->cddevno, ii.devname); #endif @@ -3058,6 +3098,8 @@ static void *filesys_thread (void *unit_v); #endif static void filesys_start_thread (UnitInfo *ui, int nr) { + TrapContext *ctx = NULL; + ui->unit_pipe = 0; ui->back_pipe = 0; ui->reset_state = FS_STARTUP; @@ -3076,24 +3118,24 @@ static void filesys_start_thread (UnitInfo *ui, int nr) #endif if (isrestore ()) { if (ui->unit_type == UNIT_CDFS) { - mount_cd (ui, nr, NULL, &ui->self->rootnode.uniq_external); + mount_cd(ctx, ui, nr, NULL, &ui->self->rootnode.uniq_external); } startup_update_unit (ui->self, ui); } } -static uae_u32 REGPARAM2 startup_handler (TrapContext *context) +static uae_u32 REGPARAM2 startup_handler(TrapContext *ctx) { /* Just got the startup packet. It's in D3. DosBase is in A2, * our allocated volume structure is in A3, A5 is a pointer to * our port. */ - uaecptr rootnode = get_long (m68k_areg (regs, 2) + 34); - uaecptr dos_info = get_long (rootnode + 24) << 2; - uaecptr pkt = m68k_dreg (regs, 3); - uaecptr arg1 = get_long (pkt + dp_Arg1); - uaecptr arg2 = get_long (pkt + dp_Arg2); - uaecptr arg3 = get_long (pkt + dp_Arg3); + uaecptr rootnode = trap_get_long(ctx, trap_get_areg(ctx, 2) + 34); + uaecptr dos_info = trap_get_long(ctx, rootnode + 24) << 2; + uaecptr pkt = trap_get_dreg(ctx, 3); + uaecptr arg1 = trap_get_long(ctx, pkt + dp_Arg1); + uaecptr arg2 = trap_get_long(ctx, pkt + dp_Arg2); + uaecptr arg3 = trap_get_long(ctx, pkt + dp_Arg3); uaecptr devnode; int nr; Unit *unit; @@ -3121,8 +3163,8 @@ static uae_u32 REGPARAM2 startup_handler (TrapContext *context) if (nr == MAX_FILESYSTEM_UNITS) { write_log (_T("Attempt to mount unknown filesystem device\n")); - put_long (pkt + dp_Res1, DOS_FALSE); - put_long (pkt + dp_Res2, ERROR_DEVICE_NOT_MOUNTED); + trap_put_long(ctx, pkt + dp_Res1, DOS_FALSE); + trap_put_long(ctx, pkt + dp_Res2, ERROR_DEVICE_NOT_MOUNTED); return 0; } uinfo = mountinfo.ui + nr; @@ -3132,9 +3174,9 @@ static uae_u32 REGPARAM2 startup_handler (TrapContext *context) if (uinfo->unit_type == UNIT_CDFS) { ed = ef = 0; - if (!mount_cd (uinfo, nr, &ctime, &uniq)) { - put_long (pkt + dp_Res1, DOS_FALSE); - put_long (pkt + dp_Res2, ERROR_DEVICE_NOT_MOUNTED); + if (!mount_cd(ctx, uinfo, nr, &ctime, &uniq)) { + trap_put_long(ctx, pkt + dp_Res1, DOS_FALSE); + trap_put_long(ctx, pkt + dp_Res2, ERROR_DEVICE_NOT_MOUNTED); return 0; } } else { @@ -3142,17 +3184,17 @@ static uae_u32 REGPARAM2 startup_handler (TrapContext *context) ef = my_existsfile (uinfo->rootdir); if (!uinfo->wasisempty && !ef && !ed) { write_log (_T("Failed attempt to mount device '%s' (%s)\n"), uinfo->devname, uinfo->rootdir); - put_long (pkt + dp_Res1, DOS_FALSE); - put_long (pkt + dp_Res2, ERROR_DEVICE_NOT_MOUNTED); + trap_put_long(ctx, pkt + dp_Res1, DOS_FALSE); + trap_put_long(ctx, pkt + dp_Res2, ERROR_DEVICE_NOT_MOUNTED); return 0; } } if (!uinfo->unit_pipe) { late = 1; - filesys_start_thread (uinfo, nr); + filesys_start_thread(uinfo, nr); } - unit = startup_create_unit (uinfo, nr); + unit = startup_create_unit(ctx, uinfo, nr); unit->volflags = uinfo->volflags; unit->rootnode.uniq_external = uniq; @@ -3162,55 +3204,55 @@ static uae_u32 REGPARAM2 startup_handler (TrapContext *context) unit->ui.volname, unit->volflags, uinfo->wasisempty, ed, ef, unit->ui.rootdir); /* fill in our process in the device node */ - put_long (devnode + 8, unit->port); - unit->dosbase = m68k_areg (regs, 2); + trap_put_long(ctx, devnode + 8, unit->port); + unit->dosbase = trap_get_areg(ctx, 2); /* make new volume */ - unit->volume = m68k_areg (regs, 3) + 32; - put_long (unit->volume + 180 - 32, devnode); + unit->volume = trap_get_areg(ctx, 3) + 32; + trap_put_long(ctx, unit->volume + 180 - 32, devnode); #ifdef UAE_FILESYS_THREADS - unit->locklist = m68k_areg (regs, 3) + 8; + unit->locklist = trap_get_areg(ctx, 3) + 8; #else - unit->locklist = m68k_areg (regs, 3); + unit->locklist = trap_get_areg(ctx, 3); #endif - unit->dummy_message = m68k_areg (regs, 3) + 12; + unit->dummy_message = trap_get_areg(ctx, 3) + 12; - put_long (unit->dummy_message + 10, 0); + trap_put_long(ctx, unit->dummy_message + 10, 0); /* Prepare volume information */ - put_long (unit->volume + 4, 2); /* Type = dt_volume */ - put_long (unit->volume + 12, 0); /* Lock */ - put_long (unit->volume + 16, cdays); /* Creation Date */ - put_long (unit->volume + 20, 0); - put_long (unit->volume + 24, 0); - put_long (unit->volume + 28, 0); /* lock list */ - put_long (unit->volume + 40, (unit->volume + 44) >> 2); /* Name */ - - put_byte (unit->volume + 44, 0); + trap_put_long(ctx, unit->volume + 4, 2); /* Type = dt_volume */ + trap_put_long(ctx, unit->volume + 12, 0); /* Lock */ + trap_put_long(ctx, unit->volume + 16, cdays); /* Creation Date */ + trap_put_long(ctx, unit->volume + 20, 0); + trap_put_long(ctx, unit->volume + 24, 0); + trap_put_long(ctx, unit->volume + 28, 0); /* lock list */ + trap_put_long(ctx, unit->volume + 40, (unit->volume + 44) >> 2); /* Name */ + + trap_put_byte(ctx, unit->volume + 44, 0); if (!uinfo->wasisempty && !uinfo->unknown_media) { int isvirtual = unit->volflags & (MYVOLUMEINFO_ARCHIVE | MYVOLUMEINFO_CDFS); /* Set volume if non-empty */ - set_volume_name (unit, &ctime); + set_volume_name(ctx, unit, &ctime); if (!isvirtual) fsdb_clean_dir (&unit->rootnode); } - put_long (unit->volume + 8, unit->port); - put_long (unit->volume + 32, uinfo->unit_type == UNIT_CDFS ? DISK_TYPE_DOS : DISK_TYPE_DOS_FFS); + trap_put_long(ctx, unit->volume + 8, unit->port); + trap_put_long(ctx, unit->volume + 32, uinfo->unit_type == UNIT_CDFS ? DISK_TYPE_DOS : DISK_TYPE_DOS_FFS); - put_long (pkt + dp_Res1, DOS_TRUE); + trap_put_long(ctx, pkt + dp_Res1, DOS_TRUE); return 1 | (late ? 2 : 0); } -static void - do_info (Unit *unit, dpacket packet, uaecptr info, bool disk_info) +static void do_info(TrapContext *ctx, Unit *unit, dpacket *packet, uaecptr info, bool disk_info) { struct fs_usage fsu; int ret, err = ERROR_NO_FREE_STORE; int blocksize, nr; uae_u32 dostype; bool fs = false, media = false; + uae_u8 buf[36] = { 0 }; // InfoData blocksize = 512; /* not FFS because it is not understood by WB1.x C:Info */ @@ -3219,7 +3261,7 @@ static void if (unit->volflags & MYVOLUMEINFO_ARCHIVE) { ret = zfile_fs_usage_archive (unit->ui.rootdir, 0, &fsu); fs = true; - media = filesys_isvolume (unit) != 0; + media = filesys_isvolume(ctx, unit) != 0; } else if (unit->volflags & MYVOLUMEINFO_CDFS) { struct isofs_info ii; ret = isofs_mediainfo (unit->ui.cdfs_superblock, &ii) ? 0 : 1; @@ -3237,38 +3279,38 @@ static void if (ret) err = dos_errno (); fs = true; - media = filesys_isvolume (unit) != 0; + media = filesys_isvolume(ctx, unit) != 0; } if (ret != 0) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, err); return; } - put_long (info, 0); /* errors */ - put_long (info + 4, nr); /* unit number */ - put_long (info + 8, unit->ui.readonly || unit->ui.locked ? 80 : 82); /* state */ - put_long (info + 20, blocksize); /* bytesperblock */ - put_long (info + 32, 0); /* inuse */ + put_long_host(buf, 0); /* errors */ + put_long_host(buf + 4, nr); /* unit number */ + put_long_host(buf + 8, unit->ui.readonly || unit->ui.locked ? 80 : 82); /* state */ + put_long_host(buf + 20, blocksize); /* bytesperblock */ + put_long_host(buf + 32, 0); /* inuse */ if (unit->ui.unknown_media) { if (!disk_info) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, ERROR_NOT_A_DOS_DISK); return; } - put_long (info + 12, 0); - put_long (info + 16, 0); - put_long (info + 24, ('B' << 24) | ('A' << 16) | ('D' << 8) | (0 << 0)); /* ID_UNREADABLE_DISK */ - put_long (info + 28, 0); + put_long_host(buf + 12, 0); + put_long_host(buf + 16, 0); + put_long_host(buf + 24, ('B' << 24) | ('A' << 16) | ('D' << 8) | (0 << 0)); /* ID_UNREADABLE_DISK */ + put_long_host(buf + 28, 0); } else if (!media) { if (!disk_info) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, ERROR_NO_DISK); return; } - put_long (info + 12, 0); - put_long (info + 16, 0); - put_long (info + 24, -1); /* ID_NO_DISK_PRESENT */ - put_long (info + 28, 0); + put_long_host(buf + 12, 0); + put_long_host(buf + 16, 0); + put_long_host(buf + 24, -1); /* ID_NO_DISK_PRESENT */ + put_long_host(buf + 28, 0); } else { if (fs && currprefs.filesys_limit) { if (fsu.fsu_blocks > (uae_u64)currprefs.filesys_limit * 1024 / blocksize) { @@ -3277,27 +3319,26 @@ static void fsu.fsu_bavail = (uae_u32)((uae_u64)fsu.fsu_bavail * fsu.fsu_blocks / oldblocks); } } - put_long (info + 12, fsu.fsu_blocks); /* numblocks */ - put_long (info + 16, fsu.fsu_blocks - fsu.fsu_bavail); /* inuse */ - put_long (info + 24, dostype); /* disk type */ - put_long (info + 28, unit->volume >> 2); /* volume node */ - put_long (info + 32, (get_long (unit->volume + 28) || unit->keys) ? -1 : 0); /* inuse */ + put_long_host(buf + 12, fsu.fsu_blocks); /* numblocks */ + put_long_host(buf + 16, fsu.fsu_blocks - fsu.fsu_bavail); /* inuse */ + put_long_host(buf + 24, dostype); /* disk type */ + put_long_host(buf + 28, unit->volume >> 2); /* volume node */ + put_long_host(buf + 32, (trap_get_long(ctx, unit->volume + 28) || unit->keys) ? -1 : 0); /* inuse */ } + trap_put_bytes(ctx, buf, info, sizeof buf); PUT_PCK_RES1 (packet, DOS_TRUE); } -static void - action_disk_info (Unit *unit, dpacket packet) +static void action_disk_info(TrapContext *ctx, Unit *unit, dpacket *packet) { TRACE((_T("ACTION_DISK_INFO\n"))); - do_info (unit, packet, GET_PCK_ARG1 (packet) << 2, true); + do_info(ctx, unit, packet, GET_PCK_ARG1 (packet) << 2, true); } -static void - action_info (Unit *unit, dpacket packet) +static void action_info(TrapContext *ctx, Unit *unit, dpacket *packet) { TRACE((_T("ACTION_INFO\n"))); - do_info (unit, packet, GET_PCK_ARG2 (packet) << 2, false); + do_info(ctx, unit, packet, GET_PCK_ARG2 (packet) << 2, false); } static void free_key (Unit *unit, Key *k) @@ -3355,8 +3396,7 @@ static Key *new_key (Unit *unit) } #if TRACING_ENABLED -static void - dumplock (Unit *unit, uaecptr lock) +static void dumplock(TrapContext *ctx, Unit *unit, uaecptr lock) { a_inode *a; TRACE((_T("LOCK: 0x%x"), lock)); @@ -3365,25 +3405,27 @@ static void return; } TRACE((_T("{ next=0x%x, mode=%d, handler=0x%x, volume=0x%x, aino %x "), - get_long (lock) << 2, get_long (lock + 8), - get_long (lock + 12), get_long (lock + 16), - get_long (lock + 4))); - a = aino_from_lock (unit, lock); - if (a == 0) { - TRACE((_T("not found!"))); - } else { - TRACE((_T("%s"), a->nname)); + trap_get_long(ctx, lock) << 2, trap_get_long(ctx, lock + 8), + trap_get_long(ctx, lock + 12), trap_get_long(ctx, lock + 16), + trap_get_long(ctx, lock + 4))); + if (log_filesys > 0) { + a = aino_from_lock(ctx, unit, lock); + if (a == 0) { + TRACE((_T("not found!"))); + } else { + TRACE((_T("%s"), a->nname)); + } } TRACE((_T(" }\n"))); } #endif -static a_inode *find_aino (Unit *unit, uaecptr lock, const TCHAR *name, int *err) +static a_inode *find_aino(TrapContext* ctx, Unit *unit, uaecptr lock, const TCHAR *name, int *err) { a_inode *a; if (lock) { - a_inode *olda = aino_from_lock (unit, lock); + a_inode *olda = aino_from_lock(ctx, unit, lock); if (olda == 0) { /* That's the best we can hope to do. */ a = get_aino (unit, &unit->rootnode, name, err); @@ -3402,25 +3444,59 @@ static a_inode *find_aino (Unit *unit, uaecptr lock, const TCHAR *name, int *err return a; } -static uaecptr make_lock (Unit *unit, uae_u32 uniq, long mode) +static uaecptr make_lock(TrapContext *ctx, Unit *unit, uae_u32 uniq, long mode) { /* allocate lock from the list kept by the assembly code */ uaecptr lock; - lock = get_long (unit->locklist); - put_long (unit->locklist, get_long (lock)); +#if TRAPMD + + struct trapmd md1[] = + { + { TRAPCMD_GET_LONG, { unit->locklist }, 1, 0 }, + { TRAPCMD_GET_LONG, { 0 }, 2, 1 }, + { TRAPCMD_PUT_LONG, { unit->locklist, 0 } }, + }; + trap_multi(ctx, md1, sizeof md1 / sizeof(struct trapmd)); + lock = md1[0].params[0] + 4; + +#else + + lock = trap_get_long(ctx, unit->locklist); + trap_put_long(ctx, unit->locklist, trap_get_long(ctx, lock)); lock += 4; - put_long (lock + 4, uniq); - put_long (lock + 8, mode); - put_long (lock + 12, unit->port); - put_long (lock + 16, unit->volume >> 2); +#endif + +#if TRAPMD + struct trapmd md2[] = + { + { TRAPCMD_PUT_LONG, { lock + 4, uniq } }, + { TRAPCMD_PUT_LONG, { lock + 8, mode } }, + { TRAPCMD_PUT_LONG, { lock + 12, unit->port } }, + { TRAPCMD_PUT_LONG, { lock + 16, unit->volume >> 2 } }, + + /* prepend to lock chain */ + { TRAPCMD_GET_LONG, { unit->volume + 28 }, 5, 1 }, + { TRAPCMD_PUT_LONG, { lock, 0 } }, + { TRAPCMD_PUT_LONG, { unit->volume + 28, lock >> 2 } } + }; + trap_multi(ctx, md2, sizeof md2 / sizeof(struct trapmd)); + +#else + + trap_put_long(ctx, lock + 4, uniq); + trap_put_long(ctx, lock + 8, mode); + trap_put_long(ctx, lock + 12, unit->port); + trap_put_long(ctx, lock + 16, unit->volume >> 2); /* prepend to lock chain */ - put_long (lock, get_long (unit->volume + 28)); - put_long (unit->volume + 28, lock >> 2); + trap_put_long(ctx, lock, trap_get_long(ctx, unit->volume + 28)); + trap_put_long(ctx, unit->volume + 28, lock >> 2); + +#endif - DUMPLOCK(unit, lock); + DUMPLOCK(ctx, unit, lock); return lock; } @@ -3433,23 +3509,23 @@ static uaecptr make_lock (Unit *unit, uae_u32 uniq, long mode) #define NRF_NOTIFY_INITIAL 16 #define NRF_MAGIC (1 << 31) -static void notify_send (Unit *unit, Notify *n) +static void notify_send(TrapContext *ctx, Unit *unit, Notify *n) { uaecptr nr = n->notifyrequest; - int flags = get_long (nr + 12); + int flags = trap_get_long(ctx, nr + 12); if (flags & NRF_SEND_MESSAGE) { if (!(flags & NRF_WAIT_REPLY) || ((flags & NRF_WAIT_REPLY) && !(flags & NRF_MAGIC))) { uae_NotificationHack (unit->port, nr); } else if (flags & NRF_WAIT_REPLY) { - put_long (nr + 12, get_long (nr + 12) | NRF_MAGIC); + trap_put_long(ctx, nr + 12, trap_get_long(ctx, nr + 12) | NRF_MAGIC); } } else if (flags & NRF_SEND_SIGNAL) { - uae_Signal (get_long (nr + 16), 1 << get_byte (nr + 20)); + uae_Signal (trap_get_long(ctx, nr + 16), 1 << trap_get_byte(ctx, nr + 20)); } } -static void notify_check (Unit *unit, a_inode *a) +static void notify_check(TrapContext *ctx, Unit *unit, a_inode *a) { Notify *n; int hash = notifyhash (a->aname); @@ -3457,9 +3533,9 @@ static void notify_check (Unit *unit, a_inode *a) uaecptr nr = n->notifyrequest; if (same_aname (n->partname, a->aname)) { int err; - a_inode *a2 = find_aino (unit, 0, n->fullname, &err); + a_inode *a2 = find_aino(ctx, unit, 0, n->fullname, &err); if (err == 0 && a == a2) - notify_send (unit, n); + notify_send(ctx, unit, n); } } if (a->parent) { @@ -3468,16 +3544,15 @@ static void notify_check (Unit *unit, a_inode *a) uaecptr nr = n->notifyrequest; if (same_aname (n->partname, a->parent->aname)) { int err; - a_inode *a2 = find_aino (unit, 0, n->fullname, &err); + a_inode *a2 = find_aino(ctx, unit, 0, n->fullname, &err); if (err == 0 && a->parent == a2) - notify_send (unit, n); + notify_send(ctx, unit, n); } } } } -static void - action_add_notify (Unit *unit, dpacket packet) +static void action_add_notify(TrapContext *ctx, Unit *unit, dpacket *packet) { uaecptr nr = GET_PCK_ARG1 (packet); int flags; @@ -3486,8 +3561,8 @@ static void TRACE((_T("ACTION_ADD_NOTIFY\n"))); - name = my_strdup (char1 (get_long (nr + 4))); - flags = get_long (nr + 12); + name = my_strdup (char1(ctx, trap_get_long(ctx, nr + 4))); + flags = trap_get_long(ctx, nr + 12); if (!(flags & (NRF_SEND_MESSAGE | NRF_SEND_SIGNAL))) { PUT_PCK_RES1 (packet, DOS_FALSE); @@ -3497,14 +3572,14 @@ static void #if 0 write_log (_T("Notify:\n")); - write_log (_T("nr_Name '%s'\n"), char1 (get_long (nr + 0))); + write_log (_T("nr_Name '%s'\n"), char1 (trap_get_long(ctx, nr + 0))); write_log (_T("nr_FullName '%s'\n"), name); - write_log (_T("nr_UserData %08X\n"), get_long (nr + 8)); + write_log (_T("nr_UserData %08X\n"), trap_get_long(ctx, nr + 8)); write_log (_T("nr_Flags %08X\n"), flags); if (flags & NRF_SEND_MESSAGE) { - write_log (_T("Message NotifyRequest, port = %08X\n"), get_long (nr + 16)); + write_log (_T("Message NotifyRequest, port = %08X\n"), trap_get_long(ctx, nr + 16)); } else if (flags & NRF_SEND_SIGNAL) { - write_log (_T("Signal NotifyRequest, Task = %08X signal = %d\n"), get_long (nr + 16), get_long (nr + 20)); + write_log (_T("Signal NotifyRequest, Task = %08X signal = %d\n"), trap_get_long(ctx, nr + 16), trap_get_long(ctx, nr + 20)); } else { write_log (_T("corrupt NotifyRequest\n")); } @@ -3523,14 +3598,13 @@ static void n->fullname = name; if (flags & NRF_NOTIFY_INITIAL) { int err; - a_inode *a = find_aino (unit, 0, n->fullname, &err); + a_inode *a = find_aino(ctx, unit, 0, n->fullname, &err); if (err == 0) - notify_send (unit, n); + notify_send(ctx, unit, n); } PUT_PCK_RES1 (packet, DOS_TRUE); } -static void - action_remove_notify (Unit *unit, dpacket packet) +static void action_remove_notify(TrapContext *ctx, Unit *unit, dpacket *packet) { uaecptr nr = GET_PCK_ARG1 (packet); Notify *n; @@ -3553,18 +3627,19 @@ static void PUT_PCK_RES1 (packet, DOS_TRUE); } -static void free_lock (Unit *unit, uaecptr lock) +static void free_lock(TrapContext *ctx, Unit *unit, uaecptr lock) { if (! lock) return; - if (lock == get_long (unit->volume + 28) << 2) { - put_long (unit->volume + 28, get_long (lock)); + uaecptr curlock = trap_get_long(ctx, unit->volume + 28); + if (lock == curlock << 2) { + trap_put_long(ctx, unit->volume + 28, trap_get_long(ctx, lock)); } else { - uaecptr current = get_long (unit->volume + 28); + uaecptr current = curlock; uaecptr next = 0; while (current) { - next = get_long (current << 2); + next = trap_get_long(ctx, current << 2); if (lock == next << 2) break; current = next; @@ -3573,15 +3648,24 @@ static void free_lock (Unit *unit, uaecptr lock) write_log (_T("tried to unlock non-existing lock %x\n"), lock); return; } - put_long (current << 2, get_long (lock)); + trap_put_long(ctx, current << 2, trap_get_long(ctx, lock)); } lock -= 4; - put_long (lock, get_long (unit->locklist)); - put_long (unit->locklist, lock); +#if TRAPMD + struct trapmd md2[] = + { + { TRAPCMD_GET_LONG, { unit->locklist }, 1, 1 }, + { TRAPCMD_PUT_LONG, { lock } }, + { TRAPCMD_PUT_LONG, { unit->locklist, lock } } + }; + trap_multi(ctx, md2, sizeof md2 / sizeof(struct trapmd)); +#else + trap_put_long(ctx, lock, trap_get_long(ctx, unit->locklist)); + trap_put_long(ctx, unit->locklist, lock); +#endif } -static void - action_lock (Unit *unit, dpacket packet) +static void action_lock(TrapContext *ctx, Unit *unit, dpacket *packet) { uaecptr lock = GET_PCK_ARG1 (packet) << 2; uaecptr name = GET_PCK_ARG2 (packet) << 2; @@ -3594,10 +3678,10 @@ static void mode = SHARED_LOCK; } - TRACE((_T("ACTION_LOCK(0x%08x, \"%s\", %d)\n"), lock, bstr (unit, name), mode)); - DUMPLOCK(unit, lock); + TRACE((_T("ACTION_LOCK(0x%08x, \"%s\", %d)\n"), lock, bstr(ctx, unit, name), mode)); + DUMPLOCK(ctx, unit, lock); - a = find_aino (unit, lock, bstr (unit, name), &err); + a = find_aino(ctx, unit, lock, bstr(ctx, unit, name), &err); if (err == 0 && a->softlink) { err = test_softlink (a); } @@ -3615,9 +3699,9 @@ static void else a->elock = 1; de_recycle_aino (unit, a); - PUT_PCK_RES1 (packet, make_lock (unit, a->uniq, mode) >> 2); + PUT_PCK_RES1(packet, make_lock(ctx, unit, a->uniq, mode) >> 2); } -static void action_read_link_add_parent (Unit *u, a_inode *a, TCHAR *path) +static void action_read_link_add_parent(Unit *u, a_inode *a, TCHAR *path) { if (a == NULL) return; @@ -3635,7 +3719,7 @@ static void action_read_link_add_parent (Unit *u, a_inode *a, TCHAR *path) #define LINK_HARD 0 #define LINK_SOFT 1 -static void action_make_link (Unit *unit, dpacket packet) +static void action_make_link(TrapContext *ctx, Unit *unit, dpacket *packet) { uaecptr lock = GET_PCK_ARG1 (packet) << 2; uaecptr name = GET_PCK_ARG2 (packet) << 2; @@ -3645,14 +3729,14 @@ static void action_make_link (Unit *unit, dpacket packet) int err; TCHAR tmp[256], tmp2[MAX_DPATH], tmp3[MAX_DPATH]; - _tcscpy (tmp, bstr (unit, name)); - a1 = aino_from_lock (unit, lock); + _tcscpy (tmp, bstr(ctx, unit, name)); + a1 = aino_from_lock(ctx, unit, lock); if (type == LINK_HARD) { // we don't support hard links uaecptr tlock = target << 2; - a2 = aino_from_lock (unit, tlock); + a2 = aino_from_lock(ctx, unit, tlock); write_log (_T("ACTION_MAKE_LINK(HARD,'%s','%s','%s')\n"), a1 ? a1->aname : _T("?"), tmp, a2 ? a2->aname : _T("?")); @@ -3663,7 +3747,7 @@ static void action_make_link (Unit *unit, dpacket packet) } else { a_inode *a3; - TCHAR *link = cstr (unit, target); + TCHAR *link = cstr(ctx, unit, target); write_log (_T("ACTION_MAKE_LINK(SOFT,'%s','%s','%s')\n"), a1 ? a1->aname : _T("?"), tmp, link); if (!a1) { @@ -3675,7 +3759,7 @@ static void action_make_link (Unit *unit, dpacket packet) for (Unit *u = units; u; u = u->next) { if (u->volflags & (MYVOLUMEINFO_ARCHIVE | MYVOLUMEINFO_CDFS)) continue; - a3 = find_aino (u, 0, link, &err); + a3 = find_aino(ctx, u, 0, link, &err); if (err || !a3) continue; _tcscpy (tmp2, a1->nname); @@ -3695,7 +3779,7 @@ static void action_make_link (Unit *unit, dpacket packet) } } -static void action_read_link (Unit *unit, dpacket packet) +static void action_read_link(TrapContext *ctx, Unit *unit, dpacket *packet) { uaecptr lock = GET_PCK_ARG1 (packet) << 2; uaecptr name = GET_PCK_ARG2 (packet); @@ -3708,9 +3792,9 @@ static void action_read_link (Unit *unit, dpacket packet) TCHAR *namep, *extrapath; extrapath = NULL; - namep = cstr (unit, name); + namep = cstr(ctx, unit, name); for (;;) { - a = find_aino (unit, lock, namep, &err); + a = find_aino(ctx, unit, lock, namep, &err); if (err != ERROR_IS_SOFT_LINK) break; for (i = _tcslen (namep) - 1; i > 0; i--) { @@ -3749,7 +3833,7 @@ static void action_read_link (Unit *unit, dpacket packet) TCHAR path[MAX_DPATH]; i = my_issamevolume (u->rootnode.nname, tmp, path); if (i > matched_len) { - a = find_aino (u, 0, path, &err); + a = find_aino(ctx, u, 0, path, &err); if (a && !err) { write_log (_T("Match found from '%s' (%d)\n"), u->rootnode.aname, i); matched_aino = a; @@ -3778,20 +3862,20 @@ static void action_read_link (Unit *unit, dpacket packet) for (i = 0; s[i]; i++) { if (i >= size - 1) break; - put_byte (newname + i, s[i]); + trap_put_byte(ctx, newname + i, s[i]); } xfree (s); - put_byte (newname + i, 0); + trap_put_byte(ctx, newname + i, 0); } -static void action_free_lock (Unit *unit, dpacket packet) +static void action_free_lock(TrapContext *ctx, Unit *unit, dpacket *packet) { uaecptr lock = GET_PCK_ARG1 (packet) << 2; a_inode *a; TRACE((_T("ACTION_FREE_LOCK(0x%x)\n"), lock)); - DUMPLOCK(unit, lock); + DUMPLOCK(ctx, unit, lock); - a = aino_from_lock (unit, lock); + a = aino_from_lock(ctx, unit, lock); if (a == 0) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, ERROR_OBJECT_NOT_AROUND); @@ -3802,13 +3886,12 @@ static void action_free_lock (Unit *unit, dpacket packet) else a->shlock--; recycle_aino (unit, a); - free_lock(unit, lock); + free_lock(ctx, unit, lock); PUT_PCK_RES1 (packet, DOS_TRUE); } -static uaecptr - action_dup_lock_2 (Unit *unit, dpacket packet, uae_u32 uniq) +static uaecptr action_dup_lock_2(TrapContext *ctx, Unit *unit, dpacket *packet, uae_u32 uniq) { uaecptr out; a_inode *a; @@ -3828,14 +3911,13 @@ static uaecptr return 0; } a->shlock++; - de_recycle_aino (unit, a); - out = make_lock (unit, a->uniq, -2) >> 2; + de_recycle_aino(unit, a); + out = make_lock(ctx, unit, a->uniq, -2) >> 2; PUT_PCK_RES1 (packet, out); return out; } -static void - action_dup_lock (Unit *unit, dpacket packet) +static void action_dup_lock(TrapContext *ctx, Unit *unit, dpacket *packet) { uaecptr lock = GET_PCK_ARG1 (packet) << 2; TRACE((_T("ACTION_DUP_LOCK(0x%x)\n"), lock)); @@ -3843,12 +3925,11 @@ static void PUT_PCK_RES1 (packet, 0); return; } - action_dup_lock_2 (unit, packet, get_long (lock + 4)); + action_dup_lock_2(ctx, unit, packet, trap_get_long(ctx, lock + 4)); } -static void - action_lock_from_fh (Unit *unit, dpacket packet) +static void action_lock_from_fh(TrapContext *ctx, Unit *unit, dpacket *packet) { Key *k = lookup_key (unit, GET_PCK_ARG1 (packet)); TRACE((_T("ACTION_COPY_DIR_FH(0x%x,'%s')\n"), GET_PCK_ARG1 (packet), k ? k->aino->aname : _T(""))); @@ -3856,7 +3937,7 @@ static void PUT_PCK_RES1 (packet, DOS_FALSE); return; } - action_dup_lock_2 (unit, packet, k->aino->uniq); + action_dup_lock_2(ctx, unit, packet, k->aino->uniq); } static void free_exkey (Unit *unit, a_inode *aino) @@ -3891,8 +3972,7 @@ static bool get_statinfo(Unit *unit, a_inode *aino, struct mystat *statbuf) return ok; } -static void - get_fileinfo (Unit *unit, dpacket packet, uaecptr info, a_inode *aino, bool longfilesize) +static void get_fileinfo(TrapContext *ctx, Unit *unit, dpacket *packet, uaecptr info, a_inode *aino, bool longfilesize) { struct mystat statbuf; int days, mins, ticks; @@ -3901,6 +3981,7 @@ static void int fsdb_can = fsdb_cando (unit); const TCHAR *xs; char *x, *x2; + uae_u8 buf[260] = { 0 }; if (aino->vfso) { fsdb_can = 1; @@ -3914,7 +3995,7 @@ static void return; } - put_long(info + 0, aino->uniq); + put_long_host(buf + 0, aino->uniq); if (aino->parent == 0) { /* Guru book says ST_ROOT = 1 (root directory, not currently used) * but some programs really expect 2 from root dir.. @@ -3925,79 +4006,80 @@ static void entrytype = aino->softlink ? ST_SOFTLINK : (aino->dir ? ST_USERDIR : ST_FILE); xs = aino->aname; } - put_long (info + 4, entrytype); + put_long_host(buf + 4, entrytype); /* AmigaOS docs say these have to contain the same value. */ - put_long (info + 120, entrytype); + put_long_host(buf + 120, entrytype); TRACE((_T("name=\"%s\"\n"), xs)); x2 = x = ua_fs (xs, -1); n = strlen (x); if (n > 107) n = 107; - if (n > abs (currprefs.filesys_max_name)) - n = abs (currprefs.filesys_max_name); + if (n > abs(currprefs.filesys_max_name)) + n = abs(currprefs.filesys_max_name); i = 8; - put_byte (info + i, n); i++; + put_byte_host(buf + i, n); i++; while (n--) - put_byte (info + i, *x), i++, x++; + put_byte_host(buf + i, *x), i++, x++; while (i < 108) - put_byte (info + i, 0), i++; + put_byte_host(buf + i, 0), i++; xfree (x2); - put_long (info + 116, fsdb_can ? aino->amigaos_mode : fsdb_mode_supported (aino)); + put_long_host(buf + 116, fsdb_can ? aino->amigaos_mode : fsdb_mode_supported (aino)); if (kickstart_version >= 36) { - put_word (info + 224, 0); // OwnerUID - put_word (info + 226, 0); // OwnerGID + put_word_host(buf + 224, 0); // OwnerUID + put_word_host(buf + 226, 0); // OwnerGID } blocksize = (unit->volflags & MYVOLUMEINFO_CDFS) ? 2048 : 512; numblocks = (statbuf.size + blocksize - 1) / blocksize; - put_long (info + 128, numblocks > MAXFILESIZE32 ? MAXFILESIZE32 : numblocks); + put_long_host(buf + 128, numblocks > MAXFILESIZE32 ? MAXFILESIZE32 : numblocks); if (longfilesize) { /* MorphOS 64-bit file length support */ - put_long (info + 124, statbuf.size > MAXFILESIZE32_2G ? 0 : (uae_u32)statbuf.size); - put_long (info + 228, statbuf.size >> 32); - put_long (info + 232, (uae_u32)statbuf.size); - put_long (info + 236, numblocks >> 32); - put_long (info + 240, (uae_u32)numblocks); + put_long_host(buf + 124, statbuf.size > MAXFILESIZE32_2G ? 0 : (uae_u32)statbuf.size); + put_long_host(buf + 228, statbuf.size >> 32); + put_long_host(buf + 232, (uae_u32)statbuf.size); + put_long_host(buf + 236, numblocks >> 32); + put_long_host(buf + 240, (uae_u32)numblocks); } else { - put_long (info + 124, statbuf.size > MAXFILESIZE32 ? MAXFILESIZE32 : (uae_u32)statbuf.size); + put_long_host(buf + 124, statbuf.size > MAXFILESIZE32 ? MAXFILESIZE32 : (uae_u32)statbuf.size); } timeval_to_amiga (&statbuf.mtime, &days, &mins, &ticks, 50); - put_long (info + 132, days); - put_long (info + 136, mins); - put_long (info + 140, ticks); + put_long_host(buf + 132, days); + put_long_host(buf + 136, mins); + put_long_host(buf + 140, ticks); if (aino->comment == 0 || !fsdb_can) - put_long (info + 144, 0); + put_long_host(buf + 144, 0); else { TRACE((_T("comment=\"%s\"\n"), aino->comment)); i = 144; xs = aino->comment; if (!xs) xs= _T(""); - x2 = x = ua_fs (xs, -1); - n = strlen (x); + x2 = x = ua_fs(xs, -1); + n = strlen(x); if (n > 78) n = 78; - put_byte (info + i, n); i++; + put_byte_host(buf + i, n); i++; while (n--) - put_byte (info + i, *x), i++, x++; + put_byte_host(buf + i, *x), i++, x++; while (i < 224) - put_byte (info + i, 0), i++; + put_byte_host(buf + i, 0), i++; xfree (x2); } + trap_put_bytes(ctx, buf, info, sizeof buf); PUT_PCK_RES1 (packet, DOS_TRUE); } -int get_native_path (uae_u32 lock, TCHAR *out) +int get_native_path(TrapContext *ctx, uae_u32 lock, TCHAR *out) { int i = 0; for (i = 0; i < MAX_FILESYSTEM_UNITS; i++) { if (mountinfo.ui[i].self) { - a_inode *a = aino_from_lock (mountinfo.ui[i].self, lock << 2); + a_inode *a = aino_from_lock(ctx, mountinfo.ui[i].self, lock << 2); if (a) { _tcscpy (out, a->nname); return 0; @@ -4012,7 +4094,7 @@ int get_native_path (uae_u32 lock, TCHAR *out) #define REC_SHARED 2 #define REC_SHARED_IMMED 3 -static struct lockrecord *new_record (uae_u32 packet, uae_u64 pos, uae_u64 len, uae_u32 mode, uae_u32 timeout, uae_u32 msg) +static struct lockrecord *new_record (dpacket *packet, uae_u64 pos, uae_u64 len, uae_u32 mode, uae_u32 timeout, uae_u32 msg) { struct lockrecord *lr = xcalloc (struct lockrecord, 1); lr->packet = packet; @@ -4050,7 +4132,7 @@ static bool record_hit (Unit *unit, Key *k, uae_u64 pos, uae_u64 len, uae_u32 mo return false; } -static void record_timeout (Unit *unit) +static void record_timeout(TrapContext *ctx, Unit *unit) { bool retry = true; while (retry) { @@ -4063,8 +4145,8 @@ static void record_timeout (Unit *unit) PUT_PCK_RES1 (lr->packet, DOS_FALSE); PUT_PCK_RES2 (lr->packet, ERROR_LOCK_TIMEOUT); // mark packet as complete - put_long (lr->msg + 4, 0xfffffffe); - uae_Signal (get_long (unit->volume + 176 - 32), 1 << 13); + trap_put_long(ctx, lr->msg + 4, 0xfffffffe); + uae_Signal (trap_get_long(ctx, unit->volume + 176 - 32), 1 << 13); if (prev) prev->next = lr->next; else @@ -4079,7 +4161,7 @@ static void record_timeout (Unit *unit) } } -static void record_check_waiting (Unit *unit) +static void record_check_waiting(TrapContext *ctx, Unit *unit) { bool retry = true; while (retry) { @@ -4094,7 +4176,7 @@ static void record_check_waiting (Unit *unit) unit->waitingrecords = lr->next; write_log (_T("queued record released '%s',%llud,%llu,%d,%d\n"), k->aino->nname, lr->pos, lr->len, lr->mode, lr->timeout); // mark packet as complete - put_long (lr->msg + 4, 0xffffffff); + trap_put_long(ctx, lr->msg + 4, 0xffffffff); xfree (lr); retry = true; break; @@ -4104,7 +4186,7 @@ static void record_check_waiting (Unit *unit) } } -static int action_lock_record (Unit *unit, dpacket packet, uae_u32 msg) +static int action_lock_record(TrapContext *ctx, Unit *unit, dpacket *packet, uae_u32 msg) { Key *k = lookup_key (unit, GET_PCK_ARG1 (packet)); uae_u32 pos = GET_PCK_ARG2 (packet); @@ -4144,7 +4226,7 @@ static int action_lock_record (Unit *unit, dpacket packet, uae_u32 msg) return 1; } - struct lockrecord *lr = new_record (GET_PCK_ARG1 (packet), pos, len, mode, timeout, 0); + struct lockrecord *lr = new_record (packet, pos, len, mode, timeout, 0); if (k->record) { lr->next = k->record; k->record = lr; @@ -4156,7 +4238,7 @@ static int action_lock_record (Unit *unit, dpacket packet, uae_u32 msg) return 1; } -static void action_free_record (Unit *unit, dpacket packet) +static void action_free_record(TrapContext *ctx, Unit *unit, dpacket *packet) { Key *k = lookup_key (unit, GET_PCK_ARG1 (packet)); uae_u32 pos = GET_PCK_ARG2 (packet); @@ -4179,7 +4261,7 @@ static void action_free_record (Unit *unit, dpacket packet) k->record = lr->next; xfree (lr); write_log (_T("->OK\n")); - record_check_waiting (unit); + record_check_waiting(ctx, unit); PUT_PCK_RES1 (packet, DOS_TRUE); return; } @@ -4215,7 +4297,7 @@ static ExAllKey *getexall (Unit *unit, uaecptr control, int id) return NULL; } -static int exalldo (uaecptr exalldata, uae_u32 exalldatasize, uae_u32 type, uaecptr control, Unit *unit, a_inode *aino) +static int exalldo(TrapContext *ctx, uaecptr exalldata, uae_u32 exalldatasize, uae_u32 type, uaecptr control, Unit *unit, a_inode *aino) { uaecptr exp = exalldata; int i; @@ -4285,9 +4367,9 @@ static int exalldo (uaecptr exalldata, uae_u32 exalldatasize, uae_u32 type, uaec size2 += 8; } - i = get_long (control + 0); + i = trap_get_long(ctx, control + 0); while (i > 0) { - exp = get_long (exp); /* ed_Next */ + exp = trap_get_long(ctx, exp); /* ed_Next */ i--; } @@ -4296,46 +4378,46 @@ static int exalldo (uaecptr exalldata, uae_u32 exalldatasize, uae_u32 type, uaec #if EXALL_DEBUG > 0 write_log (_T("ID=%d, %d, %08x: '%s'%s\n"), - get_long (control + 4), get_long (control + 0), exp, xs, aino->dir ? _T(" [DIR]") : _T("")); + trap_get_long(ctx, control + 4), trap_get_long(ctx, control + 0), exp, xs, aino->dir ? _T(" [DIR]") : _T("")); #endif - put_long (exp, exp + size + size2); /* ed_Next */ + trap_put_long(ctx, exp, exp + size + size2); /* ed_Next */ if (type >= 1) { - put_long (exp + 4, exp + size2); + trap_put_long(ctx, exp + 4, exp + size2); for (i = 0; i <= strlen (x); i++) { - put_byte (exp + size2, x[i]); + trap_put_byte(ctx, exp + size2, x[i]); size2++; } } if (type >= 2) - put_long (exp + 8, entrytype); + trap_put_long(ctx, exp + 8, entrytype); if (type >= 3) - put_long (exp + 12, statbuf.size > MAXFILESIZE32 ? MAXFILESIZE32 : statbuf.size); + trap_put_long(ctx, exp + 12, statbuf.size > MAXFILESIZE32 ? MAXFILESIZE32 : statbuf.size); if (type >= 4) - put_long (exp + 16, flags); + trap_put_long(ctx, exp + 16, flags); if (type >= 5) { - put_long (exp + 20, days); - put_long (exp + 24, mins); - put_long (exp + 28, ticks); + trap_put_long(ctx, exp + 20, days); + trap_put_long(ctx, exp + 24, mins); + trap_put_long(ctx, exp + 28, ticks); } if (type >= 6) { - put_long (exp + 32, exp + size2); - put_byte (exp + size2, strlen (comment)); + trap_put_long(ctx, exp + 32, exp + size2); + trap_put_byte(ctx, exp + size2, strlen (comment)); for (i = 0; i <= strlen (comment); i++) { - put_byte (exp + size2, comment[i]); + trap_put_byte(ctx, exp + size2, comment[i]); size2++; } } if (type >= 7) { - put_word (exp + 36, uid); - put_word (exp + 38, gid); + trap_put_word(ctx, exp + 36, uid); + trap_put_word(ctx, exp + 38, gid); } if (type >= 8) { - put_long (exp + 40, statbuf.size >> 32); - put_long (exp + 44, (uae_u32)statbuf.size); + trap_put_long(ctx, exp + 40, statbuf.size >> 32); + trap_put_long(ctx, exp + 44, (uae_u32)statbuf.size); } - put_long (control + 0, get_long (control + 0) + 1); + trap_put_long(ctx, control + 0, trap_get_long(ctx, control + 0) + 1); ret = 1; end: xfree (x); @@ -4343,7 +4425,7 @@ end: return ret; } -static bool filesys_name_invalid (const TCHAR *fn) +static bool filesys_name_invalid(const TCHAR *fn) { return _tcslen (fn) > currprefs.filesys_max_name; } @@ -4360,7 +4442,7 @@ static int filesys_readdir(struct fs_dirhandle *d, TCHAR *fn, uae_u64 *uniq) return ok; } -static int action_examine_all_do (Unit *unit, uaecptr lock, ExAllKey *eak, uaecptr exalldata, uae_u32 exalldatasize, uae_u32 type, uaecptr control) +static int action_examine_all_do(TrapContext *ctx, Unit *unit, uaecptr lock, ExAllKey *eak, uaecptr exalldata, uae_u32 exalldatasize, uae_u32 type, uaecptr control) { a_inode *aino, *base = NULL; int ok; @@ -4369,7 +4451,7 @@ static int action_examine_all_do (Unit *unit, uaecptr lock, ExAllKey *eak, uaecp TCHAR fn[MAX_DPATH]; if (lock != 0) - base = aino_from_lock (unit, lock); + base = aino_from_lock(ctx, unit, lock); if (base == 0) base = &unit->rootnode; for (;;) { @@ -4390,8 +4472,8 @@ static int action_examine_all_do (Unit *unit, uaecptr lock, ExAllKey *eak, uaecp if (!aino) return 0; eak->id = unit->exallid++; - put_long (control + 4, eak->id); - if (!exalldo (exalldata, exalldatasize, type, control, unit, aino)) { + trap_put_long(ctx, control + 4, eak->id); + if (!exalldo(ctx, exalldata, exalldatasize, type, control, unit, aino)) { eak->fn = my_strdup (fn); /* no space in exallstruct, save current entry */ break; } @@ -4399,7 +4481,7 @@ static int action_examine_all_do (Unit *unit, uaecptr lock, ExAllKey *eak, uaecp return 1; } -static int action_examine_all_end (Unit *unit, dpacket packet) +static int action_examine_all_end(TrapContext *ctx, Unit *unit, dpacket *packet) { uae_u32 id; uae_u32 doserr = 0; @@ -4408,7 +4490,7 @@ static int action_examine_all_end (Unit *unit, dpacket packet) if (kickstart_version < 36) return 0; - id = get_long (control + 4); + id = trap_get_long(ctx, control + 4); eak = getexall (unit, control, id); #if EXALL_DEBUG > 0 write_log (_T("EXALL_END ID=%d %x\n"), id, eak); @@ -4432,7 +4514,7 @@ static int action_examine_all_end (Unit *unit, dpacket packet) return 1; } -static int action_examine_all (Unit *unit, dpacket packet) +static int action_examine_all(TrapContext *ctx, Unit *unit, dpacket *packet) { uaecptr lock = GET_PCK_ARG1 (packet) << 2; uaecptr exalldata = GET_PCK_ARG2 (packet); @@ -4453,10 +4535,10 @@ static int action_examine_all (Unit *unit, dpacket packet) write_log (_T("exall: %08x %08x-%08x %d %d %08x\n"), lock, exalldata, exalldata + exalldatasize, exalldatasize, type, control); write_log (_T("exall: MatchString %08x, MatchFunc %08x\n"), - get_long (control + 8), get_long (control + 12)); + trap_get_long(ctx, control + 8), trap_get_long(ctx, control + 12)); #endif - put_long (control + 0, 0); /* eac_Entries */ + trap_put_long(ctx, control + 0, 0); /* eac_Entries */ /* EXAMINE ALL might use dos.library MatchPatternNoCase() which is >=36 */ if (kickstart_version < 36) @@ -4468,7 +4550,7 @@ static int action_examine_all (Unit *unit, dpacket packet) } PUT_PCK_RES1 (packet, DOS_TRUE); - id = get_long (control + 4); + id = trap_get_long(ctx, control + 4); if (id == EXALL_END) { write_log (_T("FILESYS: EXALL called twice with ERROR_NO_MORE_ENTRIES\n")); goto fail; /* already ended exall() */ @@ -4480,9 +4562,9 @@ static int action_examine_all (Unit *unit, dpacket packet) doserr = ERROR_OBJECT_WRONG_TYPE; goto fail; } - if (!action_examine_all_do (unit, lock, eak, exalldata, exalldatasize, type, control)) + if (!action_examine_all_do(ctx, unit, lock, eak, exalldata, exalldatasize, type, control)) goto fail; - if (get_long (control + 0) == 0) { + if (trap_get_long(ctx, control + 0) == 0) { /* uh, no space for first entry.. */ doserr = ERROR_NO_FREE_STORE; goto fail; @@ -4494,7 +4576,7 @@ static int action_examine_all (Unit *unit, dpacket packet) if (!eak) goto fail; if (lock != 0) - base = aino_from_lock (unit, lock); + base = aino_from_lock(ctx, unit, lock); if (base == 0) base = &unit->rootnode; #if EXALL_DEBUG > 0 @@ -4504,10 +4586,10 @@ static int action_examine_all (Unit *unit, dpacket packet) if (!d) goto fail; eak->dirhandle = d; - put_long (control + 4, eak->id); - if (!action_examine_all_do (unit, lock, eak, exalldata, exalldatasize, type, control)) + trap_put_long(ctx, control + 4, eak->id); + if (!action_examine_all_do(ctx, unit, lock, eak, exalldata, exalldatasize, type, control)) goto fail; - if (get_long (control + 0) == 0) { + if (trap_get_long(ctx, control + 0) == 0) { /* uh, no space for first entry.. */ doserr = ERROR_NO_FREE_STORE; goto fail; @@ -4519,18 +4601,18 @@ static int action_examine_all (Unit *unit, dpacket packet) fail: /* Clear last ed_Next. This "list" is quite non-Amiga like.. */ exp = exalldata; - i = get_long (control + 0); + i = trap_get_long(ctx, control + 0); for (;;) { if (i <= 1) { if (exp) - put_long (exp, 0); + trap_put_long(ctx, exp, 0); break; } - exp = get_long (exp); /* ed_Next */ + exp = trap_get_long(ctx, exp); /* ed_Next */ i--; } #if EXALL_DEBUG > 0 - write_log("ok=%d, err=%d, eac_Entries = %d\n", ok, ok ? -1 : doserr, get_long (control + 0)); + write_log("ok=%d, err=%d, eac_Entries = %d\n", ok, ok ? -1 : doserr, trap_get_long(ctx, control + 0)); #endif if (!ok) { @@ -4544,18 +4626,22 @@ fail: eak->fn = NULL; } if (doserr == ERROR_NO_MORE_ENTRIES) - put_long (control + 4, EXALL_END); + trap_put_long(ctx, control + 4, EXALL_END); } return 1; } -static uae_u32 exall_helpder (TrapContext *context) +static uae_u32 exall_helper(TrapContext *ctx) { int i; Unit *u; - uaecptr packet = m68k_areg (regs, 4); - uaecptr control = get_long (packet + dp_Arg5); - uae_u32 id = get_long (control + 4); + uaecptr pck = trap_get_areg(ctx, 4); + + dpacket packet; + readdpacket(ctx, &packet, pck); + + uaecptr control = get_long_host(packet.packet_data + dp_Arg5); + uae_u32 id = trap_get_long(ctx, control + 4); #if EXALL_DEBUG > 0 write_log (_T("FILESYS: EXALL extra round ID=%d\n"), id); @@ -4565,25 +4651,25 @@ static uae_u32 exall_helpder (TrapContext *context) for (u = units; u; u = u->next) { for (i = 0; i < EXALLKEYS; i++) { if (u->exalls[i].id == id && u->exalls[i].control == control) { - action_examine_all (u, packet); + action_examine_all(ctx, u, &packet); } } } return 1; } -static uae_u32 REGPARAM2 fsmisc_helper (TrapContext *context) +static uae_u32 REGPARAM2 fsmisc_helper(TrapContext *ctx) { - int mode = m68k_dreg (regs, 0); + int mode = trap_get_dreg(ctx, 0); switch (mode) { case 0: - return exall_helpder (context); + return exall_helper(ctx); case 1: - return filesys_media_change_reply (context, 0); + return filesys_media_change_reply (ctx, 0); case 2: - return filesys_media_change_reply (context, 1); + return filesys_media_change_reply (ctx, 1); case 3: uae_u32 t = getlocaltime (); uae_u32 secs = (uae_u32)t - (8 * 365 + 2) * 24 * 60 * 60; @@ -4592,21 +4678,21 @@ static uae_u32 REGPARAM2 fsmisc_helper (TrapContext *context) return 0; } -static void action_examine_object (Unit *unit, dpacket packet) +static void action_examine_object(TrapContext *ctx, Unit *unit, dpacket *packet) { uaecptr lock = GET_PCK_ARG1 (packet) << 2; uaecptr info = GET_PCK_ARG2 (packet) << 2; a_inode *aino = 0; TRACE((_T("ACTION_EXAMINE_OBJECT(0x%x,0x%x)\n"), lock, info)); - DUMPLOCK(unit, lock); + DUMPLOCK(ctx, unit, lock); if (lock != 0) - aino = aino_from_lock (unit, lock); + aino = aino_from_lock(ctx, unit, lock); if (aino == 0) aino = &unit->rootnode; - get_fileinfo (unit, packet, info, aino, false); + get_fileinfo(ctx, unit, packet, info, aino, false); } extern unsigned char def_tool[]; @@ -4716,14 +4802,14 @@ static void populate_directory (Unit *unit, a_inode *base) inject_icons_to_directory(unit, base); } -static bool do_examine (Unit *unit, dpacket packet, a_inode *aino, uaecptr info, bool longfilesize) +static bool do_examine(TrapContext *ctx, Unit *unit, dpacket *packet, a_inode *aino, uaecptr info, bool longfilesize) { for (;;) { TCHAR *name; if (!aino) break; name = aino->nname; - get_fileinfo (unit, packet, info, aino, longfilesize); + get_fileinfo(ctx, unit, packet, info, aino, longfilesize); if (!aino->vfso && !(unit->volflags & (MYVOLUMEINFO_ARCHIVE | MYVOLUMEINFO_CDFS)) && !fsdb_exists(name)) { TRACE ((_T("%s orphaned"), name)); return false; @@ -4739,7 +4825,7 @@ static bool do_examine (Unit *unit, dpacket packet, a_inode *aino, uaecptr info, #define EXNEXT_DEBUG 0 -static void action_examine_next (Unit *unit, dpacket packet, bool largefilesize) +static void action_examine_next(TrapContext *ctx, Unit *unit, dpacket *packet, bool largefilesize) { uaecptr lock = GET_PCK_ARG1 (packet) << 2; uaecptr info = GET_PCK_ARG2 (packet) << 2; @@ -4748,13 +4834,13 @@ static void action_examine_next (Unit *unit, dpacket packet, bool largefilesize) TRACE((_T("ACTION_EXAMINE_NEXT(0x%x,0x%x,%d)\n"), lock, info, largefilesize)); gui_flicker_led (UNIT_LED(unit), unit->unit, 1); - DUMPLOCK(unit, lock); + DUMPLOCK(ctx, unit, lock); if (lock != 0) - aino = aino_from_lock (unit, lock); + aino = aino_from_lock(ctx, unit, lock); if (aino == 0) aino = &unit->rootnode; - uniq = get_long(info); + uniq = trap_get_long(ctx, info); for (;;) { if (uniq == aino->uniq) { // first exnext @@ -4816,7 +4902,7 @@ static void action_examine_next (Unit *unit, dpacket packet, bool largefilesize) uniq = daino->uniq; if (daino->mountcount != unit->mountcount) continue; - if (!do_examine (unit, packet, daino, info, largefilesize)) + if (!do_examine(ctx, unit, packet, daino, info, largefilesize)) continue; return; } @@ -4827,7 +4913,7 @@ no_more_entries: PUT_PCK_RES2 (packet, ERROR_NO_MORE_ENTRIES); } -static void do_find (Unit *unit, dpacket packet, int mode, int create, int fallback) +static void do_find(TrapContext *ctx, Unit *unit, dpacket *packet, int mode, int create, int fallback) { uaecptr fh = GET_PCK_ARG1 (packet) << 2; uaecptr lock = GET_PCK_ARG2 (packet) << 2; @@ -4840,11 +4926,11 @@ static void do_find (Unit *unit, dpacket packet, int mode, int create, int fallb int aino_created = 0; int isvirtual = unit->volflags & (MYVOLUMEINFO_ARCHIVE | MYVOLUMEINFO_CDFS); - TRACE((_T("ACTION_FIND_*(0x%08x,0x%08x,\"%s\",%d,%d)\n"), fh, lock, bstr (unit, name), mode, create)); + TRACE((_T("ACTION_FIND_*(0x%08x,0x%08x,\"%s\",%d,%d)\n"), fh, lock, bstr(ctx, unit, name), mode, create)); TRACE((_T("fh=%x lock=%x name=%x\n"), fh, lock, name)); - DUMPLOCK(unit, lock); + DUMPLOCK(ctx, unit, lock); - aino = find_aino (unit, lock, bstr (unit, name), &err); + aino = find_aino(ctx, unit, lock, bstr(ctx, unit, name), &err); if (aino == 0 || (err != 0 && err != ERROR_OBJECT_NOT_AROUND)) { /* Whatever it is, we can't handle it. */ @@ -4853,7 +4939,7 @@ static void do_find (Unit *unit, dpacket packet, int mode, int create, int fallb return; } if (aino->softlink) { - handle_softlink (unit, packet, aino); + handle_softlink(ctx, unit, packet, aino); return; } if (err == 0) { @@ -4910,7 +4996,7 @@ static void do_find (Unit *unit, dpacket packet, int mode, int create, int fallb return; } else { /* Object does not exist. aino points to containing directory. */ - aino = create_child_aino (unit, aino, my_strdup (bstr_cut (unit, name)), 0); + aino = create_child_aino(unit, aino, my_strdup (bstr_cut(ctx, unit, name)), 0); if (aino == 0) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, ERROR_DISK_IS_FULL); /* best we can do */ @@ -4949,7 +5035,7 @@ static void do_find (Unit *unit, dpacket packet, int mode, int create, int fallb if (create && isvirtual) fsdb_set_file_attrs (aino); - put_long (fh + 36, k->uniq); + trap_put_long(ctx, fh + 36, k->uniq); if (create == 2) { aino->elock = 1; // clear comment if file already existed @@ -4966,8 +5052,7 @@ static void do_find (Unit *unit, dpacket packet, int mode, int create, int fallb PUT_PCK_RES1 (packet, DOS_TRUE); } -static void - action_fh_from_lock (Unit *unit, dpacket packet) +static void action_fh_from_lock(TrapContext *ctx, Unit *unit, dpacket *packet) { uaecptr fh = GET_PCK_ARG1 (packet) << 2; uaecptr lock = GET_PCK_ARG2 (packet) << 2; @@ -4978,7 +5063,7 @@ static void int mode; TRACE((_T("ACTION_FH_FROM_LOCK(0x%x,0x%x)\n"), fh, lock)); - DUMPLOCK(unit,lock); + DUMPLOCK(ctx, unit,lock); if (!lock) { PUT_PCK_RES1 (packet, DOS_FALSE); @@ -4986,11 +5071,11 @@ static void return; } - aino = aino_from_lock (unit, lock); + aino = aino_from_lock(ctx, unit, lock); if (aino == 0) aino = &unit->rootnode; if (aino->softlink) { - handle_softlink (unit, packet, aino); + handle_softlink(ctx, unit, packet, aino); return; } @@ -5018,42 +5103,39 @@ static void k->fd = fd; k->aino = aino; - put_long (fh + 36, k->uniq); + trap_put_long(ctx, fh + 36, k->uniq); /* I don't think I need to play with shlock count here, because I'm opening from an existing lock ??? */ de_recycle_aino (unit, aino); - free_lock (unit, lock); /* lock must be unlocked */ + free_lock(ctx, unit, lock); /* lock must be unlocked */ PUT_PCK_RES1 (packet, DOS_TRUE); /* PUT_PCK_RES2 (packet, k->uniq); - this shouldn't be necessary, try without it */ } -static void - action_find_input (Unit *unit, dpacket packet) +static void action_find_input(TrapContext *ctx, Unit *unit, dpacket *packet) { - do_find (unit, packet, A_FIBF_READ | A_FIBF_WRITE, 0, 1); + do_find(ctx, unit, packet, A_FIBF_READ | A_FIBF_WRITE, 0, 1); } -static void - action_find_output (Unit *unit, dpacket packet) +static void action_find_output(TrapContext *ctx, Unit *unit, dpacket *packet) { if (unit->ui.readonly || unit->ui.locked) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED); return; } - do_find (unit, packet, A_FIBF_READ | A_FIBF_WRITE, 2, 0); + do_find(ctx, unit, packet, A_FIBF_READ | A_FIBF_WRITE, 2, 0); } -static void - action_find_write (Unit *unit, dpacket packet) +static void action_find_write(TrapContext *ctx, Unit *unit, dpacket *packet) { if (unit->ui.readonly || unit->ui.locked) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED); return; } - do_find (unit, packet, A_FIBF_READ | A_FIBF_WRITE, 1, 0); + do_find(ctx, unit, packet, A_FIBF_READ | A_FIBF_WRITE, 1, 0); } /* change file/dir's parent dir modification time */ @@ -5072,8 +5154,7 @@ static void updatedirtime (a_inode *a1, int now) } } -static void - action_end (Unit *unit, dpacket packet) +static void action_end(TrapContext *ctx, Unit *unit, dpacket *packet) { Key *k; TRACE((_T("ACTION_END(0x%x)\n"), GET_PCK_ARG1 (packet))); @@ -5081,7 +5162,7 @@ static void k = lookup_key (unit, GET_PCK_ARG1 (packet)); if (k != 0) { if (k->notifyactive) { - notify_check (unit, k->aino); + notify_check(ctx, unit, k->aino); updatedirtime (k->aino, 1); } if (k->aino->elock) @@ -5095,8 +5176,7 @@ static void PUT_PCK_RES2 (packet, 0); } -static void - action_read (Unit *unit, dpacket packet) +static void action_read(TrapContext *ctx, Unit *unit, dpacket *packet) { Key *k = lookup_key (unit, GET_PCK_ARG1 (packet)); uaecptr addr = GET_PCK_ARG2 (packet); @@ -5117,13 +5197,13 @@ static void } else if (k->aino->vfso) { uae_s64 filesize = k->aino->vfso->size; for (int i = 0; i < size && k->file_pos < filesize; i++) { - put_byte(addr + i, k->aino->vfso->data[k->file_pos]); + trap_put_byte(ctx, addr + i, k->aino->vfso->data[k->file_pos]); k->file_pos++; actual++; } PUT_PCK_RES1 (packet, actual); size = 0; - } else if (!valid_address (addr, size)) { + } else if (!trap_valid_address(ctx, addr, size)) { /* check if filesize < size */ uae_s64 filesize, cur; @@ -5135,7 +5215,7 @@ static void if (size == 0) { PUT_PCK_RES1 (packet, 0); PUT_PCK_RES2 (packet, 0); - } else if (!valid_address (addr, size)) { + } else if (!trap_valid_address(ctx, addr, size)) { /* it really crosses memory boundary */ uae_u8 *buf; @@ -5163,7 +5243,7 @@ static void int i; PUT_PCK_RES1 (packet, actual); for (i = 0; i < actual; i++) - put_byte (addr + i, buf[i]); + trap_put_byte(ctx, addr + i, buf[i]); k->file_pos += actual; } xfree (buf); @@ -5172,16 +5252,42 @@ static void } } if (size) { - /* normal fast read */ - uae_u8 *realpt = get_real_address (addr); + if (trap_is_indirect()) { + + uae_u8 buf[RTAREA_TRAP_DATA_EXTRA_SIZE]; + actual = 0; + int sizecnt = size; + while (sizecnt > 0) { + int toread = sizecnt > RTAREA_TRAP_DATA_EXTRA_SIZE ? RTAREA_TRAP_DATA_EXTRA_SIZE : sizecnt; + int read = fs_read(k->fd, buf, toread); + if (read < 0) { + actual = -1; + break; + } + if (read == 0) + break; + trap_put_bytes(ctx, buf, addr, read); + sizecnt -= read; + addr += read; + actual += read; + if (read < toread) + break; + } - if (key_seek(k, k->file_pos, SEEK_SET) < 0) { - PUT_PCK_RES1 (packet, 0); - PUT_PCK_RES2 (packet, dos_errno ()); - return; - } + } else { - actual = fs_read (k->fd, realpt, size); + /* normal fast read */ + uae_u8 *realpt = get_real_address (addr); + + if (key_seek(k, k->file_pos, SEEK_SET) < 0) { + PUT_PCK_RES1 (packet, 0); + PUT_PCK_RES2 (packet, dos_errno ()); + return; + } + + actual = fs_read (k->fd, realpt, size); + + } if (actual == 0) { PUT_PCK_RES1 (packet, 0); @@ -5199,8 +5305,7 @@ static void TRACE((_T("=%d\n"), actual)); } -static void - action_write (Unit *unit, dpacket packet) +static void action_write(TrapContext *ctx, Unit *unit, dpacket *packet) { Key *k = lookup_key (unit, GET_PCK_ARG1 (packet)); uaecptr addr = GET_PCK_ARG2 (packet); @@ -5228,16 +5333,43 @@ static void actual = 0; PUT_PCK_RES1 (packet, 0); PUT_PCK_RES2 (packet, 0); - } else if (valid_address (addr, size)) { - uae_u8 *realpt = get_real_address (addr); + } else if (trap_valid_address(ctx, addr, size)) { + + if (trap_is_indirect()) { + + uae_u8 buf[RTAREA_TRAP_DATA_EXTRA_SIZE]; + actual = 0; + int sizecnt = size; + while (sizecnt > 0) { + int towrite = sizecnt > RTAREA_TRAP_DATA_EXTRA_SIZE ? RTAREA_TRAP_DATA_EXTRA_SIZE : sizecnt; + trap_get_bytes(ctx, buf, addr, towrite); + int write = fs_write(k->fd, buf, towrite); + if (write < 0) { + actual = -1; + break; + } + if (write == 0) + break; + sizecnt -= write; + addr += write; + actual += write; + if (write < towrite) + break; + } - if (key_seek(k, k->file_pos, SEEK_SET) < 0) { - PUT_PCK_RES1 (packet, 0); - PUT_PCK_RES2 (packet, dos_errno ()); - return; + } else { + + uae_u8 *realpt = get_real_address (addr); + + if (key_seek(k, k->file_pos, SEEK_SET) < 0) { + PUT_PCK_RES1 (packet, 0); + PUT_PCK_RES2 (packet, dos_errno ()); + return; + } + + actual = fs_write (k->fd, realpt, size); } - actual = fs_write (k->fd, realpt, size); } else { /* ugh this is inefficient but easy */ @@ -5255,7 +5387,7 @@ static void } for (i = 0; i < size; i++) - buf[i] = get_byte (addr + i); + buf[i] = trap_get_byte(ctx, addr + i); actual = fs_write (k->fd, buf, size); xfree (buf); @@ -5271,8 +5403,7 @@ static void k->notifyactive = 1; } -static void - action_seek (Unit *unit, dpacket packet) +static void action_seek(TrapContext *ctx, Unit *unit, dpacket *packet) { Key *k = lookup_key (unit, GET_PCK_ARG1 (packet)); int pos = (uae_s32)GET_PCK_ARG2 (packet); @@ -5321,8 +5452,7 @@ static void } } -static void - action_set_protect (Unit *unit, dpacket packet) +static void action_set_protect(TrapContext *ctx, Unit *unit, dpacket *packet) { uaecptr lock = GET_PCK_ARG2 (packet) << 2; uaecptr name = GET_PCK_ARG3 (packet) << 2; @@ -5330,7 +5460,7 @@ static void a_inode *a; int err; - TRACE((_T("ACTION_SET_PROTECT(0x%x,\"%s\",0x%x)\n"), lock, bstr (unit, name), mask)); + TRACE((_T("ACTION_SET_PROTECT(0x%x,\"%s\",0x%x)\n"), lock, bstr(ctx, unit, name), mask)); if (unit->ui.readonly || unit->ui.locked) { PUT_PCK_RES1 (packet, DOS_FALSE); @@ -5338,14 +5468,14 @@ static void return; } - a = find_aino (unit, lock, bstr (unit, name), &err); + a = find_aino(ctx, unit, lock, bstr(ctx, unit, name), &err); if (err != 0) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, err); return; } if (a->softlink) { - handle_softlink (unit, packet, a); + handle_softlink(ctx, unit, packet, a); return; } @@ -5359,11 +5489,11 @@ static void } else { PUT_PCK_RES1 (packet, DOS_TRUE); } - notify_check (unit, a); + notify_check(ctx, unit, a); gui_flicker_led (UNIT_LED(unit), unit->unit, 2); } -static void action_set_comment (Unit * unit, dpacket packet) +static void action_set_comment(TrapContext *ctx, Unit * unit, dpacket *packet) { uaecptr lock = GET_PCK_ARG2 (packet) << 2; uaecptr name = GET_PCK_ARG3 (packet) << 2; @@ -5379,7 +5509,7 @@ static void action_set_comment (Unit * unit, dpacket packet) } if (fsdb_cando (unit)) { - commented = bstr (unit, comment); + commented = bstr(ctx, unit, comment); if (_tcslen (commented) > 80) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, ERROR_COMMENT_TOO_BIG); @@ -5396,7 +5526,7 @@ static void action_set_comment (Unit * unit, dpacket packet) } TRACE ((_T("ACTION_SET_COMMENT(0x%x,\"%s\")\n"), lock, commented)); - a = find_aino (unit, lock, bstr (unit, name), &err); + a = find_aino(ctx, unit, lock, bstr(ctx, unit, name), &err); if (err != 0) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, err); @@ -5407,7 +5537,7 @@ maybe_free_and_out: return; } if (a->softlink) { - handle_softlink (unit, packet, a); + handle_softlink(ctx, unit, packet, a); goto maybe_free_and_out; } @@ -5421,28 +5551,26 @@ maybe_free_and_out: xfree (a->comment); a->comment = commented; fsdb_set_file_attrs (a); - notify_check (unit, a); + notify_check(ctx, unit, a); gui_flicker_led (UNIT_LED(unit), unit->unit, 2); } -static void - action_same_lock (Unit *unit, dpacket packet) +static void action_same_lock(TrapContext *ctx, Unit *unit, dpacket *packet) { uaecptr lock1 = GET_PCK_ARG1 (packet) << 2; uaecptr lock2 = GET_PCK_ARG2 (packet) << 2; TRACE((_T("ACTION_SAME_LOCK(0x%x,0x%x)\n"), lock1, lock2)); - DUMPLOCK(unit, lock1); DUMPLOCK(unit, lock2); + DUMPLOCK(ctx, unit, lock1); DUMPLOCK(ctx, unit, lock2); if (!lock1 || !lock2) { PUT_PCK_RES1 (packet, lock1 == lock2 ? DOS_TRUE : DOS_FALSE); } else { - PUT_PCK_RES1 (packet, get_long (lock1 + 4) == get_long (lock2 + 4) ? DOS_TRUE : DOS_FALSE); + PUT_PCK_RES1 (packet, trap_get_long(ctx, lock1 + 4) == trap_get_long(ctx, lock2 + 4) ? DOS_TRUE : DOS_FALSE); } } -static void - action_change_mode (Unit *unit, dpacket packet) +static void action_change_mode(TrapContext *ctx, Unit *unit, dpacket *packet) { #define CHANGE_LOCK 0 #define CHANGE_FH 1 @@ -5466,9 +5594,9 @@ static void } if (type == CHANGE_LOCK) { - uniq = get_long (object + 4); + uniq = trap_get_long(ctx, object + 4); } else { - Key *k = lookup_key (unit, get_long (object + 36)); + Key *k = lookup_key (unit, trap_get_long(ctx, object + 36)); if (!k) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, ERROR_OBJECT_NOT_AROUND); @@ -5504,8 +5632,7 @@ static void } } -static void - action_parent_common (Unit *unit, dpacket packet, unsigned long uniq) +static void action_parent_common(TrapContext *ctx, Unit *unit, dpacket *packet, unsigned long uniq) { a_inode *olda = lookup_aino (unit, uniq); if (olda == 0) { @@ -5526,11 +5653,10 @@ static void } olda->parent->shlock++; de_recycle_aino (unit, olda->parent); - PUT_PCK_RES1 (packet, make_lock (unit, olda->parent->uniq, -2) >> 2); + PUT_PCK_RES1(packet, make_lock(ctx, unit, olda->parent->uniq, -2) >> 2); } -static void - action_parent_fh (Unit *unit, dpacket packet) +static void action_parent_fh(TrapContext *ctx, Unit *unit, dpacket *packet) { Key *k = lookup_key (unit, GET_PCK_ARG1 (packet)); if (!k) { @@ -5538,11 +5664,10 @@ static void PUT_PCK_RES2 (packet, ERROR_OBJECT_NOT_AROUND); return; } - action_parent_common (unit, packet, k->aino->uniq); + action_parent_common (ctx, unit, packet, k->aino->uniq); } -static void - action_parent (Unit *unit, dpacket packet) +static void action_parent(TrapContext *ctx, Unit *unit, dpacket *packet) { uaecptr lock = GET_PCK_ARG1 (packet) << 2; @@ -5552,20 +5677,19 @@ static void PUT_PCK_RES1 (packet, 0); PUT_PCK_RES2 (packet, 0); } else { - action_parent_common (unit, packet, get_long (lock + 4)); + action_parent_common(ctx, unit, packet, trap_get_long(ctx, lock + 4)); } TRACE((_T("=%x %d\n"), GET_PCK_RES1 (packet), GET_PCK_RES2 (packet))); } -static void - action_create_dir (Unit *unit, dpacket packet) +static void action_create_dir(TrapContext *ctx, Unit *unit, dpacket *packet) { uaecptr lock = GET_PCK_ARG1 (packet) << 2; uaecptr name = GET_PCK_ARG2 (packet) << 2; a_inode *aino; int err; - TRACE((_T("ACTION_CREATE_DIR(0x%x,\"%s\")\n"), lock, bstr (unit, name))); + TRACE((_T("ACTION_CREATE_DIR(0x%x,\"%s\")\n"), lock, bstr(ctx, unit, name))); if (unit->ui.readonly || unit->ui.locked) { PUT_PCK_RES1 (packet, DOS_FALSE); @@ -5573,7 +5697,7 @@ static void return; } - aino = find_aino (unit, lock, bstr (unit, name), &err); + aino = find_aino(ctx, unit, lock, bstr(ctx, unit, name), &err); if (aino == 0 || (err != 0 && err != ERROR_OBJECT_NOT_AROUND)) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, err); @@ -5586,7 +5710,7 @@ static void return; } /* Object does not exist. aino points to containing directory. */ - aino = create_child_aino (unit, aino, my_strdup (bstr_cut (unit, name)), 1); + aino = create_child_aino(unit, aino, my_strdup (bstr_cut(ctx, unit, name)), 1); if (aino == 0) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, ERROR_DISK_IS_FULL); /* best we can do */ @@ -5601,14 +5725,13 @@ static void aino->shlock = 1; fsdb_set_file_attrs (aino); de_recycle_aino (unit, aino); - notify_check (unit, aino); + notify_check(ctx, unit, aino); updatedirtime (aino, 0); - PUT_PCK_RES1 (packet, make_lock (unit, aino->uniq, -2) >> 2); + PUT_PCK_RES1(packet, make_lock(ctx, unit, aino->uniq, -2) >> 2); gui_flicker_led (UNIT_LED(unit), unit->unit, 2); } -static void - action_examine_fh (Unit *unit, dpacket packet, bool largefilesize) +static void action_examine_fh(TrapContext *ctx, Unit *unit, dpacket *packet, bool largefilesize) { Key *k; a_inode *aino = 0; @@ -5623,15 +5746,14 @@ static void if (aino == 0) aino = &unit->rootnode; - get_fileinfo (unit, packet, info, aino, largefilesize); + get_fileinfo(ctx, unit, packet, info, aino, largefilesize); } /* For a nice example of just how contradictory documentation can be, see the * Autodoc for DOS:SetFileSize and the Packets.txt description of this packet... * This implementation tries to mimic the behaviour of the Kick 3.1 ramdisk * (which seems to match the Autodoc description). */ -static void - action_set_file_size (Unit *unit, dpacket packet) +static void action_set_file_size(TrapContext *ctx, Unit *unit, dpacket *packet) { Key *k, *k1; off_t offset = GET_PCK_ARG2 (packet); @@ -5746,15 +5868,14 @@ static void relock_re (Unit *unit, a_inode *a1, a_inode *a2, int failed) } } -static void - action_delete_object (Unit *unit, dpacket packet) +static void action_delete_object(TrapContext *ctx, Unit *unit, dpacket *packet) { uaecptr lock = GET_PCK_ARG1 (packet) << 2; uaecptr name = GET_PCK_ARG2 (packet) << 2; a_inode *a; int err; - TRACE((_T("ACTION_DELETE_OBJECT(0x%x,\"%s\")\n"), lock, bstr (unit, name))); + TRACE((_T("ACTION_DELETE_OBJECT(0x%x,\"%s\")\n"), lock, bstr(ctx, unit, name))); if (unit->ui.readonly || unit->ui.locked) { PUT_PCK_RES1 (packet, DOS_FALSE); @@ -5762,7 +5883,7 @@ static void return; } - a = find_aino (unit, lock, bstr (unit, name), &err); + a = find_aino(ctx, unit, lock, bstr(ctx, unit, name), &err); if (err != 0) { PUT_PCK_RES1 (packet, DOS_FALSE); @@ -5796,7 +5917,7 @@ static void } } } - notify_check (unit, a); + notify_check(ctx, unit, a); updatedirtime (a, 1); if (a->child != 0) { write_log (_T("Serious error in action_delete_object.\n")); @@ -5808,8 +5929,7 @@ static void gui_flicker_led (UNIT_LED(unit), unit->unit, 2); } -static void - action_set_date (Unit *unit, dpacket packet) +static void action_set_date(TrapContext *ctx, Unit *unit, dpacket *packet) { uaecptr lock = GET_PCK_ARG2 (packet) << 2; uaecptr name = GET_PCK_ARG3 (packet) << 2; @@ -5818,7 +5938,7 @@ static void struct mytimeval tv; int err = 0; - TRACE((_T("ACTION_SET_DATE(0x%x,\"%s\")\n"), lock, bstr (unit, name))); + TRACE((_T("ACTION_SET_DATE(0x%x,\"%s\")\n"), lock, bstr(ctx, unit, name))); if (unit->ui.readonly || unit->ui.locked) { PUT_PCK_RES1 (packet, DOS_FALSE); @@ -5826,19 +5946,19 @@ static void return; } - a = find_aino (unit, lock, bstr (unit, name), &err); + a = find_aino(ctx, unit, lock, bstr(ctx, unit, name), &err); if (err != 0) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, err); return; } if (a->softlink) { - handle_softlink (unit, packet, a); + handle_softlink(ctx, unit, packet, a); return; } if (!a->vfso) { - amiga_to_timeval (&tv, get_long (date), get_long (date + 4), get_long (date + 8), 50); - //write_log (_T("%llu.%u (%d,%d,%d) %s\n"), tv.tv_sec, tv.tv_usec, get_long (date), get_long (date + 4), get_long (date + 8), a->nname); + amiga_to_timeval (&tv, trap_get_long(ctx, date), trap_get_long(ctx, date + 4), trap_get_long(ctx, date + 8), 50); + //write_log (_T("%llu.%u (%d,%d,%d) %s\n"), tv.tv_sec, tv.tv_usec, trap_get_long(ctx, date), trap_get_long(ctx, date + 4), trap_get_long(ctx, date + 8), a->nname); if (!my_utime (a->nname, &tv)) err = dos_errno (); } @@ -5847,14 +5967,13 @@ static void PUT_PCK_RES2 (packet, err); return; } else { - notify_check (unit, a); + notify_check(ctx, unit, a); PUT_PCK_RES1 (packet, DOS_TRUE); } gui_flicker_led (UNIT_LED(unit), unit->unit, 2); } -static void - action_rename_object (Unit *unit, dpacket packet) +static void action_rename_object(TrapContext *ctx, Unit *unit, dpacket *packet) { uaecptr lock1 = GET_PCK_ARG1 (packet) << 2; uaecptr name1 = GET_PCK_ARG2 (packet) << 2; @@ -5865,8 +5984,8 @@ static void Key *k1, *knext; int wehavekeys = 0; - TRACE((_T("ACTION_RENAME_OBJECT(0x%x,\"%s\","), lock1, bstr (unit, name1))); - TRACE((_T("0x%x,\"%s\")\n"), lock2, bstr (unit, name2))); + TRACE((_T("ACTION_RENAME_OBJECT(0x%x,\"%s\","), lock1, bstr(ctx, unit, name1))); + TRACE((_T("0x%x,\"%s\")\n"), lock2, bstr(ctx, unit, name2))); if (unit->ui.readonly || unit->ui.locked) { PUT_PCK_RES1 (packet, DOS_FALSE); @@ -5874,7 +5993,7 @@ static void return; } - a1 = find_aino (unit, lock1, bstr (unit, name1), &err1); + a1 = find_aino(ctx, unit, lock1, bstr(ctx, unit, name1), &err1); if (err1 != 0) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, err1); @@ -5891,13 +6010,13 @@ static void } /* See whether the other name already exists in the filesystem. */ - a2 = find_aino (unit, lock2, bstr (unit, name2), &err2); + a2 = find_aino(ctx, unit, lock2, bstr(ctx, unit, name2), &err2); if (a2 == a1) { /* Renaming to the same name, but possibly different case. */ - if (_tcscmp (a1->aname, bstr_cut (unit, name2)) == 0) { + if (_tcscmp (a1->aname, bstr_cut(ctx, unit, name2)) == 0) { /* Exact match -> do nothing. */ - notify_check (unit, a1); + notify_check(ctx, unit, a1); updatedirtime (a1, 1); PUT_PCK_RES1 (packet, DOS_TRUE); return; @@ -5909,7 +6028,7 @@ static void return; } - a2 = create_child_aino (unit, a2, bstr_cut (unit, name2), a1->dir); + a2 = create_child_aino (unit, a2, bstr_cut(ctx, unit, name2), a1->dir); if (a2 == 0) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, ERROR_DISK_IS_FULL); /* best we can do */ @@ -5935,8 +6054,8 @@ static void } } - notify_check (unit, a1); - notify_check (unit, a2); + notify_check(ctx, unit, a1); + notify_check(ctx, unit, a2); a2->comment = a1->comment; a1->comment = 0; a2->amigaos_mode = a1->amigaos_mode; @@ -5961,21 +6080,19 @@ static void gui_flicker_led (UNIT_LED(unit), unit->unit, 2); } -static void - action_current_volume (Unit *unit, dpacket packet) +static void action_current_volume(TrapContext *ctx, Unit *unit, dpacket *packet) { - if (filesys_isvolume(unit)) + if (filesys_isvolume(ctx, unit)) PUT_PCK_RES1 (packet, unit->volume >> 2); else PUT_PCK_RES1 (packet, 0); } -static void - action_rename_disk (Unit *unit, dpacket packet) +static void action_rename_disk(TrapContext *ctx, Unit *unit, dpacket *packet) { uaecptr name = GET_PCK_ARG1 (packet) << 2; - TRACE((_T("ACTION_RENAME_DISK(\"%s\")\n"), bstr (unit, name))); + TRACE((_T("ACTION_RENAME_DISK(\"%s\")\n"), bstr(ctx, unit, name))); if (unit->ui.readonly || unit->ui.locked) { PUT_PCK_RES1 (packet, DOS_FALSE); @@ -5985,29 +6102,26 @@ static void /* get volume name */ xfree (unit->ui.volname); - unit->ui.volname = bstr1 (name); - set_volume_name (unit, 0); + unit->ui.volname = bstr1(ctx, name); + set_volume_name(ctx, unit, 0); PUT_PCK_RES1 (packet, DOS_TRUE); } -static void - action_is_filesystem (Unit *unit, dpacket packet) +static void action_is_filesystem(TrapContext *ctx, Unit *unit, dpacket *packet) { TRACE((_T("ACTION_IS_FILESYSTEM()\n"))); PUT_PCK_RES1 (packet, DOS_TRUE); } -static void - action_flush (Unit *unit, dpacket packet) +static void action_flush(TrapContext *ctx, Unit *unit, dpacket *packet) { TRACE((_T("ACTION_FLUSH()\n"))); PUT_PCK_RES1 (packet, DOS_TRUE); flush_cache (unit, 0); } -static void - action_more_cache (Unit *unit, dpacket packet) +static void action_more_cache(TrapContext *ctx, Unit *unit, dpacket *packet) { TRACE((_T("ACTION_MORE_CACHE()\n"))); PUT_PCK_RES1 (packet, 50); /* bug but AmigaOS expects it */ @@ -6015,8 +6129,7 @@ static void flush_cache (unit, 0); } -static void - action_inhibit (Unit *unit, dpacket packet) +static void action_inhibit(TrapContext *ctx, Unit *unit, dpacket *packet) { PUT_PCK_RES1 (packet, DOS_TRUE); flush_cache (unit, 0); @@ -6024,8 +6137,7 @@ static void TRACE((_T("ACTION_INHIBIT(%d:%d)\n"), unit->unit, unit->inhibited)); } -static void - action_write_protect (Unit *unit, dpacket packet) +static void action_write_protect(TrapContext *ctx, Unit *unit, dpacket *packet) { TRACE((_T("ACTION_WRITE_PROTECT()\n"))); PUT_PCK_RES1 (packet, DOS_TRUE); @@ -6048,7 +6160,7 @@ static void /* OS4 */ -static void action_change_file_position64 (Unit *unit, dpacket packet) +static void action_change_file_position64(TrapContext *ctx, Unit *unit, dpacket *packet) { Key *k = lookup_key (unit, GET_PCK64_ARG1 (packet)); uae_s64 pos = GET_PCK64_ARG2 (packet); @@ -6103,7 +6215,7 @@ static void action_change_file_position64 (Unit *unit, dpacket packet) TRACE((_T("= oldpos %lld newpos %lld\n"), cur, k->file_pos)); } -static void action_get_file_position64 (Unit *unit, dpacket packet) +static void action_get_file_position64(TrapContext *ctx, Unit *unit, dpacket *packet) { Key *k = lookup_key (unit, GET_PCK64_ARG1 (packet)); @@ -6119,7 +6231,7 @@ static void action_get_file_position64 (Unit *unit, dpacket packet) PUT_PCK64_RES2 (packet, 0); } -static void action_change_file_size64 (Unit *unit, dpacket packet) +static void action_change_file_size64(TrapContext *ctx, Unit *unit, dpacket *packet) { Key *k, *k1; uae_s64 offset = GET_PCK64_ARG2 (packet); @@ -6171,7 +6283,7 @@ static void action_change_file_size64 (Unit *unit, dpacket packet) PUT_PCK64_RES2 (packet, 0); } -static void action_get_file_size64 (Unit *unit, dpacket packet) +static void action_get_file_size64(TrapContext *ctx, Unit *unit, dpacket *packet) { Key *k = lookup_key (unit, GET_PCK64_ARG1 (packet)); uae_s64 filesize; @@ -6197,27 +6309,27 @@ static void action_get_file_size64 (Unit *unit, dpacket packet) /* MOS */ -static void action_examine_object64(Unit *unit, dpacket packet) +static void action_examine_object64(TrapContext *ctx, Unit *unit, dpacket *packet) { uaecptr lock = GET_PCK_ARG1 (packet) << 2; uaecptr info = GET_PCK_ARG2 (packet) << 2; a_inode *aino = 0; TRACE((_T("ACTION_EXAMINE_OBJECT(0x%x,0x%x)\n"), lock, info)); - DUMPLOCK(unit, lock); + DUMPLOCK(ctx, unit, lock); if (lock != 0) - aino = aino_from_lock (unit, lock); + aino = aino_from_lock(ctx, unit, lock); if (aino == 0) aino = &unit->rootnode; - get_fileinfo (unit, packet, info, aino, true); + get_fileinfo(ctx, unit, packet, info, aino, true); } -static void action_set_file_size64(Unit *unit, dpacket packet) +static void action_set_file_size64(TrapContext *ctx, Unit *unit, dpacket *packet) { Key *k, *k1; - uae_s64 offset = get_quadp(GET_PCK_ARG2 (packet)); + uae_s64 offset = get_quadp(ctx, GET_PCK_ARG2 (packet)); int mode = (uae_s32)GET_PCK_ARG3 (packet); int whence = SEEK_CUR; @@ -6261,13 +6373,13 @@ static void action_set_file_size64(Unit *unit, dpacket packet) } PUT_PCK_RES1 (packet, DOS_TRUE); - set_quadp(GET_PCK_ARG4(packet), offset); + set_quadp(ctx, GET_PCK_ARG4(packet), offset); } -static void action_seek64(Unit *unit, dpacket packet) +static void action_seek64(TrapContext *ctx, Unit *unit, dpacket *packet) { Key *k = lookup_key(unit, GET_PCK_ARG1(packet)); - uae_s64 pos = get_quadp(GET_PCK64_ARG2(packet)); + uae_s64 pos = get_quadp(ctx, GET_PCK64_ARG2(packet)); int mode = GET_PCK_ARG3(packet); long whence = SEEK_CUR; uae_s64 res, cur; @@ -6311,17 +6423,17 @@ static void action_seek64(Unit *unit, dpacket packet) PUT_PCK_RES2 (packet, ERROR_SEEK_ERROR); } else { PUT_PCK_RES1 (packet, TRUE); - set_quadp(GET_PCK_ARG3(packet), cur); + set_quadp(ctx, GET_PCK_ARG3(packet), cur); k->file_pos = key_seek(k, 0, SEEK_CUR); } TRACE((_T("= oldpos %lld newpos %lld\n"), cur, k->file_pos)); } -static int action_lock_record64(Unit *unit, dpacket packet, uae_u32 msg) +static int action_lock_record64(TrapContext *ctx, Unit *unit, dpacket *packet, uae_u32 msg) { Key *k = lookup_key(unit, GET_PCK_ARG1(packet)); - uae_u64 pos = get_quadp(GET_PCK_ARG2(packet)); - uae_u64 len = get_quadp(GET_PCK_ARG3(packet)); + uae_u64 pos = get_quadp(ctx, GET_PCK_ARG2(packet)); + uae_u64 len = get_quadp(ctx, GET_PCK_ARG3(packet)); uae_u32 mode = GET_PCK_ARG4(packet); uae_u32 timeout = GET_PCK_ARG5(packet); @@ -6357,7 +6469,7 @@ static int action_lock_record64(Unit *unit, dpacket packet, uae_u32 msg) return 1; } - struct lockrecord *lr = new_record (GET_PCK_ARG1(packet), pos, len, mode, timeout, 0); + struct lockrecord *lr = new_record(packet, pos, len, mode, timeout, 0); if (k->record) { lr->next = k->record; k->record = lr; @@ -6369,11 +6481,11 @@ static int action_lock_record64(Unit *unit, dpacket packet, uae_u32 msg) return 1; } -static void action_free_record64(Unit *unit, dpacket packet) +static void action_free_record64(TrapContext *ctx, Unit *unit, dpacket *packet) { Key *k = lookup_key(unit, GET_PCK_ARG1(packet)); - uae_u64 pos = get_quadp(GET_PCK_ARG2(packet)); - uae_u64 len = get_quadp(GET_PCK_ARG3 (packet)); + uae_u64 pos = get_quadp(ctx, GET_PCK_ARG2(packet)); + uae_u64 len = get_quadp(ctx, GET_PCK_ARG3 (packet)); write_log (_T("action_free_record('%s',%lld,%lld)\n"), k ? k->aino->nname : _T("null"), pos, len); @@ -6392,7 +6504,7 @@ static void action_free_record64(Unit *unit, dpacket packet) k->record = lr->next; xfree (lr); write_log (_T("->OK\n")); - record_check_waiting (unit); + record_check_waiting(ctx, unit); PUT_PCK_RES1 (packet, DOS_TRUE); return; } @@ -6406,11 +6518,152 @@ static void action_free_record64(Unit *unit, dpacket packet) * know whether AmigaOS takes care of that, but this does. */ static uae_sem_t singlethread_int_sem; -static uae_u32 REGPARAM2 exter_int_helper (TrapContext *context) +#if 1 + + +static uae_u32 REGPARAM2 exter_int_helper(TrapContext *ctx) { UnitInfo *uip = mountinfo.ui; uaecptr port; - int n = m68k_dreg (regs, 0); + int n = trap_get_dreg(ctx, 0); + static int unit_no; + + if (n == 1) { + /* Release a message_lock. This is called as soon as the message is + * received by the assembly code. We use the opportunity to check + * whether we have some locks that we can give back to the assembler + * code. + * Note that this is called from the main loop, unlike the other cases + * in this switch statement which are called from the interrupt handler. + */ +#ifdef UAE_FILESYS_THREADS + { + Unit *unit = find_unit(trap_get_areg(ctx, 5)); + uaecptr msg = trap_get_areg(ctx, 4); + unit->cmds_complete = unit->cmds_acked; + while (comm_pipe_has_data(unit->ui.back_pipe)) { + uaecptr locks, lockend; + int cnt = 0; + locks = read_comm_pipe_int_blocking(unit->ui.back_pipe); + lockend = locks; + while (trap_get_long(ctx, lockend) != 0) { + if (trap_get_long(ctx, lockend) == lockend) { + write_log(_T("filesystem lock queue corrupted!\n")); + break; + } + lockend = trap_get_long(ctx, lockend); + cnt++; + } + TRACE3((_T("message_lock: %d %x %x %x\n"), cnt, locks, lockend, trap_get_areg(ctx, 3))); + trap_put_long(ctx, lockend, trap_get_long(ctx, trap_get_areg(ctx, 3))); + trap_put_long(ctx, trap_get_areg(ctx, 3), locks); + } + } +#else + write_log(_T("exter_int_helper should not be called with arg 1!\n")); +#endif + return 0; + } + + if (n == 10) { + if (uae_sem_trywait(&singlethread_int_sem) != 0) { + /* Pretend it isn't for us. We might get it again later. */ + do_uae_int_requested(); + return 0; + } + filesys_in_interrupt++; + unit_no = 0; + } + if (n >= 10) { + /* Find work that needs to be done: + * return d0 = 0: none + * d0 = 1: PutMsg(), port in a0, message in a1 + * d0 = 2: Signal(), task in a1, signal set in d1 + * d0 = 3: ReplyMsg(), message in a1 + * d0 = 4: Cause(), interrupt in a1 + * d0 = 5: Send FileNofication message, port in a0, notifystruct in a1 + */ + +#ifdef SUPPORT_THREADS + /* First, check signals/messages */ + while (comm_pipe_has_data(&native2amiga_pending)) { + int cmd = read_comm_pipe_int_blocking(&native2amiga_pending); + switch (cmd) { + case 0: /* Signal() */ + trap_set_areg(ctx, 1, read_comm_pipe_u32_blocking(&native2amiga_pending)); + trap_set_dreg(ctx, 1, read_comm_pipe_u32_blocking(&native2amiga_pending)); + return 2; + + case 1: /* PutMsg() */ + trap_set_areg(ctx, 0, read_comm_pipe_u32_blocking(&native2amiga_pending)); + trap_set_areg(ctx, 1, read_comm_pipe_u32_blocking(&native2amiga_pending)); + return 1; + + case 2: /* ReplyMsg() */ + trap_set_areg(ctx, 1, read_comm_pipe_u32_blocking(&native2amiga_pending)); + return 3; + + case 3: /* Cause() */ + trap_set_areg(ctx, 1, read_comm_pipe_u32_blocking(&native2amiga_pending)); + return 4; + + case 4: /* NotifyHack() */ + trap_set_areg(ctx, 0, read_comm_pipe_u32_blocking(&native2amiga_pending)); + trap_set_areg(ctx, 1, read_comm_pipe_u32_blocking(&native2amiga_pending)); + return 5; + + case 5: /* CallLib() */ + { + int num = read_comm_pipe_u32_blocking(&native2amiga_pending); + return 6; + } + + default: + write_log(_T("exter_int_helper: unknown native action %X\n"), cmd); + break; + } + } +#endif + + /* Find some unit that needs a message sent, and return its port, + * or zero if all are done. + * Take care not to dereference self for units that didn't have their + * startup packet sent. */ + for (;;) { + if (unit_no >= MAX_FILESYSTEM_UNITS) + goto end; + + if (uip[unit_no].open > 0 && uip[unit_no].self != 0 + && uip[unit_no].self->cmds_acked == uip[unit_no].self->cmds_complete + && uip[unit_no].self->cmds_acked != uip[unit_no].self->cmds_sent) + break; + unit_no++; + } + uip[unit_no].self->cmds_acked = uip[unit_no].self->cmds_sent; + port = uip[unit_no].self->port; + if (port) { + trap_set_areg(ctx, 0, port); + trap_set_areg(ctx, 1, find_unit(port)->dummy_message); + unit_no++; + return 1; + } + +end: + /* Exit the interrupt, and release the single-threading lock. */ + filesys_in_interrupt--; + uae_sem_post(&singlethread_int_sem); + + } + return 0; +} + +#else + +static uae_u32 REGPARAM2 exter_int_helper(TrapContext *ctx) +{ + UnitInfo *uip = mountinfo.ui; + uaecptr port; + int n = trap_get_dreg (ctx, 0); static int unit_no; switch (n) { @@ -6424,7 +6677,7 @@ static uae_u32 REGPARAM2 exter_int_helper (TrapContext *context) * That way, we can get too many interrupts, but never not * enough. */ filesys_in_interrupt++; - uae_int_requested &= ~1; + atomic_and(&uae_int_requested, ~1); unit_no = 0; return 1; } @@ -6439,25 +6692,25 @@ static uae_u32 REGPARAM2 exter_int_helper (TrapContext *context) */ #ifdef UAE_FILESYS_THREADS { - Unit *unit = find_unit (m68k_areg (regs, 5)); - uaecptr msg = m68k_areg (regs, 4); + Unit *unit = find_unit (trap_get_areg (ctx, 5)); + uaecptr msg = trap_get_areg (ctx, 4); unit->cmds_complete = unit->cmds_acked; while (comm_pipe_has_data (unit->ui.back_pipe)) { uaecptr locks, lockend; int cnt = 0; locks = read_comm_pipe_int_blocking (unit->ui.back_pipe); lockend = locks; - while (get_long (lockend) != 0) { - if (get_long (lockend) == lockend) { + while (trap_get_long(ctx, lockend) != 0) { + if (trap_get_long(ctx, lockend) == lockend) { write_log (_T("filesystem lock queue corrupted!\n")); break; } - lockend = get_long (lockend); + lockend = trap_get_long(ctx, lockend); cnt++; } - TRACE3((_T("message_lock: %d %x %x %x\n"), cnt, locks, lockend, m68k_areg (regs, 3))); - put_long (lockend, get_long (m68k_areg (regs, 3))); - put_long (m68k_areg (regs, 3), locks); + TRACE3((_T("message_lock: %d %x %x %x\n"), cnt, locks, lockend, trap_get_areg (ctx, 3))); + trap_put_long(ctx, lockend, trap_get_long(ctx, trap_get_areg (ctx, 3))); + trap_put_long(ctx, trap_get_areg (ctx, 3), locks); } } #else @@ -6480,26 +6733,26 @@ static uae_u32 REGPARAM2 exter_int_helper (TrapContext *context) int cmd = read_comm_pipe_int_blocking (&native2amiga_pending); switch (cmd) { case 0: /* Signal() */ - m68k_areg (regs, 1) = read_comm_pipe_u32_blocking (&native2amiga_pending); - m68k_dreg (regs, 1) = read_comm_pipe_u32_blocking (&native2amiga_pending); + trap_set_areg(ctx, 1, read_comm_pipe_u32_blocking (&native2amiga_pending)); + trap_set_dreg(ctx, 1, read_comm_pipe_u32_blocking (&native2amiga_pending)); return 2; case 1: /* PutMsg() */ - m68k_areg (regs, 0) = read_comm_pipe_u32_blocking (&native2amiga_pending); - m68k_areg (regs, 1) = read_comm_pipe_u32_blocking (&native2amiga_pending); + trap_set_areg(ctx, 0, read_comm_pipe_u32_blocking(&native2amiga_pending)); + trap_set_areg(ctx, 1, read_comm_pipe_u32_blocking(&native2amiga_pending)); return 1; case 2: /* ReplyMsg() */ - m68k_areg (regs, 1) = read_comm_pipe_u32_blocking (&native2amiga_pending); + trap_set_areg(ctx, 1, read_comm_pipe_u32_blocking(&native2amiga_pending)); return 3; case 3: /* Cause() */ - m68k_areg (regs, 1) = read_comm_pipe_u32_blocking (&native2amiga_pending); + trap_set_areg(ctx, 1, read_comm_pipe_u32_blocking(&native2amiga_pending)); return 4; case 4: /* NotifyHack() */ - m68k_areg (regs, 0) = read_comm_pipe_u32_blocking (&native2amiga_pending); - m68k_areg (regs, 1) = read_comm_pipe_u32_blocking (&native2amiga_pending); + trap_set_areg(ctx, 0, read_comm_pipe_u32_blocking(&native2amiga_pending)); + trap_set_areg(ctx, 1, read_comm_pipe_u32_blocking(&native2amiga_pending)); return 5; default: @@ -6526,8 +6779,8 @@ static uae_u32 REGPARAM2 exter_int_helper (TrapContext *context) uip[unit_no].self->cmds_acked = uip[unit_no].self->cmds_sent; port = uip[unit_no].self->port; if (port) { - m68k_areg (regs, 0) = port; - m68k_areg (regs, 1) = find_unit (port)->dummy_message; + trap_set_areg (ctx, 0, port); + trap_set_areg (ctx, 1, find_unit (port)->dummy_message); unit_no++; return 1; } @@ -6548,13 +6801,15 @@ static uae_u32 REGPARAM2 exter_int_helper (TrapContext *context) return 0; } -static int handle_packet (Unit *unit, dpacket pck, uae_u32 msg) +#endif + +static int handle_packet(TrapContext *ctx, Unit *unit, dpacket *pck, uae_u32 msg, int isvolume) { uae_s32 type = GET_PCK_TYPE (pck); PUT_PCK_RES2 (pck, 0); TRACE((_T("unit=%p packet=%d\n"), unit, type)); - if (unit->inhibited && filesys_isvolume (unit) + if (unit->inhibited && isvolume && type != ACTION_INHIBIT && type != ACTION_MORE_CACHE && type != ACTION_DISK_INFO) { PUT_PCK_RES1 (pck, DOS_FALSE); @@ -6564,73 +6819,73 @@ static int handle_packet (Unit *unit, dpacket pck, uae_u32 msg) if (type != ACTION_INHIBIT && type != ACTION_CURRENT_VOLUME && type != ACTION_IS_FILESYSTEM && type != ACTION_MORE_CACHE && type != ACTION_WRITE_PROTECT && type != ACTION_DISK_INFO - && !filesys_isvolume (unit)) { + && !isvolume) { PUT_PCK_RES1 (pck, DOS_FALSE); PUT_PCK_RES2 (pck, unit->ui.unknown_media ? ERROR_NOT_A_DOS_DISK : ERROR_NO_DISK); return 1; } switch (type) { - case ACTION_LOCATE_OBJECT: action_lock (unit, pck); break; - case ACTION_FREE_LOCK: action_free_lock (unit, pck); break; - case ACTION_COPY_DIR: action_dup_lock (unit, pck); break; - case ACTION_DISK_INFO: action_disk_info (unit, pck); break; - case ACTION_INFO: action_info (unit, pck); break; - case ACTION_EXAMINE_OBJECT: action_examine_object (unit, pck); break; - case ACTION_EXAMINE_NEXT: action_examine_next (unit, pck, false); break; - case ACTION_FIND_INPUT: action_find_input (unit, pck); break; - case ACTION_FIND_WRITE: action_find_write (unit, pck); break; - case ACTION_FIND_OUTPUT: action_find_output (unit, pck); break; - case ACTION_END: action_end (unit, pck); break; - case ACTION_READ: action_read (unit, pck); break; - case ACTION_WRITE: action_write (unit, pck); break; - case ACTION_SEEK: action_seek (unit, pck); break; - case ACTION_SET_PROTECT: action_set_protect (unit, pck); break; - case ACTION_SET_COMMENT: action_set_comment (unit, pck); break; - case ACTION_SAME_LOCK: action_same_lock (unit, pck); break; - case ACTION_PARENT: action_parent (unit, pck); break; - case ACTION_CREATE_DIR: action_create_dir (unit, pck); break; - case ACTION_DELETE_OBJECT: action_delete_object (unit, pck); break; - case ACTION_RENAME_OBJECT: action_rename_object (unit, pck); break; - case ACTION_SET_DATE: action_set_date (unit, pck); break; - case ACTION_CURRENT_VOLUME: action_current_volume (unit, pck); break; - case ACTION_RENAME_DISK: action_rename_disk (unit, pck); break; - case ACTION_IS_FILESYSTEM: action_is_filesystem (unit, pck); break; - case ACTION_FLUSH: action_flush (unit, pck); break; - case ACTION_MORE_CACHE: action_more_cache (unit, pck); break; - case ACTION_INHIBIT: action_inhibit (unit, pck); break; - case ACTION_WRITE_PROTECT: action_write_protect (unit, pck); break; + case ACTION_LOCATE_OBJECT: action_lock (ctx, unit, pck); break; + case ACTION_FREE_LOCK: action_free_lock (ctx, unit, pck); break; + case ACTION_COPY_DIR: action_dup_lock (ctx, unit, pck); break; + case ACTION_DISK_INFO: action_disk_info (ctx, unit, pck); break; + case ACTION_INFO: action_info (ctx, unit, pck); break; + case ACTION_EXAMINE_OBJECT: action_examine_object (ctx, unit, pck); break; + case ACTION_EXAMINE_NEXT: action_examine_next (ctx, unit, pck, false); break; + case ACTION_FIND_INPUT: action_find_input (ctx, unit, pck); break; + case ACTION_FIND_WRITE: action_find_write (ctx, unit, pck); break; + case ACTION_FIND_OUTPUT: action_find_output (ctx, unit, pck); break; + case ACTION_END: action_end (ctx, unit, pck); break; + case ACTION_READ: action_read (ctx, unit, pck); break; + case ACTION_WRITE: action_write (ctx, unit, pck); break; + case ACTION_SEEK: action_seek (ctx, unit, pck); break; + case ACTION_SET_PROTECT: action_set_protect (ctx, unit, pck); break; + case ACTION_SET_COMMENT: action_set_comment (ctx, unit, pck); break; + case ACTION_SAME_LOCK: action_same_lock (ctx, unit, pck); break; + case ACTION_PARENT: action_parent (ctx, unit, pck); break; + case ACTION_CREATE_DIR: action_create_dir (ctx, unit, pck); break; + case ACTION_DELETE_OBJECT: action_delete_object (ctx, unit, pck); break; + case ACTION_RENAME_OBJECT: action_rename_object (ctx, unit, pck); break; + case ACTION_SET_DATE: action_set_date (ctx, unit, pck); break; + case ACTION_CURRENT_VOLUME: action_current_volume (ctx, unit, pck); break; + case ACTION_RENAME_DISK: action_rename_disk (ctx, unit, pck); break; + case ACTION_IS_FILESYSTEM: action_is_filesystem (ctx, unit, pck); break; + case ACTION_FLUSH: action_flush (ctx, unit, pck); break; + case ACTION_MORE_CACHE: action_more_cache (ctx, unit, pck); break; + case ACTION_INHIBIT: action_inhibit (ctx, unit, pck); break; + case ACTION_WRITE_PROTECT: action_write_protect (ctx, unit, pck); break; /* 2.0+ packet types */ - case ACTION_SET_FILE_SIZE: action_set_file_size (unit, pck); break; - case ACTION_EXAMINE_FH: action_examine_fh (unit, pck, false); break; - case ACTION_FH_FROM_LOCK: action_fh_from_lock (unit, pck); break; - case ACTION_COPY_DIR_FH: action_lock_from_fh (unit, pck); break; - case ACTION_CHANGE_MODE: action_change_mode (unit, pck); break; - case ACTION_PARENT_FH: action_parent_fh (unit, pck); break; - case ACTION_ADD_NOTIFY: action_add_notify (unit, pck); break; - case ACTION_REMOVE_NOTIFY: action_remove_notify (unit, pck); break; - case ACTION_EXAMINE_ALL: return action_examine_all (unit, pck); - case ACTION_EXAMINE_ALL_END: return action_examine_all_end (unit, pck); - case ACTION_LOCK_RECORD: return action_lock_record (unit, pck, msg); break; - case ACTION_FREE_RECORD: action_free_record (unit, pck); break; - case ACTION_READ_LINK: action_read_link (unit, pck); break; - case ACTION_MAKE_LINK: action_make_link (unit, pck); break; + case ACTION_SET_FILE_SIZE: action_set_file_size (ctx, unit, pck); break; + case ACTION_EXAMINE_FH: action_examine_fh (ctx, unit, pck, false); break; + case ACTION_FH_FROM_LOCK: action_fh_from_lock (ctx, unit, pck); break; + case ACTION_COPY_DIR_FH: action_lock_from_fh (ctx, unit, pck); break; + case ACTION_CHANGE_MODE: action_change_mode (ctx, unit, pck); break; + case ACTION_PARENT_FH: action_parent_fh (ctx, unit, pck); break; + case ACTION_ADD_NOTIFY: action_add_notify (ctx, unit, pck); break; + case ACTION_REMOVE_NOTIFY: action_remove_notify (ctx, unit, pck); break; + case ACTION_EXAMINE_ALL: return action_examine_all (ctx, unit, pck); + case ACTION_EXAMINE_ALL_END: return action_examine_all_end (ctx, unit, pck); + case ACTION_LOCK_RECORD: return action_lock_record (ctx, unit, pck, msg); break; + case ACTION_FREE_RECORD: action_free_record (ctx, unit, pck); break; + case ACTION_READ_LINK: action_read_link (ctx, unit, pck); break; + case ACTION_MAKE_LINK: action_make_link (ctx, unit, pck); break; /* OS4 packet types */ - case ACTION_CHANGE_FILE_POSITION64: action_change_file_position64 (unit, pck); break; - case ACTION_GET_FILE_POSITION64: action_get_file_position64 (unit, pck); break; - case ACTION_CHANGE_FILE_SIZE64: action_change_file_size64 (unit, pck); break; - case ACTION_GET_FILE_SIZE64: action_get_file_size64 (unit, pck); break; + case ACTION_CHANGE_FILE_POSITION64: action_change_file_position64 (ctx, unit, pck); break; + case ACTION_GET_FILE_POSITION64: action_get_file_position64 (ctx, unit, pck); break; + case ACTION_CHANGE_FILE_SIZE64: action_change_file_size64 (ctx, unit, pck); break; + case ACTION_GET_FILE_SIZE64: action_get_file_size64 (ctx, unit, pck); break; /* MOS packet types */ - case ACTION_SEEK64: action_seek64(unit, pck); break; - case ACTION_SET_FILE_SIZE64: action_set_file_size64(unit, pck); break; - case ACTION_EXAMINE_OBJECT64: action_examine_object64(unit, pck); break; - case ACTION_EXAMINE_NEXT64: action_examine_next(unit, pck, true); break; - case ACTION_EXAMINE_FH64: action_examine_fh(unit, pck, true); break; - case ACTION_LOCK_RECORD64: return action_lock_record64(unit, pck, msg); break; - case ACTION_FREE_RECORD64: action_free_record64(unit, pck); break; + case ACTION_SEEK64: action_seek64(ctx, unit, pck); break; + case ACTION_SET_FILE_SIZE64: action_set_file_size64(ctx, unit, pck); break; + case ACTION_EXAMINE_OBJECT64: action_examine_object64(ctx, unit, pck); break; + case ACTION_EXAMINE_NEXT64: action_examine_next(ctx, unit, pck, true); break; + case ACTION_EXAMINE_FH64: action_examine_fh(ctx, unit, pck, true); break; + case ACTION_LOCK_RECORD64: return action_lock_record64(ctx, unit, pck, msg); break; + case ACTION_FREE_RECORD64: action_free_record64(ctx, unit, pck); break; /* unsupported packets */ case ACTION_FORMAT: @@ -6647,15 +6902,18 @@ static int handle_packet (Unit *unit, dpacket pck, uae_u32 msg) static int filesys_iteration(UnitInfo *ui) { - dpacket pck; + uaecptr pck; uaecptr msg; uae_u32 morelocks; + TrapContext *ctx; - pck = read_comm_pipe_u32_blocking (ui->unit_pipe); - msg = read_comm_pipe_u32_blocking (ui->unit_pipe); - morelocks = (uae_u32)read_comm_pipe_int_blocking (ui->unit_pipe); + ctx = (TrapContext*)read_comm_pipe_pvoid_blocking(ui->unit_pipe); + pck = read_comm_pipe_u32_blocking(ui->unit_pipe); + msg = read_comm_pipe_u32_blocking(ui->unit_pipe); + morelocks = (uae_u32)read_comm_pipe_int_blocking(ui->unit_pipe); if (ui->reset_state == FS_GO_DOWN) { + trap_background_set_complete(ctx); if (pck != 0) return 1; /* Death message received. */ @@ -6664,25 +6922,68 @@ static int filesys_iteration(UnitInfo *ui) return 0; } - put_long (get_long (morelocks), get_long (ui->self->locklist)); - put_long (ui->self->locklist, morelocks); - int ret = handle_packet (ui->self, pck, msg); + dpacket packet; + readdpacket(ctx, &packet, pck); + + trapmd md[] = { + { TRAPCMD_GET_LONG, { morelocks }, 2, 0 }, + { TRAPCMD_GET_LONG, { ui->self->locklist }, 2, 1 }, + { TRAPCMD_PUT_LONG }, + { TRAPCMD_PUT_LONG, { ui->self->locklist, morelocks }}, + { ui->self->volume ? TRAPCMD_GET_BYTE : TRAPCMD_NOP, { ui->self->volume + 44 }}, + }; + trap_multi(ctx, md, sizeof md / sizeof(struct trapmd)); + + int isvolume = 0; + if (ui->self->volume) { + isvolume = md[4].params[0] || ui->self->ui.unknown_media; + } + +#if 0 + trap_put_long(ctx, trap_get_long(ctx, morelocks), trap_get_long(ctx, ui->self->locklist)); + trap_put_long(ctx, ui->self->locklist, morelocks); +#endif + + int ret = handle_packet(ctx, ui->self, &packet, msg, isvolume); if (!ret) { - PUT_PCK_RES1 (pck, DOS_FALSE); - PUT_PCK_RES2 (pck, ERROR_ACTION_NOT_KNOWN); + PUT_PCK_RES1 (&packet, DOS_FALSE); + PUT_PCK_RES2 (&packet, ERROR_ACTION_NOT_KNOWN); } + writedpacket(ctx, &packet); + + trapmd md2[] = { + { TRAPCMD_PUT_LONG, { msg + 4, 0xffffffff } }, + { TRAPCMD_GET_LONG, { ui->self->locklist } }, + { TRAPCMD_PUT_LONG, { ui->self->locklist, 0 } } + }; + struct trapmd *mdp = &md2[1]; + int mdcnt = 2; + if (ret >= 0) { + mdp = &md2[0]; + mdcnt = 3; /* Mark the packet as processed for the list scan in the assembly code. */ - put_long (msg + 4, 0xffffffff); + //trap_put_long(ctx, msg + 4, 0xffffffff); } /* Acquire the message lock, so that we know we can safely send the message. */ ui->self->cmds_sent++; - /* The message is sent by our interrupt handler, so make sure an interrupt happens. */ - do_uae_int_requested (); /* Send back the locks. */ - if (get_long (ui->self->locklist) != 0) - write_comm_pipe_int (ui->back_pipe, (int)(get_long (ui->self->locklist)), 0); - put_long (ui->self->locklist, 0); + + trap_multi(ctx, mdp, mdcnt); + + if (md2[1].params[1] != 0) + write_comm_pipe_int(ui->back_pipe, (int)md2[1].params[1], 0); + + /* The message is sent by our interrupt handler, so make sure an interrupt happens. */ + do_uae_int_requested(); +#if 0 + uae_u32 v = trap_get_long(ctx, ui->self->locklist); + if (v != 0) + write_comm_pipe_int (ui->back_pipe, (int)v, 0); + trap_put_long(ctx, ui->self->locklist, 0); +#endif + + trap_background_set_complete(ctx); return 1; } @@ -6693,7 +6994,7 @@ static void *filesys_thread (void *unit_v) uae_set_thread_priority (NULL, 1); for (;;) { - if (!filesys_iteration (ui)) { + if (!filesys_iteration(ui)) { return 0; } } @@ -6702,17 +7003,17 @@ static void *filesys_thread (void *unit_v) #endif /* Talk about spaghetti code... */ -static uae_u32 REGPARAM2 filesys_handler (TrapContext *context) +static uae_u32 REGPARAM2 filesys_handler(TrapContext *ctx) { - Unit *unit = find_unit (m68k_areg (regs, 5)); - uaecptr packet_addr = m68k_dreg (regs, 3); - uaecptr message_addr = m68k_areg (regs, 4); - if (! valid_address (packet_addr, 36) || ! valid_address (message_addr, 14)) { + Unit *unit = find_unit(trap_get_areg(ctx, 5)); + uaecptr packet_addr = trap_get_dreg(ctx, 3); + uaecptr message_addr = trap_get_areg(ctx, 4); + + if (!trap_valid_address(ctx, packet_addr, 36) || !trap_valid_address(ctx, message_addr, 14)) { write_log (_T("FILESYS: Bad address %x/%x passed for packet.\n"), packet_addr, message_addr); goto error2; } - put_long (message_addr + 4, 0xffffffff); if (!unit || !unit->volume) { write_log (_T("FILESYS: was not initialized.\n")); goto error; @@ -6723,28 +7024,63 @@ static uae_u32 REGPARAM2 filesys_handler (TrapContext *context) if (!unit->ui.unit_pipe) goto error; /* Get two more locks and hand them over to the other thread. */ - morelocks = get_long (m68k_areg (regs, 3)); - put_long (m68k_areg (regs, 3), get_long (get_long (morelocks))); - put_long (get_long (morelocks), 0); + +#if TRAPMD + struct trapmd md[] = { + // morelocks = trap_get_long(ctx, trap_get_areg(ctx, 3)); + /* 0 */ { TRAPCMD_GET_LONG, { trap_get_areg(ctx, 3) }, 1, 0 }, + // morelocksptr = trap_get_long(ctx, morelocks) + /* 1 */ { TRAPCMD_GET_LONG, { 0 } }, + // result 1 to index 4 + /* 2 */ { TRAPCMD_NOP, { 0 }, 4, 0 }, + // result 1 to index 6 + /* 3 */ { TRAPCMD_NOP, { 0 }, 6, 0 }, + // trap_get_long(ctx, morelocksptr) + /* 4 */ { TRAPCMD_GET_LONG, { 0 }, 5, 1 }, + // trap_put_long(ctx, trap_get_areg(ctx, 3), result 4 + /* 5 */ { TRAPCMD_PUT_LONG, { trap_get_areg(ctx, 3) } }, + // trap_put_long(ctx, morelocksptr, 0); + /* 6 */ { TRAPCMD_PUT_LONG, { 0, 0 } }, + // trap_put_long(ctx, message_addr + 4, 0); + /* 7 */ { TRAPCMD_PUT_LONG, { message_addr + 4, 0 } } + }; + trap_multi(ctx, md, sizeof md / sizeof(struct trapmd)); + morelocks = md[0].params[0]; +#else + uae_u32 morelocksptr; + morelocks = trap_get_long(ctx, trap_get_areg(ctx, 3)); + morelocksptr = trap_get_long(ctx, morelocks); + trap_put_long(ctx, trap_get_areg(ctx, 3), trap_get_long(ctx, morelocksptr)); + trap_put_long(ctx, morelocksptr, 0); /* The packet wasn't processed yet. */ - put_long (message_addr + 4, 0); - write_comm_pipe_u32 (unit->ui.unit_pipe, packet_addr, 0); - write_comm_pipe_u32 (unit->ui.unit_pipe, message_addr, 0); - write_comm_pipe_int (unit->ui.unit_pipe, (int)morelocks, 1); + trap_put_long(ctx, message_addr + 4, 0); +#endif + + trap_set_background(ctx); + write_comm_pipe_pvoid(unit->ui.unit_pipe, ctx, 0); + write_comm_pipe_u32(unit->ui.unit_pipe, packet_addr, 0); + write_comm_pipe_u32(unit->ui.unit_pipe, message_addr, 0); + write_comm_pipe_int(unit->ui.unit_pipe, (int)morelocks, 1); /* Don't reply yet. */ return 1; } #endif - if (! handle_packet (unit, packet_addr, 0)) { + dpacket packet; + readdpacket(ctx, &packet, packet_addr); + + if (! handle_packet(ctx, unit, &packet, 0, filesys_isvolume(ctx, unit))) { error: - PUT_PCK_RES1 (packet_addr, DOS_FALSE); - PUT_PCK_RES2 (packet_addr, ERROR_ACTION_NOT_KNOWN); + PUT_PCK_RES1 (&packet, DOS_FALSE); + PUT_PCK_RES2 (&packet, ERROR_ACTION_NOT_KNOWN); } - TRACE((_T("reply: %8x, %d\n"), GET_PCK_RES1 (packet_addr), GET_PCK_RES2 (packet_addr))); + TRACE((_T("reply: %8x, %d\n"), GET_PCK_RES1(&packet), GET_PCK_RES2(&packet))); + + writedpacket(ctx, &packet); error2: + trap_put_long(ctx, message_addr + 4, 0xffffffff); return 0; } @@ -6817,6 +7153,7 @@ void filesys_reset (void) { if (isrestore ()) return; + filesystem_state = 0; load_injected_icons(); filesys_reset2 (); initialize_mountinfo (); @@ -6825,7 +7162,6 @@ void filesys_reset (void) static void filesys_prepare_reset2 (void) { UnitInfo *uip; - // Unit *u; int i; uip = mountinfo.ui; @@ -6835,9 +7171,10 @@ static void filesys_prepare_reset2 (void) uae_sem_init (&uip[i].reset_sync_sem, 0, 0); uip[i].reset_state = FS_GO_DOWN; /* send death message */ - write_comm_pipe_int (uip[i].unit_pipe, 0, 0); - write_comm_pipe_int (uip[i].unit_pipe, 0, 0); - write_comm_pipe_int (uip[i].unit_pipe, 0, 1); + write_comm_pipe_pvoid(uip[i].unit_pipe, NULL, 0); + write_comm_pipe_int(uip[i].unit_pipe, 0, 0); + write_comm_pipe_int(uip[i].unit_pipe, 0, 0); + write_comm_pipe_int(uip[i].unit_pipe, 0, 1); uae_sem_wait (&uip[i].reset_sync_sem); uae_end_thread (&uip[i].tid); } @@ -6845,6 +7182,7 @@ static void filesys_prepare_reset2 (void) #endif filesys_free_handles(); #if 0 + Unit *u; u = units; while (u != 0) { free_all_ainos (u, &u->rootnode); @@ -6890,66 +7228,66 @@ static const uae_u8 bootblock_ofs[] = { 0x4e,0x75,0x70,0xff,0x60,0xfa,0x64,0x6f,0x73,0x2e,0x6c,0x69,0x62,0x72,0x61,0x72, 0x79 }; -static uae_u32 REGPARAM2 filesys_putmsg_return(TrapContext *context) +static uae_u32 REGPARAM2 filesys_putmsg_return(TrapContext *ctx) { - uaecptr message = m68k_areg(regs, 1); - uaecptr dospacket = get_long(message + 10); + uaecptr message = trap_get_areg(ctx, 1); + uaecptr dospacket = trap_get_long(ctx, message + 10); UnitInfo *uip = mountinfo.ui; if (!ks12hack_deviceproc && uip[0].parmpacket) - ks12hack_deviceproc = get_long(uip[0].parmpacket + PP_DEVICEPROC); + ks12hack_deviceproc = trap_get_long(ctx, uip[0].parmpacket + PP_DEVICEPROC); if (ks12hack_deviceproc) { uae_u32 port = ks12hack_deviceproc; if (port) { - uaecptr proc = get_long(get_long(4) + 276); // ThisTask - put_long(proc + 168, port); // pr_FileSystemTask - m68k_areg(regs, 0) = port; + uaecptr proc = trap_get_long(ctx, trap_get_long(ctx, 4) + 276); // ThisTask + trap_put_long(ctx, proc + 168, port); // pr_FileSystemTask + trap_set_areg(ctx, 0, port); write_log(_T("Pre-KS 1.3 automount hack: patch boot handler process. DP=%08x Proc %08x pr_FileSystemTask=%08x.\n"), dospacket, proc, port); } } - return m68k_dreg(regs, 0); + return trap_get_dreg(ctx, 0); } -static uae_u32 REGPARAM2 filesys_putmsg(TrapContext *context) +static uae_u32 REGPARAM2 filesys_putmsg(TrapContext *ctx) { - m68k_areg(regs, 7) -= 4; - put_long(m68k_areg(regs, 7), get_long(ROM_filesys_putmsg_original)); + trap_set_areg(ctx, 7, trap_get_areg(ctx, 7) - 4); + trap_put_long(ctx, trap_get_areg(ctx, 7), trap_get_long(ctx, ROM_filesys_putmsg_original)); if (putmsg_hack_state) { - uaecptr message = m68k_areg(regs, 1); - uaecptr dospacket = get_long(message + 10); - if (dospacket && !(dospacket & 3) && valid_address(dospacket, 48)) { - int type = get_long(dospacket + 8); + uaecptr message = trap_get_areg(ctx, 1); + uaecptr dospacket = trap_get_long(ctx, message + 10); + if (dospacket && !(dospacket & 3) && trap_valid_address(ctx, dospacket, 48)) { + int type = trap_get_long(ctx, dospacket + 8); // write_log(_T("Port=%08x Msg=%08x DP=%08x dp_Link=%08x dp_Port=%08x dp_Type=%d\n"), // m68k_areg(regs, 0), m68k_areg(regs, 1), dospacket, get_long(dospacket), get_long(dospacket + 4), type); if (type == ACTION_LOCATE_OBJECT) { write_log(_T("Pre-KS 1.3 automount hack: init drives.\n")); putmsg_hack_state = 0; if (putmsg_hack_filesystemtask) { - m68k_areg(regs, 7) -= 4; - put_long(m68k_areg(regs, 7), ROM_filesys_putmsg_return); + trap_set_areg(ctx, 7, trap_get_areg(ctx, 7) - 4); + trap_put_long(ctx, trap_get_areg(ctx, 7), ROM_filesys_putmsg_return); } - m68k_areg(regs, 7) -= 4; - put_long(m68k_areg(regs, 7), filesys_initcode); - m68k_areg(regs, 7) -= 4; - put_long(m68k_areg(regs, 7), ROM_filesys_hack_remove); - return m68k_dreg(regs, 0); + trap_set_areg(ctx, 7, trap_get_areg(ctx, 7) - 4); + trap_put_long(ctx, trap_get_areg(ctx, 7), filesys_initcode); + trap_set_areg(ctx, 7, trap_get_areg(ctx, 7) - 4); + trap_put_long(ctx, trap_get_areg(ctx, 7), ROM_filesys_hack_remove); + return trap_get_dreg(ctx, 0); } } } - return m68k_dreg(regs, 0); + return trap_get_dreg(ctx, 0); } -static uae_u32 REGPARAM2 filesys_doio(TrapContext *context) +static uae_u32 REGPARAM2 filesys_doio(TrapContext *ctx) { - uaecptr ioreq = m68k_areg(regs, 1); - uaecptr unit = get_long(ioreq + 24); // io_Unit - if (trackdisk_hack_state && unit && valid_address(unit, 14)) { - uaecptr name = get_long(unit + 10); // ln_Name - if (name && valid_address(name, 20)) { + uaecptr ioreq = trap_get_areg(ctx, 1); + uaecptr unit = trap_get_long(ctx, ioreq + 24); // io_Unit + if (trackdisk_hack_state && unit && trap_valid_address(ctx, unit, 14)) { + uaecptr name = trap_get_long(ctx, unit + 10); // ln_Name + if (name && trap_valid_address(ctx, name, 20)) { uae_u8 *addr = get_real_address(name); if (!memcmp(addr, "trackdisk.device", 17)) { - int cmd = get_word(ioreq + 28); // io_Command - uaecptr data = get_long(ioreq + 40); - int len = get_long(ioreq + 36); + int cmd = trap_get_word(ctx, ioreq + 28); // io_Command + uaecptr data = trap_get_long(ctx, ioreq + 40); + int len = trap_get_long(ctx, ioreq + 36); //write_log(_T("%08x %d\n"), ioreq, cmd); switch (cmd) { @@ -6959,49 +7297,58 @@ static uae_u32 REGPARAM2 filesys_doio(TrapContext *context) uae_u8 *d = get_real_address(data); memset(d, 0, 1024); memcpy(d, bootblock_ofs, sizeof bootblock_ofs); - put_long(ioreq + 32, len); // io_Actual + trap_put_long(ctx, ioreq + 32, len); // io_Actual trackdisk_hack_state = 0; write_log(_T("Pre-KS 1.3 automount hack: DF0: boot block faked.\n")); } break; case 9: // TD_MOTOR - put_long(ioreq + 32, trackdisk_hack_state < 0 ? 0 : 1); + trap_put_long(ctx, ioreq + 32, trackdisk_hack_state < 0 ? 0 : 1); trackdisk_hack_state = len ? 1 : -1; break; case 13: // TD_CHANGENUM - put_long(ioreq + 32, 1); // io_Actual + trap_put_long(ctx, ioreq + 32, 1); // io_Actual break; case 14: // TD_CHANGESTATE - put_long(ioreq + 32, 0); + trap_put_long(ctx, ioreq + 32, 0); break; } return 0; } } } - m68k_areg(regs, 7) -= 4; - put_long(m68k_areg(regs, 7), get_long(ROM_filesys_doio_original)); + trap_set_areg(ctx, 7, trap_get_areg(ctx, 7) - 4); + trap_put_long(ctx, trap_get_areg(ctx, 7), trap_get_long(ctx, ROM_filesys_doio_original)); return 0; } -static uae_u32 REGPARAM2 filesys_diagentry (TrapContext *context) +static uae_u32 REGPARAM2 filesys_diagentry (TrapContext *ctx) { UnitInfo *uip = mountinfo.ui; - uaecptr resaddr = m68k_areg (regs, 2) + 0x10; - uaecptr expansion = m68k_areg (regs, 5); + uaecptr resaddr = trap_get_areg(ctx, 2); + uaecptr expansion = trap_get_areg(ctx, 5); uaecptr start = resaddr; uaecptr residents, tmp; uaecptr resaddr_hack = 0; + uae_u8 *baseaddr; + + filesys_configdev = trap_get_areg(ctx, 3); - filesys_configdev = m68k_areg(regs, 3); + if (currprefs.uaeboard > 1) { + baseaddr = uaeboard_bank.baseaddr; + resaddr += 0x100; + } else { + baseaddr = filesys_bank.baseaddr; + resaddr += 0x10; + } - do_put_mem_long((uae_u32 *)(filesys_bank.baseaddr + 0x2100), EXPANSION_explibname); - do_put_mem_long((uae_u32 *)(filesys_bank.baseaddr + 0x2104), filesys_configdev); - do_put_mem_long((uae_u32 *)(filesys_bank.baseaddr + 0x2108), EXPANSION_doslibname); - do_put_mem_word((uae_u16 *)(filesys_bank.baseaddr + 0x210c), 0); - do_put_mem_word((uae_u16 *)(filesys_bank.baseaddr + 0x210e), nr_units()); - do_put_mem_word((uae_u16 *)(filesys_bank.baseaddr + 0x2110), 0); - do_put_mem_word((uae_u16 *)(filesys_bank.baseaddr + 0x2112), 1 | (currprefs.uae_hide_autoconfig ? 16 : 0)); + put_long_host(baseaddr + 0x2100, EXPANSION_explibname); + put_long_host(baseaddr + 0x2104, filesys_configdev); + put_long_host(baseaddr + 0x2108, EXPANSION_doslibname); + put_word_host(baseaddr + 0x210c, 0); + put_word_host(baseaddr + 0x210e, nr_units()); + put_word_host(baseaddr + 0x2110, 0); + put_word_host(baseaddr + 0x2112, 1 | (currprefs.uae_hide_autoconfig || currprefs.uaeboard > 1 ? 16 : 0)); native2amiga_startup(); @@ -7011,14 +7358,14 @@ static uae_u32 REGPARAM2 filesys_diagentry (TrapContext *context) if (ROM_hardfile_resid != 0) { /* Build a struct Resident. This will set up and initialize * the uae.device */ - put_word (resaddr + 0x0, 0x4AFC); - put_long (resaddr + 0x2, resaddr); - put_long (resaddr + 0x6, resaddr + 0x1A); /* Continue scan here */ - put_word (resaddr + 0xA, 0x8132); /* RTF_AUTOINIT|RTF_COLDSTART; Version 50 */ - put_word (resaddr + 0xC, 0x0305); /* NT_DEVICE; pri 05 */ - put_long (resaddr + 0xE, ROM_hardfile_resname); - put_long (resaddr + 0x12, ROM_hardfile_resid); - put_long (resaddr + 0x16, ROM_hardfile_init); /* calls filesys_init */ + trap_put_word(ctx, resaddr + 0x0, 0x4AFC); + trap_put_long(ctx, resaddr + 0x2, resaddr); + trap_put_long(ctx, resaddr + 0x6, resaddr + 0x1A); /* Continue scan here */ + trap_put_word(ctx, resaddr + 0xA, 0x8132); /* RTF_AUTOINIT|RTF_COLDSTART; Version 50 */ + trap_put_word(ctx, resaddr + 0xC, 0x0305); /* NT_DEVICE; pri 05 */ + trap_put_long(ctx, resaddr + 0xE, ROM_hardfile_resname); + trap_put_long(ctx, resaddr + 0x12, ROM_hardfile_resid); + trap_put_long(ctx, resaddr + 0x16, ROM_hardfile_init); /* calls filesys_init */ } resaddr += 0x1A; if (!KS12_BOOT_HACK || expansion) @@ -7031,48 +7378,49 @@ static uae_u32 REGPARAM2 filesys_diagentry (TrapContext *context) * Resident structures and call InitResident() for them at the end of the * diag entry. */ - resaddr = uaeres_startup (resaddr); + resaddr = uaeres_startup(ctx, resaddr); #ifdef BSDSOCKET - resaddr = bsdlib_startup (resaddr); + resaddr = bsdlib_startup(ctx, resaddr); #endif #ifdef WITH_UAENATIVE - resaddr = uaenative_startup (resaddr); + resaddr = uaenative_startup(ctx, resaddr); #endif #ifdef SCSIEMU - resaddr = scsidev_startup (resaddr); + resaddr = scsidev_startup(ctx, resaddr); #endif #ifdef SANA2 - resaddr = netdev_startup (resaddr); + resaddr = netdev_startup(ctx, resaddr); #endif #ifdef UAESERIAL - resaddr = uaeserialdev_startup (resaddr); + resaddr = uaeserialdev_startup(ctx, resaddr); #endif #ifdef WITH_TABLETLIBRARY - resaddr = tabletlib_startup (resaddr); + resaddr = tabletlib_startup(ctx, resaddr); #endif /* scan for Residents and return pointer to array of them */ residents = resaddr; while (tmp < residents && tmp >= start) { - if (get_word (tmp) == 0x4AFC && - get_long (tmp + 0x2) == tmp) { - put_word (resaddr, 0x227C); /* move.l #tmp,a1 */ - put_long (resaddr + 2, tmp); - put_word (resaddr + 6, 0x7200); /* moveq #0,d1 */ - put_long (resaddr + 8, 0x4EAEFF9A); /* jsr -$66(a6) ; InitResident */ + if (trap_get_word(ctx, tmp) == 0x4AFC && + trap_get_long(ctx, tmp + 0x2) == tmp) { + trap_put_word(ctx, resaddr, 0x227C); /* move.l #tmp,a1 */ + trap_put_long(ctx, resaddr + 2, tmp); + trap_put_word(ctx, resaddr + 6, 0x7200); /* moveq #0,d1 */ + trap_put_long(ctx, resaddr + 8, 0x4EAEFF9A); /* jsr -$66(a6) ; InitResident */ resaddr += 12; - tmp = get_long (tmp + 0x6); + tmp = trap_get_long(ctx, tmp + 0x6); } else { tmp += 2; } } /* call setup_exter */ - put_word (resaddr + 0, 0x2079); - put_long (resaddr + 2, rtarea_base + bootrom_header + 4 + 5 * 4); /* move.l RTAREA_BASE+setup_exter,a0 */ - put_word (resaddr + 6, 0xd1fc); - put_long (resaddr + 8, rtarea_base + bootrom_header); /* add.l #RTAREA_BASE+bootrom_header,a0 */ - put_word (resaddr + 12, 0x4e90); /* jsr (a0) */ - resaddr += 14; + trap_put_word(ctx, resaddr + 0, 0x7000 | (currprefs.uaeboard > 1 ? 3 : 1)); /* moveq #x,d0 */ + trap_put_word(ctx, resaddr + 2, 0x2079); /* move.l RTAREA_BASE+setup_exter,a0 */ + trap_put_long(ctx, resaddr + 4, rtarea_base + bootrom_header + 4 + 5 * 4); + trap_put_word(ctx, resaddr + 8, 0xd1fc); /* add.l #RTAREA_BASE+bootrom_header,a0 */ + trap_put_long(ctx, resaddr + 10, rtarea_base + bootrom_header); + trap_put_word(ctx, resaddr + 14, 0x4e90); /* jsr (a0) */ + resaddr += 16; trackdisk_hack_state = 0; putmsg_hack_state = 0; @@ -7091,8 +7439,8 @@ static uae_u32 REGPARAM2 filesys_diagentry (TrapContext *context) } } - put_word (resaddr + 0, 0x7001); /* moveq #1,d0 */ - put_word (resaddr + 2, RTS); + trap_put_word(ctx, resaddr + 0, 0x7001); /* moveq #1,d0 */ + trap_put_word(ctx, resaddr + 2, RTS); resaddr += 4; ROM_filesys_doio_original = resaddr; @@ -7161,33 +7509,33 @@ static uae_u32 REGPARAM2 filesys_diagentry (TrapContext *context) resaddr += 22; // filesys.asm make_dev D7 - do_put_mem_word((uae_u16 *)(filesys_bank.baseaddr + 0x2112), 1 | 2 | 8 | 16); + put_word_host(baseaddr + 0x2112, 1 | 2 | 8 | 16); } - m68k_areg (regs, 0) = residents; + trap_set_areg(ctx, 0, residents); if (currprefs.uae_hide_autoconfig && expansion) { bool found = true; while (found) { - uaecptr node = get_long (expansion + 0x3c); + uaecptr node = trap_get_long(ctx, expansion + 0x3c); found = false; - while (get_long (node)) { - if (get_word (node + 0x10 + 4) == 2011) { - uae_u8 prod = get_byte (node + 0x10 + 1); + while (trap_get_long(ctx, node)) { + if (trap_get_word(ctx, node + 0x10 + 4) == 2011) { + uae_u8 prod = trap_get_byte(ctx, node + 0x10 + 1); if (prod != 2) { // remove all 2011 boards except filesystem found = true; - uaecptr succ = get_long (node); - uaecptr pred = get_long (node + 4); - put_long (pred, succ); - put_long (succ + 4, pred); + uaecptr succ = trap_get_long(ctx, node); + uaecptr pred = trap_get_long(ctx, node + 4); + trap_put_long(ctx, pred, succ); + trap_put_long(ctx, succ + 4, pred); break; } // replace filesystem with A590/A2091 IDs.. - put_byte (node + 0x10 + 1, 3); - put_word (node + 0x10 + 4, 514); + trap_put_byte(ctx, node + 0x10 + 1, 3); + trap_put_word(ctx, node + 0x10 + 4, 514); } - node = get_long (node); + node = trap_get_long(ctx, node); } } } @@ -7195,92 +7543,92 @@ static uae_u32 REGPARAM2 filesys_diagentry (TrapContext *context) return 1; } -static uae_u32 REGPARAM2 filesys_dev_bootfilesys (TrapContext *context) +static uae_u32 REGPARAM2 filesys_dev_bootfilesys (TrapContext *ctx) { - uaecptr devicenode = m68k_areg (regs, 3); - uaecptr parmpacket = m68k_areg (regs, 1); - uaecptr fsres = get_long (parmpacket + PP_FSRES); + uaecptr devicenode = trap_get_areg(ctx, 3); + uaecptr parmpacket = trap_get_areg(ctx, 1); + uaecptr fsres = trap_get_long(ctx, parmpacket + PP_FSRES); uaecptr fsnode; uae_u32 dostype, dostype2; - int no = m68k_dreg (regs, 6) & 0x7fffffff; + int no = trap_get_dreg(ctx, 6) & 0x7fffffff; int unit_no = no & 65535; UnitInfo *uip = &mountinfo.ui[unit_no]; - int iscd = (m68k_dreg (regs, 6) & 0x80000000) != 0 || uip->unit_type == UNIT_CDFS; + int iscd = (trap_get_dreg(ctx, 6) & 0x80000000) != 0 || uip->unit_type == UNIT_CDFS; int type; if (iscd) { - if (!get_long (devicenode + 16)) - put_long (devicenode + 16, cdfs_handlername); + if (!trap_get_long(ctx, devicenode + 16)) + trap_put_long(ctx, devicenode + 16, cdfs_handlername); return 0; } else { type = is_hardfile (unit_no); } if (type == FILESYS_VIRTUAL) { - if (!get_long (devicenode + 16)) - put_long (devicenode + 16, fshandlername); + if (!trap_get_long(ctx, devicenode + 16)) + trap_put_long(ctx, devicenode + 16, fshandlername); return 0; } - if (get_long (parmpacket + PP_FSPTR) && !get_long (parmpacket + PP_ADDTOFSRES)) { - uaecptr fsptr = get_long (parmpacket + PP_FSPTR); + 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; // filesystem but was not added to fs.resource - uae_u32 pf = get_long (parmpacket + PP_FSHDSTART + 8); // fse_PatchFlags + uae_u32 pf = trap_get_long(ctx, parmpacket + PP_FSHDSTART + 8); // fse_PatchFlags for (int i = 0; i < 32; i++) { if (pf & (1 << i)) - put_long (devicenode + 4 + i * 4, get_long (parmpacket + PP_FSHDSTART + 8 + 4 + i * 4)); + trap_put_long(ctx, devicenode + 4 + i * 4, trap_get_long(ctx, parmpacket + PP_FSHDSTART + 8 + 4 + i * 4)); } uaecptr seglist = fsptr >> 2; if (bcplonlydos()) { - put_long(devicenode + 4 + 3 * 4, seglist); - seglist = (get_long(rtarea_base + bootrom_header + 4 + 6 * 4) + rtarea_base + bootrom_header) >> 2; + trap_put_long(ctx, devicenode + 4 + 3 * 4, seglist); + seglist = (trap_get_long(ctx, rtarea_base + bootrom_header + 4 + 6 * 4) + rtarea_base + bootrom_header) >> 2; } - put_long(devicenode + 4 + 7 * 4, seglist); + trap_put_long(ctx, devicenode + 4 + 7 * 4, seglist); return 1; } - dostype = get_long (parmpacket + 80); - fsnode = get_long (fsres + 18); - while (get_long (fsnode)) { - dostype2 = get_long (fsnode + 14); + 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); if (dostype2 == dostype) { - uae_u32 pf = get_long (fsnode + 22); // fse_PatchFlags + uae_u32 pf = trap_get_long(ctx, fsnode + 22); // fse_PatchFlags for (int i = 0; i < 32; i++) { if (pf & (1 << i)) { - uae_u32 data = get_long(fsnode + 22 + 4 + i * 4); + 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 - put_long(devicenode + 4 + 3 * 4, get_long(fsnode + 22 + 4 + 7 * 4)); - data = (get_long(rtarea_base + bootrom_header + 4 + 6 * 4) + rtarea_base + bootrom_header) >> 2; + 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; } - put_long(devicenode + 4 + i * 4, data); + trap_put_long(ctx, devicenode + 4 + i * 4, data); } } return 1; } - fsnode = get_long (fsnode); + fsnode = trap_get_long(ctx, fsnode); } if (type == FILESYS_HARDFILE) { - uae_u32 pf = get_long (parmpacket + PP_FSHDSTART + 8); // fse_PatchFlags + uae_u32 pf = trap_get_long(ctx, parmpacket + PP_FSHDSTART + 8); // fse_PatchFlags for (int i = 0; i < 32; i++) { if (pf & (1 << i)) - put_long (devicenode + 4 + i * 4, get_long (parmpacket + PP_FSHDSTART + 8 + 4 + i * 4)); + trap_put_long(ctx, devicenode + 4 + i * 4, trap_get_long(ctx, parmpacket + PP_FSHDSTART + 8 + 4 + i * 4)); } - put_long (devicenode + 4 + 7 * 4, 0); // seglist + trap_put_long(ctx, devicenode + 4 + 7 * 4, 0); // seglist } - uaecptr file_system_proc = m68k_dreg(regs, 1); - if (bcplonlydos() && file_system_proc && get_long(devicenode + 4 + 7 * 4) == 0) { + uaecptr file_system_proc = trap_get_dreg(ctx, 1); + if (bcplonlydos() && file_system_proc && trap_get_long(ctx, devicenode + 4 + 7 * 4) == 0) { // 1.1 or older, seglist == 0: get ROM OFS seglist from "File System" process. // 1.2 and newer automatically use ROM OFS if seglist is zero. // d1 = "File System" process pointer. - uaecptr p = get_long(file_system_proc + 0x80) << 2; // pr_SegList + uaecptr p = trap_get_long(ctx, file_system_proc + 0x80) << 2; // pr_SegList if (p) { - uae_u32 cnt = get_long(p); + uae_u32 cnt = trap_get_long(ctx, p); if (cnt > 0 && cnt < 16) { - uaecptr handlerseg = get_long(p + cnt * 4); + uaecptr handlerseg = trap_get_long(ctx, p + cnt * 4); write_log(_T("Pre-KS 1.2 handler segment %08x.\n"), handlerseg << 2); - put_long(devicenode + 4 + 7 * 4, handlerseg); + trap_put_long(ctx, devicenode + 4 + 7 * 4, handlerseg); } } } @@ -7289,15 +7637,15 @@ static uae_u32 REGPARAM2 filesys_dev_bootfilesys (TrapContext *context) } // called from bcplwrapper -static uae_u32 REGPARAM2 filesys_bcpl_wrapper(TrapContext *context) +static uae_u32 REGPARAM2 filesys_bcpl_wrapper(TrapContext *ctx) { const int patches[] = { 0x782, 0x7b8, 0x159c, 0x15b4, 0 }; - uaecptr devicenode = get_long(m68k_dreg(regs, 1) + 0x1c) << 2; + uaecptr devicenode = trap_get_long(ctx, trap_get_dreg(ctx, 1) + 0x1c) << 2; // fetch original seglist from dn_Handler - uaecptr seglist = get_long(devicenode + 4 + 3 * 4) << 2; - uaecptr patchfunc = m68k_areg(regs, 1); + uaecptr seglist = trap_get_long(ctx, devicenode + 4 + 3 * 4) << 2; + uaecptr patchfunc = trap_get_areg(ctx, 1); seglist += 4; - m68k_areg(regs, 0) = seglist; + trap_set_areg(ctx, 0, seglist); for (int i = 0; patches[i]; i++) { int offset = patches[i]; if (get_long(seglist + offset + 2) != 0x4eaefd90) { @@ -7307,23 +7655,23 @@ static uae_u32 REGPARAM2 filesys_bcpl_wrapper(TrapContext *context) } for (int i = 0; patches[i]; i++) { int offset = patches[i]; - put_word(seglist + offset, 0x4eb9); - put_long(seglist + offset + 2, patchfunc); + trap_put_word(ctx, seglist + offset, 0x4eb9); + trap_put_long(ctx, seglist + offset + 2, patchfunc); patchfunc += 4; } write_log(_T("FFS pre-1.2 patched\n")); return 0; } -static uae_u32 REGPARAM2 filesys_init_storeinfo (TrapContext *context) +static uae_u32 REGPARAM2 filesys_init_storeinfo (TrapContext *ctx) { int ret = -1; - switch (m68k_dreg (regs, 1)) + switch (trap_get_dreg(ctx, 1)) { case 1: - mountertask = m68k_areg (regs, 1); + mountertask = trap_get_areg(ctx, 1); #ifdef PICASSO96 - picasso96_alloc (context); + picasso96_alloc(ctx); #endif break; case 2: @@ -7338,16 +7686,15 @@ static uae_u32 REGPARAM2 filesys_init_storeinfo (TrapContext *context) /* Remember a pointer AmigaOS gave us so we can later use it to identify * which unit a given startup message belongs to. */ -static uae_u32 REGPARAM2 filesys_dev_remember (TrapContext *context) +static uae_u32 REGPARAM2 filesys_dev_remember (TrapContext *ctx) { - int no = m68k_dreg (regs, 6) & 0x7fffffff; + int no = trap_get_dreg(ctx, 6) & 0x7fffffff; int unit_no = no & 65535; int sub_no = no >> 16; UnitInfo *uip = &mountinfo.ui[unit_no]; - int iscd = (m68k_dreg (regs, 6) & 0x80000000) != 0 || uip->unit_type == UNIT_CDFS; - int i; - uaecptr devicenode = m68k_areg (regs, 3); - uaecptr parmpacket = m68k_areg (regs, 1); + int iscd = (trap_get_dreg(ctx, 6) & 0x80000000) != 0 || uip->unit_type == UNIT_CDFS; + uaecptr devicenode = trap_get_areg(ctx, 3); + uaecptr parmpacket = trap_get_areg(ctx, 1); int fssize; uae_u8 *fs; @@ -7356,16 +7703,23 @@ static uae_u32 REGPARAM2 filesys_dev_remember (TrapContext *context) fs = uip->rdb_filesysstore; /* copy filesystem loaded from RDB */ - if (get_long (parmpacket + PP_FSPTR)) { - for (i = 0; i < fssize; i++) - put_byte (get_long (parmpacket + PP_FSPTR) + i, fs[i]); + if (trap_get_long(ctx, parmpacket + PP_FSPTR)) { + uaecptr addr = trap_get_long(ctx, parmpacket + PP_FSPTR); + trap_put_bytes(ctx, fs, addr, fssize); } xfree (fs); uip->rdb_filesysstore = 0; uip->rdb_filesyssize = 0; - if (m68k_dreg (regs, 3) >= 0) - uip->startup = get_long (devicenode + 28); + if (trap_get_dreg(ctx, 3) >= 0) + uip->startup = trap_get_long(ctx, devicenode + 28); + + + if (!filesystem_state) { + write_log(_T("CHANGED!\n")); + filesystem_state = 1; + } + return devicenode; } @@ -7406,7 +7760,7 @@ static int rdb_checksum (const uae_char *id, uae_u8 *p, int block) return 1; } -static int device_isdup (uaecptr expbase, TCHAR *devname) +static int device_isdup (TrapContext *ctx, uaecptr expbase, TCHAR *devname) { uaecptr bnode, dnode, name; int len, i; @@ -7414,22 +7768,22 @@ static int device_isdup (uaecptr expbase, TCHAR *devname) if (!expbase) return 0; - bnode = get_long (expbase + 74); /* expansion.library bootnode list */ - while (get_long (bnode)) { - dnode = get_long (bnode + 16); /* device node */ - name = get_long (dnode + 40) << 2; /* device name BSTR */ - len = get_byte (name); + bnode = trap_get_long(ctx, expbase + 74); /* expansion.library bootnode list */ + while (trap_get_long(ctx, bnode)) { + dnode = trap_get_long(ctx, bnode + 16); /* device node */ + name = trap_get_long(ctx, dnode + 40) << 2; /* device name BSTR */ + len = trap_get_byte(ctx, name); for (i = 0; i < len; i++) - dname[i] = get_byte (name + 1 + i); + dname[i] = trap_get_byte(ctx, name + 1 + i); dname[len] = 0; - if (!_tcsicmp (devname, dname)) + if (!_tcsicmp(devname, dname)) return 1; - bnode = get_long (bnode); + bnode = trap_get_long(ctx, bnode); } return 0; } -static TCHAR *device_dupfix (uaecptr expbase, TCHAR *devname) +static TCHAR *device_dupfix (TrapContext *ctx, uaecptr expbase, TCHAR *devname) { int modified; TCHAR newname[256]; @@ -7438,7 +7792,7 @@ static TCHAR *device_dupfix (uaecptr expbase, TCHAR *devname) modified = 1; while (modified) { modified = 0; - if (device_isdup (expbase, newname)) { + if (device_isdup (ctx, expbase, newname)) { if (_tcslen (newname) > 2 && newname[_tcslen (newname) - 2] == '_') { newname[_tcslen (newname) - 1]++; } else { @@ -7596,7 +7950,7 @@ static void dump_rdb (UnitInfo *uip, struct hardfiledata *hfd, uae_u8 *bufrdb, u #define rdbmnt write_log (_T("Mounting uaehf.device %d (%d) (size=%llu):\n"), unit_no, partnum, hfd->virtsize); -static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacket) +static int rdb_mount (TrapContext *ctx, UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacket) { int lastblock = 63, blocksize, readblocksize, badblock, driveinitblock; uae_u8 bufrdb[FILESYS_MAX_BLOCKSIZE], *buf = 0; @@ -7724,19 +8078,19 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke } if (!(flags & 1) || uip->bootpri <= -128) /* not bootable */ - m68k_dreg (regs, 7) = m68k_dreg (regs, 7) & ~1; + trap_set_dreg(ctx, 7, trap_get_dreg(ctx, 7) & ~1); buf[37 + buf[36]] = 0; /* zero terminate BSTR */ s = au ((char*)buf + 37); - uip->rdb_devname_amiga[partnum] = ds (device_dupfix (get_long (parmpacket + PP_EXPLIB), s)); + uip->rdb_devname_amiga[partnum] = ds(device_dupfix(ctx, trap_get_long(ctx, parmpacket + PP_EXPLIB), s)); xfree (s); - put_long (parmpacket, uip->rdb_devname_amiga[partnum]); /* name */ - put_long (parmpacket + 4, ROM_hardfile_resname); - put_long (parmpacket + 8, uip->devno); - put_long (parmpacket + 12, 0); /* Device flags */ + trap_put_long(ctx, parmpacket, uip->rdb_devname_amiga[partnum]); /* name */ + trap_put_long(ctx, parmpacket + 4, ROM_hardfile_resname); + trap_put_long(ctx, parmpacket + 8, uip->devno); + trap_put_long(ctx, parmpacket + 12, 0); /* Device flags */ for (i = 0; i < PP_MAXSIZE; i++) - put_byte (parmpacket + 16 + i, buf[128 + i]); - dostype = get_long (parmpacket + 80); + trap_put_byte(ctx, parmpacket + 16 + i, buf[128 + i]); + dostype = trap_get_long(ctx, parmpacket + 80); uip->rdb_dostype = dostype; if (dostype == 0) { @@ -7754,21 +8108,21 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke if (fileblock == -1 || !legalrdbblock (uip, fileblock)) goto error; - fsres = get_long (parmpacket + PP_FSRES); + fsres = trap_get_long(ctx, parmpacket + PP_FSRES); if (!fsres) { write_log (_T("RDB: FileSystem.resource not found, this shouldn't happen!\n")); goto error; } - fsnode = get_long (fsres + 18); - while (get_long (fsnode)) { - if (get_long (fsnode + 14) == dostype) + fsnode = trap_get_long(ctx, fsres + 18); + while (trap_get_long(ctx, fsnode)) { + if (trap_get_long(ctx, fsnode + 14) == dostype) break; - fsnode = get_long (fsnode); + fsnode = trap_get_long(ctx, fsnode); } oldversion = oldrevision = -1; - if (get_long (fsnode)) { - oldversion = get_word (fsnode + 18); - oldrevision = get_word (fsnode + 20); + if (trap_get_long(ctx, fsnode)) { + oldversion = trap_get_word(ctx, fsnode + 18); + oldrevision = trap_get_word(ctx, fsnode + 20); } else { fsnode = 0; } @@ -7808,8 +8162,8 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke } for (i = 0; i < 140; i++) - put_byte (parmpacket + PP_FSHDSTART + i, buf[32 + i]); - put_long (parmpacket + PP_FSHDSTART, dostype); + trap_put_byte(ctx, parmpacket + PP_FSHDSTART + i, buf[32 + i]); + trap_put_long(ctx, parmpacket + PP_FSHDSTART, dostype); /* we found required FSHD block */ fsmem = xmalloc (uae_u8, 262144); lsegblock = rl (buf + 72); @@ -7836,8 +8190,8 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke break; } write_log (_T("RDB: Filesystem loaded, %d bytes\n"), i * (blocksize - 20)); - put_long (parmpacket + PP_FSSIZE, i * (blocksize - 20)); /* RDB filesystem size hack */ - put_long (parmpacket + PP_ADDTOFSRES, -1); + trap_put_long(ctx, parmpacket + PP_FSSIZE, i * (blocksize - 20)); /* RDB filesystem size hack */ + trap_put_long(ctx, parmpacket + PP_ADDTOFSRES, -1); uip->rdb_filesysstore = fsmem; uip->rdb_filesyssize = i * (blocksize - 20); xfree (buf); @@ -7848,33 +8202,33 @@ error: return err; } -static void addfakefilesys (uaecptr parmpacket, uae_u32 dostype, int ver, int rev, struct uaedev_config_info *ci) +static void addfakefilesys (TrapContext *ctx, uaecptr parmpacket, uae_u32 dostype, int ver, int rev, struct uaedev_config_info *ci) { int i; uae_u32 flags; flags = 0x180; for (i = 0; i < 140; i++) - put_byte (parmpacket + PP_FSHDSTART + i, 0); + trap_put_byte(ctx, parmpacket + PP_FSHDSTART + i, 0); if (dostype) { - put_long (parmpacket + 80, dostype); - put_long (parmpacket + PP_FSHDSTART, dostype); + trap_put_long(ctx, parmpacket + 80, dostype); + trap_put_long(ctx, parmpacket + PP_FSHDSTART, dostype); } if (ver >= 0 && rev >= 0) - put_long (parmpacket + PP_FSHDSTART + 4, (ver << 16) | rev); + trap_put_long(ctx, parmpacket + PP_FSHDSTART + 4, (ver << 16) | rev); - put_long (parmpacket + PP_FSHDSTART + 12 + 4 * 4, ci->stacksize); + trap_put_long(ctx, parmpacket + PP_FSHDSTART + 12 + 4 * 4, ci->stacksize); flags |= 0x10; if (ci->priority != -129) { - put_long (parmpacket + PP_FSHDSTART + 12 + 5 * 4, ci->priority); + trap_put_long(ctx, parmpacket + PP_FSHDSTART + 12 + 5 * 4, ci->priority); flags |= 0x20; } - put_long (parmpacket + PP_FSHDSTART + 12 + 8 * 4, dostype == 0x444f5300 || bcplonlydos() ? 0 : -1); // globvec + trap_put_long(ctx, parmpacket + PP_FSHDSTART + 12 + 8 * 4, dostype == 0x444f5300 || bcplonlydos() ? 0 : -1); // globvec // if OFS = seglist -> NULL if (dostype == 0x444f5300) flags &= ~0x080; - put_long (parmpacket + PP_FSHDSTART + 8, flags); // patchflags + trap_put_long(ctx, parmpacket + PP_FSHDSTART + 8, flags); // patchflags } static uaecptr getfakefilesysseg (UnitInfo *uip) @@ -7893,7 +8247,7 @@ static uaecptr getfakefilesysseg (UnitInfo *uip) return 0; } -static int dofakefilesys (UnitInfo *uip, uaecptr parmpacket, struct uaedev_config_info *ci) +static int dofakefilesys (TrapContext *ctx, UnitInfo *uip, uaecptr parmpacket, struct uaedev_config_info *ci) { int i, size; TCHAR tmp[MAX_DPATH]; @@ -7908,9 +8262,9 @@ static int dofakefilesys (UnitInfo *uip, uaecptr parmpacket, struct uaedev_confi uaecptr seg = getfakefilesysseg (uip); if (seg) { // yes, re-use it. - put_long (parmpacket + PP_FSSIZE, 0); - put_long (parmpacket + PP_FSPTR, seg); - put_long (parmpacket + PP_ADDTOFSRES, 0); + 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); return FILESYS_HARDFILE; } @@ -7924,7 +8278,7 @@ static int dofakefilesys (UnitInfo *uip, uaecptr parmpacket, struct uaedev_confi dostype = ci->dostype; } if (dostype == 0) { - addfakefilesys (parmpacket, dostype, ver, rev, ci); + addfakefilesys(ctx, parmpacket, dostype, ver, rev, ci); return FILESYS_HARDFILE; } if (dostype == 0x444f5300 && (!uip->filesysdir || !uip->filesysdir[0])) { @@ -7945,7 +8299,7 @@ static int dofakefilesys (UnitInfo *uip, uaecptr parmpacket, struct uaedev_confi } if (tmp[0] == 0) { write_log (_T("RDB: no filesystem for dostype 0x%08X (%s)\n"), dostype, dostypes (dostype)); - addfakefilesys (parmpacket, dostype, ver, rev, ci); + addfakefilesys(ctx, parmpacket, dostype, ver, rev, ci); if ((dostype & 0xffffff00) == 0x444f5300) return FILESYS_HARDFILE; write_log (_T("RDB: mounted without filesys\n")); @@ -7954,7 +8308,7 @@ static int dofakefilesys (UnitInfo *uip, uaecptr parmpacket, struct uaedev_confi write_log (_T("RDB: fakefilesys, trying to load '%s', dostype 0x%08X (%s)\n"), tmp, dostype, dostypes (dostype)); zf = zfile_fopen (tmp, _T("rb"), ZFD_NORMAL); if (!zf) { - addfakefilesys (parmpacket, dostype, ver, rev, ci); + addfakefilesys(ctx, parmpacket, dostype, ver, rev, ci); write_log (_T("RDB: filesys not found, mounted without forced filesys\n")); return FILESYS_HARDFILE; } @@ -7962,22 +8316,22 @@ static int dofakefilesys (UnitInfo *uip, uaecptr parmpacket, struct uaedev_confi uae_u32 fsres, fsnode; int oldversion = -1; int oldrevision = -1; - fsres = get_long (parmpacket + PP_FSRES); - fsnode = get_long (fsres + 18); - while (get_long (fsnode)) { - uae_u32 fsdostype = get_long (fsnode + 14); + fsres = trap_get_long(ctx, parmpacket + PP_FSRES); + fsnode = trap_get_long(ctx, fsres + 18); + while (trap_get_long(ctx, fsnode)) { + uae_u32 fsdostype = trap_get_long(ctx, fsnode + 14); if (fsdostype == dostype) { - oldversion = get_word (fsnode + 18); - oldrevision = get_word (fsnode + 20); + oldversion = trap_get_word(ctx, fsnode + 18); + oldrevision = trap_get_word(ctx, fsnode + 20); write_log (_T("RDB: %08X (%s) in FileSystem.resource version %d.%d\n"), dostype, dostypes (dostype), oldversion, oldrevision); break; } - fsnode = get_long (fsnode); + fsnode = trap_get_long(ctx, fsnode); } // if automatically found FastFileSystem, do not replace matching FileSystem.resource FS if (autofs && oldversion >= 0) { zfile_fclose (zf); - addfakefilesys (parmpacket, dostype, ver, rev, ci); + addfakefilesys(ctx, parmpacket, dostype, ver, rev, ci); write_log (_T("RDB: not replacing FileSystem.resource\n")); return FILESYS_HARDFILE; } @@ -8031,17 +8385,17 @@ static int dofakefilesys (UnitInfo *uip, uaecptr parmpacket, struct uaedev_confi // DOS\0 is not in fs.resource and fs.resource already existed? if (dostype == 0x444f5300 && oldversion < 0) oldversion = 0; - put_long (parmpacket + PP_FSSIZE, uip->rdb_filesyssize); - put_long (parmpacket + PP_ADDTOFSRES, oldversion < 0 ? -1 : 0); - addfakefilesys (parmpacket, dostype, ver, rev, ci); + trap_put_long(ctx, parmpacket + PP_FSSIZE, uip->rdb_filesyssize); + trap_put_long(ctx, parmpacket + PP_ADDTOFSRES, oldversion < 0 ? -1 : 0); + addfakefilesys(ctx, parmpacket, dostype, ver, rev, ci); write_log (_T("RDB: faked RDB filesystem %08X (%s %d.%d) loaded. ADD2FS=%d\n"), dostype, dostypes (dostype), ver, rev, oldversion < 0 ? 1 : 0); return FILESYS_HARDFILE; } -static void get_new_device (int type, uaecptr parmpacket, TCHAR **devname, uaecptr *devname_amiga, int unit_no) +static void get_new_device (TrapContext *ctx, int type, uaecptr parmpacket, TCHAR **devname, uaecptr *devname_amiga, int unit_no) { TCHAR buffer[80]; - uaecptr expbase = get_long (parmpacket + PP_EXPLIB); + uaecptr expbase = trap_get_long(ctx, parmpacket + PP_EXPLIB); if (*devname == 0 || _tcslen (*devname) == 0) { int un = unit_no; @@ -8049,13 +8403,13 @@ static void get_new_device (int type, uaecptr parmpacket, TCHAR **devname, uaecp _stprintf (buffer, type == FILESYS_CD ? _T("CD%d") : _T("DH%d"), un++); if (type == FILESYS_CD) *devname = my_strdup (buffer); - if (!device_isdup (expbase, buffer)) + if (!device_isdup(ctx, expbase, buffer)) break; } } else { _tcscpy (buffer, *devname); } - *devname_amiga = ds (device_dupfix (expbase, buffer)); + *devname_amiga = ds (device_dupfix(ctx, expbase, buffer)); if (type == FILESYS_CD) write_log (_T("FS: mounted CD unit %s\n"), buffer); else if (type == FILESYS_VIRTUAL) @@ -8068,23 +8422,23 @@ static void get_new_device (int type, uaecptr parmpacket, TCHAR **devname, uaecp } /* Fill in per-unit fields of a parampacket */ -static uae_u32 REGPARAM2 filesys_dev_storeinfo (TrapContext *context) +static uae_u32 REGPARAM2 filesys_dev_storeinfo (TrapContext *ctx) { UnitInfo *uip = mountinfo.ui; - int no = m68k_dreg (regs, 6) & 0x7fffffff; + int no = trap_get_dreg(ctx, 6) & 0x7fffffff; int unit_no = no & 65535; int sub_no = no >> 16; - int iscd = (m68k_dreg (regs, 6) & 0x80000000) != 0 || uip[unit_no].unit_type == UNIT_CDFS; + int iscd = (trap_get_dreg(ctx, 6) & 0x80000000) != 0 || uip[unit_no].unit_type == UNIT_CDFS; int type; - uaecptr parmpacket = m68k_areg (regs, 0); + uaecptr parmpacket = trap_get_areg(ctx, 0); struct uaedev_config_info *ci = &uip[unit_no].hf.ci; uip[unit_no].parmpacket = parmpacket; if (!ks12hack_deviceproc) - ks12hack_deviceproc = get_long(parmpacket + PP_DEVICEPROC); - put_long(parmpacket + PP_DEVICEPROC, 0); - put_long(parmpacket + PP_ADDTOFSRES, 0); - put_long(parmpacket + PP_FSSIZE, 0); + ks12hack_deviceproc = trap_get_long(ctx, parmpacket + PP_DEVICEPROC); + trap_put_long(ctx, parmpacket + PP_DEVICEPROC, 0); + trap_put_long(ctx, parmpacket + PP_ADDTOFSRES, 0); + trap_put_long(ctx, parmpacket + PP_FSSIZE, 0); if (iscd) { TCHAR *cdname = NULL; uaecptr cdname_amiga; @@ -8094,37 +8448,37 @@ static uae_u32 REGPARAM2 filesys_dev_storeinfo (TrapContext *context) return -2; type = FILESYS_CD; - get_new_device (type, parmpacket, &uip[unit_no].devname, &uip[unit_no].devname_amiga, cd_unit_no); + get_new_device(ctx, type, parmpacket, &uip[unit_no].devname, &uip[unit_no].devname_amiga, cd_unit_no); cdname_amiga = uip[unit_no].devname_amiga; uip[unit_no].devno = unit_no; type = FILESYS_VIRTUAL; gui_flicker_led (LED_CD, cd_unit_no, 0); write_log (_T("Mounting uaescsi.device %d: (%d)\n"), cd_unit_no, unit_no); - put_long (parmpacket + 0, cdname_amiga); - put_long (parmpacket + 4, cdfs_devname); - put_long (parmpacket + 8, cd_unit_no); - put_long (parmpacket + 12, 0); /* Device flags */ - put_long (parmpacket + 16, 19); /* Env. size */ - put_long (parmpacket + 20, 2048 >> 2); /* longwords per block */ - put_long (parmpacket + 24, 0); /* unused */ - put_long (parmpacket + 28, 1); /* heads */ - put_long (parmpacket + 32, 1); /* sectors per block */ - put_long (parmpacket + 36, 1); /* sectors per track */ - put_long (parmpacket + 40, 0); /* reserved blocks */ - put_long (parmpacket + 44, 0); /* unused */ - put_long (parmpacket + 48, 0); /* interleave */ - put_long (parmpacket + 52, 0); /* lowCyl */ - put_long (parmpacket + 56, 0); /* hiCyl */ - put_long (parmpacket + 60, 50); /* Number of buffers */ - put_long (parmpacket + 64, 1); /* Buffer mem type */ - put_long (parmpacket + 68, 0x7FFFFFFE); /* largest transfer */ - put_long (parmpacket + 72, 0xFFFFFFFE); /* dma mask */ - put_long (parmpacket + 76, scsi_get_cd_drive_media_mask () & (1 << cd_unit_no) ? -127 : -128); /* bootPri */ - put_long (parmpacket + 80, CDFS_DOSTYPE | (((cd_unit_no / 10) + '0') << 8) | ((cd_unit_no % 10) + '0')); - put_long (parmpacket + 84, 0); /* baud */ - put_long (parmpacket + 88, 0); /* control */ - put_long (parmpacket + 92, 0); /* bootblocks */ + trap_put_long(ctx, parmpacket + 0, cdname_amiga); + trap_put_long(ctx, parmpacket + 4, cdfs_devname); + trap_put_long(ctx, parmpacket + 8, cd_unit_no); + trap_put_long(ctx, parmpacket + 12, 0); /* Device flags */ + trap_put_long(ctx, parmpacket + 16, 19); /* Env. size */ + trap_put_long(ctx, parmpacket + 20, 2048 >> 2); /* longwords per block */ + trap_put_long(ctx, parmpacket + 24, 0); /* unused */ + trap_put_long(ctx, parmpacket + 28, 1); /* heads */ + trap_put_long(ctx, parmpacket + 32, 1); /* sectors per block */ + trap_put_long(ctx, parmpacket + 36, 1); /* sectors per track */ + trap_put_long(ctx, parmpacket + 40, 0); /* reserved blocks */ + trap_put_long(ctx, parmpacket + 44, 0); /* unused */ + trap_put_long(ctx, parmpacket + 48, 0); /* interleave */ + trap_put_long(ctx, parmpacket + 52, 0); /* lowCyl */ + trap_put_long(ctx, parmpacket + 56, 0); /* hiCyl */ + trap_put_long(ctx, parmpacket + 60, 50); /* Number of buffers */ + trap_put_long(ctx, parmpacket + 64, 1); /* Buffer mem type */ + trap_put_long(ctx, parmpacket + 68, 0x7FFFFFFE); /* largest transfer */ + trap_put_long(ctx, parmpacket + 72, 0xFFFFFFFE); /* dma mask */ + trap_put_long(ctx, parmpacket + 76, scsi_get_cd_drive_media_mask () & (1 << cd_unit_no) ? -127 : -128); /* bootPri */ + trap_put_long(ctx, parmpacket + 80, CDFS_DOSTYPE | (((cd_unit_no / 10) + '0') << 8) | ((cd_unit_no % 10) + '0')); + trap_put_long(ctx, parmpacket + 84, 0); /* baud */ + trap_put_long(ctx, parmpacket + 88, 0); /* control */ + trap_put_long(ctx, parmpacket + 92, 0); /* bootblocks */ return type; } else { @@ -8134,57 +8488,57 @@ static uae_u32 REGPARAM2 filesys_dev_storeinfo (TrapContext *context) if (type == FILESYS_HARDFILE_RDB || type == FILESYS_HARDDRIVE) { /* RDB hardfile */ uip[unit_no].devno = unit_no; - return rdb_mount (&uip[unit_no], unit_no, sub_no, parmpacket); + return rdb_mount(ctx, &uip[unit_no], unit_no, sub_no, parmpacket); } if (sub_no) return -2; write_log (_T("Mounting uaehf.device %d (%d):\n"), unit_no, sub_no); - get_new_device (type, parmpacket, &uip[unit_no].devname, &uip[unit_no].devname_amiga, unit_no); + get_new_device(ctx, type, parmpacket, &uip[unit_no].devname, &uip[unit_no].devname_amiga, unit_no); uip[unit_no].devno = unit_no; - put_long (parmpacket, uip[unit_no].devname_amiga); - put_long (parmpacket + 8, uip[unit_no].devno); - put_long (parmpacket + 12, 0); /* Device flags */ - put_long (parmpacket + 16, 16); /* Env. size */ - put_long (parmpacket + 24, 0); /* unused */ - put_long (parmpacket + 44, 0); /* unused */ - put_long (parmpacket + 48, 0); /* interleave */ - put_long (parmpacket + 60, 50); /* Number of buffers */ - put_long (parmpacket + 64, 1); /* Buffer mem type */ - put_long (parmpacket + 68, 0x7FFFFFFE); /* largest transfer */ - put_long (parmpacket + 72, 0xFFFFFFFE); /* dma mask */ - put_long (parmpacket + 76, uip[unit_no].bootpri); /* bootPri */ - put_long (parmpacket + 80, DISK_TYPE_DOS); /* DOS\0 */ + trap_put_long(ctx, parmpacket, uip[unit_no].devname_amiga); + trap_put_long(ctx, parmpacket + 8, uip[unit_no].devno); + trap_put_long(ctx, parmpacket + 12, 0); /* Device flags */ + trap_put_long(ctx, parmpacket + 16, 16); /* Env. size */ + trap_put_long(ctx, parmpacket + 24, 0); /* unused */ + trap_put_long(ctx, parmpacket + 44, 0); /* unused */ + trap_put_long(ctx, parmpacket + 48, 0); /* interleave */ + trap_put_long(ctx, parmpacket + 60, 50); /* Number of buffers */ + trap_put_long(ctx, parmpacket + 64, 1); /* Buffer mem type */ + trap_put_long(ctx, parmpacket + 68, 0x7FFFFFFE); /* largest transfer */ + trap_put_long(ctx, parmpacket + 72, 0xFFFFFFFE); /* dma mask */ + trap_put_long(ctx, parmpacket + 76, uip[unit_no].bootpri); /* bootPri */ + trap_put_long(ctx, parmpacket + 80, DISK_TYPE_DOS); /* DOS\0 */ if (type == FILESYS_VIRTUAL) { - put_long (parmpacket + 4, fsdevname); - put_long (parmpacket + 20, 512 >> 2); /* longwords per block */ - put_long (parmpacket + 28, 15); /* heads */ - put_long (parmpacket + 32, 1); /* sectors per block */ - put_long (parmpacket + 36, 127); /* sectors per track */ - put_long (parmpacket + 40, 2); /* reserved blocks */ - put_long (parmpacket + 52, 0); /* lowCyl */ - put_long (parmpacket + 56, 1); /* hiCyl */ + trap_put_long(ctx, parmpacket + 4, fsdevname); + trap_put_long(ctx, parmpacket + 20, 512 >> 2); /* longwords per block */ + trap_put_long(ctx, parmpacket + 28, 15); /* heads */ + trap_put_long(ctx, parmpacket + 32, 1); /* sectors per block */ + trap_put_long(ctx, parmpacket + 36, 127); /* sectors per track */ + trap_put_long(ctx, parmpacket + 40, 2); /* reserved blocks */ + trap_put_long(ctx, parmpacket + 52, 0); /* lowCyl */ + trap_put_long(ctx, parmpacket + 56, 1); /* hiCyl */ } else { uae_u8 buf[512]; - put_long (parmpacket + 4, ROM_hardfile_resname); - put_long (parmpacket + 20, ci->blocksize >> 2); /* longwords per block */ - put_long (parmpacket + 28, ci->surfaces); /* heads */ - put_long (parmpacket + 32, ci->sectorsperblock); /* sectors per block */ - put_long (parmpacket + 36, ci->sectors); /* sectors per track */ - put_long (parmpacket + 40, ci->reserved); /* reserved blocks */ - put_long (parmpacket + 52, ci->lowcyl); /* lowCyl */ - put_long (parmpacket + 56, ci->highcyl <= 0 ? ci->cyls - 1 : ci->highcyl - 1); /* hiCyl */ - put_long (parmpacket + 48, ci->interleave); /* interleave */ - put_long (parmpacket + 60, ci->buffers); /* Number of buffers */ - put_long (parmpacket + 64, ci->bufmemtype); /* Buffer mem type */ - put_long (parmpacket + 68, ci->maxtransfer); /* largest transfer */ - put_long (parmpacket + 72, ci->mask); /* dma mask */ + trap_put_long(ctx, parmpacket + 4, ROM_hardfile_resname); + trap_put_long(ctx, parmpacket + 20, ci->blocksize >> 2); /* longwords per block */ + trap_put_long(ctx, parmpacket + 28, ci->surfaces); /* heads */ + trap_put_long(ctx, parmpacket + 32, ci->sectorsperblock); /* sectors per block */ + trap_put_long(ctx, parmpacket + 36, ci->sectors); /* sectors per track */ + trap_put_long(ctx, parmpacket + 40, ci->reserved); /* reserved blocks */ + trap_put_long(ctx, parmpacket + 52, ci->lowcyl); /* lowCyl */ + trap_put_long(ctx, parmpacket + 56, ci->highcyl <= 0 ? ci->cyls - 1 : ci->highcyl - 1); /* hiCyl */ + trap_put_long(ctx, parmpacket + 48, ci->interleave); /* interleave */ + trap_put_long(ctx, parmpacket + 60, ci->buffers); /* Number of buffers */ + trap_put_long(ctx, parmpacket + 64, ci->bufmemtype); /* Buffer mem type */ + trap_put_long(ctx, parmpacket + 68, ci->maxtransfer); /* largest transfer */ + trap_put_long(ctx, parmpacket + 72, ci->mask); /* dma mask */ memset(buf, 0, sizeof buf); if (ci->dostype) { // forced dostype? - put_long (parmpacket + 80, ci->dostype); /* dostype */ + trap_put_long(ctx, parmpacket + 80, ci->dostype); /* dostype */ } else if (hdf_read (&uip[unit_no].hf, buf, 0, sizeof buf)) { uae_u32 dt = rl (buf); if (dt != 0x00000000 && dt != 0xffffffff) - put_long (parmpacket + 80, dt); + trap_put_long(ctx, parmpacket + 80, dt); } memset(buf, 0, sizeof buf); char *s = ua_fs(uip[unit_no].devname, -1); @@ -8193,56 +8547,58 @@ static uae_u32 REGPARAM2 filesys_dev_storeinfo (TrapContext *context) buf[37 + i] = s[i]; xfree(s); for (int i = 0; i < 80; i++) - buf[i + 128] = get_byte (parmpacket + 16 + i); + buf[i + 128] = trap_get_byte(ctx, parmpacket + 16 + i); dump_partinfo (&uip[unit_no].hf, buf); } if (type == FILESYS_HARDFILE) - type = dofakefilesys (&uip[unit_no], parmpacket, ci); + type = dofakefilesys(ctx, &uip[unit_no], parmpacket, ci); if (uip[unit_no].bootpri < -127 || (type == FILESYS_HARDFILE && ci->rootdir[0] == 0)) - m68k_dreg (regs, 7) = m68k_dreg (regs, 7) & ~1; /* do not boot */ + trap_set_dreg(ctx, 7, trap_get_dreg(ctx, 7) & ~1); /* do not boot */ if (uip[unit_no].bootpri < -128) return -1; /* do not mount */ return type; } } -static uae_u32 REGPARAM2 mousehack_done (TrapContext *context) +static uae_u32 REGPARAM2 mousehack_done (TrapContext *ctx) { - int mode = m68k_dreg (regs, 1); + int mode = trap_get_dreg(ctx, 1); if (mode < 10) { - uaecptr diminfo = m68k_areg (regs, 2); - uaecptr dispinfo = m68k_areg (regs, 3); - uaecptr vp = m68k_areg (regs, 4); - return input_mousehack_status (mode, diminfo, dispinfo, vp, m68k_dreg (regs, 2)); + uaecptr diminfo = trap_get_areg(ctx, 2); + uaecptr dispinfo = trap_get_areg(ctx, 3); + uaecptr vp = trap_get_areg(ctx, 4); + return input_mousehack_status(mode, diminfo, dispinfo, vp, trap_get_dreg(ctx, 2)); } else if (mode == 10) { - amiga_clipboard_die (); + amiga_clipboard_die(); } else if (mode == 11) { - amiga_clipboard_got_data (m68k_areg (regs, 2), m68k_dreg (regs, 2), m68k_dreg (regs, 0) + 8); + amiga_clipboard_got_data(trap_get_areg(ctx, 2), trap_get_dreg(ctx, 2), trap_get_dreg(ctx, 0) + 8); } else if (mode == 12) { - return amiga_clipboard_want_data (); + return amiga_clipboard_want_data(); } else if (mode == 13) { - return amiga_clipboard_proc_start (); + return amiga_clipboard_proc_start(); } else if (mode == 14) { - amiga_clipboard_task_start (m68k_dreg (regs, 0)); + amiga_clipboard_task_start(trap_get_dreg(ctx, 0)); } else if (mode == 15) { - amiga_clipboard_init (); + amiga_clipboard_init(); } else if (mode == 16) { - uaecptr a2 = m68k_areg (regs, 2); - input_mousehack_mouseoffset (a2); + uaecptr a2 = trap_get_areg(ctx, 2); + input_mousehack_mouseoffset(a2); } else if (mode == 17) { uae_u32 v = 0; if (currprefs.clipboard_sharing) v |= 1; - if (consolehook_activate ()) + if (consolehook_activate()) v |= 2; return v; } else if (mode == 18) { + put_long_host(rtarea_bank.baseaddr + RTAREA_EXTERTASK, trap_get_dreg(ctx, 0)); + put_long_host(rtarea_bank.baseaddr + RTAREA_TRAPTASK, trap_get_dreg(ctx, 2)); return rtarea_base + RTAREA_HEARTBEAT; } else if (mode == 101) { - consolehook_ret (m68k_areg (regs, 1), m68k_areg (regs, 2)); + consolehook_ret(trap_get_areg(ctx, 1), trap_get_areg(ctx, 2)); } else if (mode == 102) { - uaecptr ret = consolehook_beginio (m68k_areg (regs, 1)); - put_long (m68k_areg (regs, 7) + 4 * 4, ret); + uaecptr ret = consolehook_beginio(trap_get_areg(ctx, 1)); + trap_put_long(ctx, trap_get_areg(ctx, 7) + 4 * 4, ret); } else { write_log (_T("Unknown mousehack hook %d\n"), mode); } @@ -8251,18 +8607,50 @@ static uae_u32 REGPARAM2 mousehack_done (TrapContext *context) void filesys_vsync (void) { + TrapContext *ctx = NULL; Unit *u; if (uae_boot_rom_type <= 0) return; - if (heartbeat == get_long (rtarea_base + RTAREA_HEARTBEAT)) { + + if (currprefs.uaeboard > 1) { + bool req = false; + // check if there is waiting requests without signal + if (!uae_sem_trywait(&singlethread_int_sem)) { + if (comm_pipe_has_data(&native2amiga_pending)) + req = true; + UnitInfo *uip = mountinfo.ui; + int unit_no = 0; + for (;;) { + if (unit_no >= MAX_FILESYSTEM_UNITS) + break; + if (uip[unit_no].open > 0 && uip[unit_no].self != 0 + && uip[unit_no].self->cmds_acked == uip[unit_no].self->cmds_complete + && uip[unit_no].self->cmds_acked != uip[unit_no].self->cmds_sent) + break; + unit_no++; + } + if (unit_no < MAX_FILESYSTEM_UNITS) { + if (uip[unit_no].self->port) + req = true; + } + uae_sem_post(&singlethread_int_sem); + if (req) + atomic_or(&uae_int_requested, 1); + } + } + + if (heartbeat == get_long_host(rtarea_bank.baseaddr + RTAREA_HEARTBEAT)) { if (heartbeat_count > 0) heartbeat_count--; return; } - heartbeat = get_long (rtarea_base + RTAREA_HEARTBEAT); + heartbeat = get_long_host(rtarea_bank.baseaddr + RTAREA_HEARTBEAT); cia_heartbeat (); + if (currprefs.uaeboard > 1) + return; + for (u = units; u; u = u->next) { if (u->reinsertdelay > 0) { u->reinsertdelay--; @@ -8274,7 +8662,7 @@ void filesys_vsync (void) u->newrootdir = NULL; } } - record_timeout (u); + record_timeout(ctx, u); } for (int i = 0; i < currprefs.mountitems; i++) { @@ -8352,9 +8740,11 @@ void filesys_install (void) calltrap (deftrap2 (filesys_dev_storeinfo, 0, _T("filesys_dev_storeinfo"))); dw (RTS); - org(rtarea_base + 0xFF2C); - calltrap(deftrap2(filesys_bcpl_wrapper, 0, _T("filesys_bcpl_wrapper"))); - dw(RTS); + if (currprefs.uaeboard < 3) { + org(rtarea_base + 0xFF2C); + calltrap(deftrap2(filesys_bcpl_wrapper, 0, _T("filesys_bcpl_wrapper"))); + dw(RTS); + } org (rtarea_base + 0xFF30); calltrap (deftrap2 (filesys_handler, 0, _T("filesys_handler"))); @@ -8364,9 +8754,11 @@ void filesys_install (void) calltrap (deftrap2 (mousehack_done, 0, _T("mousehack_done"))); dw (RTS); - org(rtarea_base + 0xFF3C); - calltrap(deftrap2(debugger_helper, 0, _T("debugger_helper"))); - dw(RTS); + if (currprefs.uaeboard < 3) { + org(rtarea_base + 0xFF3C); + calltrap(deftrap2(debugger_helper, 0, _T("debugger_helper"))); + dw(RTS); + } org (rtarea_base + 0xFF40); calltrap (deftrap2 (startup_handler, 0, _T("startup_handler"))); @@ -8387,20 +8779,25 @@ void filesys_install (void) org (loop); } +uaecptr filesys_get_entry(int index) +{ + return bootrom_start + dlg(bootrom_start + bootrom_header + index * 4 - 4) + bootrom_header - 4; +} + void filesys_install_code (void) { - uae_u32 a, b, items; + uae_u32 b, items; bootrom_header = 3 * 4; align(4); - a = here (); + bootrom_start = here (); #include "filesys_bootrom.cpp" - items = dlg (a + 8) & 0xffff; + items = dlg (bootrom_start + 8) & 0xffff; /* The last offset comes from the code itself, look for it near the top. */ - EXPANSION_bootcode = a + bootrom_header + items * 4 - 4; - b = a + bootrom_header + 3 * 4 - 4; - filesys_initcode = a + dlg (b) + bootrom_header - 4; + EXPANSION_bootcode = bootrom_start + bootrom_header + items * 4 - 4; + b = bootrom_start + bootrom_header + 3 * 4 - 4; + filesys_initcode = bootrom_start + dlg (b) + bootrom_header - 4; } #ifdef _WIN32 @@ -8751,7 +9148,7 @@ static uae_u8 *restore_exkey (UnitInfo *ui, Unit *u, uae_u8 *src) static uae_u8 *restore_filesys_virtual (UnitInfo *ui, uae_u8 *src, int num) { - Unit *u = startup_create_unit (ui, num); + Unit *u = startup_create_unit(NULL, ui, num); int cnt; u->dosbase = restore_u32 (); diff --git a/filesys_bootrom.cpp b/filesys_bootrom.cpp index 556b3930..3f429bae 100644 --- a/filesys_bootrom.cpp +++ b/filesys_bootrom.cpp @@ -1,18 +1,19 @@ db(0x00); db(0x00); db(0x00); db(0x10); db(0x00); db(0x00); db(0x00); db(0x00); - db(0x60); db(0x02); db(0x00); db(0x09); db(0x60); db(0x00); db(0x0b); db(0xce); - db(0x00); db(0x00); db(0x09); db(0x34); db(0x00); db(0x00); db(0x01); db(0x04); - db(0x00); db(0x00); db(0x02); db(0xf4); db(0x00); db(0x00); db(0x00); db(0x24); - db(0x00); db(0x00); db(0x04); db(0x02); db(0x00); db(0x00); db(0x1a); db(0x10); - db(0x00); db(0x00); db(0x14); db(0x76); db(0x43); db(0xfa); db(0x1b); db(0x4c); + db(0x60); db(0x02); db(0x00); db(0x0b); db(0x60); db(0x00); db(0x0d); db(0x90); + db(0x00); db(0x00); db(0x0a); db(0xf6); db(0x00); db(0x00); db(0x01); db(0x0c); + db(0x00); db(0x00); db(0x04); db(0x4a); db(0x00); db(0x00); db(0x00); db(0x2c); + db(0x00); db(0x00); db(0x05); db(0x76); db(0x00); db(0x00); db(0x1b); db(0xd0); + db(0x00); db(0x00); db(0x16); db(0x38); db(0x00); db(0x00); db(0x1c); db(0x2c); + db(0x00); db(0x00); db(0x1c); db(0x7e); db(0x43); db(0xfa); db(0x20); db(0x4a); db(0x4e); db(0xae); db(0xff); db(0xa0); db(0x20); db(0x40); db(0x20); db(0x28); db(0x00); db(0x16); db(0x20); db(0x40); db(0x4e); db(0x90); db(0x4e); db(0x75); db(0x00); db(0x00); db(0x00); db(0x07); db(0x00); db(0x00); db(0x00); db(0x00); db(0x00); db(0x00); db(0x00); db(0x07); db(0xe5); db(0x89); db(0x2e); db(0x01); - db(0x60); db(0x00); db(0x0b); db(0x8c); db(0x00); db(0x00); db(0x00); db(0x00); + db(0x60); db(0x00); db(0x0d); db(0x46); db(0x00); db(0x00); db(0x00); db(0x00); db(0x00); db(0x00); db(0x00); db(0x01); db(0x00); db(0x00); db(0x00); db(0x04); db(0x00); db(0x00); db(0x00); db(0x02); db(0x48); db(0xe7); db(0xe0); db(0xe2); db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x11); db(0x61); db(0x00); - db(0x1a); db(0x04); db(0x4e); db(0x90); db(0x4a); db(0x80); db(0x67); db(0x4c); + db(0x1e); db(0xec); db(0x4e); db(0x90); db(0x4a); db(0x80); db(0x67); db(0x4c); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x0c); db(0x6e); db(0x00); db(0x25); db(0x00); db(0x14); db(0x65); db(0x40); db(0x70); db(0x14); db(0x24); db(0x00); db(0x72); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x4a); db(0x80); @@ -27,22 +28,22 @@ db(0x2f); db(0x08); db(0x4e); db(0x90); db(0x20); db(0x5f); db(0x58); db(0x8f); db(0x48); db(0xe7); db(0xff); db(0x7e); db(0x22); db(0x4e); db(0x20); db(0x08); db(0x30); db(0x7c); db(0xff); db(0xb8); db(0x4e); db(0xae); db(0xfe); db(0x5c); - db(0x61); db(0x00); db(0x13); db(0x94); db(0x61); db(0x00); db(0x17); db(0x5c); + db(0x61); db(0x00); db(0x15); db(0x4e); db(0x61); db(0x00); db(0x19); db(0x14); db(0x4c); db(0xdf); db(0x7e); db(0xff); db(0x4e); db(0x75); db(0x00); db(0x00); db(0x08); db(0x00); db(0x00); db(0x02); db(0x67); db(0x06); db(0x4e); db(0xb9); db(0x00); db(0xf0); db(0x00); db(0x00); db(0x4e); db(0xf9); db(0x00); db(0xf0); db(0x00); db(0x00); db(0x00); db(0x00); db(0x48); db(0xe7); db(0xff); db(0xfe); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x30); db(0x3c); db(0xff); db(0xec); - db(0x61); db(0x00); db(0x19); db(0x5a); db(0x2a); db(0x50); db(0x7a); db(0x00); + db(0x61); db(0x00); db(0x1e); db(0x42); db(0x2a); db(0x50); db(0x7a); db(0x00); db(0x70); db(0x00); db(0x0c); db(0x6e); db(0x00); db(0x21); db(0x00); db(0x14); - db(0x65); db(0x1c); db(0x43); db(0xfa); db(0x1a); db(0x7d); db(0x70); db(0x24); + db(0x65); db(0x1c); db(0x43); db(0xfa); db(0x1f); db(0x7b); db(0x70); db(0x24); db(0x7a); db(0x01); db(0x4e); db(0xae); db(0xfd); db(0xd8); db(0x4a); db(0x80); - db(0x66); db(0x0c); db(0x43); db(0xfa); db(0x1a); db(0x6d); db(0x70); db(0x00); + db(0x66); db(0x0c); db(0x43); db(0xfa); db(0x1f); db(0x6b); db(0x70); db(0x00); db(0x7a); db(0x00); db(0x4e); db(0xae); db(0xfd); db(0xd8); db(0x28); db(0x40); db(0xc9); db(0x4e); db(0x20); db(0x0e); db(0x67); db(0x3c); db(0x08); db(0x2d); db(0x00); db(0x04); db(0x01); db(0x13); db(0x66); db(0x34); db(0x4e); db(0xae); db(0xff); db(0xd0); db(0x4a); db(0x80); db(0x67); db(0x2c); db(0x20); db(0x40); - db(0x43); db(0xfa); db(0xfe); db(0xa6); db(0x20); db(0x09); db(0x42); db(0x40); + db(0x43); db(0xfa); db(0xfe); db(0x9e); db(0x20); db(0x09); db(0x42); db(0x40); db(0x21); db(0x40); db(0x00); db(0x20); db(0x21); db(0x7c); db(0x00); db(0x01); db(0x00); db(0x00); db(0x00); db(0x24); db(0x31); db(0x7c); db(0x01); db(0x04); db(0x00); db(0x10); db(0x31); db(0x7c); db(0x07); db(0xdb); db(0x00); db(0x14); @@ -54,7 +55,7 @@ db(0x01); db(0xa8); db(0x7c); db(0x00); db(0xbc); db(0x6d); db(0x01); db(0x0e); db(0x64); db(0x32); db(0x2f); db(0x06); db(0x2e); db(0x2d); db(0x01); db(0x10); db(0x4a); db(0x45); db(0x67); db(0x04); db(0x08); db(0xc7); db(0x00); db(0x02); - db(0x2f); db(0x0b); db(0x20); db(0x4b); db(0x61); db(0x00); db(0x07); db(0x76); + db(0x2f); db(0x0b); db(0x20); db(0x4b); db(0x61); db(0x00); db(0x09); db(0x30); db(0x26); db(0x5f); db(0x27); db(0x41); db(0x01); db(0xa4); db(0x0c); db(0x80); db(0xff); db(0xff); db(0xff); db(0xfe); db(0x67); db(0x08); db(0x48); db(0x46); db(0x52); db(0x46); db(0x48); db(0x46); db(0x60); db(0xd6); db(0x2c); db(0x1f); @@ -65,678 +66,733 @@ db(0xfe); db(0x62); db(0x0c); db(0x6e); db(0x00); db(0x22); db(0x00); db(0x14); db(0x65); db(0x6e); db(0x78); db(0x03); db(0x0c); db(0x6e); db(0x00); db(0x24); db(0x00); db(0x14); db(0x65); db(0x04); db(0x00); db(0x44); db(0x01); db(0x00); - db(0x30); db(0x3c); db(0xff); db(0x80); db(0x61); db(0x00); db(0x18); db(0x56); + db(0x30); db(0x3c); db(0xff); db(0x80); db(0x61); db(0x00); db(0x1d); db(0x3e); db(0x4e); db(0x90); db(0x2a); db(0x00); db(0x20); db(0x49); db(0x20); db(0x01); db(0x67); db(0x0c); db(0x22); db(0x04); db(0x74); db(0xfb); db(0x43); db(0xfa); - db(0x19); db(0x9f); db(0x4e); db(0xae); db(0xfd); db(0x96); db(0x43); db(0xf9); + db(0x1e); db(0x9d); db(0x4e); db(0xae); db(0xfd); db(0x96); db(0x43); db(0xf9); db(0x00); db(0x21); db(0x00); db(0x00); db(0x4e); db(0xae); db(0xfd); db(0xea); db(0x4a); db(0x80); db(0x66); db(0x18); db(0x22); db(0x04); db(0x74); db(0xf6); db(0x20); db(0x7c); db(0x00); db(0x20); db(0x00); db(0x00); db(0x20); db(0x05); db(0x90); db(0x88); db(0x65); db(0x08); db(0x67); db(0x06); db(0x93); db(0xc9); - db(0x4e); db(0xae); db(0xfd); db(0x96); db(0x41); db(0xfa); db(0x18); db(0xe3); + db(0x4e); db(0xae); db(0xfd); db(0x96); db(0x41); db(0xfa); db(0x1d); db(0xc3); db(0x43); db(0xfa); db(0x00); db(0x54); db(0x70); db(0x0a); db(0x61); db(0x00); - db(0x0c); db(0xcc); db(0x22); db(0x40); db(0x72); db(0x01); db(0x30); db(0x3c); - db(0xff); db(0x48); db(0x61); db(0x00); db(0x18); db(0x00); db(0x4e); db(0x90); + db(0x0e); db(0x86); db(0x22); db(0x40); db(0x72); db(0x01); db(0x30); db(0x3c); + db(0xff); db(0x48); db(0x61); db(0x00); db(0x1c); db(0xe8); db(0x4e); db(0x90); db(0x4c); db(0xdf); db(0x7f); db(0xff); db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x38); db(0x22); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x24); db(0x00); db(0x28); db(0x01); db(0x26); db(0x09); db(0x24); db(0x48); db(0x43); db(0xfa); - db(0x18); db(0xea); db(0x70); db(0x00); db(0x4e); db(0xae); db(0xfd); db(0xd8); + db(0x1d); db(0xe8); db(0x70); db(0x00); db(0x4e); db(0xae); db(0xfd); db(0xd8); db(0x4a); db(0x80); db(0x67); db(0x14); db(0x2c); db(0x40); db(0x22); db(0x0a); db(0xe4); db(0x8b); db(0x4e); db(0xae); db(0xff); db(0x76); db(0x22); db(0x4e); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x4e); db(0xae); db(0xfe); db(0x62); db(0x4c); db(0xdf); db(0x44); db(0x1c); db(0x4e); db(0x75); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x70); db(0x00); db(0x08); db(0xc0); db(0x00); db(0x0d); - db(0x4e); db(0xae); db(0xfe); db(0xc2); db(0x41); db(0xfa); db(0x18); db(0x8e); + db(0x4e); db(0xae); db(0xfe); db(0xc2); db(0x41); db(0xfa); db(0x1d); db(0x8c); db(0x43); db(0xfa); db(0x00); db(0x16); db(0x70); db(0x0f); db(0x22); db(0x3c); db(0x00); db(0x00); db(0x1f); db(0x40); db(0x61); db(0x00); db(0xff); db(0xa8); db(0x60); db(0xdc); db(0x00); db(0x00); db(0x00); db(0x00); db(0x00); db(0x10); db(0x00); db(0x00); db(0x00); db(0x00); db(0x72); db(0x02); db(0x30); db(0x3c); - db(0xff); db(0x48); db(0x61); db(0x00); db(0x17); db(0x88); db(0x4e); db(0x90); - db(0x22); db(0x00); db(0x6b); db(0x04); db(0x61); db(0x00); db(0x08); db(0x40); - db(0x70); db(0x00); db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x00); db(0x20); - db(0x30); db(0x3c); db(0xff); db(0x50); db(0x61); db(0x00); db(0x17); db(0x6e); - db(0x70); db(0x00); db(0x4e); db(0x90); db(0x4a); db(0x80); db(0x67); db(0x00); - db(0x00); db(0xa2); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x30); db(0x3c); - db(0xff); db(0x50); db(0x61); db(0x00); db(0x17); db(0x58); db(0x70); db(0x02); - db(0x4e); db(0x90); db(0x0c); db(0x40); db(0x00); db(0x01); db(0x6d); db(0x00); - db(0x00); db(0x7c); db(0x6e); db(0x06); db(0x4e); db(0xae); db(0xfe); db(0x92); - db(0x60); db(0xe4); db(0x0c); db(0x40); db(0x00); db(0x02); db(0x6e); db(0x08); - db(0x20); db(0x01); db(0x4e); db(0xae); db(0xfe); db(0xbc); db(0x60); db(0xd6); - db(0x0c); db(0x40); db(0x00); db(0x03); db(0x6e); db(0x06); db(0x4e); db(0xae); - db(0xfe); db(0x86); db(0x60); db(0xca); db(0x0c); db(0x40); db(0x00); db(0x04); - db(0x6e); db(0x06); db(0x4e); db(0xae); db(0xff); db(0x4c); db(0x60); db(0xbe); - db(0x0c); db(0x40); db(0x00); db(0x05); db(0x6e); db(0x46); db(0x48); db(0xe7); - db(0x00); db(0xc0); db(0x70); db(0x26); db(0x22); db(0x3c); db(0x00); db(0x01); - db(0x00); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x4c); db(0xdf); - db(0x03); db(0x00); db(0x24); db(0x40); db(0x15); db(0x7c); db(0x00); db(0x08); - db(0x00); db(0x08); db(0x25); db(0x48); db(0x00); db(0x0e); db(0x35); db(0x7c); - db(0x00); db(0x26); db(0x00); db(0x12); db(0x25); db(0x7c); db(0x40); db(0x00); - db(0x00); db(0x00); db(0x00); db(0x14); db(0x35); db(0x7c); db(0x12); db(0x34); - db(0x00); db(0x18); db(0x25); db(0x49); db(0x00); db(0x1a); db(0x20); db(0x69); - db(0x00); db(0x10); db(0x22); db(0x4a); db(0x4e); db(0xae); db(0xfe); db(0x92); - db(0x60); db(0x00); db(0xff); db(0x74); db(0x30); db(0x3c); db(0xff); db(0x50); - db(0x61); db(0x00); db(0x16); db(0xca); db(0x70); db(0x04); db(0x4e); db(0x90); - db(0x70); db(0x01); db(0x4c); db(0xdf); db(0x04); db(0x00); db(0x4e); db(0x75); - db(0x48); db(0xe7); db(0xc0); db(0xe0); db(0x30); db(0x3c); db(0xff); db(0x38); - db(0x72); db(0x12); db(0x61); db(0x00); db(0x16); db(0xb0); db(0x4e); db(0x90); - db(0x24); db(0x40); db(0x70); db(0x16); db(0x22); db(0x3c); db(0x00); db(0x01); - db(0x00); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x22); db(0x40); - db(0x13); db(0x7c); db(0x00); db(0x02); db(0x00); db(0x08); db(0x13); db(0x7c); - db(0x00); db(0xf6); db(0x00); db(0x09); db(0x41); db(0xfa); db(0x17); db(0x3d); - db(0x23); db(0x48); db(0x00); db(0x0a); db(0x41); db(0xfa); db(0x00); db(0x16); - db(0x23); db(0x48); db(0x00); db(0x12); db(0x23); db(0x4a); db(0x00); db(0x0e); - db(0x70); db(0x05); db(0x4e); db(0xae); db(0xff); db(0x58); db(0x4c); db(0xdf); - db(0x07); db(0x03); db(0x4e); db(0x75); db(0x52); db(0x91); db(0x70); db(0x00); - db(0x4e); db(0x75); db(0x48); db(0xe7); db(0xc0); db(0xc0); db(0x61); db(0x00); - db(0xfc); db(0x54); db(0x70); db(0x1a); db(0x22); db(0x3c); db(0x00); db(0x01); - db(0x00); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x22); db(0x40); - db(0x41); db(0xfa); db(0x17); db(0x10); db(0x23); db(0x48); db(0x00); db(0x0a); - db(0x41); db(0xfa); db(0xfe); db(0xd2); db(0x23); db(0x48); db(0x00); db(0x0e); - db(0x41); db(0xfa); db(0xfe); db(0xca); db(0x23); db(0x48); db(0x00); db(0x12); - db(0x33); db(0x7c); db(0x02); db(0x14); db(0x00); db(0x08); db(0x70); db(0x03); - db(0x4e); db(0xae); db(0xff); db(0x58); db(0x61); db(0x00); db(0xff); db(0x72); - db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x04); db(0x61); db(0x00); - db(0x16); db(0x24); db(0x4e); db(0x90); db(0x4a); db(0x80); db(0x67); db(0x04); - db(0x61); db(0x00); db(0x0b); db(0x36); db(0x4c); db(0xdf); db(0x03); db(0x03); - db(0x4e); db(0x75); db(0x48); db(0xe7); db(0xc0); db(0xf2); db(0x2c); db(0x78); - db(0x00); db(0x04); db(0x24); db(0x48); db(0x26); db(0x49); db(0x20); db(0x3c); - db(0x00); db(0x00); db(0x00); db(0xbe); db(0x22); db(0x3c); db(0x00); db(0x01); - db(0x00); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x20); db(0x40); - db(0x70); db(0x00); db(0x43); db(0xeb); db(0x01); db(0xac); db(0x11); db(0xb1); - db(0x00); db(0x00); db(0x00); db(0x0e); db(0x52); db(0x40); db(0x0c); db(0x40); - db(0x00); db(0x8c); db(0x66); db(0xf2); db(0x20); db(0x0a); db(0xe4); db(0x88); - db(0x21); db(0x40); db(0x00); db(0x36); db(0x22); db(0x48); db(0x41); db(0xfa); - db(0x16); db(0x92); db(0x23); db(0x48); db(0x00); db(0x0a); db(0x20); db(0x6b); - db(0x01); db(0x9c); db(0x41); db(0xe8); db(0x00); db(0x12); db(0x4e); db(0xae); - db(0xff); db(0x10); db(0x4c); db(0xdf); db(0x4f); db(0x03); db(0x4e); db(0x75); - db(0x48); db(0xe7); db(0x7f); db(0x7e); db(0x2c); db(0x78); db(0x00); db(0x04); - db(0x24); db(0x48); db(0x0c); db(0x9a); db(0x00); db(0x00); db(0x03); db(0xf3); - db(0x66); db(0x00); db(0x00); db(0xe4); db(0x50); db(0x8a); db(0x2e); db(0x2a); - db(0x00); db(0x04); db(0x9e); db(0x92); db(0x50); db(0x8a); db(0x52); db(0x87); - db(0x26); db(0x4a); db(0x20); db(0x07); db(0xd0); db(0x80); db(0xd0); db(0x80); - db(0xd7); db(0xc0); db(0x28); db(0x4a); db(0x9b); db(0xcd); db(0x7c); db(0x00); - db(0x24); db(0x12); db(0x72); db(0x01); db(0x08); db(0x02); db(0x00); db(0x1e); - db(0x67); db(0x04); db(0x08); db(0xc1); db(0x00); db(0x01); db(0x08); db(0xc1); - db(0x00); db(0x10); db(0xe5); db(0x8a); db(0x66); db(0x04); db(0x42); db(0x9a); - db(0x60); db(0x20); db(0x50); db(0x82); db(0x20); db(0x02); db(0x4e); db(0xae); - db(0xff); db(0x3a); db(0x4a); db(0x80); db(0x67); db(0x00); db(0x00); db(0xa0); - db(0x20); db(0x40); db(0x20); db(0xc2); db(0x24); db(0xc8); db(0x22); db(0x0d); - db(0x67); db(0x06); db(0x20); db(0x08); db(0xe4); db(0x88); db(0x2a); db(0x80); - db(0x2a); db(0x48); db(0x52); db(0x86); db(0xbe); db(0x86); db(0x66); db(0xc0); - db(0x7c); db(0x00); db(0x22); db(0x06); db(0xd2); db(0x81); db(0xd2); db(0x81); - db(0x20); db(0x74); db(0x18); db(0x00); db(0x58); db(0x88); db(0x26); db(0x1b); - db(0x28); db(0x1b); db(0xe5); db(0x8c); db(0x0c); db(0x83); db(0x00); db(0x00); - db(0x03); db(0xe9); db(0x67); db(0x08); db(0x0c); db(0x83); db(0x00); db(0x00); - db(0x03); db(0xea); db(0x66); db(0x0c); db(0x20); db(0x04); db(0x4a); db(0x80); - db(0x67); db(0x0e); db(0x10); db(0xdb); db(0x53); db(0x80); db(0x60); db(0xf6); - db(0x0c); db(0x83); db(0x00); db(0x00); db(0x03); db(0xeb); db(0x66); db(0x4e); - db(0x26); db(0x1b); db(0x0c); db(0x83); db(0x00); db(0x00); db(0x03); db(0xec); - db(0x66); db(0x28); db(0x22); db(0x06); db(0xd2); db(0x81); db(0xd2); db(0x81); - db(0x20); db(0x74); db(0x18); db(0x00); db(0x58); db(0x88); db(0x20); db(0x1b); - db(0x67); db(0xe6); db(0x22); db(0x1b); db(0xd2); db(0x81); db(0xd2); db(0x81); - db(0x26); db(0x34); db(0x18); db(0x00); db(0x58); db(0x83); db(0x24); db(0x1b); - db(0xd7); db(0xb0); db(0x28); db(0x00); db(0x53); db(0x80); db(0x66); db(0xf6); - db(0x60); db(0xe4); db(0x0c); db(0x83); db(0x00); db(0x00); db(0x03); db(0xf2); - db(0x66); db(0x14); db(0x52); db(0x86); db(0xbe); db(0x86); db(0x66); db(0x00); - db(0xff); db(0x8a); db(0x7e); db(0x01); db(0x20); db(0x54); db(0x20); db(0x07); - db(0x4c); db(0xdf); db(0x7e); db(0xfe); db(0x4e); db(0x75); db(0x91); db(0xc8); - db(0x7e); db(0x00); db(0x60); db(0xf2); db(0x48); db(0xe7); db(0x40); db(0xf2); - db(0x26); db(0x48); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x41); db(0xee); - db(0x01); db(0x50); db(0x20); db(0x50); db(0x4a); db(0x90); db(0x67); db(0x1a); - db(0x22); db(0x68); db(0x00); db(0x0a); db(0x45); db(0xfa); db(0x15); db(0xed); - db(0x10); db(0x19); db(0x12); db(0x1a); db(0xb0); db(0x01); db(0x66); db(0x06); - db(0x4a); db(0x00); db(0x67); db(0x46); db(0x60); db(0xf2); db(0x20); db(0x50); - db(0x60); db(0xe2); db(0x70); db(0x20); db(0x22); db(0x3c); db(0x00); db(0x01); - db(0x00); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x24); db(0x40); - db(0x15); db(0x7c); db(0x00); db(0x08); db(0x00); db(0x08); db(0x41); db(0xfa); - db(0x15); db(0xc3); db(0x25); db(0x48); db(0x00); db(0x0a); db(0x41); db(0xfa); - db(0x15); db(0x32); db(0x25); db(0x48); db(0x00); db(0x0e); db(0x41); db(0xea); - db(0x00); db(0x12); db(0x20); db(0x88); db(0x58); db(0x90); db(0x21); db(0x48); - db(0x00); db(0x08); db(0x41); db(0xee); db(0x01); db(0x50); db(0x22); db(0x4a); - db(0x4e); db(0xae); db(0xff); db(0x0a); db(0x20); db(0x4a); db(0x27); db(0x48); - db(0x01); db(0xa0); db(0x20); db(0x08); db(0x4c); db(0xdf); db(0x4f); db(0x02); - db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x01); db(0x02); db(0x2e); db(0x00); - db(0x4a); db(0x2b); db(0x00); db(0x4c); db(0x67); db(0x7c); db(0x2c); db(0x6b); - db(0x00); db(0xa0); db(0x0c); db(0x6e); db(0x00); db(0x25); db(0x00); db(0x14); - db(0x65); db(0x3e); db(0x72); db(0x0e); db(0x4e); db(0xae); db(0xfd); db(0x66); - db(0x02); db(0x80); db(0xff); db(0xff); db(0xff); db(0xfe); db(0x67); db(0x62); - db(0x08); db(0x07); db(0x00); db(0x00); db(0x67); db(0x0a); db(0x41); db(0xeb); - db(0x00); db(0x20); db(0x22); db(0x08); db(0x4e); db(0xae); db(0xfd); db(0x5a); + db(0xff); db(0x48); db(0x61); db(0x00); db(0x1c); db(0x70); db(0x4e); db(0x90); + db(0x22); db(0x00); db(0x6b); db(0x04); db(0x61); db(0x00); db(0x09); db(0xfa); + db(0x70); db(0x00); db(0x4e); db(0x75); db(0x2c); db(0x78); db(0x00); db(0x04); + db(0x20); db(0x3c); db(0x00); db(0x00); db(0x01); db(0x00); db(0x4e); db(0xae); + db(0xfe); db(0xc2); db(0x7e); db(0x00); db(0x20); db(0x3c); db(0x00); db(0x00); + db(0xf0); db(0x00); db(0x61); db(0x00); db(0x1c); db(0x48); db(0x22); db(0x48); + db(0x20); db(0x3c); db(0x00); db(0x00); db(0x40); db(0x00); db(0x61); db(0x00); + db(0x1c); db(0x3c); db(0x7c); db(0x03); db(0x4a); db(0x29); db(0x00); db(0x03); + db(0x67); db(0x48); db(0x0c); db(0x29); db(0x00); db(0xfe); db(0x00); db(0x07); + db(0x66); db(0x40); db(0x52); db(0x87); db(0x49); db(0xe8); db(0x00); db(0x50); + db(0x4b); db(0xe9); db(0x00); db(0x04); db(0x48); db(0xe7); db(0x03); db(0xce); + db(0x38); db(0x15); db(0x4c); db(0xec); db(0x07); db(0x00); db(0x00); db(0x04); + db(0x4c); db(0xec); db(0x00); db(0x07); db(0x00); db(0x04); db(0x0c); db(0x44); + db(0x00); db(0x12); db(0x66); db(0x06); db(0x61); db(0x00); db(0x1b); db(0x7e); + db(0x60); db(0x0a); db(0x0c); db(0x44); db(0x00); db(0x13); db(0x66); db(0x04); + db(0x61); db(0x00); db(0x1b); db(0x8c); db(0x4c); db(0xdf); db(0x73); db(0xc0); + db(0x29); db(0x40); db(0x00); db(0x04); db(0x1b); db(0x7c); db(0x00); db(0x02); + db(0x00); db(0x03); db(0xd0); db(0xfc); db(0x20); db(0x00); db(0xd2); db(0xfc); + db(0x00); db(0x08); db(0x51); db(0xce); db(0xff); db(0xa8); db(0x4a); db(0x87); + db(0x67); db(0x00); db(0xff); db(0x7e); db(0x60); db(0x00); db(0xff); db(0x84); + db(0x2c); db(0x78); db(0x00); db(0x04); db(0x20); db(0x3c); db(0x00); db(0x00); + db(0x01); db(0x00); db(0x4e); db(0xae); db(0xfe); db(0xc2); db(0x7e); db(0x0a); + db(0x30); db(0x3c); db(0xff); db(0x50); db(0x61); db(0x00); db(0x1b); db(0xbe); + db(0x20); db(0x07); db(0x4e); db(0x90); db(0x4a); db(0x80); db(0x67); db(0x00); + db(0xff); db(0xe4); db(0x52); db(0x47); db(0x0c); db(0x40); db(0x00); db(0x01); + db(0x6d); db(0x00); db(0xff); db(0xe6); db(0x6e); db(0x06); db(0x4e); db(0xae); + db(0xfe); db(0x92); db(0x60); db(0xdc); db(0x0c); db(0x40); db(0x00); db(0x02); + db(0x6e); db(0x08); db(0x20); db(0x01); db(0x4e); db(0xae); db(0xfe); db(0xbc); + db(0x60); db(0xce); db(0x0c); db(0x40); db(0x00); db(0x03); db(0x6e); db(0x06); + db(0x4e); db(0xae); db(0xfe); db(0x86); db(0x60); db(0xc2); db(0x0c); db(0x40); + db(0x00); db(0x04); db(0x6e); db(0x06); db(0x4e); db(0xae); db(0xff); db(0x4c); + db(0x60); db(0xb6); db(0x0c); db(0x40); db(0x00); db(0x05); db(0x6e); db(0xb0); + db(0x48); db(0xe7); db(0x00); db(0xc0); db(0x70); db(0x26); db(0x22); db(0x3c); + db(0x00); db(0x01); db(0x00); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); + db(0x4c); db(0xdf); db(0x03); db(0x00); db(0x24); db(0x40); db(0x15); db(0x7c); + db(0x00); db(0x08); db(0x00); db(0x08); db(0x25); db(0x48); db(0x00); db(0x0e); + db(0x35); db(0x7c); db(0x00); db(0x26); db(0x00); db(0x12); db(0x25); db(0x7c); + db(0x40); db(0x00); db(0x00); db(0x00); db(0x00); db(0x14); db(0x35); db(0x7c); + db(0x12); db(0x34); db(0x00); db(0x18); db(0x25); db(0x49); db(0x00); db(0x1a); + db(0x20); db(0x69); db(0x00); db(0x10); db(0x22); db(0x4a); db(0x4e); db(0xae); + db(0xfe); db(0x92); db(0x60); db(0x00); db(0xff); db(0x6c); db(0x70); db(0x00); + db(0x20); db(0x59); db(0x4a); db(0x10); db(0x67); db(0x10); db(0x2c); db(0x59); + db(0x22); db(0x51); db(0x20); db(0x3c); db(0x00); db(0x00); db(0x01); db(0x00); + db(0x4e); db(0xae); db(0xfe); db(0xbc); db(0x70); db(0x01); db(0x4a); db(0x40); + db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x00); db(0x20); db(0x4a); db(0x11); + db(0x67); db(0x00); db(0x00); db(0xb4); db(0x30); db(0x3c); db(0xff); db(0x50); + db(0x61); db(0x00); db(0x1b); db(0x02); db(0x70); db(0x00); db(0x4e); db(0x90); + db(0x4a); db(0x80); db(0x67); db(0x00); db(0x00); db(0xa2); db(0x2c); db(0x78); + db(0x00); db(0x04); db(0x30); db(0x3c); db(0xff); db(0x50); db(0x61); db(0x00); + db(0x1a); db(0xec); db(0x70); db(0x02); db(0x4e); db(0x90); db(0x0c); db(0x40); + db(0x00); db(0x01); db(0x6d); db(0x00); db(0x00); db(0x7c); db(0x6e); db(0x06); + db(0x4e); db(0xae); db(0xfe); db(0x92); db(0x60); db(0xe4); db(0x0c); db(0x40); + db(0x00); db(0x02); db(0x6e); db(0x08); db(0x20); db(0x01); db(0x4e); db(0xae); + db(0xfe); db(0xbc); db(0x60); db(0xd6); db(0x0c); db(0x40); db(0x00); db(0x03); + db(0x6e); db(0x06); db(0x4e); db(0xae); db(0xfe); db(0x86); db(0x60); db(0xca); + db(0x0c); db(0x40); db(0x00); db(0x04); db(0x6e); db(0x06); db(0x4e); db(0xae); + db(0xff); db(0x4c); db(0x60); db(0xbe); db(0x0c); db(0x40); db(0x00); db(0x05); + db(0x6e); db(0x46); db(0x48); db(0xe7); db(0x00); db(0xc0); db(0x70); db(0x26); + db(0x22); db(0x3c); db(0x00); db(0x01); db(0x00); db(0x01); db(0x4e); db(0xae); + db(0xff); db(0x3a); db(0x4c); db(0xdf); db(0x03); db(0x00); db(0x24); db(0x40); + db(0x15); db(0x7c); db(0x00); db(0x08); db(0x00); db(0x08); db(0x25); db(0x48); + db(0x00); db(0x0e); db(0x35); db(0x7c); db(0x00); db(0x26); db(0x00); db(0x12); + db(0x25); db(0x7c); db(0x40); db(0x00); db(0x00); db(0x00); db(0x00); db(0x14); + db(0x35); db(0x7c); db(0x12); db(0x34); db(0x00); db(0x18); db(0x25); db(0x49); + db(0x00); db(0x1a); db(0x20); db(0x69); db(0x00); db(0x10); db(0x22); db(0x4a); + db(0x4e); db(0xae); db(0xfe); db(0x92); db(0x60); db(0x00); db(0xff); db(0x74); + db(0x30); db(0x3c); db(0xff); db(0x50); db(0x61); db(0x00); db(0x1a); db(0x5e); + db(0x70); db(0x04); db(0x4e); db(0x90); db(0x70); db(0x01); db(0x4c); db(0xdf); + db(0x04); db(0x00); db(0x4e); db(0x75); db(0x48); db(0xe7); db(0xf0); db(0xe0); + db(0x24); db(0x00); db(0x26); db(0x01); db(0x30); db(0x3c); db(0xff); db(0x38); + db(0x72); db(0x12); db(0x61); db(0x00); db(0x1a); db(0x40); db(0x20); db(0x02); + db(0x24); db(0x03); db(0x4e); db(0x90); db(0x24); db(0x40); db(0x70); db(0x22); + db(0x22); db(0x3c); db(0x00); db(0x01); db(0x00); db(0x01); db(0x4e); db(0xae); + db(0xff); db(0x3a); db(0x22); db(0x40); db(0x41); db(0xe9); db(0x00); db(0x16); + db(0x20); db(0x8a); db(0x21); db(0x42); db(0x00); db(0x04); db(0x21); db(0x43); + db(0x00); db(0x08); db(0x23); db(0x48); db(0x00); db(0x0e); db(0x13); db(0x7c); + db(0x00); db(0x02); db(0x00); db(0x08); db(0x13); db(0x7c); db(0x00); db(0xf6); + db(0x00); db(0x09); db(0x41); db(0xfa); db(0x1a); db(0xb7); db(0x23); db(0x48); + db(0x00); db(0x0a); db(0x41); db(0xfa); db(0x00); db(0x12); db(0x23); db(0x48); + db(0x00); db(0x12); db(0x70); db(0x05); db(0x4e); db(0xae); db(0xff); db(0x58); + db(0x4c); db(0xdf); db(0x07); db(0x0f); db(0x4e); db(0x75); db(0x20); db(0x51); + db(0x52); db(0x90); db(0x70); db(0x00); db(0x4e); db(0x75); db(0x48); db(0xe7); + db(0xf1); db(0xe0); db(0x2e); db(0x00); db(0x61); db(0x00); db(0xfa); db(0xe6); + db(0x20); db(0x3c); db(0x00); db(0x00); db(0xff); db(0xfc); db(0x61); db(0x00); + db(0x19); db(0xd4); db(0x24); db(0x48); db(0x74); db(0x00); db(0x08); db(0x07); + db(0x00); db(0x00); db(0x67); db(0x10); db(0x41); db(0xfa); db(0x1a); db(0x9e); + db(0x43); db(0xfa); db(0xfd); db(0xee); db(0x70); db(0x14); db(0x61); db(0x00); + db(0x0b); db(0x4e); db(0x24); db(0x00); db(0x76); db(0x00); db(0x08); db(0x07); + db(0x00); db(0x01); db(0x67); db(0x10); db(0x41); db(0xfa); db(0x1a); db(0x94); + db(0x43); db(0xfa); db(0xfd); db(0x4a); db(0x70); db(0x19); db(0x61); db(0x00); + db(0x0b); db(0x36); db(0x26); db(0x00); db(0x70); db(0x2a); db(0x22); db(0x3c); + db(0x00); db(0x01); db(0x00); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); + db(0x22); db(0x40); db(0x41); db(0xe9); db(0x00); db(0x1a); db(0x20); db(0xca); + db(0x20); db(0xce); db(0x20); db(0xc2); db(0x20); db(0x83); db(0x41); db(0xfa); + db(0x1a); db(0x42); db(0x23); db(0x48); db(0x00); db(0x0a); db(0x45); db(0xe9); + db(0x00); db(0x1a); db(0x23); db(0x4a); db(0x00); db(0x0e); db(0x41); db(0xfa); + db(0xfe); db(0x46); db(0x23); db(0x48); db(0x00); db(0x12); db(0x33); db(0x7c); + db(0x02); db(0x14); db(0x00); db(0x08); db(0x70); db(0x03); db(0x4e); db(0xae); + db(0xff); db(0x58); db(0x20); db(0x02); db(0x22); db(0x03); db(0x61); db(0x00); + db(0xff); db(0x0c); db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x04); + db(0x61); db(0x00); db(0x19); db(0x52); db(0x4e); db(0x90); db(0x4a); db(0x80); + db(0x67); db(0x04); db(0x61); db(0x00); db(0x0b); db(0x36); db(0x4c); db(0xdf); + db(0x07); db(0x8f); db(0x4e); db(0x75); db(0x48); db(0xe7); db(0xc0); db(0xf2); + db(0x2c); db(0x78); db(0x00); db(0x04); db(0x24); db(0x48); db(0x26); db(0x49); + db(0x20); db(0x3c); db(0x00); db(0x00); db(0x00); db(0xbe); db(0x22); db(0x3c); + db(0x00); db(0x01); db(0x00); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); + db(0x20); db(0x40); db(0x70); db(0x00); db(0x43); db(0xeb); db(0x01); db(0xac); + db(0x11); db(0xb1); db(0x00); db(0x00); db(0x00); db(0x0e); db(0x52); db(0x40); + db(0x0c); db(0x40); db(0x00); db(0x8c); db(0x66); db(0xf2); db(0x20); db(0x0a); + db(0xe4); db(0x88); db(0x21); db(0x40); db(0x00); db(0x36); db(0x22); db(0x48); + db(0x41); db(0xfa); db(0x19); db(0xc0); db(0x23); db(0x48); db(0x00); db(0x0a); + db(0x20); db(0x6b); db(0x01); db(0x9c); db(0x41); db(0xe8); db(0x00); db(0x12); + db(0x4e); db(0xae); db(0xff); db(0x10); db(0x4c); db(0xdf); db(0x4f); db(0x03); + db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x7f); db(0x7e); db(0x2c); db(0x78); + db(0x00); db(0x04); db(0x24); db(0x48); db(0x0c); db(0x9a); db(0x00); db(0x00); + db(0x03); db(0xf3); db(0x66); db(0x00); db(0x00); db(0xe4); db(0x50); db(0x8a); + db(0x2e); db(0x2a); db(0x00); db(0x04); db(0x9e); db(0x92); db(0x50); db(0x8a); + db(0x52); db(0x87); db(0x26); db(0x4a); db(0x20); db(0x07); db(0xd0); db(0x80); + db(0xd0); db(0x80); db(0xd7); db(0xc0); db(0x28); db(0x4a); db(0x9b); db(0xcd); + db(0x7c); db(0x00); db(0x24); db(0x12); db(0x72); db(0x01); db(0x08); db(0x02); + db(0x00); db(0x1e); db(0x67); db(0x04); db(0x08); db(0xc1); db(0x00); db(0x01); + db(0x08); db(0xc1); db(0x00); db(0x10); db(0xe5); db(0x8a); db(0x66); db(0x04); + db(0x42); db(0x9a); db(0x60); db(0x20); db(0x50); db(0x82); db(0x20); db(0x02); + db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x4a); db(0x80); db(0x67); db(0x00); + db(0x00); db(0xa0); db(0x20); db(0x40); db(0x20); db(0xc2); db(0x24); db(0xc8); + db(0x22); db(0x0d); db(0x67); db(0x06); db(0x20); db(0x08); db(0xe4); db(0x88); + db(0x2a); db(0x80); db(0x2a); db(0x48); db(0x52); db(0x86); db(0xbe); db(0x86); + db(0x66); db(0xc0); db(0x7c); db(0x00); db(0x22); db(0x06); db(0xd2); db(0x81); + db(0xd2); db(0x81); db(0x20); db(0x74); db(0x18); db(0x00); db(0x58); db(0x88); + db(0x26); db(0x1b); db(0x28); db(0x1b); db(0xe5); db(0x8c); db(0x0c); db(0x83); + db(0x00); db(0x00); db(0x03); db(0xe9); db(0x67); db(0x08); db(0x0c); db(0x83); + db(0x00); db(0x00); db(0x03); db(0xea); db(0x66); db(0x0c); db(0x20); db(0x04); + db(0x4a); db(0x80); db(0x67); db(0x0e); db(0x10); db(0xdb); db(0x53); db(0x80); + db(0x60); db(0xf6); db(0x0c); db(0x83); db(0x00); db(0x00); db(0x03); db(0xeb); + db(0x66); db(0x4e); db(0x26); db(0x1b); db(0x0c); db(0x83); db(0x00); db(0x00); + db(0x03); db(0xec); db(0x66); db(0x28); db(0x22); db(0x06); db(0xd2); db(0x81); + db(0xd2); db(0x81); db(0x20); db(0x74); db(0x18); db(0x00); db(0x58); db(0x88); + db(0x20); db(0x1b); db(0x67); db(0xe6); db(0x22); db(0x1b); db(0xd2); db(0x81); + db(0xd2); db(0x81); db(0x26); db(0x34); db(0x18); db(0x00); db(0x58); db(0x83); + db(0x24); db(0x1b); db(0xd7); db(0xb0); db(0x28); db(0x00); db(0x53); db(0x80); + db(0x66); db(0xf6); db(0x60); db(0xe4); db(0x0c); db(0x83); db(0x00); db(0x00); + db(0x03); db(0xf2); db(0x66); db(0x14); db(0x52); db(0x86); db(0xbe); db(0x86); + db(0x66); db(0x00); db(0xff); db(0x8a); db(0x7e); db(0x01); db(0x20); db(0x54); + db(0x20); db(0x07); db(0x4c); db(0xdf); db(0x7e); db(0xfe); db(0x4e); db(0x75); + db(0x91); db(0xc8); db(0x7e); db(0x00); db(0x60); db(0xf2); db(0x48); db(0xe7); + db(0x40); db(0xf2); db(0x26); db(0x48); db(0x2c); db(0x78); db(0x00); db(0x04); + db(0x41); db(0xee); db(0x01); db(0x50); db(0x20); db(0x50); db(0x4a); db(0x90); + db(0x67); db(0x1a); db(0x22); db(0x68); db(0x00); db(0x0a); db(0x45); db(0xfa); + db(0x19); db(0x31); db(0x10); db(0x19); db(0x12); db(0x1a); db(0xb0); db(0x01); + db(0x66); db(0x06); db(0x4a); db(0x00); db(0x67); db(0x46); db(0x60); db(0xf2); + db(0x20); db(0x50); db(0x60); db(0xe2); db(0x70); db(0x20); db(0x22); db(0x3c); + db(0x00); db(0x01); db(0x00); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); + db(0x24); db(0x40); db(0x15); db(0x7c); db(0x00); db(0x08); db(0x00); db(0x08); + db(0x41); db(0xfa); db(0x19); db(0x07); db(0x25); db(0x48); db(0x00); db(0x0a); + db(0x41); db(0xfa); db(0x18); db(0x60); db(0x25); db(0x48); db(0x00); db(0x0e); + db(0x41); db(0xea); db(0x00); db(0x12); db(0x20); db(0x88); db(0x58); db(0x90); + db(0x21); db(0x48); db(0x00); db(0x08); db(0x41); db(0xee); db(0x01); db(0x50); + db(0x22); db(0x4a); db(0x4e); db(0xae); db(0xff); db(0x0a); db(0x20); db(0x4a); + db(0x27); db(0x48); db(0x01); db(0xa0); db(0x20); db(0x08); db(0x4c); db(0xdf); + db(0x4f); db(0x02); db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x01); db(0x02); + db(0x2e); db(0x00); db(0x4a); db(0x2b); db(0x00); db(0x4c); db(0x67); db(0x7c); + db(0x2c); db(0x6b); db(0x00); db(0xa0); db(0x0c); db(0x6e); db(0x00); db(0x25); + db(0x00); db(0x14); db(0x65); db(0x3e); db(0x72); db(0x0e); db(0x4e); db(0xae); + db(0xfd); db(0x66); db(0x02); db(0x80); db(0xff); db(0xff); db(0xff); db(0xfe); + db(0x67); db(0x62); db(0x08); db(0x07); db(0x00); db(0x00); db(0x67); db(0x0a); + db(0x41); db(0xeb); db(0x00); db(0x20); db(0x22); db(0x08); db(0x4e); db(0xae); + db(0xfd); db(0x5a); db(0x08); db(0x07); db(0x00); db(0x01); db(0x67); db(0x12); + db(0x4a); db(0x2b); db(0x00); db(0x9e); db(0x66); db(0x0c); db(0x50); db(0xeb); + db(0x00); db(0x9e); db(0x22); db(0x2b); db(0x00); db(0xb4); db(0x4e); db(0xae); + db(0xfd); db(0x5a); db(0x72); db(0x0e); db(0x4e); db(0xae); db(0xfd); db(0x6c); + db(0x60); db(0x32); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x4e); db(0xae); + db(0xff); db(0x7c); db(0x08); db(0x07); db(0x00); db(0x00); db(0x67); db(0x08); + db(0x41); db(0xeb); db(0x00); db(0x20); db(0x61); db(0x00); db(0x00); db(0xac); db(0x08); db(0x07); db(0x00); db(0x01); db(0x67); db(0x12); db(0x4a); db(0x2b); db(0x00); db(0x9e); db(0x66); db(0x0c); db(0x50); db(0xeb); db(0x00); db(0x9e); - db(0x22); db(0x2b); db(0x00); db(0xb4); db(0x4e); db(0xae); db(0xfd); db(0x5a); - db(0x72); db(0x0e); db(0x4e); db(0xae); db(0xfd); db(0x6c); db(0x60); db(0x32); - db(0x2c); db(0x78); db(0x00); db(0x04); db(0x4e); db(0xae); db(0xff); db(0x7c); - db(0x08); db(0x07); db(0x00); db(0x00); db(0x67); db(0x08); db(0x41); db(0xeb); - db(0x00); db(0x20); db(0x61); db(0x00); db(0x00); db(0xac); db(0x08); db(0x07); - db(0x00); db(0x01); db(0x67); db(0x12); db(0x4a); db(0x2b); db(0x00); db(0x9e); - db(0x66); db(0x0c); db(0x50); db(0xeb); db(0x00); db(0x9e); db(0x20); db(0x6b); - db(0x00); db(0xb4); db(0x61); db(0x00); db(0x00); db(0x94); db(0x4e); db(0xae); - db(0xff); db(0x76); db(0x4c); db(0xdf); db(0x40); db(0x80); db(0x4e); db(0x75); - db(0x48); db(0xe7); db(0x01); db(0x22); db(0x2e); db(0x00); db(0x2c); db(0x6b); - db(0x00); db(0xa0); db(0x0c); db(0x6e); db(0x00); db(0x25); db(0x00); db(0x14); - db(0x65); db(0x3e); db(0x72); db(0x0e); db(0x4e); db(0xae); db(0xfd); db(0x66); - db(0x02); db(0x80); db(0xff); db(0xff); db(0xff); db(0xfe); db(0x67); db(0x62); - db(0x08); db(0x07); db(0x00); db(0x00); db(0x67); db(0x0a); db(0x41); db(0xeb); - db(0x00); db(0x20); db(0x22); db(0x08); db(0x4e); db(0xae); db(0xfd); db(0x60); + db(0x20); db(0x6b); db(0x00); db(0xb4); db(0x61); db(0x00); db(0x00); db(0x94); + db(0x4e); db(0xae); db(0xff); db(0x76); db(0x4c); db(0xdf); db(0x40); db(0x80); + db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x01); db(0x22); db(0x2e); db(0x00); + db(0x2c); db(0x6b); db(0x00); db(0xa0); db(0x0c); db(0x6e); db(0x00); db(0x25); + db(0x00); db(0x14); db(0x65); db(0x3e); db(0x72); db(0x0e); db(0x4e); db(0xae); + db(0xfd); db(0x66); db(0x02); db(0x80); db(0xff); db(0xff); db(0xff); db(0xfe); + db(0x67); db(0x62); db(0x08); db(0x07); db(0x00); db(0x00); db(0x67); db(0x0a); + db(0x41); db(0xeb); db(0x00); db(0x20); db(0x22); db(0x08); db(0x4e); db(0xae); + db(0xfd); db(0x60); db(0x08); db(0x07); db(0x00); db(0x01); db(0x67); db(0x12); + db(0x4a); db(0x2b); db(0x00); db(0x9e); db(0x67); db(0x0c); db(0x42); db(0x2b); + db(0x00); db(0x9e); db(0x22); db(0x2b); db(0x00); db(0xb4); db(0x4e); db(0xae); + db(0xfd); db(0x60); db(0x72); db(0x0e); db(0x4e); db(0xae); db(0xfd); db(0x6c); + db(0x60); db(0x32); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x4e); db(0xae); + db(0xff); db(0x7c); db(0x08); db(0x07); db(0x00); db(0x00); db(0x67); db(0x08); + db(0x41); db(0xeb); db(0x00); db(0x20); db(0x61); db(0x00); db(0x00); db(0x44); db(0x08); db(0x07); db(0x00); db(0x01); db(0x67); db(0x12); db(0x4a); db(0x2b); db(0x00); db(0x9e); db(0x67); db(0x0c); db(0x42); db(0x2b); db(0x00); db(0x9e); - db(0x22); db(0x2b); db(0x00); db(0xb4); db(0x4e); db(0xae); db(0xfd); db(0x60); - db(0x72); db(0x0e); db(0x4e); db(0xae); db(0xfd); db(0x6c); db(0x60); db(0x32); - db(0x2c); db(0x78); db(0x00); db(0x04); db(0x4e); db(0xae); db(0xff); db(0x7c); - db(0x08); db(0x07); db(0x00); db(0x00); db(0x67); db(0x08); db(0x41); db(0xeb); - db(0x00); db(0x20); db(0x61); db(0x00); db(0x00); db(0x44); db(0x08); db(0x07); - db(0x00); db(0x01); db(0x67); db(0x12); db(0x4a); db(0x2b); db(0x00); db(0x9e); - db(0x67); db(0x0c); db(0x42); db(0x2b); db(0x00); db(0x9e); db(0x20); db(0x6b); - db(0x00); db(0xb4); db(0x61); db(0x00); db(0x00); db(0x2c); db(0x4e); db(0xae); - db(0xff); db(0x76); db(0x4c); db(0xdf); db(0x44); db(0x80); db(0x4e); db(0x75); - db(0x22); db(0x48); db(0x20); db(0x6b); db(0x00); db(0xa0); db(0x20); db(0x68); - db(0x00); db(0x22); db(0x20); db(0x68); db(0x00); db(0x18); db(0xd1); db(0xc8); - db(0xd1); db(0xc8); db(0x22); db(0xa8); db(0x00); db(0x04); db(0x20); db(0x09); - db(0xe4); db(0x88); db(0x21); db(0x40); db(0x00); db(0x04); db(0x4e); db(0x75); - db(0x24); db(0x48); db(0x20); db(0x6b); db(0x00); db(0xa0); db(0x20); db(0x68); - db(0x00); db(0x22); db(0x20); db(0x68); db(0x00); db(0x18); db(0xd1); db(0xc8); - db(0xd1); db(0xc8); db(0x22); db(0x68); db(0x00); db(0x04); db(0xd3); db(0xc9); - db(0xd3); db(0xc9); db(0xb3); db(0xca); db(0x66); db(0x06); db(0x21); db(0x52); - db(0x00); db(0x04); db(0x60); db(0x18); db(0x20); db(0x09); db(0x67); db(0x0e); - db(0x20); db(0x11); db(0xd0); db(0x80); db(0xd0); db(0x80); db(0xb5); db(0xc0); - db(0x67); db(0x04); db(0x22); db(0x40); db(0x60); db(0xee); db(0x20); db(0x09); - db(0x67); db(0x02); db(0x22); db(0x92); db(0x4e); db(0x75); db(0x48); db(0xe7); - db(0x20); db(0x22); db(0x74); db(0x16); db(0x9f); db(0xc2); db(0x24); db(0x4f); - db(0x32); db(0x02); db(0x42); db(0x32); db(0x10); db(0xff); db(0x53); db(0x41); - db(0x66); db(0xf8); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x72); db(0x0f); - db(0x4a); db(0x80); db(0x67); db(0x02); db(0x72); db(0x10); db(0x15); db(0x41); - db(0x00); db(0x04); db(0x35); db(0x7c); db(0x08); db(0x00); db(0x00); db(0x08); - db(0x22); db(0x6b); db(0x00); db(0xa4); db(0x33); db(0x7c); db(0x00); db(0x0b); - db(0x00); db(0x1c); db(0x23); db(0x7c); db(0x00); db(0x00); db(0x00); db(0x16); - db(0x00); db(0x24); db(0x23); db(0x4a); db(0x00); db(0x28); db(0x13); db(0x7c); - db(0x00); db(0x01); db(0x00); db(0x1e); db(0x22); db(0x6b); db(0x00); db(0xa8); - db(0x33); db(0x7c); db(0x00); db(0x0a); db(0x00); db(0x1c); db(0x13); db(0x7c); - db(0x00); db(0x01); db(0x00); db(0x1e); db(0x4e); db(0xae); db(0xfe); db(0x38); - db(0x22); db(0x6b); db(0x00); db(0xa8); db(0x25); db(0x69); db(0x00); db(0x20); - db(0x00); db(0x0e); db(0x25); db(0x69); db(0x00); db(0x24); db(0x00); db(0x12); - db(0x22); db(0x6b); db(0x00); db(0xa4); db(0x4e); db(0xae); db(0xfe); db(0x38); - db(0xdf); db(0xc2); db(0x4c); db(0xdf); db(0x44); db(0x04); db(0x4e); db(0x75); - db(0x4a); db(0x00); db(0x67); db(0x26); db(0x4a); db(0x2b); db(0x00); db(0x4c); - db(0x66); db(0x36); db(0x70); db(0x00); db(0x4a); db(0x33); db(0x00); db(0x4d); - db(0x67); db(0x04); db(0x52); db(0x00); db(0x60); db(0xf6); db(0x17); db(0x40); - db(0x00); db(0x4c); db(0x67); db(0x24); db(0x20); db(0x01); db(0x61); db(0x00); - db(0xfd); db(0xf2); db(0x70); db(0x01); db(0x61); db(0x00); db(0xff); db(0x60); - db(0x60); db(0x16); db(0x4a); db(0x2b); db(0x00); db(0x4c); db(0x67); db(0x10); - db(0x42); db(0x2b); db(0x00); db(0x4c); db(0x20); db(0x01); db(0x61); db(0x00); - db(0xfe); db(0x68); db(0x70); db(0x00); db(0x61); db(0x00); db(0xff); db(0x48); - db(0x4e); db(0x75); db(0x4a); db(0xac); db(0x00); db(0x14); db(0x67); db(0x0a); - db(0x70); db(0x00); db(0x72); db(0x01); db(0x61); db(0x00); db(0xff); db(0xb2); - db(0x4e); db(0x75); db(0x70); db(0x01); db(0x72); db(0x03); db(0x61); db(0x00); - db(0xff); db(0xa8); db(0x4e); db(0x75); db(0x10); db(0x2b); db(0x00); db(0xac); - db(0x6b); db(0x0a); db(0x70); db(0x01); db(0x72); db(0x03); db(0x61); db(0x00); - db(0xff); db(0x98); db(0x4e); db(0x75); db(0x72); db(0x01); db(0x0c); db(0x00); - db(0x00); db(0xfe); db(0x66); db(0x02); db(0x72); db(0x03); db(0x70); db(0x00); - db(0x61); db(0x00); db(0xff); db(0x86); db(0x4e); db(0x75); db(0x20); db(0x6c); - db(0x00); db(0x24); db(0x4a); db(0x90); db(0x67); db(0x0c); db(0x4a); db(0xa8); - db(0x00); db(0x08); db(0x66); db(0x0a); db(0x4a); db(0xa8); db(0x00); db(0x0c); - db(0x66); db(0x04); db(0x70); db(0x01); db(0x4e); db(0x75); db(0x48); db(0xe7); - db(0x3f); db(0x3e); db(0x2a); db(0x48); db(0x24); db(0x6c); db(0x00); db(0x18); - db(0x2e); db(0x15); db(0x7a); db(0x00); db(0x4a); db(0x87); db(0x67); db(0x70); - db(0x20); db(0x0a); db(0x67); db(0x6c); db(0x7c); db(0x00); db(0x22); db(0x2d); - db(0x00); db(0x08); db(0x67); db(0x12); db(0x24); db(0x2a); db(0x00); db(0x04); - db(0x2c); db(0x6b); db(0x00); db(0xa0); db(0x4e); db(0xae); db(0xfc); db(0x34); - db(0x4a); db(0x80); db(0x66); db(0x02); db(0x50); db(0xc6); db(0x22); db(0x2d); - db(0x00); db(0x0c); db(0x67); db(0x1c); db(0x20); db(0x41); db(0x22); db(0x4a); - db(0x2f); db(0x0a); db(0x45); db(0xec); db(0x00); db(0x20); db(0x48); db(0x7a); - db(0x00); db(0x08); db(0x2f); db(0x28); db(0x00); db(0x08); db(0x4e); db(0x75); - db(0x24); db(0x5f); db(0x4a); db(0x80); db(0x66); db(0x02); db(0x50); db(0xc6); - db(0x4a); db(0x06); db(0x67); db(0x24); db(0x20); db(0x2a); db(0x00); db(0x04); - db(0x90); db(0x8a); db(0x4a); db(0x92); db(0x66); db(0x0a); db(0x20); db(0x05); - db(0x67); db(0x10); db(0x20); db(0x40); db(0x42); db(0x90); db(0x60); db(0x0a); - db(0x20); db(0x52); db(0x22); db(0x4a); db(0x22); db(0xd8); db(0x59); db(0x80); - db(0x6a); db(0xfa); db(0x53); db(0x95); db(0x53); db(0x87); db(0x60); db(0x94); - db(0x2a); db(0x0a); db(0x24); db(0x52); db(0x53); db(0x87); db(0x60); db(0x8c); - db(0x4c); db(0xdf); db(0x7c); db(0xfc); db(0x20); db(0x6c); db(0x00); db(0x24); - db(0x4a); db(0x90); db(0x4e); db(0x75); db(0x61); db(0x00); db(0xfc); db(0x76); - db(0x21); db(0x40); db(0x01); db(0x9c); db(0x2f); db(0x08); db(0x30); db(0x3c); - db(0xff); db(0xec); db(0x61); db(0x00); db(0x11); db(0x28); db(0x2a); db(0x50); - db(0x30); db(0x3c); db(0xff); db(0x28); db(0x61); db(0x00); db(0x11); db(0x1e); - db(0x22); db(0x48); db(0x20); db(0x5f); db(0x42); db(0xa8); db(0x01); db(0x90); - db(0x42); db(0xa8); db(0x01); db(0x94); db(0x4e); db(0x91); db(0x26); db(0x00); - db(0x0c); db(0x43); db(0xff); db(0xfe); db(0x67); db(0x00); db(0xf9); db(0x0e); - db(0x20); db(0x28); db(0x01); db(0x90); db(0x67); db(0x14); db(0x6b); db(0x12); - db(0x2f); db(0x08); db(0x72); db(0x01); db(0x2c); db(0x78); db(0x00); db(0x04); - db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x20); db(0x5f); db(0x21); db(0x40); - db(0x01); db(0x94); db(0x4a); db(0x83); db(0x6a); db(0x0e); db(0x22); db(0x48); - db(0x30); db(0x3c); db(0xff); db(0x20); db(0x61); db(0x00); db(0x10); db(0xde); - db(0x4e); db(0x90); db(0x60); db(0x26); db(0x2c); db(0x4c); db(0x2f); db(0x08); - db(0x61); db(0x00); db(0x0f); db(0x72); db(0x20); db(0x5f); db(0x22); db(0x48); - db(0x26); db(0x40); db(0x30); db(0x3c); db(0xff); db(0x20); db(0x61); db(0x00); - db(0x10); db(0xc4); db(0x4e); db(0x90); db(0x70); db(0x00); db(0x27); db(0x40); - db(0x00); db(0x08); db(0x27); db(0x40); db(0x00); db(0x10); db(0x27); db(0x40); - db(0x00); db(0x20); db(0x20); db(0x69); db(0x01); db(0x94); db(0x4a); db(0xa9); - db(0x01); db(0x90); db(0x67); db(0x2c); db(0x20); db(0x08); db(0x67); db(0x32); - db(0x61); db(0x00); db(0xfa); db(0xe6); db(0x48); db(0xe7); db(0x80); db(0xc0); - db(0x20); db(0x29); db(0x01); db(0x90); db(0x22); db(0x69); db(0x01); db(0x94); - db(0x2c); db(0x78); db(0x00); db(0x04); db(0x4e); db(0xae); db(0xff); db(0x2e); - db(0x4c); db(0xdf); db(0x03); db(0x01); db(0x42); db(0xa9); db(0x01); db(0x90); - db(0x23); db(0x48); db(0x01); db(0x94); db(0x4a); db(0x80); db(0x67); db(0x0a); - db(0x4a); db(0xa9); db(0x01); db(0x98); db(0x67); db(0x04); db(0x61); db(0x00); - db(0xfa); db(0x62); db(0x4a); db(0x83); db(0x6b); db(0x00); db(0xf8); db(0x76); - db(0x2c); db(0x78); db(0x00); db(0x04); db(0x2f); db(0x09); db(0x43); db(0xfa); - db(0x11); db(0xcf); db(0x4e); db(0xae); db(0xfe); db(0xda); db(0x22); db(0x5f); - db(0x22); db(0x00); db(0x30); db(0x3c); db(0xff); db(0x18); db(0x61); db(0x00); - db(0x10); db(0x54); db(0x4e); db(0x90); db(0x20); db(0x03); db(0x16); db(0x29); - db(0x00); db(0x4f); db(0x4a); db(0x80); db(0x66); db(0x24); db(0x27); db(0x7c); - db(0x00); db(0x00); db(0x17); db(0x70); db(0x00); db(0x14); db(0x41); db(0xfa); - db(0xf5); db(0xcc); db(0x70); db(0xff); db(0x22); db(0x0c); db(0x66); db(0x06); - db(0x41); db(0xfa); db(0xf6); db(0x02); db(0x70); db(0x00); db(0x27); db(0x40); - db(0x00); db(0x24); db(0x20); db(0x08); db(0xe4); db(0x88); db(0x27); db(0x40); - db(0x00); db(0x20); db(0x08); db(0x07); db(0x00); db(0x03); db(0x66); db(0x48); - db(0x08); db(0x07); db(0x00); db(0x00); db(0x67); db(0x42); db(0x0c); db(0x03); - db(0x00); db(0x80); db(0x67); db(0x3c); db(0x2c); db(0x78); db(0x00); db(0x04); - db(0x70); db(0x14); db(0x22); db(0x3c); db(0x00); db(0x01); db(0x00); db(0x01); - db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x22); db(0x40); db(0x30); db(0x3c); - db(0x10); db(0x00); db(0x80); db(0x03); db(0x33); db(0x40); db(0x00); db(0x08); - db(0x23); db(0x6d); db(0x01); db(0x04); db(0x00); db(0x0a); db(0x23); db(0x4b); - db(0x00); db(0x10); db(0x41); db(0xec); db(0x00); db(0x4a); db(0x4e); db(0xae); - db(0xff); db(0x7c); db(0x4e); db(0xae); db(0xfe); db(0xf2); db(0x4e); db(0xae); - db(0xff); db(0x76); db(0x72); db(0x00); db(0x70); db(0x00); db(0x4e); db(0x75); - db(0x76); db(0x00); db(0x24); db(0x49); db(0x20); db(0x4b); db(0x72); db(0x00); - db(0x22); db(0x41); db(0x08); db(0x07); db(0x00); db(0x01); db(0x67); db(0x08); - db(0x08); db(0x07); db(0x00); db(0x02); db(0x67); db(0x02); db(0x72); db(0x01); - db(0x70); db(0x80); db(0x2c); db(0x4c); db(0x61); db(0x00); db(0x0f); db(0x0e); - db(0x08); db(0x07); db(0x00); db(0x01); db(0x67); db(0x6a); db(0x08); db(0x07); - db(0x00); db(0x02); db(0x66); db(0x64); db(0x20); db(0x52); db(0x74); db(0x02); - db(0x52); db(0x82); db(0x4a); db(0x30); db(0x28); db(0xfd); db(0x66); db(0xf8); - db(0x2c); db(0x78); db(0x00); db(0x04); db(0x06); db(0x82); db(0x00); db(0x00); - db(0x10); db(0x04); db(0x20); db(0x02); db(0x72); db(0x01); db(0x4e); db(0xae); - db(0xff); db(0x3a); db(0x4a); db(0x80); db(0x67); db(0x42); db(0x20); db(0x52); - db(0x24); db(0x40); db(0x22); db(0x4a); db(0x12); db(0xd8); db(0x66); db(0xfc); - db(0x13); db(0x7c); db(0x00); db(0x3a); db(0xff); db(0xff); db(0x42); db(0x11); - db(0x2c); db(0x78); db(0x00); db(0x04); db(0x43); db(0xfa); db(0x10); db(0x74); - db(0x4e); db(0xae); db(0xfe); db(0x68); db(0x2c); db(0x40); db(0x22); db(0x0a); - db(0x26); db(0x0f); db(0x4f); db(0xea); db(0x10); db(0x04); db(0x4e); db(0xae); - db(0xff); db(0x52); db(0x2e); db(0x43); db(0x26); db(0x01); db(0x22); db(0x4e); - db(0x2c); db(0x78); db(0x00); db(0x04); db(0x4e); db(0xae); db(0xfe); db(0x62); - db(0x22); db(0x4a); db(0x20); db(0x02); db(0x4e); db(0xae); db(0xff); db(0x2e); - db(0x22); db(0x03); db(0x70); db(0x00); db(0x4e); db(0x75); db(0x48); db(0xe7); - db(0x3f); db(0x3e); db(0x2c); db(0x01); db(0x7e); db(0x06); db(0x2c); db(0x78); - db(0x00); db(0x04); db(0x43); db(0xfa); db(0x10); db(0x65); db(0x70); db(0x24); - db(0x4e); db(0xae); db(0xfd); db(0xd8); db(0x4a); db(0x80); db(0x66); db(0x0e); - db(0x08); db(0x87); db(0x00); db(0x02); db(0x43); db(0xfa); db(0x10); db(0x53); - db(0x70); db(0x00); db(0x4e); db(0xae); db(0xfd); db(0xd8); db(0x28); db(0x40); - db(0x20); db(0x3c); db(0x00); db(0x00); db(0x02); db(0x38); db(0x22); db(0x3c); - db(0x00); db(0x01); db(0x00); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); - db(0x20); db(0x40); db(0x4a); db(0x80); db(0x67); db(0x2c); db(0x21); db(0x4c); - db(0x01); db(0xa8); db(0x48); db(0xe7); db(0x00); db(0x8a); db(0x61); db(0x00); - db(0xfd); db(0xbc); db(0x4c); db(0xdf); db(0x51); db(0x00); db(0x0c); db(0x80); - db(0xff); db(0xff); db(0xff); db(0xfe); db(0x67); db(0x08); db(0x48); db(0x46); - db(0x52); db(0x46); db(0x48); db(0x46); db(0x60); db(0xe4); db(0x22); db(0x48); - db(0x20); db(0x3c); db(0x00); db(0x00); db(0x02); db(0x38); db(0x4e); db(0xae); - db(0xff); db(0x2e); db(0x22); db(0x4c); db(0x4e); db(0xae); db(0xfe); db(0x62); - db(0x4c); db(0xdf); db(0x7c); db(0xfc); db(0x4e); db(0x75); db(0x30); db(0x3c); - db(0xff); db(0x58); db(0x61); db(0x00); db(0x0e); db(0xc0); db(0x70); db(0x03); - db(0x4e); db(0x90); db(0x22); db(0x6b); db(0x00); db(0xa8); db(0x23); db(0x40); - db(0x00); db(0x20); db(0x67); db(0x16); db(0x70); db(0x00); db(0x23); db(0x40); - db(0x00); db(0x24); db(0x33); db(0x7c); db(0x00); db(0x0b); db(0x00); db(0x1c); + db(0x20); db(0x6b); db(0x00); db(0xb4); db(0x61); db(0x00); db(0x00); db(0x2c); + db(0x4e); db(0xae); db(0xff); db(0x76); db(0x4c); db(0xdf); db(0x44); db(0x80); + db(0x4e); db(0x75); db(0x22); db(0x48); db(0x20); db(0x6b); db(0x00); db(0xa0); + db(0x20); db(0x68); db(0x00); db(0x22); db(0x20); db(0x68); db(0x00); db(0x18); + db(0xd1); db(0xc8); db(0xd1); db(0xc8); db(0x22); db(0xa8); db(0x00); db(0x04); + db(0x20); db(0x09); db(0xe4); db(0x88); db(0x21); db(0x40); db(0x00); db(0x04); + db(0x4e); db(0x75); db(0x24); db(0x48); db(0x20); db(0x6b); db(0x00); db(0xa0); + db(0x20); db(0x68); db(0x00); db(0x22); db(0x20); db(0x68); db(0x00); db(0x18); + db(0xd1); db(0xc8); db(0xd1); db(0xc8); db(0x22); db(0x68); db(0x00); db(0x04); + db(0xd3); db(0xc9); db(0xd3); db(0xc9); db(0xb3); db(0xca); db(0x66); db(0x06); + db(0x21); db(0x52); db(0x00); db(0x04); db(0x60); db(0x18); db(0x20); db(0x09); + db(0x67); db(0x0e); db(0x20); db(0x11); db(0xd0); db(0x80); db(0xd0); db(0x80); + db(0xb5); db(0xc0); db(0x67); db(0x04); db(0x22); db(0x40); db(0x60); db(0xee); + db(0x20); db(0x09); db(0x67); db(0x02); db(0x22); db(0x92); db(0x4e); db(0x75); + db(0x48); db(0xe7); db(0x20); db(0x22); db(0x74); db(0x16); db(0x9f); db(0xc2); + db(0x24); db(0x4f); db(0x32); db(0x02); db(0x42); db(0x32); db(0x10); db(0xff); + db(0x53); db(0x41); db(0x66); db(0xf8); db(0x2c); db(0x78); db(0x00); db(0x04); + db(0x72); db(0x0f); db(0x4a); db(0x80); db(0x67); db(0x02); db(0x72); db(0x10); + db(0x15); db(0x41); db(0x00); db(0x04); db(0x35); db(0x7c); db(0x08); db(0x00); + db(0x00); db(0x08); db(0x22); db(0x6b); db(0x00); db(0xa4); db(0x33); db(0x7c); + db(0x00); db(0x0b); db(0x00); db(0x1c); db(0x23); db(0x7c); db(0x00); db(0x00); + db(0x00); db(0x16); db(0x00); db(0x24); db(0x23); db(0x4a); db(0x00); db(0x28); + db(0x13); db(0x7c); db(0x00); db(0x01); db(0x00); db(0x1e); db(0x22); db(0x6b); + db(0x00); db(0xa8); db(0x33); db(0x7c); db(0x00); db(0x0a); db(0x00); db(0x1c); db(0x13); db(0x7c); db(0x00); db(0x01); db(0x00); db(0x1e); db(0x4e); db(0xae); - db(0xfe); db(0x38); db(0x4e); db(0x75); db(0x7e); db(0x00); db(0x2c); db(0x78); - db(0x00); db(0x04); db(0x93); db(0xc9); db(0x4e); db(0xae); db(0xfe); db(0xda); - db(0x20); db(0x40); db(0x4b); db(0xe8); db(0x00); db(0x5c); db(0x43); db(0xfa); - db(0x0f); db(0x8a); db(0x4e); db(0xae); db(0xfe); db(0x68); db(0x24); db(0x40); - db(0x20); db(0x3c); db(0x00); db(0x00); db(0x00); db(0xb9); db(0x22); db(0x3c); - db(0x00); db(0x01); db(0x00); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); - db(0x26); db(0x40); db(0x7c); db(0x00); db(0x26); db(0x86); db(0x27); db(0x46); - db(0x00); db(0x04); db(0x27); db(0x46); db(0x00); db(0x08); db(0x27); db(0x4a); - db(0x00); db(0xa0); db(0x50); db(0xeb); db(0x00); db(0x9e); db(0x93); db(0xc9); - db(0x4e); db(0xae); db(0xfe); db(0xda); db(0x27); db(0x40); db(0x00); db(0xb0); - db(0x41); db(0xfa); db(0x0e); db(0x58); db(0x70); db(0x00); db(0x72); db(0x00); - db(0x61); db(0x00); db(0x02); db(0xc8); db(0x27); db(0x40); db(0x00); db(0xa4); - db(0x41); db(0xfa); db(0x0e); db(0x55); db(0x70); db(0x00); db(0x72); db(0x00); - db(0x61); db(0x00); db(0x02); db(0xb8); db(0x27); db(0x40); db(0x00); db(0xa8); - db(0x7a); db(0x00); db(0x26); db(0x07); db(0x66); db(0x12); db(0x20); db(0x4d); - db(0x4e); db(0xae); db(0xfe); db(0x80); db(0x20); db(0x4d); db(0x4e); db(0xae); - db(0xfe); db(0x8c); db(0x28); db(0x40); db(0x26); db(0x2c); db(0x00); db(0x0a); - db(0x30); db(0x3c); db(0xff); db(0x40); db(0x61); db(0x00); db(0x0e); db(0x0e); - db(0x70); db(0x00); db(0x4e); db(0x90); db(0x24); db(0x00); db(0x70); db(0x01); - db(0x61); db(0x00); db(0xf9); db(0xb8); db(0x08); db(0x02); db(0x00); db(0x01); - db(0x67); db(0x06); db(0x70); db(0x01); db(0x61); db(0x00); db(0xfb); db(0x20); - db(0x60); db(0x00); db(0x01); db(0x44); db(0x20); db(0x4d); db(0x4e); db(0xae); - db(0xfe); db(0x8c); db(0x28); db(0x40); db(0x4a); db(0x80); db(0x66); db(0x10); - db(0x70); db(0x00); db(0x12); db(0x2d); db(0x00); db(0x0f); db(0x03); db(0xc0); - db(0x08); db(0xc0); db(0x00); db(0x0d); db(0x4e); db(0xae); db(0xfe); db(0xc2); - db(0x08); db(0x2b); db(0x00); db(0x00); db(0x00); db(0xad); db(0x67); db(0x0a); - db(0x61); db(0x00); db(0xff); db(0x04); db(0x08); db(0xab); db(0x00); db(0x00); - db(0x00); db(0xad); db(0x08); db(0x2b); db(0x00); db(0x01); db(0x00); db(0xad); - db(0x67); db(0x0a); db(0x61); db(0x00); db(0x0b); db(0xfa); db(0x08); db(0xab); - db(0x00); db(0x01); db(0x00); db(0xad); db(0x4a); db(0x2b); db(0x00); db(0xac); - db(0x67); db(0x24); db(0x30); db(0x3c); db(0xff); db(0x58); db(0x61); db(0x00); - db(0x0d); db(0xa4); db(0x70); db(0x01); db(0x4e); db(0x90); db(0x4a); db(0x80); - db(0x67); db(0x04); db(0x61); db(0x00); db(0xfb); db(0x98); db(0x42); db(0x2b); - db(0x00); db(0xac); db(0x30); db(0x3c); db(0xff); db(0x58); db(0x61); db(0x00); - db(0x0d); db(0x8c); db(0x70); db(0x02); db(0x4e); db(0x90); db(0x20); db(0x0c); - db(0x67); db(0x56); db(0x0c); db(0x6c); db(0x00); db(0x26); db(0x00); db(0x12); - db(0x66); db(0x4e); db(0x0c); db(0xac); db(0x40); db(0x00); db(0x00); db(0x00); - db(0x00); db(0x14); db(0x66); db(0x44); db(0x0c); db(0x6c); db(0x12); db(0x34); - db(0x00); db(0x18); db(0x66); db(0x3c); db(0x20); db(0x6c); db(0x00); db(0x1a); - db(0x20); db(0x28); db(0x00); db(0x0c); db(0x02); db(0x80); db(0x80); db(0x00); - db(0x00); db(0x08); db(0x0c); db(0x80); db(0x80); db(0x00); db(0x00); db(0x08); - db(0x66); db(0x1a); db(0x02); db(0xa8); db(0x7f); db(0xff); db(0xff); db(0xff); - db(0x00); db(0x0c); db(0x20); db(0x68); db(0x00); db(0x10); db(0x22); db(0x4c); - db(0x12); db(0xbc); db(0x00); db(0x08); db(0x4e); db(0xae); db(0xfe); db(0x92); - db(0x60); db(0x00); db(0xff); db(0x4a); db(0x22); db(0x4c); db(0x70); db(0x26); - db(0x4e); db(0xae); db(0xff); db(0x2e); db(0x60); db(0x00); db(0xff); db(0x3e); - db(0x74); db(0xfe); db(0x20); db(0x0c); db(0x67); db(0x14); db(0x26); db(0x2c); - db(0x00); db(0x0a); db(0x66); db(0x42); db(0x74); db(0xff); db(0x30); db(0x3c); - db(0xff); db(0x50); db(0x61); db(0x00); db(0x0d); db(0x18); db(0x70); db(0x01); - db(0x4e); db(0x90); db(0x45); db(0xeb); db(0x00); db(0x04); db(0x20); db(0x52); - db(0x20); db(0x08); db(0x67); db(0x00); db(0xff); db(0x18); db(0x22); db(0x50); - db(0x20); db(0x40); db(0x20); db(0x28); db(0x00); db(0x04); db(0xb4); db(0x80); - db(0x66); db(0x16); db(0x48); db(0xe7); db(0x00); db(0xc0); db(0x28); db(0x68); - db(0x00); db(0x0a); db(0x61); db(0x4a); db(0x53); db(0x85); db(0x4c); db(0xdf); - db(0x03); db(0x00); db(0x24); db(0x89); db(0x20); db(0x49); db(0x60); db(0xd8); - db(0x24); db(0x48); db(0x20); db(0x49); db(0x60); db(0xd2); db(0x0c); db(0x85); - db(0x00); db(0x00); db(0x00); db(0x14); db(0x65); db(0x00); db(0x00); db(0x0a); - db(0x70); db(0x01); db(0x29); db(0x40); db(0x00); db(0x04); db(0x60); db(0x12); - db(0x61); db(0x5e); db(0x30); db(0x3c); db(0xff); db(0x30); db(0x61); db(0x00); - db(0x0c); db(0xc4); db(0x4e); db(0x90); db(0x4a); db(0x80); db(0x67); db(0x0e); - db(0x52); db(0x85); db(0x28); db(0xab); db(0x00); db(0x04); db(0x27); db(0x4c); - db(0x00); db(0x04); db(0x60); db(0x00); db(0xfe); db(0xc0); db(0x28); db(0x43); - db(0x61); db(0x04); db(0x60); db(0x00); db(0xfe); db(0xb8); db(0x0c); db(0xac); - db(0x00); db(0x00); db(0x00); db(0x1f); db(0x00); db(0x08); db(0x66); db(0x04); - db(0x61); db(0x00); db(0xfa); db(0x80); db(0x0c); db(0xac); db(0x00); db(0x00); - db(0x04); db(0x09); db(0x00); db(0x08); db(0x66); db(0x14); db(0x61); db(0x00); - db(0xfa); db(0xae); db(0x66); db(0x0e); db(0x30); db(0x3c); db(0xff); db(0x58); - db(0x61); db(0x00); db(0x0c); db(0x82); db(0x70); db(0x00); db(0x4e); db(0x90); - db(0x60); db(0xec); db(0x22); db(0x54); db(0x20); db(0x6c); db(0x00); db(0x04); - db(0x29); db(0x4d); db(0x00); db(0x04); db(0x4e); db(0xee); db(0xfe); db(0x92); - db(0x2f); db(0x05); db(0x7a); db(0xfc); db(0x24); db(0x53); db(0x2e); db(0x0a); - db(0x22); db(0x0a); db(0x67); db(0x00); db(0x00); db(0x0c); db(0x52); db(0x85); - db(0x67); db(0x1e); db(0x22); db(0x4a); db(0x24); db(0x52); db(0x60); db(0xf0); - db(0x52); db(0x85); db(0x67); db(0x3c); db(0x24); db(0x47); db(0x70); db(0x18); - db(0x72); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x52); db(0x46); - db(0x24); db(0x40); db(0x24); db(0x87); db(0x2e); db(0x0a); db(0x60); db(0xe8); - db(0x20); db(0x12); db(0x67); db(0x24); db(0x20); db(0x40); db(0x20); db(0x10); - db(0x67); db(0x1e); db(0x20); db(0x40); db(0x20); db(0x10); db(0x67); db(0x18); - db(0x70); db(0x00); db(0x22); db(0x80); db(0x22); db(0x4a); db(0x24); db(0x51); - db(0x70); db(0x18); db(0x4e); db(0xae); db(0xff); db(0x2e); db(0x06); db(0x86); - db(0x00); db(0x01); db(0x00); db(0x00); db(0x20); db(0x0a); db(0x66); db(0xec); - db(0x26); db(0x87); db(0x2a); db(0x1f); db(0x4e); db(0x75); db(0x20); db(0x88); - db(0x58); db(0x90); db(0x42); db(0xa8); db(0x00); db(0x04); db(0x21); db(0x48); - db(0x00); db(0x08); db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x20); db(0x22); - db(0x2c); db(0x78); db(0x00); db(0x04); db(0x70); db(0xff); db(0x4e); db(0xae); - db(0xfe); db(0xb6); db(0x91); db(0xc8); db(0x24); db(0x00); db(0x6b); db(0x32); - db(0x70); db(0x22); db(0x22); db(0x3c); db(0x00); db(0x01); db(0x00); db(0x01); - db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x91); db(0xc8); db(0x24); db(0x40); - db(0x4a); db(0x80); db(0x67); db(0x1e); db(0x15); db(0x7c); db(0x00); db(0x04); - db(0x00); db(0x08); db(0x15); db(0x42); db(0x00); db(0x0f); db(0x93); db(0xc9); - db(0x4e); db(0xae); db(0xfe); db(0xda); db(0x25); db(0x40); db(0x00); db(0x10); - db(0x41); db(0xea); db(0x00); db(0x14); db(0x61); db(0x00); db(0xff); db(0xb0); - db(0x20); db(0x4a); db(0x20); db(0x08); db(0x4c); db(0xdf); db(0x44); db(0x04); - db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x20); db(0x22); db(0x2c); db(0x78); - db(0x00); db(0x04); db(0x4a); db(0x80); db(0x67); db(0x24); db(0x24); db(0x40); - db(0x24); db(0x01); db(0x66); db(0x02); db(0x74); db(0x30); db(0x20); db(0x02); - db(0x22); db(0x3c); db(0x00); db(0x01); db(0x00); db(0x01); db(0x4e); db(0xae); - db(0xff); db(0x3a); db(0x20); db(0x40); db(0x11); db(0x7c); db(0x00); db(0x0a); - db(0x00); db(0x08); db(0x31); db(0x42); db(0x00); db(0x12); db(0x21); db(0x4a); - db(0x00); db(0x0e); db(0x4a); db(0x80); db(0x4c); db(0xdf); db(0x44); db(0x04); - db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x30); db(0x22); db(0x24); db(0x48); - db(0x24); db(0x00); db(0x26); db(0x01); db(0x2c); db(0x78); db(0x00); db(0x04); - db(0x61); db(0x00); db(0xff); db(0x6a); db(0x22); db(0x03); db(0x61); db(0x00); - db(0xff); db(0xb2); db(0x67); db(0x18); db(0x20); db(0x4a); db(0x22); db(0x40); - db(0x24); db(0x40); db(0x20); db(0x02); db(0x72); db(0x00); db(0x4e); db(0xae); - db(0xfe); db(0x44); db(0x22); db(0x00); db(0x70); db(0x00); db(0x4a); db(0x81); - db(0x66); db(0x02); db(0x20); db(0x0a); db(0x4a); db(0x80); db(0x4c); db(0xdf); - db(0x44); db(0x0c); db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x38); db(0x32); - db(0x2c); db(0x78); db(0x00); db(0x04); db(0x28); db(0x00); db(0x24); db(0x08); - db(0x26); db(0x09); db(0x20); db(0x3c); db(0x00); db(0x00); db(0x08); db(0x5c); + db(0xfe); db(0x38); db(0x22); db(0x6b); db(0x00); db(0xa8); db(0x25); db(0x69); + db(0x00); db(0x20); db(0x00); db(0x0e); db(0x25); db(0x69); db(0x00); db(0x24); + db(0x00); db(0x12); db(0x22); db(0x6b); db(0x00); db(0xa4); db(0x4e); db(0xae); + db(0xfe); db(0x38); db(0xdf); db(0xc2); db(0x4c); db(0xdf); db(0x44); db(0x04); + db(0x4e); db(0x75); db(0x4a); db(0x00); db(0x67); db(0x26); db(0x4a); db(0x2b); + db(0x00); db(0x4c); db(0x66); db(0x36); db(0x70); db(0x00); db(0x4a); db(0x33); + db(0x00); db(0x4d); db(0x67); db(0x04); db(0x52); db(0x00); db(0x60); db(0xf6); + db(0x17); db(0x40); db(0x00); db(0x4c); db(0x67); db(0x24); db(0x20); db(0x01); + db(0x61); db(0x00); db(0xfd); db(0xf2); db(0x70); db(0x01); db(0x61); db(0x00); + db(0xff); db(0x60); db(0x60); db(0x16); db(0x4a); db(0x2b); db(0x00); db(0x4c); + db(0x67); db(0x10); db(0x42); db(0x2b); db(0x00); db(0x4c); db(0x20); db(0x01); + db(0x61); db(0x00); db(0xfe); db(0x68); db(0x70); db(0x00); db(0x61); db(0x00); + db(0xff); db(0x48); db(0x4e); db(0x75); db(0x4a); db(0xac); db(0x00); db(0x14); + db(0x67); db(0x0a); db(0x70); db(0x00); db(0x72); db(0x01); db(0x61); db(0x00); + db(0xff); db(0xb2); db(0x4e); db(0x75); db(0x70); db(0x01); db(0x72); db(0x03); + db(0x61); db(0x00); db(0xff); db(0xa8); db(0x4e); db(0x75); db(0x10); db(0x2b); + db(0x00); db(0xac); db(0x6b); db(0x0a); db(0x70); db(0x01); db(0x72); db(0x03); + db(0x61); db(0x00); db(0xff); db(0x98); db(0x4e); db(0x75); db(0x72); db(0x01); + db(0x0c); db(0x00); db(0x00); db(0xfe); db(0x66); db(0x02); db(0x72); db(0x03); + db(0x70); db(0x00); db(0x61); db(0x00); db(0xff); db(0x86); db(0x4e); db(0x75); + db(0x20); db(0x6c); db(0x00); db(0x24); db(0x4a); db(0x90); db(0x67); db(0x0c); + db(0x4a); db(0xa8); db(0x00); db(0x08); db(0x66); db(0x0a); db(0x4a); db(0xa8); + db(0x00); db(0x0c); db(0x66); db(0x04); db(0x70); db(0x01); db(0x4e); db(0x75); + db(0x48); db(0xe7); db(0x3f); db(0x3e); db(0x2a); db(0x48); db(0x24); db(0x6c); + db(0x00); db(0x18); db(0x2e); db(0x15); db(0x7a); db(0x00); db(0x4a); db(0x87); + db(0x67); db(0x70); db(0x20); db(0x0a); db(0x67); db(0x6c); db(0x7c); db(0x00); + db(0x22); db(0x2d); db(0x00); db(0x08); db(0x67); db(0x12); db(0x24); db(0x2a); + db(0x00); db(0x04); db(0x2c); db(0x6b); db(0x00); db(0xa0); db(0x4e); db(0xae); + db(0xfc); db(0x34); db(0x4a); db(0x80); db(0x66); db(0x02); db(0x50); db(0xc6); + db(0x22); db(0x2d); db(0x00); db(0x0c); db(0x67); db(0x1c); db(0x20); db(0x41); + db(0x22); db(0x4a); db(0x2f); db(0x0a); db(0x45); db(0xec); db(0x00); db(0x20); + db(0x48); db(0x7a); db(0x00); db(0x08); db(0x2f); db(0x28); db(0x00); db(0x08); + db(0x4e); db(0x75); db(0x24); db(0x5f); db(0x4a); db(0x80); db(0x66); db(0x02); + db(0x50); db(0xc6); db(0x4a); db(0x06); db(0x67); db(0x24); db(0x20); db(0x2a); + db(0x00); db(0x04); db(0x90); db(0x8a); db(0x4a); db(0x92); db(0x66); db(0x0a); + db(0x20); db(0x05); db(0x67); db(0x10); db(0x20); db(0x40); db(0x42); db(0x90); + db(0x60); db(0x0a); db(0x20); db(0x52); db(0x22); db(0x4a); db(0x22); db(0xd8); + db(0x59); db(0x80); db(0x6a); db(0xfa); db(0x53); db(0x95); db(0x53); db(0x87); + db(0x60); db(0x94); db(0x2a); db(0x0a); db(0x24); db(0x52); db(0x53); db(0x87); + db(0x60); db(0x8c); db(0x4c); db(0xdf); db(0x7c); db(0xfc); db(0x20); db(0x6c); + db(0x00); db(0x24); db(0x4a); db(0x90); db(0x4e); db(0x75); db(0x61); db(0x00); + db(0xfc); db(0x76); db(0x21); db(0x40); db(0x01); db(0x9c); db(0x2f); db(0x08); + db(0x30); db(0x3c); db(0xff); db(0xec); db(0x61); db(0x00); db(0x14); db(0x56); + db(0x2a); db(0x50); db(0x30); db(0x3c); db(0xff); db(0x28); db(0x61); db(0x00); + db(0x14); db(0x4c); db(0x22); db(0x48); db(0x20); db(0x5f); db(0x42); db(0xa8); + db(0x01); db(0x90); db(0x42); db(0xa8); db(0x01); db(0x94); db(0x4e); db(0x91); + db(0x26); db(0x00); db(0x0c); db(0x43); db(0xff); db(0xfe); db(0x67); db(0x00); + db(0xf7); db(0x54); db(0x20); db(0x28); db(0x01); db(0x90); db(0x67); db(0x14); + db(0x6b); db(0x12); db(0x2f); db(0x08); db(0x72); db(0x01); db(0x2c); db(0x78); + db(0x00); db(0x04); db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x20); db(0x5f); + db(0x21); db(0x40); db(0x01); db(0x94); db(0x4a); db(0x83); db(0x6a); db(0x0e); + db(0x22); db(0x48); db(0x30); db(0x3c); db(0xff); db(0x20); db(0x61); db(0x00); + db(0x14); db(0x0c); db(0x4e); db(0x90); db(0x60); db(0x26); db(0x2c); db(0x4c); + db(0x2f); db(0x08); db(0x61); db(0x00); db(0x0f); db(0x70); db(0x20); db(0x5f); + db(0x22); db(0x48); db(0x26); db(0x40); db(0x30); db(0x3c); db(0xff); db(0x20); + db(0x61); db(0x00); db(0x13); db(0xf2); db(0x4e); db(0x90); db(0x70); db(0x00); + db(0x27); db(0x40); db(0x00); db(0x08); db(0x27); db(0x40); db(0x00); db(0x10); + db(0x27); db(0x40); db(0x00); db(0x20); db(0x20); db(0x69); db(0x01); db(0x94); + db(0x4a); db(0xa9); db(0x01); db(0x90); db(0x67); db(0x2c); db(0x20); db(0x08); + db(0x67); db(0x32); db(0x61); db(0x00); db(0xfa); db(0xe6); db(0x48); db(0xe7); + db(0x80); db(0xc0); db(0x20); db(0x29); db(0x01); db(0x90); db(0x22); db(0x69); + db(0x01); db(0x94); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x4e); db(0xae); + db(0xff); db(0x2e); db(0x4c); db(0xdf); db(0x03); db(0x01); db(0x42); db(0xa9); + db(0x01); db(0x90); db(0x23); db(0x48); db(0x01); db(0x94); db(0x4a); db(0x80); + db(0x67); db(0x0a); db(0x4a); db(0xa9); db(0x01); db(0x98); db(0x67); db(0x04); + db(0x61); db(0x00); db(0xfa); db(0x62); db(0x4a); db(0x83); db(0x6b); db(0x00); + db(0xf6); db(0xbc); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x2f); db(0x09); + db(0x43); db(0xfa); db(0x15); db(0x13); db(0x4e); db(0xae); db(0xfe); db(0xda); + db(0x22); db(0x5f); db(0x22); db(0x00); db(0x30); db(0x3c); db(0xff); db(0x18); + db(0x61); db(0x00); db(0x13); db(0x82); db(0x4e); db(0x90); db(0x20); db(0x03); + db(0x16); db(0x29); db(0x00); db(0x4f); db(0x4a); db(0x80); db(0x66); db(0x24); + db(0x27); db(0x7c); db(0x00); db(0x00); db(0x17); db(0x70); db(0x00); db(0x14); + db(0x41); db(0xfa); db(0xf4); db(0x0a); db(0x70); db(0xff); db(0x22); db(0x0c); + db(0x66); db(0x06); db(0x41); db(0xfa); db(0xf4); db(0x48); db(0x70); db(0x00); + db(0x27); db(0x40); db(0x00); db(0x24); db(0x20); db(0x08); db(0xe4); db(0x88); + db(0x27); db(0x40); db(0x00); db(0x20); db(0x08); db(0x07); db(0x00); db(0x03); + db(0x66); db(0x48); db(0x08); db(0x07); db(0x00); db(0x00); db(0x67); db(0x42); + db(0x0c); db(0x03); db(0x00); db(0x80); db(0x67); db(0x3c); db(0x2c); db(0x78); + db(0x00); db(0x04); db(0x70); db(0x14); db(0x22); db(0x3c); db(0x00); db(0x01); + db(0x00); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x22); db(0x40); + db(0x30); db(0x3c); db(0x10); db(0x00); db(0x80); db(0x03); db(0x33); db(0x40); + db(0x00); db(0x08); db(0x23); db(0x6d); db(0x01); db(0x04); db(0x00); db(0x0a); + db(0x23); db(0x4b); db(0x00); db(0x10); db(0x41); db(0xec); db(0x00); db(0x4a); + db(0x4e); db(0xae); db(0xff); db(0x7c); db(0x4e); db(0xae); db(0xfe); db(0xf2); + db(0x4e); db(0xae); db(0xff); db(0x76); db(0x72); db(0x00); db(0x70); db(0x00); + db(0x4e); db(0x75); db(0x76); db(0x00); db(0x24); db(0x49); db(0x20); db(0x4b); + db(0x72); db(0x00); db(0x22); db(0x41); db(0x08); db(0x07); db(0x00); db(0x01); + db(0x67); db(0x08); db(0x08); db(0x07); db(0x00); db(0x02); db(0x67); db(0x02); + db(0x72); db(0x01); db(0x70); db(0x80); db(0x2c); db(0x4c); db(0x61); db(0x00); + db(0x0f); db(0x0c); db(0x08); db(0x07); db(0x00); db(0x01); db(0x67); db(0x6a); + db(0x08); db(0x07); db(0x00); db(0x02); db(0x66); db(0x64); db(0x20); db(0x52); + db(0x74); db(0x02); db(0x52); db(0x82); db(0x4a); db(0x30); db(0x28); db(0xfd); + db(0x66); db(0xf8); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x06); db(0x82); + db(0x00); db(0x00); db(0x10); db(0x04); db(0x20); db(0x02); db(0x72); db(0x01); + db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x4a); db(0x80); db(0x67); db(0x42); + db(0x20); db(0x52); db(0x24); db(0x40); db(0x22); db(0x4a); db(0x12); db(0xd8); + db(0x66); db(0xfc); db(0x13); db(0x7c); db(0x00); db(0x3a); db(0xff); db(0xff); + db(0x42); db(0x11); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x43); db(0xfa); + db(0x13); db(0xb8); db(0x4e); db(0xae); db(0xfe); db(0x68); db(0x2c); db(0x40); + db(0x22); db(0x0a); db(0x26); db(0x0f); db(0x4f); db(0xea); db(0x10); db(0x04); + db(0x4e); db(0xae); db(0xff); db(0x52); db(0x2e); db(0x43); db(0x26); db(0x01); + db(0x22); db(0x4e); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x4e); db(0xae); + db(0xfe); db(0x62); db(0x22); db(0x4a); db(0x20); db(0x02); db(0x4e); db(0xae); + db(0xff); db(0x2e); db(0x22); db(0x03); db(0x70); db(0x00); db(0x4e); db(0x75); + db(0x48); db(0xe7); db(0x3f); db(0x3e); db(0x2c); db(0x01); db(0x7e); db(0x06); + db(0x2c); db(0x78); db(0x00); db(0x04); db(0x43); db(0xfa); db(0x13); db(0xa9); + db(0x70); db(0x24); db(0x4e); db(0xae); db(0xfd); db(0xd8); db(0x4a); db(0x80); + db(0x66); db(0x0e); db(0x08); db(0x87); db(0x00); db(0x02); db(0x43); db(0xfa); + db(0x13); db(0x97); db(0x70); db(0x00); db(0x4e); db(0xae); db(0xfd); db(0xd8); + db(0x28); db(0x40); db(0x20); db(0x3c); db(0x00); db(0x00); db(0x02); db(0x38); db(0x22); db(0x3c); db(0x00); db(0x01); db(0x00); db(0x01); db(0x4e); db(0xae); - db(0xff); db(0x3a); db(0x4a); db(0x80); db(0x67); db(0x00); db(0x00); db(0x34); - db(0x24); db(0x40); db(0x15); db(0x7c); db(0x00); db(0x01); db(0x00); db(0x08); - db(0x15); db(0x44); db(0x00); db(0x09); db(0x25); db(0x42); db(0x00); db(0x0a); - db(0x47); db(0xea); db(0x00); db(0x5c); db(0x25); db(0x4b); db(0x00); db(0x3a); - db(0x47); db(0xeb); db(0x08); db(0x00); db(0x25); db(0x4b); db(0x00); db(0x3e); - db(0x25); db(0x4b); db(0x00); db(0x36); db(0x22); db(0x4a); db(0x24); db(0x43); - db(0x97); db(0xcb); db(0x24); db(0x09); db(0x4e); db(0xae); db(0xfe); db(0xe6); - db(0x20); db(0x02); db(0x4c); db(0xdf); db(0x4c); db(0x1c); db(0x4e); db(0x75); - db(0x41); db(0xfa); db(0x0b); db(0x80); db(0x43); db(0xfa); db(0x01); db(0x30); - db(0x70); db(0x13); db(0x61); db(0x00); db(0xff); db(0x98); db(0x4e); db(0x75); - db(0x22); db(0x6d); db(0x02); db(0x0c); db(0x33); db(0x7c); db(0x00); db(0x0a); + db(0xff); db(0x3a); db(0x20); db(0x40); db(0x4a); db(0x80); db(0x67); db(0x2c); + db(0x21); db(0x4c); db(0x01); db(0xa8); db(0x48); db(0xe7); db(0x00); db(0x8a); + db(0x61); db(0x00); db(0xfd); db(0xbc); db(0x4c); db(0xdf); db(0x51); db(0x00); + db(0x0c); db(0x80); db(0xff); db(0xff); db(0xff); db(0xfe); db(0x67); db(0x08); + db(0x48); db(0x46); db(0x52); db(0x46); db(0x48); db(0x46); db(0x60); db(0xe4); + db(0x22); db(0x48); db(0x20); db(0x3c); db(0x00); db(0x00); db(0x02); db(0x38); + db(0x4e); db(0xae); db(0xff); db(0x2e); db(0x22); db(0x4c); db(0x4e); db(0xae); + db(0xfe); db(0x62); db(0x4c); db(0xdf); db(0x7c); db(0xfc); db(0x4e); db(0x75); + db(0x30); db(0x3c); db(0xff); db(0x58); db(0x61); db(0x00); db(0x11); db(0xee); + db(0x70); db(0x03); db(0x4e); db(0x90); db(0x22); db(0x6b); db(0x00); db(0xa8); + db(0x23); db(0x40); db(0x00); db(0x20); db(0x67); db(0x16); db(0x70); db(0x00); + db(0x23); db(0x40); db(0x00); db(0x24); db(0x33); db(0x7c); db(0x00); db(0x0b); db(0x00); db(0x1c); db(0x13); db(0x7c); db(0x00); db(0x01); db(0x00); db(0x1e); - db(0x4e); db(0xae); db(0xfe); db(0x38); db(0x22); db(0x6d); db(0x02); db(0x0c); - db(0x25); db(0x69); db(0x00); db(0x20); db(0x00); db(0x0e); db(0x25); db(0x69); - db(0x00); db(0x24); db(0x00); db(0x12); db(0x22); db(0x6d); db(0x02); db(0x08); - db(0x13); db(0x7c); db(0x00); db(0x01); db(0x00); db(0x1e); db(0x4e); db(0xae); - db(0xfe); db(0x38); db(0x4e); db(0x75); db(0x42); db(0xaa); db(0x00); db(0x0e); - db(0x42); db(0xaa); db(0x00); db(0x12); db(0x22); db(0x6d); db(0x02); db(0x08); - db(0x13); db(0x7c); db(0x00); db(0x01); db(0x00); db(0x1e); db(0x4e); db(0xae); - db(0xfe); db(0x38); db(0x4e); db(0x75); db(0x48); db(0xe7); db(0xf8); db(0xfe); - db(0x2a); db(0x48); db(0x95); db(0xca); db(0x97); db(0xcb); db(0x99); db(0xcc); - db(0x78); db(0x00); db(0x2c); db(0x6d); db(0x00); db(0x18); db(0x20); db(0x6d); - db(0x00); db(0x14); db(0x20); db(0x28); db(0x00); db(0x3c); db(0x67); db(0x5c); - db(0x20); db(0x40); db(0x41); db(0xe8); db(0x00); db(0x2c); db(0x28); db(0x48); - db(0x4e); db(0xae); db(0xfc); db(0xe8); db(0x72); db(0xff); db(0x74); db(0xff); - db(0xb2); db(0x80); db(0x67); db(0x48); db(0x26); db(0x00); db(0x2c); db(0x6d); - db(0x00); db(0x14); db(0x41); db(0xed); db(0x00); db(0xc0); db(0x70); db(0x66); - db(0x4e); db(0xae); db(0xff); db(0x7c); db(0x41); db(0xed); db(0x00); db(0xc0); - db(0x38); db(0x28); db(0x00); db(0x64); db(0x2c); db(0x6d); db(0x00); db(0x18); - db(0x91); db(0xc8); db(0x43); db(0xed); db(0x00); db(0x38); db(0x70); db(0x00); - db(0x30); db(0x3c); db(0x00); db(0x58); db(0x22); db(0x3c); db(0x80); db(0x00); - db(0x10); db(0x00); db(0x24); db(0x03); db(0x4e); db(0xae); db(0xfd); db(0x0c); - db(0x72); db(0xff); db(0x74); db(0xff); db(0x4a); db(0x80); db(0x6b); db(0x0c); - db(0x45); db(0xed); db(0x00); db(0x38); db(0x22); db(0x2a); db(0x00); db(0x32); - db(0x24); db(0x2a); db(0x00); db(0x36); db(0x20); db(0x2c); db(0x00); db(0x1c); - db(0xb8); db(0x6d); db(0x00); db(0x2c); db(0x66); db(0x12); db(0xb0); db(0xad); - db(0x00); db(0x28); db(0x66); db(0x0c); db(0xb2); db(0xad); db(0x00); db(0x20); - db(0x66); db(0x06); db(0xb4); db(0xad); db(0x00); db(0x24); db(0x67); db(0x40); - db(0x2b); db(0x40); db(0x00); db(0x28); db(0x2b); db(0x41); db(0x00); db(0x20); - db(0x2b); db(0x42); db(0x00); db(0x24); db(0x3b); db(0x44); db(0x00); db(0x2c); - db(0x91); db(0xc8); db(0x43); db(0xed); db(0x00); db(0x90); db(0x70); db(0x00); - db(0x30); db(0x3c); db(0x00); db(0x58); db(0x22); db(0x3c); db(0x80); db(0x00); - db(0x00); db(0x00); db(0x24); db(0x03); db(0x4e); db(0xae); db(0xfd); db(0x0c); - db(0x4a); db(0x80); db(0x6b); db(0x04); db(0x47); db(0xed); db(0x00); db(0x90); - db(0x34); db(0x2d); db(0x00); db(0x2c); db(0x30); db(0x3c); db(0xff); db(0x38); - db(0x72); db(0x01); db(0x61); db(0x00); db(0x09); db(0xb8); db(0x4e); db(0x90); - db(0x4c); db(0xdf); db(0x7f); db(0x1f); db(0x4e); db(0x75); db(0x2c); db(0x78); - db(0x00); db(0x04); db(0x3e); db(0x2e); db(0x00); db(0x14); db(0x70); db(0xff); - db(0x4e); db(0xae); db(0xfe); db(0xb6); db(0x7c); db(0x00); db(0x01); db(0xc6); - db(0x93); db(0xc9); db(0x4e); db(0xae); db(0xfe); db(0xda); db(0x28); db(0x40); - db(0x70); db(0x14); db(0x22); db(0x4c); db(0x4e); db(0xae); db(0xfe); db(0xd4); - db(0x70); db(0x00); db(0x30); db(0x3c); db(0x02); db(0x3c); db(0x22); db(0x3c); - db(0x00); db(0x01); db(0x00); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); - db(0x2a); db(0x40); db(0x47); db(0xed); db(0x00); db(0x16); db(0x27); db(0x4e); - db(0x00); db(0x10); db(0x27); db(0x4c); db(0x00); db(0x08); db(0x27); db(0x46); - db(0x00); db(0x0c); db(0x70); db(0xff); db(0x37); db(0x40); db(0x00); db(0x00); - db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x05); db(0x61); db(0x00); - db(0x09); db(0x5c); db(0x20); db(0x0d); db(0x06); db(0x80); db(0x00); db(0x00); - db(0x02); db(0x10); db(0x4e); db(0x90); db(0x43); db(0xed); db(0x00); db(0x00); - db(0x13); db(0x7c); db(0x00); db(0x02); db(0x00); db(0x08); db(0x13); db(0x7c); - db(0x00); db(0x05); db(0x00); db(0x09); db(0x41); db(0xfa); db(0x09); db(0xdc); - db(0x23); db(0x48); db(0x00); db(0x0a); db(0x41); db(0xfa); db(0x02); db(0xf4); - db(0x23); db(0x48); db(0x00); db(0x12); db(0x23); db(0x4d); db(0x00); db(0x0e); - db(0x70); db(0x05); db(0x4e); db(0xae); db(0xff); db(0x58); db(0x20); db(0x06); - db(0x4e); db(0xae); db(0xfe); db(0xc2); db(0x70); db(0x00); db(0x53); db(0xab); - db(0x00); db(0x1c); db(0x6a); db(0x06); db(0x70); db(0x0a); db(0x27); db(0x40); - db(0x00); db(0x1c); db(0x4a); db(0xab); db(0x00); db(0x14); db(0x66); db(0x16); - db(0x4a); db(0xab); db(0x00); db(0x1c); db(0x66); db(0xe0); db(0x43); db(0xfa); - db(0x0a); db(0x16); db(0x70); db(0x00); db(0x4e); db(0xae); db(0xfd); db(0xd8); - db(0x27); db(0x40); db(0x00); db(0x14); db(0x67); db(0xd0); db(0x4a); db(0xab); - db(0x00); db(0x18); db(0x66); db(0x18); db(0x4a); db(0xab); db(0x00); db(0x1c); - db(0x66); db(0xc4); db(0x43); db(0xfa); db(0x0a); db(0x0c); db(0x70); db(0x00); - db(0x4e); db(0xae); db(0xfd); db(0xd8); db(0x27); db(0x40); db(0x00); db(0x18); - db(0x67); db(0x00); db(0xff); db(0xb4); db(0x4a); db(0xad); db(0x02); db(0x08); - db(0x66); db(0x38); db(0x4a); db(0xab); db(0x00); db(0x1c); db(0x66); db(0xa6); - db(0x4e); db(0xae); db(0xff); db(0x7c); db(0x41); db(0xee); db(0x01); db(0x5e); - db(0x43); db(0xfa); db(0x08); db(0xd0); db(0x4e); db(0xae); db(0xfe); db(0xec); - db(0x24); db(0x00); db(0x4e); db(0xae); db(0xff); db(0x76); db(0x4a); db(0x82); - db(0x67); db(0x8c); db(0x41); db(0xfa); db(0x08); db(0xbe); db(0x70); db(0x00); - db(0x72); db(0x00); db(0x61); db(0x00); db(0xfd); db(0x2e); db(0x2b); db(0x40); - db(0x02); db(0x08); db(0x67); db(0x00); db(0x02); db(0x32); db(0x60); db(0x00); - db(0xff); db(0x76); db(0x4a); db(0xad); db(0x02); db(0x0c); db(0x66); db(0x48); - db(0x4a); db(0xab); db(0x00); db(0x1c); db(0x66); db(0x00); db(0xff); db(0x68); - db(0x4e); db(0xae); db(0xff); db(0x7c); db(0x41); db(0xee); db(0x01); db(0x5e); - db(0x43); db(0xfa); db(0x08); db(0x9d); db(0x4e); db(0xae); db(0xfe); db(0xec); - db(0x24); db(0x00); db(0x4e); db(0xae); db(0xff); db(0x76); db(0x4a); db(0x82); - db(0x67); db(0x00); db(0xff); db(0x4c); db(0x41); db(0xfa); db(0x08); db(0x89); - db(0x70); db(0x00); db(0x72); db(0x00); db(0x61); db(0x00); db(0xfc); db(0xec); - db(0x2b); db(0x40); db(0x02); db(0x0c); db(0x67); db(0x00); db(0x01); db(0xf0); - db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x00); db(0x61); db(0x00); - db(0x08); db(0x54); db(0x4e); db(0x90); db(0x60); db(0x00); db(0xff); db(0x28); - db(0x0c); db(0x47); db(0x00); db(0x24); db(0x65); db(0x12); db(0x53); db(0xab); - db(0x00); db(0x34); db(0x6a); db(0x0c); db(0x20); db(0x4b); db(0x61); db(0x00); - db(0xfd); db(0xb4); db(0x70); db(0x32); db(0x27); db(0x40); db(0x00); db(0x34); - db(0x22); db(0x6d); db(0x02); db(0x08); db(0x45); db(0xed); db(0x01); db(0x3c); - db(0x33); db(0x7c); db(0x00); db(0x0b); db(0x00); db(0x1c); db(0x23); db(0x7c); - db(0x00); db(0x00); db(0x00); db(0x16); db(0x00); db(0x24); db(0x23); db(0x4a); - db(0x00); db(0x28); db(0x10); db(0x2d); db(0x02); db(0x10); db(0x0c); db(0x47); - db(0x00); db(0x27); db(0x65); db(0x00); db(0x01); db(0x52); db(0x08); db(0x00); - db(0x00); db(0x01); db(0x67); db(0x00); db(0x01); db(0x4a); db(0x41); db(0xed); - db(0x01); db(0x68); db(0x25); db(0x48); db(0x00); db(0x0a); db(0x15); db(0x7c); - db(0x00); db(0x13); db(0x00); db(0x04); db(0x15); db(0x7c); db(0x00); db(0x03); - db(0x00); db(0x05); db(0x42); db(0x90); db(0x42); db(0xa8); db(0x00); db(0x04); - db(0x42); db(0xa8); db(0x00); db(0x08); db(0x42); db(0x68); db(0x00); db(0x0c); - db(0x42); db(0x6a); db(0x00); db(0x06); db(0x61); db(0x00); db(0x01); db(0x72); - db(0x31); db(0x6d); db(0x02); db(0x1a); db(0x00); db(0x0e); db(0x42); db(0x68); - db(0x00); db(0x10); db(0x31); db(0x6d); db(0x02); db(0x1c); db(0x00); db(0x12); - db(0x42); db(0x68); db(0x00); db(0x14); db(0x31); db(0x6d); db(0x02); db(0x14); - db(0x00); db(0x16); db(0x42); db(0x68); db(0x00); db(0x18); db(0x31); db(0x6d); - db(0x02); db(0x16); db(0x00); db(0x1a); db(0x43); db(0xed); db(0x01); db(0x88); - db(0x21); db(0x49); db(0x00); db(0x1c); db(0x22); db(0xfc); db(0x80); db(0x03); - db(0xa0); db(0x06); db(0x30); db(0x2d); db(0x02); db(0x30); db(0x48); db(0xc0); - db(0xe1); db(0x80); db(0x22); db(0xc0); db(0x22); db(0xfc); db(0x80); db(0x03); - db(0xa0); db(0x07); db(0x22); db(0xed); db(0x02); db(0x32); db(0x70); db(0x00); - db(0x30); db(0x2d); db(0x02); db(0x20); db(0x6b); db(0x08); db(0x22); db(0xfc); - db(0x80); db(0x03); db(0xa0); db(0x09); db(0x22); db(0xc0); db(0x30); db(0x2d); - db(0x02); db(0x22); db(0x6b); db(0x08); db(0x22); db(0xfc); db(0x80); db(0x03); - db(0xa0); db(0x0a); db(0x22); db(0xc0); db(0x30); db(0x2d); db(0x02); db(0x18); - db(0x6b); db(0x14); db(0x22); db(0xfc); db(0x80); db(0x03); db(0xa0); db(0x02); - db(0x22); db(0xc0); db(0x30); db(0x2d); db(0x02); db(0x1e); db(0x22); db(0xfc); - db(0x80); db(0x03); db(0xa0); db(0x01); db(0x22); db(0xc0); db(0x30); db(0x2d); - db(0x02); db(0x24); db(0x6b); db(0x10); db(0x22); db(0xfc); db(0x80); db(0x03); - db(0xa0); db(0x03); db(0x30); db(0x2d); db(0x02); db(0x2a); db(0x48); db(0xc0); - db(0xe1); db(0x80); db(0x22); db(0xc0); db(0x30); db(0x2d); db(0x02); db(0x26); - db(0x6b); db(0x10); db(0x22); db(0xfc); db(0x80); db(0x03); db(0xa0); db(0x04); - db(0x30); db(0x2d); db(0x02); db(0x2c); db(0x48); db(0xc0); db(0xe1); db(0x80); - db(0x22); db(0xc0); db(0x30); db(0x2d); db(0x02); db(0x28); db(0x6b); db(0x10); - db(0x22); db(0xfc); db(0x80); db(0x03); db(0xa0); db(0x05); db(0x30); db(0x2d); - db(0x02); db(0x2e); db(0x48); db(0xc0); db(0xe1); db(0x80); db(0x22); db(0xc0); - db(0x70); db(0x00); db(0x30); db(0x2d); db(0x02); db(0x36); db(0x6b); db(0x08); - db(0x22); db(0xfc); db(0x80); db(0x03); db(0xa0); db(0x08); db(0x22); db(0xc0); - db(0x42); db(0x91); db(0x61); db(0x00); db(0xfc); db(0x68); db(0x36); db(0x3c); - db(0x00); db(0x68); db(0x74); db(0x01); db(0x28); db(0x2d); db(0x02); db(0x32); - db(0x20); db(0x04); db(0xc0); db(0x82); db(0x22); db(0x2b); db(0x00); db(0x04); - db(0xc2); db(0x82); db(0xb2); db(0x80); db(0x67); db(0x22); db(0x42); db(0x92); - db(0x35); db(0x7c); db(0x02); db(0x00); db(0x00); db(0x04); db(0x42); db(0xaa); - db(0x00); db(0x0a); db(0x32); db(0x03); db(0x4a); db(0x00); db(0x66); db(0x04); - db(0x08); db(0xc1); db(0x00); db(0x07); db(0x35); db(0x41); db(0x00); db(0x06); - db(0x42); db(0x6a); db(0x00); db(0x08); db(0x61); db(0x00); db(0xfc); db(0x2e); - db(0x52); db(0x43); db(0xd4); db(0x42); db(0x0c); db(0x42); db(0x00); db(0x08); - db(0x66); db(0xc6); db(0x27); db(0x44); db(0x00); db(0x04); db(0x10); db(0x2d); - db(0x02); db(0x10); db(0x08); db(0x00); db(0x00); db(0x00); db(0x67); db(0x00); - db(0xfd); db(0x8e); db(0x42); db(0x92); db(0x35); db(0x7c); db(0x04); db(0x00); - db(0x00); db(0x04); db(0x42); db(0x6a); db(0x00); db(0x06); db(0x61); db(0x00); - db(0x00); db(0x38); db(0x20); db(0x6b); db(0x00); db(0x14); db(0x30); db(0x2d); - db(0x02); db(0x38); db(0x32); db(0x28); db(0x00); db(0x30); db(0xd2); db(0x41); - db(0x90); db(0x41); db(0x6a); db(0x02); db(0x70); db(0x00); db(0x35); db(0x40); - db(0x00); db(0x0a); db(0x30); db(0x2d); db(0x02); db(0x3a); db(0x32); db(0x28); - db(0x00); db(0x2e); db(0xd2); db(0x41); db(0x90); db(0x41); db(0x6a); db(0x02); - db(0x70); db(0x00); db(0x35); db(0x40); db(0x00); db(0x0c); db(0x61); db(0x00); - db(0xfb); db(0xa0); db(0x60); db(0x00); db(0xfd); db(0x4a); db(0x4e); db(0x75); - db(0x22); db(0x2d); db(0x02); db(0x32); db(0x70); db(0x00); db(0x08); db(0x01); - db(0x00); db(0x00); db(0x67); db(0x04); db(0x08); db(0xc0); db(0x00); db(0x0e); - db(0x08); db(0x01); db(0x00); db(0x01); db(0x67); db(0x04); db(0x08); db(0xc0); - db(0x00); db(0x0d); db(0x08); db(0x01); db(0x00); db(0x02); db(0x67); db(0x04); - db(0x08); db(0xc0); db(0x00); db(0x0c); db(0x35); db(0x40); db(0x00); db(0x08); - db(0x4e); db(0x75); db(0x4a); db(0xa9); db(0x02); db(0x08); db(0x67); db(0x14); - db(0x4a); db(0xa9); db(0x02); db(0x0c); db(0x67); db(0x0e); db(0x30); db(0x29); - db(0x02); db(0x12); db(0xb0); db(0x69); db(0x00); db(0x16); db(0x67); db(0x14); - db(0x33); db(0x40); db(0x00); db(0x16); db(0x2c); db(0x69); db(0x00); db(0x26); - db(0x20); db(0x29); db(0x00); db(0x22); db(0x22); db(0x69); db(0x00); db(0x1e); - db(0x4e); db(0xae); db(0xfe); db(0xbc); db(0x53); db(0x69); db(0x00); db(0x46); - db(0x6a); db(0x12); db(0x33); db(0x7c); db(0x00); db(0x32); db(0x00); db(0x46); - db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x02); db(0x61); db(0x00); - db(0x06); db(0x04); db(0x4e); db(0x90); db(0x41); db(0xf9); db(0x00); db(0xdf); - db(0xf0); db(0x00); db(0x70); db(0x00); db(0x4e); db(0x75); db(0x48); db(0xe7); - db(0x00); db(0x06); db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x11); - db(0x61); db(0x00); db(0x05); db(0xea); db(0x4e); db(0x90); db(0x08); db(0x00); - db(0x00); db(0x00); db(0x67); db(0x42); db(0x2c); db(0x78); db(0x00); db(0x04); - db(0x20); db(0x3c); db(0x00); db(0x00); db(0x00); db(0x88); db(0x22); db(0x3c); - db(0x00); db(0x01); db(0x00); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); - db(0x4a); db(0x80); db(0x67); db(0x00); db(0x00); db(0x40); db(0x2a); db(0x40); - db(0x2b); db(0x4e); db(0x00); db(0x14); db(0x30); db(0x3c); db(0xff); db(0x38); - db(0x72); db(0x0e); db(0x61); db(0x00); db(0x05); db(0xb8); db(0x20); db(0x0d); - db(0x4e); db(0x90); db(0x41); db(0xfa); db(0x06); db(0x38); db(0x43); db(0xfa); - db(0x01); db(0x14); db(0x70); db(0xf6); db(0x22); db(0x3c); db(0x00); db(0x00); - db(0x27); db(0x10); db(0x61); db(0x00); db(0xed); db(0xaa); db(0x70); db(0x00); - db(0x4c); db(0xdf); db(0x60); db(0x00); db(0x4e); db(0x75); db(0x30); db(0x3c); - db(0xff); db(0x38); db(0x72); db(0x0a); db(0x61); db(0x00); db(0x05); db(0x8e); - db(0x4e); db(0x90); db(0x4e); db(0x75); db(0x61); db(0xf0); db(0x20); db(0x0d); - db(0x67); db(0x1c); db(0x2c); db(0x6d); db(0x00); db(0x14); db(0x20); db(0x2d); - db(0x00); db(0x18); db(0x67); db(0x06); db(0x22); db(0x40); db(0x4e); db(0xae); - db(0xfe); db(0x62); db(0x22); db(0x4d); db(0x20); db(0x3c); db(0x00); db(0x00); - db(0x00); db(0x88); db(0x4e); db(0xae); db(0xff); db(0x2e); db(0x70); db(0x00); - db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x38); db(0x3e); db(0x2c); db(0x6d); - db(0x00); db(0x18); db(0x41); db(0xfa); db(0x05); db(0xc6); db(0x22); db(0x08); - db(0x24); db(0x3c); db(0x00); db(0x00); db(0x03); db(0xed); db(0x4e); db(0xae); - db(0xff); db(0xe2); db(0x28); db(0x00); db(0x67); db(0x4c); db(0x45); db(0xed); - db(0x00); db(0x68); db(0x42); db(0x92); db(0x34); db(0xaa); db(0x00); db(0x02); - db(0x24); db(0x0a); db(0x54); db(0x82); db(0x76); db(0x02); db(0x22); db(0x04); - db(0x4e); db(0xae); db(0xff); db(0xd6); db(0xb6); db(0x80); db(0x66); db(0x32); - db(0x0c); db(0x92); db(0x50); db(0x4e); db(0x54); db(0x52); db(0x66); db(0xe4); - db(0x24); db(0x0a); db(0x76); db(0x04); db(0x22); db(0x04); db(0x4e); db(0xae); - db(0xff); db(0xd6); db(0x24); db(0x0a); db(0x76); db(0x20); db(0x22); db(0x04); - db(0x4e); db(0xae); db(0xff); db(0xd6); db(0xb6); db(0x80); db(0x66); db(0x12); - db(0x4a); db(0x6a); db(0x00); db(0x10); db(0x66); db(0xc4); db(0x30); db(0x3c); - db(0xff); db(0x38); db(0x72); db(0x10); db(0x61); db(0x00); db(0x04); db(0xfe); - db(0x4e); db(0x90); db(0x22); db(0x04); db(0x67); db(0x04); db(0x4e); db(0xae); - db(0xff); db(0xdc); db(0x4c); db(0xdf); db(0x7c); db(0x1c); db(0x4e); db(0x75); - db(0x2c); db(0x6d); db(0x00); db(0x18); db(0x41); db(0xfa); db(0x05); db(0x3e); - db(0x22); db(0x08); db(0x74); db(0xfe); db(0x4e); db(0xae); db(0xff); db(0xac); - db(0x22); db(0x00); db(0x67); db(0x34); db(0x4e); db(0xae); db(0xff); db(0xa6); - db(0x2c); db(0x6d); db(0x00); db(0x14); db(0x45); db(0xed); db(0x00); db(0x38); - db(0x70); db(0xff); db(0x4e); db(0xae); db(0xfe); db(0xb6); db(0x15); db(0x40); - db(0x00); db(0x14); db(0x41); db(0xfa); db(0x05); db(0x2e); db(0x24); db(0x88); - db(0x25); db(0x7c); db(0x00); db(0x00); db(0x00); db(0x12); db(0x00); db(0x0c); - db(0x25); db(0x6d); db(0x00); db(0x08); db(0x00); db(0x10); db(0x2c); db(0x6d); - db(0x00); db(0x18); db(0x22); db(0x0a); db(0x4e); db(0xae); db(0xfc); db(0x88); - db(0x2c); db(0x6d); db(0x00); db(0x14); db(0x4e); db(0x75); db(0x00); db(0x00); + db(0x4e); db(0xae); db(0xfe); db(0x38); db(0x4e); db(0x75); db(0x7e); db(0x00); + db(0x2c); db(0x78); db(0x00); db(0x04); db(0x93); db(0xc9); db(0x4e); db(0xae); + db(0xfe); db(0xda); db(0x20); db(0x40); db(0x4b); db(0xe8); db(0x00); db(0x5c); + db(0x43); db(0xfa); db(0x12); db(0xce); db(0x4e); db(0xae); db(0xfe); db(0x68); + db(0x24); db(0x40); db(0x20); db(0x3c); db(0x00); db(0x00); db(0x00); db(0xb9); + db(0x22); db(0x3c); db(0x00); db(0x01); db(0x00); db(0x01); db(0x4e); db(0xae); + db(0xff); db(0x3a); db(0x26); db(0x40); db(0x7c); db(0x00); db(0x26); db(0x86); + db(0x27); db(0x46); db(0x00); db(0x04); db(0x27); db(0x46); db(0x00); db(0x08); + db(0x27); db(0x4a); db(0x00); db(0xa0); db(0x50); db(0xeb); db(0x00); db(0x9e); + db(0x93); db(0xc9); db(0x4e); db(0xae); db(0xfe); db(0xda); db(0x27); db(0x40); + db(0x00); db(0xb0); db(0x41); db(0xfa); db(0x11); db(0x86); db(0x70); db(0x00); + db(0x72); db(0x00); db(0x61); db(0x00); db(0x02); db(0xc8); db(0x27); db(0x40); + db(0x00); db(0xa4); db(0x41); db(0xfa); db(0x11); db(0x83); db(0x70); db(0x00); + db(0x72); db(0x00); db(0x61); db(0x00); db(0x02); db(0xb8); db(0x27); db(0x40); + db(0x00); db(0xa8); db(0x7a); db(0x00); db(0x26); db(0x07); db(0x66); db(0x12); + db(0x20); db(0x4d); db(0x4e); db(0xae); db(0xfe); db(0x80); db(0x20); db(0x4d); + db(0x4e); db(0xae); db(0xfe); db(0x8c); db(0x28); db(0x40); db(0x26); db(0x2c); + db(0x00); db(0x0a); db(0x30); db(0x3c); db(0xff); db(0x40); db(0x61); db(0x00); + db(0x11); db(0x3c); db(0x70); db(0x00); db(0x4e); db(0x90); db(0x24); db(0x00); + db(0x70); db(0x01); db(0x61); db(0x00); db(0xf9); db(0xb8); db(0x08); db(0x02); + db(0x00); db(0x01); db(0x67); db(0x06); db(0x70); db(0x01); db(0x61); db(0x00); + db(0xfb); db(0x20); db(0x60); db(0x00); db(0x01); db(0x44); db(0x20); db(0x4d); + db(0x4e); db(0xae); db(0xfe); db(0x8c); db(0x28); db(0x40); db(0x4a); db(0x80); + db(0x66); db(0x10); db(0x70); db(0x00); db(0x12); db(0x2d); db(0x00); db(0x0f); + db(0x03); db(0xc0); db(0x08); db(0xc0); db(0x00); db(0x0d); db(0x4e); db(0xae); + db(0xfe); db(0xc2); db(0x08); db(0x2b); db(0x00); db(0x00); db(0x00); db(0xad); + db(0x67); db(0x0a); db(0x61); db(0x00); db(0xff); db(0x04); db(0x08); db(0xab); + db(0x00); db(0x00); db(0x00); db(0xad); db(0x08); db(0x2b); db(0x00); db(0x01); + db(0x00); db(0xad); db(0x67); db(0x0a); db(0x61); db(0x00); db(0x0b); db(0xf8); + db(0x08); db(0xab); db(0x00); db(0x01); db(0x00); db(0xad); db(0x4a); db(0x2b); + db(0x00); db(0xac); db(0x67); db(0x24); db(0x30); db(0x3c); db(0xff); db(0x58); + db(0x61); db(0x00); db(0x10); db(0xd2); db(0x70); db(0x01); db(0x4e); db(0x90); + db(0x4a); db(0x80); db(0x67); db(0x04); db(0x61); db(0x00); db(0xfb); db(0x98); + db(0x42); db(0x2b); db(0x00); db(0xac); db(0x30); db(0x3c); db(0xff); db(0x58); + db(0x61); db(0x00); db(0x10); db(0xba); db(0x70); db(0x02); db(0x4e); db(0x90); + db(0x20); db(0x0c); db(0x67); db(0x56); db(0x0c); db(0x6c); db(0x00); db(0x26); + db(0x00); db(0x12); db(0x66); db(0x4e); db(0x0c); db(0xac); db(0x40); db(0x00); + db(0x00); db(0x00); db(0x00); db(0x14); db(0x66); db(0x44); db(0x0c); db(0x6c); + db(0x12); db(0x34); db(0x00); db(0x18); db(0x66); db(0x3c); db(0x20); db(0x6c); + db(0x00); db(0x1a); db(0x20); db(0x28); db(0x00); db(0x0c); db(0x02); db(0x80); + db(0x80); db(0x00); db(0x00); db(0x08); db(0x0c); db(0x80); db(0x80); db(0x00); + db(0x00); db(0x08); db(0x66); db(0x1a); db(0x02); db(0xa8); db(0x7f); db(0xff); + db(0xff); db(0xff); db(0x00); db(0x0c); db(0x20); db(0x68); db(0x00); db(0x10); + db(0x22); db(0x4c); db(0x12); db(0xbc); db(0x00); db(0x08); db(0x4e); db(0xae); + db(0xfe); db(0x92); db(0x60); db(0x00); db(0xff); db(0x4a); db(0x22); db(0x4c); + db(0x70); db(0x26); db(0x4e); db(0xae); db(0xff); db(0x2e); db(0x60); db(0x00); + db(0xff); db(0x3e); db(0x74); db(0xfe); db(0x20); db(0x0c); db(0x67); db(0x14); + db(0x26); db(0x2c); db(0x00); db(0x0a); db(0x66); db(0x42); db(0x74); db(0xff); + db(0x30); db(0x3c); db(0xff); db(0x50); db(0x61); db(0x00); db(0x10); db(0x46); + db(0x70); db(0x01); db(0x4e); db(0x90); db(0x45); db(0xeb); db(0x00); db(0x04); + db(0x20); db(0x52); db(0x20); db(0x08); db(0x67); db(0x00); db(0xff); db(0x18); + db(0x22); db(0x50); db(0x20); db(0x40); db(0x20); db(0x28); db(0x00); db(0x04); + db(0xb4); db(0x80); db(0x66); db(0x16); db(0x48); db(0xe7); db(0x00); db(0xc0); + db(0x28); db(0x68); db(0x00); db(0x0a); db(0x61); db(0x4a); db(0x53); db(0x85); + db(0x4c); db(0xdf); db(0x03); db(0x00); db(0x24); db(0x89); db(0x20); db(0x49); + db(0x60); db(0xd8); db(0x24); db(0x48); db(0x20); db(0x49); db(0x60); db(0xd2); + db(0x0c); db(0x85); db(0x00); db(0x00); db(0x00); db(0x14); db(0x65); db(0x00); + db(0x00); db(0x0a); db(0x70); db(0x01); db(0x29); db(0x40); db(0x00); db(0x04); + db(0x60); db(0x12); db(0x61); db(0x5e); db(0x30); db(0x3c); db(0xff); db(0x30); + db(0x61); db(0x00); db(0x0f); db(0xf2); db(0x4e); db(0x90); db(0x4a); db(0x80); + db(0x67); db(0x0e); db(0x52); db(0x85); db(0x28); db(0xab); db(0x00); db(0x04); + db(0x27); db(0x4c); db(0x00); db(0x04); db(0x60); db(0x00); db(0xfe); db(0xc0); + db(0x28); db(0x43); db(0x61); db(0x04); db(0x60); db(0x00); db(0xfe); db(0xb8); + db(0x0c); db(0xac); db(0x00); db(0x00); db(0x00); db(0x1f); db(0x00); db(0x08); + db(0x66); db(0x04); db(0x61); db(0x00); db(0xfa); db(0x80); db(0x0c); db(0xac); + db(0x00); db(0x00); db(0x04); db(0x09); db(0x00); db(0x08); db(0x66); db(0x14); + db(0x61); db(0x00); db(0xfa); db(0xae); db(0x66); db(0x0e); db(0x30); db(0x3c); + db(0xff); db(0x58); db(0x61); db(0x00); db(0x0f); db(0xb0); db(0x70); db(0x00); + db(0x4e); db(0x90); db(0x60); db(0xec); db(0x22); db(0x54); db(0x20); db(0x6c); + db(0x00); db(0x04); db(0x29); db(0x4d); db(0x00); db(0x04); db(0x4e); db(0xee); + db(0xfe); db(0x92); db(0x2f); db(0x05); db(0x7a); db(0xfc); db(0x24); db(0x53); + db(0x2e); db(0x0a); db(0x22); db(0x0a); db(0x67); db(0x00); db(0x00); db(0x0c); + db(0x52); db(0x85); db(0x67); db(0x1e); db(0x22); db(0x4a); db(0x24); db(0x52); + db(0x60); db(0xf0); db(0x52); db(0x85); db(0x67); db(0x3c); db(0x24); db(0x47); + db(0x70); db(0x18); db(0x72); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); + db(0x52); db(0x46); db(0x24); db(0x40); db(0x24); db(0x87); db(0x2e); db(0x0a); + db(0x60); db(0xe8); db(0x20); db(0x12); db(0x67); db(0x24); db(0x20); db(0x40); + db(0x20); db(0x10); db(0x67); db(0x1e); db(0x20); db(0x40); db(0x20); db(0x10); + db(0x67); db(0x18); db(0x70); db(0x00); db(0x22); db(0x80); db(0x22); db(0x4a); + db(0x24); db(0x51); db(0x70); db(0x18); db(0x4e); db(0xae); db(0xff); db(0x2e); + db(0x06); db(0x86); db(0x00); db(0x01); db(0x00); db(0x00); db(0x20); db(0x0a); + db(0x66); db(0xec); db(0x26); db(0x87); db(0x2a); db(0x1f); db(0x4e); db(0x75); + db(0x20); db(0x88); db(0x58); db(0x90); db(0x42); db(0xa8); db(0x00); db(0x04); + db(0x21); db(0x48); db(0x00); db(0x08); db(0x4e); db(0x75); db(0x48); db(0xe7); + db(0x20); db(0x22); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x70); db(0xff); + db(0x4e); db(0xae); db(0xfe); db(0xb6); db(0x91); db(0xc8); db(0x24); db(0x00); + db(0x6b); db(0x32); db(0x70); db(0x22); db(0x22); db(0x3c); db(0x00); db(0x01); + db(0x00); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x91); db(0xc8); + db(0x24); db(0x40); db(0x4a); db(0x80); db(0x67); db(0x1e); db(0x15); db(0x7c); + db(0x00); db(0x04); db(0x00); db(0x08); db(0x15); db(0x42); db(0x00); db(0x0f); + db(0x93); db(0xc9); db(0x4e); db(0xae); db(0xfe); db(0xda); db(0x25); db(0x40); + db(0x00); db(0x10); db(0x41); db(0xea); db(0x00); db(0x14); db(0x61); db(0x00); + db(0xff); db(0xb0); db(0x20); db(0x4a); db(0x20); db(0x08); db(0x4c); db(0xdf); + db(0x44); db(0x04); db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x20); db(0x22); + db(0x2c); db(0x78); db(0x00); db(0x04); db(0x4a); db(0x80); db(0x67); db(0x24); + db(0x24); db(0x40); db(0x24); db(0x01); db(0x66); db(0x02); db(0x74); db(0x30); + db(0x20); db(0x02); db(0x22); db(0x3c); db(0x00); db(0x01); db(0x00); db(0x01); + db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x20); db(0x40); db(0x11); db(0x7c); + db(0x00); db(0x0a); db(0x00); db(0x08); db(0x31); db(0x42); db(0x00); db(0x12); + db(0x21); db(0x4a); db(0x00); db(0x0e); db(0x4a); db(0x80); db(0x4c); db(0xdf); + db(0x44); db(0x04); db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x30); db(0x22); + db(0x24); db(0x48); db(0x24); db(0x00); db(0x26); db(0x01); db(0x2c); db(0x78); + db(0x00); db(0x04); db(0x61); db(0x00); db(0xff); db(0x6a); db(0x22); db(0x03); + db(0x61); db(0x00); db(0xff); db(0xb2); db(0x67); db(0x18); db(0x20); db(0x4a); + db(0x22); db(0x40); db(0x24); db(0x40); db(0x20); db(0x02); db(0x72); db(0x00); + db(0x4e); db(0xae); db(0xfe); db(0x44); db(0x22); db(0x00); db(0x70); db(0x00); + db(0x4a); db(0x81); db(0x66); db(0x02); db(0x20); db(0x0a); db(0x4a); db(0x80); + db(0x4c); db(0xdf); db(0x44); db(0x0c); db(0x4e); db(0x75); db(0x48); db(0xe7); + db(0x38); db(0x32); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x28); db(0x00); + db(0x24); db(0x08); db(0x26); db(0x09); db(0x20); db(0x3c); db(0x00); db(0x00); + db(0x08); db(0x5c); db(0x22); db(0x3c); db(0x00); db(0x01); db(0x00); db(0x01); + db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x4a); db(0x80); db(0x67); db(0x00); + db(0x00); db(0x34); db(0x24); db(0x40); db(0x15); db(0x7c); db(0x00); db(0x01); + db(0x00); db(0x08); db(0x15); db(0x44); db(0x00); db(0x09); db(0x25); db(0x42); + db(0x00); db(0x0a); db(0x47); db(0xea); db(0x00); db(0x5c); db(0x25); db(0x4b); + db(0x00); db(0x3a); db(0x47); db(0xeb); db(0x08); db(0x00); db(0x25); db(0x4b); + db(0x00); db(0x3e); db(0x25); db(0x4b); db(0x00); db(0x36); db(0x22); db(0x4a); + db(0x24); db(0x43); db(0x97); db(0xcb); db(0x24); db(0x09); db(0x4e); db(0xae); + db(0xfe); db(0xe6); db(0x20); db(0x02); db(0x4c); db(0xdf); db(0x4c); db(0x1c); + db(0x4e); db(0x75); db(0x41); db(0xfa); db(0x0e); db(0xae); db(0x43); db(0xfa); + db(0x01); db(0x30); db(0x70); db(0x13); db(0x61); db(0x00); db(0xff); db(0x98); + db(0x4e); db(0x75); db(0x22); db(0x6d); db(0x02); db(0x0c); db(0x33); db(0x7c); + db(0x00); db(0x0a); db(0x00); db(0x1c); db(0x13); db(0x7c); db(0x00); db(0x01); + db(0x00); db(0x1e); db(0x4e); db(0xae); db(0xfe); db(0x38); db(0x22); db(0x6d); + db(0x02); db(0x0c); db(0x25); db(0x69); db(0x00); db(0x20); db(0x00); db(0x0e); + db(0x25); db(0x69); db(0x00); db(0x24); db(0x00); db(0x12); db(0x22); db(0x6d); + db(0x02); db(0x08); db(0x13); db(0x7c); db(0x00); db(0x01); db(0x00); db(0x1e); + db(0x4e); db(0xae); db(0xfe); db(0x38); db(0x4e); db(0x75); db(0x42); db(0xaa); + db(0x00); db(0x0e); db(0x42); db(0xaa); db(0x00); db(0x12); db(0x22); db(0x6d); + db(0x02); db(0x08); db(0x13); db(0x7c); db(0x00); db(0x01); db(0x00); db(0x1e); + db(0x4e); db(0xae); db(0xfe); db(0x38); db(0x4e); db(0x75); db(0x48); db(0xe7); + db(0xf8); db(0xfe); db(0x2a); db(0x48); db(0x95); db(0xca); db(0x97); db(0xcb); + db(0x99); db(0xcc); db(0x78); db(0x00); db(0x2c); db(0x6d); db(0x00); db(0x18); + db(0x20); db(0x6d); db(0x00); db(0x14); db(0x20); db(0x28); db(0x00); db(0x3c); + db(0x67); db(0x5c); db(0x20); db(0x40); db(0x41); db(0xe8); db(0x00); db(0x2c); + db(0x28); db(0x48); db(0x4e); db(0xae); db(0xfc); db(0xe8); db(0x72); db(0xff); + db(0x74); db(0xff); db(0xb2); db(0x80); db(0x67); db(0x48); db(0x26); db(0x00); + db(0x2c); db(0x6d); db(0x00); db(0x14); db(0x41); db(0xed); db(0x00); db(0xc0); + db(0x70); db(0x66); db(0x4e); db(0xae); db(0xff); db(0x7c); db(0x41); db(0xed); + db(0x00); db(0xc0); db(0x38); db(0x28); db(0x00); db(0x64); db(0x2c); db(0x6d); + db(0x00); db(0x18); db(0x91); db(0xc8); db(0x43); db(0xed); db(0x00); db(0x38); + db(0x70); db(0x00); db(0x30); db(0x3c); db(0x00); db(0x58); db(0x22); db(0x3c); + db(0x80); db(0x00); db(0x10); db(0x00); db(0x24); db(0x03); db(0x4e); db(0xae); + db(0xfd); db(0x0c); db(0x72); db(0xff); db(0x74); db(0xff); db(0x4a); db(0x80); + db(0x6b); db(0x0c); db(0x45); db(0xed); db(0x00); db(0x38); db(0x22); db(0x2a); + db(0x00); db(0x32); db(0x24); db(0x2a); db(0x00); db(0x36); db(0x20); db(0x2c); + db(0x00); db(0x1c); db(0xb8); db(0x6d); db(0x00); db(0x2c); db(0x66); db(0x12); + db(0xb0); db(0xad); db(0x00); db(0x28); db(0x66); db(0x0c); db(0xb2); db(0xad); + db(0x00); db(0x20); db(0x66); db(0x06); db(0xb4); db(0xad); db(0x00); db(0x24); + db(0x67); db(0x40); db(0x2b); db(0x40); db(0x00); db(0x28); db(0x2b); db(0x41); + db(0x00); db(0x20); db(0x2b); db(0x42); db(0x00); db(0x24); db(0x3b); db(0x44); + db(0x00); db(0x2c); db(0x91); db(0xc8); db(0x43); db(0xed); db(0x00); db(0x90); + db(0x70); db(0x00); db(0x30); db(0x3c); db(0x00); db(0x58); db(0x22); db(0x3c); + db(0x80); db(0x00); db(0x00); db(0x00); db(0x24); db(0x03); db(0x4e); db(0xae); + db(0xfd); db(0x0c); db(0x4a); db(0x80); db(0x6b); db(0x04); db(0x47); db(0xed); + db(0x00); db(0x90); db(0x34); db(0x2d); db(0x00); db(0x2c); db(0x30); db(0x3c); + db(0xff); db(0x38); db(0x72); db(0x01); db(0x61); db(0x00); db(0x0c); db(0xe6); + db(0x4e); db(0x90); db(0x4c); db(0xdf); db(0x7f); db(0x1f); db(0x4e); db(0x75); + db(0x2c); db(0x78); db(0x00); db(0x04); db(0x3e); db(0x2e); db(0x00); db(0x14); + db(0x70); db(0xff); db(0x4e); db(0xae); db(0xfe); db(0xb6); db(0x7c); db(0x00); + db(0x01); db(0xc6); db(0x93); db(0xc9); db(0x4e); db(0xae); db(0xfe); db(0xda); + db(0x28); db(0x40); db(0x70); db(0x14); db(0x22); db(0x4c); db(0x4e); db(0xae); + db(0xfe); db(0xd4); db(0x70); db(0x00); db(0x30); db(0x3c); db(0x02); db(0x3c); + db(0x22); db(0x3c); db(0x00); db(0x01); db(0x00); db(0x01); db(0x4e); db(0xae); + db(0xff); db(0x3a); db(0x2a); db(0x40); db(0x47); db(0xed); db(0x00); db(0x16); + db(0x27); db(0x4e); db(0x00); db(0x10); db(0x27); db(0x4c); db(0x00); db(0x08); + db(0x27); db(0x46); db(0x00); db(0x0c); db(0x70); db(0xff); db(0x37); db(0x40); + db(0x00); db(0x00); db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x05); + db(0x61); db(0x00); db(0x0c); db(0x8a); db(0x20); db(0x0d); db(0x06); db(0x80); + db(0x00); db(0x00); db(0x02); db(0x10); db(0x4e); db(0x90); db(0x43); db(0xed); + db(0x00); db(0x00); db(0x13); db(0x7c); db(0x00); db(0x02); db(0x00); db(0x08); + db(0x13); db(0x7c); db(0x00); db(0x05); db(0x00); db(0x09); db(0x41); db(0xfa); + db(0x0d); db(0x0a); db(0x23); db(0x48); db(0x00); db(0x0a); db(0x41); db(0xfa); + db(0x02); db(0xf4); db(0x23); db(0x48); db(0x00); db(0x12); db(0x23); db(0x4d); + db(0x00); db(0x0e); db(0x70); db(0x05); db(0x4e); db(0xae); db(0xff); db(0x58); + db(0x20); db(0x06); db(0x4e); db(0xae); db(0xfe); db(0xc2); db(0x70); db(0x00); + db(0x53); db(0xab); db(0x00); db(0x1c); db(0x6a); db(0x06); db(0x70); db(0x0a); + db(0x27); db(0x40); db(0x00); db(0x1c); db(0x4a); db(0xab); db(0x00); db(0x14); + db(0x66); db(0x16); db(0x4a); db(0xab); db(0x00); db(0x1c); db(0x66); db(0xe0); + db(0x43); db(0xfa); db(0x0d); db(0x5a); db(0x70); db(0x00); db(0x4e); db(0xae); + db(0xfd); db(0xd8); db(0x27); db(0x40); db(0x00); db(0x14); db(0x67); db(0xd0); + db(0x4a); db(0xab); db(0x00); db(0x18); db(0x66); db(0x18); db(0x4a); db(0xab); + db(0x00); db(0x1c); db(0x66); db(0xc4); db(0x43); db(0xfa); db(0x0d); db(0x50); + db(0x70); db(0x00); db(0x4e); db(0xae); db(0xfd); db(0xd8); db(0x27); db(0x40); + db(0x00); db(0x18); db(0x67); db(0x00); db(0xff); db(0xb4); db(0x4a); db(0xad); + db(0x02); db(0x08); db(0x66); db(0x38); db(0x4a); db(0xab); db(0x00); db(0x1c); + db(0x66); db(0xa6); db(0x4e); db(0xae); db(0xff); db(0x7c); db(0x41); db(0xee); + db(0x01); db(0x5e); db(0x43); db(0xfa); db(0x0b); db(0xfe); db(0x4e); db(0xae); + db(0xfe); db(0xec); db(0x24); db(0x00); db(0x4e); db(0xae); db(0xff); db(0x76); + db(0x4a); db(0x82); db(0x67); db(0x8c); db(0x41); db(0xfa); db(0x0b); db(0xec); + db(0x70); db(0x00); db(0x72); db(0x00); db(0x61); db(0x00); db(0xfd); db(0x2e); + db(0x2b); db(0x40); db(0x02); db(0x08); db(0x67); db(0x00); db(0x02); db(0x32); + db(0x60); db(0x00); db(0xff); db(0x76); db(0x4a); db(0xad); db(0x02); db(0x0c); + db(0x66); db(0x48); db(0x4a); db(0xab); db(0x00); db(0x1c); db(0x66); db(0x00); + db(0xff); db(0x68); db(0x4e); db(0xae); db(0xff); db(0x7c); db(0x41); db(0xee); + db(0x01); db(0x5e); db(0x43); db(0xfa); db(0x0b); db(0xcb); db(0x4e); db(0xae); + db(0xfe); db(0xec); db(0x24); db(0x00); db(0x4e); db(0xae); db(0xff); db(0x76); + db(0x4a); db(0x82); db(0x67); db(0x00); db(0xff); db(0x4c); db(0x41); db(0xfa); + db(0x0b); db(0xb7); db(0x70); db(0x00); db(0x72); db(0x00); db(0x61); db(0x00); + db(0xfc); db(0xec); db(0x2b); db(0x40); db(0x02); db(0x0c); db(0x67); db(0x00); + db(0x01); db(0xf0); db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x00); + db(0x61); db(0x00); db(0x0b); db(0x82); db(0x4e); db(0x90); db(0x60); db(0x00); + db(0xff); db(0x28); db(0x0c); db(0x47); db(0x00); db(0x24); db(0x65); db(0x12); + db(0x53); db(0xab); db(0x00); db(0x34); db(0x6a); db(0x0c); db(0x20); db(0x4b); + db(0x61); db(0x00); db(0xfd); db(0xb4); db(0x70); db(0x32); db(0x27); db(0x40); + db(0x00); db(0x34); db(0x22); db(0x6d); db(0x02); db(0x08); db(0x45); db(0xed); + db(0x01); db(0x3c); db(0x33); db(0x7c); db(0x00); db(0x0b); db(0x00); db(0x1c); + db(0x23); db(0x7c); db(0x00); db(0x00); db(0x00); db(0x16); db(0x00); db(0x24); + db(0x23); db(0x4a); db(0x00); db(0x28); db(0x10); db(0x2d); db(0x02); db(0x10); + db(0x0c); db(0x47); db(0x00); db(0x27); db(0x65); db(0x00); db(0x01); db(0x52); + db(0x08); db(0x00); db(0x00); db(0x01); db(0x67); db(0x00); db(0x01); db(0x4a); + db(0x41); db(0xed); db(0x01); db(0x68); db(0x25); db(0x48); db(0x00); db(0x0a); + db(0x15); db(0x7c); db(0x00); db(0x13); db(0x00); db(0x04); db(0x15); db(0x7c); + db(0x00); db(0x03); db(0x00); db(0x05); db(0x42); db(0x90); db(0x42); db(0xa8); + db(0x00); db(0x04); db(0x42); db(0xa8); db(0x00); db(0x08); db(0x42); db(0x68); + db(0x00); db(0x0c); db(0x42); db(0x6a); db(0x00); db(0x06); db(0x61); db(0x00); + db(0x01); db(0x72); db(0x31); db(0x6d); db(0x02); db(0x1a); db(0x00); db(0x0e); + db(0x42); db(0x68); db(0x00); db(0x10); db(0x31); db(0x6d); db(0x02); db(0x1c); + db(0x00); db(0x12); db(0x42); db(0x68); db(0x00); db(0x14); db(0x31); db(0x6d); + db(0x02); db(0x14); db(0x00); db(0x16); db(0x42); db(0x68); db(0x00); db(0x18); + db(0x31); db(0x6d); db(0x02); db(0x16); db(0x00); db(0x1a); db(0x43); db(0xed); + db(0x01); db(0x88); db(0x21); db(0x49); db(0x00); db(0x1c); db(0x22); db(0xfc); + db(0x80); db(0x03); db(0xa0); db(0x06); db(0x30); db(0x2d); db(0x02); db(0x30); + db(0x48); db(0xc0); db(0xe1); db(0x80); db(0x22); db(0xc0); db(0x22); db(0xfc); + db(0x80); db(0x03); db(0xa0); db(0x07); db(0x22); db(0xed); db(0x02); db(0x32); + db(0x70); db(0x00); db(0x30); db(0x2d); db(0x02); db(0x20); db(0x6b); db(0x08); + db(0x22); db(0xfc); db(0x80); db(0x03); db(0xa0); db(0x09); db(0x22); db(0xc0); + db(0x30); db(0x2d); db(0x02); db(0x22); db(0x6b); db(0x08); db(0x22); db(0xfc); + db(0x80); db(0x03); db(0xa0); db(0x0a); db(0x22); db(0xc0); db(0x30); db(0x2d); + db(0x02); db(0x18); db(0x6b); db(0x14); db(0x22); db(0xfc); db(0x80); db(0x03); + db(0xa0); db(0x02); db(0x22); db(0xc0); db(0x30); db(0x2d); db(0x02); db(0x1e); + db(0x22); db(0xfc); db(0x80); db(0x03); db(0xa0); db(0x01); db(0x22); db(0xc0); + db(0x30); db(0x2d); db(0x02); db(0x24); db(0x6b); db(0x10); db(0x22); db(0xfc); + db(0x80); db(0x03); db(0xa0); db(0x03); db(0x30); db(0x2d); db(0x02); db(0x2a); + db(0x48); db(0xc0); db(0xe1); db(0x80); db(0x22); db(0xc0); db(0x30); db(0x2d); + db(0x02); db(0x26); db(0x6b); db(0x10); db(0x22); db(0xfc); db(0x80); db(0x03); + db(0xa0); db(0x04); db(0x30); db(0x2d); db(0x02); db(0x2c); db(0x48); db(0xc0); + db(0xe1); db(0x80); db(0x22); db(0xc0); db(0x30); db(0x2d); db(0x02); db(0x28); + db(0x6b); db(0x10); db(0x22); db(0xfc); db(0x80); db(0x03); db(0xa0); db(0x05); + db(0x30); db(0x2d); db(0x02); db(0x2e); db(0x48); db(0xc0); db(0xe1); db(0x80); + db(0x22); db(0xc0); db(0x70); db(0x00); db(0x30); db(0x2d); db(0x02); db(0x36); + db(0x6b); db(0x08); db(0x22); db(0xfc); db(0x80); db(0x03); db(0xa0); db(0x08); + db(0x22); db(0xc0); db(0x42); db(0x91); db(0x61); db(0x00); db(0xfc); db(0x68); + db(0x36); db(0x3c); db(0x00); db(0x68); db(0x74); db(0x01); db(0x28); db(0x2d); + db(0x02); db(0x32); db(0x20); db(0x04); db(0xc0); db(0x82); db(0x22); db(0x2b); + db(0x00); db(0x04); db(0xc2); db(0x82); db(0xb2); db(0x80); db(0x67); db(0x22); + db(0x42); db(0x92); db(0x35); db(0x7c); db(0x02); db(0x00); db(0x00); db(0x04); + db(0x42); db(0xaa); db(0x00); db(0x0a); db(0x32); db(0x03); db(0x4a); db(0x00); + db(0x66); db(0x04); db(0x08); db(0xc1); db(0x00); db(0x07); db(0x35); db(0x41); + db(0x00); db(0x06); db(0x42); db(0x6a); db(0x00); db(0x08); db(0x61); db(0x00); + db(0xfc); db(0x2e); db(0x52); db(0x43); db(0xd4); db(0x42); db(0x0c); db(0x42); + db(0x00); db(0x08); db(0x66); db(0xc6); db(0x27); db(0x44); db(0x00); db(0x04); + db(0x10); db(0x2d); db(0x02); db(0x10); db(0x08); db(0x00); db(0x00); db(0x00); + db(0x67); db(0x00); db(0xfd); db(0x8e); db(0x42); db(0x92); db(0x35); db(0x7c); + db(0x04); db(0x00); db(0x00); db(0x04); db(0x42); db(0x6a); db(0x00); db(0x06); + db(0x61); db(0x00); db(0x00); db(0x38); db(0x20); db(0x6b); db(0x00); db(0x14); + db(0x30); db(0x2d); db(0x02); db(0x38); db(0x32); db(0x28); db(0x00); db(0x30); + db(0xd2); db(0x41); db(0x90); db(0x41); db(0x6a); db(0x02); db(0x70); db(0x00); + db(0x35); db(0x40); db(0x00); db(0x0a); db(0x30); db(0x2d); db(0x02); db(0x3a); + db(0x32); db(0x28); db(0x00); db(0x2e); db(0xd2); db(0x41); db(0x90); db(0x41); + db(0x6a); db(0x02); db(0x70); db(0x00); db(0x35); db(0x40); db(0x00); db(0x0c); + db(0x61); db(0x00); db(0xfb); db(0xa0); db(0x60); db(0x00); db(0xfd); db(0x4a); + db(0x4e); db(0x75); db(0x22); db(0x2d); db(0x02); db(0x32); db(0x70); db(0x00); + db(0x08); db(0x01); db(0x00); db(0x00); db(0x67); db(0x04); db(0x08); db(0xc0); + db(0x00); db(0x0e); db(0x08); db(0x01); db(0x00); db(0x01); db(0x67); db(0x04); + db(0x08); db(0xc0); db(0x00); db(0x0d); db(0x08); db(0x01); db(0x00); db(0x02); + db(0x67); db(0x04); db(0x08); db(0xc0); db(0x00); db(0x0c); db(0x35); db(0x40); + db(0x00); db(0x08); db(0x4e); db(0x75); db(0x4a); db(0xa9); db(0x02); db(0x08); + db(0x67); db(0x14); db(0x4a); db(0xa9); db(0x02); db(0x0c); db(0x67); db(0x0e); + db(0x30); db(0x29); db(0x02); db(0x12); db(0xb0); db(0x69); db(0x00); db(0x16); + db(0x67); db(0x14); db(0x33); db(0x40); db(0x00); db(0x16); db(0x2c); db(0x69); + db(0x00); db(0x26); db(0x20); db(0x29); db(0x00); db(0x22); db(0x22); db(0x69); + db(0x00); db(0x1e); db(0x4e); db(0xae); db(0xfe); db(0xbc); db(0x53); db(0x69); + db(0x00); db(0x46); db(0x6a); db(0x12); db(0x33); db(0x7c); db(0x00); db(0x32); + db(0x00); db(0x46); db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x02); + db(0x61); db(0x00); db(0x09); db(0x32); db(0x4e); db(0x90); db(0x41); db(0xf9); + db(0x00); db(0xdf); db(0xf0); db(0x00); db(0x70); db(0x00); db(0x4e); db(0x75); + db(0x48); db(0xe7); db(0x00); db(0x06); db(0x30); db(0x3c); db(0xff); db(0x38); + db(0x72); db(0x11); db(0x61); db(0x00); db(0x09); db(0x18); db(0x4e); db(0x90); + db(0x08); db(0x00); db(0x00); db(0x00); db(0x67); db(0x42); db(0x2c); db(0x78); + db(0x00); db(0x04); db(0x20); db(0x3c); db(0x00); db(0x00); db(0x00); db(0x88); + db(0x22); db(0x3c); db(0x00); db(0x01); db(0x00); db(0x01); db(0x4e); db(0xae); + db(0xff); db(0x3a); db(0x4a); db(0x80); db(0x67); db(0x00); db(0x00); db(0x40); + db(0x2a); db(0x40); db(0x2b); db(0x4e); db(0x00); db(0x14); db(0x30); db(0x3c); + db(0xff); db(0x38); db(0x72); db(0x0e); db(0x61); db(0x00); db(0x08); db(0xe6); + db(0x20); db(0x0d); db(0x4e); db(0x90); db(0x41); db(0xfa); db(0x09); db(0x66); + db(0x43); db(0xfa); db(0x01); db(0x12); db(0x70); db(0xf6); db(0x22); db(0x3c); + db(0x00); db(0x00); db(0x27); db(0x10); db(0x61); db(0x00); db(0xeb); db(0xf0); + db(0x70); db(0x00); db(0x4c); db(0xdf); db(0x60); db(0x00); db(0x4e); db(0x75); + db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x0a); db(0x61); db(0x00); + db(0x08); db(0xbc); db(0x4e); db(0x90); db(0x4e); db(0x75); db(0x61); db(0xf0); + db(0x20); db(0x0d); db(0x67); db(0x1c); db(0x2c); db(0x6d); db(0x00); db(0x14); + db(0x20); db(0x2d); db(0x00); db(0x18); db(0x67); db(0x06); db(0x22); db(0x40); + db(0x4e); db(0xae); db(0xfe); db(0x62); db(0x22); db(0x4d); db(0x20); db(0x3c); + db(0x00); db(0x00); db(0x00); db(0x88); db(0x4e); db(0xae); db(0xff); db(0x2e); + db(0x70); db(0x00); db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x38); db(0x3e); + db(0x2c); db(0x6d); db(0x00); db(0x18); db(0x41); db(0xfa); db(0x08); db(0xf4); + db(0x22); db(0x08); db(0x24); db(0x3c); db(0x00); db(0x00); db(0x03); db(0xed); + db(0x4e); db(0xae); db(0xff); db(0xe2); db(0x28); db(0x00); db(0x67); db(0x4c); + db(0x45); db(0xed); db(0x00); db(0x68); db(0x42); db(0x92); db(0x34); db(0xaa); + db(0x00); db(0x02); db(0x24); db(0x0a); db(0x54); db(0x82); db(0x76); db(0x02); + db(0x22); db(0x04); db(0x4e); db(0xae); db(0xff); db(0xd6); db(0xb6); db(0x80); + db(0x66); db(0x32); db(0x0c); db(0x92); db(0x50); db(0x4e); db(0x54); db(0x52); + db(0x66); db(0xe4); db(0x24); db(0x0a); db(0x76); db(0x04); db(0x22); db(0x04); + db(0x4e); db(0xae); db(0xff); db(0xd6); db(0x24); db(0x0a); db(0x76); db(0x20); + db(0x22); db(0x04); db(0x4e); db(0xae); db(0xff); db(0xd6); db(0xb6); db(0x80); + db(0x66); db(0x12); db(0x4a); db(0x6a); db(0x00); db(0x10); db(0x66); db(0xc4); + db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x10); db(0x61); db(0x00); + db(0x08); db(0x2c); db(0x4e); db(0x90); db(0x22); db(0x04); db(0x67); db(0x04); + db(0x4e); db(0xae); db(0xff); db(0xdc); db(0x4c); db(0xdf); db(0x7c); db(0x1c); + db(0x4e); db(0x75); db(0x2c); db(0x6d); db(0x00); db(0x18); db(0x41); db(0xfa); + db(0x08); db(0x6c); db(0x22); db(0x08); db(0x74); db(0xfe); db(0x4e); db(0xae); + db(0xff); db(0xac); db(0x22); db(0x00); db(0x67); db(0x34); db(0x4e); db(0xae); + db(0xff); db(0xa6); db(0x2c); db(0x6d); db(0x00); db(0x14); db(0x45); db(0xed); + db(0x00); db(0x38); db(0x70); db(0xff); db(0x4e); db(0xae); db(0xfe); db(0xb6); + db(0x15); db(0x40); db(0x00); db(0x14); db(0x41); db(0xfa); db(0x08); db(0x5c); + db(0x24); db(0x88); db(0x25); db(0x7c); db(0x00); db(0x00); db(0x00); db(0x12); + db(0x00); db(0x0c); db(0x25); db(0x6d); db(0x00); db(0x08); db(0x00); db(0x10); + db(0x2c); db(0x6d); db(0x00); db(0x18); db(0x22); db(0x0a); db(0x4e); db(0xae); + db(0xfc); db(0x88); db(0x2c); db(0x6d); db(0x00); db(0x14); db(0x4e); db(0x75); db(0x00); db(0x00); db(0x00); db(0x10); db(0x00); db(0x00); db(0x00); db(0x00); db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x0d); db(0x61); db(0x00); - db(0x04); db(0x8c); db(0x4e); db(0x90); db(0x4a); db(0x80); db(0x67); db(0x00); - db(0xfe); db(0xfc); db(0x2a); db(0x40); db(0x2c); db(0x6d); db(0x00); db(0x14); + db(0x07); db(0xbc); db(0x4e); db(0x90); db(0x4a); db(0x80); db(0x67); db(0x00); + db(0xfe); db(0xfe); db(0x2a); db(0x40); db(0x2c); db(0x6d); db(0x00); db(0x14); db(0x93); db(0xc9); db(0x4e); db(0xae); db(0xfe); db(0xda); db(0x2b); db(0x40); - db(0x00); db(0x08); db(0x43); db(0xfa); db(0x05); db(0x76); db(0x70); db(0x00); + db(0x00); db(0x08); db(0x43); db(0xfa); db(0x08); db(0xbc); db(0x70); db(0x00); db(0x4e); db(0xae); db(0xfd); db(0xd8); db(0x2b); db(0x40); db(0x00); db(0x18); - db(0x67); db(0x00); db(0xfe); db(0xda); db(0x2c); db(0x40); db(0x72); db(0x32); - db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x41); db(0xfa); db(0x04); db(0x92); + db(0x67); db(0x00); db(0xfe); db(0xdc); db(0x2c); db(0x40); db(0x72); db(0x32); + db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x41); db(0xfa); db(0x07); db(0xc2); db(0x22); db(0x08); db(0x74); db(0xfe); db(0x4e); db(0xae); db(0xff); db(0xac); db(0x4a); db(0x80); db(0x67); db(0xea); db(0x22); db(0x00); db(0x4e); db(0xae); db(0xff); db(0xa6); db(0x72); db(0x32); db(0x4e); db(0xae); db(0xff); db(0x3a); - db(0x41); db(0xfa); db(0x04); db(0x7c); db(0x22); db(0x08); db(0x74); db(0xfe); + db(0x41); db(0xfa); db(0x07); db(0xac); db(0x22); db(0x08); db(0x74); db(0xfe); db(0x4e); db(0xae); db(0xff); db(0xac); db(0x4a); db(0x80); db(0x67); db(0x00); - db(0xfe); db(0xa4); db(0x22); db(0x00); db(0x4e); db(0xae); db(0xff); db(0xa6); - db(0x2c); db(0x6d); db(0x00); db(0x14); db(0x61); db(0x00); db(0xf8); db(0x1e); + db(0xfe); db(0xa6); db(0x22); db(0x00); db(0x4e); db(0xae); db(0xff); db(0xa6); + db(0x2c); db(0x6d); db(0x00); db(0x14); db(0x61); db(0x00); db(0xf8); db(0x20); db(0x72); db(0x00); db(0x32); db(0x3c); db(0x00); db(0x34); db(0x61); db(0x00); - db(0xf8); db(0x62); db(0x28); db(0x40); db(0x4a); db(0x80); db(0x67); db(0x00); - db(0xfe); db(0x84); db(0x70); db(0x00); db(0x08); db(0xc0); db(0x00); db(0x0d); + db(0xf8); db(0x64); db(0x28); db(0x40); db(0x4a); db(0x80); db(0x67); db(0x00); + db(0xfe); db(0x86); db(0x70); db(0x00); db(0x08); db(0xc0); db(0x00); db(0x0d); db(0x4e); db(0xae); db(0xfe); db(0xc2); db(0x72); db(0x00); db(0x20); db(0x2d); - db(0x00); db(0x0c); db(0x41); db(0xfa); db(0x04); db(0x55); db(0x22); db(0x4c); + db(0x00); db(0x0c); db(0x41); db(0xfa); db(0x07); db(0x85); db(0x22); db(0x4c); db(0x4e); db(0xae); db(0xfe); db(0x44); db(0x4a); db(0x80); db(0x66); db(0xe2); db(0x20); db(0x6c); db(0x00); db(0x14); db(0x0c); db(0x68); db(0x00); db(0x25); - db(0x00); db(0x14); db(0x64); db(0x0c); db(0x61); db(0x00); db(0xfe); db(0x48); + db(0x00); db(0x14); db(0x64); db(0x0c); db(0x61); db(0x00); db(0xfe); db(0x4a); db(0x70); db(0x00); db(0x4e); db(0xae); db(0xfe); db(0xc2); db(0x60); db(0xf8); - db(0x61); db(0x00); db(0xfe); db(0xe6); db(0x41); db(0xed); db(0x00); db(0x1c); + db(0x61); db(0x00); db(0xfe); db(0xe8); db(0x41); db(0xed); db(0x00); db(0x1c); db(0x29); db(0x48); db(0x00); db(0x28); db(0x70); db(0x01); db(0x29); db(0x40); db(0x00); db(0x24); db(0x39); db(0x7c); db(0x00); db(0x0c); db(0x00); db(0x1c); db(0x2b); db(0x4d); db(0x00); db(0x2c); db(0x41); db(0xfa); db(0x01); db(0x60); db(0x2b); db(0x48); db(0x00); db(0x24); db(0x22); db(0x4c); db(0x4e); db(0xae); db(0xfe); db(0x38); db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x0f); - db(0x61); db(0x00); db(0x03); db(0xa2); db(0x4e); db(0x90); db(0x4a); db(0xad); + db(0x61); db(0x00); db(0x06); db(0xd2); db(0x4e); db(0x90); db(0x4a); db(0xad); db(0x00); db(0x00); db(0x66); db(0x1c); db(0x70); db(0x00); db(0x74); db(0x00); db(0x14); db(0x2d); db(0x00); db(0x4c); db(0x05); db(0xc0); db(0x08); db(0xc0); db(0x00); db(0x0d); db(0x4e); db(0xae); db(0xfe); db(0xc2); db(0x05); db(0x00); - db(0x67); db(0x06); db(0x61); db(0x00); db(0xfe); db(0x1e); db(0x60); db(0xe4); + db(0x67); db(0x06); db(0x61); db(0x00); db(0xfe); db(0x20); db(0x60); db(0xe4); db(0x20); db(0x2d); db(0x00); db(0x00); db(0x67); db(0x00); db(0x00); db(0x76); db(0x72); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x2b); db(0x40); db(0x00); db(0x04); db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x0c); - db(0x61); db(0x00); db(0x03); db(0x62); db(0x4e); db(0x90); db(0x4a); db(0x80); + db(0x61); db(0x00); db(0x06); db(0x92); db(0x4e); db(0x90); db(0x4a); db(0x80); db(0x67); db(0x40); db(0x4a); db(0xad); db(0x00); db(0x04); db(0x67); db(0x3a); db(0x39); db(0x7c); db(0x00); db(0x03); db(0x00); db(0x1c); db(0x42); db(0x2c); db(0x00); db(0x1f); db(0x42); db(0xac); db(0x00); db(0x20); db(0x29); db(0x6d); @@ -763,7 +819,7 @@ db(0x00); db(0x34); db(0x29); db(0x48); db(0x00); db(0x28); db(0x20); db(0x02); db(0x51); db(0x80); db(0x29); db(0x40); db(0x00); db(0x24); db(0x22); db(0x4c); db(0x4e); db(0xae); db(0xfe); db(0x38); db(0x30); db(0x3c); db(0xff); db(0x38); - db(0x72); db(0x0b); db(0x61); db(0x00); db(0x02); db(0x88); db(0x20); db(0x2c); + db(0x72); db(0x0b); db(0x61); db(0x00); db(0x05); db(0xb8); db(0x20); db(0x2c); db(0x00); db(0x20); db(0x4e); db(0x90); db(0x22); db(0x4a); db(0x20); db(0x02); db(0x4e); db(0xae); db(0xff); db(0x2e); db(0x4a); db(0xac); db(0x00); db(0x20); db(0x67); db(0x00); db(0xfe); db(0xda); db(0x41); db(0xed); db(0x00); db(0x30); @@ -777,25 +833,25 @@ db(0x4e); db(0xae); db(0xfe); db(0xbc); db(0x2c); db(0x5f); db(0x70); db(0x00); db(0x4e); db(0x75); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x74); db(0xff); db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x11); db(0x61); db(0x00); - db(0x02); db(0x1c); db(0x4e); db(0x90); db(0x08); db(0x00); db(0x00); db(0x01); + db(0x05); db(0x4c); db(0x4e); db(0x90); db(0x08); db(0x00); db(0x00); db(0x01); db(0x67); db(0x38); db(0x74); db(0x00); db(0x4e); db(0xae); db(0xff); db(0x7c); - db(0x41); db(0xee); db(0x01); db(0x5e); db(0x43); db(0xfa); db(0x02); db(0x2e); + db(0x41); db(0xee); db(0x01); db(0x5e); db(0x43); db(0xfa); db(0x05); db(0x5e); db(0x4e); db(0xae); db(0xfe); db(0xec); db(0x4a); db(0x80); db(0x67); db(0x1e); db(0x20); db(0x40); db(0x43); db(0xfa); db(0x00); db(0x22); db(0x24); db(0x68); db(0xff); db(0xe4); db(0x21); db(0x49); db(0xff); db(0xe4); db(0x22); db(0x48); db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x65); db(0x61); db(0x00); - db(0x01); db(0xe4); db(0x4e); db(0x90); db(0x74); db(0x01); db(0x4e); db(0xae); + db(0x05); db(0x14); db(0x4e); db(0x90); db(0x74); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x76); db(0x20); db(0x02); db(0x4e); db(0x75); db(0x59); db(0x8f); db(0x48); db(0xe7); db(0xc0); db(0x80); db(0x30); db(0x3c); db(0xff); db(0x38); - db(0x72); db(0x66); db(0x61); db(0x00); db(0x01); db(0xc8); db(0x4e); db(0x90); + db(0x72); db(0x66); db(0x61); db(0x00); db(0x04); db(0xf8); db(0x4e); db(0x90); db(0x4c); db(0xdf); db(0x01); db(0x03); db(0x4e); db(0x75); db(0x2c); db(0x78); - db(0x00); db(0x04); db(0x41); db(0xfa); db(0x02); db(0xb1); db(0x43); db(0xfa); + db(0x00); db(0x04); db(0x41); db(0xfa); db(0x05); db(0xf7); db(0x43); db(0xfa); db(0x00); db(0x14); db(0x70); db(0x0f); db(0x22); db(0x3c); db(0x00); db(0x00); - db(0x1f); db(0x40); db(0x61); db(0x00); db(0xe9); db(0xb2); db(0x4e); db(0x75); + db(0x1f); db(0x40); db(0x61); db(0x00); db(0xe7); db(0xfa); db(0x4e); db(0x75); db(0x00); db(0x00); db(0x00); db(0x10); db(0x00); db(0x00); db(0x00); db(0x00); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x70); db(0x00); db(0x43); db(0xfa); - db(0x02); db(0x9a); db(0x4e); db(0xae); db(0xfd); db(0xd8); db(0x72); db(0x02); - db(0x30); db(0x3c); db(0xff); db(0x3c); db(0x61); db(0x00); db(0x01); db(0x86); + db(0x05); db(0xe0); db(0x4e); db(0xae); db(0xfd); db(0xd8); db(0x72); db(0x02); + db(0x30); db(0x3c); db(0xff); db(0x3c); db(0x61); db(0x00); db(0x04); db(0xb6); db(0x24); db(0x48); db(0x72); db(0x01); db(0x4e); db(0x90); db(0x4a); db(0x81); db(0x67); db(0x0c); db(0x26); db(0x41); db(0x4e); db(0xae); db(0xfe); db(0x08); db(0x72); db(0x02); db(0x20); db(0x4b); db(0x4e); db(0x92); db(0x22); db(0x4e); @@ -826,7 +882,7 @@ db(0x7c); db(0xfc); db(0x4e); db(0x75); db(0xbc); db(0xfc); db(0x00); db(0x00); db(0x67); db(0x06); db(0x4e); db(0xae); db(0xff); db(0x6a); db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x38); db(0x3e); db(0x24); db(0x48); db(0x2c); db(0x78); - db(0x00); db(0x04); db(0x43); db(0xfa); db(0x01); db(0x96); db(0x4e); db(0xae); + db(0x00); db(0x04); db(0x43); db(0xfa); db(0x04); db(0xdc); db(0x4e); db(0xae); db(0xfe); db(0x68); db(0x2a); db(0x40); db(0x20); db(0x6d); db(0x00); db(0x22); db(0x20); db(0x28); db(0x00); db(0x18); db(0xe5); db(0x88); db(0x26); db(0x40); db(0x24); db(0xab); db(0x00); db(0x04); db(0x20); db(0x0a); db(0xe4); db(0x88); @@ -839,12 +895,114 @@ db(0x00); db(0x5c); db(0xe5); db(0x8a); db(0x22); db(0x42); db(0x22); db(0x51); db(0x4e); db(0xae); db(0xfe); db(0x92); db(0x22); db(0x02); db(0x43); db(0xfa); db(0x00); db(0x0e); db(0x30); db(0x3c); db(0xff); db(0x2c); db(0x61); db(0x00); - db(0x00); db(0x2c); db(0x4e); db(0x90); db(0x4e); db(0xd0); db(0x70); db(0x30); + db(0x03); db(0x5c); db(0x4e); db(0x90); db(0x4e); db(0xd0); db(0x70); db(0x30); db(0x60); db(0x0a); db(0x70); db(0x28); db(0x60); db(0x06); db(0x20); db(0x06); db(0x60); db(0x02); db(0x20); db(0x06); db(0x12); db(0xd8); db(0x53); db(0x80); db(0x6e); db(0xfa); db(0x4e); db(0x75); db(0x00); db(0x00); db(0x00); db(0x00); db(0x00); db(0x00); db(0x00); db(0x01); db(0x00); db(0x00); db(0x00); db(0x04); - db(0x00); db(0x00); db(0x00); db(0x02); db(0x41); db(0xfa); db(0xe5); db(0x86); + db(0x00); db(0x00); db(0x00); db(0x02); db(0x48); db(0xe7); db(0x00); db(0x22); + db(0x2c); db(0x78); db(0x00); db(0x04); db(0x20); db(0x3c); db(0x00); db(0x00); + db(0xff); db(0xfc); db(0x61); db(0x00); db(0x03); db(0x20); db(0x24); db(0x48); + db(0x20); db(0x08); db(0x42); db(0x40); db(0x20); db(0x40); db(0x21); db(0x4e); + db(0x3f); db(0xfc); db(0x70); db(0x1a); db(0x22); db(0x3c); db(0x00); db(0x01); + db(0x00); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x22); db(0x40); + db(0x41); db(0xfa); db(0x02); db(0xf8); db(0x23); db(0x48); db(0x00); db(0x0a); + db(0x23); db(0x4a); db(0x00); db(0x0e); db(0x41); db(0xfa); db(0x00); db(0xd6); + db(0x23); db(0x48); db(0x00); db(0x12); db(0x33); db(0x7c); db(0x02); db(0x70); + db(0x00); db(0x08); db(0x70); db(0x0d); db(0x4e); db(0xae); db(0xff); db(0x58); + db(0x4c); db(0xdf); db(0x44); db(0x00); db(0x4e); db(0x75); db(0x48); db(0xe7); + db(0xc0); db(0xf0); db(0x20); db(0x3c); db(0x00); db(0x00); db(0xf0); db(0x00); + db(0x61); db(0x00); db(0x02); db(0xd2); db(0x22); db(0x48); db(0x20); db(0x3c); + db(0x00); db(0x00); db(0x40); db(0x00); db(0x61); db(0x00); db(0x02); db(0xc6); + db(0x70); db(0x03); db(0x4a); db(0xe9); db(0x00); db(0x03); db(0x67); db(0x0e); + db(0xd0); db(0xfc); db(0x20); db(0x00); db(0xd2); db(0xfc); db(0x00); db(0x08); + db(0x51); db(0xc8); db(0xff); db(0xf0); db(0x60); db(0xd4); db(0x42); db(0x29); + db(0x00); db(0x02); db(0x48); db(0xe8); db(0x00); db(0xfc); db(0x00); db(0x0c); + db(0x48); db(0xe8); db(0x7c); db(0x00); db(0x00); db(0x2c); db(0x21); db(0x6f); + db(0x00); db(0x00); db(0x00); db(0x04); db(0x21); db(0x6f); db(0x00); db(0x04); + db(0x00); db(0x08); db(0x21); db(0x6f); db(0x00); db(0x08); db(0x00); db(0x24); + db(0x21); db(0x6f); db(0x00); db(0x0c); db(0x00); db(0x28); db(0x24); db(0x48); + db(0x26); db(0x49); db(0x42); db(0xaa); db(0x00); db(0x4c); db(0x4a); db(0x13); + db(0x67); db(0x0e); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x93); db(0xc9); + db(0x4e); db(0xae); db(0xfe); db(0xda); db(0x25); db(0x40); db(0x00); db(0x4c); + db(0x36); db(0xaf); db(0x00); db(0x18); db(0x4a); db(0x2b); db(0x00); db(0x02); + db(0x66); db(0x12); db(0x4a); db(0xaa); db(0x00); db(0x4c); db(0x67); db(0xf4); + db(0x20); db(0x3c); db(0x00); db(0x00); db(0x01); db(0x00); db(0x4e); db(0xae); + db(0xfe); db(0xc2); db(0x60); db(0xe8); db(0x17); db(0x7c); db(0x00); db(0x01); + db(0x00); db(0x02); db(0x20); db(0x4a); db(0x22); db(0x4b); db(0x4c); db(0xe8); + db(0x00); db(0xff); db(0x00); db(0x04); db(0x4c); db(0xe8); db(0x7c); db(0x00); + db(0x00); db(0x2c); db(0x2f); db(0x28); db(0x00); db(0x24); db(0x2f); db(0x28); + db(0x00); db(0x28); db(0x42); db(0xa8); db(0x00); db(0x4c); db(0x42); db(0x29); + db(0x00); db(0x03); db(0x22); db(0x5f); db(0x20); db(0x5f); db(0x4f); db(0xef); + db(0x00); db(0x1a); db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x30); db(0x30); + db(0x76); db(0x00); db(0x24); db(0x49); db(0x4a); db(0x2a); db(0x00); db(0x01); + db(0x67); db(0x36); db(0x76); db(0x01); db(0x20); db(0x0a); db(0x42); db(0x40); + db(0x20); db(0x40); db(0x72); db(0x03); db(0x22); db(0x48); db(0x2c); db(0x68); + db(0x3f); db(0xfc); db(0xd1); db(0xfc); db(0x00); db(0x00); db(0x40); db(0x00); + db(0xd3); db(0xfc); db(0x00); db(0x00); db(0xf0); db(0x00); db(0x4a); db(0x29); + db(0x00); db(0x03); db(0x67); db(0x08); db(0x0c); db(0x29); db(0x00); db(0xff); + db(0x00); db(0x07); db(0x67); db(0x64); db(0xd0); db(0xfc); db(0x20); db(0x00); + db(0xd2); db(0xfc); db(0x00); db(0x08); db(0x51); db(0xc9); db(0xff); db(0xe8); + db(0x4a); db(0x2a); db(0x00); db(0x02); db(0x67); db(0x4a); db(0x76); db(0x01); + db(0x20); db(0x0a); db(0x42); db(0x40); db(0x24); db(0x40); db(0x26); db(0x40); + db(0x2c); db(0x6a); db(0x3f); db(0xfc); db(0xd5); db(0xfc); db(0x00); db(0x00); + db(0x40); db(0x00); db(0xd7); db(0xfc); db(0x00); db(0x00); db(0xf0); db(0x00); + db(0x74); db(0x03); db(0x20); db(0x2a); db(0x00); db(0x4c); db(0x67); db(0x1c); + db(0x4a); db(0x2b); db(0x00); db(0x03); db(0x67); db(0x16); db(0x4a); db(0x2b); + db(0x00); db(0x02); db(0x6a); db(0x10); db(0x42); db(0xaa); db(0x00); db(0x4c); + db(0x22); db(0x40); db(0x20); db(0x3c); db(0x00); db(0x00); db(0x01); db(0x00); + db(0x4e); db(0xae); db(0xfe); db(0xbc); db(0xd4); db(0xfc); db(0x20); db(0x00); + db(0xd6); db(0xfc); db(0x00); db(0x08); db(0x51); db(0xca); db(0xff); db(0xd4); + db(0x20); db(0x03); db(0x4c); db(0xdf); db(0x0c); db(0x0c); db(0x4e); db(0x75); + db(0x48); db(0xe7); db(0x78); db(0x7e); db(0x49); db(0xe8); db(0x00); db(0x50); + db(0x4b); db(0xe9); db(0x00); db(0x04); db(0x38); db(0x15); db(0xd8); db(0x44); + db(0x47); db(0xfa); db(0x00); db(0x4c); db(0x32); db(0x33); db(0x40); db(0x00); + db(0x66); db(0x22); db(0x20); db(0x3c); db(0x00); db(0x00); db(0xff); db(0xf4); + db(0x61); db(0x00); db(0x01); db(0x62); db(0x20); db(0x10); db(0x67); db(0x14); + db(0x22); db(0x40); db(0x1b); db(0x7c); db(0x00); db(0xfe); db(0x00); db(0x03); + db(0x20); db(0x3c); db(0x00); db(0x00); db(0x01); db(0x00); db(0x4e); db(0xae); + db(0xfe); db(0xbc); db(0x60); db(0x1a); db(0xd6); db(0xc1); db(0x4c); db(0xec); + db(0x07); db(0x00); db(0x00); db(0x04); db(0x4c); db(0xec); db(0x00); db(0x07); + db(0x00); db(0x04); db(0x4e); db(0x93); db(0x29); db(0x40); db(0x00); db(0x04); + db(0x1b); db(0x7c); db(0x00); db(0x01); db(0x00); db(0x03); db(0x4c); db(0xdf); + db(0x7e); db(0x1e); db(0x60); db(0x00); db(0xff); db(0x18); db(0x00); db(0xcc); + db(0x00); db(0x2c); db(0x00); db(0x30); db(0x00); db(0x34); db(0x00); db(0x38); + db(0x00); db(0x3c); db(0x00); db(0x42); db(0x00); db(0x48); db(0x00); db(0x50); + db(0x00); db(0x5a); db(0x00); db(0x48); db(0x00); db(0x50); db(0x00); db(0x5a); + db(0x00); db(0x64); db(0x00); db(0x64); db(0x00); db(0x72); db(0x00); db(0x7a); + db(0x00); db(0x82); db(0x00); db(0x00); db(0x00); db(0x00); db(0x00); db(0xc8); + db(0x00); db(0x8a); db(0x20); db(0x81); db(0x4e); db(0x75); db(0x30); db(0x81); + db(0x4e); db(0x75); db(0x10); db(0x81); db(0x4e); db(0x75); db(0x20); db(0x10); + db(0x4e); db(0x75); db(0x70); db(0x00); db(0x30); db(0x10); db(0x4e); db(0x75); + db(0x70); db(0x00); db(0x10); db(0x10); db(0x4e); db(0x75); db(0x20); db(0x02); + db(0x4e); db(0xae); db(0xfd); db(0x90); db(0x4e); db(0x75); db(0x20); db(0x02); + db(0xd0); db(0x80); db(0x4e); db(0xae); db(0xfd); db(0x90); db(0x4e); db(0x75); + db(0x20); db(0x02); db(0xe5); db(0x88); db(0x4e); db(0xae); db(0xfd); db(0x90); + db(0x4e); db(0x75); db(0x53); db(0x42); db(0x67); db(0x04); db(0x12); db(0xd8); + db(0x66); db(0xf8); db(0x42); db(0x29); db(0xff); db(0xff); db(0x4e); db(0x75); + db(0x20); db(0xc1); db(0x53); db(0x82); db(0x66); db(0xfa); db(0x4e); db(0x75); + db(0x30); db(0xc1); db(0x53); db(0x82); db(0x66); db(0xfa); db(0x4e); db(0x75); + db(0x10); db(0xc1); db(0x53); db(0x82); db(0x66); db(0xfa); db(0x4e); db(0x75); + db(0x70); db(0x00); db(0x10); db(0x18); db(0x53); db(0x40); db(0x6b); db(0x08); + db(0x53); db(0x42); db(0x6b); db(0x04); db(0x12); db(0xd8); db(0x60); db(0xf4); + db(0x42); db(0x11); db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x3f); db(0x3e); + db(0x2c); db(0x48); db(0xd0); db(0xc1); db(0x48); db(0x7a); db(0x00); db(0x0a); + db(0x2f); db(0x08); db(0x4c); db(0xd2); db(0x3f); db(0xff); db(0x4e); db(0x75); + db(0x4c); db(0xdf); db(0x7c); db(0xfc); db(0x4e); db(0x75); db(0x48); db(0xe7); + db(0x3f); db(0x3e); db(0x48); db(0x7a); db(0xff); db(0xf4); db(0x2f); db(0x08); + db(0x4c); db(0xd1); db(0x7f); db(0xff); db(0x4e); db(0x75); db(0x20); db(0x05); + db(0x4e); db(0x75); db(0x48); db(0xe7); db(0xff); db(0xfe); db(0x28); db(0x48); + db(0x2a); db(0x4c); db(0x2e); db(0x01); db(0x7a); db(0x00); db(0x38); db(0x1c); + db(0x7c); db(0x00); db(0x3c); db(0x1c); db(0xd8); db(0x44); db(0x47); db(0xfa); + db(0xff); db(0x1e); db(0xd6); db(0xf3); db(0x40); db(0x00); db(0x4c); db(0xd4); + db(0x07); db(0x00); db(0x4c); db(0xd4); db(0x00); db(0x07); db(0x4e); db(0x93); + db(0x28); db(0x80); db(0x2a); db(0x00); db(0x4a); db(0x46); db(0x67); db(0x14); + db(0x36); db(0x06); db(0x02); db(0x46); db(0x00); db(0x0f); db(0xe0); db(0x4b); + db(0xc6); db(0xfc); db(0x00); db(0x14); db(0xe5); db(0x4e); db(0xd6); db(0x46); + db(0x2b); db(0x80); db(0x30); db(0x04); db(0xd8); db(0xfc); db(0x00); db(0x10); + db(0x53); db(0x87); db(0x66); db(0xc2); db(0x4c); db(0xdf); db(0x7f); db(0xff); + db(0x4e); db(0x75); db(0x55); db(0x41); db(0x45); db(0x20); db(0x62); db(0x6f); + db(0x61); db(0x72); db(0x64); db(0x00); db(0x41); db(0xfa); db(0xe0); db(0x96); db(0x02); db(0x80); db(0x00); db(0x00); db(0xff); db(0xff); db(0xd1); db(0xc0); db(0x4e); db(0x75); db(0x69); db(0x6e); db(0x70); db(0x75); db(0x74); db(0x2e); db(0x64); db(0x65); db(0x76); db(0x69); db(0x63); db(0x65); db(0x00); db(0x74); @@ -868,28 +1026,31 @@ db(0x75); db(0x73); db(0x65); db(0x20); db(0x64); db(0x72); db(0x69); db(0x76); db(0x65); db(0x72); db(0x00); db(0x55); db(0x41); db(0x45); db(0x20); db(0x68); db(0x65); db(0x61); db(0x72); db(0x74); db(0x20); db(0x62); db(0x65); db(0x61); - db(0x74); db(0x00); db(0x55); db(0x41); db(0x45); db(0x20); db(0x66); db(0x69); - db(0x6c); db(0x65); db(0x73); db(0x79); db(0x73); db(0x74); db(0x65); db(0x6d); + db(0x74); db(0x00); db(0x55); db(0x41); db(0x45); db(0x20); db(0x66); db(0x73); db(0x00); db(0x55); db(0x41); db(0x45); db(0x20); db(0x66); db(0x73); db(0x20); db(0x61); db(0x75); db(0x74); db(0x6f); db(0x6d); db(0x6f); db(0x75); db(0x6e); db(0x74); db(0x65); db(0x72); db(0x00); db(0x55); db(0x41); db(0x45); db(0x20); - db(0x66); db(0x73); db(0x20); db(0x61); db(0x75); db(0x74); db(0x6f); db(0x6d); - db(0x6f); db(0x75); db(0x6e); db(0x74); db(0x20); db(0x70); db(0x72); db(0x6f); - db(0x63); db(0x65); db(0x73); db(0x73); db(0x00); db(0x55); db(0x41); db(0x45); - db(0x20); db(0x64); db(0x65); db(0x62); db(0x75); db(0x67); db(0x67); db(0x65); - db(0x72); db(0x00); db(0x64); db(0x6f); db(0x73); db(0x2e); db(0x6c); db(0x69); - db(0x62); db(0x72); db(0x61); db(0x72); db(0x79); db(0x00); db(0x69); db(0x6e); - db(0x74); db(0x75); db(0x69); db(0x74); db(0x69); db(0x6f); db(0x6e); db(0x2e); - db(0x6c); db(0x69); db(0x62); db(0x72); db(0x61); db(0x72); db(0x79); db(0x00); - db(0x67); db(0x72); db(0x61); db(0x70); db(0x68); db(0x69); db(0x63); db(0x73); + db(0x66); db(0x73); db(0x20); db(0x77); db(0x6f); db(0x72); db(0x6b); db(0x65); + db(0x72); db(0x00); db(0x55); db(0x41); db(0x45); db(0x20); db(0x74); db(0x72); + db(0x61); db(0x70); db(0x20); db(0x77); db(0x6f); db(0x72); db(0x6b); db(0x65); + db(0x72); db(0x00); db(0x55); db(0x41); db(0x45); db(0x20); db(0x66); db(0x73); + db(0x20); db(0x61); db(0x75); db(0x74); db(0x6f); db(0x6d); db(0x6f); db(0x75); + db(0x6e); db(0x74); db(0x20); db(0x70); db(0x72); db(0x6f); db(0x63); db(0x65); + db(0x73); db(0x73); db(0x00); db(0x55); db(0x41); db(0x45); db(0x20); db(0x64); + db(0x65); db(0x62); db(0x75); db(0x67); db(0x67); db(0x65); db(0x72); db(0x00); + db(0x64); db(0x6f); db(0x73); db(0x2e); db(0x6c); db(0x69); db(0x62); db(0x72); + db(0x61); db(0x72); db(0x79); db(0x00); db(0x69); db(0x6e); db(0x74); db(0x75); + db(0x69); db(0x74); db(0x69); db(0x6f); db(0x6e); db(0x2e); db(0x6c); db(0x69); + db(0x62); db(0x72); db(0x61); db(0x72); db(0x79); db(0x00); db(0x67); db(0x72); + db(0x61); db(0x70); db(0x68); db(0x69); db(0x63); db(0x73); db(0x2e); db(0x6c); + db(0x69); db(0x62); db(0x72); db(0x61); db(0x72); db(0x79); db(0x00); db(0x65); + db(0x78); db(0x70); db(0x61); db(0x6e); db(0x73); db(0x69); db(0x6f); db(0x6e); db(0x2e); db(0x6c); db(0x69); db(0x62); db(0x72); db(0x61); db(0x72); db(0x79); - db(0x00); db(0x65); db(0x78); db(0x70); db(0x61); db(0x6e); db(0x73); db(0x69); - db(0x6f); db(0x6e); db(0x2e); db(0x6c); db(0x69); db(0x62); db(0x72); db(0x61); - db(0x72); db(0x79); db(0x00); db(0x46); db(0x69); db(0x6c); db(0x65); db(0x53); - db(0x79); db(0x73); db(0x74); db(0x65); db(0x6d); db(0x2e); db(0x72); db(0x65); - db(0x73); db(0x6f); db(0x75); db(0x72); db(0x63); db(0x65); db(0x00); db(0x6d); - db(0x65); db(0x67); db(0x61); db(0x63); db(0x68); db(0x69); db(0x70); db(0x20); - db(0x6d); db(0x65); db(0x6d); db(0x6f); db(0x72); db(0x79); db(0x00); db(0x46); - db(0x69); db(0x6c); db(0x65); db(0x20); db(0x53); db(0x79); db(0x73); db(0x74); - db(0x65); db(0x6d); db(0x00); db(0x00); db(0x00); db(0x00); db(0x03); db(0xf2); + db(0x00); db(0x46); db(0x69); db(0x6c); db(0x65); db(0x53); db(0x79); db(0x73); + db(0x74); db(0x65); db(0x6d); db(0x2e); db(0x72); db(0x65); db(0x73); db(0x6f); + db(0x75); db(0x72); db(0x63); db(0x65); db(0x00); db(0x6d); db(0x65); db(0x67); + db(0x61); db(0x63); db(0x68); db(0x69); db(0x70); db(0x20); db(0x6d); db(0x65); + db(0x6d); db(0x6f); db(0x72); db(0x79); db(0x00); db(0x46); db(0x69); db(0x6c); + db(0x65); db(0x20); db(0x53); db(0x79); db(0x73); db(0x74); db(0x65); db(0x6d); + db(0x00); db(0x00); db(0x00); db(0x00); db(0x00); db(0x00); db(0x03); db(0xf2); diff --git a/fsdb.cpp b/fsdb.cpp index 4bfaa51c..cf27ba96 100644 --- a/fsdb.cpp +++ b/fsdb.cpp @@ -12,6 +12,7 @@ #include "options.h" #include "uae.h" +#include "traps.h" #include "memory.h" #include "custom.h" #include "newcpu.h" diff --git a/hardfile.cpp b/hardfile.cpp index 497f6458..9487b684 100644 --- a/hardfile.cpp +++ b/hardfile.cpp @@ -36,7 +36,7 @@ #include "archivers/chd/harddisk.h" #endif -//#undef DEBUGME +#undef DEBUGME #define hf_log(fmt, ...) #define hf_log2(fmt, ...) #define scsi_log(fmt, ...) @@ -62,15 +62,17 @@ extern int log_scsiemu; #define ASYNC_REQUEST_CHANGEINT 10 struct hardfileprivdata { - volatile uaecptr d_request[MAX_ASYNC_REQUESTS]; - volatile int d_request_type[MAX_ASYNC_REQUESTS]; - volatile uae_u32 d_request_data[MAX_ASYNC_REQUESTS]; + uaecptr d_request[MAX_ASYNC_REQUESTS]; + uae_u8 *d_request_iobuf[MAX_ASYNC_REQUESTS]; + int d_request_type[MAX_ASYNC_REQUESTS]; + uae_u32 d_request_data[MAX_ASYNC_REQUESTS]; smp_comm_pipe requests; int thread_running; uae_sem_t sync_sem; uaecptr base; int changenum; uaecptr changeint; + struct scsi_data *sd; }; #define HFD_CHD_OTHER 5 @@ -224,7 +226,7 @@ void getchsgeometry_hdf (struct hardfiledata *hfd, uae_u64 size, int *pcyl, int } memset (block, 0, sizeof block); if (hfd) { - hdf_read (hfd, block, 0, 512); + hdf_read(hfd, block, 0, 512); if (block[0] == 'D' && block[1] == 'O' && block[2] == 'S') { int mode; for (mode = 0; mode < 2; mode++) { @@ -233,7 +235,7 @@ void getchsgeometry_hdf (struct hardfiledata *hfd, uae_u64 size, int *pcyl, int getchsgeometry2 (size, pcyl, phead, psectorspertrack, mode); rootblock = (2 + ((*pcyl) * (*phead) * (*psectorspertrack) - 1)) / 2; memset (block, 0, sizeof block); - hdf_read (hfd, block, (uae_u64)rootblock * 512, 512); + hdf_read(hfd, block, (uae_u64)rootblock * 512, 512); for (i = 0; i < 512; i += 4) chk += (block[i] << 24) | (block[i + 1] << 16) | (block[i + 2] << 8) | (block[i + 3] << 0); if (!chk && block[0] == 0 && block[1] == 0 && block[2] == 0 && block[3] == 2 && @@ -1030,7 +1032,7 @@ int hdf_read_rdb (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int le return v; } -int hdf_read (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len) +int hdf_read(struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len) { int v; @@ -1049,7 +1051,7 @@ int hdf_read (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len) return v; } -int hdf_write (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len) +int hdf_write(struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len) { int v; @@ -1071,30 +1073,68 @@ int hdf_write (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len) return v; } -static uae_u64 cmd_readx (struct hardfiledata *hfd, uae_u8 *dataptr, uae_u64 offset, uae_u64 len) +static uae_u64 cmd_readx(struct hardfiledata *hfd, uae_u8 *dataptr, uae_u64 offset, uae_u64 len) { gui_flicker_led (LED_HD, hfd->unitnum, 1); return hdf_read (hfd, dataptr, offset, len); } -static uae_u64 cmd_read (struct hardfiledata *hfd, uaecptr dataptr, uae_u64 offset, uae_u64 len) +static uae_u64 cmd_read(TrapContext *ctx, struct hardfiledata *hfd, uaecptr dataptr, uae_u64 offset, uae_u64 len) { - addrbank *bank_data = &get_mem_bank (dataptr); - if (!len || !bank_data || !bank_data->check (dataptr, len)) + if (!len) return 0; - return cmd_readx (hfd, bank_data->xlateaddr (dataptr), offset, len); + if (!ctx) { + addrbank *bank_data = &get_mem_bank (dataptr); + if (!bank_data || !bank_data->check (dataptr, len)) + return 0; + uae_u8 *buffer = bank_data->xlateaddr(dataptr); + return cmd_readx(hfd, buffer, offset, len); + } + int total = 0; + while (len > 0) { + uae_u8 buf[RTAREA_TRAP_DATA_EXTRA_SIZE]; + int max = RTAREA_TRAP_DATA_EXTRA_SIZE & ~511; + int size = len > max ? max : len; + if (cmd_readx(hfd, buf, offset, size) != size) + break; + trap_put_bytes(ctx, buf, dataptr, size); + offset += size; + dataptr += size; + len -= size; + total += size; + } + return total; } -static uae_u64 cmd_writex (struct hardfiledata *hfd, uae_u8 *dataptr, uae_u64 offset, uae_u64 len) +static uae_u64 cmd_writex(struct hardfiledata *hfd, uae_u8 *dataptr, uae_u64 offset, uae_u64 len) { gui_flicker_led (LED_HD, hfd->unitnum, 2); return hdf_write (hfd, dataptr, offset, len); } -static uae_u64 cmd_write (struct hardfiledata *hfd, uaecptr dataptr, uae_u64 offset, uae_u64 len) +static uae_u64 cmd_write(TrapContext *ctx, struct hardfiledata *hfd, uaecptr dataptr, uae_u64 offset, uae_u64 len) { - addrbank *bank_data = &get_mem_bank (dataptr); - if (!len || !bank_data || !bank_data->check (dataptr, len)) + if (!len) return 0; - return cmd_writex (hfd, bank_data->xlateaddr (dataptr), offset, len); + if (!ctx) { + addrbank *bank_data = &get_mem_bank (dataptr); + if (!bank_data || !bank_data->check (dataptr, len)) + return 0; + uae_u8 *buffer = bank_data->xlateaddr(dataptr); + return cmd_writex(hfd, buffer, offset, len); + } + int total = 0; + while (len > 0) { + uae_u8 buf[RTAREA_TRAP_DATA_EXTRA_SIZE]; + int max = RTAREA_TRAP_DATA_EXTRA_SIZE & ~511; + int size = len > max ? max : len; + trap_get_bytes(ctx, buf, dataptr, size); + if (cmd_writex(hfd, buf, offset, size) != size) + break; + offset += size; + dataptr += size; + len -= size; + total += size; + } + return total; } static int checkbounds (struct hardfiledata *hfd, uae_u64 offset, uae_u64 len) @@ -1179,6 +1219,7 @@ static uae_u64 get_scsi_6_offset(struct hardfiledata *hfd, struct hd_hardfiledat int scsi_hd_emulate (struct hardfiledata *hfd, struct hd_hardfiledata *hdhfd, uae_u8 *cmdbuf, int scsi_cmd_len, uae_u8 *scsi_data, int *data_len, uae_u8 *r, int *reply_len, uae_u8 *s, int *sense_len) { + TrapContext *ctx = NULL; if (cmdbuf == NULL) return 0; @@ -1393,7 +1434,7 @@ int scsi_hd_emulate (struct hardfiledata *hfd, struct hd_hardfiledata *hdhfd, ua len *= hfd->ci.blocksize; if (!checkbounds(hfd, offset, len)) goto outofbounds; - scsi_len = (uae_u32)cmd_readx (hfd, scsi_data, offset, len); + scsi_len = (uae_u32)cmd_readx(hfd, scsi_data, offset, len); break; case 0x0f: /* WRITE SECTOR BUFFER */ scsi_len = hfd->ci.blocksize; @@ -1413,7 +1454,7 @@ int scsi_hd_emulate (struct hardfiledata *hfd, struct hd_hardfiledata *hdhfd, ua len *= hfd->ci.blocksize; if (!checkbounds(hfd, offset, len)) goto outofbounds; - scsi_len = (uae_u32)cmd_writex (hfd, scsi_data, offset, len); + scsi_len = (uae_u32)cmd_writex(hfd, scsi_data, offset, len); break; case 0x5a: // MODE SENSE(10) case 0x1a: /* MODE SENSE(6) */ @@ -1773,73 +1814,76 @@ scsi_done: return status; } -static int handle_scsi (uaecptr request, struct hardfiledata *hfd) -{ - uae_u32 acmd = get_long (request + 40); - uaecptr scsi_data = get_long (acmd + 0); - int scsi_len = get_long (acmd + 4); - uaecptr scsi_cmd = get_long (acmd + 12); - uae_u16 scsi_cmd_len = get_word (acmd + 16); - uae_u8 scsi_flags = get_byte (acmd + 20); - uaecptr scsi_sense = get_long (acmd + 22); - uae_u16 scsi_sense_len = get_word (acmd + 26); - uae_u8 cmd = get_byte (scsi_cmd); - uae_u8 cmdbuf[256]; - int status, ret = 0, reply_len, sense_len; - uae_u32 i; - uae_u8 reply[256], sense[256]; - uae_u8 *scsi_data_ptr = NULL; - addrbank *bank_data = &get_mem_bank (scsi_data); - - if (bank_data && bank_data->check (scsi_data, scsi_len)) - scsi_data_ptr = bank_data->xlateaddr (scsi_data); +static int handle_scsi (TrapContext *ctx, uae_u8 *iobuf, uaecptr request, struct hardfiledata *hfd, struct scsi_data *sd) +{ + int ret = 0; + + uae_u32 scsicmdaddr = get_long_host(iobuf + 40); + + uae_u8 scsicmd[30]; + trap_get_bytes(ctx, scsicmd, scsicmdaddr, sizeof scsicmd); + + uaecptr scsi_data = get_long_host(scsicmd + 0); + int scsi_len = get_long_host(scsicmd + 4); + uaecptr scsi_cmd = get_long_host(scsicmd + 12); + uae_u16 scsi_cmd_len = get_word_host(scsicmd + 16); + uae_u8 scsi_flags = get_byte_host(scsicmd + 20); + uaecptr scsi_sense = get_long_host(scsicmd + 22); + uae_u16 scsi_sense_len = get_word_host(scsicmd + 26); + uae_u8 cmd = trap_get_byte(ctx, scsi_cmd); + scsi_sense_len = (scsi_flags & 4) ? 4 : /* SCSIF_OLDAUTOSENSE */ (scsi_flags & 2) ? scsi_sense_len : /* SCSIF_AUTOSENSE */ 32; - status = 0; - memset (reply, 0, sizeof reply); - reply_len = 0; sense_len = 0; scsi_log (_T("hdf scsiemu: cmd=%02X,%d flags=%02X sense=%p,%d data=%p,%d\n"), cmd, scsi_cmd_len, scsi_flags, scsi_sense, scsi_sense_len, scsi_data, scsi_len); - for (i = 0; i < scsi_cmd_len; i++) { - cmdbuf[i] = get_byte (scsi_cmd + i); - scsi_log (_T("%02X%c"), get_byte (scsi_cmd + i), i < scsi_cmd_len - 1 ? '.' : ' '); + + sd->cmd_len = scsi_cmd_len; + sd->data_len = scsi_len; + + 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("\n")); - status = scsi_hd_emulate (hfd, NULL, cmdbuf, scsi_cmd_len, scsi_data_ptr, &scsi_len, reply, &reply_len, sense, &sense_len); + scsi_emulate_analyze(sd); + scsi_start_transfer(sd); + if (sd->direction > 0) { + trap_get_bytes(ctx, sd->buffer, scsi_data, sd->data_len); + scsi_emulate_cmd(sd); + } else { + scsi_emulate_cmd(sd); + if (sd->direction < 0) + trap_put_bytes(ctx, sd->buffer, scsi_data, sd->data_len); + } - put_word (acmd + 18, status != 0 ? 0 : scsi_cmd_len); /* fake scsi_CmdActual */ - put_byte (acmd + 21, status); /* scsi_Status */ - if (reply_len > 0) { + put_word_host(scsicmd + 18, sd->status != 0 ? 0 : sd->cmd_len); /* fake scsi_CmdActual */ + put_byte_host(scsicmd + 21, sd->status); /* scsi_Status */ + if (sd->reply_len > 0) { + trap_put_bytes(ctx, sd->reply, scsi_data, sd->reply_len); scsi_log (_T("RD:")); - i = 0; - while (i < reply_len) { - if (i < 24) { - scsi_log (_T("%02X%c"), reply[i], i < reply_len - 1 ? '.' : ' '); - } - put_byte (scsi_data + i, reply[i]); + int i = 0; + while (i < sd->reply_len && i < 24) { + scsi_log (_T("%02X%c"), reply[i], i < reply_len - 1 ? '.' : ' '); i++; } scsi_log (_T("\n")); } - i = 0; if (scsi_sense) { - while (i < sense_len && i < scsi_sense_len) { - put_byte (scsi_sense + i, sense[i]); - i++; + trap_put_bytes(ctx, sd->sense, scsi_sense, sd->sense_len < scsi_sense_len ? sd->sense_len : scsi_sense_len); + if (scsi_sense_len > sd->sense_len) { + trap_set_bytes(ctx, scsi_sense + sd->sense_len, 0, scsi_sense_len - sd->sense_len); } } - while (i < scsi_sense_len && scsi_sense) { - put_byte (scsi_sense + i, 0); - i++; - } if (scsi_len < 0) { - put_long (acmd + 8, 0); /* scsi_Actual */ + put_long_host(scsicmd + 8, 0); /* scsi_Actual */ ret = 20; } else { - put_long (acmd + 8, scsi_len); /* scsi_Actual */ + put_long_host(scsicmd + 8, scsi_len); /* scsi_Actual */ } + + trap_put_bytes(ctx, scsicmd, scsicmdaddr, sizeof scsicmd); return ret; } @@ -1882,7 +1926,7 @@ void hardfile_do_disk_change (struct uaedev_config_data *uci, bool insert) hardfile_send_disk_change (hfd, insert); } -static int add_async_request (struct hardfileprivdata *hfpd, uaecptr request, int type, uae_u32 data) +static int add_async_request (struct hardfileprivdata *hfpd, uae_u8 *iobuf, uaecptr request, int type, uae_u32 data) { int i; @@ -1900,6 +1944,7 @@ static int add_async_request (struct hardfileprivdata *hfpd, uaecptr request, in while (i < MAX_ASYNC_REQUESTS) { if (hfpd->d_request[i] == 0) { hfpd->d_request[i] = request; + hfpd->d_request_iobuf[i] = iobuf; hfpd->d_request_type[i] = type; hfpd->d_request_data[i] = data; hf_log (_T("async request %p (%d) added (total=%d)\n"), request, type, i); @@ -1911,7 +1956,7 @@ static int add_async_request (struct hardfileprivdata *hfpd, uaecptr request, in return -1; } -static int release_async_request (struct hardfileprivdata *hfpd, uaecptr request) +static int release_async_request(struct hardfileprivdata *hfpd, uaecptr request) { int i = 0; @@ -1919,6 +1964,8 @@ static int release_async_request (struct hardfileprivdata *hfpd, uaecptr request if (hfpd->d_request[i] == request) { int type = hfpd->d_request_type[i]; hfpd->d_request[i] = 0; + xfree(hfpd->d_request_iobuf[i]); + hfpd->d_request_iobuf[i] = 0; hfpd->d_request_data[i] = 0; hfpd->d_request_type[i] = 0; hf_log (_T("async request %p removed\n"), request); @@ -1951,14 +1998,14 @@ static void abort_async (struct hardfileprivdata *hfpd, uaecptr request, int err } static void *hardfile_thread (void *devs); -static int start_thread (TrapContext *context, int unit) +static int start_thread (TrapContext *ctx, int unit) { struct hardfileprivdata *hfpd = &hardfpd[unit]; if (hfpd->thread_running) return 1; memset (hfpd, 0, sizeof (struct hardfileprivdata)); - hfpd->base = m68k_areg (regs, 6); + hfpd->base = trap_get_areg(ctx, 6); init_comm_pipe (&hfpd->requests, 100, 1); uae_sem_init (&hfpd->sync_sem, 0, 0); uae_start_thread (_T("hardfile"), hardfile_thread, hfpd, NULL); @@ -1977,10 +2024,10 @@ static int mangleunit (int unit) return -1; } -static uae_u32 REGPARAM2 hardfile_open (TrapContext *context) +static uae_u32 REGPARAM2 hardfile_open (TrapContext *ctx) { - uaecptr ioreq = m68k_areg (regs, 1); /* IOReq */ - int unit = mangleunit (m68k_dreg (regs, 0)); + uaecptr ioreq = trap_get_areg (ctx, 1); /* IOReq */ + int unit = mangleunit (trap_get_dreg(ctx, 0)); int err = IOERR_OPENFAIL; /* boot device port size == 0!? KS 1.x size = 12??? @@ -1991,27 +2038,29 @@ static uae_u32 REGPARAM2 hardfile_open (TrapContext *context) if (unit >= 0 && unit < MAX_FILESYSTEM_UNITS) { struct hardfileprivdata *hfpd = &hardfpd[unit]; struct hardfiledata *hfd = get_hardfile_data (unit); - if (hfd && (hfd->handle_valid || hfd->drive_empty) && start_thread (context, unit)) { - put_word (hfpd->base + 32, get_word (hfpd->base + 32) + 1); - put_long (ioreq + 24, unit); /* io_Unit */ - put_byte (ioreq + 31, 0); /* io_Error */ - put_byte (ioreq + 8, 7); /* ln_type = NT_REPLYMSG */ - hf_log (_T("hardfile_open, unit %d (%d), OK\n"), unit, m68k_dreg (regs, 0)); + 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 */ + trap_put_byte(ctx, ioreq + 31, 0); /* io_Error */ + trap_put_byte(ctx, ioreq + 8, 7); /* ln_type = NT_REPLYMSG */ + if (!hfpd->sd) + hfpd->sd = scsi_alloc_generic(hfd, UAEDEV_HDF); + hf_log (_T("hardfile_open, unit %d (%d), OK\n"), unit, trap_get_dreg (ctx, 0)); return 0; } } if (unit < 1000 || is_hardfile (unit) == FILESYS_VIRTUAL || is_hardfile (unit) == FILESYS_CD) err = 50; /* HFERR_NoBoard */ - hf_log (_T("hardfile_open, unit %d (%d), ERR=%d\n"), unit, m68k_dreg (regs, 0), err); - put_long (ioreq + 20, (uae_u32)err); - put_byte (ioreq + 31, (uae_u8)err); + hf_log (_T("hardfile_open, unit %d (%d), ERR=%d\n"), unit, trap_get_dreg(ctx, 0), err); + trap_put_long(ctx, ioreq + 20, (uae_u32)err); + trap_put_byte(ctx, ioreq + 31, (uae_u8)err); return (uae_u32)err; } -static uae_u32 REGPARAM2 hardfile_close (TrapContext *context) +static uae_u32 REGPARAM2 hardfile_close (TrapContext *ctx) { - uaecptr request = m68k_areg (regs, 1); /* IOReq */ - int unit = mangleunit (get_long (request + 24)); + uaecptr request = trap_get_areg (ctx, 1); /* IOReq */ + int unit = mangleunit (trap_get_long(ctx, request + 24)); if (unit < 0 || unit >= MAX_FILESYSTEM_UNITS) { return 0; } @@ -2019,8 +2068,9 @@ static uae_u32 REGPARAM2 hardfile_close (TrapContext *context) if (!hfpd) return 0; - put_word (hfpd->base + 32, get_word (hfpd->base + 32) - 1); - if (get_word (hfpd->base + 32) == 0) + scsi_free(hfpd->sd); + trap_put_word(ctx, hfpd->base + 32, trap_get_word(ctx, hfpd->base + 32) - 1); + if (trap_get_word(ctx, hfpd->base + 32) == 0) write_comm_pipe_u32 (&hfpd->requests, 0, 1); return 0; } @@ -2043,24 +2093,25 @@ static void unaligned (int cmd, uae_u64 offset, uae_u64 len, int blocksize) blocksize); } -static uae_u32 hardfile_do_io (struct hardfiledata *hfd, struct hardfileprivdata *hfpd, uaecptr request) +static uae_u32 hardfile_do_io (TrapContext *ctx, struct hardfiledata *hfd, struct hardfileprivdata *hfpd, uae_u8 *iobuf, uaecptr request) { uae_u32 dataptr, offset, actual = 0, cmd; uae_u64 offset64; - int unit = get_long (request + 24); + int unit; uae_u32 error = 0, len; int async = 0; int bmask = hfd->ci.blocksize - 1; - cmd = get_word (request + 28); /* io_Command */ - dataptr = get_long (request + 40); + unit = get_long_host(iobuf + 24); + cmd = get_word_host(iobuf + 28); /* io_Command */ + dataptr = get_long_host(iobuf + 40); switch (cmd) { case CMD_READ: if (nodisk (hfd)) goto no_disk; - offset = get_long (request + 44); - len = get_long (request + 36); /* io_Length */ + offset = get_long_host(iobuf + 44); + len = get_long_host(iobuf + 36); /* io_Length */ if (offset & bmask) { unaligned (cmd, offset, len, hfd->ci.blocksize); goto bad_command; @@ -2073,15 +2124,15 @@ static uae_u32 hardfile_do_io (struct hardfiledata *hfd, struct hardfileprivdata outofbounds (cmd, offset, len, hfd->virtsize); goto bad_len; } - actual = (uae_u32)cmd_read (hfd, dataptr, offset, len); + actual = (uae_u32)cmd_read(ctx, hfd, dataptr, offset, len); break; case TD_READ64: case NSCMD_TD_READ64: if (nodisk (hfd)) goto no_disk; - offset64 = get_long (request + 44) | ((uae_u64)get_long (request + 32) << 32); - len = get_long (request + 36); /* io_Length */ + offset64 = get_long_host(iobuf + 44) | ((uae_u64)get_long_host(iobuf + 32) << 32); + len = get_long_host(iobuf + 36); /* io_Length */ if (offset64 & bmask) { unaligned (cmd, offset64, len, hfd->ci.blocksize); goto bad_command; @@ -2094,7 +2145,7 @@ static uae_u32 hardfile_do_io (struct hardfiledata *hfd, struct hardfileprivdata outofbounds (cmd, offset64, len, hfd->virtsize); goto bad_len; } - actual = (uae_u32)cmd_read (hfd, dataptr, offset64, len); + actual = (uae_u32)cmd_read(ctx, hfd, dataptr, offset64, len); break; case CMD_WRITE: @@ -2104,8 +2155,8 @@ static uae_u32 hardfile_do_io (struct hardfiledata *hfd, struct hardfileprivdata if (hfd->ci.readonly || hfd->dangerous) { error = 28; /* write protect */ } else { - offset = get_long (request + 44); - len = get_long (request + 36); /* io_Length */ + offset = get_long_host(iobuf + 44); + len = get_long_host(iobuf + 36); /* io_Length */ if (offset & bmask) { unaligned (cmd, offset, len, hfd->ci.blocksize); goto bad_command; @@ -2118,7 +2169,7 @@ static uae_u32 hardfile_do_io (struct hardfiledata *hfd, struct hardfileprivdata outofbounds (cmd, offset, len, hfd->virtsize); goto bad_len; } - actual = (uae_u32)cmd_write (hfd, dataptr, offset, len); + actual = (uae_u32)cmd_write(ctx, hfd, dataptr, offset, len); } break; @@ -2131,8 +2182,8 @@ static uae_u32 hardfile_do_io (struct hardfiledata *hfd, struct hardfileprivdata if (hfd->ci.readonly || hfd->dangerous) { error = 28; /* write protect */ } else { - offset64 = get_long (request + 44) | ((uae_u64)get_long (request + 32) << 32); - len = get_long (request + 36); /* io_Length */ + offset64 = get_long_host(iobuf + 44) | ((uae_u64)get_long_host(iobuf + 32) << 32); + len = get_long_host(iobuf + 36); /* io_Length */ if (offset64 & bmask) { unaligned (cmd, offset64, len, hfd->ci.blocksize); goto bad_command; @@ -2145,16 +2196,16 @@ static uae_u32 hardfile_do_io (struct hardfiledata *hfd, struct hardfileprivdata outofbounds (cmd, offset64, len, hfd->virtsize); goto bad_len; } - actual = (uae_u32)cmd_write (hfd, dataptr, offset64, len); + actual = (uae_u32)cmd_write(ctx, hfd, dataptr, offset64, len); } break; case NSCMD_DEVICEQUERY: - put_long (dataptr + 0, 0); - put_long (dataptr + 4, 16); /* size */ - put_word (dataptr + 8, NSDEVTYPE_TRACKDISK); - put_word (dataptr + 10, 0); - put_long (dataptr + 12, nscmd_cmd); + trap_put_long(ctx, dataptr + 0, 0); + trap_put_long(ctx, dataptr + 4, 16); /* size */ + trap_put_word(ctx, dataptr + 8, NSDEVTYPE_TRACKDISK); + trap_put_word(ctx, dataptr + 10, 0); + trap_put_long(ctx, dataptr + 12, nscmd_cmd); actual = 16; break; @@ -2175,18 +2226,18 @@ static uae_u32 hardfile_do_io (struct hardfiledata *hfd, struct hardfileprivdata int cyl, cylsec, head, tracksec; uae_u64 size; getchsx (hfd, &cyl, &cylsec, &head, &tracksec); - put_long (dataptr + 0, hfd->ci.blocksize); + trap_put_long(ctx, dataptr + 0, hfd->ci.blocksize); size = hfd->virtsize / hfd->ci.blocksize; if (size > 0x00ffffffff) size = 0xffffffff; - put_long (dataptr + 4, (uae_u32)size); - put_long (dataptr + 8, cyl); - put_long (dataptr + 12, cylsec); - put_long (dataptr + 16, head); - put_long (dataptr + 20, tracksec); - put_long (dataptr + 24, 0); /* bufmemtype */ - put_byte (dataptr + 28, 0); /* type = DG_DIRECT_ACCESS */ - put_byte (dataptr + 29, 0); /* flags */ + trap_put_long(ctx, dataptr + 4, (uae_u32)size); + trap_put_long(ctx, dataptr + 8, cyl); + trap_put_long(ctx, dataptr + 12, cylsec); + trap_put_long(ctx, dataptr + 16, head); + trap_put_long(ctx, dataptr + 20, tracksec); + trap_put_long(ctx, dataptr + 24, 0); /* bufmemtype */ + trap_put_byte(ctx, dataptr + 28, 0); /* type = DG_DIRECT_ACCESS */ + trap_put_byte(ctx, dataptr + 29, 0); /* flags */ } break; @@ -2219,7 +2270,7 @@ static uae_u32 hardfile_do_io (struct hardfiledata *hfd, struct hardfileprivdata break; case CMD_ADDCHANGEINT: - error = add_async_request (hfpd, request, ASYNC_REQUEST_CHANGEINT, get_long (request + 40)); + error = add_async_request (hfpd, iobuf, request, ASYNC_REQUEST_CHANGEINT, get_long_host(iobuf + 40)); if (!error) async = 1; break; @@ -2229,7 +2280,7 @@ static uae_u32 hardfile_do_io (struct hardfiledata *hfd, struct hardfileprivdata case HD_SCSICMD: /* SCSI */ if (!hfd->ci.sectors && !hfd->ci.surfaces && !hfd->ci.reserved) { - error = handle_scsi (request, hfd); + error = handle_scsi(ctx, iobuf, request, hfd, hfpd->sd); } else { /* we don't want users trashing their "partition" hardfiles with hdtoolbox */ error = IOERR_NOCMD; write_log (_T("UAEHF: HD_SCSICMD tried on regular HDF, unit %d\n"), unit); @@ -2238,7 +2289,7 @@ static uae_u32 hardfile_do_io (struct hardfiledata *hfd, struct hardfileprivdata case CD_EJECT: if (hfd->ci.sectors && hfd->ci.surfaces) { - int len = get_long (request + 36); + int len = get_long_host(iobuf + 36); if (len) { if (hfd->drive_empty) { hardfile_media_change (hfd, NULL, true, false); @@ -2270,32 +2321,32 @@ no_disk: error = IOERR_NOCMD; break; } - put_long (request + 32, actual); - put_byte (request + 31, error); + put_long_host(iobuf + 32, actual); + put_byte_host(iobuf + 31, error); hf_log2 (_T("hf: unit=%d, request=%p, cmd=%d offset=%u len=%d, actual=%d error%=%d\n"), unit, request, - get_word (request + 28), get_long (request + 44), get_long (request + 36), actual, error); + get_word_host(iobuf + 28), get_long_host(iobuf + 44), get_long_host(iobuf + 36), actual, error); return async; } -static uae_u32 REGPARAM2 hardfile_abortio (TrapContext *context) +static uae_u32 REGPARAM2 hardfile_abortio (TrapContext *ctx) { - uae_u32 request = m68k_areg (regs, 1); - int unit = mangleunit (get_long (request + 24)); + 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 hardfileprivdata *hfpd = &hardfpd[unit]; hf_log2 (_T("uaehf.device abortio ")); - start_thread (context, unit); + start_thread (ctx, unit); if (!hfd || !hfpd || !hfpd->thread_running) { - put_byte (request + 31, 32); + trap_put_byte(ctx, request + 31, 32); hf_log2 (_T("error\n")); - return get_byte (request + 31); + return trap_get_byte(ctx, request + 31); } - put_byte (request + 31, -2); + trap_put_byte(ctx, request + 31, -2); hf_log2 (_T("unit=%d, request=%08X\n"), unit, request); - abort_async (hfpd, request, -2, 0); + abort_async(hfpd, request, -2, 0); return 0; } @@ -2320,43 +2371,59 @@ static int hardfile_can_quick (uae_u32 command) return 0; } -static int hardfile_canquick (struct hardfiledata *hfd, uaecptr request) +static int hardfile_canquick (TrapContext *ctx, struct hardfiledata *hfd, uae_u8 *iobuf) { - uae_u32 command = get_word (request + 28); + uae_u32 command = get_word_host(iobuf + 28); return hardfile_can_quick (command); } -static uae_u32 REGPARAM2 hardfile_beginio (TrapContext *context) +static uae_u32 REGPARAM2 hardfile_beginio (TrapContext *ctx) { - uae_u32 request = m68k_areg (regs, 1); - uae_u8 flags = get_byte (request + 30); - int cmd = get_word (request + 28); - int unit = mangleunit (get_long (request + 24)); - struct hardfiledata *hfd = get_hardfile_data (unit); - struct hardfileprivdata *hfpd = &hardfpd[unit]; int canquick; + uae_u32 request = trap_get_areg(ctx, 1); + + uae_u8 *iobuf = xmalloc(uae_u8, 48); + + trap_get_bytes(ctx, iobuf, request, 48); - put_byte (request + 8, NT_MESSAGE); - start_thread (context, unit); + uae_u8 flags = get_byte_host(iobuf + 30); + int cmd = get_word_host(iobuf + 28); + int unit = mangleunit(get_long_host(iobuf + 24)); + + struct hardfiledata *hfd = get_hardfile_data(unit); + struct hardfileprivdata *hfpd = &hardfpd[unit]; + + put_byte_host(iobuf + 8, NT_MESSAGE); + start_thread(ctx, unit); if (!hfd || !hfpd || !hfpd->thread_running) { - put_byte (request + 31, 32); - return get_byte (request + 31); - } - put_byte (request + 31, 0); - canquick = hardfile_canquick (hfd, request); + put_byte_host(iobuf + 31, 32); + uae_u8 v = get_byte_host(iobuf + 31); + trap_put_bytes(ctx, iobuf + 8, request + 8, 48 - 8); + xfree(iobuf); + return v; + } + put_byte_host(iobuf + 31, 0); + canquick = hardfile_canquick(ctx, hfd, iobuf); if (((flags & 1) && canquick) || (canquick < 0)) { hf_log (_T("hf quickio unit=%d request=%p cmd=%d\n"), unit, request, cmd); - if (hardfile_do_io(hfd, hfpd, request)) { + if (hardfile_do_io(ctx, hfd, hfpd, iobuf, request)) { hf_log2 (_T("uaehf.device cmd %d bug with IO_QUICK\n"), cmd); } + uae_u8 v = get_byte_host(iobuf + 31); + trap_put_bytes(ctx, iobuf + 8, request + 8, 48 - 8); + xfree(iobuf); if (!(flags & 1)) - uae_ReplyMsg (request); - return get_byte (request + 31); + uae_ReplyMsg(request); + return v; } else { hf_log2 (_T("hf asyncio unit=%d request=%p cmd=%d\n"), unit, request, cmd); - add_async_request (hfpd, request, ASYNC_REQUEST_TEMP, 0); - put_byte (request + 30, get_byte (request + 30) & ~1); - write_comm_pipe_u32 (&hfpd->requests, request, 1); + add_async_request(hfpd, iobuf, request, ASYNC_REQUEST_TEMP, 0); + put_byte_host(iobuf + 30, get_byte_host(iobuf + 30) & ~1); + trap_put_bytes(ctx, iobuf + 8, request + 8, 48 - 8); + trap_set_background(ctx); + write_comm_pipe_pvoid(&hfpd->requests, ctx, 0); + write_comm_pipe_pvoid(&hfpd->requests, iobuf, 0); + write_comm_pipe_u32(&hfpd->requests, request, 1); return 0; } } @@ -2369,6 +2436,8 @@ static void *hardfile_thread (void *devs) hfpd->thread_running = 1; uae_sem_post (&hfpd->sync_sem); for (;;) { + TrapContext *ctx = (TrapContext*)read_comm_pipe_pvoid_blocking(&hfpd->requests); + uae_u8 *iobuf = (uae_u8*)read_comm_pipe_pvoid_blocking(&hfpd->requests); uaecptr request = (uaecptr)read_comm_pipe_u32_blocking (&hfpd->requests); uae_sem_wait (&change_sem); if (!request) { @@ -2376,13 +2445,16 @@ static void *hardfile_thread (void *devs) uae_sem_post (&hfpd->sync_sem); uae_sem_post (&change_sem); return 0; - } else if (hardfile_do_io (get_hardfile_data (hfpd - &hardfpd[0]), hfpd, request) == 0) { - put_byte (request + 30, get_byte (request + 30) & ~1); - release_async_request (hfpd, request); - uae_ReplyMsg (request); + } else if (hardfile_do_io(ctx, get_hardfile_data (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); + uae_ReplyMsg(request); } else { hf_log2 (_T("async request %08X\n"), request); + trap_put_bytes(ctx, iobuf + 8, request + 8, 48 - 8); } + trap_background_set_complete(ctx); uae_sem_post (&change_sem); } } diff --git a/include/autoconf.h b/include/autoconf.h index 6abe7392..07dc9831 100644 --- a/include/autoconf.h +++ b/include/autoconf.h @@ -15,10 +15,38 @@ #define RTAREA_BACKUP 0xef0000 #define RTAREA_BACKUP_2 0xdb0000 #define RTAREA_SIZE 0x10000 -#define RTAREA_TRAPS 0x2000 -#define RTAREA_RTG 0x3000 + +#define RTAREA_TRAPS 0x3000 +#define RTAREA_RTG 0x3800 +#define RTAREA_TRAMPOLINE 0x3b00 +#define RTAREA_DATAREGION 0xF000 + #define RTAREA_FSBOARD 0xFFEC -#define RTAREA_INT 0xFFEB +#define RTAREA_HEARTBEAT 0xFFF0 +#define RTAREA_TRAPTASK 0xFFF4 +#define RTAREA_EXTERTASK 0xFFF8 +#define RTAREA_INTREQ 0xFFFC + +#define RTAREA_TRAP_DATA 0x4000 +#define RTAREA_TRAP_DATA_SIZE 0x8000 +#define RTAREA_TRAP_DATA_SLOT_SIZE 0x2000 // 8192 +#define RTAREA_TRAP_DATA_SECOND 80 +#define RTAREA_TRAP_DATA_TASKWAIT (RTAREA_TRAP_DATA_SECOND - 4) +#define RTAREA_TRAP_DATA_EXTRA 144 +#define RTAREA_TRAP_DATA_EXTRA_SIZE (RTAREA_TRAP_DATA_SLOT_SIZE - RTAREA_TRAP_DATA_EXTRA) + +#define RTAREA_TRAP_SEND_DATA 0xc0000 +#define RTAREA_TRAP_SEND_DATA_SIZE 0x2000 + +#define RTAREA_TRAP_STATUS 0xF000 +#define RTAREA_TRAP_STATUS_SIZE 8 +#define RTAREA_TRAP_STATUS_SECOND 4 + +#define RTAREA_TRAP_SEND_STATUS 0xF100 + +#define RTAREA_SYSBASE 0x3FFC + +#define RTAREA_TRAP_DATA_NUM (RTAREA_TRAP_DATA_SIZE / RTAREA_TRAP_DATA_SLOT_SIZE) extern uae_u32 addr (int); extern void db (uae_u8); @@ -35,9 +63,9 @@ extern uaecptr makedatatable (uaecptr resid, uaecptr resname, uae_u8 type, uae_s extern void align (int); -extern volatile int uae_int_requested, uaenet_int_requested; -extern volatile int uaenet_vsync_requested; -extern void set_uae_int_flag (void); +extern volatile uae_atomic uae_int_requested; +extern void rtarea_reset(void); +extern bool rethink_traps(void); #define RTS 0x4e75 #define RTE 0x4e73 @@ -93,6 +121,7 @@ extern void filesys_vsync (void); extern void filesys_install (void); extern void filesys_install_code (void); +extern uaecptr filesys_get_entry(int); extern void filesys_store_devinfo (uae_u8 *); extern void hardfile_install (void); extern void hardfile_reset (void); diff --git a/include/bsdsocket.h b/include/bsdsocket.h index a250fabf..a04ae57d 100644 --- a/include/bsdsocket.h +++ b/include/bsdsocket.h @@ -140,8 +140,8 @@ uae_u32 addmem (uae_u32 * dst, const uae_char *src, int len); #define SB struct socketbase *sb -extern void bsdsocklib_seterrno (SB, int); -extern void bsdsocklib_setherrno (SB, int); +extern void bsdsocklib_seterrno(TrapContext*, SB, int); +extern void bsdsocklib_setherrno(TrapContext*, SB, int); extern void sockabort (SB); @@ -204,7 +204,7 @@ extern uae_u32 host_Dup2Socket (void); extern uae_u32 host_gethostname (uae_u32, uae_u32); extern uae_u32 callfdcallback (TrapContext *context, SB, uae_u32 fd, uae_u32 action); -extern uaecptr bsdlib_startup (uaecptr); +extern uaecptr bsdlib_startup (TrapContext*, uaecptr); extern void bsdlib_install (void); extern void bsdlib_reset (void); diff --git a/include/filesys.h b/include/filesys.h index ad111a89..37c15155 100644 --- a/include/filesys.h +++ b/include/filesys.h @@ -10,6 +10,7 @@ #define UAE_FILESYS_H #include "uae/types.h" +#include "traps.h" struct hardfilehandle; @@ -130,12 +131,12 @@ extern int hdf_open (struct hardfiledata *hfd, const TCHAR *altname); extern int hdf_dup (struct hardfiledata *dhfd, const struct hardfiledata *shfd); extern void hdf_close (struct hardfiledata *hfd); extern int hdf_read_rdb (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len); -extern int hdf_read (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len); -extern int hdf_write (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len); +extern int hdf_read(struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len); +extern int hdf_write(struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len); extern int hdf_getnumharddrives (void); extern TCHAR *hdf_getnameharddrive (int index, int flags, int *sectorsize, int *dangerousdrive); extern int isspecialdrive(const TCHAR *name); -extern int get_native_path(uae_u32 lock, TCHAR *out); +extern int get_native_path(TrapContext *ctx, uae_u32 lock, TCHAR *out); extern void hardfile_do_disk_change (struct uaedev_config_data *uci, bool insert); extern void hardfile_send_disk_change (struct hardfiledata *hfd, bool insert); extern int hardfile_media_change (struct hardfiledata *hfd, struct uaedev_config_info *ci, bool inserted, bool timer); diff --git a/include/memory.h b/include/memory.h index 7bd0ce32..72487762 100644 --- a/include/memory.h +++ b/include/memory.h @@ -73,8 +73,8 @@ enum { ABFLAG_UNK = 0, ABFLAG_RAM = 1, ABFLAG_ROM = 2, ABFLAG_ROMIN = 4, ABFLAG_IO = 8, ABFLAG_NONE = 16, ABFLAG_SAFE = 32, ABFLAG_INDIRECT = 64, ABFLAG_NOALLOC = 128, - ABFLAG_RTG = 256, ABFLAG_THREADSAFE = 512, ABFLAG_DIRECTMAP = 1024, - ABFLAG_CHIPRAM = 2048, ABFLAG_CIA = 4096, ABFLAG_PPCIOSPACE = 8192 + ABFLAG_RTG = 256, ABFLAG_THREADSAFE = 512, ABFLAG_DIRECTMAP = 1024, ABFLAG_ALLOCINDIRECT = 2048, + ABFLAG_CHIPRAM = 4096, ABFLAG_CIA = 8192, ABFLAG_PPCIOSPACE = 16384, }; typedef struct { /* These ones should be self-explanatory... */ @@ -267,9 +267,10 @@ extern addrbank extendedkickmem2_bank; extern addrbank custmem1_bank; extern addrbank custmem2_bank; -extern void rtarea_init (void); -extern void rtarea_init_mem (void); -extern void rtarea_setup (void); +extern void rtarea_init(void); +extern void rtarea_free(void); +extern void rtarea_init_mem(void); +extern void rtarea_setup(void); extern void expamem_init (void); extern void expamem_reset (void); extern void expamem_next (addrbank *mapped, addrbank *next); @@ -533,6 +534,31 @@ STATIC_INLINE int valid_address (uaecptr addr, uae_u32 size) return get_mem_bank (addr).check(addr, size); } +STATIC_INLINE void put_long_host(void *addr, uae_u32 v) +{ + do_put_mem_long((uae_u32*)addr, v); +} +STATIC_INLINE void put_word_host(void *addr, uae_u16 v) +{ + do_put_mem_word((uae_u16*)addr, v); +} +STATIC_INLINE void put_byte_host(void *addr, uae_u8 v) +{ + *((uae_u8*)addr) = v; +} +STATIC_INLINE uae_u32 get_long_host(void *addr) +{ + return do_get_mem_long((uae_u32*)addr); +} +STATIC_INLINE uae_u16 get_word_host(void *addr) +{ + return do_get_mem_word((uae_u16*)addr); +} +STATIC_INLINE uae_u32 get_byte_host(void *addr) +{ + return *((uae_u8*)addr); +} + extern int addr_valid (const TCHAR*, uaecptr,uae_u32); /* For faster access in custom chip emulation. */ diff --git a/include/native2amiga.h b/include/native2amiga.h index 7a3bafe1..ef770c9f 100644 --- a/include/native2amiga.h +++ b/include/native2amiga.h @@ -52,8 +52,7 @@ extern smp_comm_pipe native2amiga_pending; STATIC_INLINE void do_uae_int_requested (void) { - uae_int_requested |= 1; - set_uae_int_flag (); + atomic_or(&uae_int_requested, 1); } #endif /* UAE_NATIVE2AMIGA_H */ diff --git a/include/native2amiga_api.h b/include/native2amiga_api.h index df2ea8b4..f313ef6d 100644 --- a/include/native2amiga_api.h +++ b/include/native2amiga_api.h @@ -16,7 +16,6 @@ void uae_PutMsg(uaecptr port, uaecptr msg); void uae_Signal(uaecptr task, uae_u32 mask); void uae_NotificationHack(uaecptr, uaecptr); #endif -void uae_NewList(uaecptr list); -int native2amiga_isfree (void); +int native2amiga_isfree(void); #endif /* UAE_NATIVE2AMIGA_API_H */ diff --git a/include/newcpu.h b/include/newcpu.h index c854338b..1ca089ce 100644 --- a/include/newcpu.h +++ b/include/newcpu.h @@ -161,7 +161,7 @@ struct regstruct uae_u32 instruction_pc; uae_u16 irc, ir, db; - volatile uae_u32 spcflags; + volatile uae_atomic spcflags; uae_u32 last_prefetch; uae_u32 chipset_latch_rw; uae_u32 chipset_latch_read; @@ -270,31 +270,20 @@ extern int mmu_enabled, mmu_triggered; extern int cpu_cycles; extern int cpucycleunit; extern int m68k_pc_indirect; + +STATIC_INLINE void set_special_exter(uae_u32 x) +{ + atomic_or(®s.spcflags, x); +} STATIC_INLINE void set_special (uae_u32 x) { -#ifdef WITH_THREADED_CPU -#ifdef _WIN32 - _InterlockedOr((volatile long*)®s.spcflags, x); -#else - regs.spcflags |= x; -#endif -#else - regs.spcflags |= x; -#endif + atomic_or(®s.spcflags, x); cycles_do_special (); } STATIC_INLINE void unset_special (uae_u32 x) { -#ifdef WITH_THREADED_CPU -#ifdef _WIN32 - _InterlockedAnd((volatile long*)®s.spcflags, ~x); -#else - regs.spcflags &= ~x; -#endif -#else - regs.spcflags &= ~x; -#endif + atomic_and(®s.spcflags, ~x); } #define m68k_dreg(r,num) ((r).regs[(num)]) diff --git a/include/sana2.h b/include/sana2.h index b5bb7bed..3081aabc 100644 --- a/include/sana2.h +++ b/include/sana2.h @@ -13,10 +13,11 @@ #define MAX_TOTAL_NET_DEVICES 10 -uaecptr netdev_startup (uaecptr resaddr); -void netdev_install (void); -void netdev_reset (void); -void netdev_start_threads (void); +uaecptr netdev_startup(TrapContext*, uaecptr resaddr); +void netdev_install(void); +void netdev_reset(void); +void netdev_start_threads(void); +void uaenet_vsync(void); extern int log_net; diff --git a/include/scsidev.h b/include/scsidev.h index 3f25ad8e..073334f8 100644 --- a/include/scsidev.h +++ b/include/scsidev.h @@ -13,7 +13,7 @@ #include "uae/types.h" -uaecptr scsidev_startup (uaecptr resaddr); +uaecptr scsidev_startup(TrapContext*, uaecptr resaddr); void scsidev_install (void); void scsidev_reset (void); void scsidev_start_threads (void); diff --git a/include/tabletlibrary.h b/include/tabletlibrary.h index f0931939..59715140 100644 --- a/include/tabletlibrary.h +++ b/include/tabletlibrary.h @@ -3,12 +3,12 @@ #include "uae/types.h" -uaecptr tabletlib_startup (uaecptr resaddr); -void tabletlib_install (void); +uaecptr tabletlib_startup(TrapContext*, uaecptr resaddr); +void tabletlib_install(void); -extern void tabletlib_tablet (int x, int y, int z, +extern void tabletlib_tablet(int x, int y, int z, int pressure, int maxpressure, uae_u32 buttonbits, int inproximity, int ax, int ay, int az); -extern void tabletlib_tablet_info (int maxx, int maxy, int maxz, int maxax, int maxay, int maxaz, int xres, int yres); +extern void tabletlib_tablet_info(int maxx, int maxy, int maxz, int maxax, int maxay, int maxaz, int xres, int yres); #endif /* UAE_TABLETLIBRARY_H */ diff --git a/include/traps.h b/include/traps.h index 1271abea..8057e356 100644 --- a/include/traps.h +++ b/include/traps.h @@ -15,6 +15,37 @@ #include "uae/types.h" + +#define TRAPCMD_MULTI 0 +#define TRAPCMD_PUT_LONG 1 +#define TRAPCMD_PUT_WORD 2 +#define TRAPCMD_PUT_BYTE 3 +#define TRAPCMD_GET_LONG 4 +#define TRAPCMD_GET_WORD 5 +#define TRAPCMD_GET_BYTE 6 +#define TRAPCMD_PUT_BYTES 7 +#define TRAPCMD_PUT_WORDS 8 +#define TRAPCMD_PUT_LONGS 9 +#define TRAPCMD_GET_BYTES 10 +#define TRAPCMD_GET_WORDS 11 +#define TRAPCMD_GET_LONGS 12 +#define TRAPCMD_PUT_STRING 13 +#define TRAPCMD_GET_STRING 14 +#define TRAPCMD_SET_LONGS 15 +#define TRAPCMD_SET_WORDS 16 +#define TRAPCMD_SET_BYTES 17 +#define TRAPCMD_CALL_LIB 18 +#define TRAPCMD_CALL_FUNC 19 +#define TRAPCMD_NOP 20 +#define TRAPCMD_GET_BSTR 21 + +struct trapmd { + uae_u16 cmd; + uae_u32 params[4]; + uae_u8 trapmd_index, parm_num; + uae_u8 *haddr; +}; + /* * Data passed to a trap handler */ @@ -50,11 +81,55 @@ extern uae_u32 CallFunc (TrapContext *context, uaecptr func); /* * Initialization */ -void init_traps (void); -void init_extended_traps (void); +void init_traps(void); +void free_traps(void); +void init_extended_traps(void); -#define deftrap(f) define_trap((f), 0, _T("")) +#define deftrap(f) define_trap((f), 0, _T(#f)) #define deftrap2(f, mode, str) define_trap((f), (mode), (str)) #define deftrapres(f, mode, str) define_trap((f), (mode | TRAPFLAG_UAERES), (str)) +/* New trap system */ + +void call_hardware_trap(uae_u8*, uaecptr, int); +void trap_set_background(TrapContext *ctx); +void trap_background_set_complete(TrapContext *ctx); +bool trap_valid_address(TrapContext *ctx, uaecptr addr, uae_u32 size); +bool trap_is_indirect(void); + +uae_u32 trap_get_dreg(TrapContext *context, int reg); +uae_u32 trap_get_areg(TrapContext *context, int reg); +void trap_set_dreg(TrapContext *context, int reg, uae_u32 v); +void trap_set_areg(TrapContext *context, int reg, uae_u32 v); + +void trap_put_long(TrapContext *context, uaecptr addr, uae_u32 v); +void trap_put_word(TrapContext *context, uaecptr addr, uae_u16 v); +void trap_put_byte(TrapContext *context, uaecptr addr, uae_u8 v); + +uae_u32 trap_get_long(TrapContext *context, uaecptr addr); +uae_u16 trap_get_word(TrapContext *context, uaecptr addr); +uae_u8 trap_get_byte(TrapContext *context, uaecptr addr); + +void trap_put_bytes(TrapContext *context, void *haddrp, uaecptr addr, int cnt); +void trap_get_bytes(TrapContext *context, void *haddrp, uaecptr addr, int cnt); +void trap_put_longs(TrapContext *context, uae_u32 *haddr, uaecptr addr, int cnt); +void trap_get_longs(TrapContext *context, uae_u32 *haddr, uaecptr addr, int cnt); +void trap_put_words(TrapContext *context, uae_u16 *haddr, uaecptr addr, int cnt); +void trap_get_words(TrapContext *context, uae_u16 *haddr, uaecptr addr, int cnt); + +int trap_put_string(TrapContext *context, void *haddrp, uaecptr addr, int maxlen); +int trap_get_string(TrapContext *context, void *haddrp, uaecptr addr, int maxlen); + +void trap_set_longs(TrapContext *ctx, uaecptr addr, uae_u32 v, int cnt); +void trap_set_words(TrapContext *ctx, uaecptr addr, uae_u16 v, int cnt); +void trap_set_bytes(TrapContext *ctx, uaecptr addr, uae_u8 v, int cnt); + +void trap_multi(TrapContext *ctx, struct trapmd *data, int items); + +void trap_call_add_dreg(TrapContext *ctx, int reg, uae_u32 v); +void trap_call_add_areg(TrapContext *ctx, int reg, uae_u32 v); +uae_u32 trap_call_lib(TrapContext *ctx, uaecptr base, uae_s16 offset); +uae_u32 trap_call_func(TrapContext *ctx, uaecptr func); + + #endif /* UAE_TRAPS_H */ diff --git a/include/uaenative.h b/include/uaenative.h index bedf9dde..9d1abd0b 100644 --- a/include/uaenative.h +++ b/include/uaenative.h @@ -26,7 +26,7 @@ uae_u32 uaenative_close_library(TrapContext *context, int flags); void *uaenative_get_uaevar(void); void uaenative_install (); -uaecptr uaenative_startup (uaecptr resaddr); +uaecptr uaenative_startup(TrapContext*, uaecptr resaddr); /* This function must return a list of directories to look for native * libraries in. The returned list must be NULL-terminated, and must not diff --git a/include/uaeresource.h b/include/uaeresource.h index 22766d66..97235fba 100644 --- a/include/uaeresource.h +++ b/include/uaeresource.h @@ -3,7 +3,7 @@ #include "uae/types.h" -uaecptr uaeres_startup (uaecptr resaddr); -void uaeres_install (void); +uaecptr uaeres_startup(TrapContext *ctx, uaecptr resaddr); +void uaeres_install(void); #endif /* UAE_UAERESOURCE_H */ diff --git a/include/uaeserial.h b/include/uaeserial.h index b69d30cb..ae41be5f 100644 --- a/include/uaeserial.h +++ b/include/uaeserial.h @@ -11,10 +11,10 @@ #include "uae/types.h" -uaecptr uaeserialdev_startup (uaecptr resaddr); -void uaeserialdev_install (void); -void uaeserialdev_reset (void); -void uaeserialdev_start_threads (void); +uaecptr uaeserialdev_startup(TrapContext*, uaecptr resaddr); +void uaeserialdev_install(void); +void uaeserialdev_reset(void); +void uaeserialdev_start_threads(void); extern int log_uaeserial; diff --git a/native2amiga.cpp b/native2amiga.cpp index a8c60c41..74bfdb33 100644 --- a/native2amiga.cpp +++ b/native2amiga.cpp @@ -106,23 +106,16 @@ void uae_NotificationHack (uaecptr port, uaecptr nr) #endif -void uae_NewList (uaecptr list) +uaecptr uae_AllocMem (TrapContext *ctx, uae_u32 size, uae_u32 flags, uaecptr sysbase) { - x_put_long (list, list + 4); - x_put_long (list + 4, 0); - x_put_long (list + 8, list); + trap_set_dreg(ctx, 0, size); + trap_set_dreg(ctx, 1, flags); + return CallLib(ctx, sysbase, -198); /* AllocMem */ } -uaecptr uae_AllocMem (TrapContext *context, uae_u32 size, uae_u32 flags, uaecptr sysbase) +void uae_FreeMem (TrapContext *ctx, uaecptr memory, uae_u32 size, uaecptr sysbase) { - m68k_dreg (regs, 0) = size; - m68k_dreg (regs, 1) = flags; - return CallLib (context, sysbase, -198); /* AllocMem */ -} - -void uae_FreeMem (TrapContext *context, uaecptr memory, uae_u32 size, uaecptr sysbase) -{ - m68k_dreg (regs, 0) = size; - m68k_areg (regs, 1) = memory; - CallLib (context, sysbase, -0xD2); /* FreeMem */ + trap_set_dreg(ctx, 0, size); + trap_set_areg(ctx, 1, memory); + CallLib(ctx, sysbase, -0xD2); /* FreeMem */ } diff --git a/od-win32/blkdev_win32_spti.cpp b/od-win32/blkdev_win32_spti.cpp index bc97f9a2..e87cbb70 100644 --- a/od-win32/blkdev_win32_spti.cpp +++ b/od-win32/blkdev_win32_spti.cpp @@ -17,6 +17,7 @@ #ifdef WINDDK +#include "traps.h" #include "memory.h" #include "threaddep/thread.h" #include "blkdev.h" diff --git a/od-win32/bsdsock.cpp b/od-win32/bsdsock.cpp index f39d3015..1cd54cf9 100644 --- a/od-win32/bsdsock.cpp +++ b/od-win32/bsdsock.cpp @@ -103,12 +103,12 @@ extern HWND hAmigaWnd; #define THREAD(func,arg) (HANDLE)_beginthreadex(NULL, 0, func, arg, 0, &bsd->threadid) #define THREADEND(result) _endthreadex(result) -#define SETERRNO bsdsocklib_seterrno(sb, WSAGetLastError() - WSABASEERR) -#define SETHERRNO bsdsocklib_setherrno(sb, WSAGetLastError() - WSABASEERR) -#define WAITSIGNAL waitsig(context, sb) +#define SETERRNO bsdsocklib_seterrno(ctx, sb, WSAGetLastError() - WSABASEERR) +#define SETHERRNO bsdsocklib_setherrno(ctx, sb, WSAGetLastError() - WSABASEERR) +#define WAITSIGNAL waitsig(ctx, sb) #define SETSIGNAL addtosigqueue(sb,0) -#define CANCELSIGNAL cancelsig(context, sb) +#define CANCELSIGNAL cancelsig(ctx, sb) #define FIOSETOWN _IOW('f', 124, long) /* set owner (struct Task *) */ #define FIOGETOWN _IOR('f', 123, long) /* get owner (struct Task *) */ @@ -446,15 +446,15 @@ static void sockmsg(unsigned int msg, WPARAM wParam, LPARAM lParam) bsd->asyncsb[index] = NULL; if (WSAGETASYNCERROR(lParam)) { - bsdsocklib_seterrno(sb, WSAGETASYNCERROR(lParam) - WSABASEERR); + bsdsocklib_seterrno(NULL, sb, WSAGETASYNCERROR(lParam) - WSABASEERR); if (sb->sb_errno >= 1001 && sb->sb_errno <= 1005) { - bsdsocklib_setherrno(sb, sb->sb_errno - 1000); + bsdsocklib_setherrno(NULL, sb, sb->sb_errno - 1000); } else if (sb->sb_errno == 55) { // ENOBUFS write_log (_T("BSDSOCK: ERROR - Buffer overflow - %d bytes requested\n"), WSAGETASYNCBUFLEN(lParam)); } } else { - bsdsocklib_seterrno(sb,0); + bsdsocklib_seterrno(NULL, sb,0); } SETSIGNAL; @@ -487,13 +487,13 @@ static unsigned int allocasyncmsg(SB,uae_u32 sd,SOCKET s) } unlocksigqueue(); - bsdsocklib_seterrno(sb, 12); // ENOMEM + bsdsocklib_seterrno(NULL, sb, 12); // ENOMEM write_log (_T("BSDSOCK: ERROR - Async operation completion table overflow\n")); return 0; } -static void cancelasyncmsg(TrapContext *context, unsigned int wMsg) +static void cancelasyncmsg(TrapContext *ctx, unsigned int wMsg) { SB; @@ -564,7 +564,7 @@ static void prepamigaaddr(struct sockaddr *realpt, int len) } -int host_dup2socket(TrapContext *context, SB, int fd1, int fd2) +int host_dup2socket(TrapContext *ctx, SB, int fd1, int fd2) { SOCKET s1,s2; @@ -576,7 +576,7 @@ int host_dup2socket(TrapContext *context, SB, int fd1, int fd2) if (fd2 != -1) { if ((unsigned int) (fd2) >= (unsigned int) sb->dtablesize) { BSDTRACE ((_T("Bad file descriptor (%d)\n"), fd2)); - bsdsocklib_seterrno (sb, 9); /* EBADF */ + bsdsocklib_seterrno(ctx, sb, 9); /* EBADF */ } fd2++; s2 = getsock(sb,fd2); @@ -584,12 +584,12 @@ int host_dup2socket(TrapContext *context, SB, int fd1, int fd2) shutdown(s2,1); closesocket(s2); } - setsd(context, sb, fd2, s1); + setsd(ctx, sb, fd2, s1); BSDTRACE((_T("0\n"))); return 0; } else { - fd2 = getsd(context, sb, 1); - setsd(context, sb, fd2, s1); + fd2 = getsd(ctx, sb, 1); + setsd(ctx, sb, fd2, s1); BSDTRACE((_T("%d\n"),fd2)); return (fd2 - 1); } @@ -598,7 +598,7 @@ int host_dup2socket(TrapContext *context, SB, int fd1, int fd2) return -1; } -int host_socket(TrapContext *context, SB, int af, int type, int protocol) +int host_socket(TrapContext *ctx, SB, int af, int type, int protocol) { int sd; SOCKET s; @@ -616,7 +616,7 @@ int host_socket(TrapContext *context, SB, int af, int type, int protocol) BSDTRACE((_T("failed (%d)\n"),sb->sb_errno)); return -1; } else { - sd = getsd(context, sb,s); + sd = getsd(ctx, sb,s); } sb->ftable[sd-1] = SF_BLOCKING; @@ -637,11 +637,11 @@ int host_socket(TrapContext *context, SB, int af, int type, int protocol) sb->ftable[sd-1] |= SF_RAW_RAW; } } - callfdcallback (context, sb, sd - 1, FDCB_ALLOC); + callfdcallback (ctx, sb, sd - 1, FDCB_ALLOC); return sd-1; } -uae_u32 host_bind(TrapContext *context, SB, uae_u32 sd, uae_u32 name, uae_u32 namelen) +uae_u32 host_bind(TrapContext *ctx, SB, uae_u32 sd, uae_u32 name, uae_u32 namelen) { uae_char buf[MAXADDRLEN]; uae_u32 success = 0; @@ -672,7 +672,7 @@ uae_u32 host_bind(TrapContext *context, SB, uae_u32 sd, uae_u32 name, uae_u32 na return success; } -uae_u32 host_listen(TrapContext *context, SB, uae_u32 sd, uae_u32 backlog) +uae_u32 host_listen(TrapContext *ctx, SB, uae_u32 sd, uae_u32 backlog) { SOCKET s; uae_u32 success = -1; @@ -691,7 +691,7 @@ uae_u32 host_listen(TrapContext *context, SB, uae_u32 sd, uae_u32 backlog) return success; } -void host_accept(TrapContext *context, SB, uae_u32 sd, uae_u32 name, uae_u32 namelen) +void host_accept(TrapContext *ctx, SB, uae_u32 sd, uae_u32 name, uae_u32 namelen) { struct sockaddr *rp_name, *rp_nameuae; struct sockaddr sockaddr; @@ -738,7 +738,7 @@ void host_accept(TrapContext *context, SB, uae_u32 sd, uae_u32 name, uae_u32 nam WAITSIGNAL; if (sb->mtable[sd - 1] == 0) { - cancelasyncmsg(context, wMsg); + cancelasyncmsg(ctx, wMsg); } else { setWSAAsyncSelect(sb, sd, s, 0); } @@ -765,9 +765,9 @@ void host_accept(TrapContext *context, SB, uae_u32 sd, uae_u32 name, uae_u32 nam sb->resultval = -1; BSDTRACE((_T("failed (%d)\n"),sb->sb_errno)); } else { - sb->resultval = getsd(context, sb, s2); + sb->resultval = getsd(ctx, sb, s2); sb->ftable[sb->resultval - 1] = sb->ftable[sd - 1]; // new socket inherits the old socket's properties - callfdcallback(context, sb, sb->resultval - 1, FDCB_ALLOC); + callfdcallback(ctx, sb, sb->resultval - 1, FDCB_ALLOC); sb->resultval--; if (rp_name != 0) { // 1.11.2002 XXX if (hlen <= hlenuae) { // Fix for CNET BBS Part 2 @@ -847,6 +847,7 @@ static BOOL HandleStuff(void) BOOL quit = FALSE; SB = NULL; BOOL handled = TRUE; + TrapContext *ctx = NULL; if (bsd->hSockReq) { // 100ms sleepiness might need some tuning... @@ -960,7 +961,7 @@ static unsigned int __stdcall sock_thread(void *p) return 0; } -void host_connect(TrapContext *context, SB, uae_u32 sd, uae_u32 name, uae_u32 namelen) +void host_connect(TrapContext *ctx, SB, uae_u32 sd, uae_u32 name, uae_u32 namelen) { SOCKET s; int success = 0; @@ -1006,7 +1007,7 @@ void host_connect(TrapContext *context, SB, uae_u32 sd, uae_u32 name, uae_u32 na if (sb->resultval) { if (sb->sb_errno == WSAEWOULDBLOCK - WSABASEERR) { if (sb->ftable[sd-1] & SF_BLOCKING) { - bsdsocklib_seterrno(sb, 0); + bsdsocklib_seterrno(ctx, sb, 0); WAITSIGNAL; @@ -1018,7 +1019,7 @@ void host_connect(TrapContext *context, SB, uae_u32 sd, uae_u32 name, uae_u32 na sb->dtable[sd-1] = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP); } } else { - bsdsocklib_seterrno(sb, 36); // EINPROGRESS + bsdsocklib_seterrno(ctx,sb, 36); // EINPROGRESS } } else { CANCELSIGNAL; // Cancel pending signal @@ -1027,7 +1028,7 @@ void host_connect(TrapContext *context, SB, uae_u32 sd, uae_u32 name, uae_u32 na ENDBLOCKING; if (sb->mtable[sd-1] == 0) { - cancelasyncmsg(context, wMsg); + cancelasyncmsg(ctx, wMsg); } else { setWSAAsyncSelect(sb,sd,s,0); } @@ -1062,7 +1063,7 @@ struct udphdr { #endif -void host_sendto (TrapContext *context, SB, uae_u32 sd, uae_u32 msg, uae_u32 len, uae_u32 flags, uae_u32 to, uae_u32 tolen) +void host_sendto (TrapContext *ctx, SB, uae_u32 sd, uae_u32 msg, uae_u32 len, uae_u32 flags, uae_u32 to, uae_u32 tolen) { SOCKET s; char *realpt; @@ -1198,7 +1199,7 @@ void host_sendto (TrapContext *context, SB, uae_u32 sd, uae_u32 msg, uae_u32 len WAITSIGNAL; if (sb->mtable[sd-1] == 0) { - cancelasyncmsg(context, wMsg); + cancelasyncmsg(ctx, wMsg); } else { setWSAAsyncSelect(sb, sd, s, 0); } @@ -1222,7 +1223,7 @@ void host_sendto (TrapContext *context, SB, uae_u32 sd, uae_u32 msg, uae_u32 len BSDTRACE((_T("sendto %d:%d\n"),sb->resultval,wscnt)); } -void host_recvfrom(TrapContext *context, SB, uae_u32 sd, uae_u32 msg, uae_u32 len, uae_u32 flags, uae_u32 addr, uae_u32 addrlen) +void host_recvfrom(TrapContext *ctx, SB, uae_u32 sd, uae_u32 msg, uae_u32 len, uae_u32 flags, uae_u32 addr, uae_u32 addrlen) { SOCKET s; uae_char *realpt; @@ -1311,7 +1312,7 @@ void host_recvfrom(TrapContext *context, SB, uae_u32 sd, uae_u32 msg, uae_u32 le WAITSIGNAL; if (sb->mtable[sd-1] == 0) { - cancelasyncmsg(context, wMsg); + cancelasyncmsg(ctx, wMsg); } else { setWSAAsyncSelect(sb, sd, s, 0); } @@ -1346,6 +1347,7 @@ void host_recvfrom(TrapContext *context, SB, uae_u32 sd, uae_u32 msg, uae_u32 le uae_u32 host_shutdown(SB, uae_u32 sd, uae_u32 how) { + TrapContext *ctx = NULL; SOCKET s; BSDTRACE((_T("shutdown(%d,%d) -> "),sd,how)); @@ -1367,6 +1369,7 @@ uae_u32 host_shutdown(SB, uae_u32 sd, uae_u32 how) void host_setsockopt(SB, uae_u32 sd, uae_u32 level, uae_u32 optname, uae_u32 optval, uae_u32 len) { + TrapContext *ctx = NULL; SOCKET s; uae_char buf[MAXADDRLEN]; int i; @@ -1442,6 +1445,7 @@ void host_setsockopt(SB, uae_u32 sd, uae_u32 level, uae_u32 optname, uae_u32 opt uae_u32 host_getsockopt(SB, uae_u32 sd, uae_u32 level, uae_u32 optname, uae_u32 optval, uae_u32 optlen) { + TrapContext *ctx = NULL; SOCKET s; uae_char buf[MAXADDRLEN]; int len = sizeof buf; @@ -1509,6 +1513,7 @@ uae_u32 host_getsockname(SB, uae_u32 sd, uae_u32 name, uae_u32 namelen) SOCKET s; int len; struct sockaddr *rp_name; + TrapContext *ctx = NULL; sd++; if (!addr_valid (_T("host_getsockname1"), namelen, 4)) @@ -1543,6 +1548,7 @@ uae_u32 host_getpeername(SB, uae_u32 sd, uae_u32 name, uae_u32 namelen) SOCKET s; int len; struct sockaddr *rp_name; + TrapContext *ctx = NULL; sd++; if (!addr_valid (_T("host_getpeername1"), namelen, 4)) @@ -1572,7 +1578,7 @@ uae_u32 host_getpeername(SB, uae_u32 sd, uae_u32 name, uae_u32 namelen) return -1; } -uae_u32 host_IoctlSocket(TrapContext *context, SB, uae_u32 sd, uae_u32 request, uae_u32 arg) +uae_u32 host_IoctlSocket(TrapContext *ctx, SB, uae_u32 sd, uae_u32 request, uae_u32 arg) { SOCKET s; uae_u32 data; @@ -1629,7 +1635,7 @@ uae_u32 host_IoctlSocket(TrapContext *context, SB, uae_u32 sd, uae_u32 request, break; default: write_log (_T("BSDSOCK: WARNING - Unknown IoctlSocket request: 0x%08lx\n"), request); - bsdsocklib_seterrno(sb, 22); // EINVAL + bsdsocklib_seterrno(ctx, sb, 22); // EINVAL break; } } @@ -1637,7 +1643,7 @@ uae_u32 host_IoctlSocket(TrapContext *context, SB, uae_u32 sd, uae_u32 request, return success; } -int host_CloseSocket(TrapContext *context, SB, int sd) +int host_CloseSocket(TrapContext *ctx, SB, int sd) { unsigned int wMsg; SOCKET s; @@ -1653,7 +1659,7 @@ int host_CloseSocket(TrapContext *context, SB, int sd) sb->mtable[sd-1] = 0; } - if (checksd(context, sb ,sd) == true) + if (checksd(ctx, sb ,sd) == true) return 0; BEGINBLOCKING; @@ -1662,7 +1668,7 @@ int host_CloseSocket(TrapContext *context, SB, int sd) shutdown(s,1); if (!closesocket(s)) { - releasesock(context, sb, sd); + releasesock(ctx, sb, sd); BSDTRACE((_T("OK\n"))); return 0; } @@ -1677,7 +1683,7 @@ int host_CloseSocket(TrapContext *context, SB, int sd) WAITSIGNAL; - cancelasyncmsg(context, wMsg); + cancelasyncmsg(ctx, wMsg); if (sb->eintr) { BSDTRACE((_T("[interrupted]\n"))); @@ -1793,6 +1799,7 @@ static unsigned int thread_WaitSelect2(void *indexp) struct fd_set readsocks, writesocks, exceptsocks; struct timeval tv; volatile struct threadargsw *args; + TrapContext *ctx = NULL; SB; @@ -1927,7 +1934,7 @@ static void fddebug(const TCHAR *name, uae_u32 nfds, uae_u32 fd) BSDTRACE((_T("%s: %08x %s\n"), name, v, out)); } -void host_WaitSelect(TrapContext *context, SB, uae_u32 nfds, uae_u32 readfds, uae_u32 writefds, uae_u32 exceptfds, uae_u32 timeout, uae_u32 sigmp) +void host_WaitSelect(TrapContext *ctx, SB, uae_u32 nfds, uae_u32 readfds, uae_u32 writefds, uae_u32 exceptfds, uae_u32 timeout, uae_u32 sigmp) { static int wscount; uae_u32 sigs, wssigs; @@ -1953,7 +1960,7 @@ void host_WaitSelect(TrapContext *context, SB, uae_u32 nfds, uae_u32 readfds, ua if (wssigs) { m68k_dreg (regs,0) = 0; m68k_dreg (regs,1) = wssigs; - sigs = CallLib (context, sb->sysbase, -0x132) & wssigs; // SetSignal() + sigs = CallLib(ctx, sb->sysbase, -0x132) & wssigs; // SetSignal() if (sigs) { BSDTRACE((_T("-> [preempted by signals 0x%08lx]\n"),sigs & wssigs)); @@ -1966,7 +1973,7 @@ void host_WaitSelect(TrapContext *context, SB, uae_u32 nfds, uae_u32 readfds, ua if (exceptfds) fd_zero(exceptfds,nfds); sb->resultval = 0; - bsdsocklib_seterrno(sb,0); + bsdsocklib_seterrno(ctx, sb,0); return; } } @@ -1974,7 +1981,7 @@ void host_WaitSelect(TrapContext *context, SB, uae_u32 nfds, uae_u32 readfds, ua // No sockets to check, only wait for signals if (wssigs != 0) { m68k_dreg (regs, 0) = wssigs; - sigs = CallLib (context, sb->sysbase, -0x13e); // Wait() + sigs = CallLib(ctx, sb->sysbase, -0x13e); // Wait() put_long (sigmp, sigs & wssigs); } @@ -2009,7 +2016,7 @@ void host_WaitSelect(TrapContext *context, SB, uae_u32 nfds, uae_u32 readfds, ua unlocksigqueue (); write_log (_T("BSDSOCK: ERROR - Thread/Event creation failed - error code: %d\n"), GetLastError()); - bsdsocklib_seterrno(sb,12); // ENOMEM + bsdsocklib_seterrno(ctx, sb,12); // ENOMEM sb->resultval = -1; return; } @@ -2040,7 +2047,7 @@ void host_WaitSelect(TrapContext *context, SB, uae_u32 nfds, uae_u32 readfds, ua SetEvent(bsd->hEvents[i]); m68k_dreg (regs, 0) = (((uae_u32)1) << sb->signal) | sb->eintrsigs | wssigs; - sigs = CallLib (context, sb->sysbase, -0x13e); // Wait() + sigs = CallLib(ctx, sb->sysbase, -0x13e); // Wait() /* if ((1<signal) & sigs) { // 2.3.2002/SR Fix for AmiFTP -> Thread is ready, no need to Abort @@ -2073,17 +2080,17 @@ void host_WaitSelect(TrapContext *context, SB, uae_u32 nfds, uae_u32 readfds, ua if (readfds) fd_zero(readfds,nfds); if (writefds) fd_zero(writefds,nfds); if (exceptfds) fd_zero(exceptfds,nfds); - bsdsocklib_seterrno(sb,0); + bsdsocklib_seterrno(ctx, sb, 0); sb->resultval = 0; } else if (sigs & sb->eintrsigs) { uae_u32 gotsigs = sigs & sb->eintrsigs; BSDTRACE((_T("[interrupted 0x%08x]:%d\n"), gotsigs, wscnt)); sb->resultval = -1; - bsdsocklib_seterrno(sb,4); // EINTR + bsdsocklib_seterrno(ctx, sb, 4); // EINTR /* EINTR signals are kept active */ m68k_dreg (regs,0) = gotsigs; m68k_dreg (regs,1) = gotsigs; - CallLib (context, sb->sysbase, -0x132); // SetSignal + CallLib (ctx, sb->sysbase, -0x132); // SetSignal } if (sb->resultval >= 0) { @@ -2094,7 +2101,7 @@ void host_WaitSelect(TrapContext *context, SB, uae_u32 nfds, uae_u32 readfds, ua } } -uae_u32 host_Inet_NtoA(TrapContext *context, SB, uae_u32 in) +uae_u32 host_Inet_NtoA(TrapContext *ctx, SB, uae_u32 in) { uae_char *addr; struct in_addr ina; @@ -2179,6 +2186,7 @@ static unsigned int thread_get2 (void *indexp) long addrtype; char *name_rp; SB; + TrapContext *ctx = NULL; while (bsd->hGetEvents[index]) { @@ -2223,7 +2231,7 @@ static unsigned int thread_get2 (void *indexp) SETERRNO; BSDTRACE((_T("tg2_0 failed %d:%d -> "), sb->sb_errno,wscnt)); } else { - bsdsocklib_seterrno(sb, 0); + bsdsocklib_seterrno(ctx, sb, 0); memcpy((void*)args->buf, host, sizeof(HOSTENT)); } } @@ -2246,7 +2254,7 @@ static unsigned int thread_get2 (void *indexp) SETERRNO; BSDTRACE((_T("tg2_1 failed %d:%d -> "), sb->sb_errno, wscnt)); } else { - bsdsocklib_seterrno(sb, 0); + bsdsocklib_seterrno(ctx, sb, 0); memcpy((void*)args->buf, proto, sizeof(struct protoent)); } } @@ -2283,7 +2291,7 @@ static unsigned int thread_get2 (void *indexp) SETERRNO; BSDTRACE((_T("tg2_2 failed %d:%d -> "), sb->sb_errno, wscnt)); } else { - bsdsocklib_seterrno(sb, 0); + bsdsocklib_seterrno(ctx, sb, 0); memcpy((void*)args->buf, serv, sizeof (struct servent)); } } @@ -2318,7 +2326,7 @@ static unsigned int __stdcall thread_get(void *p) return 0; } -static int run_get_thread(TrapContext *context, SB, struct threadargs *args) +static int run_get_thread(TrapContext *ctx, SB, struct threadargs *args) { int i; @@ -2352,7 +2360,7 @@ static int run_get_thread(TrapContext *context, SB, struct threadargs *args) bsd->hGetEvents2[i] = NULL; write_log (_T("BSDSOCK: ERROR - Thread/Event creation failed - error code: %d:%d\n"), GetLastError(), args->wscnt); - bsdsocklib_seterrno(sb, 12); // ENOMEM + bsdsocklib_seterrno(ctx, sb, 12); // ENOMEM sb->resultval = -1; unlocksigqueue (); return -1; @@ -2365,7 +2373,7 @@ static int run_get_thread(TrapContext *context, SB, struct threadargs *args) if (i >= MAX_GET_THREADS) { write_log (_T("BSDSOCK: ERROR - Too many gethostbyname()s:%d\n"), args->wscnt); - bsdsocklib_seterrno(sb, 12); // ENOMEM + bsdsocklib_seterrno(ctx, sb, 12); // ENOMEM sb->resultval = -1; unlocksigqueue (); return -1; @@ -2403,7 +2411,7 @@ static void release_get_thread(int index) bsd->threadGetargs_inuse[index] = GET_STATE_REALLY_DONE; } -void host_gethostbynameaddr (TrapContext *context, SB, uae_u32 name, uae_u32 namelen, long addrtype) +void host_gethostbynameaddr (TrapContext *ctx, SB, uae_u32 name, uae_u32 namelen, long addrtype) { static int wscounter; HOSTENT *h; @@ -2441,7 +2449,7 @@ void host_gethostbynameaddr (TrapContext *context, SB, uae_u32 name, uae_u32 nam } // workaround for numeric host "names" if ((addr = inet_addr(name_rp)) != INADDR_NONE) { - bsdsocklib_seterrno(sb,0); + bsdsocklib_seterrno(ctx, sb,0); ((HOSTENT *)buf)->h_name = name_rp; ((HOSTENT *)buf)->h_aliases = NULL; ((HOSTENT *)buf)->h_addrtype = AF_INET; @@ -2462,7 +2470,7 @@ void host_gethostbynameaddr (TrapContext *context, SB, uae_u32 name, uae_u32 nam argsp->args3 = namelen; argsp->args4 = addrtype; - tindex = run_get_thread(context, sb, &args); + tindex = run_get_thread(ctx, sb, &args); if (tindex < 0) return; buf = argsp->buf; @@ -2486,16 +2494,16 @@ kludge: } if (sb->hostent) { - uae_FreeMem(context, sb->hostent, sb->hostentsize, sb->sysbase); + uae_FreeMem(ctx, sb->hostent, sb->hostentsize, sb->sysbase); } - sb->hostent = uae_AllocMem(context, size, 0, sb->sysbase); + sb->hostent = uae_AllocMem(ctx, size, 0, sb->sysbase); if (!sb->hostent) { write_log (_T("BSDSOCK: WARNING - gethostby%s() ran out of Amiga memory ") _T("(couldn't allocate %ld bytes) while returning result of lookup for '%s':%d\n"), addrtype == -1 ? _T("name") : _T("addr"), size, name_rp, argsp->wscnt); - bsdsocklib_seterrno(sb, 12); // ENOMEM + bsdsocklib_seterrno(ctx, sb, 12); // ENOMEM release_get_thread (tindex); return; } @@ -2525,8 +2533,8 @@ kludge: xfree (s); } - bsdsocklib_seterrno(sb, 0); - bsdsocklib_setherrno(sb, 0); + bsdsocklib_seterrno(ctx, sb, 0); + bsdsocklib_setherrno(ctx, sb, 0); } else { BSDTRACE((_T("failed (%d/%d):%d\n"), sb->sb_errno, sb->sb_herrno,argsp->wscnt)); @@ -2536,7 +2544,7 @@ kludge: } -void host_getprotobyname(TrapContext *context, SB, uae_u32 name) +void host_getprotobyname(TrapContext *ctx, SB, uae_u32 name) { static int wscounter; PROTOENT *p; @@ -2565,7 +2573,7 @@ void host_getprotobyname(TrapContext *context, SB, uae_u32 name) argsp->args1 = 1; argsp->args2 = name; - tindex = run_get_thread(context, sb, &args); + tindex = run_get_thread(ctx, sb, &args); if (tindex < 0) return; @@ -2581,10 +2589,10 @@ void host_getprotobyname(TrapContext *context, SB, uae_u32 name) while (p->p_aliases[numaliases]) size += strlen(p->p_aliases[numaliases++])+5; if (sb->protoent) { - uae_FreeMem(context, sb->protoent, sb->protoentsize, sb->sysbase); + uae_FreeMem(ctx, sb->protoent, sb->protoentsize, sb->sysbase); } - sb->protoent = uae_AllocMem(context, size, 0, sb->sysbase); + sb->protoent = uae_AllocMem(ctx, size, 0, sb->sysbase); if (!sb->protoent) { if (ISBSDTRACE) { @@ -2594,7 +2602,7 @@ void host_getprotobyname(TrapContext *context, SB, uae_u32 name) size, s, argsp->wscnt); xfree (s); } - bsdsocklib_seterrno(sb,12); // ENOMEM + bsdsocklib_seterrno(ctx, sb, 12); // ENOMEM release_get_thread (tindex); return; } @@ -2617,7 +2625,7 @@ void host_getprotobyname(TrapContext *context, SB, uae_u32 name) BSDTRACE((_T("OK (%s, %d):%d\n"), s, p->p_proto, argsp->wscnt)); xfree (s); } - bsdsocklib_seterrno (sb,0); + bsdsocklib_seterrno(ctx, sb,0); } else { BSDTRACE((_T("failed (%d):%d\n"), sb->sb_errno, argsp->wscnt)); @@ -2626,12 +2634,12 @@ void host_getprotobyname(TrapContext *context, SB, uae_u32 name) release_get_thread (tindex); } -void host_getprotobynumber(TrapContext *context, SB, uae_u32 name) +void host_getprotobynumber(TrapContext *ctx, SB, uae_u32 name) { - bsdsocklib_seterrno(sb, 1); + bsdsocklib_seterrno(ctx, sb, 1); } -void host_getservbynameport(TrapContext *context, SB, uae_u32 nameport, uae_u32 proto, uae_u32 type) +void host_getservbynameport(TrapContext *ctx, SB, uae_u32 nameport, uae_u32 proto, uae_u32 type) { static int wscounter; SERVENT *s; @@ -2665,7 +2673,7 @@ void host_getservbynameport(TrapContext *context, SB, uae_u32 nameport, uae_u32 argsp->args3 = proto; argsp->args4 = type; - tindex = run_get_thread (context, sb, &args); + tindex = run_get_thread(ctx, sb, &args); if (tindex < 0) return; @@ -2684,14 +2692,14 @@ void host_getservbynameport(TrapContext *context, SB, uae_u32 nameport, uae_u32 size += strlen(s->s_aliases[numaliases++])+5; if (sb->servent) { - uae_FreeMem(context, sb->servent, sb->serventsize, sb->sysbase); + uae_FreeMem(ctx, sb->servent, sb->serventsize, sb->sysbase); } - sb->servent = uae_AllocMem(context, size, 0, sb->sysbase); + sb->servent = uae_AllocMem(ctx, size, 0, sb->sysbase); if (!sb->servent) { write_log (_T("BSDSOCK: WARNING - getservby%s() ran out of Amiga memory (couldn't allocate %ld bytes):%d\n"), type ? _T("port") : _T("name"), size, argsp->wscnt); - bsdsocklib_seterrno(sb, 12); // ENOMEM + bsdsocklib_seterrno(ctx, sb, 12); // ENOMEM release_get_thread (tindex); return; } @@ -2718,7 +2726,7 @@ void host_getservbynameport(TrapContext *context, SB, uae_u32 nameport, uae_u32 xfree (ss); } - bsdsocklib_seterrno(sb, 0); + bsdsocklib_seterrno(ctx, sb, 0); } else { BSDTRACE((_T("failed (%d):%d\n"),sb->sb_errno, argsp->wscnt)); diff --git a/od-win32/dinput.cpp b/od-win32/dinput.cpp index d3761f18..88e83a14 100644 --- a/od-win32/dinput.cpp +++ b/od-win32/dinput.cpp @@ -34,6 +34,7 @@ int no_windowsmouse = 0; #include "sysdeps.h" #include "options.h" +#include "traps.h" #include "rp.h" #include "inputdevice.h" #include "keybuf.h" diff --git a/od-win32/picasso96_win.cpp b/od-win32/picasso96_win.cpp index 802d46b4..4b7dff4c 100644 --- a/od-win32/picasso96_win.cpp +++ b/od-win32/picasso96_win.cpp @@ -30,14 +30,20 @@ * programs started from a Picasso workbench. */ -#define MULTIDISPLAY 0 -#define WINCURSOR 1 #include "sysconfig.h" #include "sysdeps.h" #if defined(PICASSO96) +#define MULTIDISPLAY 0 +#define WINCURSOR 1 +#define NEWTRAP 1 + +#define USE_HARDWARESPRITE 1 +#define P96TRACING_ENABLED 0 +#define P96SPRTRACING_ENABLED 0 + #include "options.h" #include "threaddep/thread.h" #include "memory.h" @@ -68,10 +74,7 @@ int debug_rtg_blitter = 3; #define NOBLITTER (0 || !(debug_rtg_blitter & 1)) #define NOBLITTER_BLIT (0 || !(debug_rtg_blitter & 2)) - -#define USE_HARDWARESPRITE 1 -#define P96TRACING_ENABLED 0 -#define P96SPRTRACING_ENABLED 0 +#define NOBLITTER_ALL 0 static int hwsprite = 0; static int picasso96_BT = BT_uaegfx; @@ -193,36 +196,36 @@ STATIC_INLINE void endianswap (uae_u32 *vp, int bpp) /* * Debugging dumps */ -static void DumpModeInfoStructure (uaecptr amigamodeinfoptr) +static void DumpModeInfoStructure(TrapContext *ctx, uaecptr amigamodeinfoptr) { write_log (_T("ModeInfo Structure Dump:\n")); - write_log (_T(" Node.ln_Succ = 0x%x\n"), get_long (amigamodeinfoptr)); - write_log (_T(" Node.ln_Pred = 0x%x\n"), get_long (amigamodeinfoptr + 4)); - write_log (_T(" Node.ln_Type = 0x%x\n"), get_byte (amigamodeinfoptr + 8)); - write_log (_T(" Node.ln_Pri = %d\n"), get_byte (amigamodeinfoptr + 9)); + write_log (_T(" Node.ln_Succ = 0x%x\n"), trap_get_long(ctx, amigamodeinfoptr)); + write_log (_T(" Node.ln_Pred = 0x%x\n"), trap_get_long(ctx, amigamodeinfoptr + 4)); + write_log (_T(" Node.ln_Type = 0x%x\n"), trap_get_byte(ctx, amigamodeinfoptr + 8)); + write_log (_T(" Node.ln_Pri = %d\n"), trap_get_byte(ctx, amigamodeinfoptr + 9)); /*write_log (_T(" Node.ln_Name = %s\n"), uaememptr->Node.ln_Name); */ - write_log (_T(" OpenCount = %d\n"), get_word (amigamodeinfoptr + PSSO_ModeInfo_OpenCount)); - write_log (_T(" Active = %d\n"), get_byte (amigamodeinfoptr + PSSO_ModeInfo_Active)); - write_log (_T(" Width = %d\n"), get_word (amigamodeinfoptr + PSSO_ModeInfo_Width)); - write_log (_T(" Height = %d\n"), get_word (amigamodeinfoptr + PSSO_ModeInfo_Height)); - write_log (_T(" Depth = %d\n"), get_byte (amigamodeinfoptr + PSSO_ModeInfo_Depth)); - write_log (_T(" Flags = %d\n"), get_byte (amigamodeinfoptr + PSSO_ModeInfo_Flags)); - write_log (_T(" HorTotal = %d\n"), get_word (amigamodeinfoptr + PSSO_ModeInfo_HorTotal)); - write_log (_T(" HorBlankSize = %d\n"), get_word (amigamodeinfoptr + PSSO_ModeInfo_HorBlankSize)); - write_log (_T(" HorSyncStart = %d\n"), get_word (amigamodeinfoptr + PSSO_ModeInfo_HorSyncStart)); - write_log (_T(" HorSyncSize = %d\n"), get_word (amigamodeinfoptr + PSSO_ModeInfo_HorSyncSize)); - write_log (_T(" HorSyncSkew = %d\n"), get_byte (amigamodeinfoptr + PSSO_ModeInfo_HorSyncSkew)); - write_log (_T(" HorEnableSkew = %d\n"), get_byte (amigamodeinfoptr + PSSO_ModeInfo_HorEnableSkew)); - write_log (_T(" VerTotal = %d\n"), get_word (amigamodeinfoptr + PSSO_ModeInfo_VerTotal)); - write_log (_T(" VerBlankSize = %d\n"), get_word (amigamodeinfoptr + PSSO_ModeInfo_VerBlankSize)); - write_log (_T(" VerSyncStart = %d\n"), get_word (amigamodeinfoptr + PSSO_ModeInfo_VerSyncStart)); - write_log (_T(" VerSyncSize = %d\n"), get_word (amigamodeinfoptr + PSSO_ModeInfo_VerSyncSize)); - write_log (_T(" Clock = %d\n"), get_byte (amigamodeinfoptr + PSSO_ModeInfo_first_union)); - write_log (_T(" ClockDivide = %d\n"), get_byte (amigamodeinfoptr + PSSO_ModeInfo_second_union)); - write_log (_T(" PixelClock = %d\n"), get_long (amigamodeinfoptr + PSSO_ModeInfo_PixelClock)); + write_log (_T(" OpenCount = %d\n"), trap_get_word(ctx, amigamodeinfoptr + PSSO_ModeInfo_OpenCount)); + write_log (_T(" Active = %d\n"), trap_get_byte(ctx, amigamodeinfoptr + PSSO_ModeInfo_Active)); + write_log (_T(" Width = %d\n"), trap_get_word(ctx, amigamodeinfoptr + PSSO_ModeInfo_Width)); + write_log (_T(" Height = %d\n"), trap_get_word(ctx, amigamodeinfoptr + PSSO_ModeInfo_Height)); + write_log (_T(" Depth = %d\n"), trap_get_byte(ctx, amigamodeinfoptr + PSSO_ModeInfo_Depth)); + write_log (_T(" Flags = %d\n"), trap_get_byte(ctx, amigamodeinfoptr + PSSO_ModeInfo_Flags)); + write_log (_T(" HorTotal = %d\n"), trap_get_word(ctx, amigamodeinfoptr + PSSO_ModeInfo_HorTotal)); + write_log (_T(" HorBlankSize = %d\n"), trap_get_word(ctx, amigamodeinfoptr + PSSO_ModeInfo_HorBlankSize)); + write_log (_T(" HorSyncStart = %d\n"), trap_get_word(ctx, amigamodeinfoptr + PSSO_ModeInfo_HorSyncStart)); + write_log (_T(" HorSyncSize = %d\n"), trap_get_word(ctx, amigamodeinfoptr + PSSO_ModeInfo_HorSyncSize)); + write_log (_T(" HorSyncSkew = %d\n"), trap_get_byte(ctx, amigamodeinfoptr + PSSO_ModeInfo_HorSyncSkew)); + write_log (_T(" HorEnableSkew = %d\n"), trap_get_byte(ctx, amigamodeinfoptr + PSSO_ModeInfo_HorEnableSkew)); + write_log (_T(" VerTotal = %d\n"), trap_get_word(ctx, amigamodeinfoptr + PSSO_ModeInfo_VerTotal)); + write_log (_T(" VerBlankSize = %d\n"), trap_get_word(ctx, amigamodeinfoptr + PSSO_ModeInfo_VerBlankSize)); + write_log (_T(" VerSyncStart = %d\n"), trap_get_word(ctx, amigamodeinfoptr + PSSO_ModeInfo_VerSyncStart)); + write_log (_T(" VerSyncSize = %d\n"), trap_get_word(ctx, amigamodeinfoptr + PSSO_ModeInfo_VerSyncSize)); + write_log (_T(" Clock = %d\n"), trap_get_byte(ctx, amigamodeinfoptr + PSSO_ModeInfo_first_union)); + write_log (_T(" ClockDivide = %d\n"), trap_get_byte(ctx, amigamodeinfoptr + PSSO_ModeInfo_second_union)); + write_log (_T(" PixelClock = %d\n"), trap_get_long(ctx, amigamodeinfoptr + PSSO_ModeInfo_PixelClock)); } -static void DumpLibResolutionStructure (uaecptr amigalibresptr) +static void DumpLibResolutionStructure(TrapContext *ctx, uaecptr amigalibresptr) { int i; uaecptr amigamodeinfoptr; @@ -230,21 +233,21 @@ static void DumpLibResolutionStructure (uaecptr amigalibresptr) write_log (_T("LibResolution Structure Dump:\n")); - if (get_long (amigalibresptr + PSSO_LibResolution_DisplayID) == 0xFFFFFFFF) { + if (trap_get_long(ctx, amigalibresptr + PSSO_LibResolution_DisplayID) == 0xFFFFFFFF) { write_log (_T(" Finished With LibResolutions...\n")); } else { write_log (_T(" Name = %s\n"), uaememptr->P96ID); - write_log (_T(" DisplayID = 0x%x\n"), get_long (amigalibresptr + PSSO_LibResolution_DisplayID)); - write_log (_T(" Width = %d\n"), get_word (amigalibresptr + PSSO_LibResolution_Width)); - write_log (_T(" Height = %d\n"), get_word (amigalibresptr + PSSO_LibResolution_Height)); - write_log (_T(" Flags = %d\n"), get_word (amigalibresptr + PSSO_LibResolution_Flags)); + write_log (_T(" DisplayID = 0x%x\n"), trap_get_long(ctx, amigalibresptr + PSSO_LibResolution_DisplayID)); + write_log (_T(" Width = %d\n"), trap_get_word(ctx, amigalibresptr + PSSO_LibResolution_Width)); + write_log (_T(" Height = %d\n"), trap_get_word(ctx, amigalibresptr + PSSO_LibResolution_Height)); + write_log (_T(" Flags = %d\n"), trap_get_word(ctx, amigalibresptr + PSSO_LibResolution_Flags)); for (i = 0; i < MAXMODES; i++) { - amigamodeinfoptr = get_long (amigalibresptr + PSSO_LibResolution_Modes + i*4); + amigamodeinfoptr = trap_get_long(ctx, amigalibresptr + PSSO_LibResolution_Modes + i*4); write_log (_T(" ModeInfo[%d] = 0x%x\n"), i, amigamodeinfoptr); if (amigamodeinfoptr) - DumpModeInfoStructure (amigamodeinfoptr); + DumpModeInfoStructure(ctx, amigamodeinfoptr); } - write_log (_T(" BoardInfo = 0x%x\n"), get_long (amigalibresptr + PSSO_LibResolution_BoardInfo)); + write_log (_T(" BoardInfo = 0x%x\n"), trap_get_long(ctx, amigalibresptr + PSSO_LibResolution_BoardInfo)); } } @@ -355,7 +358,7 @@ static uae_u8 GetBytesPerPixel (uae_u32 RGBfmt) return 0; } -STATIC_INLINE bool validatecoords2 (struct RenderInfo *ri, uae_u32 *Xp, uae_u32 *Yp, uae_u32 *Widthp, uae_u32 *Heightp) +STATIC_INLINE bool validatecoords2(TrapContext *ctx, struct RenderInfo *ri, uae_u32 *Xp, uae_u32 *Yp, uae_u32 *Widthp, uae_u32 *Heightp) { uae_u32 Width = *Widthp; uae_u32 Height = *Heightp; @@ -373,14 +376,14 @@ STATIC_INLINE bool validatecoords2 (struct RenderInfo *ri, uae_u32 *Xp, uae_u32 Width = X2 - X; *Widthp = Width; } - if (!valid_address (ri->AMemory, (Y + Height - 1) * ri->BytesPerRow + (X + Width - 1) * bpp)) + if (!valid_address(ri->AMemory, (Y + Height - 1) * ri->BytesPerRow + (X + Width - 1) * bpp)) return false; } return true; } -static bool validatecoords (struct RenderInfo *ri, uae_u32 *X, uae_u32 *Y, uae_u32 *Width, uae_u32 *Height) +static bool validatecoords(TrapContext *ctx, struct RenderInfo *ri, uae_u32 *X, uae_u32 *Y, uae_u32 *Width, uae_u32 *Height) { - if (validatecoords2 (ri, X, Y, Width, Height)) + if (trap_is_indirect() || validatecoords2(ctx, ri, X, Y, Width, Height)) return true; write_log (_T("RTG invalid region: %08X:%d:%d (%dx%d)-(%dx%d)\n"), ri->AMemory, ri->BytesPerRow, ri->RGBFormat, *X, *Y, *Width, *Height); return false; @@ -390,66 +393,108 @@ static bool validatecoords (struct RenderInfo *ri, uae_u32 *X, uae_u32 *Y, uae_u * Amiga <-> native structure conversion functions */ -static int CopyRenderInfoStructureA2U (uaecptr amigamemptr, struct RenderInfo *ri) +static int CopyRenderInfoStructureA2U(TrapContext *ctx, uaecptr amigamemptr, struct RenderInfo *ri) { - if (valid_address (amigamemptr, PSSO_RenderInfo_sizeof)) { - uaecptr memp = get_long (amigamemptr + PSSO_RenderInfo_Memory); + if (trap_valid_address(ctx, amigamemptr, PSSO_RenderInfo_sizeof)) { + struct trapmd md[] = + { + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_RenderInfo_Memory } }, + { TRAPCMD_GET_WORD, { amigamemptr + PSSO_RenderInfo_BytesPerRow } }, + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_RenderInfo_RGBFormat } } + }; + trap_multi(ctx, md, sizeof md / sizeof(struct trapmd)); + uaecptr memp = md[0].params[0]; ri->AMemory = memp; ri->Memory = get_real_address (memp); - ri->BytesPerRow = get_word (amigamemptr + PSSO_RenderInfo_BytesPerRow); - ri->RGBFormat = (RGBFTYPE)get_long (amigamemptr + PSSO_RenderInfo_RGBFormat); + ri->BytesPerRow = md[1].params[0]; + ri->RGBFormat = (RGBFTYPE)md[2].params[0]; // Can't really validate this better at this point, no height. - if (valid_address (memp, ri->BytesPerRow)) + if (trap_valid_address(ctx, memp, ri->BytesPerRow)) return 1; } write_log (_T("ERROR - Invalid RenderInfo memory area...\n")); return 0; } -static int CopyPatternStructureA2U (uaecptr amigamemptr, struct Pattern *pattern) +static int CopyPatternStructureA2U(TrapContext *ctx, uaecptr amigamemptr, struct Pattern *pattern) { - if (valid_address (amigamemptr, PSSO_Pattern_sizeof)) { - uaecptr memp = get_long (amigamemptr + PSSO_Pattern_Memory); - pattern->Memory = get_real_address (memp); - pattern->XOffset = get_word (amigamemptr + PSSO_Pattern_XOffset); - pattern->YOffset = get_word (amigamemptr + PSSO_Pattern_YOffset); - pattern->FgPen = get_long (amigamemptr + PSSO_Pattern_FgPen); - pattern->BgPen = get_long (amigamemptr + PSSO_Pattern_BgPen); - pattern->Size = get_byte (amigamemptr + PSSO_Pattern_Size); - pattern->DrawMode = get_byte (amigamemptr + PSSO_Pattern_DrawMode); - if (valid_address (memp, 2)) + if (trap_valid_address(ctx, amigamemptr, PSSO_Pattern_sizeof)) { + struct trapmd md[] = + { + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_Pattern_Memory } }, + { TRAPCMD_GET_WORD, { amigamemptr + PSSO_Pattern_XOffset } }, + { TRAPCMD_GET_WORD, { amigamemptr + PSSO_Pattern_YOffset } }, + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_Pattern_FgPen } }, + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_Pattern_BgPen } }, + { TRAPCMD_GET_BYTE, { amigamemptr + PSSO_Pattern_Size } }, + { TRAPCMD_GET_BYTE, { amigamemptr + PSSO_Pattern_DrawMode } } + }; + trap_multi(ctx, md, sizeof md / sizeof(struct trapmd)); + uaecptr memp = md[0].params[0]; + if (trap_is_indirect()) + pattern->Memory = NULL; + else + pattern->Memory = get_real_address(memp); + pattern->AMemory = memp; + pattern->XOffset = md[1].params[0]; + pattern->YOffset = md[2].params[0]; + pattern->FgPen = md[3].params[0]; + pattern->BgPen = md[4].params[0]; + pattern->Size = md[5].params[0]; + pattern->DrawMode = md[6].params[0]; + if (trap_valid_address(ctx, memp, 2)) return 1; } write_log (_T("ERROR - Invalid Pattern memory area...\n")); return 0; } -static void CopyColorIndexMappingA2U (uaecptr amigamemptr, struct ColorIndexMapping *cim, int Bpp) +static void CopyColorIndexMappingA2U(TrapContext *ctx, uaecptr amigamemptr, struct ColorIndexMapping *cim, int Bpp) { int i; - cim->ColorMask = get_long (amigamemptr); - for (i = 0; i < 256; i++, amigamemptr += 4) { - uae_u32 v = get_long (amigamemptr + 4); + uae_u32 buf[1 + 256]; + + trap_get_longs(ctx, buf, amigamemptr, 1 + 256); + cim->ColorMask = buf[0]; + for (i = 0; i < 256; i++) { + uae_u32 v = buf[i + 1]; endianswap (&v, Bpp); cim->Colors[i] = v; } } -static int CopyBitMapStructureA2U (uaecptr amigamemptr, struct BitMap *bm) +static int CopyBitMapStructureA2U(TrapContext *ctx, uaecptr amigamemptr, struct BitMap *bm) { int i; - bm->BytesPerRow = get_word (amigamemptr + PSSO_BitMap_BytesPerRow); - bm->Rows = get_word (amigamemptr + PSSO_BitMap_Rows); - bm->Flags = get_byte (amigamemptr + PSSO_BitMap_Flags); - bm->Depth = get_byte (amigamemptr + PSSO_BitMap_Depth); + struct trapmd md[] = + { + { TRAPCMD_GET_WORD, { amigamemptr + PSSO_BitMap_BytesPerRow } }, + { TRAPCMD_GET_WORD, { amigamemptr + PSSO_BitMap_Rows } }, + { TRAPCMD_GET_BYTE, { amigamemptr + PSSO_BitMap_Flags } }, + { TRAPCMD_GET_BYTE, { amigamemptr + PSSO_BitMap_Depth } }, + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_BitMap_Planes + 0 } }, + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_BitMap_Planes + 4 } }, + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_BitMap_Planes + 8 } }, + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_BitMap_Planes + 12 } }, + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_BitMap_Planes + 16 } }, + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_BitMap_Planes + 20 } }, + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_BitMap_Planes + 24 } }, + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_BitMap_Planes + 28} } + }; + trap_multi(ctx, md, sizeof md / sizeof(struct trapmd)); + bm->BytesPerRow = md[0].params[0]; + bm->Rows = md[1].params[0]; + bm->Flags = md[2].params[0]; + bm->Depth = md[3].params[0]; /* ARGH - why is THIS happening? */ if(bm->Depth > 8) bm->Depth = 8; for (i = 0; i < bm->Depth; i++) { - uaecptr plane = get_long (amigamemptr + PSSO_BitMap_Planes + i * 4); + uaecptr plane = md[4 + i].params[0]; + bm->APlanes[i] = plane; switch (plane) { case 0: bm->Planes[i] = &all_zeros_bitmap; @@ -458,52 +503,66 @@ static int CopyBitMapStructureA2U (uaecptr amigamemptr, struct BitMap *bm) bm->Planes[i] = &all_ones_bitmap; break; default: - if (valid_address (plane, bm->BytesPerRow * bm->Rows)) - bm->Planes[i] = get_real_address (plane); + if (!trap_is_indirect() && trap_valid_address(ctx, plane, bm->BytesPerRow * bm->Rows)) + bm->Planes[i] = get_real_address(plane); else - return 0; + bm->Planes[i] = &all_zeros_bitmap; break; } } return 1; } -static int CopyTemplateStructureA2U (uaecptr amigamemptr, struct Template *tmpl) +static int CopyTemplateStructureA2U(TrapContext *ctx, uaecptr amigamemptr, struct Template *tmpl) { - uaecptr memp = get_long (amigamemptr + PSSO_Template_Memory); - - if (valid_address (memp, sizeof(struct Template))) { - tmpl->Memory = get_real_address (memp); - tmpl->BytesPerRow = get_word (amigamemptr + PSSO_Template_BytesPerRow); - tmpl->XOffset = get_byte (amigamemptr + PSSO_Template_XOffset); - tmpl->DrawMode = get_byte (amigamemptr + PSSO_Template_DrawMode); - tmpl->FgPen = get_long (amigamemptr + PSSO_Template_FgPen); - tmpl->BgPen = get_long (amigamemptr + PSSO_Template_BgPen); + if (trap_valid_address(ctx, amigamemptr, PSSO_Template_sizeof)) { + struct trapmd md[] = + { + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_Template_Memory } }, + { TRAPCMD_GET_WORD, { amigamemptr + PSSO_Template_BytesPerRow } }, + { TRAPCMD_GET_BYTE, { amigamemptr + PSSO_Template_XOffset } }, + { TRAPCMD_GET_BYTE, { amigamemptr + PSSO_Template_DrawMode } }, + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_Template_FgPen } }, + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_Template_BgPen } } + }; + trap_multi(ctx, md, sizeof md / sizeof(struct trapmd)); + + uaecptr memp = md[0].params[0]; + if (trap_is_indirect()) + tmpl->Memory = NULL; + else + tmpl->Memory = get_real_address(memp); + tmpl->AMemory = memp; + tmpl->BytesPerRow = md[1].params[0]; + tmpl->XOffset = md[2].params[0]; + tmpl->DrawMode = md[3].params[0]; + tmpl->FgPen = md[4].params[0]; + tmpl->BgPen = md[5].params[0]; return 1; } write_log (_T("ERROR - Invalid Template memory area...\n")); return 0; } -static int CopyLineStructureA2U(uaecptr amigamemptr, struct Line *line) +static int CopyLineStructureA2U(TrapContext *ctx, uaecptr amigamemptr, struct Line *line) { - if (valid_address(amigamemptr, sizeof(struct Line))) { - line->X = get_word (amigamemptr + PSSO_Line_X); - line->Y = get_word (amigamemptr + PSSO_Line_Y); - line->Length = get_word (amigamemptr + PSSO_Line_Length); - line->dX = get_word (amigamemptr + PSSO_Line_dX); - line->dY = get_word (amigamemptr + PSSO_Line_dY); - line->lDelta = get_word (amigamemptr + PSSO_Line_lDelta); - line->sDelta = get_word (amigamemptr + PSSO_Line_sDelta); - line->twoSDminusLD = get_word (amigamemptr + PSSO_Line_twoSDminusLD); - line->LinePtrn = get_word (amigamemptr + PSSO_Line_LinePtrn); - line->PatternShift = get_word (amigamemptr + PSSO_Line_PatternShift); - line->FgPen = get_long (amigamemptr + PSSO_Line_FgPen); - line->BgPen = get_long (amigamemptr + PSSO_Line_BgPen); - line->Horizontal = get_word (amigamemptr + PSSO_Line_Horizontal); - line->DrawMode = get_byte (amigamemptr + PSSO_Line_DrawMode); - line->Xorigin = get_word (amigamemptr + PSSO_Line_Xorigin); - line->Yorigin = get_word (amigamemptr + PSSO_Line_Yorigin); + if (trap_valid_address(ctx, amigamemptr, sizeof(struct Line))) { + line->X = trap_get_word(ctx, amigamemptr + PSSO_Line_X); + line->Y = trap_get_word(ctx, amigamemptr + PSSO_Line_Y); + line->Length = trap_get_word(ctx, amigamemptr + PSSO_Line_Length); + line->dX = trap_get_word(ctx, amigamemptr + PSSO_Line_dX); + line->dY = trap_get_word(ctx, amigamemptr + PSSO_Line_dY); + line->lDelta = trap_get_word(ctx, amigamemptr + PSSO_Line_lDelta); + line->sDelta = trap_get_word(ctx, amigamemptr + PSSO_Line_sDelta); + line->twoSDminusLD = trap_get_word(ctx, amigamemptr + PSSO_Line_twoSDminusLD); + line->LinePtrn = trap_get_word(ctx, amigamemptr + PSSO_Line_LinePtrn); + line->PatternShift = trap_get_word(ctx, amigamemptr + PSSO_Line_PatternShift); + line->FgPen = trap_get_long(ctx, amigamemptr + PSSO_Line_FgPen); + line->BgPen = trap_get_long(ctx, amigamemptr + PSSO_Line_BgPen); + line->Horizontal = trap_get_word(ctx, amigamemptr + PSSO_Line_Horizontal); + line->DrawMode = trap_get_byte(ctx, amigamemptr + PSSO_Line_DrawMode); + line->Xorigin = trap_get_word(ctx, amigamemptr + PSSO_Line_Xorigin); + line->Yorigin = trap_get_word(ctx, amigamemptr + PSSO_Line_Yorigin); return 1; } write_log (_T("ERROR - Invalid Line structure...\n")); @@ -512,28 +571,18 @@ static int CopyLineStructureA2U(uaecptr amigamemptr, struct Line *line) /* list is Amiga address of list, in correct endian format for UAE * node is Amiga address of node, in correct endian format for UAE */ -static void AmigaListAddTail (uaecptr l, uaecptr n) +static void AmigaListAddTail(TrapContext *ctx, uaecptr l, uaecptr n) { - put_long (n + 0, l + 4); // n->ln_Succ = (struct Node *)&l->lh_Tail; - put_long (n + 4, get_long (l + 8)); // n->ln_Pred = l->lh_TailPred; - put_long (get_long (l + 8) + 0, n); // l->lh_TailPred->ln_Succ = n; - put_long (l + 8, n); // l->lh_TailPred = n; -} - -static int renderinfo_is_current_screen (struct RenderInfo *ri) -{ - if (! picasso_on) - return 0; - if (ri->Memory != gfxmem_bank.baseaddr + (picasso96_state.Address - gfxmem_bank.start)) - return 0; - return 1; + trap_put_long(ctx, n + 0, l + 4); // n->ln_Succ = (struct Node *)&l->lh_Tail; + trap_put_long(ctx, n + 4, trap_get_long(ctx, l + 8)); // n->ln_Pred = l->lh_TailPred; + trap_put_long(ctx, trap_get_long(ctx, l + 8) + 0, n); // l->lh_TailPred->ln_Succ = n; + trap_put_long(ctx, l + 8, n); // l->lh_TailPred = n; } /* * Fill a rectangle in the screen. */ -static void do_fillrect_frame_buffer (struct RenderInfo *ri, int X, int Y, - int Width, int Height, uae_u32 Pen, int Bpp) +static void do_fillrect_frame_buffer(struct RenderInfo *ri, int X, int Y, int Width, int Height, uae_u32 Pen, int Bpp) { int cols; uae_u8 *dst; @@ -665,12 +714,13 @@ static int doskip (void) return p96_framecnt > 0; } -void picasso_trigger_vblank (void) +void picasso_trigger_vblank(void) { + TrapContext *ctx = NULL; if (!ABI_interrupt || !uaegfx_base || !interrupt_enabled || !currprefs.rtg_hardwareinterrupt) return; - put_long (uaegfx_base + CARD_IRQPTR, ABI_interrupt + PSSO_BoardInfo_SoftInterrupt); - put_byte (uaegfx_base + CARD_IRQFLAG, 1); + trap_put_long(ctx, uaegfx_base + CARD_IRQPTR, ABI_interrupt + PSSO_BoardInfo_SoftInterrupt); + trap_put_byte(ctx, uaegfx_base + CARD_IRQFLAG, 1); if (currprefs.win32_rtgvblankrate != 0) INTREQ (0x8000 | 0x0008); } @@ -768,7 +818,7 @@ void picasso_handle_vsync (void) return; if (!picasso_on && uaegfx) { - createwindowscursor (0, 0, 0, 0, 0, 1); + createwindowscursor(0, 0, 0, 0, 0, 1); picasso_trigger_vblank (); return; } @@ -807,7 +857,7 @@ void picasso_handle_hsync (void) if (p96hsync >= p96syncrate) { if (!picasso_on) { if (uaegfx) { - createwindowscursor (0, 0, 0, 0, 0, 1); + createwindowscursor(0, 0, 0, 0, 0, 1); picasso_trigger_vblank (); } } else { @@ -857,14 +907,14 @@ enum { RGBFB_CLUT_8 }; -static uae_u32 setspriteimage (uaecptr bi); -static void recursor (void) +static uae_u32 setspriteimage(TrapContext *ctx, uaecptr bi); +static void recursor(TrapContext *ctx) { cursorok = FALSE; - setspriteimage (boardinfo); + setspriteimage(ctx, boardinfo); } -static int getconvert (int rgbformat, int pixbytes) +static int getconvert(int rgbformat, int pixbytes) { int v = 0; int d = pixbytes; @@ -958,29 +1008,29 @@ static int getconvert (int rgbformat, int pixbytes) return v; } -static void setconvert (void) +static void setconvert(TrapContext *ctx) { static int ohost_mode, orgbformat; - picasso_convert = getconvert (picasso96_state.RGBFormat, picasso_vidinfo.pixbytes); + picasso_convert = getconvert(picasso96_state.RGBFormat, picasso_vidinfo.pixbytes); if (currprefs.gfx_api) { host_mode = picasso_vidinfo.pixbytes == 4 ? RGBFB_B8G8R8A8 : RGBFB_B5G6R5PC; } else { - host_mode = DirectDraw_GetSurfacePixelFormat (NULL); + host_mode = DirectDraw_GetSurfacePixelFormat(NULL); } if (picasso_vidinfo.pixbytes == 4) - alloc_colors_rgb (8, 8, 8, 16, 8, 0, 0, 0, 0, 0, p96rc, p96gc, p96bc); + alloc_colors_rgb(8, 8, 8, 16, 8, 0, 0, 0, 0, 0, p96rc, p96gc, p96bc); else - alloc_colors_rgb (5, 6, 5, 11, 5, 0, 0, 0, 0, 0, p96rc, p96gc, p96bc); - gfx_set_picasso_colors (picasso96_state.RGBFormat); - picasso_palette (); + alloc_colors_rgb(5, 6, 5, 11, 5, 0, 0, 0, 0, 0, p96rc, p96gc, p96bc); + gfx_set_picasso_colors(picasso96_state.RGBFormat); + picasso_palette(); if (host_mode != ohost_mode || picasso96_state.RGBFormat != orgbformat) { write_log (_T("RTG conversion: Depth=%d HostRGBF=%d P96RGBF=%d Mode=%d\n"), picasso_vidinfo.pixbytes, host_mode, picasso96_state.RGBFormat, picasso_convert); ohost_mode = host_mode; orgbformat = picasso96_state.RGBFormat; } - recursor (); + recursor(ctx); full_refresh = 1; } @@ -1002,9 +1052,9 @@ void picasso_refresh (void) if (! picasso_on) return; full_refresh = 1; - setconvert (); - setupcursor (); - rtg_clear (); + setconvert(NULL); + setupcursor(); + rtg_clear(); if (currprefs.rtgmem_type >= GFXBOARD_HARDWARE) { gfxboard_refresh (); @@ -1287,93 +1337,95 @@ static int do_blitrect_frame_buffer (struct RenderInfo *ri, struct } return 1; - } else if (Bpp == 4) { + } else { - /* 32-bit optimized */ - switch (opcode) - { - case BLIT_FALSE: BLIT_FALSE_32 (PARMS); break; - case BLIT_NOR: BLIT_NOR_32 (PARMS); break; - case BLIT_ONLYDST: BLIT_ONLYDST_32 (PARMS); break; - case BLIT_NOTSRC: BLIT_NOTSRC_32 (PARMS); break; - case BLIT_ONLYSRC: BLIT_ONLYSRC_32 (PARMS); break; - case BLIT_NOTDST: BLIT_NOTDST_32 (PARMS); break; - case BLIT_EOR: BLIT_EOR_32 (PARMS); break; - case BLIT_NAND: BLIT_NAND_32 (PARMS); break; - case BLIT_AND: BLIT_AND_32 (PARMS); break; - case BLIT_NEOR: BLIT_NEOR_32 (PARMS); break; - case BLIT_NOTONLYSRC: BLIT_NOTONLYSRC_32 (PARMS); break; - case BLIT_NOTONLYDST: BLIT_NOTONLYDST_32 (PARMS); break; - case BLIT_OR: BLIT_OR_32 (PARMS); break; - case BLIT_TRUE: BLIT_TRUE_32 (PARMS); break; - case BLIT_SWAP: BLIT_SWAP_32 (PARMS); break; - } - } else if (Bpp == 3) { + if (Bpp == 4) { - /* 24-bit (not very) optimized */ - switch (opcode) - { - case BLIT_FALSE: BLIT_FALSE_24 (PARMS); break; - case BLIT_NOR: BLIT_NOR_24 (PARMS); break; - case BLIT_ONLYDST: BLIT_ONLYDST_24 (PARMS); break; - case BLIT_NOTSRC: BLIT_NOTSRC_24 (PARMS); break; - case BLIT_ONLYSRC: BLIT_ONLYSRC_24 (PARMS); break; - case BLIT_NOTDST: BLIT_NOTDST_24 (PARMS); break; - case BLIT_EOR: BLIT_EOR_24 (PARMS); break; - case BLIT_NAND: BLIT_NAND_24 (PARMS); break; - case BLIT_AND: BLIT_AND_24 (PARMS); break; - case BLIT_NEOR: BLIT_NEOR_24 (PARMS); break; - case BLIT_NOTONLYSRC: BLIT_NOTONLYSRC_24 (PARMS); break; - case BLIT_NOTONLYDST: BLIT_NOTONLYDST_24 (PARMS); break; - case BLIT_OR: BLIT_OR_24 (PARMS); break; - case BLIT_TRUE: BLIT_TRUE_24 (PARMS); break; - case BLIT_SWAP: BLIT_SWAP_24 (PARMS); break; - } + /* 32-bit optimized */ + switch (opcode) + { + case BLIT_FALSE: BLIT_FALSE_32 (PARMS); break; + case BLIT_NOR: BLIT_NOR_32 (PARMS); break; + case BLIT_ONLYDST: BLIT_ONLYDST_32 (PARMS); break; + case BLIT_NOTSRC: BLIT_NOTSRC_32 (PARMS); break; + case BLIT_ONLYSRC: BLIT_ONLYSRC_32 (PARMS); break; + case BLIT_NOTDST: BLIT_NOTDST_32 (PARMS); break; + case BLIT_EOR: BLIT_EOR_32 (PARMS); break; + case BLIT_NAND: BLIT_NAND_32 (PARMS); break; + case BLIT_AND: BLIT_AND_32 (PARMS); break; + case BLIT_NEOR: BLIT_NEOR_32 (PARMS); break; + case BLIT_NOTONLYSRC: BLIT_NOTONLYSRC_32 (PARMS); break; + case BLIT_NOTONLYDST: BLIT_NOTONLYDST_32 (PARMS); break; + case BLIT_OR: BLIT_OR_32 (PARMS); break; + case BLIT_TRUE: BLIT_TRUE_32 (PARMS); break; + case BLIT_SWAP: BLIT_SWAP_32 (PARMS); break; + } + } else if (Bpp == 3) { - } else if (Bpp == 2) { + /* 24-bit (not very) optimized */ + switch (opcode) + { + case BLIT_FALSE: BLIT_FALSE_24 (PARMS); break; + case BLIT_NOR: BLIT_NOR_24 (PARMS); break; + case BLIT_ONLYDST: BLIT_ONLYDST_24 (PARMS); break; + case BLIT_NOTSRC: BLIT_NOTSRC_24 (PARMS); break; + case BLIT_ONLYSRC: BLIT_ONLYSRC_24 (PARMS); break; + case BLIT_NOTDST: BLIT_NOTDST_24 (PARMS); break; + case BLIT_EOR: BLIT_EOR_24 (PARMS); break; + case BLIT_NAND: BLIT_NAND_24 (PARMS); break; + case BLIT_AND: BLIT_AND_24 (PARMS); break; + case BLIT_NEOR: BLIT_NEOR_24 (PARMS); break; + case BLIT_NOTONLYSRC: BLIT_NOTONLYSRC_24 (PARMS); break; + case BLIT_NOTONLYDST: BLIT_NOTONLYDST_24 (PARMS); break; + case BLIT_OR: BLIT_OR_24 (PARMS); break; + case BLIT_TRUE: BLIT_TRUE_24 (PARMS); break; + case BLIT_SWAP: BLIT_SWAP_24 (PARMS); break; + } - /* 16-bit optimized */ - switch (opcode) - { - case BLIT_FALSE: BLIT_FALSE_16 (PARMS); break; - case BLIT_NOR: BLIT_NOR_16 (PARMS); break; - case BLIT_ONLYDST: BLIT_ONLYDST_16 (PARMS); break; - case BLIT_NOTSRC: BLIT_NOTSRC_16 (PARMS); break; - case BLIT_ONLYSRC: BLIT_ONLYSRC_16 (PARMS); break; - case BLIT_NOTDST: BLIT_NOTDST_16 (PARMS); break; - case BLIT_EOR: BLIT_EOR_16 (PARMS); break; - case BLIT_NAND: BLIT_NAND_16 (PARMS); break; - case BLIT_AND: BLIT_AND_16 (PARMS); break; - case BLIT_NEOR: BLIT_NEOR_16 (PARMS); break; - case BLIT_NOTONLYSRC: BLIT_NOTONLYSRC_16 (PARMS); break; - case BLIT_NOTONLYDST: BLIT_NOTONLYDST_16 (PARMS); break; - case BLIT_OR: BLIT_OR_16 (PARMS); break; - case BLIT_TRUE: BLIT_TRUE_16 (PARMS); break; - case BLIT_SWAP: BLIT_SWAP_16 (PARMS); break; - } + } else if (Bpp == 2) { - } else if (Bpp == 1) { + /* 16-bit optimized */ + switch (opcode) + { + case BLIT_FALSE: BLIT_FALSE_16 (PARMS); break; + case BLIT_NOR: BLIT_NOR_16 (PARMS); break; + case BLIT_ONLYDST: BLIT_ONLYDST_16 (PARMS); break; + case BLIT_NOTSRC: BLIT_NOTSRC_16 (PARMS); break; + case BLIT_ONLYSRC: BLIT_ONLYSRC_16 (PARMS); break; + case BLIT_NOTDST: BLIT_NOTDST_16 (PARMS); break; + case BLIT_EOR: BLIT_EOR_16 (PARMS); break; + case BLIT_NAND: BLIT_NAND_16 (PARMS); break; + case BLIT_AND: BLIT_AND_16 (PARMS); break; + case BLIT_NEOR: BLIT_NEOR_16 (PARMS); break; + case BLIT_NOTONLYSRC: BLIT_NOTONLYSRC_16 (PARMS); break; + case BLIT_NOTONLYDST: BLIT_NOTONLYDST_16 (PARMS); break; + case BLIT_OR: BLIT_OR_16 (PARMS); break; + case BLIT_TRUE: BLIT_TRUE_16 (PARMS); break; + case BLIT_SWAP: BLIT_SWAP_16 (PARMS); break; + } - /* 8-bit optimized */ - switch (opcode) - { - case BLIT_FALSE: BLIT_FALSE_8 (PARMS); break; - case BLIT_NOR: BLIT_NOR_8 (PARMS); break; - case BLIT_ONLYDST: BLIT_ONLYDST_8 (PARMS); break; - case BLIT_NOTSRC: BLIT_NOTSRC_8 (PARMS); break; - case BLIT_ONLYSRC: BLIT_ONLYSRC_8 (PARMS); break; - case BLIT_NOTDST: BLIT_NOTDST_8 (PARMS); break; - case BLIT_EOR: BLIT_EOR_8 (PARMS); break; - case BLIT_NAND: BLIT_NAND_8 (PARMS); break; - case BLIT_AND: BLIT_AND_8 (PARMS); break; - case BLIT_NEOR: BLIT_NEOR_8 (PARMS); break; - case BLIT_NOTONLYSRC: BLIT_NOTONLYSRC_8 (PARMS); break; - case BLIT_NOTONLYDST: BLIT_NOTONLYDST_8 (PARMS); break; - case BLIT_OR: BLIT_OR_8 (PARMS); break; - case BLIT_TRUE: BLIT_TRUE_8 (PARMS); break; - case BLIT_SWAP: BLIT_SWAP_8 (PARMS); break; - } + } else if (Bpp == 1) { + /* 8-bit optimized */ + switch (opcode) + { + case BLIT_FALSE: BLIT_FALSE_8 (PARMS); break; + case BLIT_NOR: BLIT_NOR_8 (PARMS); break; + case BLIT_ONLYDST: BLIT_ONLYDST_8 (PARMS); break; + case BLIT_NOTSRC: BLIT_NOTSRC_8 (PARMS); break; + case BLIT_ONLYSRC: BLIT_ONLYSRC_8 (PARMS); break; + case BLIT_NOTDST: BLIT_NOTDST_8 (PARMS); break; + case BLIT_EOR: BLIT_EOR_8 (PARMS); break; + case BLIT_NAND: BLIT_NAND_8 (PARMS); break; + case BLIT_AND: BLIT_AND_8 (PARMS); break; + case BLIT_NEOR: BLIT_NEOR_8 (PARMS); break; + case BLIT_NOTONLYSRC: BLIT_NOTONLYSRC_8 (PARMS); break; + case BLIT_NOTONLYDST: BLIT_NOTONLYDST_8 (PARMS); break; + case BLIT_OR: BLIT_OR_8 (PARMS); break; + case BLIT_TRUE: BLIT_TRUE_8 (PARMS); break; + case BLIT_SWAP: BLIT_SWAP_8 (PARMS); break; + } + } } return 1; } @@ -1389,10 +1441,10 @@ d7: RGBFTYPE RGBFormat */ static uae_u32 REGPARAM2 picasso_SetSpritePosition (TrapContext *ctx) { - uaecptr bi = m68k_areg (regs, 0); + uaecptr bi = trap_get_areg(ctx, 0); boardinfo = bi; - newcursor_x = (uae_s16)get_word (bi + PSSO_BoardInfo_MouseX) - picasso96_state.XOffset; - newcursor_y = (uae_s16)get_word (bi + PSSO_BoardInfo_MouseY) - picasso96_state.YOffset; + newcursor_x = (uae_s16)trap_get_word(ctx, bi + PSSO_BoardInfo_MouseX) - picasso96_state.XOffset; + newcursor_y = (uae_s16)trap_get_word(ctx, bi + PSSO_BoardInfo_MouseY) - picasso96_state.YOffset; if (!hwsprite) return 0; return 1; @@ -1413,11 +1465,11 @@ This function changes one of the possible three colors of the hardware sprite. */ static uae_u32 REGPARAM2 picasso_SetSpriteColor (TrapContext *ctx) { - uaecptr bi = m68k_areg (regs, 0); - uae_u8 idx = m68k_dreg (regs, 0); - uae_u8 red = m68k_dreg (regs, 1); - uae_u8 green = m68k_dreg (regs, 2); - uae_u8 blue = m68k_dreg (regs, 3); + uaecptr bi = trap_get_areg(ctx, 0); + uae_u8 idx = trap_get_dreg(ctx, 0); + uae_u8 red = trap_get_dreg(ctx, 1); + uae_u8 green = trap_get_dreg(ctx, 2); + uae_u8 blue = trap_get_dreg(ctx, 3); boardinfo = bi; idx++; if (!hwsprite) @@ -1492,7 +1544,7 @@ extern uaecptr sprite_0; extern int sprite_0_width, sprite_0_height, sprite_0_doubled; extern uae_u32 sprite_0_colors[4]; -int createwindowscursor (uaecptr src, int w, int h, int hiressprite, int doubledsprite, int chipset) +int createwindowscursor(uaecptr src, int w, int h, int hiressprite, int doubledsprite, int chipset) { HBITMAP andBM, xorBM; HBITMAP andoBM, xoroBM; @@ -1503,6 +1555,7 @@ int createwindowscursor (uaecptr src, int w, int h, int hiressprite, int doubled HCURSOR oldwincursor = wincursor; uae_u8 *realsrc; uae_u32 *ct; + TrapContext *ctx = NULL; ret = 0; wincursor_shown = 0; @@ -1580,8 +1633,8 @@ int createwindowscursor (uaecptr src, int w, int h, int hiressprite, int doubled for (dbl = 0; dbl < (doubledsprite ? 2 : 1); dbl++) { x = 0; while (x < w2) { - uae_u32 d1 = get_long (img); - uae_u32 d2 = get_long (img + 2 * hiressprite); + uae_u32 d1 = trap_get_long(ctx, img); + uae_u32 d2 = trap_get_long(ctx, img + 2 * hiressprite); int bits; int maxbits = w2 - x; @@ -1670,7 +1723,7 @@ int picasso_setwincursor (void) return 0; } -static uae_u32 setspriteimage (uaecptr bi) +static uae_u32 setspriteimage(TrapContext *ctx, uaecptr bi) { uae_u32 flags; int x, y, yy, bits, bpp; @@ -1684,9 +1737,9 @@ static uae_u32 setspriteimage (uaecptr bi) xfree (cursordata); cursordata = NULL; bpp = 4; - w = get_byte (bi + PSSO_BoardInfo_MouseWidth); - h = get_byte (bi + PSSO_BoardInfo_MouseHeight); - flags = get_long (bi + PSSO_BoardInfo_Flags); + w = trap_get_byte(ctx, bi + PSSO_BoardInfo_MouseWidth); + h = trap_get_byte(ctx, bi + PSSO_BoardInfo_MouseHeight); + flags = trap_get_long(ctx, bi + PSSO_BoardInfo_Flags); hiressprite = 1; doubledsprite = 0; if (flags & BIF_HIRESSPRITE) @@ -1696,27 +1749,27 @@ static uae_u32 setspriteimage (uaecptr bi) updatesprcolors (bpp); P96TRACE_SPR ((_T("SetSpriteImage(%08x,%08x,w=%d,h=%d,%d/%d,%08x)\n"), - bi, get_long (bi + PSSO_BoardInfo_MouseImage), w, h, + bi, trap_get_long(ctx, bi + PSSO_BoardInfo_MouseImage), w, h, hiressprite - 1, doubledsprite, bi + PSSO_BoardInfo_MouseImage)); - if (!w || !h || get_long (bi + PSSO_BoardInfo_MouseImage) == 0) { + if (!w || !h || trap_get_long(ctx, bi + PSSO_BoardInfo_MouseImage) == 0) { cursordeactivate = 1; ret = 1; goto end; } - createwindowscursor (get_long (bi + PSSO_BoardInfo_MouseImage) + 4 * hiressprite, + createwindowscursor (trap_get_long(ctx, bi + PSSO_BoardInfo_MouseImage) + 4 * hiressprite, w, h, hiressprite, doubledsprite, 0); cursordata = xmalloc (uae_u8, w * h * bpp); for (y = 0, yy = 0; y < h; y++, yy++) { uae_u8 *p = cursordata + w * bpp * y; uae_u8 *pprev = p; - uaecptr img = get_long (bi + PSSO_BoardInfo_MouseImage) + 4 * hiressprite + yy * 4 * hiressprite; + uaecptr img = trap_get_long(ctx, bi + PSSO_BoardInfo_MouseImage) + 4 * hiressprite + yy * 4 * hiressprite; x = 0; while (x < w) { - uae_u32 d1 = get_long (img); - uae_u32 d2 = get_long (img + 2 * hiressprite); + uae_u32 d1 = trap_get_long(ctx, img); + uae_u32 d2 = trap_get_long(ctx, img + 2 * hiressprite); int maxbits = w - x; if (maxbits > 16 * hiressprite) maxbits = 16 * hiressprite; @@ -1780,11 +1833,11 @@ planes for one image line respectively. You have to double each pixel horizontal used in this case already assume a zoomed sprite, only the sprite data is not zoomed yet. You will have to compensate for this when accounting for hotspot offsets and sprite dimensions. */ -static uae_u32 REGPARAM2 picasso_SetSpriteImage (TrapContext *ctx) +static uae_u32 REGPARAM2 picasso_SetSpriteImage(TrapContext *ctx) { - uaecptr bi = m68k_areg (regs, 0); + uaecptr bi = trap_get_areg(ctx, 0); boardinfo = bi; - return setspriteimage (bi); + return setspriteimage(ctx, bi); } /* @@ -1799,7 +1852,7 @@ This function activates or deactivates the hardware sprite. static uae_u32 REGPARAM2 picasso_SetSprite (TrapContext *ctx) { uae_u32 result = 0; - uae_u32 activate = m68k_dreg (regs, 0); + uae_u32 activate = trap_get_dreg(ctx, 0); if (!hwsprite) return 0; if (activate) { @@ -1832,27 +1885,27 @@ static uae_u32 REGPARAM2 picasso_SetSprite (TrapContext *ctx) static void picasso96_alloc2 (TrapContext *ctx); static uae_u32 REGPARAM2 picasso_FindCard (TrapContext *ctx) { - uaecptr AmigaBoardInfo = m68k_areg (regs, 0); + uaecptr AmigaBoardInfo = trap_get_areg(ctx, 0); /* NOTES: See BoardInfo struct definition in Picasso96 dev info */ if (!uaegfx_active || !gfxmem_bank.start) return 0; if (uaegfx_base) { - put_long (uaegfx_base + CARD_BOARDINFO, AmigaBoardInfo); + trap_put_long(ctx, uaegfx_base + CARD_BOARDINFO, AmigaBoardInfo); } else if (uaegfx_old) { picasso96_alloc2 (ctx); } boardinfo = AmigaBoardInfo; if (gfxmem_bank.allocated && !picasso96_state.CardFound) { /* Fill in MemoryBase, MemorySize */ - put_long (AmigaBoardInfo + PSSO_BoardInfo_MemoryBase, gfxmem_bank.start); - put_long (AmigaBoardInfo + PSSO_BoardInfo_MemorySize, gfxmem_bank.allocated - reserved_gfxmem); + trap_put_long(ctx, AmigaBoardInfo + PSSO_BoardInfo_MemoryBase, gfxmem_bank.start); + trap_put_long(ctx, AmigaBoardInfo + PSSO_BoardInfo_MemorySize, gfxmem_bank.allocated - reserved_gfxmem); picasso96_state.CardFound = 1; /* mark our "card" as being found */ return -1; } else return 0; } -static void FillBoardInfo (uaecptr amigamemptr, struct LibResolution *res, int width, int height, int depth) +static void FillBoardInfo(TrapContext *ctx, uaecptr amigamemptr, struct LibResolution *res, int width, int height, int depth) { int i; @@ -1873,28 +1926,28 @@ static void FillBoardInfo (uaecptr amigamemptr, struct LibResolution *res, int w break; } for (i = 0; i < PSSO_ModeInfo_sizeof; i++) - put_byte (amigamemptr + i, 0); - - put_word (amigamemptr + PSSO_ModeInfo_Width, width); - put_word (amigamemptr + PSSO_ModeInfo_Height, height); - put_byte (amigamemptr + PSSO_ModeInfo_Depth, depth); - put_byte (amigamemptr + PSSO_ModeInfo_Flags, 0); - put_word (amigamemptr + PSSO_ModeInfo_HorTotal, width); - put_word (amigamemptr + PSSO_ModeInfo_HorBlankSize, 0); - put_word (amigamemptr + PSSO_ModeInfo_HorSyncStart, 0); - put_word (amigamemptr + PSSO_ModeInfo_HorSyncSize, 0); - put_byte (amigamemptr + PSSO_ModeInfo_HorSyncSkew, 0); - put_byte (amigamemptr + PSSO_ModeInfo_HorEnableSkew, 0); - - put_word (amigamemptr + PSSO_ModeInfo_VerTotal, height); - put_word (amigamemptr + PSSO_ModeInfo_VerBlankSize, 0); - put_word (amigamemptr + PSSO_ModeInfo_VerSyncStart, 0); - put_word (amigamemptr + PSSO_ModeInfo_VerSyncSize, 0); - - put_byte (amigamemptr + PSSO_ModeInfo_first_union, 98); - put_byte (amigamemptr + PSSO_ModeInfo_second_union, 14); - - put_long (amigamemptr + PSSO_ModeInfo_PixelClock, + trap_put_byte(ctx, amigamemptr + i, 0); + + trap_put_word(ctx, amigamemptr + PSSO_ModeInfo_Width, width); + trap_put_word(ctx, amigamemptr + PSSO_ModeInfo_Height, height); + trap_put_byte(ctx, amigamemptr + PSSO_ModeInfo_Depth, depth); + trap_put_byte(ctx, amigamemptr + PSSO_ModeInfo_Flags, 0); + trap_put_word(ctx, amigamemptr + PSSO_ModeInfo_HorTotal, width); + trap_put_word(ctx, amigamemptr + PSSO_ModeInfo_HorBlankSize, 0); + trap_put_word(ctx, amigamemptr + PSSO_ModeInfo_HorSyncStart, 0); + trap_put_word(ctx, amigamemptr + PSSO_ModeInfo_HorSyncSize, 0); + trap_put_byte(ctx, amigamemptr + PSSO_ModeInfo_HorSyncSkew, 0); + trap_put_byte(ctx, amigamemptr + PSSO_ModeInfo_HorEnableSkew, 0); + + trap_put_word(ctx, amigamemptr + PSSO_ModeInfo_VerTotal, height); + trap_put_word(ctx, amigamemptr + PSSO_ModeInfo_VerBlankSize, 0); + trap_put_word(ctx, amigamemptr + PSSO_ModeInfo_VerSyncStart, 0); + trap_put_word(ctx, amigamemptr + PSSO_ModeInfo_VerSyncSize, 0); + + trap_put_byte(ctx, amigamemptr + PSSO_ModeInfo_first_union, 98); + trap_put_byte(ctx, amigamemptr + PSSO_ModeInfo_second_union, 14); + + trap_put_long(ctx, amigamemptr + PSSO_ModeInfo_PixelClock, width * height * (currprefs.gfx_apmode[1].gfx_refreshrate ? abs (currprefs.gfx_apmode[1].gfx_refreshrate) : default_freq)); } @@ -1997,22 +2050,22 @@ static int AssignModeID (int w, int h, int *unkcnt) static uaecptr picasso96_amem, picasso96_amemend; -static void CopyLibResolutionStructureU2A (struct LibResolution *libres, uaecptr amigamemptr) +static void CopyLibResolutionStructureU2A(TrapContext *ctx, struct LibResolution *libres, uaecptr amigamemptr) { int i; for (i = 0; i < PSSO_LibResolution_sizeof; i++) - put_byte (amigamemptr + i, 0); + trap_put_byte(ctx, amigamemptr + i, 0); for (i = 0; i < strlen (libres->P96ID); i++) - put_byte (amigamemptr + PSSO_LibResolution_P96ID + i, libres->P96ID[i]); - put_long (amigamemptr + PSSO_LibResolution_DisplayID, libres->DisplayID); - put_word (amigamemptr + PSSO_LibResolution_Width, libres->Width); - put_word (amigamemptr + PSSO_LibResolution_Height, libres->Height); - put_word (amigamemptr + PSSO_LibResolution_Flags, libres->Flags); + trap_put_byte(ctx, amigamemptr + PSSO_LibResolution_P96ID + i, libres->P96ID[i]); + trap_put_long(ctx, amigamemptr + PSSO_LibResolution_DisplayID, libres->DisplayID); + trap_put_word(ctx, amigamemptr + PSSO_LibResolution_Width, libres->Width); + trap_put_word(ctx, amigamemptr + PSSO_LibResolution_Height, libres->Height); + trap_put_word(ctx, amigamemptr + PSSO_LibResolution_Flags, libres->Flags); for (i = 0; i < MAXMODES; i++) - put_long (amigamemptr + PSSO_LibResolution_Modes + i * 4, libres->Modes[i]); - put_long (amigamemptr + 10, amigamemptr + PSSO_LibResolution_P96ID); - put_long (amigamemptr + PSSO_LibResolution_BoardInfo, libres->BoardInfo); + trap_put_long(ctx, amigamemptr + PSSO_LibResolution_Modes + i * 4, libres->Modes[i]); + trap_put_long(ctx, amigamemptr + 10, amigamemptr + PSSO_LibResolution_P96ID); + trap_put_long(ctx, amigamemptr + PSSO_LibResolution_BoardInfo, libres->BoardInfo); } void picasso_allocatewritewatch (int gfxmemsize) @@ -2069,8 +2122,8 @@ static void init_alloc (TrapContext *ctx, int size) { picasso96_amem = picasso96_amemend = 0; if (uaegfx_base) { - int size = get_long (uaegfx_base + CARD_RESLISTSIZE); - picasso96_amem = get_long (uaegfx_base + CARD_RESLIST); + int size = trap_get_long(ctx, uaegfx_base + CARD_RESLISTSIZE); + picasso96_amem = trap_get_long(ctx, uaegfx_base + CARD_RESLIST); } else if (uaegfx_active) { reserved_gfxmem = size; picasso96_amem = gfxmem_bank.start + gfxmem_bank.allocated - size; @@ -2259,8 +2312,8 @@ void picasso96_alloc (TrapContext *ctx) picasso96_alloc2 (ctx); } -static void inituaegfxfuncs (uaecptr start, uaecptr ABI); -static void inituaegfx (uaecptr ABI) +static void inituaegfxfuncs (TrapContext *ctx, uaecptr start, uaecptr ABI); +static void inituaegfx(TrapContext *ctx, uaecptr ABI) { uae_u32 flags; @@ -2268,38 +2321,44 @@ static void inituaegfx (uaecptr ABI) cursorok = 0; cursordeactivate = 0; write_log (_T("RTG mode mask: %x\n"), currprefs.picasso96_modeflags); - put_word (ABI + PSSO_BoardInfo_BitsPerCannon, 8); - put_word (ABI + PSSO_BoardInfo_RGBFormats, currprefs.picasso96_modeflags); - put_long (ABI + PSSO_BoardInfo_BoardType, picasso96_BT); - put_long (ABI + PSSO_BoardInfo_GraphicsControllerType, picasso96_GCT); - put_long (ABI + PSSO_BoardInfo_PaletteChipType, picasso96_PCT); - put_long (ABI + PSSO_BoardInfo_BoardName, uaegfx_resname); - put_long (ABI + PSSO_BoardInfo_BoardType, 1); + trap_put_word(ctx, ABI + PSSO_BoardInfo_BitsPerCannon, 8); + trap_put_word(ctx, ABI + PSSO_BoardInfo_RGBFormats, currprefs.picasso96_modeflags); + trap_put_long(ctx, ABI + PSSO_BoardInfo_BoardType, picasso96_BT); + trap_put_long(ctx, ABI + PSSO_BoardInfo_GraphicsControllerType, picasso96_GCT); + trap_put_long(ctx, ABI + PSSO_BoardInfo_PaletteChipType, picasso96_PCT); + trap_put_long(ctx, ABI + PSSO_BoardInfo_BoardName, uaegfx_resname); + trap_put_long(ctx, ABI + PSSO_BoardInfo_BoardType, 1); /* only 1 clock */ - put_long (ABI + PSSO_BoardInfo_PixelClockCount + PLANAR * 4, 1); - put_long (ABI + PSSO_BoardInfo_PixelClockCount + CHUNKY * 4, 1); - put_long (ABI + PSSO_BoardInfo_PixelClockCount + HICOLOR * 4, 1); - put_long (ABI + PSSO_BoardInfo_PixelClockCount + TRUECOLOR * 4, 1); - put_long (ABI + PSSO_BoardInfo_PixelClockCount + TRUEALPHA * 4, 1); + trap_put_long(ctx, ABI + PSSO_BoardInfo_PixelClockCount + PLANAR * 4, 1); + trap_put_long(ctx, ABI + PSSO_BoardInfo_PixelClockCount + CHUNKY * 4, 1); + trap_put_long(ctx, ABI + PSSO_BoardInfo_PixelClockCount + HICOLOR * 4, 1); + trap_put_long(ctx, ABI + PSSO_BoardInfo_PixelClockCount + TRUECOLOR * 4, 1); + trap_put_long(ctx, ABI + PSSO_BoardInfo_PixelClockCount + TRUEALPHA * 4, 1); /* we have 16 bits for horizontal and vertical timings - hack */ - put_word (ABI + PSSO_BoardInfo_MaxHorValue + PLANAR * 2, 0xffff); - put_word (ABI + PSSO_BoardInfo_MaxHorValue + CHUNKY * 2, 0xffff); - put_word (ABI + PSSO_BoardInfo_MaxHorValue + HICOLOR * 2, 0xffff); - put_word (ABI + PSSO_BoardInfo_MaxHorValue + TRUECOLOR * 2, 0xffff); - put_word (ABI + PSSO_BoardInfo_MaxHorValue + TRUEALPHA * 2, 0xffff); - put_word (ABI + PSSO_BoardInfo_MaxVerValue + PLANAR * 2, 0xffff); - put_word (ABI + PSSO_BoardInfo_MaxVerValue + CHUNKY * 2, 0xffff); - put_word (ABI + PSSO_BoardInfo_MaxVerValue + HICOLOR * 2, 0xffff); - put_word (ABI + PSSO_BoardInfo_MaxVerValue + TRUECOLOR * 2, 0xffff); - put_word (ABI + PSSO_BoardInfo_MaxVerValue + TRUEALPHA * 2, 0xffff); - - flags = get_long (ABI + PSSO_BoardInfo_Flags); + trap_put_word(ctx, ABI + PSSO_BoardInfo_MaxHorValue + PLANAR * 2, 0xffff); + trap_put_word(ctx, ABI + PSSO_BoardInfo_MaxHorValue + CHUNKY * 2, 0xffff); + trap_put_word(ctx, ABI + PSSO_BoardInfo_MaxHorValue + HICOLOR * 2, 0xffff); + trap_put_word(ctx, ABI + PSSO_BoardInfo_MaxHorValue + TRUECOLOR * 2, 0xffff); + trap_put_word(ctx, ABI + PSSO_BoardInfo_MaxHorValue + TRUEALPHA * 2, 0xffff); + trap_put_word(ctx, ABI + PSSO_BoardInfo_MaxVerValue + PLANAR * 2, 0xffff); + trap_put_word(ctx, ABI + PSSO_BoardInfo_MaxVerValue + CHUNKY * 2, 0xffff); + trap_put_word(ctx, ABI + PSSO_BoardInfo_MaxVerValue + HICOLOR * 2, 0xffff); + trap_put_word(ctx, ABI + PSSO_BoardInfo_MaxVerValue + TRUECOLOR * 2, 0xffff); + trap_put_word(ctx, ABI + PSSO_BoardInfo_MaxVerValue + TRUEALPHA * 2, 0xffff); + + flags = trap_get_long(ctx, ABI + PSSO_BoardInfo_Flags); flags &= 0xffff0000; if (flags & BIF_NOBLITTER) write_log (_T("P96: Blitter disabled in devs:monitors/uaegfx!\n")); - flags |= BIF_BLITTER | BIF_NOMEMORYMODEMIX; + if (NOBLITTER_ALL) { + flags |= BIF_NOBLITTER; + flags &= ~BIF_BLITTER; + } else { + flags |= BIF_BLITTER; + } + flags |= BIF_NOMEMORYMODEMIX; flags &= ~BIF_HARDWARESPRITE; if (currprefs.gfx_api && D3D_goodenough () > 0 && USE_HARDWARESPRITE && currprefs.rtg_hardwaresprite) { hwsprite = 1; @@ -2315,24 +2374,24 @@ static void inituaegfx (uaecptr ABI) write_log (_T("P96: BIF_INDISPLAYCHAIN force-enabled!\n")); flags |= BIF_INDISPLAYCHAIN; } - put_long (ABI + PSSO_BoardInfo_Flags, flags); + trap_put_long(ctx, ABI + PSSO_BoardInfo_Flags, flags); if (debug_rtg_blitter != 3) write_log (_T("P96: Blitter mode = %x!\n"), debug_rtg_blitter); - put_word (ABI + PSSO_BoardInfo_MaxHorResolution + 0, planar.width); - put_word (ABI + PSSO_BoardInfo_MaxHorResolution + 2, chunky.width); - put_word (ABI + PSSO_BoardInfo_MaxHorResolution + 4, hicolour.width); - put_word (ABI + PSSO_BoardInfo_MaxHorResolution + 6, truecolour.width); - put_word (ABI + PSSO_BoardInfo_MaxHorResolution + 8, alphacolour.width); - put_word (ABI + PSSO_BoardInfo_MaxVerResolution + 0, planar.height); - put_word (ABI + PSSO_BoardInfo_MaxVerResolution + 2, chunky.height); - put_word (ABI + PSSO_BoardInfo_MaxVerResolution + 4, hicolour.height); - put_word (ABI + PSSO_BoardInfo_MaxVerResolution + 6, truecolour.height); - put_word (ABI + PSSO_BoardInfo_MaxVerResolution + 8, alphacolour.height); - inituaegfxfuncs (uaegfx_rom, ABI); + trap_put_word(ctx, ABI + PSSO_BoardInfo_MaxHorResolution + 0, planar.width); + trap_put_word(ctx, ABI + PSSO_BoardInfo_MaxHorResolution + 2, chunky.width); + trap_put_word(ctx, ABI + PSSO_BoardInfo_MaxHorResolution + 4, hicolour.width); + trap_put_word(ctx, ABI + PSSO_BoardInfo_MaxHorResolution + 6, truecolour.width); + trap_put_word(ctx, ABI + PSSO_BoardInfo_MaxHorResolution + 8, alphacolour.width); + trap_put_word(ctx, ABI + PSSO_BoardInfo_MaxVerResolution + 0, planar.height); + trap_put_word(ctx, ABI + PSSO_BoardInfo_MaxVerResolution + 2, chunky.height); + trap_put_word(ctx, ABI + PSSO_BoardInfo_MaxVerResolution + 4, hicolour.height); + trap_put_word(ctx, ABI + PSSO_BoardInfo_MaxVerResolution + 6, truecolour.height); + trap_put_word(ctx, ABI + PSSO_BoardInfo_MaxVerResolution + 8, alphacolour.height); + inituaegfxfuncs(ctx, uaegfx_rom, ABI); } -static void addmode (uaecptr AmigaBoardInfo, uaecptr *amem, struct LibResolution *res, int w, int h, const TCHAR *name, int display, int *unkcnt) +static void addmode(TrapContext *ctx, uaecptr AmigaBoardInfo, uaecptr *amem, struct LibResolution *res, int w, int h, const TCHAR *name, int display, int *unkcnt) { int depth; @@ -2358,7 +2417,7 @@ static void addmode (uaecptr AmigaBoardInfo, uaecptr *amem, struct LibResolution if (!p96depth (depth)) continue; if(gfxmem_bank.allocated >= w * h * (depth + 7) / 8) { - FillBoardInfo (*amem, res, w, h, depth); + FillBoardInfo(ctx, *amem, res, w, h, depth); *amem += PSSO_ModeInfo_sizeof; } } @@ -2375,7 +2434,7 @@ static uae_u32 REGPARAM2 picasso_InitCard (TrapContext *ctx) int LibResolutionStructureCount = 0; int i, j, unkcnt, cnt; uaecptr amem; - uaecptr AmigaBoardInfo = m68k_areg (regs, 0); + uaecptr AmigaBoardInfo = trap_get_areg(ctx, 0); if (!picasso96_amem) { write_log (_T("P96: InitCard() but no resolution memory!\n")); @@ -2383,7 +2442,7 @@ static uae_u32 REGPARAM2 picasso_InitCard (TrapContext *ctx) } amem = picasso96_amem; - inituaegfx (AmigaBoardInfo); + inituaegfx(ctx, AmigaBoardInfo); i = 0; unkcnt = cnt = 0; @@ -2391,7 +2450,7 @@ static uae_u32 REGPARAM2 picasso_InitCard (TrapContext *ctx) struct LibResolution res = { 0 }; TCHAR *s; j = i; - addmode (AmigaBoardInfo, &amem, &res, newmodes[i].res.width, newmodes[i].res.height, NULL, 0, &unkcnt); + addmode(ctx, AmigaBoardInfo, &amem, &res, newmodes[i].res.width, newmodes[i].res.height, NULL, 0, &unkcnt); s = au (res.Name); write_log (_T("%2d: %08X %4dx%4d %s\n"), ++cnt, res.DisplayID, res.Width, res.Height, s); xfree (s); @@ -2401,11 +2460,11 @@ static uae_u32 REGPARAM2 picasso_InitCard (TrapContext *ctx) i++; LibResolutionStructureCount++; - CopyLibResolutionStructureU2A (&res, amem); + CopyLibResolutionStructureU2A(ctx, &res, amem); #if P96TRACING_ENABLED && P96TRACING_LEVEL > 1 - DumpLibResolutionStructure(amem); + DumpLibResolutionStructurectx, (amem); #endif - AmigaListAddTail (AmigaBoardInfo + PSSO_BoardInfo_ResolutionsList, amem); + AmigaListAddTail(ctx, AmigaBoardInfo + PSSO_BoardInfo_ResolutionsList, amem); amem += PSSO_LibResolution_sizeof; } #if MULTIDISPLAY @@ -2424,7 +2483,7 @@ static uae_u32 REGPARAM2 picasso_InitCard (TrapContext *ctx) LibResolutionStructureCount++; CopyLibResolutionStructureU2A (&res, amem); #if P96TRACING_ENABLED && P96TRACING_LEVEL > 1 - DumpLibResolutionStructure(amem); + DumpLibResolutionStructure(ctx, amem); #endif AmigaListAddTail (AmigaBoardInfo + PSSO_BoardInfo_ResolutionsList, amem); amem += PSSO_LibResolution_sizeof; @@ -2451,7 +2510,7 @@ static uae_u32 REGPARAM2 picasso_InitCard (TrapContext *ctx) */ static uae_u32 REGPARAM2 picasso_SetSwitch (TrapContext *ctx) { - uae_u16 flag = m68k_dreg (regs, 0) & 0xFFFF; + uae_u16 flag = trap_get_dreg(ctx, 0) & 0xFFFF; TCHAR p96text[100]; /* Do not switch immediately. Tell the custom chip emulation about the @@ -2497,15 +2556,16 @@ static void resetpalette(void) * per cannon your board has. So you might have to shift the colors * before writing them to the hardware. */ -static int updateclut (uaecptr clut, int start, int count) +static int updateclut(TrapContext *ctx, uaecptr clut, int start, int count) { + uae_u8 clutbuf[256 * 3]; int i, changed = 0; clut += start * 3; + trap_get_bytes(ctx, clutbuf + start * 3, clut, count * 3); for (i = start; i < start + count; i++) { - int r = get_byte (clut); - int g = get_byte (clut + 1); - int b = get_byte (clut + 2); - + int r = clutbuf[i * 3 + 0]; + int g = clutbuf[i * 3 + 1]; + int b = clutbuf[i * 3 + 2]; //write_log(_T("%d: %02x%02x%02x\n"), i, r, g, b); changed |= picasso96_state.CLUT[i].Red != r || picasso96_state.CLUT[i].Green != g @@ -2526,13 +2586,13 @@ static uae_u32 REGPARAM2 picasso_SetColorArray (TrapContext *ctx) { /* Fill in some static UAE related structure about this new CLUT setting * We need this for CLUT-based displays, and for mapping CLUT to hi/true colour */ - uae_u16 start = m68k_dreg (regs, 0); - uae_u16 count = m68k_dreg (regs, 1); - uaecptr boardinfo = m68k_areg (regs, 0); + uae_u16 start = trap_get_dreg (ctx, 0); + uae_u16 count = trap_get_dreg (ctx, 1); + uaecptr boardinfo = trap_get_areg (ctx, 0); uaecptr clut = boardinfo + PSSO_BoardInfo_CLUT; if (start > 256 || start + count > 256) return 0; - if (updateclut (clut, start, count)) + if (updateclut(ctx, clut, start, count)) full_refresh = 1; P96TRACE((_T("SetColorArray(%d,%d)\n"), start, count)); return 1; @@ -2592,21 +2652,21 @@ static void init_picasso_screen (void) static uae_u32 REGPARAM2 picasso_SetGC (TrapContext *ctx) { /* Fill in some static UAE related structure about this new ModeInfo setting */ - uaecptr AmigaBoardInfo = m68k_areg (regs, 0); - uae_u32 border = m68k_dreg (regs, 0); - uaecptr modeinfo = m68k_areg (regs, 1); + uaecptr AmigaBoardInfo = trap_get_areg(ctx, 0); + uae_u32 border = trap_get_dreg(ctx, 0); + uaecptr modeinfo = trap_get_areg(ctx, 1); - put_long (AmigaBoardInfo + PSSO_BoardInfo_ModeInfo, modeinfo); - put_word (AmigaBoardInfo + PSSO_BoardInfo_Border, border); + trap_put_long(ctx, AmigaBoardInfo + PSSO_BoardInfo_ModeInfo, modeinfo); + trap_put_word(ctx, AmigaBoardInfo + PSSO_BoardInfo_Border, border); - picasso96_state.Width = get_word (modeinfo + PSSO_ModeInfo_Width); + picasso96_state.Width = trap_get_word(ctx, modeinfo + PSSO_ModeInfo_Width); picasso96_state.VirtualWidth = picasso96_state.Width; /* in case SetPanning doesn't get called */ - picasso96_state.Height = get_word (modeinfo + PSSO_ModeInfo_Height); + picasso96_state.Height =trap_get_word(ctx, modeinfo + PSSO_ModeInfo_Height); picasso96_state.VirtualHeight = picasso96_state.Height; /* in case SetPanning doesn't get called */ - picasso96_state.GC_Depth = get_byte (modeinfo + PSSO_ModeInfo_Depth); - picasso96_state.GC_Flags = get_byte (modeinfo + PSSO_ModeInfo_Flags); + picasso96_state.GC_Depth = trap_get_byte(ctx, modeinfo + PSSO_ModeInfo_Depth); + picasso96_state.GC_Flags = trap_get_byte(ctx, modeinfo + PSSO_ModeInfo_Flags); P96TRACE((_T("SetGC(%d,%d,%d,%d)\n"), picasso96_state.Width, picasso96_state.Height, picasso96_state.GC_Depth, border)); set_gc_called = 1; @@ -2651,10 +2711,10 @@ static void picasso_SetPanningInit (void) static uae_u32 REGPARAM2 picasso_SetPanning (TrapContext *ctx) { - uae_u16 Width = m68k_dreg (regs, 0); - uaecptr start_of_screen = m68k_areg (regs, 1); - uaecptr bi = m68k_areg (regs, 0); - uaecptr bmeptr = get_long (bi + PSSO_BoardInfo_BitMapExtra); /* Get our BoardInfo ptr's BitMapExtra ptr */ + uae_u16 Width = trap_get_dreg(ctx, 0); + uaecptr start_of_screen = trap_get_areg(ctx, 1); + uaecptr bi = trap_get_areg(ctx, 0); + uaecptr bmeptr = trap_get_long(ctx, bi + PSSO_BoardInfo_BitMapExtra); /* Get our BoardInfo ptr's BitMapExtra ptr */ uae_u16 bme_width, bme_height; int changed = 0; RGBFTYPE rgbf; @@ -2668,24 +2728,24 @@ static uae_u32 REGPARAM2 picasso_SetPanning (TrapContext *ctx) changed = 1; } - bme_width = get_word (bmeptr + PSSO_BitMapExtra_Width); - bme_height = get_word (bmeptr + PSSO_BitMapExtra_Height); + bme_width =trap_get_word(ctx, bmeptr + PSSO_BitMapExtra_Width); + bme_height = trap_get_word(ctx, bmeptr + PSSO_BitMapExtra_Height); rgbf = picasso96_state.RGBFormat; picasso96_state.Address = start_of_screen; /* Amiga-side address */ - picasso96_state.XOffset = (uae_s16)(m68k_dreg (regs, 1) & 0xFFFF); - picasso96_state.YOffset = (uae_s16)(m68k_dreg (regs, 2) & 0xFFFF); - put_word (bi + PSSO_BoardInfo_XOffset, picasso96_state.XOffset); - put_word (bi + PSSO_BoardInfo_YOffset, picasso96_state.YOffset); + picasso96_state.XOffset = (uae_s16)(trap_get_dreg(ctx, 1) & 0xFFFF); + picasso96_state.YOffset = (uae_s16)(trap_get_dreg(ctx, 2) & 0xFFFF); + trap_put_word(ctx, bi + PSSO_BoardInfo_XOffset, picasso96_state.XOffset); + trap_put_word(ctx, bi + PSSO_BoardInfo_YOffset, picasso96_state.YOffset); picasso96_state.VirtualWidth = bme_width; picasso96_state.VirtualHeight = bme_height; - picasso96_state.RGBFormat = (RGBFTYPE)m68k_dreg (regs, 7); + picasso96_state.RGBFormat = (RGBFTYPE)trap_get_dreg(ctx, 7); picasso96_state.BytesPerPixel = GetBytesPerPixel (picasso96_state.RGBFormat); picasso96_state.BytesPerRow = picasso96_state.VirtualWidth * picasso96_state.BytesPerPixel; picasso_SetPanningInit(); if (rgbf != picasso96_state.RGBFormat) - setconvert (); + setconvert(ctx); full_refresh = 1; set_panning_called = 1; @@ -2761,13 +2821,13 @@ static void do_xor8 (uae_u8 *p, int w, uae_u32 v) */ static uae_u32 REGPARAM2 picasso_InvertRect (TrapContext *ctx) { - uaecptr renderinfo = m68k_areg (regs, 1); - uae_u32 X = (uae_u16)m68k_dreg (regs, 0); - uae_u32 Y = (uae_u16)m68k_dreg (regs, 1); - uae_u32 Width = (uae_u16)m68k_dreg (regs, 2); - uae_u32 Height = (uae_u16)m68k_dreg (regs, 3); - uae_u8 mask = (uae_u8)m68k_dreg (regs, 4); - int Bpp = GetBytesPerPixel (m68k_dreg (regs, 7)); + uaecptr renderinfo = trap_get_areg(ctx, 1); + uae_u32 X = (uae_u16)trap_get_dreg(ctx, 0); + uae_u32 Y = (uae_u16)trap_get_dreg(ctx, 1); + uae_u32 Width = (uae_u16)trap_get_dreg(ctx, 2); + uae_u32 Height = (uae_u16)trap_get_dreg(ctx, 3); + uae_u8 mask = (uae_u8)trap_get_dreg(ctx, 4); + int Bpp = GetBytesPerPixel (trap_get_dreg(ctx, 7)); uae_u32 xorval; unsigned int lines; struct RenderInfo ri; @@ -2778,10 +2838,10 @@ static uae_u32 REGPARAM2 picasso_InvertRect (TrapContext *ctx) if (NOBLITTER) return 0; - if (CopyRenderInfoStructureA2U (renderinfo, &ri)) { + if (CopyRenderInfoStructureA2U(ctx, renderinfo, &ri)) { P96TRACE((_T("InvertRect %dbpp 0x%lx\n"), Bpp, (long)mask)); - if (!validatecoords (&ri, &X, &Y, &Width, &Height)) + if (!validatecoords(ctx, &ri, &X, &Y, &Width, &Height)) return 1; if (mask != 0xFF && Bpp > 1) @@ -2812,16 +2872,16 @@ FillRect: * d5: UBYTE Mask * d7: uae_u32 RGBFormat ***********************************************************/ -static uae_u32 REGPARAM2 picasso_FillRect (TrapContext *ctx) +static uae_u32 REGPARAM2 picasso_FillRect(TrapContext *ctx) { - uaecptr renderinfo = m68k_areg (regs, 1); - uae_u32 X = (uae_u16)m68k_dreg (regs, 0); - uae_u32 Y = (uae_u16)m68k_dreg (regs, 1); - uae_u32 Width = (uae_u16)m68k_dreg (regs, 2); - uae_u32 Height = (uae_u16)m68k_dreg (regs, 3); - uae_u32 Pen = m68k_dreg (regs, 4); - uae_u8 Mask = (uae_u8)m68k_dreg (regs, 5); - RGBFTYPE RGBFormat = (RGBFTYPE)m68k_dreg (regs, 7); + uaecptr renderinfo = trap_get_areg(ctx, 1); + uae_u32 X = (uae_u16)trap_get_dreg(ctx, 0); + uae_u32 Y = (uae_u16)trap_get_dreg(ctx, 1); + uae_u32 Width = (uae_u16)trap_get_dreg(ctx, 2); + uae_u32 Height = (uae_u16)trap_get_dreg(ctx, 3); + uae_u32 Pen = trap_get_dreg(ctx, 4); + uae_u8 Mask = (uae_u8)trap_get_dreg(ctx, 5); + RGBFTYPE RGBFormat = (RGBFTYPE)trap_get_dreg(ctx, 7); uae_u8 *oldstart; int Bpp; struct RenderInfo ri; @@ -2829,11 +2889,11 @@ static uae_u32 REGPARAM2 picasso_FillRect (TrapContext *ctx) if (NOBLITTER) return 0; - if (CopyRenderInfoStructureA2U (renderinfo, &ri)) { - if (!validatecoords (&ri, &X, &Y, &Width, &Height)) + if (CopyRenderInfoStructureA2U(ctx, renderinfo, &ri)) { + if (!validatecoords(ctx, &ri, &X, &Y, &Width, &Height)) return 1; - Bpp = GetBytesPerPixel (RGBFormat); + Bpp = GetBytesPerPixel(RGBFormat); P96TRACE((_T("FillRect(%d, %d, %d, %d) Pen 0x%x BPP %d BPR %d Mask 0x%x\n"), X, Y, Width, Height, Pen, Bpp, ri.BytesPerRow, Mask)); @@ -2844,7 +2904,7 @@ static uae_u32 REGPARAM2 picasso_FillRect (TrapContext *ctx) if (Mask == 0xFF) { /* Do the fill-rect in the frame-buffer */ - do_fillrect_frame_buffer (&ri, X, Y, Width, Height, Pen, Bpp); + do_fillrect_frame_buffer(&ri, X, Y, Width, Height, Pen, Bpp); result = 1; } else { @@ -2913,7 +2973,7 @@ struct blitdata BLIT_OPCODE opcode; } blitrectdata; -STATIC_INLINE int BlitRectHelper (void) +STATIC_INLINE int BlitRectHelper(TrapContext *ctx) { struct RenderInfo *ri = blitrectdata.ri; struct RenderInfo *dstri = blitrectdata.dstri; @@ -2926,9 +2986,9 @@ STATIC_INLINE int BlitRectHelper (void) uae_u8 mask = blitrectdata.mask; BLIT_OPCODE opcode = blitrectdata.opcode; - if (!validatecoords (ri, &srcx, &srcy, &width, &height)) + if (!validatecoords(ctx, ri, &srcx, &srcy, &width, &height)) return 1; - if (!validatecoords (dstri, &dstx, &dsty, &width, &height)) + if (!validatecoords(ctx, dstri, &dstx, &dsty, &width, &height)) return 1; uae_u8 Bpp = GetBytesPerPixel (ri->RGBFormat); @@ -2952,18 +3012,18 @@ STATIC_INLINE int BlitRectHelper (void) dstri = ri; } /* Do our virtual frame-buffer memory first */ - return do_blitrect_frame_buffer (ri, dstri, srcx, srcy, dstx, dsty, width, height, mask, opcode); + return do_blitrect_frame_buffer(ri, dstri, srcx, srcy, dstx, dsty, width, height, mask, opcode); } -STATIC_INLINE int BlitRect (uaecptr ri, uaecptr dstri, +static int BlitRect(TrapContext *ctx, uaecptr ri, uaecptr dstri, unsigned long srcx, unsigned long srcy, unsigned long dstx, unsigned long dsty, unsigned long width, unsigned long height, uae_u8 mask, BLIT_OPCODE opcode) { /* Set up the params */ - CopyRenderInfoStructureA2U(ri, &blitrectdata.ri_struct); + CopyRenderInfoStructureA2U(ctx, ri, &blitrectdata.ri_struct); blitrectdata.ri = &blitrectdata.ri_struct; if(dstri) { - CopyRenderInfoStructureA2U(dstri, &blitrectdata.dstri_struct); + CopyRenderInfoStructureA2U(ctx, dstri, &blitrectdata.dstri_struct); blitrectdata.dstri = &blitrectdata.dstri_struct; } else { blitrectdata.dstri = NULL; @@ -2977,7 +3037,7 @@ STATIC_INLINE int BlitRect (uaecptr ri, uaecptr dstri, blitrectdata.mask = mask; blitrectdata.opcode = opcode; - return BlitRectHelper (); + return BlitRectHelper(ctx); } /*********************************************************** @@ -2996,20 +3056,20 @@ BlitRect: ***********************************************************/ static uae_u32 REGPARAM2 picasso_BlitRect (TrapContext *ctx) { - uaecptr renderinfo = m68k_areg (regs, 1); - unsigned long srcx = (uae_u16)m68k_dreg (regs, 0); - unsigned long srcy = (uae_u16)m68k_dreg (regs, 1); - unsigned long dstx = (uae_u16)m68k_dreg (regs, 2); - unsigned long dsty = (uae_u16)m68k_dreg (regs, 3); - unsigned long width = (uae_u16)m68k_dreg (regs, 4); - unsigned long height = (uae_u16)m68k_dreg (regs, 5); - uae_u8 Mask = (uae_u8)m68k_dreg (regs, 6); + uaecptr renderinfo = trap_get_areg(ctx, 1); + unsigned long srcx = (uae_u16)trap_get_dreg(ctx, 0); + unsigned long srcy = (uae_u16)trap_get_dreg(ctx, 1); + unsigned long dstx = (uae_u16)trap_get_dreg(ctx, 2); + unsigned long dsty = (uae_u16)trap_get_dreg(ctx, 3); + unsigned long width = (uae_u16)trap_get_dreg(ctx, 4); + unsigned long height = (uae_u16)trap_get_dreg(ctx, 5); + uae_u8 Mask = (uae_u8)trap_get_dreg(ctx, 6); uae_u32 result = 0; if (NOBLITTER_BLIT) return 0; P96TRACE((_T("BlitRect(%d, %d, %d, %d, %d, %d, 0x%x)\n"), srcx, srcy, dstx, dsty, width, height, Mask)); - result = BlitRect (renderinfo, (uaecptr)NULL, srcx, srcy, dstx, dsty, width, height, Mask, BLIT_SRC); + result = BlitRect(ctx, renderinfo, (uaecptr)NULL, srcx, srcy, dstx, dsty, width, height, Mask, BLIT_SRC); return result; } @@ -3033,28 +3093,29 @@ BlitRectNoMaskComplete: ***********************************************************/ static uae_u32 REGPARAM2 picasso_BlitRectNoMaskComplete (TrapContext *ctx) { - uaecptr srcri = m68k_areg (regs, 1); - uaecptr dstri = m68k_areg (regs, 2); - unsigned long srcx = (uae_u16)m68k_dreg (regs, 0); - unsigned long srcy = (uae_u16)m68k_dreg (regs, 1); - unsigned long dstx = (uae_u16)m68k_dreg (regs, 2); - unsigned long dsty = (uae_u16)m68k_dreg (regs, 3); - unsigned long width = (uae_u16)m68k_dreg (regs, 4); - unsigned long height = (uae_u16)m68k_dreg (regs, 5); - BLIT_OPCODE OpCode = (BLIT_OPCODE)(m68k_dreg (regs, 6) & 0xff); - uae_u32 RGBFmt = m68k_dreg (regs, 7); + uaecptr srcri = trap_get_areg(ctx, 1); + uaecptr dstri = trap_get_areg(ctx, 2); + unsigned long srcx = (uae_u16)trap_get_dreg(ctx, 0); + unsigned long srcy = (uae_u16)trap_get_dreg(ctx, 1); + unsigned long dstx = (uae_u16)trap_get_dreg(ctx, 2); + unsigned long dsty = (uae_u16)trap_get_dreg(ctx, 3); + unsigned long width = (uae_u16)trap_get_dreg(ctx, 4); + unsigned long height = (uae_u16)trap_get_dreg(ctx, 5); + BLIT_OPCODE OpCode = (BLIT_OPCODE)(trap_get_dreg(ctx, 6) & 0xff); + uae_u32 RGBFmt = trap_get_dreg(ctx, 7); uae_u32 result = 0; if (NOBLITTER_BLIT) return 0; + P96TRACE((_T("BlitRectNoMaskComplete() op 0x%02x, %08x:(%4d,%4d) --> %08x:(%4d,%4d), wh(%4d,%4d)\n"), - OpCode, get_long (srcri + PSSO_RenderInfo_Memory), srcx, srcy, get_long (dstri + PSSO_RenderInfo_Memory), dstx, dsty, width, height)); - result = BlitRect (srcri, dstri, srcx, srcy, dstx, dsty, width, height, 0xFF, OpCode); + OpCode, trap_get_long(ctx, srcri + PSSO_RenderInfo_Memory), srcx, srcy, trap_get_long(ctx, dstri + PSSO_RenderInfo_Memory), dstx, dsty, width, height)); + result = BlitRect(ctx, srcri, dstri, srcx, srcy, dstx, dsty, width, height, 0xFF, OpCode); return result; } /* NOTE: fgpen MUST be in host byte order */ -STATIC_INLINE void PixelWrite (uae_u8 *mem, int bits, uae_u32 fgpen, int Bpp, uae_u32 mask) +STATIC_INLINE void PixelWrite(uae_u8 *mem, int bits, uae_u32 fgpen, int Bpp, uae_u32 mask) { switch (Bpp) { @@ -3101,14 +3162,14 @@ STATIC_INLINE void PixelWrite (uae_u8 *mem, int bits, uae_u32 fgpen, int Bpp, ua */ static uae_u32 REGPARAM2 picasso_BlitPattern (TrapContext *ctx) { - uaecptr rinf = m68k_areg (regs, 1); - uaecptr pinf = m68k_areg (regs, 2); - uae_u32 X = (uae_u16)m68k_dreg (regs, 0); - uae_u32 Y = (uae_u16)m68k_dreg (regs, 1); - uae_u32 W = (uae_u16)m68k_dreg (regs, 2); - uae_u32 H = (uae_u16)m68k_dreg (regs, 3); - uae_u8 Mask = (uae_u8)m68k_dreg (regs, 4); - uae_u32 RGBFmt = m68k_dreg (regs, 7); + uaecptr rinf = trap_get_areg(ctx, 1); + uaecptr pinf = trap_get_areg(ctx, 2); + uae_u32 X = (uae_u16)trap_get_dreg(ctx, 0); + uae_u32 Y = (uae_u16)trap_get_dreg(ctx, 1); + uae_u32 W = (uae_u16)trap_get_dreg(ctx, 2); + uae_u32 H = (uae_u16)trap_get_dreg(ctx, 3); + uae_u8 Mask = (uae_u8)trap_get_dreg(ctx, 4); + uae_u32 RGBFmt = trap_get_dreg(ctx, 7); uae_u8 Bpp = GetBytesPerPixel (RGBFmt); int inversion = 0; struct RenderInfo ri; @@ -3121,9 +3182,10 @@ static uae_u32 REGPARAM2 picasso_BlitPattern (TrapContext *ctx) if (NOBLITTER) return 0; - if(CopyRenderInfoStructureA2U (rinf, &ri) && CopyPatternStructureA2U (pinf, &pattern)) { - if (!validatecoords (&ri, &X, &Y, &W, &H)) - return 1; + + if(CopyRenderInfoStructureA2U(ctx, rinf, &ri) && CopyPatternStructureA2U(ctx, pinf, &pattern)) { + if (!validatecoords(ctx, &ri, &X, &Y, &W, &H)) + return 0; Bpp = GetBytesPerPixel(ri.RGBFormat); uae_mem = ri.Memory + Y * ri.BytesPerRow + X * Bpp; /* offset with address */ @@ -3141,6 +3203,7 @@ static uae_u32 REGPARAM2 picasso_BlitPattern (TrapContext *ctx) } if(result) { + bool indirect = trap_is_indirect(); uae_u32 fgpen, bgpen; P96TRACE((_T("BlitPattern() xy(%d,%d), wh(%d,%d) draw 0x%x, off(%d,%d), ph %d\n"), X, Y, W, H, pattern.DrawMode, pattern.XOffset, pattern.YOffset, 1 << pattern.Size)); @@ -3156,12 +3219,24 @@ static uae_u32 REGPARAM2 picasso_BlitPattern (TrapContext *ctx) bgpen = pattern.BgPen; endianswap (&bgpen, Bpp); + uae_u16 *tmplbuf = NULL; + if (indirect) { + tmplbuf = xcalloc(uae_u16, 1 << pattern.Size); + trap_get_words(ctx, tmplbuf, pattern.AMemory, 1 << pattern.Size); + } + for (rows = 0; rows < H; rows++, uae_mem += ri.BytesPerRow) { unsigned long prow = (rows + pattern.YOffset) & ysize_mask; - unsigned int d = do_get_mem_word (((uae_u16 *)pattern.Memory) + prow); + unsigned int d; uae_u8 *uae_mem2 = uae_mem; unsigned long cols; + if (indirect) { + d = do_get_mem_word(tmplbuf + prow); + } else { + d = do_get_mem_word(((uae_u16 *)pattern.Memory) + prow); + } + if (xshift != 0) d = (d << xshift) | (d >> (16 - xshift)); @@ -3238,6 +3313,7 @@ static uae_u32 REGPARAM2 picasso_BlitPattern (TrapContext *ctx) } } result = 1; + xfree(tmplbuf); } } @@ -3263,16 +3339,16 @@ BlitTemplate: * using a single plane of image data which will be expanded to the destination RGBFormat * using ForeGround and BackGround pens as well as draw modes. ***********************************************************************************/ -static uae_u32 REGPARAM2 picasso_BlitTemplate (TrapContext *ctx) +static uae_u32 REGPARAM2 picasso_BlitTemplate(TrapContext *ctx) { uae_u8 inversion = 0; - uaecptr rinf = m68k_areg (regs, 1); - uaecptr tmpl = m68k_areg (regs, 2); - uae_u32 X = (uae_u16)m68k_dreg (regs, 0); - uae_u32 Y = (uae_u16)m68k_dreg (regs, 1); - uae_u32 W = (uae_u16)m68k_dreg (regs, 2); - uae_u32 H = (uae_u16)m68k_dreg (regs, 3); - uae_u16 Mask = (uae_u16)m68k_dreg (regs, 4); + uaecptr rinf = trap_get_areg(ctx, 1); + uaecptr tmpl = trap_get_areg(ctx, 2); + uae_u32 X = (uae_u16)trap_get_dreg(ctx, 0); + uae_u32 Y = (uae_u16)trap_get_dreg(ctx, 1); + uae_u32 W = (uae_u16)trap_get_dreg(ctx, 2); + uae_u32 H = (uae_u16)trap_get_dreg(ctx, 3); + uae_u16 Mask = (uae_u16)trap_get_dreg(ctx, 4); struct Template tmp; struct RenderInfo ri; unsigned long rows; @@ -3283,8 +3359,8 @@ static uae_u32 REGPARAM2 picasso_BlitTemplate (TrapContext *ctx) if (NOBLITTER) return 0; - if (CopyRenderInfoStructureA2U (rinf, &ri) && CopyTemplateStructureA2U (tmpl, &tmp)) { - if (!validatecoords (&ri, &X, &Y, &W, &H)) + if (CopyRenderInfoStructureA2U(ctx, rinf, &ri) && CopyTemplateStructureA2U(ctx, tmpl, &tmp)) { + if (!validatecoords(ctx, &ri, &X, &Y, &W, &H)) return 1; Bpp = GetBytesPerPixel (ri.RGBFormat); @@ -3310,6 +3386,7 @@ static uae_u32 REGPARAM2 picasso_BlitTemplate (TrapContext *ctx) if(result) { uae_u32 fgpen, bgpen; + bool indirect = trap_is_indirect(); P96TRACE((_T("BlitTemplate() xy(%d,%d), wh(%d,%d) draw 0x%x fg 0x%x bg 0x%x \n"), X, Y, W, H, tmp.DrawMode, tmp.FgPen, tmp.BgPen)); @@ -3320,18 +3397,28 @@ static uae_u32 REGPARAM2 picasso_BlitTemplate (TrapContext *ctx) DumpTemplate(&tmp, W, H); #endif - tmpl_base = tmp.Memory + tmp.XOffset / 8; - fgpen = tmp.FgPen; endianswap (&fgpen, Bpp); bgpen = tmp.BgPen; endianswap (&bgpen, Bpp); + uae_u8 *tmpl_buffer = NULL; + if (indirect) { + int tmpl_size = H * tmp.BytesPerRow * Bpp; + tmpl_buffer = xcalloc(uae_u8, tmpl_size); + trap_get_bytes(ctx, tmpl_buffer, tmp.AMemory, tmpl_size); + tmpl_base = tmpl_buffer + tmp.XOffset / 8; + } else { + tmpl_base = tmp.Memory + tmp.XOffset / 8; + } + for (rows = 0; rows < H; rows++, uae_mem += ri.BytesPerRow, tmpl_base += tmp.BytesPerRow) { unsigned long cols; - uae_u8 *tmpl_mem = tmpl_base; uae_u8 *uae_mem2 = uae_mem; - unsigned int data = *tmpl_mem; + uae_u8 *tmpl_mem = tmpl_base; + unsigned int data; + + data = *tmpl_mem; for (cols = 0; cols < W; cols += 8, uae_mem2 += Bpp * 8) { unsigned int byte; @@ -3356,7 +3443,7 @@ static uae_u32 REGPARAM2 picasso_BlitTemplate (TrapContext *ctx) if (inversion) bit_set = !bit_set; if (bit_set) - PixelWrite (uae_mem2, bits, fgpen, Bpp, Mask); + PixelWrite(uae_mem2, bits, fgpen, Bpp, Mask); } break; } @@ -3367,7 +3454,7 @@ static uae_u32 REGPARAM2 picasso_BlitTemplate (TrapContext *ctx) byte <<= 1; if (inversion) bit_set = !bit_set; - PixelWrite (uae_mem2, bits, bit_set ? fgpen : bgpen, Bpp, Mask); + PixelWrite(uae_mem2, bits, bit_set ? fgpen : bgpen, Bpp, Mask); } break; } @@ -3412,6 +3499,7 @@ static uae_u32 REGPARAM2 picasso_BlitTemplate (TrapContext *ctx) } } result = 1; + xfree(tmpl_buffer); } } @@ -3428,9 +3516,10 @@ static uae_u32 REGPARAM2 picasso_BlitTemplate (TrapContext *ctx) */ static uae_u32 REGPARAM2 picasso_CalculateBytesPerRow (TrapContext *ctx) { - uae_u16 width = m68k_dreg (regs, 0); - uae_u32 type = m68k_dreg (regs, 7); - width = GetBytesPerPixel (type) * width; + uae_u16 width = trap_get_dreg(ctx, 0); + uae_u32 type = trap_get_dreg(ctx, 7); + int bpp = GetBytesPerPixel(type); + width = bpp * width; return width; } @@ -3444,7 +3533,7 @@ static uae_u32 REGPARAM2 picasso_CalculateBytesPerRow (TrapContext *ctx) */ static uae_u32 REGPARAM2 picasso_SetDisplay (TrapContext *ctx) { - uae_u32 state = m68k_dreg (regs, 0); + uae_u32 state = trap_get_dreg(ctx, 0); P96TRACE ((_T("SetDisplay(%d)\n"), state)); resetpalette (); return !state; @@ -3472,7 +3561,7 @@ void init_hz_p96 (void) } /* NOTE: Watch for those planeptrs of 0x00000000 and 0xFFFFFFFF for all zero / all one bitmaps !!!! */ -static void PlanarToChunky (struct RenderInfo *ri, struct BitMap *bm, +static void PlanarToChunky(TrapContext *ctx, struct RenderInfo *ri, struct BitMap *bm, unsigned long srcx, unsigned long srcy, unsigned long dstx, unsigned long dsty, unsigned long width, unsigned long height, @@ -3480,19 +3569,31 @@ static void PlanarToChunky (struct RenderInfo *ri, struct BitMap *bm, { int j; - uae_u8 *PLANAR[8], *image = ri->Memory + dstx * GetBytesPerPixel (ri->RGBFormat) + dsty * ri->BytesPerRow; + uae_u8 *PLANAR[8]; + uaecptr APLANAR[8]; + uae_u8 *image = ri->Memory + dstx * GetBytesPerPixel(ri->RGBFormat) + dsty * ri->BytesPerRow; int Depth = bm->Depth; unsigned long rows, bitoffset = srcx & 7; long eol_offset; + bool indirect = trap_is_indirect(); /* Set up our bm->Planes[] pointers to the right horizontal offset */ for (j = 0; j < Depth; j++) { - uae_u8 *p = bm->Planes[j]; - if (p != &all_zeros_bitmap && p != &all_ones_bitmap) - p += srcx / 8 + srcy * bm->BytesPerRow; - PLANAR[j] = p; - if ((mask & (1 << j)) == 0) - PLANAR[j] = &all_zeros_bitmap; + if (indirect) { + uaecptr ap = bm->APlanes[j]; + if (ap != 0 && ap != 0xffffffff) + ap += srcx / 8 + srcy * bm->BytesPerRow; + APLANAR[j] = ap; + if ((mask & (1 << j)) == 0) + APLANAR[j] = 0; + } else { + uae_u8 *p = bm->Planes[j]; + if (p != &all_zeros_bitmap && p != &all_ones_bitmap) + p += srcx / 8 + srcy * bm->BytesPerRow; + PLANAR[j] = p; + if ((mask & (1 << j)) == 0) + PLANAR[j] = &all_zeros_bitmap; + } } eol_offset = (long)bm->BytesPerRow - (long)((width + 7) >> 3); for (rows = 0; rows < height; rows++, image += ri->BytesPerRow) { @@ -3515,13 +3616,24 @@ static void PlanarToChunky (struct RenderInfo *ri, struct BitMap *bm, } for (k = 0; k < Depth; k++) { unsigned int data; - if (PLANAR[k] == &all_zeros_bitmap) - data = 0; - else if (PLANAR[k] == &all_ones_bitmap) - data = 0xFF; - else { - data = (uae_u8)(do_get_mem_word ((uae_u16 *)PLANAR[k]) >> (8 - bitoffset)); - PLANAR[k]++; + if (indirect) { + if (APLANAR[k] == 0) + data = 0; + else if (APLANAR[k] == 0xffffffff) + data = 0xFF; + else { + data = (uae_u8)(trap_get_word(ctx, APLANAR[k]) >> (8 - bitoffset)); + APLANAR[k]++; + } + } else { + if (PLANAR[k] == &all_zeros_bitmap) + data = 0; + else if (PLANAR[k] == &all_ones_bitmap) + data = 0xFF; + else { + data = (uae_u8)(do_get_mem_word ((uae_u16 *)PLANAR[k]) >> (8 - bitoffset)); + PLANAR[k]++; + } } data &= msk; a |= p2ctab[data][0] << k; @@ -3531,8 +3643,14 @@ static void PlanarToChunky (struct RenderInfo *ri, struct BitMap *bm, do_put_mem_long ((uae_u32 *)(image + cols + 4), b); } for (j = 0; j < Depth; j++) { - if (PLANAR[j] != &all_zeros_bitmap && PLANAR[j] != &all_ones_bitmap) { - PLANAR[j] += eol_offset; + if (indirect) { + if (APLANAR[j] != 0 && APLANAR[j] != 0xffffffff) { + APLANAR[j] += eol_offset; + } + } else { + if (PLANAR[j] != &all_zeros_bitmap && PLANAR[j] != &all_ones_bitmap) { + PLANAR[j] += eol_offset; + } } } } @@ -3558,16 +3676,16 @@ static void PlanarToChunky (struct RenderInfo *ri, struct BitMap *bm, */ static uae_u32 REGPARAM2 picasso_BlitPlanar2Chunky (TrapContext *ctx) { - uaecptr bm = m68k_areg (regs, 1); - uaecptr ri = m68k_areg (regs, 2); - unsigned long srcx = (uae_u16)m68k_dreg (regs, 0); - unsigned long srcy = (uae_u16)m68k_dreg (regs, 1); - unsigned long dstx = (uae_u16)m68k_dreg (regs, 2); - unsigned long dsty = (uae_u16)m68k_dreg (regs, 3); - unsigned long width = (uae_u16)m68k_dreg (regs, 4); - unsigned long height = (uae_u16)m68k_dreg (regs, 5); - uae_u8 minterm = m68k_dreg (regs, 6) & 0xFF; - uae_u8 mask = m68k_dreg (regs, 7) & 0xFF; + uaecptr bm = trap_get_areg(ctx, 1); + uaecptr ri = trap_get_areg(ctx, 2); + unsigned long srcx = (uae_u16)trap_get_dreg(ctx, 0); + unsigned long srcy = (uae_u16)trap_get_dreg(ctx, 1); + unsigned long dstx = (uae_u16)trap_get_dreg(ctx, 2); + unsigned long dsty = (uae_u16)trap_get_dreg(ctx, 3); + unsigned long width = (uae_u16)trap_get_dreg(ctx, 4); + unsigned long height = (uae_u16)trap_get_dreg(ctx, 5); + uae_u8 minterm = trap_get_dreg(ctx, 6) & 0xFF; + uae_u8 mask = trap_get_dreg(ctx, 7) & 0xFF; struct RenderInfo local_ri; struct BitMap local_bm; uae_u32 result = 0; @@ -3577,18 +3695,18 @@ static uae_u32 REGPARAM2 picasso_BlitPlanar2Chunky (TrapContext *ctx) if (minterm != 0x0C) { write_log (_T("ERROR - BlitPlanar2Chunky() has minterm 0x%x, which I don't handle. Using fall-back routine.\n"), minterm); - } else if (CopyRenderInfoStructureA2U (ri, &local_ri) && CopyBitMapStructureA2U (bm, &local_bm)) { + } else if (CopyRenderInfoStructureA2U(ctx, ri, &local_ri) && CopyBitMapStructureA2U(ctx, bm, &local_bm)) { P96TRACE((_T("BlitPlanar2Chunky(%d, %d, %d, %d, %d, %d) Minterm 0x%x, Mask 0x%x, Depth %d\n"), srcx, srcy, dstx, dsty, width, height, minterm, mask, local_bm.Depth)); P96TRACE((_T("P2C - BitMap has %d BPR, %d rows\n"), local_bm.BytesPerRow, local_bm.Rows)); - PlanarToChunky (&local_ri, &local_bm, srcx, srcy, dstx, dsty, width, height, mask); + PlanarToChunky (ctx, &local_ri, &local_bm, srcx, srcy, dstx, dsty, width, height, mask); result = 1; } return result; } /* NOTE: Watch for those planeptrs of 0x00000000 and 0xFFFFFFFF for all zero / all one bitmaps !!!! */ -static void PlanarToDirect (struct RenderInfo *ri, struct BitMap *bm, +static void PlanarToDirect (TrapContext *ctx, struct RenderInfo *ri, struct BitMap *bm, unsigned long srcx, unsigned long srcy, unsigned long dstx, unsigned long dsty, unsigned long width, unsigned long height, uae_u8 mask, struct ColorIndexMapping *cim) @@ -3596,22 +3714,39 @@ static void PlanarToDirect (struct RenderInfo *ri, struct BitMap *bm, int j; int bpp = GetBytesPerPixel (ri->RGBFormat); uae_u8 *PLANAR[8]; + uaecptr APLANAR[8]; uae_u8 *image = ri->Memory + dstx * bpp + dsty * ri->BytesPerRow; int Depth = bm->Depth; unsigned long rows; long eol_offset; + bool indirect = trap_is_indirect(); if(!bpp) return; /* Set up our bm->Planes[] pointers to the right horizontal offset */ for (j = 0; j < Depth; j++) { - uae_u8 *p = bm->Planes[j]; - if (p != &all_zeros_bitmap && p != &all_ones_bitmap) - p += srcx / 8 + srcy * bm->BytesPerRow; - PLANAR[j] = p; - if ((mask & (1 << j)) == 0) - PLANAR[j] = &all_zeros_bitmap; + if (indirect) { + uaecptr ap = bm->APlanes[j]; + if (ap != 0 && ap != 0xffffffff) + ap += srcx / 8 + srcy * bm->BytesPerRow; + APLANAR[j] = ap; + if ((mask & (1 << j)) == 0) + APLANAR[j] = 0; + } else { + uae_u8 *p = bm->Planes[j]; + if (p != &all_zeros_bitmap && p != &all_ones_bitmap) + p += srcx / 8 + srcy * bm->BytesPerRow; + PLANAR[j] = p; + if ((mask & (1 << j)) == 0) + PLANAR[j] = &all_zeros_bitmap; + } + } + + uae_u8 *planebuf = NULL; + int planebuf_width = (width + 1) & ~1; + if (indirect) { + planebuf = xmalloc(uae_u8, planebuf_width * Depth); } eol_offset = (long)bm->BytesPerRow - (long)((width + (srcx & 7)) >> 3); @@ -3621,6 +3756,19 @@ static void PlanarToDirect (struct RenderInfo *ri, struct BitMap *bm, unsigned int bitoffs = 7 - (srcx & 7); int i; + if (indirect) { + for (int k = 0; k < Depth; k++) { + if (APLANAR[k] != 0 && APLANAR[k] != 0xffffffff) { + PLANAR[k] = planebuf + planebuf_width *k; + trap_get_bytes(ctx, PLANAR[k], APLANAR[k], planebuf_width); + } else if (APLANAR[k] == 0) { + PLANAR[k] = &all_zeros_bitmap; + } else { + PLANAR[k] = &all_ones_bitmap; + } + } + } + for (cols = 0; cols < width; cols ++) { int v = 0, k; for (k = 0; k < Depth; k++) { @@ -3654,6 +3802,8 @@ static void PlanarToDirect (struct RenderInfo *ri, struct BitMap *bm, for (k = 0; k < Depth; k++) { if (PLANAR[k] != &all_zeros_bitmap && PLANAR[k] != &all_ones_bitmap) { PLANAR[k]++; + if (indirect) + APLANAR[k]++; } } } @@ -3662,9 +3812,12 @@ static void PlanarToDirect (struct RenderInfo *ri, struct BitMap *bm, for (i = 0; i < Depth; i++) { if (PLANAR[i] != &all_zeros_bitmap && PLANAR[i] != &all_ones_bitmap) { PLANAR[i] += eol_offset; + if (indirect) + APLANAR[i] += eol_offset; } } } + xfree(planebuf); } /* @@ -3696,17 +3849,17 @@ static void PlanarToDirect (struct RenderInfo *ri, struct BitMap *bm, */ static uae_u32 REGPARAM2 picasso_BlitPlanar2Direct (TrapContext *ctx) { - uaecptr bm = m68k_areg (regs, 1); - uaecptr ri = m68k_areg (regs, 2); - uaecptr cim = m68k_areg (regs, 3); - unsigned long srcx = (uae_u16)m68k_dreg (regs, 0); - unsigned long srcy = (uae_u16)m68k_dreg (regs, 1); - unsigned long dstx = (uae_u16)m68k_dreg (regs, 2); - unsigned long dsty = (uae_u16)m68k_dreg (regs, 3); - unsigned long width = (uae_u16)m68k_dreg (regs, 4); - unsigned long height = (uae_u16)m68k_dreg (regs, 5); - uae_u8 minterm = m68k_dreg (regs, 6); - uae_u8 Mask = m68k_dreg (regs, 7); + uaecptr bm = trap_get_areg(ctx, 1); + uaecptr ri = trap_get_areg(ctx, 2); + uaecptr cim = trap_get_areg(ctx, 3); + unsigned long srcx = (uae_u16)trap_get_dreg(ctx, 0); + unsigned long srcy = (uae_u16)trap_get_dreg(ctx, 1); + unsigned long dstx = (uae_u16)trap_get_dreg(ctx, 2); + unsigned long dsty = (uae_u16)trap_get_dreg(ctx, 3); + unsigned long width = (uae_u16)trap_get_dreg(ctx, 4); + unsigned long height = (uae_u16)trap_get_dreg(ctx, 5); + uae_u8 minterm = trap_get_dreg(ctx, 6); + uae_u8 Mask = trap_get_dreg(ctx, 7); struct RenderInfo local_ri; struct BitMap local_bm; struct ColorIndexMapping local_cim; @@ -3719,12 +3872,12 @@ static uae_u32 REGPARAM2 picasso_BlitPlanar2Direct (TrapContext *ctx) write_log (_T("WARNING - BlitPlanar2Direct() has unhandled op-code 0x%x. Using fall-back routine.\n"), minterm); return 0; } - if (CopyRenderInfoStructureA2U (ri, &local_ri) && CopyBitMapStructureA2U (bm, &local_bm)) { + if (CopyRenderInfoStructureA2U(ctx, ri, &local_ri) && CopyBitMapStructureA2U(ctx, bm, &local_bm)) { Mask = 0xFF; - CopyColorIndexMappingA2U (cim, &local_cim, GetBytesPerPixel (local_ri.RGBFormat)); + CopyColorIndexMappingA2U(ctx, cim, &local_cim, GetBytesPerPixel (local_ri.RGBFormat)); P96TRACE((_T("BlitPlanar2Direct(%d, %d, %d, %d, %d, %d) Minterm 0x%x, Mask 0x%x, Depth %d\n"), srcx, srcy, dstx, dsty, width, height, minterm, Mask, local_bm.Depth)); - PlanarToDirect (&local_ri, &local_bm, srcx, srcy, dstx, dsty, width, height, Mask, &local_cim); + PlanarToDirect(ctx, &local_ri, &local_bm, srcx, srcy, dstx, dsty, width, height, Mask, &local_cim); result = 1; } return result; @@ -4313,18 +4466,18 @@ void InitPicasso96 (void) static uae_u32 REGPARAM2 picasso_SetInterrupt (TrapContext *ctx) { - uaecptr bi = m68k_areg (regs, 0); - uae_u32 onoff = m68k_dreg (regs, 0); + uaecptr bi = trap_get_areg(ctx, 0); + uae_u32 onoff = trap_get_dreg(ctx, 0); interrupt_enabled = onoff; //write_log (_T("Picasso_SetInterrupt(%08x,%d)\n"), bi, onoff); return onoff; } static uaecptr uaegfx_vblankname, uaegfx_portsname; -static void initvblankABI (uaecptr base, uaecptr ABI) +static void initvblankABI (TrapContext *ctx, uaecptr base, uaecptr ABI) { for (int i = 0; i < 22; i++) - put_byte (ABI + PSSO_BoardInfo_HardInterrupt + i, get_byte (base + CARD_PORTSIRQ + i)); + trap_put_byte(ctx, ABI + PSSO_BoardInfo_HardInterrupt + i, trap_get_byte(ctx, base + CARD_PORTSIRQ + i)); ABI_interrupt = ABI; } static void initvblankirq (TrapContext *ctx, uaecptr base) @@ -4333,51 +4486,61 @@ static void initvblankirq (TrapContext *ctx, uaecptr base) uaecptr p2 = base + CARD_PORTSIRQ; uaecptr c = base + CARD_IRQCODE; - put_word (p1 + 8, 0x0205); - put_long (p1 + 10, uaegfx_vblankname); - put_long (p1 + 14, base + CARD_IRQFLAG); - put_long (p1 + 18, c); - - put_word (p2 + 8, 0x0205); - put_long (p2 + 10, uaegfx_portsname); - put_long (p2 + 14, base + CARD_IRQFLAG); - put_long (p2 + 18, c); - - put_word (c, 0x4a11); c += 2; // tst.b (a1) CARD_IRQFLAG - put_word (c, 0x670e); c += 2; // beq.s label - put_word (c, 0x4211); c += 2; // clr.b (a1) - put_long (c, 0x2c690008); c += 4; // move.l 8(a1),a6 CARD_IRQEXECBASE - put_long (c, 0x22690004); c += 4; // move.l 4(a1),a1 CARD_IRQPTR - put_long (c, 0x4eaeff4c); c += 4; // jsr Cause(a6) - put_word (c, 0x7000); c += 2; // label: moveq #0,d0 - put_word (c, RTS); // rts - - m68k_areg (regs, 1) = p1; - m68k_dreg (regs, 0) = 5; /* VERTB */ - CallLib (ctx, get_long (4), -168); /* AddIntServer */ - m68k_areg (regs, 1) = p2; - m68k_dreg (regs, 0) = 3; /* PORTS */ - CallLib (ctx, get_long (4), -168); /* AddIntServer */ + trap_put_word(ctx, p1 + 8, 0x0205); + trap_put_long(ctx, p1 + 10, uaegfx_vblankname); + trap_put_long(ctx, p1 + 14, base + CARD_IRQFLAG); + trap_put_long(ctx, p1 + 18, c); + + trap_put_word(ctx, p2 + 8, 0x0205); + trap_put_long(ctx, p2 + 10, uaegfx_portsname); + trap_put_long(ctx, p2 + 14, base + CARD_IRQFLAG); + trap_put_long(ctx, p2 + 18, c); + + trap_put_word(ctx, c, 0x4a11); c += 2; // tst.b (a1) CARD_IRQFLAG + trap_put_word(ctx, c, 0x670e); c += 2; // beq.s label + trap_put_word(ctx, c, 0x4211); c += 2; // clr.b (a1) + trap_put_long(ctx, c, 0x2c690008); c += 4; // move.l 8(a1),a6 CARD_IRQEXECBASE + trap_put_long(ctx, c, 0x22690004); c += 4; // move.l 4(a1),a1 CARD_IRQPTR + trap_put_long(ctx, c, 0x4eaeff4c); c += 4; // jsr Cause(a6) + trap_put_word(ctx, c, 0x7000); c += 2; // label: moveq #0,d0 + trap_put_word(ctx, c, RTS); // rts + +#if NEWTRAP + trap_call_add_areg(ctx, 1, p1); + trap_call_add_dreg(ctx, 0, 5); + trap_call_lib(ctx, trap_get_long(ctx, 4), -168); /* AddIntServer */ + + trap_call_add_areg(ctx, 1, p2); + trap_call_add_dreg(ctx, 0, 3); + trap_call_lib(ctx, trap_get_long(ctx, 4), -168); /* AddIntServer */ +#else + trap_set_areg(ctx, 1, p1); + trap_set_dreg(ctx, 0, 5); /* VERTB */ + CallLib (ctx, trap_get_long(ctx, 4), -168); /* AddIntServer */ + trap_set_areg(ctx, 1, p2); + trap_set_dreg(ctx, 0, 3); /* PORTS */ + CallLib (ctx, trap_get_long(ctx, 4), -168); /* AddIntServer */ +#endif } static uae_u32 REGPARAM2 picasso_SetClock(TrapContext *ctx) { - uaecptr bi = m68k_areg (regs, 0); + uaecptr bi = trap_get_areg(ctx, 0); P96TRACE((_T("SetClock\n"))); return 0; } static uae_u32 REGPARAM2 picasso_SetMemoryMode(TrapContext *ctx) { - uaecptr bi = m68k_areg (regs, 0); - uae_u32 rgbformat = m68k_dreg (regs, 7); + uaecptr bi = trap_get_areg(ctx, 0); + uae_u32 rgbformat = trap_get_dreg(ctx, 7); P96TRACE((_T("SetMemoryMode\n"))); return 0; } #define PUTABI(func) \ if (ABI) \ - put_long (ABI + func, here ()); + trap_put_long(ctx, ABI + func, here ()); #define RTGCALL(func,funcdef,call) \ PUTABI (func); \ @@ -4401,11 +4564,17 @@ static uae_u32 REGPARAM2 picasso_SetMemoryMode(TrapContext *ctx) dw (funcdef); \ dw (RTS); +#define RTGCALLONLYDEFAULT(func,funcdef,unused) \ + PUTABI (func); \ + dw (0x2f28); \ + dw (funcdef); \ + dw (RTS); + #define RTGNONE(func) \ if (ABI) \ - put_long (ABI + func, start); + trap_put_long(ctx, ABI + func, start); -static void inituaegfxfuncs (uaecptr start, uaecptr ABI) +static void inituaegfxfuncs(TrapContext *ctx, uaecptr start, uaecptr ABI) { if (uaegfx_old) return; @@ -4456,25 +4625,30 @@ static void inituaegfxfuncs (uaecptr start, uaecptr ABI) /* CalculateBytesPerRow (optimized) */ PUTABI (PSSO_BoardInfo_CalculateBytesPerRow); - dl (0x0c400140); // cmp.w #320,d0 - dw (0x6504); // bcs.s .l1 + dl(0x0c400140); // cmp.w #320,d0 + uaecptr addr = here(); + dw(0); calltrap (deftrap (picasso_CalculateBytesPerRow)); - dw (RTS); - dw (0x0c87); dl (0x00000010); // l1: cmp.l #$10,d7 - dw (0x640a); // bcc.s .l2 - dw (0x7200); // moveq #0,d1 - dl (0x123b7010); // move.b table(pc,d7.w),d1 - dw (0x6b04); // bmi.s l3 - dw (0xe368); // lsl.w d1,d0 - dw (RTS); // .l2 - dw (0x3200); // .l3 move.w d0,d1 - dw (0xd041); // add.w d1,d0 - dw (0xd041); // add.w d1,d0 - dw (RTS); - dl (0x0000ffff); // table - dl (0x01010202); - dl (0x02020101); - dl (0x01010100); + uaecptr addr2 = here(); + org(addr); + dw(0x6500 | (addr2 - addr)); // bcs.s .l1 + org(addr2); + dw(RTS); + dw(0x0c87); dl (0x00000010); // l1: cmp.l #$10,d7 + dw(0x640a); // bcc.s .l2 + dw(0x7200); // moveq #0,d1 + dl(0x123b7010); // move.b table(pc,d7.w),d1 + dw(0x6b04); // bmi.s l3 + dw(0xe368); // lsl.w d1,d0 + dw(RTS); // .l2 + dw(0x3200); // .l3 move.w d0,d1 + dw(0xd041); // add.w d1,d0 + dw(0xd041); // add.w d1,d0 + dw(RTS); + dl(0x0000ffff); // table + dl(0x01010202); + dl(0x02020101); + dl(0x01010100); //RTGCALL2(PSSO_BoardInfo_SetClock, picasso_SetClock); //RTGCALL2(PSSO_BoardInfo_SetMemoryMode, picasso_SetMemoryMode); @@ -4533,6 +4707,35 @@ static void inituaegfxfuncs (uaecptr start, uaecptr ABI) RTGCALLDEFAULT(PSSO_BoardInfo_, PSSO_BoardInfo_Default); #endif +#if 0 + + RTGCALLONLYDEFAULT(PSSO_BoardInfo_BlitPlanar2Direct, PSSO_BoardInfo_BlitPlanar2DirectDefault, picasso_BlitPlanar2Direct); + RTGCALLONLYDEFAULT(PSSO_BoardInfo_FillRect, PSSO_BoardInfo_FillRectDefault, picasso_FillRect); + RTGCALLONLYDEFAULT(PSSO_BoardInfo_BlitRect, PSSO_BoardInfo_BlitRectDefault, picasso_BlitRect); + RTGCALLONLYDEFAULT(PSSO_BoardInfo_BlitPlanar2Chunky, PSSO_BoardInfo_BlitPlanar2ChunkyDefault, picasso_BlitPlanar2Chunky); + RTGCALLONLYDEFAULT(PSSO_BoardInfo_BlitTemplate, PSSO_BoardInfo_BlitTemplateDefault, picasso_BlitTemplate); + RTGCALLONLYDEFAULT(PSSO_BoardInfo_InvertRect, PSSO_BoardInfo_InvertRectDefault, picasso_InvertRect); + RTGCALLONLYDEFAULT(PSSO_BoardInfo_BlitRectNoMaskComplete, PSSO_BoardInfo_BlitRectNoMaskCompleteDefault, picasso_BlitRectNoMaskComplete); + RTGCALL(PSSO_BoardInfo_BlitPattern, PSSO_BoardInfo_BlitPatternDefault, picasso_BlitPattern); + + RTGCALL2(PSSO_BoardInfo_SetSwitch, picasso_SetSwitch); + RTGCALL2(PSSO_BoardInfo_SetColorArray, picasso_SetColorArray); + RTGCALL2(PSSO_BoardInfo_SetDAC, picasso_SetDAC); + RTGCALL2(PSSO_BoardInfo_SetGC, picasso_SetGC); + RTGCALL2(PSSO_BoardInfo_SetPanning, picasso_SetPanning); + RTGCALL2(PSSO_BoardInfo_SetDisplay, picasso_SetDisplay); + + RTGCALL2(PSSO_BoardInfo_SetSprite, picasso_SetSprite); + RTGCALL2(PSSO_BoardInfo_SetSpritePosition, picasso_SetSpritePosition); + RTGCALL2(PSSO_BoardInfo_SetSpriteImage, picasso_SetSpriteImage); + RTGCALL2(PSSO_BoardInfo_SetSpriteColor, picasso_SetSpriteColor); + + RTGCALLDEFAULT(PSSO_BoardInfo_ScrollPlanar, PSSO_BoardInfo_ScrollPlanarDefault); + RTGCALLDEFAULT(PSSO_BoardInfo_UpdatePlanar, PSSO_BoardInfo_UpdatePlanarDefault); + RTGCALLDEFAULT(PSSO_BoardInfo_DrawLine, PSSO_BoardInfo_DrawLineDefault); + +#else + RTGCALL(PSSO_BoardInfo_BlitPlanar2Direct, PSSO_BoardInfo_BlitPlanar2DirectDefault, picasso_BlitPlanar2Direct); RTGCALL(PSSO_BoardInfo_FillRect, PSSO_BoardInfo_FillRectDefault, picasso_FillRect); RTGCALL(PSSO_BoardInfo_BlitRect, PSSO_BoardInfo_BlitRectDefault, picasso_BlitRect); @@ -4558,13 +4761,15 @@ static void inituaegfxfuncs (uaecptr start, uaecptr ABI) RTGCALLDEFAULT(PSSO_BoardInfo_UpdatePlanar, PSSO_BoardInfo_UpdatePlanarDefault); RTGCALLDEFAULT(PSSO_BoardInfo_DrawLine, PSSO_BoardInfo_DrawLineDefault); +#endif + if (currprefs.rtg_hardwareinterrupt) RTGCALL2(PSSO_BoardInfo_SetInterrupt, picasso_SetInterrupt); write_log (_T("uaegfx.card magic code: %08X-%08X ABI=%08X\n"), start, here (), ABI); if (ABI && currprefs.rtg_hardwareinterrupt) - initvblankABI (uaegfx_base, ABI); + initvblankABI(ctx, uaegfx_base, ABI); } void picasso_reset (void) @@ -4584,23 +4789,23 @@ void uaegfx_install_code (uaecptr start) { uaegfx_rom = start; org (start); - inituaegfxfuncs (start, 0); + inituaegfxfuncs(NULL, start, 0); } #define UAEGFX_VERSION 3 #define UAEGFX_REVISION 3 -static uae_u32 REGPARAM2 gfx_open (TrapContext *context) +static uae_u32 REGPARAM2 gfx_open(TrapContext *ctx) { - put_word (uaegfx_base + 32, get_word (uaegfx_base + 32) + 1); + trap_put_word(ctx, uaegfx_base + 32, trap_get_word(ctx, uaegfx_base + 32) + 1); return uaegfx_base; } -static uae_u32 REGPARAM2 gfx_close (TrapContext *context) +static uae_u32 REGPARAM2 gfx_close(TrapContext *ctx) { - put_word (uaegfx_base + 32, get_word (uaegfx_base + 32) - 1); + trap_put_word(ctx, uaegfx_base + 32, trap_get_word(ctx, uaegfx_base + 32) - 1); return 0; } -static uae_u32 REGPARAM2 gfx_expunge (TrapContext *context) +static uae_u32 REGPARAM2 gfx_expunge(TrapContext *ctx) { return 0; } @@ -4610,7 +4815,7 @@ static uaecptr uaegfx_card_install (TrapContext *ctx, uae_u32 extrasize) uae_u32 functable, datatable, a2; uaecptr openfunc, closefunc, expungefunc; uaecptr findcardfunc, initcardfunc; - uaecptr exec = get_long (4); + uaecptr exec = trap_get_long(ctx, 4); if (uaegfx_old || !gfxmem_bank.start) return 0; @@ -4650,29 +4855,55 @@ static uaecptr uaegfx_card_install (TrapContext *ctx, uae_u32 extrasize) datatable = makedatatable (uaegfx_resid, uaegfx_resname, 0x09, -50, UAEGFX_VERSION, UAEGFX_REVISION); - a2 = m68k_areg (regs, 2); - m68k_areg (regs, 0) = functable; - m68k_areg (regs, 1) = datatable; - m68k_areg (regs, 2) = 0; - m68k_dreg (regs, 0) = CARD_SIZEOF + extrasize; - m68k_dreg (regs, 1) = 0; - uaegfx_base = CallLib (ctx, exec, -0x54); /* MakeLibrary */ - m68k_areg (regs, 2) = a2; + a2 = trap_get_areg(ctx, 2); + +#if NEWTRAP + trap_call_add_areg(ctx, 0, functable); + trap_call_add_areg(ctx, 1, datatable); + trap_call_add_areg(ctx, 2, 0); + trap_call_add_dreg(ctx, 0, CARD_SIZEOF + extrasize); + trap_call_add_dreg(ctx, 1, 0); + uaegfx_base = trap_call_lib(ctx, exec, -0x54); /* MakeLibrary */ +#else + trap_set_areg(ctx, 0, functable); + trap_set_areg(ctx, 1, datatable); + trap_set_areg(ctx, 2, 0); + trap_set_dreg(ctx, 0, CARD_SIZEOF + extrasize); + trap_set_dreg(ctx, 1, 0); + uaegfx_base = CallLib(ctx, exec, -0x54); /* MakeLibrary */ +#endif + + trap_set_areg(ctx, 2, a2); if (!uaegfx_base) return 0; - m68k_areg (regs, 1) = uaegfx_base; + +#if NEWTRAP + trap_call_add_areg(ctx, 1, uaegfx_base); + trap_call_lib(ctx, exec, -0x18c); /* AddLibrary */ +#else + trap_set_areg(ctx, 1, uaegfx_base); CallLib (ctx, exec, -0x18c); /* AddLibrary */ - m68k_areg (regs, 1) = EXPANSION_explibname; - m68k_dreg (regs, 0) = 0; - put_long (uaegfx_base + CARD_EXPANSIONBASE, CallLib (ctx, exec, -0x228)); /* OpenLibrary */ - put_long (uaegfx_base + CARD_EXECBASE, exec); - put_long (uaegfx_base + CARD_IRQEXECBASE, exec); - put_long (uaegfx_base + CARD_NAME, uaegfx_resname); - put_long (uaegfx_base + CARD_RESLIST, uaegfx_base + CARD_SIZEOF); - put_long (uaegfx_base + CARD_RESLISTSIZE, extrasize); +#endif + +#if NEWTRAP + trap_call_add_areg(ctx, 1, EXPANSION_explibname); + trap_call_add_dreg(ctx, 0, 0); + uae_u32 lib = trap_call_lib(ctx, exec, -0x228); /* OpenLibrary */ +#else + trap_set_areg(ctx, 1, EXPANSION_explibname); + trap_set_dreg(ctx, 0, 0); + uae_u32 lib = CallLib(ctx, exec, -0x228); /* OpenLibrary */ +#endif + + trap_put_long(ctx, uaegfx_base + CARD_EXPANSIONBASE, lib); /* OpenLibrary */ + trap_put_long(ctx, uaegfx_base + CARD_EXECBASE, exec); + trap_put_long(ctx, uaegfx_base + CARD_IRQEXECBASE, exec); + trap_put_long(ctx, uaegfx_base + CARD_NAME, uaegfx_resname); + trap_put_long(ctx, uaegfx_base + CARD_RESLIST, uaegfx_base + CARD_SIZEOF); + trap_put_long(ctx, uaegfx_base + CARD_RESLISTSIZE, extrasize); if (currprefs.rtg_hardwareinterrupt) - initvblankirq (ctx, uaegfx_base); + initvblankirq(ctx, uaegfx_base); write_log (_T("uaegfx.card %d.%d init @%08X\n"), UAEGFX_VERSION, UAEGFX_REVISION, uaegfx_base); uaegfx_active = 1; @@ -4681,7 +4912,7 @@ static uaecptr uaegfx_card_install (TrapContext *ctx, uae_u32 extrasize) uae_u32 picasso_demux (uae_u32 arg, TrapContext *ctx) { - uae_u32 num = get_long (m68k_areg (regs, 7) + 4); + uae_u32 num = trap_get_long(ctx, trap_get_areg(ctx, 7) + 4); if (uaegfx_base) { if (num >= 16 && num <= 39) { @@ -4728,7 +4959,7 @@ void restore_p96_finish (void) { init_alloc (NULL, 0); if (uaegfx_rom && boardinfo) - inituaegfxfuncs (uaegfx_rom, boardinfo); + inituaegfxfuncs(NULL, uaegfx_rom, boardinfo); #if 0 if (picasso_requested_on) { picasso_on = true; diff --git a/od-win32/picasso96_win.h b/od-win32/picasso96_win.h index 77bb0e5c..ea4c8ad6 100644 --- a/od-win32/picasso96_win.h +++ b/od-win32/picasso96_win.h @@ -131,6 +131,7 @@ struct BitMap uae_u8 Depth; uae_u16 pad; uae_u8 *Planes[8]; + uaecptr APlanes[8]; }; /************************************************************************/ @@ -229,6 +230,7 @@ struct RenderInfo { #define PSSO_Pattern_sizeof 18 struct Pattern { uae_u8 *Memory; + uaecptr AMemory; uae_u16 XOffset, YOffset; uae_u32 FgPen, BgPen; uae_u8 Size; /* Width: 16, Height: (1<= MAX_OPEN_DEVICES || pdevst[i].inuse == 0) { write_log (_T("%s: corrupt iorequest %08X %d\n"), SANA2NAME, request, i); return 0; @@ -263,16 +262,16 @@ static int start_thread (struct s2devstruct *dev) if (dev->thread_running) return 1; init_comm_pipe (&dev->requests, 100, 1); - uae_sem_init (&dev->sync_sem, 0, 0); + uae_sem_init(&dev->sync_sem, 0, 0); uae_start_thread (SANA2NAME, dev_thread, dev, NULL); uae_sem_wait (&dev->sync_sem); return dev->thread_running; } -static uae_u32 REGPARAM2 dev_close_2 (TrapContext *context) +static uae_u32 REGPARAM2 dev_close_2 (TrapContext *ctx) { - uae_u32 request = m68k_areg (regs, 1); - struct priv_s2devstruct *pdev = getps2devstruct (request); + uae_u32 request = trap_get_areg(ctx, 1); + struct priv_s2devstruct *pdev = getps2devstruct(ctx, request); struct s2devstruct *dev; if (!pdev) { @@ -286,79 +285,108 @@ static uae_u32 REGPARAM2 dev_close_2 (TrapContext *context) } if (log_net) write_log (_T("%s:%d close, open=%d req=%08X\n"), SANA2NAME, pdev->unit, dev->opencnt, request); - put_long (request + 24, 0); + trap_put_long(ctx, request + 24, 0); dev->opencnt--; pdev->inuse = 0; if (!dev->opencnt) { dev->exclusive = 0; if (pdev->tempbuf) { - m68k_areg (regs, 1) = pdev->tempbuf; - m68k_dreg (regs, 0) = pdev->td->mtu + ETH_HEADER_SIZE + 2; - CallLib (context, get_long (4), -0xD2); /* FreeMem */ + trap_call_add_areg(ctx, 1, pdev->tempbuf); + trap_call_add_dreg(ctx, 0, pdev->td->mtu + ETH_HEADER_SIZE + 2); + trap_call_lib(ctx, trap_get_long(ctx, 4), -0xD2); /* FreeMem */ pdev->tempbuf = 0; } ethernet_close (pdev->td, dev->sysdata); xfree (dev->sysdata); dev->sysdata = NULL; + uae_sem_wait(&pipe_sem); + write_comm_pipe_pvoid(&dev->requests, NULL, 0); + write_comm_pipe_pvoid(&dev->requests, NULL, 0); write_comm_pipe_u32 (&dev->requests, 0, 1); + uae_sem_post(&pipe_sem); write_log (_T("%s: opencnt == 0, all instances closed\n"), SANA2NAME); } - put_word (m68k_areg (regs, 6) + 32, get_word (m68k_areg (regs, 6) + 32) - 1); + trap_put_word(ctx, trap_get_areg(ctx, 6) + 32, trap_get_word(ctx, trap_get_areg(ctx, 6) + 32) - 1); return 0; } -static uae_u32 REGPARAM2 dev_close (TrapContext *context) +static uae_u32 REGPARAM2 dev_close (TrapContext *ctx) { - return dev_close_2 (context); + return dev_close_2(ctx); } -static uae_u32 REGPARAM2 diskdev_close (TrapContext *context) +static uae_u32 REGPARAM2 diskdev_close (TrapContext *ctx) { - return dev_close_2 (context); + return dev_close_2(ctx); } -static int openfail (uaecptr ioreq, int error) +static int openfail (TrapContext *ctx, uaecptr ioreq, int error) { - put_long (ioreq + 20, -1); - put_byte (ioreq + 31, error); - put_long (ioreq + 32, 0); /* io_device */ + trap_put_long(ctx, ioreq + 20, -1); + trap_put_byte(ctx, ioreq + 31, error); + trap_put_long(ctx, ioreq + 32, 0); /* io_device */ if (log_net) write_log (_T("-> failed with error %d\n"), error); return (uae_u32)-1; } +static uaecptr uaenet_worker; + +static void uaenet_int(void) +{ + if (uaenet_worker) + uae_Signal(uaenet_worker, 0x100); +} + static uae_u32 REGPARAM2 uaenet_int_handler (TrapContext *ctx); static int irq_init; static int initint (TrapContext *ctx) { - uae_u32 tmp1; + uae_u32 tmp1, tmp2; uaecptr p; if (irq_init) return 1; - m68k_dreg (regs, 0) = 26; - m68k_dreg (regs, 1) = 65536 + 1; - p = CallLib (ctx, get_long (4), -0xC6); /* AllocMem */ + + trap_call_add_dreg(ctx, 0, 92 + 4096); + trap_call_add_dreg(ctx, 1, 65536 + 1); + p = trap_call_lib(ctx, trap_get_long(ctx, 4), -0xC6); /* AllocMem */ if (!p) return 0; + + tmp1 = ds(_T("uaenet worker")); + trap_put_byte(ctx, p + 8, 1); // NT_TASK + trap_put_byte(ctx, p + 9, 20); // Priority + trap_put_long(ctx, p + 10, tmp1); // name + trap_put_long(ctx, p + 58, p + 92); // SPLower + trap_put_long(ctx, p + 62, p + 92 + 4096); // SPUpper + trap_put_long(ctx, p + 54, p + 92 + 4096); // SPReg + tmp1 = here (); + write_log(_T("uaenet worker: %08x\n"), tmp1); + dl(0x2c780004); // move.l 4.w,a6 + dw(0x203c); // move.l #$100,d0 + dl(0x00000100); + dl(0x4eaefec2); // jsr -$13e(a6) + tmp2 = here(); calltrap (deftrap2 (uaenet_int_handler, TRAPFLAG_EXTRA_STACK, _T("uaenet_int_handler"))); - put_word (p + 8, 0x020a); - put_long (p + 10, ROM_netdev_resid); - put_long (p + 18, tmp1); - m68k_areg (regs, 1) = p; - m68k_dreg (regs, 0) = 3; /* PORTS */ - dw (0x4a80); /* TST.L D0 */ - dw (0x4e75); /* RTS */ - CallLib (ctx, get_long (4), -168); /* AddIntServer */ + dw(0x4a80); // tst.l d0 + dw(0x6600 | (tmp2 - here() - 2) & 0xff); // bne.s tmp2 + dw(0x6000 | (tmp1 - here() - 2) & 0xff); // bra.s tmp1 + + trap_call_add_areg(ctx, 1, p); + trap_call_add_areg(ctx, 2, tmp1); + trap_call_add_areg(ctx, 3, 0); + uaenet_worker = trap_call_lib(ctx, trap_get_long(ctx, 4), -0x11a); // AddTask + irq_init = 1; return 1; } -static uae_u32 REGPARAM2 dev_open_2 (TrapContext *context) +static uae_u32 REGPARAM2 dev_open_2 (TrapContext *ctx) { - uaecptr ioreq = m68k_areg (regs, 1); - uae_u32 unit = m68k_dreg (regs, 0); - uae_u32 flags = m68k_dreg (regs, 1); + uaecptr ioreq = trap_get_areg(ctx, 1); + uae_u32 unit = trap_get_dreg(ctx, 0); + uae_u32 flags = trap_get_dreg(ctx, 1); uaecptr buffermgmt; struct s2devstruct *dev = gets2devstruct (unit); struct priv_s2devstruct *pdev = 0; @@ -366,15 +394,15 @@ static uae_u32 REGPARAM2 dev_open_2 (TrapContext *context) uaecptr tagp, tagpnext; if (!dev) - return openfail (ioreq, IOERR_OPENFAIL); - if (!initint(context)) - return openfail (ioreq, IOERR_SELFTEST); + return openfail(ctx, ioreq, IOERR_OPENFAIL); + if (!initint(ctx)) + return openfail(ctx, ioreq, IOERR_SELFTEST); if (log_net) write_log (_T("opening %s:%d opencnt=%d ioreq=%08X\n"), SANA2NAME, unit, dev->opencnt, ioreq); - if (get_word (ioreq + 0x12) < IOSTDREQ_SIZE) - return openfail (ioreq, IOERR_BADLENGTH); + if (trap_get_word(ctx, ioreq + 0x12) < IOSTDREQ_SIZE) + return openfail(ctx, ioreq, IOERR_BADLENGTH); if ((flags & SANA2OPF_PROM) && dev->opencnt > 0) - return openfail (ioreq, IOERR_UNITBUSY); + return openfail(ctx, ioreq, IOERR_UNITBUSY); for (i = 0; i < MAX_OPEN_DEVICES; i++) { pdev = &pdevst[i]; @@ -382,9 +410,9 @@ static uae_u32 REGPARAM2 dev_open_2 (TrapContext *context) break; } if (i == MAX_OPEN_DEVICES) - return openfail (ioreq, IOERR_UNITBUSY); + return openfail(ctx, ioreq, IOERR_UNITBUSY); - put_long (ioreq + 24, pdev - pdevst); + trap_put_long(ctx, ioreq + 24, pdev - pdevst); pdev->unit = unit; pdev->flags = flags; pdev->inuse = 1; @@ -392,7 +420,7 @@ static uae_u32 REGPARAM2 dev_open_2 (TrapContext *context) pdev->promiscuous = (flags & SANA2OPF_PROM) ? 1 : 0; if (pdev->td == NULL || pdev->td->active == 0) - return openfail (ioreq, IOERR_OPENFAIL); + return openfail(ctx, ioreq, IOERR_OPENFAIL); if (dev->opencnt == 0) { dev->unit = unit; @@ -400,7 +428,7 @@ static uae_u32 REGPARAM2 dev_open_2 (TrapContext *context) if (!ethernet_open (pdev->td, dev->sysdata, dev, uaenet_gotdata, uaenet_getdata, pdev->promiscuous)) { xfree (dev->sysdata); dev->sysdata = NULL; - return openfail (ioreq, IOERR_OPENFAIL); + return openfail(ctx, ioreq, IOERR_OPENFAIL); } write_log (_T("%s: initializing unit %d\n"), getdevname (), unit); dev->td = pdev->td; @@ -413,20 +441,19 @@ static uae_u32 REGPARAM2 dev_open_2 (TrapContext *context) } if (kickstart_version >= 36) { - m68k_areg (regs, 0) = get_long (4) + 350; - m68k_areg (regs, 1) = timerdevname; - CallLib (context, get_long (4), -0x114); /* FindName('timer.device') */ - pdev->timerbase = m68k_dreg (regs, 0); + trap_call_add_areg(ctx, 0, trap_get_long(ctx, 4) + 350); + trap_call_add_areg(ctx, 1, timerdevname); + pdev->timerbase = trap_call_lib(ctx, trap_get_long(ctx, 4), -0x114); /* FindName('timer.device') */ } pdev->copyfrombuff = pdev->copytobuff = pdev->packetfilter = 0; pdev->tempbuf = 0; - if (get_word (ioreq + 0x12) >= SANA2_IOREQSIZE) { - buffermgmt = get_long (ioreq + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES * 2 + 4 + 4 + 4); + if (trap_get_word(ctx, ioreq + 0x12) >= SANA2_IOREQSIZE) { + buffermgmt = trap_get_long(ctx, ioreq + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES * 2 + 4 + 4 + 4); tagpnext = buffermgmt; while (tagpnext) { - uae_u32 tag = get_long (tagpnext); - uae_u32 val = get_long (tagpnext + 4); + uae_u32 tag = trap_get_long(ctx, tagpnext); + uae_u32 val = trap_get_long(ctx, tagpnext + 4); tagp = tagpnext; tagpnext += 8; switch (tag) @@ -453,28 +480,29 @@ static uae_u32 REGPARAM2 dev_open_2 (TrapContext *context) break; } } - if (log_net) - write_log (_T("%s:%d CTB=%08x CFB=%08x PF=%08x\n"), - getdevname(), unit, pdev->copytobuff, pdev->copyfrombuff, pdev->packetfilter); - m68k_dreg (regs, 0) = dev->td->mtu + ETH_HEADER_SIZE + 2; - m68k_dreg (regs, 1) = 1; - pdev->tempbuf = CallLib (context, get_long (4), -0xC6); /* AllocMem */ + trap_call_add_dreg(ctx, 0, dev->td->mtu + ETH_HEADER_SIZE + 2); + trap_call_add_dreg(ctx, 1, 65536 + 1); + pdev->tempbuf = trap_call_lib(ctx, trap_get_long(ctx, 4), -0xC6); /* AllocMem */ + if (log_net) { + write_log(_T("%s:%d CTB=%08x CFB=%08x PF=%08x TEMP=%08x\n"), + getdevname(), unit, pdev->copytobuff, pdev->copyfrombuff, pdev->packetfilter, pdev->tempbuf); + } if (!pdev->tempbuf) { if (dev->opencnt == 0) { ethernet_close (pdev->td, dev->sysdata); xfree (dev->sysdata); dev->sysdata = NULL; } - return openfail (ioreq, S2ERR_BAD_ARGUMENT); + return openfail(ctx, ioreq, S2ERR_BAD_ARGUMENT); } /* buffermanagement */ - put_long (ioreq + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES * 2 + 4 + 4 + 4, pdev->tempbuf); + trap_put_long(ctx, ioreq + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES * 2 + 4 + 4 + 4, pdev->tempbuf); } dev->exclusive = flags & SANA2OPF_MINE; dev->opencnt++; - put_word (m68k_areg (regs, 6) + 32, get_word (m68k_areg (regs, 6) + 32) + 1); - put_byte (ioreq + 31, 0); - put_byte (ioreq + 8, 7); + trap_put_word(ctx, trap_get_areg(ctx, 6) + 32, trap_get_word(ctx, trap_get_areg(ctx, 6) + 32) + 1); + trap_put_byte(ctx, ioreq + 31, 0); + trap_put_byte(ctx, ioreq + 8, 7); return 0; } @@ -497,7 +525,7 @@ static void freepacket (struct s2packet *s2p) xfree (s2p); } -static void add_async_packet (struct s2devstruct *dev, struct s2packet *s2p, uaecptr request) +static void add_async_packet (struct s2devstruct *dev, struct s2packet *s2p, uae_u8 *request, uaecptr arequest) { struct asyncreq *ar, *ar2; @@ -511,10 +539,11 @@ static void add_async_packet (struct s2devstruct *dev, struct s2packet *s2p, uae ar2 = ar2->next; ar2->next = ar; } + ar->arequest = arequest; ar->request = request; } -static void rem_async_packet (struct s2devstruct *dev, uaecptr request) +static void rem_async_packet (struct s2devstruct *dev, uaecptr arequest) { struct asyncreq *ar, *prevar; @@ -522,14 +551,15 @@ static void rem_async_packet (struct s2devstruct *dev, uaecptr request) ar = dev->s2p; prevar = NULL; while (ar) { - if (ar->request == request) { + if (ar->arequest == arequest) { if (prevar == NULL) dev->s2p = ar->next; else prevar->next = ar->next; uae_sem_post (&async_sem); freepacket (ar->s2p); - xfree (ar); + xfree(ar->request); + xfree(ar); return; } prevar = ar; @@ -538,7 +568,7 @@ static void rem_async_packet (struct s2devstruct *dev, uaecptr request) uae_sem_post (&async_sem); } -static struct asyncreq *get_async_request (struct s2devstruct *dev, uaecptr request, int ready) +static struct asyncreq *get_async_request (struct s2devstruct *dev, uaecptr arequest, int ready) { struct asyncreq *ar; int ret = 0; @@ -546,7 +576,7 @@ static struct asyncreq *get_async_request (struct s2devstruct *dev, uaecptr requ uae_sem_wait (&async_sem); ar = dev->ar; while (ar) { - if (ar->request == request) { + if (ar->arequest == arequest) { if (ready) ar->ready = 1; break; @@ -557,15 +587,16 @@ static struct asyncreq *get_async_request (struct s2devstruct *dev, uaecptr requ return ar; } -static int add_async_request (struct s2devstruct *dev, uaecptr request) +static int add_async_request (struct s2devstruct *dev, uae_u8 *request, uaecptr arequest) { struct asyncreq *ar, *ar2; if (log_net) - write_log (_T("%s:%d async request %x added\n"), getdevname(), dev->unit, request); + write_log (_T("%s:%d async request %x added\n"), getdevname(), dev->unit, arequest); uae_sem_wait (&async_sem); ar = xcalloc (struct asyncreq, 1); + ar->arequest = arequest; ar->request = request; if (!dev->ar) { dev->ar = ar; @@ -579,7 +610,7 @@ static int add_async_request (struct s2devstruct *dev, uaecptr request) return 1; } -static int release_async_request (struct s2devstruct *dev, uaecptr request) +static int release_async_request (struct s2devstruct *dev, uaecptr arequest) { struct asyncreq *ar, *prevar; @@ -587,81 +618,90 @@ static int release_async_request (struct s2devstruct *dev, uaecptr request) ar = dev->ar; prevar = NULL; while (ar) { - if (ar->request == request) { + if (ar->arequest == arequest) { if (prevar == NULL) dev->ar = ar->next; else prevar->next = ar->next; uae_sem_post (&async_sem); - xfree (ar); + xfree(ar); if (log_net) - write_log (_T("%s:%d async request %x removed\n"), getdevname(), dev->unit, request); + write_log (_T("%s:%d async request %x removed\n"), getdevname(), dev->unit, arequest); return 1; } prevar = ar; ar = ar->next; } uae_sem_post (&async_sem); - write_log (_T("%s:%d async request %x not found for removal!\n"), getdevname(), dev->unit, request); + write_log (_T("%s:%d async request %x not found for removal!\n"), getdevname(), dev->unit, arequest); return 0; } -static void do_abort_async (struct s2devstruct *dev, uaecptr request) +static void do_abort_async (TrapContext *ctx, struct s2devstruct *dev, uae_u8 *request, uaecptr arequest) { - put_byte (request + 30, get_byte (request + 30) | 0x20); - put_byte (request + 31, IOERR_ABORTED); - put_long (request + 32, S2WERR_GENERIC_ERROR); - write_comm_pipe_u32 (&dev->requests, request, 1); + put_byte_host(request + 30, get_byte_host(request + 30) | 0x20); + put_byte_host(request + 31, IOERR_ABORTED); + put_long_host(request + 32, S2WERR_GENERIC_ERROR); + uae_sem_wait(&pipe_sem); + trap_set_background(ctx); + write_comm_pipe_pvoid(&dev->requests, ctx, 0); + write_comm_pipe_pvoid(&dev->requests, request, 0); + write_comm_pipe_u32(&dev->requests, arequest, 1); + uae_sem_post(&pipe_sem); } -static void abort_async (struct s2devstruct *dev, uaecptr request) +static void abort_async(TrapContext *ctx, struct s2devstruct *dev, uaecptr arequest) { - struct asyncreq *ar = get_async_request (dev, request, 1); + struct asyncreq *ar = get_async_request (dev, arequest, 1); if (!ar) { - write_log (_T("%s:%d: abort async but no request %x found!\n"), getdevname(), dev->unit, request); + write_log (_T("%s:%d: abort async but no request %x found!\n"), getdevname(), dev->unit, arequest); return; } if (log_net) - write_log (_T("%s:%d asyncronous request=%08X aborted\n"), getdevname(), dev->unit, request); - do_abort_async (dev, request); + write_log (_T("%s:%d asyncronous request=%08X aborted\n"), getdevname(), dev->unit, arequest); + do_abort_async(ctx, dev, ar->request, arequest); } -static void signalasync (struct s2devstruct *dev, struct asyncreq *ar, int actual, int err) +static void signalasync(TrapContext *ctx, struct s2devstruct *dev, struct asyncreq *ar, int actual, int err) { - uaecptr request = ar->request; - int command = get_word (request + 28); + uaecptr arequest = ar->arequest; + uae_u8 *request = ar->request; + int command = get_word_host(request + 28); if (log_net) - write_log (_T("%s:%d CMD=%d async request %x completed\n"), getdevname(), dev->unit, command, request); - put_long (request + 32, actual); - put_byte (request + 31, err); + write_log (_T("%s:%d CMD=%d async request %x completed\n"), getdevname(), dev->unit, command, arequest); + put_long_host(request + 32, actual); + put_byte_host(request + 31, err); ar->ready = 1; - write_comm_pipe_u32 (&dev->requests, request, 1); + uae_sem_wait(&pipe_sem); + trap_set_background(ctx); + write_comm_pipe_pvoid(&dev->requests, ctx, 0); + write_comm_pipe_pvoid(&dev->requests, request, 0); + write_comm_pipe_u32(&dev->requests, arequest, 1); + uae_sem_post(&pipe_sem); } static uae_u32 copytobuff (TrapContext *ctx, uaecptr from, uaecptr to, uae_u32 len, uaecptr func) { - m68k_areg (regs, 0) = to; - m68k_areg (regs, 1) = from; - m68k_dreg (regs, 0) = len; - return CallFunc (ctx, func); + trap_call_add_areg(ctx, 0, to); + trap_call_add_areg(ctx, 1, from); + trap_call_add_dreg(ctx, 0, len); + return trap_call_func(ctx, func); } static uae_u32 copyfrombuff (TrapContext *ctx, uaecptr from, uaecptr to, uae_u32 len, uaecptr func) { - m68k_areg (regs, 0) = to; - m68k_areg (regs, 1) = from; - m68k_dreg (regs, 0) = len; - return CallFunc (ctx, func); + trap_call_add_areg(ctx, 0, to); + trap_call_add_areg(ctx, 1, from); + trap_call_add_dreg(ctx, 0, len); + return trap_call_func(ctx, func); } static uae_u32 packetfilter (TrapContext *ctx, uaecptr hook, uaecptr ios2, uaecptr data) { - uae_u32 a2, v; - - a2 = m68k_areg (regs, 2); - m68k_areg (regs, 0) = hook; - m68k_areg (regs, 2) = ios2; - m68k_areg (regs, 1) = data; - v = CallFunc (ctx, get_long (hook + 8)); - m68k_areg (regs, 2) = a2; + uae_u32 v; + + trap_call_add_areg(ctx, 0, hook); + trap_call_add_areg(ctx, 2, ios2); + trap_call_add_areg(ctx, 1, data); + v = trap_call_func(ctx, trap_get_long(ctx, hook + 8)); return v; } @@ -691,13 +731,13 @@ static uae_u64 addrto64 (const uae_u8 *d) } return addr; } -static uae_u64 amigaaddrto64 (uaecptr d) +static uae_u64 amigaaddrto64(uae_u8 *d) { int i; uae_u64 addr = 0; for (i = 0; i < ADDR_SIZE; i++) { addr <<= 8; - addr |= get_byte (d + i); + addr |= get_byte_host(d + i); } return addr; } @@ -759,48 +799,50 @@ static struct s2packet *createreadpacket (struct s2devstruct *dev, const uae_u8 { struct s2packet *s2p = xcalloc (struct s2packet, 1); s2p->data = xmalloc (uae_u8, dev->td->mtu + ETH_HEADER_SIZE + 2); - memcpy (s2p->data, d, len); + memcpy(s2p->data, d, len); s2p->len = len; return s2p; } -static int handleread (TrapContext *ctx, struct priv_s2devstruct *pdev, uaecptr request, uae_u8 *d, int len, int cmd) +static int handleread (TrapContext *ctx, struct priv_s2devstruct *pdev, uae_u8 *request, uaecptr arequest, uae_u8 *d, int len, int cmd) { - uae_u8 flags = get_byte (request + 30); - uaecptr data = get_long (request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES * 2 + 4); - uaecptr srcaddr = request + 32 + 4 + 4; - uaecptr dstaddr = request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES; + uae_u8 flags = get_byte_host(request + 30); + uaecptr data = get_long_host(request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES * 2 + 4); + uae_u8 *srcaddr = request + 32 + 4 + 4; + uae_u8 *dstaddr = request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES; uae_u16 type = (d[2 * ADDR_SIZE] << 8) | d[2 * ADDR_SIZE + 1]; uae_u32 v = 0; uaecptr data2; - memcpyha_safe (pdev->tempbuf, d, len); - memcpyha_safe (dstaddr, d, ADDR_SIZE); - memcpyha_safe (srcaddr, d + ADDR_SIZE, ADDR_SIZE); - put_long (request + 32 + 4, type); + trap_put_bytes(ctx, d, pdev->tempbuf, len); + memcpy(dstaddr, d, ADDR_SIZE); + memcpy(srcaddr, d + ADDR_SIZE, ADDR_SIZE); + + put_long_host(request + 32 + 4, type); if (pdev->tracks[type]) { pdev->bytesreceived += len; pdev->packetsreceived++; } + flags &= ~(SANA2IOF_BCAST | SANA2IOF_MCAST); if (isbroadcast (d)) flags |= SANA2IOF_BCAST; else if (ismulticast (d)) flags |= SANA2IOF_MCAST; - put_byte (request + 30, flags); + put_byte_host(request + 30, flags); data2 = pdev->tempbuf; if (!(flags & SANA2IOF_RAW)) { len -= ETH_HEADER_SIZE; data2 += ETH_HEADER_SIZE; } - put_long (request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES * 2, len); + put_long_host(request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES * 2, len); - if (pdev->packetfilter && cmd == CMD_READ && packetfilter (ctx, pdev->packetfilter, request, data2) == 0) + if (pdev->packetfilter && cmd == CMD_READ && packetfilter (ctx, pdev->packetfilter, arequest, data2) == 0) return 0; if (!copytobuff (ctx, data2, data, len, pdev->copytobuff)) { - put_long (request + 32, S2WERR_BUFF_ERROR); - put_byte (request + 31, S2ERR_NO_RESOURCES); + put_long_host(request + 32, S2WERR_BUFF_ERROR); + put_byte_host(request + 31, S2ERR_NO_RESOURCES); } return 1; } @@ -853,19 +895,19 @@ static void uaenet_gotdata (void *devv, const uae_u8 *d, int len) s2p2 = s2p2->next; s2p2->next = s2p; } - uaenet_int_requested = 1; + uaenet_int(); uae_sem_post (&async_sem); } -static struct s2packet *createwritepacket (TrapContext *ctx, uaecptr request) +static struct s2packet *createwritepacket(TrapContext *ctx, uae_u8 *request, uaecptr arequest) { - uae_u8 flags = get_byte (request + 30); - uae_u32 datalength = get_long (request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES * 2); - uaecptr data = get_long (request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES * 2 + 4); - uaecptr srcaddr = request + 32 + 4 + 4; - uaecptr dstaddr = request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES; - uae_u16 packettype = get_long (request + 32 + 4); - struct priv_s2devstruct *pdev = getps2devstruct (request); + struct priv_s2devstruct *pdev = getps2devstruct(ctx, arequest); + uae_u8 flags = get_byte_host(request + 30); + uae_u32 datalength = get_long_host(request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES * 2); + uaecptr data = get_long_host(request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES * 2 + 4); + uae_u8 *srcaddr = request + 32 + 4 + 4; + uae_u8 *dstaddr = request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES; + uae_u16 packettype = get_long_host(request + 32 + 4); struct s2packet *s2p; if (!pdev) @@ -875,15 +917,15 @@ static struct s2packet *createwritepacket (TrapContext *ctx, uaecptr request) s2p = xcalloc (struct s2packet, 1); s2p->data = xmalloc (uae_u8, pdev->td->mtu + ETH_HEADER_SIZE + 2); if (flags & SANA2IOF_RAW) { - memcpyah_safe (s2p->data, pdev->tempbuf, datalength); + trap_get_bytes(ctx, s2p->data, pdev->tempbuf, datalength); packettype = (s2p->data[2 * ADDR_SIZE + 0] << 8) | (s2p->data[2 * ADDR_SIZE + 1]); s2p->len = datalength; } else { - memcpyah_safe (s2p->data + ETH_HEADER_SIZE, pdev->tempbuf, datalength); - memcpy (s2p->data + ADDR_SIZE, pdev->td->mac, ADDR_SIZE); - memcpyah_safe (s2p->data, dstaddr, ADDR_SIZE); + trap_get_bytes(ctx, s2p->data + ETH_HEADER_SIZE, pdev->tempbuf, datalength); + memcpy(s2p->data + ADDR_SIZE, pdev->td->mac, ADDR_SIZE); + memcpy(s2p->data, dstaddr, ADDR_SIZE); s2p->data[2 * ADDR_SIZE + 0] = packettype >> 8; - s2p->data[2 * ADDR_SIZE + 1] = packettype; + s2p->data[2 * ADDR_SIZE + 1] = (uae_u8)packettype; s2p->len = datalength + ETH_HEADER_SIZE; } if (pdev->tracks[packettype]) { @@ -893,7 +935,7 @@ static struct s2packet *createwritepacket (TrapContext *ctx, uaecptr request) return s2p; } -static int uaenet_getdata (void *devv, uae_u8 *d, int *len) +static int uaenet_getdata(void *devv, uae_u8 *d, int *len) { int gotit; struct asyncreq *ar; @@ -904,16 +946,17 @@ static int uaenet_getdata (void *devv, uae_u8 *d, int *len) gotit = 0; while (ar && !gotit) { if (!ar->ready) { - uaecptr request = ar->request; - int command = get_word (request + 28); - uae_u32 packettype = get_long (request + 32 + 4); + uaecptr arequest = ar->arequest; + uae_u8 *request = ar->request; + int command = get_word_host(request + 28); + uae_u32 packettype = get_long_host(request + 32 + 4); if (command == CMD_WRITE || command == S2_BROADCAST || command == S2_MULTICAST) { - struct priv_s2devstruct *pdev = getps2devstruct (request); + struct priv_s2devstruct *pdev = getps2devstruct(dev->ctx, arequest); struct asyncreq *ars2p = dev->s2p; while (ars2p) { - if (ars2p->request == request) { + if (ars2p->arequest == arequest) { *len = ars2p->s2p->len; - memcpy (d, ars2p->s2p->data, *len); + memcpy(d, ars2p->s2p->data, *len); if (log_net) write_log (_T("->DST:%02X.%02X.%02X.%02X.%02X.%02X SRC:%02X.%02X.%02X.%02X.%02X.%02X E=%04X S=%d\n"), d[0], d[1], d[2], d[3], d[4], d[5], @@ -921,7 +964,7 @@ static int uaenet_getdata (void *devv, uae_u8 *d, int *len) packettype, *len); gotit = 1; dev->packetssent++; - signalasync (dev, ar, *len, 0); + signalasync(dev->ctx, dev, ar, *len, 0); break; } ars2p = ars2p->next; @@ -934,7 +977,7 @@ static int uaenet_getdata (void *devv, uae_u8 *d, int *len) return gotit; } -static void checkevents (struct s2devstruct *dev, int mask, int sem) +static void checkevents(TrapContext *ctx, struct s2devstruct *dev, int mask, int sem) { struct asyncreq *ar; @@ -943,11 +986,12 @@ static void checkevents (struct s2devstruct *dev, int mask, int sem) ar = dev->ar; while (ar) { if (!ar->ready) { - uaecptr request = ar->request; - int command = get_word (request + 28); - uae_u32 cmask = get_long (request + 32); + uaecptr arequest = ar->arequest; + uae_u8 *request = ar->request; + int command = get_word_host(request + 28); + uae_u32 cmask = get_long_host(request + 32); if (command == S2_ONEVENT && (mask & cmask)) - signalasync (dev, ar, 0, 0); + signalasync(ctx, dev, ar, 0, 0); } ar = ar->next; } @@ -955,16 +999,16 @@ static void checkevents (struct s2devstruct *dev, int mask, int sem) uae_sem_post (&async_sem); } -static int checksize (uaecptr request, struct s2devstruct *dev) +static int checksize(uae_u8 *request, struct s2devstruct *dev) { - uae_u32 datalength = get_long (request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES * 2); + uae_u32 datalength = get_long_host(request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES * 2); if (datalength > dev->td->mtu) return 0; return 1; } -static void flush (struct priv_s2devstruct *pdev) +static void flush(TrapContext *ctx, struct priv_s2devstruct *pdev) { struct asyncreq *ar; struct s2devstruct *dev; @@ -972,36 +1016,37 @@ static void flush (struct priv_s2devstruct *pdev) dev = gets2devstruct (pdev->unit); ar = dev->ar; while (ar) { - if (!ar->ready && getps2devstruct (ar->request) == pdev) { + if (!ar->ready && getps2devstruct(ctx, ar->arequest) == pdev) { ar->ready = 1; - do_abort_async (dev, ar->request); + do_abort_async(ctx, dev, ar->request, ar->arequest); } ar = ar->next; } } -static int dev_do_io_2 (struct s2devstruct *dev, uaecptr request, int quick) +static int dev_do_io_2 (TrapContext *ctx, struct s2devstruct *dev, uae_u8 *request, uaecptr arequest, int quick) { - uae_u8 flags = get_byte (request + 30); - uae_u32 command = get_word (request + 28); - uae_u32 packettype = get_long (request + 32 + 4); - uaecptr data = get_long (request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES * 2 + 4); - uae_u32 datalength = get_long (request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES * 2); - uaecptr srcaddr = request + 32 + 4 + 4; - uaecptr dstaddr = request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES; - uaecptr statdata = get_long (request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES * 2 + 4 + 4); - uaecptr buffermgmt = get_long (request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES * 2 + 4 + 4 + 4); + struct priv_s2devstruct *pdev = getps2devstruct(ctx, arequest); + + uae_u8 flags = get_byte_host(request + 30); + uae_u32 command = get_word_host(request + 28); + uae_u32 packettype = get_long_host(request + 32 + 4); + uaecptr data = get_long_host(request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES * 2 + 4); + uae_u32 datalength = get_long_host(request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES * 2); + uae_u8 *srcaddr = request + 32 + 4 + 4; + uae_u8 *dstaddr = request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES; + uaecptr statdata = get_long_host(request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES * 2 + 4 + 4); + uaecptr buffermgmt = get_long_host(request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES * 2 + 4 + 4 + 4); uae_u32 io_error = 0; uae_u32 wire_error = 0; int i; int async = 0; - struct priv_s2devstruct *pdev = getps2devstruct (request); if (log_net) - write_log (_T("S2: C=%02d T=%04X S=%02X%02X%02X%02X%02X%02X D=%02X%02X%02X%02X%02X%02X L=%d D=%08X SD=%08X BM=%08X\n"), - command, packettype, - get_byte (srcaddr + 0), get_byte (srcaddr + 1), get_byte (srcaddr + 2), get_byte (srcaddr + 3), get_byte (srcaddr + 4), get_byte (srcaddr + 5), - get_byte (dstaddr + 0), get_byte (dstaddr + 1), get_byte (dstaddr + 2), get_byte (dstaddr + 3), get_byte (dstaddr + 4), get_byte (dstaddr + 5), + write_log (_T("S2: IO=%08x %p C=%02d T=%04X S=%02X%02X%02X%02X%02X%02X D=%02X%02X%02X%02X%02X%02X L=%d D=%08X SD=%08X BM=%08X\n"), + arequest, request, command, packettype, + get_byte_host(srcaddr + 0), get_byte_host(srcaddr + 1), get_byte_host(srcaddr + 2), get_byte_host(srcaddr + 3), get_byte_host(srcaddr + 4), get_byte_host(srcaddr + 5), + get_byte_host(dstaddr + 0), get_byte_host(dstaddr + 1), get_byte_host(dstaddr + 2), get_byte_host(dstaddr + 3), get_byte_host(dstaddr + 4), get_byte_host(dstaddr + 5), datalength, data, statdata, buffermgmt); if (command == CMD_READ || command == S2_READORPHAN || command == CMD_WRITE || command == S2_BROADCAST || command == S2_MULTICAST) { @@ -1030,7 +1075,7 @@ static int dev_do_io_2 (struct s2devstruct *dev, uaecptr request, int quick) case CMD_WRITE: if (!dev->online) goto offline; - if (!checksize (request, dev)) + if (!checksize(request, dev)) goto toobig; async = 1; break; @@ -1038,12 +1083,12 @@ static int dev_do_io_2 (struct s2devstruct *dev, uaecptr request, int quick) case S2_MULTICAST: if (!dev->online) goto offline; - if ((get_byte (dstaddr + 0) & 1) == 0) { + if ((get_byte_host(dstaddr + 0) & 1) == 0) { io_error = S2ERR_BAD_ADDRESS; wire_error = S2WERR_BAD_MULTICAST; goto end; } - if (!checksize (request, dev)) + if (!checksize(request, dev)) goto toobig; async = 1; break; @@ -1054,26 +1099,26 @@ static int dev_do_io_2 (struct s2devstruct *dev, uaecptr request, int quick) if (log_net) write_log (_T("CMD_FLUSH started %08x\n"), request); uae_sem_wait (&async_sem); - flush (pdev); + flush(ctx, pdev); uae_sem_post (&async_sem); async = 1; - uaenet_vsync_requested++; + uaenet_int(); break; case S2_ADDMULTICASTADDRESS: - addmulticastaddresses (dev, amigaaddrto64 (srcaddr), 0); + addmulticastaddresses (dev, amigaaddrto64(srcaddr), 0); break; case S2_DELMULTICASTADDRESS: - if (!delmulticastaddresses (dev, amigaaddrto64 (srcaddr), 0)) { + if (!delmulticastaddresses (dev, amigaaddrto64(srcaddr), 0)) { io_error = S2ERR_BAD_STATE; wire_error = S2WERR_BAD_MULTICAST; } break; case S2_ADDMULTICASTADDRESSES: - addmulticastaddresses (dev, amigaaddrto64 (srcaddr), amigaaddrto64 (dstaddr)); + addmulticastaddresses(dev, amigaaddrto64(srcaddr), amigaaddrto64(dstaddr)); break; case S2_DELMULTICASTADDRESSES: - if (!delmulticastaddresses (dev, amigaaddrto64 (srcaddr), amigaaddrto64 (dstaddr))) { + if (!delmulticastaddresses(dev, amigaaddrto64(srcaddr), amigaaddrto64(dstaddr))) { io_error = S2ERR_BAD_STATE; wire_error = S2WERR_BAD_MULTICAST; } @@ -1081,32 +1126,32 @@ static int dev_do_io_2 (struct s2devstruct *dev, uaecptr request, int quick) case S2_DEVICEQUERY: { - int size = get_long (statdata); + int size = trap_get_long(ctx, statdata); if (size > 30) size = 30; - put_long (statdata + 4, size); + trap_put_long(ctx, statdata + 4, size); if (size >= 12) - put_long (statdata + 8, 0); + trap_put_long(ctx, statdata + 8, 0); if (size >= 16) - put_long (statdata + 12, 0); + trap_put_long(ctx, statdata + 12, 0); if (size >= 18) - put_word (statdata + 16, ADDR_SIZE * 8); + trap_put_word(ctx, statdata + 16, ADDR_SIZE * 8); if (size >= 22) - put_long (statdata + 18, dev->td->mtu); + trap_put_long(ctx, statdata + 18, dev->td->mtu); if (size >= 26) - put_long (statdata + 22, 10000000); + trap_put_long(ctx, statdata + 22, 10000000); if (size >= 30) - put_long (statdata + 26, S2WireType_Ethernet); + trap_put_long(ctx, statdata + 26, S2WireType_Ethernet); } break; case S2_GETTYPESTATS: if (pdev->trackcnt) { - put_long (statdata + 0, pdev->packetssent); - put_long (statdata + 4, pdev->packetsreceived); - put_long (statdata + 8, pdev->bytessent); - put_long (statdata + 12, pdev->bytesreceived); - put_long (statdata + 16, pdev->packetsdropped); + trap_put_long(ctx, statdata + 0, pdev->packetssent); + trap_put_long(ctx, statdata + 4, pdev->packetsreceived); + trap_put_long(ctx, statdata + 8, pdev->bytessent); + trap_put_long(ctx, statdata + 12, pdev->bytesreceived); + trap_put_long(ctx, statdata + 16, pdev->packetsdropped); } else { io_error = S2ERR_BAD_STATE; wire_error = S2WERR_NOT_TRACKED; @@ -1114,30 +1159,30 @@ static int dev_do_io_2 (struct s2devstruct *dev, uaecptr request, int quick) break; case S2_GETGLOBALSTATS: - put_long (statdata + 0, dev->packetsreceived); - put_long (statdata + 4, dev->packetssent); - put_long (statdata + 8, dev->baddata); - put_long (statdata + 12, dev->overruns); - put_long (statdata + 16, 0); - put_long (statdata + 20, dev->unknowntypesreceived); - put_long (statdata + 24, dev->reconfigurations); - put_long (statdata + 28, dev->online_secs); - put_long (statdata + 32, dev->online_micro); + trap_put_long(ctx, statdata + 0, dev->packetsreceived); + trap_put_long(ctx, statdata + 4, dev->packetssent); + trap_put_long(ctx, statdata + 8, dev->baddata); + trap_put_long(ctx, statdata + 12, dev->overruns); + trap_put_long(ctx, statdata + 16, 0); + trap_put_long(ctx, statdata + 20, dev->unknowntypesreceived); + trap_put_long(ctx, statdata + 24, dev->reconfigurations); + trap_put_long(ctx, statdata + 28, dev->online_secs); + trap_put_long(ctx, statdata + 32, dev->online_micro); break; case S2_GETSPECIALSTATS: - put_long (statdata + 1, 0); + trap_put_long(ctx, statdata + 1, 0); break; case S2_GETSTATIONADDRESS: for (i = 0; i < ADDR_SIZE; i++) { - put_byte (srcaddr + i, dev->td->mac[i]); - put_byte (dstaddr + i, dev->td->mac[i]); + put_byte_host(srcaddr + i, dev->td->mac[i]); + put_byte_host(dstaddr + i, dev->td->mac[i]); } break; case S2_CONFIGINTERFACE: - if (dev->configured) { + if (0 && dev->configured) { io_error = S2ERR_BAD_STATE; wire_error = S2WERR_IS_CONFIGURED; } else { @@ -1155,7 +1200,7 @@ static int dev_do_io_2 (struct s2devstruct *dev, uaecptr request, int quick) wire_error = S2WERR_RCVREL_HDW_ERR; } if (!io_error) { - uaenet_vsync_requested++; + uaenet_int(); async = 1; } break; @@ -1190,14 +1235,14 @@ static int dev_do_io_2 (struct s2devstruct *dev, uaecptr request, int quick) case S2_OFFLINE: if (dev->online) { dev->online = 0; - checkevents (dev, S2EVENT_OFFLINE, 1); + checkevents(ctx, dev, S2EVENT_OFFLINE, 1); } break; case S2_ONEVENT: { uae_u32 events; - uae_u32 wanted_events = get_long (request + 32); + uae_u32 wanted_events = get_long_host(request + 32); if (wanted_events & ~KNOWN_EVENTS) { io_error = S2ERR_NOT_SUPPORTED; events = S2WERR_BAD_EVENT; @@ -1233,36 +1278,36 @@ toobig: end: if (log_net && (io_error || wire_error)) write_log (_T("-> %d (%d)\n"), io_error, wire_error); - put_long (request + 32, wire_error); - put_byte (request + 31, io_error); + put_long_host(request + 32, wire_error); + put_byte_host(request + 31, io_error); return async; } -static int dev_do_io (struct s2devstruct *dev, uaecptr request, int quick) +static int dev_do_io (TrapContext *ctx, struct s2devstruct *dev, uae_u8 *request, uaecptr arequest, int quick) { - uae_u32 command = get_word (request + 28); - struct priv_s2devstruct *pdev = getps2devstruct (request); - uaecptr data = get_long (request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES * 2 + 4); + struct priv_s2devstruct *pdev = getps2devstruct(ctx, arequest); + uae_u32 command = get_word_host(request + 28); + uaecptr data = get_long_host(request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES * 2 + 4); - put_byte (request + 31, 0); + put_byte_host(request + 31, 0); if (!pdev) { write_log (_T("%s unknown iorequest %08x\n"), getdevname (), request); return 0; } if (command == NSCMD_DEVICEQUERY) { - uae_u32 data = get_long (request + 40); /* io_data */ - put_long (data + 0, 0); - put_long (data + 4, 16); /* size */ - put_word (data + 8, 7); /* NSDEVTYPE_SANA2 */ - put_word (data + 10, 0); - put_long (data + 12, nscmd_cmd); - put_long (request + 32, 16); /* io_actual */ + uae_u32 data = get_long_host(request + 40); /* io_data */ + trap_put_long(ctx, data + 0, 0); + trap_put_long(ctx, data + 4, 16); /* size */ + trap_put_word(ctx, data + 8, 7); /* NSDEVTYPE_SANA2 */ + trap_put_word(ctx, data + 10, 0); + trap_put_long(ctx, data + 12, nscmd_cmd); + put_long_host(request + 32, 16); /* io_actual */ return 0; - } else if (get_word (request + 0x12) < SANA2_IOREQSIZE) { - put_byte (request + 31, IOERR_BADLENGTH); + } else if (get_word_host(request + 0x12) < SANA2_IOREQSIZE) { + put_byte_host(request + 31, IOERR_BADLENGTH); return 0; } - return dev_do_io_2 (dev, request, quick); + return dev_do_io_2(ctx, dev, request, arequest, quick); } static int dev_can_quick (uae_u32 command) @@ -1275,74 +1320,90 @@ static int dev_can_quick (uae_u32 command) case S2_GETSTATIONADDRESS: case S2_TRACKTYPE: case S2_UNTRACKTYPE: - return 1; + return 0; } return 0; } -static int dev_canquick (struct s2devstruct *dev, uaecptr request) +static int dev_canquick (TrapContext *ctx, struct s2devstruct *dev, uae_u8 *request) { - uae_u32 command = get_word (request + 28); + uae_u32 command = get_word_host(request + 28); return dev_can_quick (command); } -static uae_u32 REGPARAM2 dev_beginio (TrapContext *context) +static uae_u32 REGPARAM2 dev_beginio (TrapContext *ctx) { - uae_u32 request = m68k_areg (regs, 1); - uae_u8 flags = get_byte (request + 30); - int command = get_word (request + 28); - struct priv_s2devstruct *pdev = getps2devstruct (request); + uae_u32 err = 0; + uae_u32 arequest = trap_get_areg(ctx, 1); + struct priv_s2devstruct *pdev = getps2devstruct(ctx, arequest); + uae_u8 *request = xmalloc(uae_u8, SANA2_IOREQSIZE); + trap_get_bytes(ctx, request, arequest, SANA2_IOREQSIZE); + + uae_u8 flags = get_byte_host(request + 30); + int command = get_word_host(request + 28); struct s2devstruct *dev; - put_byte (request + 8, NT_MESSAGE); + put_byte_host(request + 31, 0); + + put_byte_host(request + 8, NT_MESSAGE); if (!pdev) { write_log (_T("%s unknown iorequest (1) %08x\n"), getdevname (), request); - put_byte (request + 31, 32); - return get_byte (request + 31); + err = 32; + goto err; } dev = gets2devstruct (pdev->unit); if (!dev) { write_log (_T("%s unknown iorequest (2) %08x\n"), getdevname (), request); - put_byte (request + 31, 32); - return get_byte (request + 31); + err = 32; + goto err; } - put_byte (request + 31, 0); - if ((flags & 1) && dev_canquick (dev, request)) { - if (dev_do_io (dev, request, 1)) + + if ((flags & 1) && dev_canquick (ctx, dev, request)) { + if (dev_do_io(ctx, dev, request, arequest, 1)) write_log (_T("%s: command %d bug with IO_QUICK\n"), SANA2NAME, command); - return get_byte (request + 31); + err = get_byte_host(request + 31); } else { if (command == CMD_WRITE || command == S2_BROADCAST || command == S2_MULTICAST) { struct s2packet *s2p; if (!pdev->copyfrombuff || !pdev->copytobuff) { - put_long (request + 32, S2ERR_BAD_ARGUMENT); - put_byte (request + 31, S2WERR_BUFF_ERROR); + put_long_host(request + 32, S2ERR_BAD_ARGUMENT); + put_byte_host(request + 31, S2WERR_BUFF_ERROR); } else { if (command == S2_BROADCAST) { - uaecptr dstaddr = request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES; - put_byte (dstaddr + 0, 0xff); - put_byte (dstaddr + 1, 0xff); - put_byte (dstaddr + 2, 0xff); - put_byte (dstaddr + 3, 0xff); - put_byte (dstaddr + 4, 0xff); - put_byte (dstaddr + 5, 0xff); + uae_u8 *dstaddr = request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES; + put_byte_host(dstaddr + 0, 0xff); + put_byte_host(dstaddr + 1, 0xff); + put_byte_host(dstaddr + 2, 0xff); + put_byte_host(dstaddr + 3, 0xff); + put_byte_host(dstaddr + 4, 0xff); + put_byte_host(dstaddr + 5, 0xff); } - s2p = createwritepacket (context, request); + s2p = createwritepacket(ctx, request, arequest); if (s2p) { uae_sem_wait (&async_sem); - add_async_packet (dev, s2p, request); + add_async_packet (dev, s2p, request, arequest); uae_sem_post (&async_sem); } if (!s2p) { - put_long (request + 32, S2WERR_BUFF_ERROR); - put_byte (request + 31, S2ERR_NO_RESOURCES); + put_long_host(request + 32, S2WERR_BUFF_ERROR); + put_byte_host(request + 31, S2ERR_NO_RESOURCES); } } } - put_byte (request + 30, get_byte (request + 30) & ~1); - write_comm_pipe_u32 (&dev->requests, request, 1); + put_byte_host(request + 30, get_byte_host(request + 30) & ~1); + trap_put_bytes(ctx, request + 8, arequest + 8, SANA2_IOREQSIZE - 8); + uae_sem_wait(&pipe_sem); + trap_set_background(ctx); + write_comm_pipe_pvoid(&dev->requests, ctx, 0); + write_comm_pipe_pvoid(&dev->requests, request, 0); + write_comm_pipe_u32(&dev->requests, arequest, 1); + uae_sem_post(&pipe_sem); return 0; } +err: + trap_put_bytes(ctx, request + 8, arequest + 8, SANA2_IOREQSIZE - 8); + xfree(request); + return err; } static void *dev_thread (void *devs) @@ -1353,6 +1414,8 @@ static void *dev_thread (void *devs) dev->thread_running = 1; uae_sem_post (&dev->sync_sem); for (;;) { + TrapContext *ctx = (TrapContext*)read_comm_pipe_pvoid_blocking(&dev->requests); + uae_u8 *iobuf = (uae_u8*)read_comm_pipe_pvoid_blocking(&dev->requests); uaecptr request = (uaecptr)read_comm_pipe_u32_blocking (&dev->requests); uae_sem_wait (&change_sem); if (!request) { @@ -1361,70 +1424,77 @@ static void *dev_thread (void *devs) uae_sem_post (&change_sem); write_log (_T("%s: dev_thread killed\n"), getdevname ()); return 0; - } else if (get_async_request (dev, request, 1)) { + } + struct priv_s2devstruct *pdev = getps2devstruct(ctx, request); + asyncreq *ar = get_async_request (dev, request, 1); + if (ar) { + trap_put_bytes(ctx, ar->request + 8, request + 8, SANA2_IOREQSIZE - 8); uae_ReplyMsg (request); release_async_request (dev, request); rem_async_packet (dev, request); - } else if (dev_do_io (dev, request, 0) == 0) { + } else if (dev_do_io(ctx, dev, iobuf, request, 0) == 0) { + trap_put_bytes(ctx, iobuf + 8, request + 8, SANA2_IOREQSIZE - 8); uae_ReplyMsg (request); rem_async_packet (dev, request); } else { - struct priv_s2devstruct *pdev = getps2devstruct (request); - add_async_request (dev, request); + add_async_request (dev, iobuf, request); + dev->ctx = ctx; ethernet_trigger (pdev->td, dev->sysdata); + dev->ctx = NULL; + iobuf = NULL; } + trap_background_set_complete(ctx); uae_sem_post (&change_sem); } return 0; } -static uae_u32 REGPARAM2 dev_init_2 (TrapContext *context) +static uae_u32 REGPARAM2 dev_init_2 (TrapContext *ctx) { - uae_u32 base = m68k_dreg (regs,0); + uae_u32 base = trap_get_dreg(ctx, 0); if (log_net) write_log (_T("%s init\n"), SANA2NAME); return base; } -static uae_u32 REGPARAM2 dev_init (TrapContext *context) +static uae_u32 REGPARAM2 dev_init (TrapContext *ctx) { - return dev_init_2 (context); + return dev_init_2 (ctx); } -static uae_u32 REGPARAM2 dev_abortio (TrapContext *context) +static uae_u32 REGPARAM2 dev_abortio (TrapContext *ctx) { - uae_u32 request = m68k_areg (regs, 1); - struct priv_s2devstruct *pdev = getps2devstruct (request); + uae_u8 err = 0; + uae_u32 request = trap_get_areg(ctx, 1); + struct priv_s2devstruct *pdev = getps2devstruct(ctx, request); struct s2devstruct *dev; if (!pdev) { write_log (_T("%s abortio but no request %08x found!\n"), getdevname(), request); - put_byte (request + 31, 32); - return get_byte (request + 31); + err = 32; + trap_put_byte(ctx, request + 31, err); + return err; } dev = gets2devstruct (pdev->unit); if (!dev) { write_log (_T("%s (%d) abortio but no request %08x found!\n"), getdevname(), pdev->unit, request); - put_byte (request + 31, 32); - return get_byte (request + 31); + err = 32; + trap_put_byte(ctx, request + 31, err); + return err; } if (log_net) write_log (_T("%s:%d abortio %08x\n"), getdevname(), dev->unit, request); - abort_async (dev, request); + abort_async(ctx, dev, request); return 0; } -static uae_u32 REGPARAM2 uaenet_int_handler (TrapContext *ctx) +static int uaenet_int_handler2(TrapContext *ctx) { int i, j; int gotit; struct asyncreq *ar; + bool irq = false; - if (uae_sem_trywait (&async_sem)) { - uaenet_int_requested = 0; - uaenet_int_late = 1; - return 0; - } for (i = 0; i < MAX_OPEN_DEVICES; i++) pdevst[i].tmp = 0; @@ -1440,24 +1510,34 @@ static uae_u32 REGPARAM2 uaenet_int_handler (TrapContext *ctx) gotit = 0; while (ar) { if (!ar->ready) { - uaecptr request = ar->request; - int command = get_word (request + 28); - uae_u32 packettype = get_long (request + 32 + 4); - if (command == CMD_READ && (packettype == type || (packettype <= 1500 && type <= 1500))) { - struct priv_s2devstruct *pdev = getps2devstruct (request); - if (pdev && pdev->tmp == 0) { - if (handleread (ctx, pdev, request, p->data, p->len, command)) { - if (log_net) - write_log (_T("-> %p Accepted, CMD_READ, REQ=%08X LEN=%d\n"), p, request, p->len); - ar->ready = 1; - write_comm_pipe_u32 (&dev->requests, request, 1); - dev->packetsreceived++; - gotit = 1; - pdev->tmp = 1; - } else { - if (log_net) - write_log (_T("-> %p PacketFilter() rejected, CMD_READ, REQ=%08X LEN=%d\n"), p, request, p->len); - pdev->tmp = -1; + uaecptr arequest = ar->arequest; + uae_u8 *request = ar->request; + int command = get_word_host(request + 28); + if (command == CMD_READ) { + uae_u32 packettype = get_long_host(request + 32 + 4); + if (packettype == type || (packettype <= 1500 && type <= 1500)) { + struct priv_s2devstruct *pdev = getps2devstruct(ctx, arequest); + if (pdev && pdev->tmp == 0) { + if (handleread (ctx, pdev, request, arequest, p->data, p->len, command)) { + if (log_net) + write_log (_T("-> %p Accepted, CMD_READ, REQ=%08X LEN=%d\n"), p, arequest, p->len); + ar->ready = 1; + uae_sem_wait(&pipe_sem); + trap_set_background(ctx); + write_comm_pipe_pvoid(&dev->requests, ctx, 0); + write_comm_pipe_pvoid(&dev->requests, request, 0); + write_comm_pipe_u32 (&dev->requests, arequest, 1); + uae_sem_post(&pipe_sem); + dev->packetsreceived++; + pdev->tmp = 1; + dev->readqueue = dev->readqueue->next; + freepacket(p); + return -1; + } else { + if (log_net) + write_log (_T("-> %p PacketFilter() rejected, CMD_READ, REQ=%08X LEN=%d\n"), p, request, p->len); + pdev->tmp = -1; + } } } } @@ -1467,20 +1547,29 @@ static uae_u32 REGPARAM2 uaenet_int_handler (TrapContext *ctx) ar = dev->ar; while (ar) { if (!ar->ready) { - uaecptr request = ar->request; - int command = get_word (request + 28); + uaecptr arequest = ar->arequest; + uae_u8 *request = ar->request; + int command = get_word_host(request + 28); if (command == S2_READORPHAN) { - struct priv_s2devstruct *pdev = getps2devstruct (request); + struct priv_s2devstruct *pdev = getps2devstruct(ctx, arequest); if (pdev && pdev->tmp <= 0) { if (log_net) - write_log (_T("-> %p Accepted, S2_READORPHAN, REQ=%08X LEN=%d\n"), p, request, p->len); - handleread (ctx, pdev, request, p->data, p->len, command); + write_log (_T("-> %p Accepted, S2_READORPHAN, REQ=%08X LEN=%d\n"), p, arequest, p->len); + handleread (ctx, pdev, request, arequest, p->data, p->len, command); ar->ready = 1; - write_comm_pipe_u32 (&dev->requests, request, 1); + uae_sem_wait(&pipe_sem); + trap_set_background(ctx); + write_comm_pipe_pvoid(&dev->requests, ctx, 0); + write_comm_pipe_pvoid(&dev->requests, request, 0); + write_comm_pipe_u32 (&dev->requests, arequest, 1); + uae_sem_post(&pipe_sem); dev->packetsreceived++; dev->unknowntypesreceived++; gotit = 1; pdev->tmp = 1; + dev->readqueue = dev->readqueue->next; + freepacket(p); + return -1; } } } @@ -1510,10 +1599,11 @@ static uae_u32 REGPARAM2 uaenet_int_handler (TrapContext *ctx) ar = dev->ar; while (ar) { if (!ar->ready) { - uaecptr request = ar->request; - int command = get_word (request + 28); + uaecptr arequest = ar->arequest; + uae_u8 *request = ar->request; + int command = get_word_host(request + 28); if (command == S2_ONLINE) { - struct priv_s2devstruct *pdev = getps2devstruct (request); + struct priv_s2devstruct *pdev = getps2devstruct(ctx, arequest); dev->packetsreceived = 0; dev->packetssent = 0; dev->baddata = 0; @@ -1521,29 +1611,39 @@ static uae_u32 REGPARAM2 uaenet_int_handler (TrapContext *ctx) dev->unknowntypesreceived = 0; dev->reconfigurations = 0; if (pdev && pdev->timerbase) { - m68k_areg (regs, 0) = pdev->tempbuf; - CallLib (ctx, pdev->timerbase, -0x42); /* GetSysTime() */ + trap_call_add_areg(ctx, 0, pdev->tempbuf); + trap_call_lib(ctx, pdev->timerbase, -0x42); /* GetSysTime() */ } else { - put_long (pdev->tempbuf + 0, 0); - put_long (pdev->tempbuf + 4, 0); + trap_put_long(ctx, pdev->tempbuf + 0, 0); + trap_put_long(ctx, pdev->tempbuf + 4, 0); } - dev->online_secs = get_long (pdev->tempbuf + 0); - dev->online_micro = get_long (pdev->tempbuf + 4); - checkevents (dev, S2EVENT_ONLINE, 0); + dev->online_secs = trap_get_long(ctx, pdev->tempbuf + 0); + dev->online_micro = trap_get_long(ctx, pdev->tempbuf + 4); + checkevents(ctx, dev, S2EVENT_ONLINE, 0); dev->online = 1; ar->ready = 1; - write_comm_pipe_u32 (&dev->requests, request, 1); - uaenet_vsync_requested--; + uae_sem_wait(&pipe_sem); + trap_set_background(ctx); + write_comm_pipe_pvoid(&dev->requests, ctx, 0); + write_comm_pipe_pvoid(&dev->requests, request, 0); + write_comm_pipe_u32(&dev->requests, arequest, 1); + uae_sem_post(&pipe_sem); + return -1; } else if (command == CMD_FLUSH) { /* do not reply CMD_FLUSH until all other requests are gone */ if (dev->ar->next == NULL) { if (log_net) - write_log (_T("CMD_FLUSH replied %08x\n"), request); + write_log (_T("CMD_FLUSH replied %08x\n"), arequest); ar->ready = 1; - write_comm_pipe_u32 (&dev->requests, request, 1); - uaenet_vsync_requested--; + uae_sem_wait(&pipe_sem); + trap_set_background(ctx); + write_comm_pipe_pvoid(&dev->requests, ctx, 0); + write_comm_pipe_pvoid(&dev->requests, request, 0); + write_comm_pipe_u32 (&dev->requests, arequest, 1); + uae_sem_post(&pipe_sem); + return -1; } else { - struct priv_s2devstruct *pdev = getps2devstruct (request); + struct priv_s2devstruct *pdev = getps2devstruct(ctx, arequest); if (pdev) { dev->flush_timeout--; if (dev->flush_timeout <= 0) { @@ -1551,7 +1651,7 @@ static uae_u32 REGPARAM2 uaenet_int_handler (TrapContext *ctx) if (dev->flush_timeout_cnt > 1) write_log (_T("WARNING: %s:%d CMD_FLUSH possibly frozen..\n"), getdevname(), pdev->unit); dev->flush_timeout_cnt++; - flush (pdev); + flush(ctx, pdev); } } } @@ -1561,12 +1661,46 @@ static uae_u32 REGPARAM2 uaenet_int_handler (TrapContext *ctx) } } if (uaenet_int_late) - uaenet_int_requested = 1; - else - uaenet_int_requested = 0; + irq = true; uaenet_int_late = 0; - uae_sem_post (&async_sem); - return 0; + return irq ? 1 : 0; +} + +static uae_u32 REGPARAM2 uaenet_int_handler(TrapContext *ctx) +{ + for (;;) { + if (uae_sem_trywait(&async_sem)) { + uaenet_int_late = 1; + return 1; + } + int r = uaenet_int_handler2(ctx); + uae_sem_post(&async_sem); + if (r <= 0) + return r; + } +} + +void uaenet_vsync(void) +{ + if (!irq_init) + return; + if (uae_sem_trywait(&async_sem)) + return; + bool pending = false; + for (int i = 0; i < MAX_TOTAL_NET_DEVICES; i++) { + struct s2devstruct *dev = &devst[i]; + if (dev->online) { + if(dev->readqueue) + pending = true; + } + if (dev->ar) { + pending = true; + } + } + if (uaenet_int_late || pending) + uaenet_int(); + uaenet_int_late = 0; + uae_sem_post(&async_sem); } static void dev_reset (void) @@ -1588,11 +1722,15 @@ static void dev_reset (void) while (ar) { if (!ar->ready) { dev->ar->ready = 1; - do_abort_async (dev, ar->request); + do_abort_async(NULL, dev, ar->request, ar->arequest); } ar = ar->next; } + uae_sem_wait(&pipe_sem); + write_comm_pipe_pvoid(&dev->requests, NULL, 0); + write_comm_pipe_pvoid(&dev->requests, NULL, 0); write_comm_pipe_u32 (&dev->requests, 0, 1); + uae_sem_post(&pipe_sem); uae_sem_wait (&dev->sync_sem); } while (dev->mc) @@ -1601,13 +1739,11 @@ static void dev_reset (void) } for (i = 0; i < MAX_OPEN_DEVICES; i++) memset (&pdevst[i], 0, sizeof (struct priv_s2devstruct)); - uaenet_vsync_requested = 0; - uaenet_int_requested = 0; irq_init = 0; } -uaecptr netdev_startup (uaecptr resaddr) +uaecptr netdev_startup(TrapContext *ctx, uaecptr resaddr) { if (!currprefs.sana2) return resaddr; @@ -1615,14 +1751,14 @@ uaecptr netdev_startup (uaecptr resaddr) write_log (_T("netdev_startup(0x%x)\n"), resaddr); /* Build a struct Resident. This will set up and initialize * the uaenet.device */ - put_word (resaddr + 0x0, 0x4AFC); - put_long (resaddr + 0x2, resaddr); - put_long (resaddr + 0x6, resaddr + 0x1A); /* Continue scan here */ - put_word (resaddr + 0xA, 0x8101); /* RTF_AUTOINIT|RTF_COLDSTART; Version 1 */ - put_word (resaddr + 0xC, 0x0305); /* NT_DEVICE; pri 05 */ - put_long (resaddr + 0xE, ROM_netdev_resname); - put_long (resaddr + 0x12, ROM_netdev_resid); - put_long (resaddr + 0x16, ROM_netdev_init); /* calls netdev_init */ + trap_put_word(ctx, resaddr + 0x0, 0x4AFC); + trap_put_long(ctx, resaddr + 0x2, resaddr); + trap_put_long(ctx, resaddr + 0x6, resaddr + 0x1A); /* Continue scan here */ + trap_put_word(ctx, resaddr + 0xA, 0x8101); /* RTF_AUTOINIT|RTF_COLDSTART; Version 1 */ + trap_put_word(ctx, resaddr + 0xC, 0x0305); /* NT_DEVICE; pri 05 */ + trap_put_long(ctx, resaddr + 0xE, ROM_netdev_resname); + trap_put_long(ctx, resaddr + 0x12, ROM_netdev_resid); + trap_put_long(ctx, resaddr + 0x16, ROM_netdev_init); /* calls netdev_init */ resaddr += 0x1A; return resaddr; } @@ -1740,8 +1876,9 @@ void netdev_start_threads (void) return; if (log_net) write_log (_T("netdev_start_threads()\n")); - uae_sem_init (&change_sem, 0, 1); - uae_sem_init (&async_sem, 0, 1); + uae_sem_init(&change_sem, 0, 1); + uae_sem_init(&pipe_sem, 0, 1); + uae_sem_init(&async_sem, 0, 1); } void netdev_reset (void) diff --git a/scsiemul.cpp b/scsiemul.cpp index 1aa3fda8..80529db4 100644 --- a/scsiemul.cpp +++ b/scsiemul.cpp @@ -1096,7 +1096,7 @@ static void *dev_thread (void *devs) static uae_u32 REGPARAM2 dev_init_2 (TrapContext *context, int type) { - uae_u32 base = m68k_dreg (regs, 0); + uae_u32 base = trap_get_dreg (context, 0); if (log_scsi) write_log (_T("%s init\n"), getdevname (type)); return base; @@ -1253,25 +1253,25 @@ static uaecptr ROM_diskdev_resname = 0, ROM_diskdev_init = 0; -static uaecptr diskdev_startup (uaecptr resaddr) +static uaecptr diskdev_startup (TrapContext *ctx, uaecptr resaddr) { /* Build a struct Resident. This will set up and initialize * the cd.device */ if (log_scsi) write_log (_T("diskdev_startup(0x%x)\n"), resaddr); - put_word (resaddr + 0x0, 0x4AFC); - put_long (resaddr + 0x2, resaddr); - put_long (resaddr + 0x6, resaddr + 0x1A); /* Continue scan here */ - put_word (resaddr + 0xA, 0x8101); /* RTF_AUTOINIT|RTF_COLDSTART; Version 1 */ - put_word (resaddr + 0xC, 0x0305); /* NT_DEVICE; pri 05 */ - put_long (resaddr + 0xE, ROM_diskdev_resname); - put_long (resaddr + 0x12, ROM_diskdev_resid); - put_long (resaddr + 0x16, ROM_diskdev_init); + trap_put_word(ctx, resaddr + 0x0, 0x4AFC); + trap_put_long(ctx, resaddr + 0x2, resaddr); + trap_put_long(ctx, resaddr + 0x6, resaddr + 0x1A); /* Continue scan here */ + trap_put_word(ctx, resaddr + 0xA, 0x8101); /* RTF_AUTOINIT|RTF_COLDSTART; Version 1 */ + trap_put_word(ctx, resaddr + 0xC, 0x0305); /* NT_DEVICE; pri 05 */ + trap_put_long(ctx, resaddr + 0xE, ROM_diskdev_resname); + trap_put_long(ctx, resaddr + 0x12, ROM_diskdev_resid); + trap_put_long(ctx, resaddr + 0x16, ROM_diskdev_init); resaddr += 0x1A; return resaddr; } -uaecptr scsidev_startup (uaecptr resaddr) +uaecptr scsidev_startup(TrapContext *ctx, uaecptr resaddr) { if (currprefs.scsi != 1) return resaddr; @@ -1279,17 +1279,17 @@ uaecptr scsidev_startup (uaecptr resaddr) write_log (_T("scsidev_startup(0x%x)\n"), resaddr); /* Build a struct Resident. This will set up and initialize * the uaescsi.device */ - put_word (resaddr + 0x0, 0x4AFC); - put_long (resaddr + 0x2, resaddr); - put_long (resaddr + 0x6, resaddr + 0x1A); /* Continue scan here */ - put_word (resaddr + 0xA, 0x8101); /* RTF_AUTOINIT|RTF_COLDSTART; Version 1 */ - put_word (resaddr + 0xC, 0x0305); /* NT_DEVICE; pri 05 */ - put_long (resaddr + 0xE, ROM_scsidev_resname); - put_long (resaddr + 0x12, ROM_scsidev_resid); - put_long (resaddr + 0x16, ROM_scsidev_init); /* calls scsidev_init */ + trap_put_word(ctx, resaddr + 0x0, 0x4AFC); + trap_put_long(ctx, resaddr + 0x2, resaddr); + trap_put_long(ctx, resaddr + 0x6, resaddr + 0x1A); /* Continue scan here */ + trap_put_word(ctx, resaddr + 0xA, 0x8101); /* RTF_AUTOINIT|RTF_COLDSTART; Version 1 */ + trap_put_word(ctx, resaddr + 0xC, 0x0305); /* NT_DEVICE; pri 05 */ + trap_put_long(ctx, resaddr + 0xE, ROM_scsidev_resname); + trap_put_long(ctx, resaddr + 0x12, ROM_scsidev_resid); + trap_put_long(ctx, resaddr + 0x16, ROM_scsidev_init); /* calls scsidev_init */ resaddr += 0x1A; return resaddr; - return diskdev_startup (resaddr); + //return diskdev_startup(ctx, resaddr); } static void diskdev_install (void) diff --git a/tabletlibrary.cpp b/tabletlibrary.cpp index 58943195..3e4e0b51 100644 --- a/tabletlibrary.cpp +++ b/tabletlibrary.cpp @@ -43,68 +43,68 @@ void tabletlib_tablet_info (int maxx, int maxy, int maxz, int maxax, int maxay, tablet_resy = yres; } -static void filltags (uaecptr tabletdata) +static void filltags (TrapContext *ctx, uaecptr tabletdata) { uaecptr p = tablettags; if (!p) return; - put_word (tabletdata + 0, 0); - put_word (tabletdata + 2, 0); - put_long (tabletdata + 4, tablet_x); - put_long (tabletdata + 8, tablet_y); - put_long (tabletdata + 12, tablet_maxx); - put_long (tabletdata + 16, tablet_maxy); + trap_put_word(ctx, tabletdata + 0, 0); + trap_put_word(ctx, tabletdata + 2, 0); + trap_put_long(ctx, tabletdata + 4, tablet_x); + trap_put_long(ctx, tabletdata + 8, tablet_y); + trap_put_long(ctx, tabletdata + 12, tablet_maxx); + trap_put_long(ctx, tabletdata + 16, tablet_maxy); //write_log(_T("P=%08X BUT=%08X\n"), tablet_pressure, tablet_buttonbits); // pressure - put_long (p, 0x8003a000 + 6); + trap_put_long(ctx, p, 0x8003a000 + 6); p += 4; - put_long (p, tablet_pressure); + trap_put_long(ctx, p, tablet_pressure); p += 4; // buttonbits - put_long (p, 0x8003a000 + 7); + trap_put_long(ctx, p, 0x8003a000 + 7); p += 4; - put_long (p, tablet_buttonbits); + trap_put_long(ctx, p, tablet_buttonbits); p += 4; // resolutionx - put_long (p, 0x8003a000 + 9); + trap_put_long(ctx, p, 0x8003a000 + 9); p += 4; - put_long (p, tablet_resx); + trap_put_long(ctx, p, tablet_resx); p += 4; // resolutiony - put_long (p, 0x8003a000 + 10); + trap_put_long(ctx, p, 0x8003a000 + 10); p += 4; - put_long (p, tablet_resy); + trap_put_long(ctx, p, tablet_resy); p += 4; if (tablet_inproximity == 0) { // inproximity - put_long (p, 0x8003a000 + 8); + trap_put_long(ctx, p, 0x8003a000 + 8); p += 4; - put_long (p, 0); + trap_put_long(ctx, p, 0); p += 4; } - put_long (p, 0); + trap_put_long(ctx, p, 0); } static uae_u32 REGPARAM2 lib_initcode (TrapContext *ctx) { - base = m68k_dreg (regs, 0); + base = trap_get_dreg(ctx, 0); tablettags = base + SIZEOF_LIBRARY; tablet_inproximity = -1; tablet_x = tablet_y = 0; tablet_buttonbits = tablet_pressure = 0; - ksversion = get_word (m68k_areg (regs, 6) + 20); + ksversion = trap_get_word(ctx, trap_get_areg(ctx, 6) + 20); return base; } static uae_u32 REGPARAM2 lib_openfunc (TrapContext *ctx) { - put_word (m68k_areg (regs, 6) + 32, get_word (m68k_areg (regs, 6) + 32) + 1); - return m68k_areg (regs, 6); + trap_put_word(ctx, trap_get_areg(ctx, 6) + 32, trap_get_word(ctx, trap_get_areg(ctx, 6) + 32) + 1); + return trap_get_areg(ctx, 6); } static uae_u32 REGPARAM2 lib_closefunc (TrapContext *ctx) { - put_word (m68k_areg (regs, 6) + 32, get_word (m68k_areg (regs, 6) + 32) - 1); + trap_put_word(ctx, trap_get_areg(ctx, 6) + 32, trap_get_word(ctx, trap_get_areg(ctx, 6) + 32) - 1); return 0; } static uae_u32 REGPARAM2 lib_expungefunc (TrapContext *context) @@ -117,52 +117,53 @@ static uae_u32 REGPARAM2 lib_expungefunc (TrapContext *context) #define TAG_MORE (2L) /* ti_Data is pointer to another array of TagItems */ #define TAG_SKIP (3L) /* skip this and the next ti_Data items */ -static uae_u32 REGPARAM2 lib_allocfunc (TrapContext *context) +static uae_u32 REGPARAM2 lib_allocfunc (TrapContext *ctx) { - uae_u32 tags = m68k_areg (regs, 0); + uae_u32 tags = trap_get_areg(ctx, 0); uae_u32 mem; - m68k_dreg (regs, 0) = 24; - m68k_dreg (regs, 1) = 65536 + 1; - mem = CallLib (context, get_long (4), -0xC6); /* AllocMem */ + + trap_call_add_dreg(ctx, 0, 24); + trap_call_add_dreg(ctx, 1, 65536 + 1); + mem = trap_call_lib(ctx, trap_get_long(ctx, 4), -0xC6); /* AllocMem */ if (!mem) return 0; for (;;) { - uae_u32 t = get_long(tags); + uae_u32 t = trap_get_long(ctx, tags); if (t == TAG_DONE) break; if (t == TAG_SKIP) { - tags += 8 + get_long(tags + 4) * 8; + tags += 8 + trap_get_long(ctx, tags + 4) * 8; } else if (t == TAG_MORE) { - tags = get_long(tags + 4); + tags = trap_get_long(ctx, tags + 4); } else if (t == TAG_IGNORE) { tags += 8; } else { t -= 0x8003a000; // clear "unknown" tags if (t != 6 && t != 8) - put_long(tags, TAG_IGNORE); + trap_put_long(ctx, tags, TAG_IGNORE); tags += 8; } } - put_long (mem + 20, tablettags); - filltags (mem); + trap_put_long(ctx, mem + 20, tablettags); + filltags(ctx, mem); return mem; } -static uae_u32 REGPARAM2 lib_freefunc (TrapContext *context) +static uae_u32 REGPARAM2 lib_freefunc (TrapContext *ctx) { - m68k_areg (regs, 1) = m68k_areg (regs, 0); - m68k_dreg (regs, 0) = 24; - CallLib(context, get_long (4), -0xD2); + trap_call_add_areg(ctx, 1, trap_get_areg(ctx, 0)); + trap_call_add_dreg(ctx, 0, 24); + trap_call_lib(ctx, trap_get_long(ctx, 4), -0xD2); return 0; } -static uae_u32 REGPARAM2 lib_dofunc (TrapContext *context) +static uae_u32 REGPARAM2 lib_dofunc (TrapContext *ctx) { - uaecptr im = m68k_areg (regs, 0); - uaecptr td = m68k_areg (regs, 1); - filltags (td); + uaecptr im = trap_get_areg(ctx, 0); + uaecptr td = trap_get_areg(ctx, 1); + filltags(ctx, td); if (ksversion < 39) return 0; - td = get_long (im + 52); + td = trap_get_long(ctx, im + 52); if (!td) return 0; return 1; @@ -173,18 +174,18 @@ static uae_u32 REGPARAM2 lib_unkfunc (TrapContext *context) return 0; } -uaecptr tabletlib_startup (uaecptr resaddr) +uaecptr tabletlib_startup(TrapContext *ctx, uaecptr resaddr) { if (!currprefs.tablet_library) return resaddr; - put_word (resaddr + 0x0, 0x4AFC); - put_long (resaddr + 0x2, resaddr); - put_long (resaddr + 0x6, resaddr + 0x1A); /* Continue scan here */ - put_word (resaddr + 0xA, 0x8127); /* RTF_AUTOINIT|RTF_COLDSTART; Version 1 */ - put_word (resaddr + 0xC, 0x0900); /* NT_LIBRARY; pri 00 */ - put_long (resaddr + 0xE, lib_name); - put_long (resaddr + 0x12, lib_id); - put_long (resaddr + 0x16, lib_init); + trap_put_word(ctx, resaddr + 0x0, 0x4AFC); + trap_put_long(ctx, resaddr + 0x2, resaddr); + trap_put_long(ctx, resaddr + 0x6, resaddr + 0x1A); /* Continue scan here */ + trap_put_word(ctx, resaddr + 0xA, 0x8127); /* RTF_AUTOINIT|RTF_COLDSTART; Version 1 */ + trap_put_word(ctx, resaddr + 0xC, 0x0900); /* NT_LIBRARY; pri 00 */ + trap_put_long(ctx, resaddr + 0xE, lib_name); + trap_put_long(ctx, resaddr + 0x12, lib_id); + trap_put_long(ctx, resaddr + 0x16, lib_init); resaddr += 0x1A; return resaddr; } diff --git a/traps.cpp b/traps.cpp index 37d76466..48760ae7 100644 --- a/traps.cpp +++ b/traps.cpp @@ -10,6 +10,8 @@ * Copyright 1996 Ed Hanway */ +#define NEW_TRAP_DEBUG 0 + #include "sysconfig.h" #include "sysdeps.h" @@ -20,6 +22,7 @@ #include "threaddep/thread.h" #include "autoconf.h" #include "traps.h" +#include "uae.h" /* * Traps are the mechanism via which 68k code can call emulator code @@ -75,6 +78,7 @@ struct Trap static struct Trap traps[MAX_TRAPS]; static unsigned int trap_count = 1; +volatile uae_atomic hwtrap_waiting; static const int trace_traps = 0; @@ -190,7 +194,6 @@ struct TrapContext { /* Trap's working copy of 68k state. This is what the trap handler should * access to get arguments from 68k space. */ - //struct regstruct regs; /* Trap handler function that gets called on the trap context */ TrapHandler trap_handler; @@ -200,7 +203,6 @@ struct TrapContext uae_u32 trap_retval; /* Copy of 68k state at trap entry. */ - //struct regstruct saved_regs; struct TrapCPUContext saved_regs; /* Thread which effects the trap context. */ @@ -215,6 +217,19 @@ struct TrapContext uaecptr call68k_func_addr; /* And this gets set to the return value of the 68k call. */ uae_u32 call68k_retval; + + /* new stuff */ + uae_u8 *host_trap_data; + uae_u8 *host_trap_status; + uaecptr amiga_trap_data; + uaecptr amiga_trap_status; + /* do not ack automatically */ + volatile int trap_background; + volatile bool trap_done; + uae_u32 calllib_regs[16]; + uae_u8 calllib_reg_inuse[16]; + int tindex; + int tcnt; }; static void copytocpucontext(struct TrapCPUContext *cpu) @@ -286,6 +301,193 @@ static void *trap_thread (void *arg) return 0; } +/* UAE board traps */ + +#define TRAP_THREADS 4 +static smp_comm_pipe trap_thread_pipe[TRAP_THREADS]; +static uae_thread_id trap_thread_id[TRAP_THREADS]; +static volatile uae_atomic trap_thread_index; +static volatile int hardware_trap_kill[RTAREA_TRAP_DATA_NUM]; +static volatile int trap_cnt; + +static void hardware_trap_ack(TrapContext *ctx) +{ + uae_u8 *data = ctx->host_trap_data; + uae_u8 *status = ctx->host_trap_status; + uaecptr addr = ctx->amiga_trap_status; + +#if NEW_TRAP_DEBUG + write_log(_T("%d: A%d\n"), ctx->tcnt, ctx->tindex); +#endif + + // ack call_hardware_trap + uaecptr task = get_long_host(data + RTAREA_TRAP_DATA_TASKWAIT); + put_byte_host(status + 2, 0xff); + if (task) { + atomic_or(&uae_int_requested, 0x4000); + set_special_exter(SPCFLAG_UAEINT); + } + xfree(ctx); +} + +static void *hardware_trap_thread(void *arg) +{ + int tid = (uae_u32)arg; + for (;;) { + TrapContext *ctx = (TrapContext*)read_comm_pipe_pvoid_blocking(&trap_thread_pipe[tid]); + if (!ctx) + break; + uae_u8 *data = ctx->host_trap_data; + uae_u8 *status = ctx->host_trap_status; + ctx->tindex = tid; + ctx->tcnt = ++trap_cnt; + + for (int i = 0; i < 15; i++) { + uae_u32 v = get_long_host(data + 4 + i * 4); + ctx->saved_regs.regs[i] = v; + } + put_long_host(status + RTAREA_TRAP_STATUS_SECOND, 0); + + int trap_num = get_word_host(status); + struct Trap *trap = &traps[trap_num]; + +#if NEW_TRAP_DEBUG + if (_tcscmp(trap->name, _T("exter_int_helper"))) + write_log(_T("%d: T%d,%d,%08x\n"), ctx->tcnt, tid, trap_num, trap->addr); +#endif + + uae_u32 ret = trap->handler(ctx); + + if (!ctx->trap_background) { + for (int i = 0; i < 15; i++) { + uae_u32 v = ctx->saved_regs.regs[i]; + put_long_host(data + 4 + i * 4, v); + } + if ((trap->flags & TRAPFLAG_NO_RETVAL) == 0) { + put_long_host(data + 4, ret); + } + + hardware_trap_ack(ctx); + } else { + ctx->trap_done = true; + } + } + hardware_trap_kill[tid] = -1; + return 0; +} + +void trap_background_set_complete(TrapContext *ctx) +{ + if (!trap_is_indirect()) + return; + if (!ctx || !ctx->trap_background) + return; + ctx->trap_background--; + if (!ctx->trap_background) { + while (!ctx->trap_done); + hardware_trap_ack(ctx); + } +} + +void call_hardware_trap(uae_u8 *host_base, uaecptr amiga_base, int slot) +{ + TrapContext *ctx = xcalloc(TrapContext, 1); + ctx->host_trap_data = host_base + RTAREA_TRAP_DATA + slot * RTAREA_TRAP_DATA_SLOT_SIZE; + ctx->amiga_trap_data = amiga_base + RTAREA_TRAP_DATA + slot * RTAREA_TRAP_DATA_SLOT_SIZE; + ctx->host_trap_status = host_base + RTAREA_TRAP_STATUS + slot * RTAREA_TRAP_STATUS_SIZE; + ctx->amiga_trap_status = amiga_base + RTAREA_TRAP_STATUS + slot * RTAREA_TRAP_STATUS_SIZE; + uae_u32 idx = atomic_inc(&trap_thread_index) & (TRAP_THREADS - 1); + write_comm_pipe_pvoid(&trap_thread_pipe[idx], ctx, 1); +} + +extern HANDLE hardware_trap_event[]; + +#define MAX_OUTTRAPS 1 + +static struct TrapContext outtrap[MAX_OUTTRAPS]; +static volatile uae_atomic outtrap_alloc[MAX_OUTTRAPS]; + +static uae_u32 call_hardware_trap_back(TrapContext *ctx, uae_u16 cmd, uae_u32 p1, uae_u32 p2, uae_u32 p3, uae_u32 p4) +{ + bool sendmode = false; + + if (ctx == NULL) { + int slot = 0; + // now this gets even more tricky.. + if (atomic_inc(&outtrap_alloc[slot])) { + write_log(_T("already allocated!!\n")); + return 0; + } + ctx = &outtrap[slot]; + ctx->host_trap_data = rtarea_bank.baseaddr + RTAREA_TRAP_SEND_DATA + slot * RTAREA_TRAP_DATA_SLOT_SIZE; + ctx->amiga_trap_data = rtarea_base + RTAREA_TRAP_DATA + slot * RTAREA_TRAP_DATA_SLOT_SIZE; + ctx->host_trap_status = rtarea_bank.baseaddr + RTAREA_TRAP_SEND_STATUS + slot * RTAREA_TRAP_STATUS_SIZE; + ctx->amiga_trap_status = rtarea_base + RTAREA_TRAP_SEND_STATUS + slot * RTAREA_TRAP_STATUS_SIZE; + + sendmode = true; + } + + uae_u8 *data = ctx->host_trap_data + RTAREA_TRAP_DATA_SECOND; + uae_u8 *status = ctx->host_trap_status + RTAREA_TRAP_STATUS_SECOND; + + int trap_slot = ((ctx->amiga_trap_data & 0xffff) - RTAREA_TRAP_DATA) / RTAREA_TRAP_DATA_SLOT_SIZE; + +#if NEW_TRAP_DEBUG + write_log(_T("%d: B%dS%d\n"), ctx->tcnt, cmd, trap_slot); +#endif + + put_long_host(data + 4, p1); + put_long_host(data + 8, p2); + put_long_host(data + 12, p3); + put_long_host(data + 16, p4); + put_word_host(status, cmd); + + atomic_inc(&hwtrap_waiting); + atomic_or(&uae_int_requested, 0x2000); + set_special_exter(SPCFLAG_UAEINT); + + volatile uae_u8 *d = status + 3; + + *d = 0xff; + + if (sendmode) { + + write_log(_T("sendmode!\n")); + + } else { + + for (;;) { + if (hardware_trap_kill[trap_slot] == 0xff) + return 0; + uae_u8 v = *d; + if (v == 0x01 || v == 0x02) + break; + if (hardware_trap_kill[trap_slot] == 0) { + hardware_trap_kill[trap_slot] = 2; + return 0; + } + // FIXME: OS specific code! + if (WaitForSingleObject(hardware_trap_event[trap_slot], 100) == WAIT_ABANDONED) { + hardware_trap_kill[trap_slot] = 3; + return 0; + } + } + + } + + // get result + uae_u32 v = get_long_host(data + 4); + + put_long_host(status, 0); + +#if NEW_TRAP_DEBUG + write_log(_T("%d: =%08x\n"), ctx->tcnt, v, hwtrap_waiting); +#endif + + return v; +} + + /* * Set up extended trap context and call handler function */ @@ -324,36 +526,43 @@ static void trap_HandleExtendedTrap (TrapHandler handler_func, int has_retval) * * This function is to be called from the trap context. */ -static uae_u32 trap_Call68k (TrapContext *context, uaecptr func_addr) +static uae_u32 trap_Call68k(TrapContext *ctx, uaecptr func_addr) { - /* Enter critical section - only one trap at a time, please! */ - uae_sem_wait (&trap_mutex); - current_context = context; + if (ctx->host_trap_data) { - /* Don't allow an interrupt and thus potentially another - * trap to be invoked while we hold the above mutex. - * This is probably just being paranoid. */ - regs.intmask = 7; + return call_hardware_trap_back(ctx, 10, func_addr, 0, 0, 0); - /* Set up function call address. */ - context->call68k_func_addr = func_addr; + } else { - /* Set PC to address of 68k call trap, so that it will be - * executed when emulator context resumes. */ - m68k_setpc (m68k_call_trapaddr); - fill_prefetch (); + /* Enter critical section - only one trap at a time, please! */ + uae_sem_wait (&trap_mutex); + current_context = ctx; - /* Switch to emulator context. */ - uae_sem_post (&context->switch_to_emu_sem); + /* Don't allow an interrupt and thus potentially another + * trap to be invoked while we hold the above mutex. + * This is probably just being paranoid. */ + regs.intmask = 7; - /* Wait for 68k call return handler to switch back to us. */ - uae_sem_wait (&context->switch_to_trap_sem); + /* Set up function call address. */ + ctx->call68k_func_addr = func_addr; - /* End critical section. */ - uae_sem_post (&trap_mutex); + /* Set PC to address of 68k call trap, so that it will be + * executed when emulator context resumes. */ + m68k_setpc (m68k_call_trapaddr); + fill_prefetch (); - /* Get return value from 68k function called. */ - return context->call68k_retval; + /* Switch to emulator context. */ + uae_sem_post (&ctx->switch_to_emu_sem); + + /* Wait for 68k call return handler to switch back to us. */ + uae_sem_wait (&ctx->switch_to_trap_sem); + + /* End critical section. */ + uae_sem_post (&trap_mutex); + + /* Get return value from 68k function called. */ + return ctx->call68k_retval; + } } /* @@ -464,14 +673,14 @@ static uae_u32 REGPARAM2 exit_trap_handler (TrapContext *dummy_ctx) /* * Call a 68k library function from extended trap. */ -uae_u32 CallLib (TrapContext *context, uaecptr base, uae_s16 offset) +uae_u32 CallLib(TrapContext *ctx, uaecptr base, uae_s16 offset) { uae_u32 retval; - uaecptr olda6 = m68k_areg (regs, 6); + uaecptr olda6 = trap_get_areg(ctx, 6); - m68k_areg (regs, 6) = base; - retval = trap_Call68k (context, base + offset); - m68k_areg (regs, 6) = olda6; + trap_set_areg(ctx, 6, base); + retval = trap_Call68k(ctx, base + offset); + trap_set_areg(ctx, 6, olda6); return retval; } @@ -479,18 +688,44 @@ uae_u32 CallLib (TrapContext *context, uaecptr base, uae_s16 offset) /* * Call 68k function from extended trap. */ -uae_u32 CallFunc (TrapContext *context, uaecptr func) +uae_u32 CallFunc(TrapContext *ctx, uaecptr func) { - return trap_Call68k (context, func); + return trap_Call68k(ctx, func); } /* * Initialize trap mechanism. */ -void init_traps (void) +void init_traps(void) { trap_count = 0; + hwtrap_waiting = 0; + if (!trap_thread_id[0] && trap_is_indirect()) { + for (int i = 0; i < TRAP_THREADS; i++) { + init_comm_pipe(&trap_thread_pipe[i], 100, 1); + hardware_trap_kill[i] = 1; + uae_start_thread_fast(hardware_trap_thread, (void *)i, &trap_thread_id[i]); + } + } +} + +void free_traps(void) +{ + for (int i = 0; i < TRAP_THREADS; i++) { + if (trap_thread_id[i]) { + if (hardware_trap_kill[i] >= 0) { + hardware_trap_kill[i] = 0; + write_comm_pipe_pvoid(&trap_thread_pipe[i], NULL, 1); + while (hardware_trap_kill[i] == 0) { + sleep_millis(1); + } + } + destroy_comm_pipe(&trap_thread_pipe[i]); + uae_end_thread(&trap_thread_id[i]); + trap_thread_id[i] = NULL; + } + } } /* @@ -509,3 +744,555 @@ void init_extended_traps (void) uae_sem_init (&trap_mutex, 0, 1); } + + +void trap_call_add_dreg(TrapContext *ctx, int reg, uae_u32 v) +{ + ctx->calllib_reg_inuse[reg] = 1; + ctx->calllib_regs[reg] = v; +} +void trap_call_add_areg(TrapContext *ctx, int reg, uae_u32 v) +{ + ctx->calllib_reg_inuse[reg + 8] = 1; + ctx->calllib_regs[reg + 8] = v; +} +uae_u32 trap_call_lib(TrapContext *ctx, uaecptr base, uae_s16 offset) +{ + uae_u32 v; + if (ctx && ctx->host_trap_data) { + uae_u8 *p = ctx->host_trap_data + RTAREA_TRAP_DATA_EXTRA; + for (int i = 0; i < 16; i++) { + if (ctx->calllib_reg_inuse[i]) { + put_long_host(p , ctx->calllib_regs[i]); + ctx->calllib_reg_inuse[i] = 0; + } else { + put_long_host(p, ctx->saved_regs.regs[i]); + } + p += 4; + } + v = call_hardware_trap_back(ctx, TRAPCMD_CALL_LIB, base, offset, ctx->amiga_trap_data + RTAREA_TRAP_DATA_EXTRA, 0); + } else { + uae_u32 storedregs[16]; + bool storedregsused[16]; + for (int i = 0; i < 16; i++) { + storedregsused[i] = false; + if (ctx->calllib_reg_inuse[i]) { + if ((i & 7) >= 2) { + storedregsused[i] = true; + storedregs[i] = regs.regs[i]; + } + regs.regs[i] = ctx->calllib_regs[i]; + } + ctx->calllib_reg_inuse[i] = 0; + } + v = CallLib(ctx, base, offset); + for (int i = 0; i < 16; i++) { + if (storedregsused[i]) { + regs.regs[i] = storedregs[i]; + } + } + } + return v; +} +uae_u32 trap_call_func(TrapContext *ctx, uaecptr func) +{ + uae_u32 v; + if (ctx && ctx->host_trap_data) { + uae_u8 *p = ctx->host_trap_data + RTAREA_TRAP_DATA_EXTRA; + for (int i = 0; i < 16; i++) { + if (ctx->calllib_reg_inuse[i]) { + put_long_host(p, ctx->calllib_regs[i]); + ctx->calllib_reg_inuse[i] = 0; + } else { + put_long_host(p, ctx->saved_regs.regs[i]); + } + p += 4; + } + v = call_hardware_trap_back(ctx, TRAPCMD_CALL_FUNC, func, ctx->amiga_trap_data + RTAREA_TRAP_DATA_EXTRA, 0, 0); + } else { + uae_u32 storedregs[16]; + bool storedregsused[16]; + for (int i = 0; i < 16; i++) { + storedregsused[i] = false; + if (ctx->calllib_reg_inuse[i]) { + if ((i & 7) >= 2) { + storedregsused[i] = true; + storedregs[i] = regs.regs[i]; + } + regs.regs[i] = ctx->calllib_regs[i]; + } + ctx->calllib_reg_inuse[i] = 0; + } + v = CallFunc(ctx, func); + for (int i = 0; i < 16; i++) { + if (storedregsused[i]) { + regs.regs[i] = storedregs[i]; + } + } + } + return v; +} + + +void trap_set_background(TrapContext *ctx) +{ + if (!trap_is_indirect()) + return; + ctx->trap_background++; +} + +bool trap_is_indirect(void) +{ + return currprefs.uaeboard > 2; +} + +bool trap_valid_address(TrapContext *ctx, uaecptr addr, uae_u32 size) +{ + if (!ctx || currprefs.uaeboard < 3) + return valid_address(addr, size) != 0; + // can't really do any checks.. + return true; +} + +uae_u32 trap_get_dreg(TrapContext *ctx, int reg) +{ + if (trap_is_indirect()) { + if (!ctx) { + write_log(_T("trap_get_dreg() without TrapContext!\n")); + return 0; + } + return ctx->saved_regs.regs[reg]; + } else { + return m68k_dreg(regs, reg); + } +} +uae_u32 trap_get_areg(TrapContext *ctx, int reg) +{ + if (trap_is_indirect()) { + if (!ctx) { + write_log(_T("trap_get_areg() without TrapContext!\n")); + return 0; + } + return ctx->saved_regs.regs[reg + 8]; + } else { + return m68k_areg(regs, reg); + } +} +void trap_set_dreg(TrapContext *ctx, int reg, uae_u32 v) +{ + if (trap_is_indirect()) { + if (!ctx) { + write_log(_T("trap_set_dreg() without TrapContext!\n")); + return; + } + ctx->saved_regs.regs[reg] = v; + } else { + m68k_dreg(regs, reg) = v; + } +} +void trap_set_areg(TrapContext *ctx, int reg, uae_u32 v) +{ + if (trap_is_indirect()) { + if (!ctx) { + write_log(_T("trap_set_areg() without TrapContext!\n")); + return; + } + ctx->saved_regs.regs[reg + 8] = v; + } else { + m68k_areg(regs, reg) = v; + } +} + +void trap_put_long(TrapContext *context, uaecptr addr, uae_u32 v) +{ + if (trap_is_indirect()) { + call_hardware_trap_back(context, TRAPCMD_PUT_LONG, addr, v, 0, 0); + } else { + put_long(addr, v); + } +} +void trap_put_word(TrapContext *context, uaecptr addr, uae_u16 v) +{ + if (trap_is_indirect()) { + call_hardware_trap_back(context, TRAPCMD_PUT_WORD, addr, v, 0, 0); + } else { + put_word(addr, v); + } +} +void trap_put_byte(TrapContext *context, uaecptr addr, uae_u8 v) +{ + if (trap_is_indirect()) { + call_hardware_trap_back(context, TRAPCMD_PUT_BYTE, addr, v, 0, 0); + } else { + put_byte(addr, v); + } +} + +uae_u32 trap_get_long(TrapContext *context, uaecptr addr) +{ + if (trap_is_indirect()) { + return call_hardware_trap_back(context, TRAPCMD_GET_LONG, addr, 0, 0, 0); + } else { + return get_long(addr); + } +} +uae_u16 trap_get_word(TrapContext *context, uaecptr addr) +{ + if (trap_is_indirect()) { + return call_hardware_trap_back(context, TRAPCMD_GET_WORD, addr, 0, 0, 0); + } else { + return get_word(addr); + } +} +uae_u8 trap_get_byte(TrapContext *context, uaecptr addr) +{ + if (trap_is_indirect()) { + return call_hardware_trap_back(context, TRAPCMD_GET_BYTE, addr, 0, 0, 0); + } else { + return get_byte(addr); + } +} + +void trap_put_bytes(TrapContext *context, void *haddrp, uaecptr addr, int cnt) +{ + if (!cnt) + return; + uae_u8 *haddr = (uae_u8*)haddrp; + if (trap_is_indirect()) { + while (cnt > 0) { + int max = cnt > RTAREA_TRAP_DATA_EXTRA_SIZE ? RTAREA_TRAP_DATA_EXTRA_SIZE : cnt; + memcpy(context->host_trap_data + RTAREA_TRAP_DATA_EXTRA, haddr, max); + call_hardware_trap_back(context, TRAPCMD_PUT_BYTES, context->amiga_trap_data + RTAREA_TRAP_DATA_EXTRA, addr, max, 0); + haddr += max; + addr += max; + cnt -= max; + } + } else { + if (valid_address(addr, cnt)) { + memcpy(get_real_address(addr), haddr, cnt); + } else { + for (int i = 0; i < cnt; i++) { + put_byte(addr, *haddr++); + addr++; + } + } + } +} +void trap_get_bytes(TrapContext *context, void *haddrp, uaecptr addr, int cnt) +{ + if (!cnt) + return; + uae_u8 *haddr = (uae_u8*)haddrp; + if (trap_is_indirect()) { + while (cnt > 0) { + int max = cnt > RTAREA_TRAP_DATA_EXTRA_SIZE ? RTAREA_TRAP_DATA_EXTRA_SIZE : cnt; + call_hardware_trap_back(context, TRAPCMD_PUT_BYTES, addr, context->amiga_trap_data + RTAREA_TRAP_DATA_EXTRA, max, 0); + memcpy(haddr, context->host_trap_data + RTAREA_TRAP_DATA_EXTRA, max); + haddr += max; + addr += max; + cnt -= max; + } + } else { + if (valid_address(addr, cnt)) { + memcpy(haddr, get_real_address(addr), cnt); + } else { + for (int i = 0; i < cnt; i++) { + *haddr++ = get_byte(addr); + addr++; + } + } + } +} +void trap_put_longs(TrapContext *context, uae_u32 *haddr, uaecptr addr, int cnt) +{ + if (!cnt) + return; + if (trap_is_indirect()) { + while (cnt > 0) { + int max = cnt > RTAREA_TRAP_DATA_EXTRA_SIZE / sizeof(uae_u32) ? RTAREA_TRAP_DATA_EXTRA_SIZE / sizeof(uae_u32) : cnt; + for (int i = 0; i < max; i++) { + put_long_host(context->host_trap_data + RTAREA_TRAP_DATA_EXTRA + i * sizeof(uae_u32), *haddr++); + } + call_hardware_trap_back(context, TRAPCMD_PUT_LONGS, context->amiga_trap_data + RTAREA_TRAP_DATA_EXTRA, addr, max, 0); + addr += max * sizeof(uae_u32); + cnt -= max; + } + } else { + uae_u32 *p = (uae_u32*)haddr; + for (int i = 0; i < cnt; i++) { + put_long(addr, *p++); + addr += 4; + } + } +} +void trap_get_longs(TrapContext *context, uae_u32 *haddr, uaecptr addr, int cnt) +{ + if (!cnt) + return; + if (trap_is_indirect()) { + while (cnt > 0) { + int max = cnt > RTAREA_TRAP_DATA_EXTRA_SIZE / sizeof(uae_u32) ? RTAREA_TRAP_DATA_EXTRA_SIZE / sizeof(uae_u32) : cnt; + call_hardware_trap_back(context, TRAPCMD_GET_LONGS, addr, context->amiga_trap_data + RTAREA_TRAP_DATA_EXTRA, max, 0); + for (int i = 0; i < max; i++) { + *haddr++ = get_long_host(context->host_trap_data + RTAREA_TRAP_DATA_EXTRA + i * sizeof(uae_u32)); + } + addr += max * sizeof(uae_u32); + cnt -= max; + } + } else { + uae_u32 *p = (uae_u32*)haddr; + for (int i = 0; i < cnt; i++) { + *p++ = get_long(addr); + addr += 4; + } + } +} +void trap_put_words(TrapContext *context, uae_u16 *haddr, uaecptr addr, int cnt) +{ + if (!cnt) + return; + if (trap_is_indirect()) { + while (cnt > 0) { + int max = cnt > RTAREA_TRAP_DATA_EXTRA_SIZE / sizeof(uae_u16) ? RTAREA_TRAP_DATA_EXTRA_SIZE / sizeof(uae_u16) : cnt; + for (int i = 0; i < max; i++) { + put_word_host(context->host_trap_data + RTAREA_TRAP_DATA_EXTRA + i * sizeof(uae_u16), *haddr++); + } + call_hardware_trap_back(context, TRAPCMD_PUT_WORDS, context->amiga_trap_data + RTAREA_TRAP_DATA_EXTRA, addr, max, 0); + addr += max * sizeof(uae_u16); + cnt -= max; + } + } else { + uae_u16 *p = (uae_u16*)haddr; + for (int i = 0; i < cnt; i++) { + put_word(addr, *p++); + addr += sizeof(uae_u16); + } + } +} +void trap_get_words(TrapContext *context, uae_u16 *haddr, uaecptr addr, int cnt) +{ + if (!cnt) + return; + if (trap_is_indirect()) { + while (cnt > 0) { + int max = cnt > RTAREA_TRAP_DATA_EXTRA_SIZE / sizeof(uae_u16) ? RTAREA_TRAP_DATA_EXTRA_SIZE / sizeof(uae_u16) : cnt; + call_hardware_trap_back(context, TRAPCMD_GET_WORDS, addr, context->amiga_trap_data + RTAREA_TRAP_DATA_EXTRA, max, 0); + for (int i = 0; i < max; i++) { + *haddr++ = get_word_host(context->host_trap_data + RTAREA_TRAP_DATA_EXTRA + i * sizeof(uae_u16)); + } + addr += max * sizeof(uae_u16); + cnt -= max; + } + } else { + uae_u16 *p = (uae_u16*)haddr; + for (int i = 0; i < cnt; i++) { + *p++ = get_word(addr); + addr += sizeof(uae_u16); + } + } +} + +int trap_put_string(TrapContext *context, void *haddrp, uaecptr addr, int maxlen) +{ + int len = 0; + uae_u8 *haddr = (uae_u8*)haddrp; + if (trap_is_indirect()) { + uae_u8 *p = context->host_trap_data + RTAREA_TRAP_DATA_EXTRA; + for (;;) { + uae_u8 v = *haddr++; + *p++ = v; + if (!v) + break; + len++; + } + call_hardware_trap_back(context, TRAPCMD_PUT_STRING, context->amiga_trap_data + RTAREA_TRAP_DATA_EXTRA, addr, maxlen, 0); + } else { + for (;;) { + uae_u8 v = *haddr++; + put_byte(addr, v); + addr++; + if (!v) + break; + len++; + } + } + return len; +} +int trap_get_string(TrapContext *context, void *haddrp, uaecptr addr, int maxlen) +{ + int len = 0; + uae_u8 *haddr = (uae_u8*)haddrp; + if (trap_is_indirect()) { + uae_u8 *p = context->host_trap_data + RTAREA_TRAP_DATA_EXTRA; + call_hardware_trap_back(context, TRAPCMD_GET_STRING, addr, context->amiga_trap_data + RTAREA_TRAP_DATA_EXTRA, maxlen, 0); + for (;;) { + uae_u8 v = *p++; + *haddr++ = v; + if (!v) + break; + len++; + } + } else { + for (;;) { + uae_u8 v = get_byte(addr); + *haddr++ = v; + addr++; + if (!v) + break; + } + len++; + } + return len; +} +int trap_get_bstr(TrapContext *context, uae_u8 *haddr, uaecptr addr, int maxlen) +{ + int len = 0; + if (trap_is_indirect()) { + uae_u8 *p = context->host_trap_data + RTAREA_TRAP_DATA_EXTRA; + call_hardware_trap_back(context, TRAPCMD_GET_BSTR, addr, context->amiga_trap_data + RTAREA_TRAP_DATA_EXTRA, maxlen, 0); + for (;;) { + uae_u8 v = *p++; + *haddr++ = v; + if (!v) + break; + len++; + } + } else { + uae_u8 cnt = get_byte(addr); + while (cnt-- != 0 && maxlen-- > 0) { + addr++; + *haddr++ = get_byte(addr); + } + *haddr = 0; + } + return len; +} + +void trap_set_longs(TrapContext *ctx, uaecptr addr, uae_u32 v, int cnt) +{ + if (!cnt) + return; + if (trap_is_indirect()) { + call_hardware_trap_back(ctx, TRAPCMD_SET_LONGS, addr, v, cnt, 0); + } else { + for (int i = 0; i < cnt; i++) { + put_long(addr, v); + addr += 4; + } + } +} +void trap_set_words(TrapContext *ctx, uaecptr addr, uae_u16 v, int cnt) +{ + if (!cnt) + return; + if (trap_is_indirect()) { + call_hardware_trap_back(ctx, TRAPCMD_SET_WORDS, addr, v, cnt, 0); + } else { + for (int i = 0; i < cnt; i++) { + put_word(addr, v); + addr += 2; + } + } +} +void trap_set_bytes(TrapContext *ctx, uaecptr addr, uae_u8 v, int cnt) +{ + if (!cnt) + return; + if (trap_is_indirect()) { + call_hardware_trap_back(ctx, TRAPCMD_SET_BYTES, addr, v, cnt, 0); + } else { + for (int i = 0; i < cnt; i++) { + put_byte(addr, v); + addr += 1; + } + } +} + +void trap_multi(TrapContext *ctx, struct trapmd *data, int items) +{ + if (trap_is_indirect()) { + uae_u8 *p = ctx->host_trap_data + RTAREA_TRAP_DATA_EXTRA; + for (int i = 0; i < items; i++) { + struct trapmd *md = &data[i]; + put_word_host(p + 0, md->cmd); + put_byte_host(p + 2, md->trapmd_index); + put_byte_host(p + 3, md->parm_num); + put_long_host(p + 4, md->params[0]); + put_long_host(p + 8, md->params[1]); + put_long_host(p + 12, md->params[2]); + put_long_host(p + 16, md->params[3]); + p += 5 * 4; + } + call_hardware_trap_back(ctx, TRAPCMD_MULTI, ctx->amiga_trap_data + RTAREA_TRAP_DATA_EXTRA, items, 0, 0); + p = ctx->host_trap_data + RTAREA_TRAP_DATA_EXTRA; + for (int i = 0; i < items; i++) { + struct trapmd *md = &data[i]; + md->params[0] = get_long_host(p + 4); + p += 5 * 4; + } + } else { + uae_u32 v = 0; + for (int i = 0; i < items; i++) { + struct trapmd *md = &data[i]; + switch (md->cmd) + { + case TRAPCMD_PUT_LONG: + trap_put_long(ctx, md->params[0], md->params[1]); + break; + case TRAPCMD_PUT_WORD: + trap_put_word(ctx, md->params[0], md->params[1]); + break; + case TRAPCMD_PUT_BYTE: + trap_put_byte(ctx, md->params[0], md->params[1]); + break; + case TRAPCMD_GET_LONG: + v = md->params[0] = trap_get_long(ctx, md->params[0]); + break; + case TRAPCMD_GET_WORD: + v = md->params[0] = trap_get_word(ctx, md->params[0]); + break; + case TRAPCMD_GET_BYTE: + v = md->params[0] = trap_get_byte(ctx, md->params[0]); + break; + case TRAPCMD_PUT_BYTES: + trap_put_bytes(ctx, md->haddr, md->params[0], md->params[1]); + break; + case TRAPCMD_GET_BYTES: + trap_get_bytes(ctx, md->haddr, md->params[0], md->params[1]); + break; + case TRAPCMD_PUT_WORDS: + trap_put_words(ctx, (uae_u16*)md->haddr, md->params[0], md->params[1]); + break; + case TRAPCMD_GET_WORDS: + trap_get_words(ctx, (uae_u16*)md->haddr, md->params[0], md->params[1]); + break; + case TRAPCMD_PUT_LONGS: + trap_put_longs(ctx, (uae_u32*)md->haddr, md->params[0], md->params[1]); + break; + case TRAPCMD_GET_LONGS: + trap_get_longs(ctx, (uae_u32*)md->haddr, md->params[0], md->params[1]); + break; + case TRAPCMD_PUT_STRING: + trap_put_string(ctx, md->haddr, md->params[0], md->params[1]); + break; + case TRAPCMD_GET_STRING: + trap_get_string(ctx, md->haddr, md->params[0], md->params[1]); + break; + case TRAPCMD_SET_LONGS: + trap_set_longs(ctx, md->params[0], md->params[1], md->params[2]); + break; + case TRAPCMD_SET_WORDS: + trap_set_words(ctx, md->params[0], md->params[1], md->params[2]); + break; + case TRAPCMD_SET_BYTES: + trap_set_bytes(ctx, md->params[0], md->params[1], md->params[2]); + break; + case TRAPCMD_NOP: + break; + } + if (md->trapmd_index) { + data[md->trapmd_index].params[md->parm_num] = v; + } + } + } +} diff --git a/uaeexe.cpp b/uaeexe.cpp index 5244aeb9..8a179d91 100644 --- a/uaeexe.cpp +++ b/uaeexe.cpp @@ -104,8 +104,8 @@ static TCHAR *get_cmd (void) /* * helper function */ -#define ARG(x) (get_long (m68k_areg (regs, 7) + 4 * (x + 1))) -static uae_u32 REGPARAM2 uaeexe_server (TrapContext *context) +#define ARG(x) (trap_get_long(ctx, trap_get_areg(ctx, 7) + 4 * (x + 1))) +static uae_u32 REGPARAM2 uaeexe_server (TrapContext *ctx) { int len; TCHAR *cmd; diff --git a/uaelib.cpp b/uaelib.cpp index 57a1b9bd..3ff8f5ae 100644 --- a/uaelib.cpp +++ b/uaelib.cpp @@ -130,14 +130,14 @@ static uae_u32 emulib_ChangeLanguage (uae_u32 which) * Changes chip memory size * (reboots) */ -static uae_u32 REGPARAM2 emulib_ChgCMemSize (uae_u32 memsize) +static uae_u32 REGPARAM2 emulib_ChgCMemSize(TrapContext *ctx, uae_u32 memsize) { if (memsize != 0x80000 && memsize != 0x100000 && memsize != 0x200000) { memsize = 0x200000; write_log (_T("Unsupported chipmem size!\n")); } - m68k_dreg (regs, 0) = 0; + trap_set_dreg(ctx, 0, 0); changed_prefs.chipmem_size = memsize; uae_reset(1, 1); @@ -148,7 +148,7 @@ static uae_u32 REGPARAM2 emulib_ChgCMemSize (uae_u32 memsize) * Changes slow memory size * (reboots) */ -static uae_u32 REGPARAM2 emulib_ChgSMemSize (uae_u32 memsize) +static uae_u32 REGPARAM2 emulib_ChgSMemSize(TrapContext *ctx, uae_u32 memsize) { if (memsize != 0x80000 && memsize != 0x100000 && memsize != 0x180000 && memsize != 0x1C0000) { @@ -156,7 +156,7 @@ static uae_u32 REGPARAM2 emulib_ChgSMemSize (uae_u32 memsize) write_log (_T("Unsupported bogomem size!\n")); } - m68k_dreg (regs, 0) = 0; + trap_set_dreg(ctx, 0, 0); changed_prefs.bogomem_size = memsize; uae_reset (1, 1); return 1; @@ -166,14 +166,14 @@ static uae_u32 REGPARAM2 emulib_ChgSMemSize (uae_u32 memsize) * Changes fast memory size * (reboots) */ -static uae_u32 REGPARAM2 emulib_ChgFMemSize (uae_u32 memsize) +static uae_u32 REGPARAM2 emulib_ChgFMemSize(TrapContext *ctx, uae_u32 memsize) { if (memsize != 0x100000 && memsize != 0x200000 && memsize != 0x400000 && memsize != 0x800000) { memsize = 0; write_log (_T("Unsupported fastmem size!\n")); } - m68k_dreg (regs, 0) = 0; + trap_set_dreg(ctx, 0, 0); changed_prefs.fastmem_size = memsize; uae_reset (1, 1); return 0; @@ -182,19 +182,15 @@ static uae_u32 REGPARAM2 emulib_ChgFMemSize (uae_u32 memsize) /* * Inserts a disk */ -static uae_u32 emulib_InsertDisk (uaecptr name, uae_u32 drive) +static uae_u32 emulib_InsertDisk(TrapContext *ctx, uaecptr name, uae_u32 drive) { - int i = 0; char real_name[256]; TCHAR *s; if (drive > 3) return 0; - while ((real_name[i] = get_byte (name + i)) != 0 && i++ != 254) - ; - - if (i == 255) + if (trap_get_string(ctx, real_name, name, sizeof real_name) >= sizeof real_name) return 0; /* ENAMETOOLONG */ s = au (real_name); @@ -207,7 +203,7 @@ static uae_u32 emulib_InsertDisk (uaecptr name, uae_u32 drive) /* * Exits the emulator */ -static uae_u32 emulib_ExitEmu (void) +static uae_u32 emulib_ExitEmu(void) { uae_quit (); return 1; @@ -216,39 +212,36 @@ static uae_u32 emulib_ExitEmu (void) /* * Gets UAE Configuration */ -static uae_u32 emulib_GetUaeConfig (uaecptr place) +static uae_u32 emulib_GetUaeConfig(TrapContext *ctx, uaecptr place) { - int i, j; - - put_long (place, version); - put_long (place + 4, chipmem_bank.allocated); - put_long (place + 8, bogomem_bank.allocated); - put_long (place + 12, fastmem_bank.allocated); - put_long (place + 16, currprefs.gfx_framerate); - put_long (place + 20, currprefs.produce_sound); - put_long (place + 24, currprefs.jports[0].id | (currprefs.jports[1].id << 8)); - put_long (place + 28, currprefs.keyboard_lang); + trap_put_long(ctx, place, version); + trap_put_long(ctx, place + 4, chipmem_bank.allocated); + trap_put_long(ctx, place + 8, bogomem_bank.allocated); + trap_put_long(ctx, place + 12, fastmem_bank.allocated); + trap_put_long(ctx, place + 16, currprefs.gfx_framerate); + trap_put_long(ctx, place + 20, currprefs.produce_sound); + trap_put_long(ctx, place + 24, currprefs.jports[0].id | (currprefs.jports[1].id << 8)); + trap_put_long(ctx, place + 28, currprefs.keyboard_lang); if (disk_empty (0)) - put_byte (place + 32, 0); + trap_put_byte(ctx, place + 32, 0); else - put_byte (place + 32, 1); + trap_put_byte(ctx, place + 32, 1); if (disk_empty (1)) - put_byte (place + 33, 0); + trap_put_byte(ctx, place + 33, 0); else - put_byte (place + 33, 1); + trap_put_byte(ctx, place + 33, 1); if (disk_empty(2)) - put_byte (place + 34, 0); + trap_put_byte(ctx, place + 34, 0); else - put_byte (place + 34, 1); + trap_put_byte(ctx, place + 34, 1); if (disk_empty(3)) - put_byte (place + 35, 0); + trap_put_byte(ctx, place + 35, 0); else - put_byte (place + 35, 1); + trap_put_byte(ctx, place + 35, 1); - for (j = 0; j < 4; j++) { - char *s = ua (currprefs.floppyslots[j].df); - for (i = 0; i < 256; i++) - put_byte (place + 36 + i + j * 256, s[i]); + for (int i = 0; i < 4; i++) { + char *s = ua (currprefs.floppyslots[i].df); + trap_put_string(ctx, s, place + 36 + i * 256, 256); xfree (s); } return 1; @@ -259,7 +252,7 @@ static uae_u32 emulib_GetUaeConfig (uaecptr place) * * NOT IMPLEMENTED YET */ -static uae_u32 emulib_SetUaeConfig (uaecptr place) +static uae_u32 emulib_SetUaeConfig(uaecptr place) { return 1; } @@ -267,22 +260,21 @@ static uae_u32 emulib_SetUaeConfig (uaecptr place) /* * Gets the name of the disk in the given drive */ -static uae_u32 emulib_GetDisk (uae_u32 drive, uaecptr name) +static uae_u32 emulib_GetDisk(TrapContext *ctx, uae_u32 drive, uaecptr name) { - int i; if (drive > 3) return 0; - for (i = 0; i < 256; i++) { - put_byte (name + i, currprefs.floppyslots[drive].df[i]); - } + char *n = ua(currprefs.floppyslots[drive].df); + trap_put_string(ctx, (uae_u8*)n, name, 256); + xfree(n); return 1; } /* * Enter debugging state */ -static uae_u32 emulib_Debug (void) +static uae_u32 emulib_Debug(void) { #ifdef DEBUGGER activate_debugger (); @@ -337,48 +329,45 @@ static uae_u32 emulib_Minimize (void) return 0; // OSDEP_minimize_uae(); } -static int native_dos_op (uae_u32 mode, uae_u32 p1, uae_u32 p2, uae_u32 p3) +static int native_dos_op(TrapContext *ctx, uae_u32 mode, uae_u32 p1, uae_u32 p2, uae_u32 p3) { TCHAR tmp[MAX_DPATH]; char *s; - int v, i; + int v; if (mode) return -1; /* receive native path from lock * p1 = dos.library:Lock, p2 = buffer, p3 = max buffer size */ - v = get_native_path (p1, tmp); + v = get_native_path(ctx, p1, tmp); if (v) return v; s = ua (tmp); - for (i = 0; i <= strlen (s) && i < p3 - 1; i++) { - put_byte (p2 + i, s[i]); - put_byte (p2 + i + 1, 0); - } + trap_put_string(ctx, (uae_u8*)s, p2, p3); xfree (s); return 0; } -static uae_u32 uaelib_demux_common(uae_u32 ARG0, uae_u32 ARG1, uae_u32 ARG2, uae_u32 ARG3, uae_u32 ARG4, uae_u32 ARG5) +static uae_u32 uaelib_demux_common(TrapContext *ctx, uae_u32 ARG0, uae_u32 ARG1, uae_u32 ARG2, uae_u32 ARG3, uae_u32 ARG4, uae_u32 ARG5) { switch (ARG0) { case 0: return emulib_GetVersion(); - case 1: return emulib_GetUaeConfig(ARG1); + case 1: return emulib_GetUaeConfig(ctx, ARG1); case 2: return emulib_SetUaeConfig(ARG1); case 3: return emulib_HardReset(); case 4: return emulib_Reset(); - case 5: return emulib_InsertDisk(ARG1, ARG2); + case 5: return emulib_InsertDisk(ctx, ARG1, ARG2); case 6: return emulib_EnableSound(ARG1); case 7: return emulib_EnableJoystick(ARG1); case 8: return emulib_SetFrameRate(ARG1); - case 9: return emulib_ChgCMemSize(ARG1); - case 10: return emulib_ChgSMemSize(ARG1); - case 11: return emulib_ChgFMemSize(ARG1); + case 9: return emulib_ChgCMemSize(ctx, ARG1); + case 10: return emulib_ChgSMemSize(ctx, ARG1); + case 11: return emulib_ChgFMemSize(ctx, ARG1); case 12: return emulib_ChangeLanguage(ARG1); /* The next call brings bad luck */ case 13: return emulib_ExitEmu(); - case 14: return emulib_GetDisk(ARG1, ARG2); + case 14: return emulib_GetDisk(ctx, ARG1, ARG2); case 15: return emulib_Debug(); case 68: return emulib_Minimize(); @@ -392,16 +381,18 @@ static uae_u32 uaelib_demux_common(uae_u32 ARG0, uae_u32 ARG1, uae_u32 ARG2, uae /* Disable possible ROM protection */ unprotect_maprom(); return currprefs.maprom; - case 81: return cfgfile_uaelib(ARG1, ARG2, ARG3, ARG4); - case 82: return cfgfile_uaelib_modify(ARG1, ARG2, ARG3, ARG4, ARG5); + case 81: return cfgfile_uaelib(ctx, ARG1, ARG2, ARG3, ARG4); + case 82: return cfgfile_uaelib_modify(ctx, ARG1, ARG2, ARG3, ARG4, ARG5); case 83: currprefs.mmkeyboard = ARG1 ? 1 : 0; return currprefs.mmkeyboard; #ifdef DEBUGGER case 84: return mmu_init(ARG1, ARG2, ARG3); #endif - case 85: return native_dos_op(ARG1, ARG2, ARG3, ARG4); + case 85: return native_dos_op(ctx, ARG1, ARG2, ARG3, ARG4); case 86: if (valid_address(ARG1, 1)) { - TCHAR *s = au((char*)get_real_address(ARG1)); + uae_char tmp[MAX_DPATH]; + trap_get_string(ctx, tmp, ARG1, sizeof tmp); + TCHAR *s = au(tmp); write_log(_T("DBG: %s\n"), s); xfree(s); return 1; @@ -411,7 +402,7 @@ static uae_u32 uaelib_demux_common(uae_u32 ARG0, uae_u32 ARG1, uae_u32 ARG2, uae { uae_u32 d0, d1; d0 = emulib_target_getcpurate(ARG1, &d1); - m68k_dreg(regs, 1) = d1; + trap_set_dreg(ctx, 1, d1); return d0; } @@ -429,27 +420,27 @@ uae_u32 uaeboard_demux(uae_u32 *board) arg3 = do_get_mem_long(&board[4]); arg4 = do_get_mem_long(&board[5]); arg5 = do_get_mem_long(&board[6]); - return uaelib_demux_common(arg0, arg1, arg2, arg3, arg4, arg5); + return uaelib_demux_common(NULL, arg0, arg1, arg2, arg3, arg4, arg5); } -static uae_u32 REGPARAM2 uaelib_demux2 (TrapContext *context) +static uae_u32 REGPARAM2 uaelib_demux2 (TrapContext *ctx) { -#define ARG0 (get_long (m68k_areg (regs, 7) + 4)) -#define ARG1 (get_long (m68k_areg (regs, 7) + 8)) -#define ARG2 (get_long (m68k_areg (regs, 7) + 12)) -#define ARG3 (get_long (m68k_areg (regs, 7) + 16)) -#define ARG4 (get_long (m68k_areg (regs, 7) + 20)) -#define ARG5 (get_long (m68k_areg (regs, 7) + 24)) +#define ARG0 (trap_get_long(ctx, trap_get_areg(ctx, 7) + 4)) +#define ARG1 (trap_get_long(ctx, trap_get_areg(ctx, 7) + 8)) +#define ARG2 (trap_get_long(ctx, trap_get_areg(ctx, 7) + 12)) +#define ARG3 (trap_get_long(ctx, trap_get_areg(ctx, 7) + 16)) +#define ARG4 (trap_get_long(ctx, trap_get_areg(ctx, 7) + 20)) +#define ARG5 (trap_get_long(ctx, trap_get_areg(ctx, 7) + 24)) #ifdef PICASSO96 if (ARG0 >= 16 && ARG0 <= 39) - return picasso_demux(ARG0, context); + return picasso_demux(ARG0, ctx); #endif - return uaelib_demux_common(ARG0, ARG1, ARG2, ARG3, ARG4, ARG5); + return uaelib_demux_common(ctx, ARG0, ARG1, ARG2, ARG3, ARG4, ARG5); } extern int uaelib_debug; -static uae_u32 REGPARAM2 uaelib_demux (TrapContext *context) +static uae_u32 REGPARAM2 uaelib_demux (TrapContext *ctx) { uae_u32 v; struct regstruct *r = ®s; @@ -459,7 +450,7 @@ static uae_u32 REGPARAM2 uaelib_demux (TrapContext *context) ARG0, r->regs[0],r->regs[1],r->regs[2],r->regs[3],r->regs[4],r->regs[5],r->regs[6],r->regs[7], r->regs[8],r->regs[9],r->regs[10],r->regs[11],r->regs[12],r->regs[13],r->regs[14],r->regs[15]); - v = uaelib_demux2 (context); + v = uaelib_demux2 (ctx); if (uaelib_debug) write_log (_T("=%08x\n"), v); return v; diff --git a/uaenative.cpp b/uaenative.cpp index 4a731839..7ea41700 100644 --- a/uaenative.cpp +++ b/uaenative.cpp @@ -279,12 +279,12 @@ uae_u32 uaenative_open_library (TrapContext *context, int flags) uaecptr name; uae_u32 min_version; if (flags & UNI_FLAG_COMPAT) { - name = m68k_areg (regs, 0); + name = trap_get_areg(context, 0); min_version = 0; } else { - name = m68k_areg (regs, 1); - min_version = m68k_dreg (regs, 0); + name = trap_get_areg(context, 1); + min_version = trap_get_dreg(context, 0); } uae_u32 result = open_library ( @@ -342,12 +342,12 @@ uae_u32 uaenative_get_function (TrapContext *context, int flags) uaecptr name; uae_u32 library; if (flags & UNI_FLAG_COMPAT) { - name = m68k_areg (regs, 0); - library = m68k_dreg (regs, 1); + name = trap_get_areg(context, 0); + library = trap_get_dreg(context, 1); } else { - library = m68k_areg (regs, 0); - name = m68k_areg (regs, 1); + library = trap_get_areg(context, 0); + name = trap_get_areg(context, 1); } uae_u32 result = get_function_handle ( @@ -464,14 +464,14 @@ static void *uaenative_thread(void *arg) return NULL; } -uae_u32 uaenative_call_function (TrapContext *context, int flags) +uae_u32 uaenative_call_function (TrapContext *ctx, int flags) { if (!currprefs.native_code) { return UNI_ERROR_NOT_ENABLED; } struct uni uni; - uni.function = m68k_areg (regs, 0); + uni.function = trap_get_areg(ctx, 0); if (flags & UNI_FLAG_COMPAT) { uni.library = 0; #ifdef AHI @@ -481,7 +481,7 @@ uae_u32 uaenative_call_function (TrapContext *context, int flags) #endif } else if (flags & UNI_FLAG_NAMED_FUNCTION) { - uni.library = m68k_dreg (regs, 0); + uni.library = trap_get_dreg(ctx, 0); } else { uni.library = 0; @@ -491,7 +491,8 @@ uae_u32 uaenative_call_function (TrapContext *context, int flags) if (uni.library) { // library handle given, function is pointer to function name - const char *function = (const char *) get_real_address (uni.function); + uae_u8 function[256]; + trap_get_string(ctx, function, uni.function, sizeof function); library_data = get_library_data_from_handle (uni.library); if (library_data == NULL) { @@ -500,7 +501,7 @@ uae_u32 uaenative_call_function (TrapContext *context, int flags) return UNI_ERROR_INVALID_LIBRARY; } - uni.native_function = dl_symbol (library_data->dl_handle, function); + uni.native_function = dl_symbol (library_data->dl_handle, (const char*)function); if (uni.native_function == NULL) { write_log (_T("uni: get_function - function (%s) not found ") _T("in library %d (%p)\n"), function, uni.library, @@ -524,36 +525,36 @@ uae_u32 uaenative_call_function (TrapContext *context, int flags) } } - if (context == NULL) { + if (ctx == NULL) { // we have no context and cannot call into m68k space flags &= ~UNI_FLAG_ASYNCHRONOUS; } - uni.d1 = m68k_dreg (regs, 1); - uni.d2 = m68k_dreg (regs, 2); - uni.d3 = m68k_dreg (regs, 3); - uni.d4 = m68k_dreg (regs, 4); - uni.d5 = m68k_dreg (regs, 5); - uni.d6 = m68k_dreg (regs, 6); - uni.d7 = m68k_dreg (regs, 7); - uni.a1 = m68k_areg (regs, 1); - uni.a2 = m68k_areg (regs, 2); - uni.a3 = m68k_areg (regs, 3); - uni.a4 = m68k_areg (regs, 4); - uni.a5 = m68k_areg (regs, 5); - uni.a7 = m68k_areg (regs, 7); + uni.d1 = trap_get_dreg(ctx, 1); + uni.d2 = trap_get_dreg(ctx, 2); + uni.d3 = trap_get_dreg(ctx, 3); + uni.d4 = trap_get_dreg(ctx, 4); + uni.d5 = trap_get_dreg(ctx, 5); + uni.d6 = trap_get_dreg(ctx, 6); + uni.d7 = trap_get_dreg(ctx, 7); + uni.a1 = trap_get_areg(ctx, 1); + uni.a2 = trap_get_areg(ctx, 2); + uni.a3 = trap_get_areg(ctx, 3); + uni.a4 = trap_get_areg(ctx, 4); + uni.a5 = trap_get_areg(ctx, 5); + uni.a7 = trap_get_areg(ctx, 7); uni.flags = flags; uni.error = 0; if (flags & UNI_FLAG_ASYNCHRONOUS) { - uaecptr sysbase = get_long (4); - uni.task = get_long (sysbase + 276); // ThisTask + uaecptr sysbase = trap_get_long(ctx, 4); + uni.task = trap_get_long(ctx, sysbase + 276); // ThisTask // make sure signal bit is cleared m68k_dreg (regs, 0) = 0; m68k_dreg (regs, 1) = 1 << SIGBIT; - CallLib (context, sysbase, -0x132); // SetSignal + CallLib (ctx, sysbase, -0x132); // SetSignal // start thread if necessary if (!library_data->thread_id) { @@ -571,8 +572,8 @@ uae_u32 uaenative_call_function (TrapContext *context, int flags) uae_sem_post(&library_data->full_count); // wait for signal - m68k_dreg (regs, 0) = 1 << SIGBIT; - CallLib (context, sysbase, -0x13e); // Wait + trap_set_dreg(ctx, 0, 1 << SIGBIT); + CallLib(ctx, sysbase, -0x13e); // Wait write_log (_T("uni: -- Got async result --\n")); } else { @@ -590,10 +591,10 @@ uae_u32 uaenative_close_library(TrapContext *context, int flags) uae_u32 handle; if (flags & UNI_FLAG_COMPAT) { - handle = m68k_dreg (regs, 1); + handle = trap_get_dreg(context, 1); } else { - handle = m68k_areg (regs, 1); + handle = trap_get_areg(context, 1); } struct library_data *library_data = get_library_data_from_handle (handle); @@ -708,20 +709,20 @@ static void uae_library_install (struct uae_library *library) library->name, MODULE_SUFFIX); } -static uaecptr uae_library_startup (uaecptr res_addr, struct uae_library *library) +static uaecptr uae_library_startup (TrapContext *ctx, uaecptr res_addr, struct uae_library *library) { if (library->aptr_name == 0 || !currprefs.native_code) { return res_addr; } - put_word (res_addr + 0x00, 0x4AFC); - put_long (res_addr + 0x02, res_addr); - put_long (res_addr + 0x06, res_addr + 0x1A); // Continue scan here - put_word (res_addr + 0x0A, 0x8004); // RTF_AUTOINIT, RT_VERSION - put_word (res_addr + 0x0C, 0x0970); // NT_LIBRARY, RT_PRI - put_long (res_addr + 0x0E, library->aptr_name); - put_long (res_addr + 0x12, library->aptr_id); - put_long (res_addr + 0x16, library->aptr_init); + trap_put_word(ctx, res_addr + 0x00, 0x4AFC); + trap_put_long(ctx, res_addr + 0x02, res_addr); + trap_put_long(ctx, res_addr + 0x06, res_addr + 0x1A); // Continue scan here + trap_put_word(ctx, res_addr + 0x0A, 0x8004); // RTF_AUTOINIT, RT_VERSION + trap_put_word(ctx, res_addr + 0x0C, 0x0970); // NT_LIBRARY, RT_PRI + trap_put_long(ctx, res_addr + 0x0E, library->aptr_name); + trap_put_long(ctx, res_addr + 0x12, library->aptr_id); + trap_put_long(ctx, res_addr + 0x16, library->aptr_init); return res_addr + 0x1A; } @@ -730,7 +731,7 @@ static uaecptr uae_library_startup (uaecptr res_addr, struct uae_library *librar static uae_u32 REGPARAM2 lib_init (TrapContext *context) { - uaecptr aptr_base = m68k_dreg (regs, 0); + uaecptr aptr_base = trap_get_dreg(context, 0); #if 0 uaecptr aptr_data = aptr_base + SIZEOF_LIBRARY; // sizeof(Library) // our library data area, LIB_DATA_SIZE must be at least as big @@ -743,15 +744,15 @@ static uae_u32 REGPARAM2 lib_open (TrapContext *context) { // we could do some security checks here if only some specific Amiga // tasks can call us or something like that - put_word (m68k_areg (regs, 6) + 32, - get_word (m68k_areg (regs, 6) + 32) + 1); - return m68k_areg (regs, 6); + trap_put_word(context, trap_get_areg(context, 6) + 32, + trap_get_word(context, trap_get_areg(context, 6) + 32) + 1); + return trap_get_areg(context, 6); } static uae_u32 REGPARAM2 lib_close (TrapContext *context) { - put_word (m68k_areg (regs, 6) + 32, - get_word (m68k_areg (regs, 6) + 32) - 1); + trap_put_word(context, trap_get_areg(context, 6) + 32, + trap_get_word(context, trap_get_areg(context, 6) + 32) - 1); return 0; } @@ -836,12 +837,12 @@ void uaenative_install (void) uae_library_install (&uaenative_library); } -uaecptr uaenative_startup (uaecptr res_addr) +uaecptr uaenative_startup(TrapContext *ctx, uaecptr res_addr) { if (!currprefs.native_code) { return res_addr; } - return uae_library_startup (res_addr, &uaenative_library); + return uae_library_startup(ctx, res_addr, &uaenative_library); } #endif // WITH_UAENATIVE diff --git a/uaeresource.cpp b/uaeresource.cpp index 2268b7cc..4b69a001 100644 --- a/uaeresource.cpp +++ b/uaeresource.cpp @@ -41,16 +41,16 @@ static uaecptr res_init, res_name, res_id, base; static uae_u32 REGPARAM2 res_getfunc (TrapContext *ctx) { - uaecptr funcname = m68k_areg (regs, 0); + uaecptr funcname = trap_get_areg(ctx, 0); uae_char tmp[256]; uae_u32 p; TCHAR *s; if (funcname == 0) return 0; - strcpyah_safe (tmp, funcname, sizeof tmp); - s = au (tmp); - p = find_trap (s); + trap_get_string(ctx, tmp, funcname, sizeof tmp); + s = au(tmp); + p = find_trap(s); xfree (s); return p; } @@ -58,26 +58,26 @@ static uae_u32 REGPARAM2 res_getfunc (TrapContext *ctx) static uae_u32 REGPARAM2 res_initcode (TrapContext *ctx) { uaecptr rb; - base = m68k_dreg (regs, 0); + base = trap_get_dreg (ctx, 0); rb = base + SIZEOF_LIBRARY; - put_word (rb + 0, UAEMAJOR); - put_word (rb + 2, UAEMINOR); - put_word (rb + 4, UAESUBREV); - put_word (rb + 6, 0); - put_long (rb + 8, rtarea_base); + trap_put_word(ctx, rb + 0, UAEMAJOR); + trap_put_word(ctx, rb + 2, UAEMINOR); + trap_put_word(ctx, rb + 4, UAESUBREV); + trap_put_word(ctx, rb + 6, 0); + trap_put_long(ctx, rb + 8, rtarea_base); return base; } -uaecptr uaeres_startup (uaecptr resaddr) +uaecptr uaeres_startup (TrapContext *ctx, uaecptr resaddr) { - put_word (resaddr + 0x0, 0x4AFC); - put_long (resaddr + 0x2, resaddr); - put_long (resaddr + 0x6, resaddr + 0x1A); /* Continue scan here */ - put_word (resaddr + 0xA, 0x8101); /* RTF_AUTOINIT|RTF_COLDSTART; Version 1 */ - put_word (resaddr + 0xC, 0x0878); /* NT_DEVICE; pri 05 */ - put_long (resaddr + 0xE, res_name); - put_long (resaddr + 0x12, res_id); - put_long (resaddr + 0x16, res_init); + trap_put_word(ctx, resaddr + 0x0, 0x4AFC); + trap_put_long(ctx, resaddr + 0x2, resaddr); + trap_put_long(ctx, resaddr + 0x6, resaddr + 0x1A); /* Continue scan here */ + trap_put_word(ctx, resaddr + 0xA, 0x8101); /* RTF_AUTOINIT|RTF_COLDSTART; Version 1 */ + trap_put_word(ctx, resaddr + 0xC, 0x0878); /* NT_DEVICE; pri 05 */ + trap_put_long(ctx, resaddr + 0xE, res_name); + trap_put_long(ctx, resaddr + 0x12, res_id); + trap_put_long(ctx, resaddr + 0x16, res_init); resaddr += 0x1A; return resaddr; } diff --git a/uaeserial.cpp b/uaeserial.cpp index 154d9687..bf278393 100644 --- a/uaeserial.cpp +++ b/uaeserial.cpp @@ -83,6 +83,8 @@ int log_uaeserial = 0; #define io_SerFlags 0x4f /* UBYTE see SerFlags bit definitions below */ #define io_Status 0x50 /* UWORD */ +#define IOExtSerSize 48 + /* status of serial port, as follows: * BIT ACTIVE FUNCTION * 0 --- reserved @@ -107,7 +109,8 @@ int log_uaeserial = 0; struct asyncreq { struct asyncreq *next; - uaecptr request; + uaecptr arequest; + uae_u8 *request; int ready; }; @@ -129,20 +132,20 @@ struct devstruct { static int uniq; static uae_u32 nscmd_cmd; static struct devstruct devst[MAX_TOTAL_DEVICES]; -static uae_sem_t change_sem, async_sem; +static uae_sem_t change_sem, async_sem, pipe_sem; static const TCHAR *getdevname (void) { return _T("uaeserial.device"); } -static void io_log (const TCHAR *msg, uaecptr request) +static void io_log (const TCHAR *msg, uae_u8 *request, uaecptr arequest) { if (log_uaeserial) write_log (_T("%s: %08X %d %08X %d %d io_actual=%d io_error=%d\n"), - msg, request, get_word (request + 28), get_long (request + 40), - get_long (request + 36), get_long (request + 44), - get_long (request + 32), get_byte (request + 31)); + msg, request, get_word_host(request + 28), get_long_host(request + 40), + get_long_host(request + 36), get_long_host(request + 44), + get_long_host(request + 32), get_byte_host(request + 31)); } static struct devstruct *getdevstruct (int uniq) @@ -170,69 +173,73 @@ static void dev_close_3 (struct devstruct *dev) uaeser_close (dev->sysdata); dev->open = 0; xfree (dev->sysdata); + uae_sem_wait(&pipe_sem); + write_comm_pipe_pvoid(&dev->requests, NULL, 0); + write_comm_pipe_pvoid(&dev->requests, NULL, 0); write_comm_pipe_u32 (&dev->requests, 0, 1); + uae_sem_post(&pipe_sem); } -static uae_u32 REGPARAM2 dev_close (TrapContext *context) +static uae_u32 REGPARAM2 dev_close (TrapContext *ctx) { - uae_u32 request = m68k_areg (regs, 1); + uae_u32 request = trap_get_areg(ctx, 1); struct devstruct *dev; - dev = getdevstruct (get_long (request + 24)); + dev = getdevstruct (trap_get_long(ctx, request + 24)); if (!dev) return 0; if (log_uaeserial) write_log (_T("%s:%d close, req=%x\n"), getdevname(), dev->unit, request); dev_close_3 (dev); - put_long (request + 24, 0); - put_word (m68k_areg (regs, 6) + 32, get_word (m68k_areg (regs, 6) + 32) - 1); + trap_put_long(ctx, request + 24, 0); + trap_put_word(ctx, trap_get_areg(ctx, 6) + 32, trap_get_word(ctx, trap_get_areg(ctx, 6) + 32) - 1); return 0; } -static void resetparams (struct devstruct *dev, uaecptr req) +static void resetparams(TrapContext *ctx, struct devstruct *dev, uae_u8 *req) { - put_long (req + io_CtlChar, 0x00001311); - put_long (req + io_RBufLen, 1024); - put_long (req + io_ExtFlags, 0); - put_long (req + io_Baud, 9600); - put_long (req + io_BrkTime, 250000); - put_long (req + io_TermArray0, 0); - put_long (req + io_TermArray1, 0); - put_byte (req + io_ReadLen, 8); - put_byte (req + io_WriteLen, 8); - put_byte (req + io_StopBits, 1); - put_byte (req + io_SerFlags, get_byte (req + io_SerFlags) & (SERF_XDISABLED | SERF_SHARED | SERF_7WIRE)); - put_word (req + io_Status, 0); + put_long_host(req + io_CtlChar, 0x00001311); + put_long_host(req + io_RBufLen, 1024); + put_long_host(req + io_ExtFlags, 0); + put_long_host(req + io_Baud, 9600); + put_long_host(req + io_BrkTime, 250000); + put_long_host(req + io_TermArray0, 0); + put_long_host(req + io_TermArray1, 0); + put_byte_host(req + io_ReadLen, 8); + put_byte_host(req + io_WriteLen, 8); + put_byte_host(req + io_StopBits, 1); + put_byte_host(req + io_SerFlags, get_byte_host(req + io_SerFlags) & (SERF_XDISABLED | SERF_SHARED | SERF_7WIRE)); + put_word_host(req + io_Status, 0); } -static int setparams (struct devstruct *dev, uaecptr req) +static int setparams(TrapContext *ctx, struct devstruct *dev, uae_u8 *req) { int v; int rbuffer, baud, rbits, wbits, sbits, rtscts, parity, xonxoff; - rbuffer = get_long (req + io_RBufLen); - v = get_long (req + io_ExtFlags); + rbuffer = get_long_host(req + io_RBufLen); + v = get_long_host(req + io_ExtFlags); if (v) { write_log (_T("UAESER: io_ExtFlags=%08x, not supported\n"), v); return 5; } - baud = get_long (req + io_Baud); - v = get_byte (req + io_SerFlags); + baud = get_long_host(req + io_Baud); + v = get_byte_host(req + io_SerFlags); if (v & SERF_EOFMODE) { write_log (_T("UAESER: SERF_EOFMODE not supported\n")); return 5; } xonxoff = (v & SERF_XDISABLED) ? 0 : 1; if (xonxoff) { - xonxoff |= (get_long (req + io_CtlChar) << 8) & 0x00ffff00; + xonxoff |= (get_long_host(req + io_CtlChar) << 8) & 0x00ffff00; } rtscts = (v & SERF_7WIRE) ? 1 : 0; parity = 0; if (v & SERF_PARTY_ON) parity = (v & SERF_PARTY_ODD) ? 1 : 2; - rbits = get_byte (req + io_ReadLen); - wbits = get_byte (req + io_WriteLen); - sbits = get_byte (req + io_StopBits); + rbits = get_byte_host(req + io_ReadLen); + wbits = get_byte_host(req + io_WriteLen); + sbits = get_byte_host(req + io_StopBits); if ((rbits != 7 && rbits != 8) || (wbits != 7 && wbits != 8) || (sbits != 1 && sbits != 2) || rbits != wbits) { write_log (_T("UAESER: Read=%d, Write=%d, Stop=%d, not supported\n"), rbits, wbits, sbits); return 5; @@ -249,59 +256,63 @@ static int setparams (struct devstruct *dev, uaecptr req) return 0; } -static int openfail (uaecptr ioreq, int error) +static int openfail(TrapContext *ctx, uaecptr ioreq, int error) { - put_long (ioreq + 20, -1); - put_byte (ioreq + 31, error); + trap_put_long(ctx, ioreq + 20, -1); + trap_put_byte(ctx, ioreq + 31, error); return (uae_u32)-1; } -static uae_u32 REGPARAM2 dev_open (TrapContext *context) +static uae_u32 REGPARAM2 dev_open (TrapContext *ctx) { - uaecptr ioreq = m68k_areg (regs, 1); - uae_u32 unit = m68k_dreg (regs, 0); - uae_u32 flags = m68k_dreg (regs, 1); + uaecptr ioreq = trap_get_areg(ctx, 1); + uae_u32 unit = trap_get_dreg(ctx, 0); + uae_u32 flags = trap_get_dreg(ctx, 1); struct devstruct *dev; int i, err; + uae_u8 request[IOExtSerSize]; + + trap_get_bytes(ctx, request, ioreq, IOExtSerSize); - if (get_word (ioreq + 0x12) < IOSTDREQ_SIZE) - return openfail (ioreq, IOERR_BADLENGTH); + if (trap_get_word(ctx, ioreq + 0x12) < IOSTDREQ_SIZE) + return openfail(ctx, ioreq, IOERR_BADLENGTH); for (i = 0; i < MAX_TOTAL_DEVICES; i++) { if (devst[i].open && devst[i].unit == unit && devst[i].exclusive) - return openfail (ioreq, IOERR_UNITBUSY); + return openfail(ctx, ioreq, IOERR_UNITBUSY); } for (i = 0; i < MAX_TOTAL_DEVICES; i++) { if (!devst[i].open) break; } if (i == MAX_TOTAL_DEVICES) - return openfail (ioreq, IOERR_OPENFAIL); + return openfail(ctx, ioreq, IOERR_OPENFAIL); dev = &devst[i]; dev->sysdata = xcalloc (uae_u8, uaeser_getdatalength ()); if (!uaeser_open (dev->sysdata, dev, unit)) { xfree (dev->sysdata); - return openfail (ioreq, IOERR_OPENFAIL); + return openfail(ctx, ioreq, IOERR_OPENFAIL); } dev->unit = unit; dev->open = 1; dev->uniq = ++uniq; - dev->exclusive = (get_word (ioreq + io_SerFlags) & SERF_SHARED) ? 0 : 1; - put_long (ioreq + 24, dev->uniq); - resetparams (dev, ioreq); - err = setparams (dev, ioreq); + dev->exclusive = (trap_get_word(ctx, ioreq + io_SerFlags) & SERF_SHARED) ? 0 : 1; + put_long_host(request + 24, dev->uniq); + resetparams (ctx, dev, request); + err = setparams (ctx, dev, request); if (err) { uaeser_close (dev->sysdata); dev->open = 0; xfree (dev->sysdata); - return openfail (ioreq, err); + return openfail(ctx, ioreq, err); } if (log_uaeserial) write_log (_T("%s:%d open ioreq=%08X\n"), getdevname(), unit, ioreq); start_thread (dev); - put_word (m68k_areg (regs, 6) + 32, get_word (m68k_areg (regs, 6) + 32) + 1); - put_byte (ioreq + 31, 0); - put_byte (ioreq + 8, 7); + trap_put_word(ctx, trap_get_areg(ctx, 6) + 32, trap_get_word(ctx, trap_get_areg(ctx, 6) + 32) + 1); + put_byte_host(request + 31, 0); + put_byte_host(request + 8, 7); + trap_put_bytes(ctx, request + 8, ioreq + 8, IOExtSerSize - 8); return 0; } @@ -310,14 +321,14 @@ static uae_u32 REGPARAM2 dev_expunge (TrapContext *context) return 0; } -static struct asyncreq *get_async_request (struct devstruct *dev, uaecptr request, int ready) +static struct asyncreq *get_async_request (struct devstruct *dev, uaecptr arequest, int ready) { struct asyncreq *ar; uae_sem_wait (&async_sem); ar = dev->ar; while (ar) { - if (ar->request == request) { + if (ar->arequest == arequest) { if (ready) ar->ready = 1; break; @@ -328,15 +339,16 @@ static struct asyncreq *get_async_request (struct devstruct *dev, uaecptr reques return ar; } -static int add_async_request (struct devstruct *dev, uaecptr request) +static int add_async_request (struct devstruct *dev, uae_u8 *request, uaecptr arequest) { struct asyncreq *ar, *ar2; if (log_uaeserial) - write_log (_T("%s:%d async request %x added\n"), getdevname(), dev->unit, request); + write_log (_T("%s:%d async request %x added\n"), getdevname(), dev->unit, arequest); uae_sem_wait (&async_sem); ar = xcalloc (struct asyncreq, 1); + ar->arequest = arequest; ar->request = request; if (!dev->ar) { dev->ar = ar; @@ -350,7 +362,7 @@ static int add_async_request (struct devstruct *dev, uaecptr request) return 1; } -static int release_async_request (struct devstruct *dev, uaecptr request) +static int release_async_request (struct devstruct *dev, uaecptr arequest) { struct asyncreq *ar, *prevar; @@ -358,49 +370,48 @@ static int release_async_request (struct devstruct *dev, uaecptr request) ar = dev->ar; prevar = NULL; while (ar) { - if (ar->request == request) { + if (ar->arequest == arequest) { if (prevar == NULL) dev->ar = ar->next; else prevar->next = ar->next; uae_sem_post (&async_sem); - xfree (ar); + xfree(ar->request); + xfree(ar); if (log_uaeserial) - write_log (_T("%s:%d async request %x removed\n"), getdevname(), dev->unit, request); + write_log (_T("%s:%d async request %x removed\n"), getdevname(), dev->unit, arequest); return 1; } prevar = ar; ar = ar->next; } uae_sem_post (&async_sem); - write_log (_T("%s:%d async request %x not found for removal!\n"), getdevname(), dev->unit, request); + write_log (_T("%s:%d async request %x not found for removal!\n"), getdevname(), dev->unit, arequest); return 0; } -static void abort_async (struct devstruct *dev, uaecptr request) +static void abort_async(TrapContext *ctx, struct devstruct *dev, uaecptr arequest) { - struct asyncreq *ar = get_async_request (dev, request, 1); + struct asyncreq *ar = get_async_request (dev, arequest, 1); if (!ar) { - write_log (_T("%s:%d: abort async but no request %x found!\n"), getdevname(), dev->unit, request); + write_log (_T("%s:%d: abort async but no request %x found!\n"), getdevname(), dev->unit, arequest); return; } + uae_u8 *request = ar->request; if (log_uaeserial) - write_log (_T("%s:%d asyncronous request=%08X aborted\n"), getdevname(), dev->unit, request); - put_byte (request + 31, IOERR_ABORTED); - put_byte (request + 30, get_byte (request + 30) | 0x20); - write_comm_pipe_u32 (&dev->requests, request, 1); -} - -static uae_u8 *memmap(uae_u32 addr, uae_u32 len) -{ - addrbank *bank_data = &get_mem_bank (addr); - if (!bank_data->check (addr, len)) - return NULL; - return bank_data->xlateaddr (addr); + write_log (_T("%s:%d asyncronous request=%08X aborted\n"), getdevname(), dev->unit, arequest); + put_byte_host(request + 31, IOERR_ABORTED); + put_byte_host(request + 30, get_byte_host(request + 30) | 0x20); + uae_sem_wait(&pipe_sem); + write_comm_pipe_pvoid(&dev->requests, ctx, 0); + write_comm_pipe_pvoid(&dev->requests, request, 0); + write_comm_pipe_u32(&dev->requests, arequest, 1); + uae_sem_post(&pipe_sem); } void uaeser_signal (void *vdev, int sigmask) { + TrapContext *ctx = NULL; struct devstruct *dev = (struct devstruct*)vdev; struct asyncreq *ar; @@ -408,44 +419,49 @@ void uaeser_signal (void *vdev, int sigmask) ar = dev->ar; while (ar) { if (!ar->ready) { - uaecptr request = ar->request; - uae_u32 io_data = get_long (request + 40); // 0x28 - uae_u32 io_length = get_long (request + 36); // 0x24 - int command = get_word (request + 28); + uaecptr arequest = ar->arequest; + uae_u8 *request = ar->request; + uae_u32 io_data = get_long_host(request + 40); // 0x28 + uae_u32 io_length = get_long_host(request + 36); // 0x24 + int command = get_word_host(request + 28); uae_u32 io_error = 0, io_actual = 0; - uae_u8 *addr; int io_done = 0; switch (command) { case SDCMD_BREAK: if (ar == dev->ar) { - uaeser_break (dev->sysdata, get_long (request + io_BrkTime)); + uaeser_break (dev->sysdata, get_long_host(request + io_BrkTime)); io_done = 1; } break; case CMD_READ: if (sigmask & 1) { - addr = memmap(io_data, io_length); - if (addr) { - if (uaeser_read (dev->sysdata, addr, io_length)) { - io_error = 0; - io_actual = io_length; - io_done = 1; + uae_u8 tmp[RTAREA_TRAP_DATA_EXTRA_SIZE]; + while (io_length > 0) { + int size = io_length > sizeof(tmp) ? sizeof(tmp) : io_length; + if (uaeser_read(dev->sysdata, tmp, size)) { + trap_put_bytes(ctx, tmp, io_data, size); + io_actual += size; + io_data += size; + io_length -= size; } - } else { - io_error = IOERR_BADADDRESS; - io_done = 1; } + io_done = 1; } break; case CMD_WRITE: if (sigmask & 2) { - io_error = IOERR_BADADDRESS; - addr = memmap(io_data, io_length); - if (addr && uaeser_write (dev->sysdata, addr, io_length)) - io_error = 0; - io_actual = io_length; + uae_u8 tmp[RTAREA_TRAP_DATA_EXTRA_SIZE]; + while (io_length > 0) { + int size = io_length > sizeof(tmp) ? sizeof(tmp) : io_length; + trap_get_bytes(ctx, tmp, io_data, size); + if (!uaeser_write(dev->sysdata, tmp, size)) + break; + io_actual += size; + io_data += size; + io_length -= size; + } io_done = 1; } break; @@ -457,10 +473,15 @@ void uaeser_signal (void *vdev, int sigmask) if (io_done) { if (log_uaeserial) write_log (_T("%s:%d async request %x completed\n"), getdevname(), dev->unit, request); - put_long (request + 32, io_actual); - put_byte (request + 31, io_error); + put_long_host(request + 32, io_actual); + put_byte_host(request + 31, io_error); ar->ready = 1; - write_comm_pipe_u32 (&dev->requests, request, 1); + uae_sem_wait(&pipe_sem); + write_comm_pipe_pvoid(&dev->requests, ctx, 0); + write_comm_pipe_pvoid(&dev->requests, request, 0); + write_comm_pipe_u32 (&dev->requests, arequest, 1); + uae_sem_post(&pipe_sem); + break; } } @@ -469,49 +490,49 @@ void uaeser_signal (void *vdev, int sigmask) uae_sem_post (&async_sem); } -static void cmd_reset(struct devstruct *dev, uaecptr req) +static void cmd_reset(TrapContext *ctx, struct devstruct *dev, uae_u8 *req) { while (dev->ar) - abort_async (dev, dev->ar->request); - put_long (req + io_RBufLen, 8192); - put_long (req + io_ExtFlags, 0); - put_long (req + io_Baud, 57600); - put_long (req + io_BrkTime, 250000); - put_long (req + io_TermArray0, 0); - put_long (req + io_TermArray1, 0); - put_long (req + io_ReadLen, 8); - put_long (req + io_WriteLen, 8); - put_long (req + io_StopBits, 1); - put_long (req + io_SerFlags, SERF_XDISABLED); - put_word (req + io_Status, 0); + abort_async(ctx, dev, dev->ar->arequest); + put_long_host(req + io_RBufLen, 8192); + put_long_host(req + io_ExtFlags, 0); + put_long_host(req + io_Baud, 57600); + put_long_host(req + io_BrkTime, 250000); + put_long_host(req + io_TermArray0, 0); + put_long_host(req + io_TermArray1, 0); + put_long_host(req + io_ReadLen, 8); + put_long_host(req + io_WriteLen, 8); + put_long_host(req + io_StopBits, 1); + put_long_host(req + io_SerFlags, SERF_XDISABLED); + put_word_host(req + io_Status, 0); } -static int dev_do_io (struct devstruct *dev, uaecptr request, int quick) +static int dev_do_io(TrapContext *ctx, struct devstruct *dev, uae_u8 *request, uaecptr arequest, int quick) { uae_u32 command; - uae_u32 io_data = get_long (request + 40); // 0x28 - uae_u32 io_length = get_long (request + 36); // 0x24 - uae_u32 io_actual = get_long (request + 32); // 0x20 - uae_u32 io_offset = get_long (request + 44); // 0x2c + uae_u32 io_data = get_long_host(request + 40); // 0x28 + uae_u32 io_length = get_long_host(request + 36); // 0x24 + uae_u32 io_actual = get_long_host(request + 32); // 0x20 + uae_u32 io_offset = get_long_host(request + 44); // 0x2c uae_u32 io_error = 0; uae_u16 io_status; int async = 0; if (!dev) return 0; - command = get_word (request + 28); - io_log (_T("dev_io_START"),request); + command = get_word_host(request + 28); + io_log (_T("dev_io_START"), request, arequest); switch (command) { case SDCMD_QUERY: if (uaeser_query (dev->sysdata, &io_status, &io_actual)) - put_byte (request + io_Status, io_status); + put_byte_host(request + io_Status, (uae_u8)io_status); else io_error = IOERR_BADADDRESS; break; case SDCMD_SETPARAMS: - io_error = setparams(dev, request); + io_error = setparams(ctx, dev, request); break; case CMD_WRITE: async = 1; @@ -520,67 +541,83 @@ static int dev_do_io (struct devstruct *dev, uaecptr request, int quick) async = 1; break; case SDCMD_BREAK: - if (get_byte (request + io_SerFlags) & SERF_QUEUEDBRK) { + if (get_byte_host(request + io_SerFlags) & SERF_QUEUEDBRK) { async = 1; } else { - uaeser_break (dev->sysdata, get_long (request + io_BrkTime)); + uaeser_break(dev->sysdata, get_long_host(request + io_BrkTime)); } break; case CMD_CLEAR: uaeser_clearbuffers(dev->sysdata); break; case CMD_RESET: - cmd_reset(dev, request); + cmd_reset(ctx, dev, request); break; case CMD_FLUSH: case CMD_START: case CMD_STOP: break; case NSCMD_DEVICEQUERY: - put_long (io_data + 0, 0); - put_long (io_data + 4, 16); /* size */ - put_word (io_data + 8, NSDEVTYPE_SERIAL); - put_word (io_data + 10, 0); - put_long (io_data + 12, nscmd_cmd); + trap_put_long(ctx, io_data + 0, 0); + trap_put_long(ctx, io_data + 4, 16); /* size */ + trap_put_word(ctx, io_data + 8, NSDEVTYPE_SERIAL); + trap_put_word(ctx, io_data + 10, 0); + trap_put_long(ctx, io_data + 12, nscmd_cmd); io_actual = 16; break; default: io_error = IOERR_NOCMD; break; } - put_long (request + 32, io_actual); - put_byte (request + 31, io_error); - io_log (_T("dev_io_END"),request); + put_long_host(request + 32, io_actual); + put_byte_host(request + 31, io_error); + io_log (_T("dev_io_END"), request, arequest); return async; } -static int dev_canquick (struct devstruct *dev, uaecptr request) +static int dev_canquick (struct devstruct *dev, uae_u8 *request) { return 0; } -static uae_u32 REGPARAM2 dev_beginio (TrapContext *context) +static uae_u32 REGPARAM2 dev_beginio (TrapContext *ctx) { - uae_u32 request = m68k_areg (regs, 1); - uae_u8 flags = get_byte (request + 30); - int command = get_word (request + 28); - struct devstruct *dev = getdevstruct (get_long (request + 24)); + uae_u8 err = 0; + uae_u32 arequest = trap_get_areg(ctx, 1); + uae_u8 *request = xmalloc(uae_u8, IOExtSerSize); + + trap_get_bytes(ctx, request, arequest, IOExtSerSize); + + uae_u8 flags = get_byte_host(request + 30); + int command = get_word_host(request + 28); + struct devstruct *dev = getdevstruct (get_long_host(request + 24)); - put_byte (request + 8, NT_MESSAGE); + put_byte_host(request + 8, NT_MESSAGE); if (!dev) { - put_byte (request + 31, 32); - return get_byte (request + 31); + err = 32; + goto end; } - put_byte (request + 31, 0); - if ((flags & 1) && dev_canquick (dev, request)) { - if (dev_do_io (dev, request, 1)) + put_byte_host(request + 31, 0); + if ((flags & 1) && dev_canquick(dev, request)) { + if (dev_do_io(ctx, dev, request, arequest, 1)) write_log (_T("device %s:%d command %d bug with IO_QUICK\n"), getdevname(), dev->unit, command); - return get_byte (request + 31); + err = get_byte_host(request + 31); } else { - put_byte (request + 30, get_byte (request + 30) & ~1); - write_comm_pipe_u32 (&dev->requests, request, 1); + put_byte_host(request + 30, get_byte_host(request + 30) & ~1); + trap_put_bytes(ctx, request + 8, arequest + 8, IOExtSerSize - 8); + uae_sem_wait(&pipe_sem); + trap_set_background(ctx); + write_comm_pipe_pvoid(&dev->requests, ctx, 0); + write_comm_pipe_pvoid(&dev->requests, request, 0); + write_comm_pipe_u32(&dev->requests, arequest, 1); + uae_sem_post(&pipe_sem); return 0; } +end: + put_byte_host(request + 31, 32); + trap_put_bytes(ctx, request + 8, arequest + 8, IOExtSerSize - 8); + xfree(request); + return err; } static void *dev_thread (void *devs) @@ -591,6 +628,8 @@ static void *dev_thread (void *devs) dev->thread_running = 1; uae_sem_post (&dev->sync_sem); for (;;) { + TrapContext *ctx = (TrapContext*)read_comm_pipe_pvoid_blocking(&dev->requests); + uae_u8 *iobuf = (uae_u8*)read_comm_pipe_pvoid_blocking(&dev->requests); uaecptr request = (uaecptr)read_comm_pipe_u32_blocking (&dev->requests); uae_sem_wait (&change_sem); if (!request) { @@ -601,12 +640,13 @@ static void *dev_thread (void *devs) } else if (get_async_request (dev, request, 1)) { uae_ReplyMsg (request); release_async_request (dev, request); - } else if (dev_do_io (dev, request, 0) == 0) { + } else if (dev_do_io(ctx, dev, iobuf, request, 0) == 0) { uae_ReplyMsg (request); } else { - add_async_request (dev, request); + add_async_request (dev, iobuf, request); uaeser_trigger (dev->sysdata); } + trap_background_set_complete(ctx); uae_sem_post (&change_sem); } return 0; @@ -614,22 +654,22 @@ static void *dev_thread (void *devs) static uae_u32 REGPARAM2 dev_init (TrapContext *context) { - uae_u32 base = m68k_dreg (regs, 0); + uae_u32 base = trap_get_dreg (context, 0); if (log_uaeserial) write_log (_T("%s init\n"), getdevname ()); return base; } -static uae_u32 REGPARAM2 dev_abortio (TrapContext *context) +static uae_u32 REGPARAM2 dev_abortio(TrapContext *ctx) { - uae_u32 request = m68k_areg (regs, 1); - struct devstruct *dev = getdevstruct (get_long (request + 24)); + uae_u32 request = trap_get_areg(ctx, 1); + struct devstruct *dev = getdevstruct(trap_get_long(ctx, request + 24)); if (!dev) { - put_byte (request + 31, 32); - return get_byte (request + 31); + trap_put_byte(ctx, request + 31, 32); + return trap_get_byte(ctx, request + 31); } - abort_async (dev, request); + abort_async(ctx, dev, request); return 0; } @@ -642,7 +682,7 @@ static void dev_reset (void) dev = &devst[i]; if (dev->open) { while (dev->ar) - abort_async (dev, dev->ar->request); + abort_async(NULL, dev, dev->ar->arequest); dev_close_3 (dev); uae_sem_wait (&dev->sync_sem); } @@ -654,7 +694,7 @@ static uaecptr ROM_uaeserialdev_resname = 0, ROM_uaeserialdev_resid = 0, ROM_uaeserialdev_init = 0; -uaecptr uaeserialdev_startup (uaecptr resaddr) +uaecptr uaeserialdev_startup(TrapContext *ctx, uaecptr resaddr) { if (!currprefs.uaeserial) return resaddr; @@ -662,14 +702,14 @@ uaecptr uaeserialdev_startup (uaecptr resaddr) write_log (_T("uaeserialdev_startup(0x%x)\n"), resaddr); /* Build a struct Resident. This will set up and initialize * the serial.device */ - put_word (resaddr + 0x0, 0x4AFC); - put_long (resaddr + 0x2, resaddr); - put_long (resaddr + 0x6, resaddr + 0x1A); /* Continue scan here */ - put_word (resaddr + 0xA, 0x8101); /* RTF_AUTOINIT|RTF_COLDSTART; Version 1 */ - put_word (resaddr + 0xC, 0x0305); /* NT_DEVICE; pri 05 */ - put_long (resaddr + 0xE, ROM_uaeserialdev_resname); - put_long (resaddr + 0x12, ROM_uaeserialdev_resid); - put_long (resaddr + 0x16, ROM_uaeserialdev_init); + trap_put_word(ctx, resaddr + 0x0, 0x4AFC); + trap_put_long(ctx, resaddr + 0x2, resaddr); + trap_put_long(ctx, resaddr + 0x6, resaddr + 0x1A); /* Continue scan here */ + trap_put_word(ctx, resaddr + 0xA, 0x8101); /* RTF_AUTOINIT|RTF_COLDSTART; Version 1 */ + trap_put_word(ctx, resaddr + 0xC, 0x0305); /* NT_DEVICE; pri 05 */ + trap_put_long(ctx, resaddr + 0xE, ROM_uaeserialdev_resname); + trap_put_long(ctx, resaddr + 0x12, ROM_uaeserialdev_resid); + trap_put_long(ctx, resaddr + 0x16, ROM_uaeserialdev_init); resaddr += 0x1A; return resaddr; } @@ -685,7 +725,7 @@ void uaeserialdev_install (void) return; ROM_uaeserialdev_resname = ds (_T("uaeserial.device")); - ROM_uaeserialdev_resid = ds (_T("UAE serial.device 0.1")); + ROM_uaeserialdev_resid = ds (_T("UAE serial.device 0.2")); /* initcode */ initcode = here (); @@ -766,8 +806,9 @@ void uaeserialdev_install (void) void uaeserialdev_start_threads (void) { - uae_sem_init (&change_sem, 0, 1); - uae_sem_init (&async_sem, 0, 1); + uae_sem_init(&change_sem, 0, 1); + uae_sem_init(&async_sem, 0, 1); + uae_sem_init(&pipe_sem, 0, 1); } void uaeserialdev_reset (void)