Voxia OS v0.0.1
Hobby Project Operating System Targeting x86-64
Loading...
Searching...
No Matches
interrupt.c File Reference
#include "./interrupt.h"
#include "autoconf.h"
#include "console/console.h"
#include "hal/apic/apic.h"
#include "hal/cpu/paging.h"
#include "init/init.h"
#include <hal/cpu/core.h>
#include <libk/debug/debug.h>
#include <libk/io.h>
#include <libk/serial.h>
#include <memory/memory_utils.h>
#include <memory/vm_manager.h>
#include <procc/scheduler.h>
#include <procc/task.h>
#include <spinlock.h>
#include <str.h>
#include <type.h>

Go to the source code of this file.

Enumerations

enum  EXCEPTION_ID {
  DIVIDE_BY_ZERO = 0 , DEBUG = 1 , NON_MASKABLE_INTERRUPT = 2 , BREAKPOINT = 3 ,
  INTO_DETECTED_OVERFLOW = 4 , OUT_OF_BOUNDS = 5 , INVALID_OPCODE = 6 , NO_COPROCESSOR = 7 ,
  DOUBLE_FAULT = 8 , COPROCESSOR_SEGMENT_OVERRUN = 9 , BAD_TSS = 10 , SEGMENT_NOT_PRESENT = 11 ,
  STACK_FAULT = 12 , GENERAL_PROTECTION_FAULT = 13 , PAGE_FAULT = 14 , X87_FPU_FLOATING_POINT_ERROR = 16 ,
  ALIGNMENT_CHECK = 17 , MACHINE_CHECK = 18 , SIMD_FLOATING_POINT_EXCEPTION = 19 , VIRTUALIZATION_EXCEPTION = 20 ,
  CONTORL_PROTECTION_EXCEPTION = 21 , HYPERVISOR_INJECTION_EXCEPTION = 28 , VMM_COMMUNICATION_EXCEPTION = 29 , SECURITY_EXCEPTION = 30
}
 

Functions

static void interrupt_io_wait ()
 
static void interrupt_pic_remap (void)
 
static void interrupt_reload (interrupt_pointers_t *ptr, interrupt_entry_t *tbl)
 
static void interrupt_register (interrupt_entry_t *entries, int n, void *handler, int selector, uint8_t ist, uint8_t type_attr)
 
void irq_register (uint8_t core, int n, void *handler, boolean_t use_default_isr, uint16_t selector, uint8_t ist, uint8_t type_attr)
 
uint16_t irq_alloc_entry (uint8_t core)
 
void irq_setup (uint16_t core)
 
 INIT (Interrupt)
 
void jump_usermode (uintptr_t addr)
 
void init_runtime ()
 
void timer_handle (void)
 
void virtio_irq ()
 
 __attribute__ ((no_stack_protector))
 

Variables

static interrupt_per_core_data_t interrupt_per_core_data [VOXIA_MAX_CORE] = {0}
 
void * int_table []
 
static const char * exception_messages []
 
boolean_t is_running_program = 0
 
boolean_t g__scheduler__is__running
 
boolean_t elf_has_running
 
uintptr_t rip_before_run_elf
 
spinlock_t int_lock
 

Enumeration Type Documentation

◆ EXCEPTION_ID

Enumerator
DIVIDE_BY_ZERO 
DEBUG 
NON_MASKABLE_INTERRUPT 
BREAKPOINT 
INTO_DETECTED_OVERFLOW 
OUT_OF_BOUNDS 
INVALID_OPCODE 
NO_COPROCESSOR 
DOUBLE_FAULT 
COPROCESSOR_SEGMENT_OVERRUN 
BAD_TSS 
SEGMENT_NOT_PRESENT 
STACK_FAULT 
GENERAL_PROTECTION_FAULT 
PAGE_FAULT 
X87_FPU_FLOATING_POINT_ERROR 
ALIGNMENT_CHECK 
MACHINE_CHECK 
SIMD_FLOATING_POINT_EXCEPTION 
VIRTUALIZATION_EXCEPTION 
CONTORL_PROTECTION_EXCEPTION 
HYPERVISOR_INJECTION_EXCEPTION 
VMM_COMMUNICATION_EXCEPTION 
SECURITY_EXCEPTION 

Definition at line 185 of file interrupt.c.

Function Documentation

◆ __attribute__()

◆ INIT()

INIT ( Interrupt )

Definition at line 145 of file interrupt.c.

References irq_setup(), and update_core_gs().

◆ init_runtime()

void init_runtime ( )
extern

◆ interrupt_io_wait()

static void interrupt_io_wait ( )
static

Definition at line 21 of file interrupt.c.

References outb().

Referenced by interrupt_pic_remap().

◆ interrupt_pic_remap()

static void interrupt_pic_remap ( void )
static

Definition at line 23 of file interrupt.c.

References ICW1_ICW4, ICW1_INIT, ICW4_8086, interrupt_io_wait(), outb(), PIC1_COMMAND, PIC1_DATA, PIC2_COMMAND, and PIC2_DATA.

Referenced by irq_setup().

◆ interrupt_register()

static void interrupt_register ( interrupt_entry_t * entries,
int n,
void * handler,
int selector,
uint8_t ist,
uint8_t type_attr )
static

Definition at line 50 of file interrupt.c.

References ist.

Referenced by irq_register(), and irq_setup().

◆ interrupt_reload()

static void interrupt_reload ( interrupt_pointers_t * ptr,
interrupt_entry_t * tbl )
static

Definition at line 39 of file interrupt.c.

References MAX_INTERRUPTS, and ptr.

Referenced by irq_setup().

◆ irq_alloc_entry()

uint16_t irq_alloc_entry ( uint8_t core)

Definition at line 109 of file interrupt.c.

References irq_entry_t::allocated, core, interrupt_per_core_data, and MAX_INTERRUPTS.

Referenced by __attribute__().

◆ irq_register()

void irq_register ( uint8_t core,
int n,
void * handler,
boolean_t use_default_isr,
uint16_t selector,
uint8_t ist,
uint8_t type_attr )

◆ irq_setup()

◆ jump_usermode()

void jump_usermode ( uintptr_t addr)
extern

References addr.

◆ timer_handle()

void timer_handle ( void )
extern

◆ virtio_irq()

void virtio_irq ( )
extern

Variable Documentation

◆ elf_has_running

boolean_t elf_has_running
extern

Definition at line 14 of file elf.c.

Referenced by virtio_irq().

◆ exception_messages

const char* exception_messages[]
static

Definition at line 150 of file interrupt.c.

Referenced by __attribute__().

◆ g__scheduler__is__running

boolean_t g__scheduler__is__running
extern

Definition at line 19 of file scheduler.c.

Referenced by init_runtime(), and usleep().

◆ int_lock

spinlock_t int_lock

Definition at line 221 of file interrupt.c.

◆ int_table

void* int_table[]
extern

Referenced by irq_register(), and irq_setup().

◆ interrupt_per_core_data

interrupt_per_core_data_t interrupt_per_core_data[VOXIA_MAX_CORE] = {0}
static

Definition at line 19 of file interrupt.c.

Referenced by __attribute__(), irq_alloc_entry(), irq_register(), and irq_setup().

◆ is_running_program

boolean_t is_running_program = 0

Definition at line 212 of file interrupt.c.

◆ rip_before_run_elf

uintptr_t rip_before_run_elf
extern

Definition at line 15 of file elf.c.

Referenced by virtio_irq().