vbos/include/kernel/idt.h
Michael Shaw 37518aea81 usr: implement user process switching
This is a rather large commit, so the gist of it is this:

User context switching is now functional, after a change to the TSS, and
a few minor details in the scheduler and loader.

ELF parsing is rather primitive, but basically functional, as long as it
only loads code.

The interrupt 0x80 is for syscalls, and will switch from user mode to
kernel mode. It is currently the only interrupt that can be called from
user mode

This adds the syscall functionality, which currently uses a red-black
tree to store the function pointers, although when the table is more
flushed out, it will probably be replaced with an array

The pager now correctly marks the parent nodes with attributes as it
allocates them. Without doing this, the page table entries will never be
reached in lower privilege modes, causing page faults

Signed-off-by: Michael Shaw <spencershawiscool@gmail.com>
2023-11-20 22:07:35 -05:00

41 lines
684 B
C

/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef _IDT_H_
#define _IDT_H_
#define GATE_INTR 0x8E
#define GATE_TRAP 0x8F
#define GATE_INTR_DPL3 0xEE
#define IDT_GATE_SIZE 16
#define IDT_NUM_VECTORS 256
#define IDT_SIZE (IDT_GATE_SIZE * IDT_NUM_VECTORS)
#ifndef __ASM__
#include <kernel/common.h>
struct irqdesc {
uint16_t offset_low;
uint16_t segment;
uint8_t ist;
uint8_t attrs;
uint16_t offset_mid;
uint32_t offset_high;
uint32_t reserved;
} PACKED;
struct idtr {
uint16_t size;
uint64_t offset;
} PACKED;
void idt_init();
void cli();
void sti();
extern struct idtr __idtr;
extern struct irqdesc __idt[IDT_NUM_VECTORS];
#endif /* __ASM__ */
#endif /* _IDT_H_ */