FreeBSD/sys/cddl/dev/dtrace/riscv/dtrace_subr.c
int
dtrace_trap(struct trapframe *frame, u_int type)
{
	/*
	 * A trap can occur while DTrace executes a probe. Before
	 * executing the probe, DTrace blocks re-scheduling and sets
	 * a flag in it's per-cpu flags to indicate that it doesn't
	 * want to fault. On returning from the probe, the no-fault
	 * flag is cleared and finally re-scheduling is enabled.
	 *
	 * Check if DTrace has enabled 'no-fault' mode:
	 *
	 */

	if ((cpu_core[curcpu].cpuc_dtrace_flags & CPU_DTRACE_NOFAULT) != 0) {
		/*
		 * There are only a couple of trap types that are expected.
		 * All the rest will be handled in the usual way.
		 */
		switch (type) {
		case EXCP_LOAD_ACCESS_FAULT:
		case EXCP_STORE_ACCESS_FAULT:
		case EXCP_INSTR_ACCESS_FAULT:
			/* Flag a bad address. */
			cpu_core[curcpu].cpuc_dtrace_flags |= CPU_DTRACE_BADADDR;
			cpu_core[curcpu].cpuc_dtrace_illval = 0;

			/*
			 * Offset the instruction pointer to the instruction
			 * following the one causing the fault.
			 */
			frame->tf_sepc += 4;

			return (1);
		default:
			/* Handle all other traps in the usual way. */
			break;
		}
	}

	/* Handle the trap in the usual way. */
	return (0);
}
/* Function to handle DTrace traps during probes. See riscv/riscv/trap.c */
Function to handle DTrace traps during probes.
Function to handle DTrace traps during probes .
int
dtrace_trap(struct trapframe *frame, u_int type)
{
	if ((cpu_core[curcpu].cpuc_dtrace_flags & CPU_DTRACE_NOFAULT) != 0) {
		switch (type) {
		case EXCP_LOAD_ACCESS_FAULT:
		case EXCP_STORE_ACCESS_FAULT:
		case EXCP_INSTR_ACCESS_FAULT:
			cpu_core[curcpu].cpuc_dtrace_flags |= CPU_DTRACE_BADADDR;
			cpu_core[curcpu].cpuc_dtrace_illval = 0;
			frame->tf_sepc += 4;
			return (1);
		default:
			break;
		}
	}
	return (0);
}
int dtrace_trap ( struct trapframe * frame , u_int type ) { if ( ( cpu_core [ curcpu ] . cpuc_dtrace_flags & CPU_DTRACE_NOFAULT ) != 0 ) { switch ( type ) { case EXCP_LOAD_ACCESS_FAULT : case EXCP_STORE_ACCESS_FAULT : case EXCP_INSTR_ACCESS_FAULT : cpu_core [ curcpu ] . cpuc_dtrace_flags |= CPU_DTRACE_BADADDR ; cpu_core [ curcpu ] . cpuc_dtrace_illval = 0 ; frame -> tf_sepc += 4 ; return ( 1 ) ; default : break ; } } return ( 0 ) ; }
Function to handle DTrace traps during probes.
Function to handle DTrace traps during probes .
/*
	 * A trap can occur while DTrace executes a probe. Before
	 * executing the probe, DTrace blocks re-scheduling and sets
	 * a flag in it's per-cpu flags to indicate that it doesn't
	 * want to fault. On returning from the probe, the no-fault
	 * flag is cleared and finally re-scheduling is enabled.
	 *
	 * Check if DTrace has enabled 'no-fault' mode:
	 *
	 */ /*
		 * There are only a couple of trap types that are expected.
		 * All the rest will be handled in the usual way.
		 */ /* Flag a bad address. */ /*
			 * Offset the instruction pointer to the instruction
			 * following the one causing the fault.
			 */ /* Handle all other traps in the usual way. */ /* Handle the trap in the usual way. */