diff options
Diffstat (limited to 'src/loader/inc')
-rw-r--r-- | src/loader/inc/a20.h | 10 | ||||
-rw-r--r-- | src/loader/inc/cpu.h | 3 | ||||
-rw-r--r-- | src/loader/inc/def.h | 1 | ||||
-rw-r--r-- | src/loader/inc/gdt.h | 25 | ||||
-rw-r--r-- | src/loader/inc/int.h | 2 | ||||
-rw-r--r-- | src/loader/inc/mem.h | 32 | ||||
-rw-r--r-- | src/loader/inc/rem.h | 29 |
7 files changed, 102 insertions, 0 deletions
diff --git a/src/loader/inc/a20.h b/src/loader/inc/a20.h new file mode 100644 index 0000000..705ada0 --- /dev/null +++ b/src/loader/inc/a20.h @@ -0,0 +1,10 @@ +// MIT License, Copyright (c) 2021 Marvin Borner + +#ifndef A20_H +#define A20_H + +#include <def.h> + +void a20_enable(void); + +#endif diff --git a/src/loader/inc/cpu.h b/src/loader/inc/cpu.h index 0236002..4fa7d0c 100644 --- a/src/loader/inc/cpu.h +++ b/src/loader/inc/cpu.h @@ -13,4 +13,7 @@ void outb(u16 port, u8 data); void outw(u16 port, u16 data); void outl(u16 port, u32 data); +u16 mminw(u32 addr); +void mmoutw(u32 addr, u16 value); + #endif diff --git a/src/loader/inc/def.h b/src/loader/inc/def.h index a8ee30b..e42c372 100644 --- a/src/loader/inc/def.h +++ b/src/loader/inc/def.h @@ -28,6 +28,7 @@ typedef __builtin_va_list va_list; #define STRINGIFY_PARAM(a) #a #define STRINGIFY(a) STRINGIFY_PARAM(a) +#define REAL __attribute__((section(".realmode"))) #define PACKED __attribute__((packed)) #endif diff --git a/src/loader/inc/gdt.h b/src/loader/inc/gdt.h new file mode 100644 index 0000000..1ff20b7 --- /dev/null +++ b/src/loader/inc/gdt.h @@ -0,0 +1,25 @@ +// MIT License, Copyright (c) 2021 Marvin Borner + +#ifndef GDT_H +#define GDT_H + +#include <def.h> + +struct gdtr { + u16 limit; + u32 ptr; + u32 pad; +} PACKED; + +struct gdt_desc { + u16 limit; + u16 base_low; + u8 base_mid; + u8 access; + u8 granularity; + u8 base_hi; +} PACKED; + +extern struct gdtr gdt; + +#endif diff --git a/src/loader/inc/int.h b/src/loader/inc/int.h index ccd9ea8..8336cd8 100644 --- a/src/loader/inc/int.h +++ b/src/loader/inc/int.h @@ -43,6 +43,8 @@ struct idt_ptr { void *base; } PACKED; +extern struct idt_ptr idt; + void idt_install(void); void int_event_handler_add(u32 int_no, void (*handler)(void)); diff --git a/src/loader/inc/mem.h b/src/loader/inc/mem.h new file mode 100644 index 0000000..7153465 --- /dev/null +++ b/src/loader/inc/mem.h @@ -0,0 +1,32 @@ +// MIT License, Copyright (c) 2021 Marvin Borner + +#ifndef MEM_H +#define MEM_H + +#include <def.h> + +enum mem_entry_type { + MEM_NONE, + MEM_USABLE, + MEM_RESERVED, + MEM_RECLAIMABLE, + MEM_ACPI_NVS, + MEM_UNUSABLE, +}; + +// Generalised memory map entry struct +struct mem_entry { + u32 base; + u32 length; + u32 type; +}; + +struct mem_map { + struct mem_entry *entry; + u32 count; +}; + +void mem_map(void); +struct mem_map *mem_map_get(void); + +#endif diff --git a/src/loader/inc/rem.h b/src/loader/inc/rem.h new file mode 100644 index 0000000..61eb30a --- /dev/null +++ b/src/loader/inc/rem.h @@ -0,0 +1,29 @@ +// MIT License, Copyright (c) 2021 Marvin Borner +// Real mode emulation - Implementation by Napalm (see rem.asm) + +#ifndef REM_H +#define REM_H + +#include <def.h> + +#define EFLAGS_CF (1 << 0) // Carry flag +#define EFLAGS_ZF (1 << 6) // Zero flag + +struct rem_regs { + u16 gs; + u16 fs; + u16 es; + u16 ds; + u32 eflags; + u32 ebp; + u32 edi; + u32 esi; + u32 edx; + u32 ecx; + u32 ebx; + u32 eax; +} PACKED; + +void rem_int(u8 int_num, struct rem_regs *out_regs, struct rem_regs *in_regs); + +#endif |