diff options
Diffstat (limited to 'source/boot')
| -rw-r--r-- | source/boot/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | source/boot/arch/x86_64/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | source/boot/arch/x86_64/include/boot/pointers.hpp | 12 | ||||
| -rw-r--r-- | source/boot/arch/x86_64/src/boot.s | 2 | ||||
| -rw-r--r-- | source/boot/include/boot/asm_pointer.hpp | 43 |
5 files changed, 64 insertions, 1 deletions
diff --git a/source/boot/CMakeLists.txt b/source/boot/CMakeLists.txt index 5591d70..66f1d65 100644 --- a/source/boot/CMakeLists.txt +++ b/source/boot/CMakeLists.txt @@ -8,6 +8,10 @@ add_library("_boot" STATIC) add_library("teachos::boot" ALIAS "_boot") +target_include_directories("_boot" PUBLIC + "include" +) + #[============================================================================[ # Apply the platform dependent settings to the bootstrapping library. #]============================================================================] diff --git a/source/boot/arch/x86_64/CMakeLists.txt b/source/boot/arch/x86_64/CMakeLists.txt index 0fd6539..14b0610 100644 --- a/source/boot/arch/x86_64/CMakeLists.txt +++ b/source/boot/arch/x86_64/CMakeLists.txt @@ -4,3 +4,7 @@ target_sources("_boot" PRIVATE "src/crtn.s" "src/multiboot.s" ) + +target_include_directories("_boot" PUBLIC + "include" +)
\ No newline at end of file diff --git a/source/boot/arch/x86_64/include/boot/pointers.hpp b/source/boot/arch/x86_64/include/boot/pointers.hpp new file mode 100644 index 0000000..f4f504c --- /dev/null +++ b/source/boot/arch/x86_64/include/boot/pointers.hpp @@ -0,0 +1,12 @@ +#ifndef TEACHOS_ARCH_X86_64_BOOT_POINTERS_HPP +#define TEACHOS_ARCH_X86_64_BOOT_POINTERS_HPP + +#include <cstddef> + +namespace teachos::boot +{ + extern "C" std::byte const multiboot_information_pointer; + extern "C" std::byte * vga_buffer_pointer; +} // namespace teachos::boot + +#endif
\ No newline at end of file diff --git a/source/boot/arch/x86_64/src/boot.s b/source/boot/arch/x86_64/src/boot.s index 4781773..45f261e 100644 --- a/source/boot/arch/x86_64/src/boot.s +++ b/source/boot/arch/x86_64/src/boot.s @@ -103,6 +103,7 @@ mesage_long_mode_not_supported: /** * We need a pointer to our current position in the VGA text buffer. */ +.global vga_buffer_pointer vga_buffer_pointer: .long 0xb8000 /** @@ -369,6 +370,5 @@ _transition_to_long_mode: call _init - mov multiboot_information_pointer, %rdi call kernel_main hlt diff --git a/source/boot/include/boot/asm_pointer.hpp b/source/boot/include/boot/asm_pointer.hpp new file mode 100644 index 0000000..ec7141e --- /dev/null +++ b/source/boot/include/boot/asm_pointer.hpp @@ -0,0 +1,43 @@ +#ifndef TEACHOS_BOOT_ASM_POINTER_HPP +#define TEACHOS_BOOT_ASM_POINTER_HPP + +namespace teachos::boot +{ + + template<typename Type> + struct asm_pointer + { + constexpr asm_pointer(Type & pointer) + : m_pointer{&pointer} + { + } + + auto constexpr operator->() -> Type * { return m_pointer; } + auto constexpr operator->() const -> Type const * { return m_pointer; } + auto constexpr operator*() -> Type & { return *m_pointer; } + auto constexpr operator*() const -> Type const & { return *m_pointer; } + + private: + Type * m_pointer; + }; + + template<typename Type> + struct asm_pointer<Type const> + { + constexpr asm_pointer(Type const & pointer) + : m_pointer{&pointer} + { + } + + auto constexpr operator->() -> Type const * { return m_pointer; } + auto constexpr operator->() const -> Type const * { return m_pointer; } + auto constexpr operator*() -> Type const & { return *m_pointer; } + auto constexpr operator*() const -> Type const & { return *m_pointer; } + + private: + Type const * m_pointer; + }; + +} // namespace teachos::boot + +#endif
\ No newline at end of file |
