#include "ring3.hpp"
#include "utils.hpp"
#include "serial.hpp"
+#include "paging.hpp"
void os::set_ring0_stack(os::tss& tss, std::uint64_t stack) {
tss.rsp0 = stack;
os::set_msr(0xC0000084, 0x00000000); // syscall flag mask, we don't want to change the flags for now.
}
-extern "C" void syscall_print(char v) {
+extern "C" void os::syscall_print(char v) {
os::printc(v);
}
-extern "C" void syscall_println(char v) {
+extern "C" void os::syscall_println(char v) {
os::printc(v);
os::printc('\n');
}
-extern "C" void syscall_rax_error_handler() {
+extern "C" os::paging::PML4T PML4T;
+extern "C" void os::syscall_print_low_mmap() {
+ os::paging::on_all_pages(PML4T, [](os::paging::page* vaddr, os::phys_ptr<os::paging::page> paddr, std::size_t page_size_in_bytes) {
+ if (std::size_t(vaddr) < 128ul * 1024 * 1024 * 1024 * 1024) { // Lower half:
+ if (std::size_t(vaddr) < 0x10'0000'0000) {
+ os::print("segments:");
+ } else if (std::size_t(vaddr) < 0x7FFF'FFFF'0000) {
+ os::print("heap: ");
+ } else {
+ os::print("stack: ");
+ }
+ os::print(" {} -> {} (0x{}B)\n", std::size_t(vaddr), paddr.get_phys_addr(), page_size_in_bytes);
+ }
+ });
+}
+
+extern "C" void os::syscall_rax_error_handler() {
os::assert(false, "Incorrect %rax for syscall.");
}
extern "C" void syscall_print(char c);
extern "C" void syscall_println(char c);
+extern "C" void syscall_print_low_mmap();
extern "C" void syscall_rax_error_handler();
void set_ring0_stack(tss& tss, std::uint64_t stack);
#include <stddef.h>
extern "C" void print(char c);
+extern "C" void check_mem();
void printstr(const char* str) {
for (size_t i = 0; str[i] != '\0'; i++) {
for (size_t i = 0; i < 16; i++) {
printstr(str);
}
+ printstr("Mem:\n");
+ check_mem();
+ printstr("Done.\n");
while (true) {}
}