/** * Intercept GEMDOS calls. * Used for GEMDOS HD emulation (see gemdos.c). */ unsigned long OpCode_GemDos(uae_u32 opcode) { GemDOS_OpCode(); /* handler code in gemdos.c */ m68k_incpc(2); fill_prefetch_0(); return 4; }
void REGPARAM2 call_calltrap(int func) { uae_u32 retval = 0; int has_retval = (trapmode[func] & TRAPFLAG_NO_RETVAL) == 0; int implicit_rts = (trapmode[func] & TRAPFLAG_DORET) != 0; if (*trapstr[func] != 0 && trace_traps) write_log ("TRAP: %s\n", trapstr[func]); /* For monitoring only? */ if (traps[func] == NULL) { _68k_setpc(trapoldfunc[func]); fill_prefetch_0 (); return; } if (func < max_trap) { if (trapmode[func] & TRAPFLAG_EXTRA_STACK) { execute_fn_on_extra_stack(traps[func], has_retval); return; } retval = (*traps[func])(); } else write_log ("illegal emulator trap\n"); if (has_retval) _68k_dreg(0) = retval; if (implicit_rts) { #ifndef USE_FAME_CORE m68k_do_rts (); #else /* WinUAE code - m68k_do_rts() */ _68k_setpc(get_long(_68k_areg(7))); _68k_areg(7) += 4; /*******************************/ #endif fill_prefetch_0 (); } }
static void do_stack_magic (TrapFunction f, void *s, int has_retval) { #ifdef CAN_DO_STACK_MAGIC uaecptr a7; jmp_buf *j = (jmp_buf *)s; switch (setjmp (j[0])) { case 0: /* Returning directly */ current_extra_stack = s; if (has_retval == -1) { /*write_log ("finishing m68k mode return\n");*/ longjmp (j[1], 1); } /*write_log ("calling native function\n");*/ transfer_control (s, EXTRA_STACK_SIZE, stack_stub, f, has_retval); /* not reached */ return; case 1: /*write_log ("native function complete\n");*/ /* Returning normally. */ if (stack_has_retval (s, EXTRA_STACK_SIZE)) _68k_dreg (0) = get_retval_from_stack (s, EXTRA_STACK_SIZE); free_extra_stack (s); break; case 2: /* Returning to do a m68k call. We're now back on the main stack. */ a7 = _68k_areg(7) -= (sizeof (void *) + 7) & ~3; /* Save stack to restore */ *((void **)get_real_address (a7 + 4)) = s; /* Save special return address: this address contains a * calltrap that will longjmp to the right stack. */ put_long (_68k_areg (7), RTAREA_BASE + 0xFF00); _68k_setpc (m68k_calladdr); fill_prefetch_0 (); /*write_log ("native function calls m68k\n");*/ break; } current_extra_stack = 0; #endif }
/** * This is called after completion of each VDI call */ unsigned long OpCode_VDI(uae_u32 opcode) { Uint32 pc = M68000_GetPC(); /* this is valid only after VDI trap, called from cartridge code */ if (VDI_OldPC && pc >= 0xfa0000 && pc < 0xfc0000) { VDI_Complete(); /* Set PC back to where originated from to continue instruction decoding */ m68k_setpc(VDI_OldPC); VDI_OldPC = 0; } else { /* illegal instruction */ op_illg(opcode); } fill_prefetch_0(); return 4; }
/** * This function will be called at system init by the cartridge routine * (after gemdos init, before booting floppies). * The GEMDOS vector (#$84) is setup and we also initialize the connected * drive mask and Line-A variables (for an extended VDI resolution) from here. */ unsigned long OpCode_SysInit(uae_u32 opcode) { /* Add any drives mapped by TOS in the interim */ ConnectedDriveMask |= STMemory_ReadLong(0x4c2); /* Initialize the connected drive mask */ STMemory_WriteLong(0x4c2, ConnectedDriveMask); if (!bInitGemDOS) { /* Init on boot - see cart.c */ GemDOS_Boot(); /* Update LineA for extended VDI res * D0: LineA base, A1: Font base */ VDI_LineA(regs.regs[0], regs.regs[9]); } m68k_incpc(2); fill_prefetch_0(); return 4; }
static void ersatz_init (void) { int f; uaecptr request; uaecptr a; if (disk_empty (0)) { write_log ("You need to have a diskfile in DF0 to use the Kickstart replacement!\n"); uae_quit (); _68k_setpc (0xF80010); return; } _68k_sreg = 0; /* Set some interrupt vectors */ for (a = 8; a < 0xC0; a += 4) { put_long (a, 0xF8001A); } _68k_ispreg = _68k_mspreg = _68k_uspreg = 0x800; _68k_areg(7) = 0x80000; #ifndef USE_FAME_CORE _68k_intmask = 0; #endif /* Build a dummy execbase */ put_long (4, _68k_areg(6) = 0x676); put_byte (0x676 + 0x129, 0); for (f = 1; f < 105; f++) { put_word (0x676 - 6*f, 0x4EF9); put_long (0x676 - 6*f + 2, 0xF8000C); } /* Some "supported" functions */ put_long (0x676 - 456 + 2, 0xF80014); put_long (0x676 - 216 + 2, 0xF80020); put_long (0x676 - 198 + 2, 0xF80026); put_long (0x676 - 204 + 2, 0xF8002c); put_long (0x676 - 210 + 2, 0xF8002a); /* Build an IORequest */ request = 0x800; put_word (request + 0x1C, 2); put_long (request + 0x28, 0x4000); put_long (request + 0x2C, 0); put_long (request + 0x24, 0x200 * 4); _68k_areg(1) = request; ersatz_doio (); /* kickstart disk loader */ if (get_long(0x4000) == 0x4b49434b) { /* a kickstart disk was found in drive 0! */ write_log ("Loading Kickstart rom image from Kickstart disk\n"); /* print some notes... */ write_log ("NOTE: if UAE crashes set CPU to 68000 and/or chipmem size to 512KB!\n"); /* read rom image from kickstart disk */ put_word (request + 0x1C, 2); put_long (request + 0x28, 0xF80000); put_long (request + 0x2C, 0x200); put_long (request + 0x24, 0x200 * 512); _68k_areg(1) = request; ersatz_doio (); /* read rom image once ajain to mirror address space. not elegant, but it works... */ put_word (request + 0x1C, 2); put_long (request + 0x28, 0xFC0000); put_long (request + 0x2C, 0x200); put_long (request + 0x24, 0x200 * 512); _68k_areg(1) = request; ersatz_doio (); disk_eject (0); _68k_setpc (0xFC0002); fill_prefetch_0 (); uae_reset (); ersatzkickfile = 0; return; } _68k_setpc (0x400C); fill_prefetch_0 (); /* Init the hardware */ put_long (0x3000, 0xFFFFFFFEul); put_long (0xDFF080, 0x3000); put_word (0xDFF088, 0); put_word (0xDFF096, 0xE390); put_word (0xDFF09A, 0xE02C); put_word (0xDFF09E, 0x0000); put_word (0xDFF092, 0x0038); put_word (0xDFF094, 0x00D0); put_word (0xDFF08E, 0x2C81); put_word (0xDFF090, 0xF4C1); put_word (0xDFF02A, 0x8000); put_byte (0xBFD100, 0xF7); put_byte (0xBFEE01, 0); put_byte (0xBFEF01, 0x08); put_byte (0xBFDE00, 0x04); put_byte (0xBFDF00, 0x84); put_byte (0xBFDD00, 0x9F); put_byte (0xBFED01, 0x9F); }