diff options
author | Benji Dial <benji@benjidial.net> | 2024-01-15 15:44:20 -0500 |
---|---|---|
committer | Benji Dial <benji@benjidial.net> | 2024-01-15 15:44:20 -0500 |
commit | c9a1266d219a83882735a3a8304f3824e0219cdb (patch) | |
tree | fea71a0b5b0de8f3a8962dc6ed417273f231e2a9 /include/hilbert/kernel/application.hpp | |
parent | 7c6a18d77a81f232ad2e1d3a311bb21ea8f1f5b4 (diff) | |
download | hilbert-os-c9a1266d219a83882735a3a8304f3824e0219cdb.tar.gz |
redo application paging and system calls, rename mercury to hilbert
Diffstat (limited to 'include/hilbert/kernel/application.hpp')
-rw-r--r-- | include/hilbert/kernel/application.hpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/include/hilbert/kernel/application.hpp b/include/hilbert/kernel/application.hpp new file mode 100644 index 0000000..dc2c9a3 --- /dev/null +++ b/include/hilbert/kernel/application.hpp @@ -0,0 +1,70 @@ +#ifndef HILBERT_KERNEL_APPLICATION_HPP +#define HILBERT_KERNEL_APPLICATION_HPP + +#include <hilbert/kernel/vfile.hpp> +#include <cstdint> + +//TODO: end application, threading. + +namespace hilbert::kernel::application { + + enum class app_state { + running, + paused, + zombie + }; + + struct app_instance { + + app_state state; + + uint64_t *p4; + uint64_t *p3; + uint64_t *p2s[512]; + uint64_t **p1s[512]; + + bool **p1es_to_free_on_exit[512]; + + uint64_t p4_paddr; + + //set to 0 if none + uint64_t framebuffer_vaddr; + + //only valid if state is zombie + int exit_code; + + //only valid if state is paused + struct { + uint64_t rip; + uint64_t rsp; + //TODO: etc. + } saved_regs; + + app_instance(); + + //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); + + //returns start of first page. + uint64_t get_free_vaddr_pages(uint64_t count); + + //in lower half + uint64_t count_mapped_vram_pages(); + + }; + + extern app_instance *running_app; + + enum class create_app_result { + success, + device_error, + app_corrupt, + fs_corrupt + }; + + create_app_result create_app(const vfile::vfile &file, app_instance *&out); + +} + +#endif |