Initial commit
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
#ifndef IDT_H
|
||||
#define IDT_H
|
||||
#include "../include/types.h"
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct {
|
||||
uint16_t isr_low; // The lower 16 bits of the ISR's address
|
||||
uint16_t kernel_cs; // The GDT segment selector that the CPU will load into CS before calling the ISR
|
||||
uint8_t reserved; // Set to zero
|
||||
uint8_t attributes; // Type and attributes; see the IDT page
|
||||
uint16_t isr_high; // The higher 16 bits of the ISR's address
|
||||
} __attribute__((packed)) idt_entry_t;
|
||||
|
||||
__attribute__((aligned(0x10)))
|
||||
static idt_entry_t idt[256]; // Create an array of IDT entries; aligned for performance
|
||||
|
||||
typedef struct {
|
||||
uint16_t limit;
|
||||
uint32_t base;
|
||||
} __attribute__((packed)) idtr_t;
|
||||
|
||||
static idtr_t idtr;
|
||||
|
||||
//void idt_init(void);
|
||||
//void idt_set_descriptor(uint8_t vector, void* isr, uint8_t flags);
|
||||
void idt_set_descriptor(uint8 vector, uint32 isr, uint8_t flags);
|
||||
void idt_set();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#ifndef ISR_H
|
||||
#define ISR_H
|
||||
|
||||
void isr0();
|
||||
void isr1();
|
||||
void isr2();
|
||||
void isr3();
|
||||
void isr4();
|
||||
void isr5();
|
||||
void isr6();
|
||||
void isr7();
|
||||
void isr8();
|
||||
void isr9();
|
||||
void isr10();
|
||||
void isr11();
|
||||
void isr12();
|
||||
void isr13();
|
||||
void isr14();
|
||||
void isr15();
|
||||
void isr16();
|
||||
void isr17();
|
||||
void isr18();
|
||||
void isr19();
|
||||
void isr20();
|
||||
void isr21();
|
||||
void isr22();
|
||||
void isr23();
|
||||
void isr24();
|
||||
void isr25();
|
||||
void isr26();
|
||||
void isr27();
|
||||
void isr28();
|
||||
void isr29();
|
||||
void isr30();
|
||||
void isr31();
|
||||
|
||||
static char* exception_messages[32];
|
||||
|
||||
void isr_install();
|
||||
#endif
|
||||
@@ -0,0 +1,42 @@
|
||||
// screen.h
|
||||
#ifndef SCREEN_H
|
||||
#define SCREEN_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* Hardware text mode color constants. */
|
||||
enum vga_color {
|
||||
VGA_COLOR_BLACK = 0,
|
||||
VGA_COLOR_BLUE = 1,
|
||||
VGA_COLOR_GREEN = 2,
|
||||
VGA_COLOR_CYAN = 3,
|
||||
VGA_COLOR_RED = 4,
|
||||
VGA_COLOR_MAGENTA = 5,
|
||||
VGA_COLOR_BROWN = 6,
|
||||
VGA_COLOR_LIGHT_GREY = 7,
|
||||
VGA_COLOR_DARK_GREY = 8,
|
||||
VGA_COLOR_LIGHT_BLUE = 9,
|
||||
VGA_COLOR_LIGHT_GREEN = 10,
|
||||
VGA_COLOR_LIGHT_CYAN = 11,
|
||||
VGA_COLOR_LIGHT_RED = 12,
|
||||
VGA_COLOR_LIGHT_MAGENTA = 13,
|
||||
VGA_COLOR_LIGHT_BROWN = 14,
|
||||
VGA_COLOR_WHITE = 15,
|
||||
};
|
||||
|
||||
static const size_t VGA_WIDTH = 80;
|
||||
static const size_t VGA_HEIGHT = 25;
|
||||
|
||||
uint8_t vga_entry_color(enum vga_color fg, enum vga_color bg);
|
||||
uint16_t vga_entry(unsigned char uc, uint8_t color);
|
||||
size_t strlen(const char* str);
|
||||
void terminal_initialize(void);
|
||||
void terminal_setcolor(uint8_t color);
|
||||
void terminal_putentryat(char c, uint8_t color, size_t x, size_t y);
|
||||
void terminal_putchar(char c);
|
||||
void terminal_write(const char* data, size_t size);
|
||||
void terminal_writestring(const char* data);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef TYPES_H
|
||||
#define TYPES_H
|
||||
|
||||
typedef signed char int8;
|
||||
typedef unsigned char uint8;
|
||||
|
||||
typedef signed short int16;
|
||||
typedef unsigned short uint16;
|
||||
|
||||
typedef signed int int32;
|
||||
typedef unsigned int uint32;
|
||||
|
||||
typedef signed long long int64;
|
||||
typedef unsigned long long uint64;
|
||||
|
||||
typedef char* string;
|
||||
|
||||
#define low_16(address) (uint16)((address) & 0xFFFF)
|
||||
#define high_16(address) (uint16)(((address) >> 16) & 0xFFFF)
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user