mirror of
https://github.com/johndoe6345789/MetalOS.git
synced 2026-04-26 06:35:12 +00:00
Add CMake, Ninja, and Conan support with kernel modules (GDT, interrupts)
Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
25
kernel/include/kernel/gdt.h
Normal file
25
kernel/include/kernel/gdt.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef METALOS_KERNEL_GDT_H
|
||||
#define METALOS_KERNEL_GDT_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// GDT Entry structure
|
||||
typedef struct {
|
||||
uint16_t limit_low;
|
||||
uint16_t base_low;
|
||||
uint8_t base_middle;
|
||||
uint8_t access;
|
||||
uint8_t granularity;
|
||||
uint8_t base_high;
|
||||
} __attribute__((packed)) gdt_entry_t;
|
||||
|
||||
// GDT Pointer structure
|
||||
typedef struct {
|
||||
uint16_t limit;
|
||||
uint64_t base;
|
||||
} __attribute__((packed)) gdt_ptr_t;
|
||||
|
||||
// Initialize the Global Descriptor Table
|
||||
void gdt_init(void);
|
||||
|
||||
#endif // METALOS_KERNEL_GDT_H
|
||||
37
kernel/include/kernel/interrupts.h
Normal file
37
kernel/include/kernel/interrupts.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef METALOS_KERNEL_INTERRUPTS_H
|
||||
#define METALOS_KERNEL_INTERRUPTS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// IDT Entry structure
|
||||
typedef struct {
|
||||
uint16_t offset_low; // Offset bits 0-15
|
||||
uint16_t selector; // Code segment selector
|
||||
uint8_t ist; // Interrupt Stack Table offset
|
||||
uint8_t type_attr; // Type and attributes
|
||||
uint16_t offset_mid; // Offset bits 16-31
|
||||
uint32_t offset_high; // Offset bits 32-63
|
||||
uint32_t zero; // Reserved
|
||||
} __attribute__((packed)) idt_entry_t;
|
||||
|
||||
// IDT Pointer structure
|
||||
typedef struct {
|
||||
uint16_t limit;
|
||||
uint64_t base;
|
||||
} __attribute__((packed)) idt_ptr_t;
|
||||
|
||||
// CPU registers state (for interrupt handlers)
|
||||
typedef struct {
|
||||
uint64_t r15, r14, r13, r12, r11, r10, r9, r8;
|
||||
uint64_t rbp, rdi, rsi, rdx, rcx, rbx, rax;
|
||||
uint64_t int_no, err_code;
|
||||
uint64_t rip, cs, rflags, rsp, ss;
|
||||
} __attribute__((packed)) registers_t;
|
||||
|
||||
// Initialize Interrupt Descriptor Table
|
||||
void idt_init(void);
|
||||
|
||||
// Generic interrupt handler (called from assembly)
|
||||
void interrupt_handler(registers_t* regs);
|
||||
|
||||
#endif // METALOS_KERNEL_INTERRUPTS_H
|
||||
Reference in New Issue
Block a user