#include "doscmd.h"

void
softint(int intnum)
{
#define	sc	(&saved_sigframe->sf_sc)
	u_long vec = ivec[intnum];

	if (dead || !saved_valid || vec == 0)
		return;

	if ((vec >> 16) == 0xf000 || *(u_char *)VECPTR(vec) == 0xcf)
		return;

	debug(D_TRAPS|intnum, "Int%x [%04x:%04x]\n",
	    intnum, vec >> 16, vec & 0xffff);

	PUSH(GET16(sc->sc_eflags), sc);
	PUSH(GET16(sc->sc_cs), sc);
	PUSH(GET16(sc->sc_eip), sc);
	PUTVEC(sc->sc_cs, sc->sc_eip, vec);
#undef	sc
}

void
hardint(int intnum)
{
#define	sc	(&saved_sigframe->sf_sc)
	/*
	 * XXXXX
	 * We should simulate the IRQ mask in the PIC.
	 */
	if (sc->sc_eflags & PSL_I) {
		u_long vec = ivec[intnum];

		if (dead || !saved_valid || vec == 0)
			return;

		if ((vec >> 16) == 0xf000 || *(u_char *)VECPTR(vec) == 0xcf)
			return;

		debug(D_TRAPS|intnum, "Int%x [%04x:%04x]\n",
		    intnum, vec >> 16, vec & 0xffff);

		PUSH(GET16(sc->sc_eflags), sc);
		PUSH(GET16(sc->sc_cs), sc);
		PUSH(GET16(sc->sc_eip), sc);
		sc->sc_eflags &= ~PSL_I;
		PUTVEC(sc->sc_cs, sc->sc_eip, vec);
	}
#undef	sc
}
