PatchworkOS
Loading...
Searching...
No Matches
interrupt.h File Reference
#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  interrupt_frame_t
 Trap Frame Structure. More...
 
struct  interrupt_ctx_t
 Per-CPU Interrupt Context. More...
 

Macros

#define INTERRUPT_FRAME_IN_USER_SPACE(frame)   ((frame)->ss == (GDT_SS_RING3) && (frame)->cs == (GDT_CS_RING3))
 Checks if a interrupt frame is from user space.
 

Enumerations

enum  page_fault_errors_t {
  PAGE_FAULT_PRESENT = 1 << 0 ,
  PAGE_FAULT_WRITE = 1 << 1 ,
  PAGE_FAULT_USER = 1 << 2 ,
  PAGE_FAULT_RESERVED = 1 << 3 ,
  PAGE_FAULT_INSTRUCTION = 1 << 4 ,
  PAGE_FAULT_PROTECTION_KEY = 1 << 5 ,
  PAGE_FAULT_SHADOW_STACK = 1 << 6 ,
  PAGE_FAULT_SOFTWARE_GUARD_EXT = 1 << 7
}
 Page Fault Error Codes. More...
 
enum  interrupt_t {
  EXCEPTION_DIVIDE_ERROR = 0x0 ,
  EXCEPTION_DEBUG = 0x1 ,
  EXCEPTION_NMI = 0x2 ,
  EXCEPTION_BREAKPOINT = 0x3 ,
  EXCEPTION_OVERFLOW = 0x4 ,
  EXCEPTION_BOUND_RANGE_EXCEEDED = 0x5 ,
  EXCEPTION_INVALID_OPCODE = 0x6 ,
  EXCEPTION_DEVICE_NOT_AVAILABLE = 0x7 ,
  EXCEPTION_DOUBLE_FAULT = 0x8 ,
  EXCEPTION_COPROCESSOR_SEGMENT_OVERRUN = 0x9 ,
  EXCEPTION_INVALID_TSS = 0xA ,
  EXCEPTION_SEGMENT_NOT_PRESENT = 0xB ,
  EXCEPTION_STACK_FAULT = 0xC ,
  EXCEPTION_GENERAL_PROTECTION = 0xD ,
  EXCEPTION_PAGE_FAULT = 0xE ,
  EXCEPTION_RESERVED = 0xF ,
  EXCEPTION_X87_FPU_ERROR = 0x10 ,
  EXCEPTION_ALIGNMENT_CHECK = 0x11 ,
  EXCEPTION_MACHINE_CHECK = 0x12 ,
  EXCEPTION_SIMD_EXCEPTION = 0x13 ,
  EXCEPTION_VIRTUALIZATION_EXCEPTION = 0x14 ,
  EXCEPTION_CONTROL_PROTECTION_EXCEPTION = 0x15 ,
  EXCEPTION_RESERVED_16 = 0x16 ,
  EXCEPTION_RESERVED_17 = 0x17 ,
  EXCEPTION_RESERVED_18 = 0x18 ,
  EXCEPTION_RESERVED_19 = 0x19 ,
  EXCEPTION_RESERVED_1A = 0x1A ,
  EXCEPTION_RESERVED_1B = 0x1B ,
  EXCEPTION_RESERVED_1C = 0x1C ,
  EXCEPTION_RESERVED_1D = 0x1D ,
  EXCEPTION_RESERVED_1E = 0x1E ,
  EXCEPTION_RESERVED_1F = 0x1F ,
  EXCEPTION_AMOUNT = 0x20 ,
  EXTERNAL_INTERRUPT_BASE = 0x20 ,
  INTERRUPT_TLB_SHOOTDOWN = 0xFA ,
  INTERRUPT_DIE = 0xFB ,
  INTERRUPT_NOTE = 0xFC ,
  INTERRUPT_TIMER = 0xFD ,
  INTERRUPT_HALT = 0xFE ,
  INTERRUPT_AMOUNT = 0xFF
}
 CPU vector identifiers. More...
 

Functions

void interrupt_ctx_init (interrupt_ctx_t *ctx)
 Initializes the CLI context.
 
void interrupt_disable (void)
 Disable interrupts and increment the disableDepth.
 
void interrupt_enable (void)
 Decrement the CLI depth and enable interrupts if depth reaches zero and interrupts were previously enabled.
 
void interrupt_handler (interrupt_frame_t *frame)
 Handles CPU interrupts.
 

Variables

void * vectorTable [INTERRUPT_AMOUNT]
 Pointers to functions to handle each vector.