summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorBenji Dial <benji@benjidial.net>2024-01-15 15:44:20 -0500
committerBenji Dial <benji@benjidial.net>2024-01-15 15:44:20 -0500
commitc9a1266d219a83882735a3a8304f3824e0219cdb (patch)
treefea71a0b5b0de8f3a8962dc6ed417273f231e2a9 /include
parent7c6a18d77a81f232ad2e1d3a311bb21ea8f1f5b4 (diff)
downloadhilbert-os-c9a1266d219a83882735a3a8304f3824e0219cdb.tar.gz
redo application paging and system calls, rename mercury to hilbert
Diffstat (limited to 'include')
-rw-r--r--include/hilbert/kernel/application.hpp (renamed from include/mercury/kernel/application.hpp)26
-rw-r--r--include/hilbert/kernel/framebuffer.hpp (renamed from include/mercury/kernel/framebuffer.hpp)10
-rw-r--r--include/hilbert/kernel/paging.hpp (renamed from include/mercury/kernel/paging.hpp)13
-rw-r--r--include/hilbert/kernel/storage.hpp (renamed from include/mercury/kernel/storage.hpp)8
-rw-r--r--include/hilbert/kernel/storage/bd/memory.hpp (renamed from include/mercury/kernel/storage/bd/memory.hpp)8
-rw-r--r--include/hilbert/kernel/storage/fs/tarfs.hpp (renamed from include/mercury/kernel/storage/fs/tarfs.hpp)8
-rw-r--r--include/hilbert/kernel/syscall.hpp13
-rw-r--r--include/hilbert/kernel/terminal.hpp (renamed from include/mercury/kernel/terminal.hpp)10
-rw-r--r--include/hilbert/kernel/utility.hpp (renamed from include/mercury/kernel/utility.hpp)6
-rw-r--r--include/hilbert/kernel/vfile.hpp (renamed from include/mercury/kernel/vfile.hpp)10
-rw-r--r--include/hilbert/syscall.hpp (renamed from include/mercury/syscall.hpp)8
11 files changed, 63 insertions, 57 deletions
diff --git a/include/mercury/kernel/application.hpp b/include/hilbert/kernel/application.hpp
index bc4a763..dc2c9a3 100644
--- a/include/mercury/kernel/application.hpp
+++ b/include/hilbert/kernel/application.hpp
@@ -1,10 +1,12 @@
-#ifndef MERCURY_KERNEL_APPLICATION_HPP
-#define MERCURY_KERNEL_APPLICATION_HPP
+#ifndef HILBERT_KERNEL_APPLICATION_HPP
+#define HILBERT_KERNEL_APPLICATION_HPP
-#include <mercury/kernel/vfile.hpp>
+#include <hilbert/kernel/vfile.hpp>
#include <cstdint>
-namespace mercury::kernel::application {
+//TODO: end application, threading.
+
+namespace hilbert::kernel::application {
enum class app_state {
running,
@@ -18,9 +20,10 @@ namespace mercury::kernel::application {
uint64_t *p4;
uint64_t *p3;
- uint64_t *p2;
+ uint64_t *p2s[512];
+ uint64_t **p1s[512];
- bool *p2es_to_free_on_exit;
+ bool **p1es_to_free_on_exit[512];
uint64_t p4_paddr;
@@ -38,20 +41,15 @@ namespace mercury::kernel::application {
} saved_regs;
app_instance();
- ~app_instance();
- //2MiB page. vaddr and paddr must be aligned, and vaddr in valid range.
+ //vaddr and paddr must be aligned, and vaddr must be < 0x0080.0000.0000
void map_page(uint64_t vaddr, uint64_t paddr,
bool write, bool execute, bool free_pram_on_exit);
- //2MiB pages. returns start of first page.
+ //returns start of first page.
uint64_t get_free_vaddr_pages(uint64_t count);
- void create_stack();
-
- void set_instruction_pointer(uint64_t vaddr);
-
- //2MiB pages; only lower half.
+ //in lower half
uint64_t count_mapped_vram_pages();
};
diff --git a/include/mercury/kernel/framebuffer.hpp b/include/hilbert/kernel/framebuffer.hpp
index 677a42a..c6725ae 100644
--- a/include/mercury/kernel/framebuffer.hpp
+++ b/include/hilbert/kernel/framebuffer.hpp
@@ -1,16 +1,14 @@
-#ifndef MERCURY_KERNEL_FRAMEBUFFER_HPP
-#define MERCURY_KERNEL_FRAMEBUFFER_HPP
+#ifndef HILBERT_KERNEL_FRAMEBUFFER_HPP
+#define HILBERT_KERNEL_FRAMEBUFFER_HPP
#include <cstdint>
-namespace mercury::kernel::framebuffer {
+namespace hilbert::kernel::framebuffer {
- extern uint32_t *vaddr;
extern int width;
extern int height;
- extern int dword_pitch;
- void init_framebuffer(uint64_t vaddr, uint64_t width, uint64_t height, uint64_t pitch);
+ void init_framebuffer(uint64_t paddr, uint64_t vaddr, uint64_t width, uint64_t height, uint64_t pitch);
typedef uint32_t color;
color encode_color(uint8_t r, uint8_t g, uint8_t b);
diff --git a/include/mercury/kernel/paging.hpp b/include/hilbert/kernel/paging.hpp
index f6d400a..2cf6f5c 100644
--- a/include/mercury/kernel/paging.hpp
+++ b/include/hilbert/kernel/paging.hpp
@@ -1,12 +1,12 @@
-#ifndef MERCURY_KERNEL_PAGING_HPP
-#define MERCURY_KERNEL_PAGING_HPP
+#ifndef HILBERT_KERNEL_PAGING_HPP
+#define HILBERT_KERNEL_PAGING_HPP
#include <cstdint>
//in paging.asm
extern "C" [[noreturn]] void switch_to_kernel_p4(void (*and_then_jump_to)());
-namespace mercury::kernel::paging {
+namespace hilbert::kernel::paging {
void mark_all_pram_used();
void mark_all_vram_free();
@@ -16,11 +16,12 @@ namespace mercury::kernel::paging {
uint64_t find_unmapped_vram_region(uint64_t page_count);
- uint64_t encode_pte(
- uint64_t addr, bool user, bool write, bool execute, bool ps);
+ uint64_t encode_pte(uint64_t addr, bool user, bool write, bool execute);
void init_kernel_page_tables(uint64_t kernel_offset);
+ uint64_t take_pram_page();
+
void map_kernel_stacks();
void map_kernel_page(
@@ -39,8 +40,6 @@ namespace mercury::kernel::paging {
extern uint64_t kernel_p4e;
- uint64_t take_2mib_pram_page();
-
}
#endif
diff --git a/include/mercury/kernel/storage.hpp b/include/hilbert/kernel/storage.hpp
index 61e7d3b..ea40d86 100644
--- a/include/mercury/kernel/storage.hpp
+++ b/include/hilbert/kernel/storage.hpp
@@ -1,10 +1,10 @@
-#ifndef MERCURY_KERNEL_STORAGE_HPP
-#define MERCURY_KERNEL_STORAGE_HPP
+#ifndef HILBERT_KERNEL_STORAGE_HPP
+#define HILBERT_KERNEL_STORAGE_HPP
-#include <mercury/kernel/utility.hpp>
+#include <hilbert/kernel/utility.hpp>
#include <cstdint>
-namespace mercury::kernel::storage {
+namespace hilbert::kernel::storage {
typedef uint64_t node_id_t;
typedef uint64_t directory_iter_t;
diff --git a/include/mercury/kernel/storage/bd/memory.hpp b/include/hilbert/kernel/storage/bd/memory.hpp
index e12d565..7702cb3 100644
--- a/include/mercury/kernel/storage/bd/memory.hpp
+++ b/include/hilbert/kernel/storage/bd/memory.hpp
@@ -1,9 +1,9 @@
-#ifndef MERCURY_KERNEL_STORAGE_BD_MEMORY_HPP
-#define MERCURY_KERNEL_STORAGE_BD_MEMORY_HPP
+#ifndef HILBERT_KERNEL_STORAGE_BD_MEMORY_HPP
+#define HILBERT_KERNEL_STORAGE_BD_MEMORY_HPP
-#include <mercury/kernel/storage.hpp>
+#include <hilbert/kernel/storage.hpp>
-namespace mercury::kernel::storage::bd {
+namespace hilbert::kernel::storage::bd {
class memory : public block_device {
diff --git a/include/mercury/kernel/storage/fs/tarfs.hpp b/include/hilbert/kernel/storage/fs/tarfs.hpp
index 9e16207..80e6030 100644
--- a/include/mercury/kernel/storage/fs/tarfs.hpp
+++ b/include/hilbert/kernel/storage/fs/tarfs.hpp
@@ -1,9 +1,9 @@
-#ifndef MERCURY_KERNEL_STORAGE_FS_TARFS_HPP
-#define MERCURY_KERNEL_STORAGE_FS_TARFS_HPP
+#ifndef HILBERT_KERNEL_STORAGE_FS_TARFS_HPP
+#define HILBERT_KERNEL_STORAGE_FS_TARFS_HPP
-#include <mercury/kernel/storage.hpp>
+#include <hilbert/kernel/storage.hpp>
-namespace mercury::kernel::storage::fs {
+namespace hilbert::kernel::storage::fs {
class tarfs_instance : public file_system_instance {
diff --git a/include/hilbert/kernel/syscall.hpp b/include/hilbert/kernel/syscall.hpp
new file mode 100644
index 0000000..c83e514
--- /dev/null
+++ b/include/hilbert/kernel/syscall.hpp
@@ -0,0 +1,13 @@
+#include <cstdint>
+
+namespace hilbert::kernel::syscall {
+
+ typedef void (*syscall_handler)(
+ uint64_t &rax, uint64_t &rdi, uint64_t &rsi, uint64_t &rdx);
+
+ void init_syscalls();
+
+ //assumes this rax has not been used yet and is < 256.
+ void add_syscall(uint64_t rax, syscall_handler handler);
+
+}
diff --git a/include/mercury/kernel/terminal.hpp b/include/hilbert/kernel/terminal.hpp
index 7b2d27a..78ddbe8 100644
--- a/include/mercury/kernel/terminal.hpp
+++ b/include/hilbert/kernel/terminal.hpp
@@ -1,12 +1,12 @@
-#ifndef MERCURY_KERNEL_TERMINAL_HPP
-#define MERCURY_KERNEL_TERMINAL_HPP
+#ifndef HILBERT_KERNEL_TERMINAL_HPP
+#define HILBERT_KERNEL_TERMINAL_HPP
-#include <mercury/kernel/framebuffer.hpp>
-#include <mercury/kernel/utility.hpp>
+#include <hilbert/kernel/framebuffer.hpp>
+#include <hilbert/kernel/utility.hpp>
#include <cstddef>
#include <cstdint>
-namespace mercury::kernel::terminal {
+namespace hilbert::kernel::terminal {
extern uint8_t *termfont;
extern uint64_t termfont_len;
diff --git a/include/mercury/kernel/utility.hpp b/include/hilbert/kernel/utility.hpp
index 3edd7d4..930264a 100644
--- a/include/mercury/kernel/utility.hpp
+++ b/include/hilbert/kernel/utility.hpp
@@ -1,10 +1,10 @@
-#ifndef MERCURY_KERNEL_UTILITY_HPP
-#define MERCURY_KERNEL_UTILITY_HPP
+#ifndef HILBERT_KERNEL_UTILITY_HPP
+#define HILBERT_KERNEL_UTILITY_HPP
#include <optional>
#include <cstdint>
-namespace mercury::kernel::utility {
+namespace hilbert::kernel::utility {
template <class t>
static inline t min(t a, t b) {
diff --git a/include/mercury/kernel/vfile.hpp b/include/hilbert/kernel/vfile.hpp
index ce72bb1..086b6ab 100644
--- a/include/mercury/kernel/vfile.hpp
+++ b/include/hilbert/kernel/vfile.hpp
@@ -1,15 +1,15 @@
-#ifndef MERCURY_KERNEL_VFILE_HPP
-#define MERCURY_KERNEL_VFILE_HPP
+#ifndef HILBERT_KERNEL_VFILE_HPP
+#define HILBERT_KERNEL_VFILE_HPP
-#include <mercury/kernel/storage.hpp>
-#include <mercury/kernel/utility.hpp>
+#include <hilbert/kernel/storage.hpp>
+#include <hilbert/kernel/utility.hpp>
//TODO: mounts points.
//maybe a two-way map between mount points and targets? one mount point per
//target and vice versa. only directories may be mount points, and only file
//system roots (which must be directories) may be targets.
-namespace mercury::kernel::vfile {
+namespace hilbert::kernel::vfile {
//a canon path contains no . or empty directory names, and
//contains no .. except for at the start of a relative path.
diff --git a/include/mercury/syscall.hpp b/include/hilbert/syscall.hpp
index f434d91..0e430d1 100644
--- a/include/mercury/syscall.hpp
+++ b/include/hilbert/syscall.hpp
@@ -1,9 +1,9 @@
-#ifndef MERCURY_SYSCALL_HPP
-#define MERCURY_SYSCALL_HPP
+#ifndef HILBERT_SYSCALL_HPP
+#define HILBERT_SYSCALL_HPP
#include <cstdint>
-namespace mercury::syscall {
+namespace hilbert::syscall {
typedef uint32_t encoded_color;
@@ -19,8 +19,6 @@ namespace mercury::syscall {
uint32_t &width_out, uint32_t &height_out, uint32_t &pitch_out
);
- extern "C" void draw_framebuffer();
-
}
#endif