Beispiel #1
0
/*
* Set up extended trap context and call handler function
*/
static void trap_HandleExtendedTrap (TrapHandler handler_func, int has_retval)
{
	struct TrapContext *context = xcalloc (TrapContext, 1);

	if (context) {
		uae_sem_init (&context->switch_to_trap_sem, 0, 0);
		uae_sem_init (&context->switch_to_emu_sem, 0, 0);

		context->trap_handler = handler_func;
		context->trap_has_retval = has_retval;

		//context->saved_regs = regs;
		copytocpucontext (&context->saved_regs);

		/* Start thread to handle new trap context. */
		uae_start_thread_fast (trap_thread, (void *)context, &context->thread);

		/* Switch to trap context to begin execution of
		* trap handler function.
		*/
		uae_sem_post (&context->switch_to_trap_sem);

		/* Wait for trap context to switch back to us.
		*
		* It'll do this when the trap handler is done - or when
		* the handler wants to call 68k code. */
		uae_sem_wait (&context->switch_to_emu_sem);
	}
}
Beispiel #2
0
/*
 * Set up extended trap context and call handler function
 */
static void trap_HandleExtendedTrap (TrapHandler handler_func, int has_retval)
{
    struct ExtendedTrapContext *context = (struct ExtendedTrapContext *) calloc (1, sizeof (ExtendedTrapContext));

    if (context) {
	uae_sem_init (&context->switch_to_trap_sem, 0, 0);
	uae_sem_init (&context->switch_to_emu_sem, 0, 0);

	context->trap_handler    = handler_func;
	context->trap_has_retval = has_retval;

	context->regs = regs;       /* Working copy of regs */

	context->saved_regs = regs; /* Copy of regs to be restored when trap is done */

	/* Start thread to handle new trap context. */
	uae_start_thread_fast (trap_thread, (void *)context, &context->thread);

	/* Switch to trap context to begin execution of
	 * trap handler function.
	 */
	uae_sem_post (&context->switch_to_trap_sem);

	/* Wait for trap context to switch back to us.
	 *
	 * It'll do this when the trap handler is done - or when
	 * the handler wants to call 68k code. */
	uae_sem_wait (&context->switch_to_emu_sem);

	/* Use trap's modified 68k state. This will reset the PC, so that
	 * execution will resume at either the m68k call handler or the
	 * the exit handler. */
	regs = context->regs;
    }
}
Beispiel #3
0
/*
* Initialize trap mechanism.
*/
void init_traps(void)
{
	trap_count = 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]);
		}
	}
}