#

include(`emuniv.h')

/*
 *       SCCS File Type - Emulator Source File
 *
 *       What identification string
 */
static char *_S_K10     "@(#)EM_K10.c	3.2";

	/****************************************************************
	 *
	 *      K_interrupt_return
	 */

/*
 *      K_interrupt_return ()
 */

K_interrupt_return ()
{
#       ifdef EMULATOR
	/*
	 * Make sure our pseudo-interrupt vector is ok before
	 * returning to the user:
	 */
	chkPIV ();
#       endif

	return (EMT10 ());
}


# ifdef EMULATOR
/*
 * Verify the integrity of the pseudo-interrupt vectors.
 */

chkPIV ()
{
	extern Fstruct                  F;
	extern t_FProcTab_index         ownPindex;
	extern pseudo_int_vectors       dPIV;
	register pseudo_int_vector      *PIV;
	register pseudo_int_levels      lev;
	proc_stat_block                 ps_blk;

	K_get_process_status (ownSEID, &ps_blk);
	lev = ps_blk.pseint;

	PIV = PI_ADDRESS;
	if (  PIV[lev].new_pc != dPIV[lev].new_pc
	   OR PIV[lev].new_ps != dPIV[lev].new_ps
	   OR (PIV[lev].interrupted_ps & TBIT)
	   OR (PIV[lev].interrupted_pc & 01)
	   )
	{       panic ( "corrupted int vector; lev: %d, new_pc: %o, new_ps: %o, int_pc: %o, int_ps: %o"
		      , lev
		      , PIV[lev].new_pc
		      , PIV[lev].new_ps
		      , PIV[lev].interrupted_pc
		      , PIV[lev].interrupted_ps
		      );
	}
	/* Dump out what we will return to: */
	debug15 ( ":< %d : %o : %o\n"
		, PIV[lev].interrupted_p_level
		, PIV[lev].interrupted_pc
		, PIV[lev].interrupted_ps
		);
}
# endif
