mirror of
https://github.com/encounter/osdev.git
synced 2026-07-10 12:18:43 -07:00
101 lines
2.9 KiB
C
101 lines
2.9 KiB
C
#pragma once
|
|
|
|
#include <common.h>
|
|
|
|
void init_descriptor_tables();
|
|
|
|
// This structure contains the value of one GDT entry.
|
|
// We use the attribute 'packed' to tell GCC not to change
|
|
// any of the alignment in the structure.
|
|
struct gdt_entry {
|
|
uint16_t limit_low; // The lower 16 bits of the limit.
|
|
uint16_t base_low; // The lower 16 bits of the base.
|
|
uint8_t base_middle; // The next 8 bits of the base.
|
|
uint8_t access; // Access flags, determine what ring this segment can be used in.
|
|
uint8_t granularity;
|
|
uint8_t base_high; // The last 8 bits of the base.
|
|
} _packed;
|
|
|
|
typedef struct gdt_entry gdt_entry_t;
|
|
|
|
static_assert(sizeof(gdt_entry_t) == 8, "gdt_entry incorrect size");
|
|
|
|
struct gdt_ptr {
|
|
uint16_t limit; // The upper 16 bits of all selector limits.
|
|
uint32_t base; // The address of the first gdt_entry_t struct.
|
|
} _packed;
|
|
|
|
typedef struct gdt_ptr gdt_ptr_t;
|
|
|
|
// A struct describing an interrupt gate.
|
|
struct idt_entry
|
|
{
|
|
uint16_t base_lo; // The lower 16 bits of the address to jump to when this interrupt fires.
|
|
uint16_t sel; // Kernel segment selector.
|
|
uint8_t always0; // This must always be zero.
|
|
uint8_t flags; // More flags. See documentation.
|
|
uint16_t base_hi; // The upper 16 bits of the address to jump to.
|
|
} _packed;
|
|
typedef struct idt_entry idt_entry_t;
|
|
|
|
static_assert(sizeof(idt_entry_t) == 8, "idt_entry incorrect size");
|
|
|
|
// A struct describing a pointer to an array of interrupt handlers.
|
|
// This is in a format suitable for giving to 'lidt'.
|
|
struct idt_ptr
|
|
{
|
|
uint16_t limit;
|
|
uint32_t base; // The address of the first element in our idt_entry_t array.
|
|
} _packed;
|
|
typedef struct idt_ptr idt_ptr_t;
|
|
|
|
// These extern directives let us access the addresses of our ASM ISR handlers.
|
|
extern void isr0 ();
|
|
extern void isr1 ();
|
|
extern void isr2 ();
|
|
extern void isr3 ();
|
|
extern void isr4 ();
|
|
extern void isr5 ();
|
|
extern void isr6 ();
|
|
extern void isr7 ();
|
|
extern void isr8 ();
|
|
extern void isr9 ();
|
|
extern void isr10();
|
|
extern void isr11();
|
|
extern void isr12();
|
|
extern void isr13();
|
|
extern void isr14();
|
|
extern void isr15();
|
|
extern void isr16();
|
|
extern void isr17();
|
|
extern void isr18();
|
|
extern void isr19();
|
|
extern void isr20();
|
|
extern void isr21();
|
|
extern void isr22();
|
|
extern void isr23();
|
|
extern void isr24();
|
|
extern void isr25();
|
|
extern void isr26();
|
|
extern void isr27();
|
|
extern void isr28();
|
|
extern void isr29();
|
|
extern void isr30();
|
|
extern void isr31();
|
|
|
|
extern void irq0 ();
|
|
extern void irq1 ();
|
|
extern void irq2 ();
|
|
extern void irq3 ();
|
|
extern void irq4 ();
|
|
extern void irq5 ();
|
|
extern void irq6 ();
|
|
extern void irq7 ();
|
|
extern void irq8 ();
|
|
extern void irq9 ();
|
|
extern void irq10();
|
|
extern void irq11();
|
|
extern void irq12();
|
|
extern void irq13();
|
|
extern void irq14();
|
|
extern void irq15(); |