diff --git a/prototypes/base/include/pointer.hpp b/prototypes/base/include/pointer.hpp new file mode 100644 index 0000000..7aace7b --- /dev/null +++ b/prototypes/base/include/pointer.hpp @@ -0,0 +1,44 @@ +#pragma once + +template +class pointer +{ +private: + void *ptr; +public: + explicit pointer(void *ptr) : + ptr(ptr) + { + + } + + explicit pointer(uint32_t value) : + ptr(reinterpret_cast(value)) + { + + } + + pointer(const pointer &) = default; + pointer(pointer &&) = default; + ~pointer() = default; + + void * data() const { + return this->ptr; + } + + template + T * data () const { + return reinterpret_cast(this->ptr); + } + + explicit operator void * () const { + return this->ptr; + } +}; + +struct physical_t_ident; +struct virtual_t_ident; + +// Add different memory pointer types here.... +using physical_t = pointer; +using virtual_t = pointer; \ No newline at end of file diff --git a/prototypes/base/init.cpp b/prototypes/base/init.cpp index bc94c14..35c0699 100644 --- a/prototypes/base/init.cpp +++ b/prototypes/base/init.cpp @@ -3,6 +3,7 @@ #include "console.hpp" #include "pmm.hpp" #include "numeric.hpp" +#include "pointer.hpp" #include "compat.h" extern "C" void init(void) @@ -12,10 +13,13 @@ extern "C" void init(void) << FColor(Color::Yellow) << "Hello color!" << FColor() << "\n" << BColor(Color::Blue) << "Hello blue!" << BColor() << "\n" << "Hello default color.\n"; - for(int i = 0; i < 4097; i++) { + + PMM::markOccupied((void*)0x1500); + + for(int i = 0; i < 10; i++) { bool success; - void *page = PMM::alloc(success); - Console::main << "allocated page " << i << " [" << success << "]: 0x" << page << "\n"; + physical_t page(PMM::alloc(success)); + Console::main << "allocated page " << i << " [" << success << "]: 0x" << page.data() << "\n"; } }