next up previous contents index
Next: 10.20 Boot Module Filesystem Up: 10.19 Annotations Previous: anno_intr: (X86) interrupt annotations

anno_trap: (X86) trap annotations

   

SYNOPSIS

#include <oskit/anno.h>

struct anno_table anno_trap ;

ANNO_TRAP (routine, val3)

int anno_trap_handler(struct anno_entry *anno, struct trap_state *tstate);

DESCRIPTION

The trap annotation table anno_trap contains entries which associate a handler function with specific addresses in the kernel. These addresses correspond to points where synchronous exceptions are expected to occur. When such an exception occurs, the default OSKit trap handler (in base_trap_inittab.S) uses anno_find_exact to locate an annotation entry based on the instruction pointer at the time of the fault. This handler function is invoked instead of the standard kernel trap handler in those instances.

ANNO_TRAP is a macro in oskit/x86/anno.h. It records an annotation in anno_trap for the current point in the code segment. The given routine and val3 arguments are stored in the entry's val2 and val3 fields respectively.

The annotation trap handler function is called in the context of the faulting thread with a pointer to the matching annotation entry and a pointer to the architecture-specific trap state for the thread. If the handler returns zero, the OSKit trap handler will restore state from the trap state structure and resume execution. If it returns non-zero, it is considered a failed fault and the kernel will panic.

An example of trap annotation usage is a kernel copyin routine which must read data in the user's address space. Associating an annotation entry with the instruction which moves data from the user's address space enables the kernel to catch any access violation caused and reflect it to the user.



University of Utah Flux Research Group