From d1aaaeb615e148a13f46223c84819ba828e5209f Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Mon, 14 Jul 2025 16:42:26 +0000 Subject: arch: make linkable --- CMakeLists.txt | 3 +- arch/CMakeLists.txt | 4 +++ arch/x86_64/CMakeLists.txt | 3 +- include/memory/asm_pointer.hpp | 76 --------------------------------------- kern/CMakeLists.txt | 7 ++-- kern/include/kern/asm_pointer.hpp | 76 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 86 insertions(+), 83 deletions(-) delete mode 100644 include/memory/asm_pointer.hpp create mode 100644 kern/include/kern/asm_pointer.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index c08753b..a00b043 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,9 +32,8 @@ add_subdirectory("kern") add_subdirectory("arch") target_link_libraries("kernel" PRIVATE - "kern" - "arch::any" "arch::${CMAKE_SYSTEM_PROCESSOR}" + "os::kern" ) # #[============================================================================[ diff --git a/arch/CMakeLists.txt b/arch/CMakeLists.txt index c7b2c15..eded57e 100644 --- a/arch/CMakeLists.txt +++ b/arch/CMakeLists.txt @@ -14,4 +14,8 @@ target_include_directories("arch-any" INTERFACE "include" ) +target_link_libraries("arch-any" INTERFACE + "libs::kstd" +) + add_subdirectory("${CMAKE_SYSTEM_PROCESSOR}") diff --git a/arch/x86_64/CMakeLists.txt b/arch/x86_64/CMakeLists.txt index 19bc78c..dd54b39 100644 --- a/arch/x86_64/CMakeLists.txt +++ b/arch/x86_64/CMakeLists.txt @@ -6,8 +6,7 @@ target_include_directories("arch-x86_64" PUBLIC ) target_link_libraries("arch-x86_64" PUBLIC - "kern" - + "arch::any" "libs::multiboot2" ) diff --git a/include/memory/asm_pointer.hpp b/include/memory/asm_pointer.hpp deleted file mode 100644 index 4c25658..0000000 --- a/include/memory/asm_pointer.hpp +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef TEACHOS_MEMORY_ASM_POINTER_HPP -#define TEACHOS_MEMORY_ASM_POINTER_HPP - -namespace teachos::memory -{ - - /** - * @brief A pointer that is defined in some assembly source file. - * - * @tparam Type The type of the pointer - * @since 0.0.1 - */ - template - struct asm_pointer - { - /** - * @brief The type of the underlying pointer. - */ - using pointer = Type *; - - /** - * @brief Construct a new asm_pointer for a given assembly-defined pointer. - * - * @param pointer A pointer defined in assembly. - */ - constexpr asm_pointer(Type *& pointer) - : m_pointer{&pointer} - { - // Nothing to do - } - - /** - * @brief Access the underlying pointer. - * - * @return The pointer wrapped by this asm_pointer. - */ - auto constexpr operator*() -> pointer & { return *m_pointer; } - - /** - * @brief Access the underlying pointer. - * - * @return The pointer wrapped by this asm_pointer. - */ - auto constexpr operator*() const -> pointer const & { return *m_pointer; } - - private: - pointer * m_pointer; - }; - - /** - * @copydoc asm_pointer - * - * @note This specialization allows the use of this type for pointers to constant data. - * @since 0.0.1 - */ - template - struct asm_pointer - { - /** @copydoc asm_pointer::asm_pointer */ - constexpr asm_pointer(Type const & pointer) - : m_pointer{&pointer} - { - } - - /** @copydoc asm_pointer::operator*() */ - auto constexpr operator*() -> Type const & { return *m_pointer; } - /** @copydoc asm_pointer::operator*() const */ - auto constexpr operator*() const -> Type const & { return *m_pointer; } - - private: - Type const * m_pointer; - }; - -} // namespace teachos::memory - -#endif // TEACHOS_MEMORY_ASM_POINTER_HPP diff --git a/kern/CMakeLists.txt b/kern/CMakeLists.txt index 9bfe9e8..52c2cb5 100644 --- a/kern/CMakeLists.txt +++ b/kern/CMakeLists.txt @@ -1,4 +1,7 @@ -add_library("kern" OBJECT +add_library("kern" OBJECT) +add_library("os::kern" ALIAS "kern") + +target_sources("kern" PRIVATE "src/abort.cpp" "src/error.cpp" "src/main.cpp" @@ -11,6 +14,4 @@ target_include_directories("kern" PUBLIC target_link_libraries("kern" PUBLIC "arch::any" - - "gcc" ) diff --git a/kern/include/kern/asm_pointer.hpp b/kern/include/kern/asm_pointer.hpp new file mode 100644 index 0000000..4c25658 --- /dev/null +++ b/kern/include/kern/asm_pointer.hpp @@ -0,0 +1,76 @@ +#ifndef TEACHOS_MEMORY_ASM_POINTER_HPP +#define TEACHOS_MEMORY_ASM_POINTER_HPP + +namespace teachos::memory +{ + + /** + * @brief A pointer that is defined in some assembly source file. + * + * @tparam Type The type of the pointer + * @since 0.0.1 + */ + template + struct asm_pointer + { + /** + * @brief The type of the underlying pointer. + */ + using pointer = Type *; + + /** + * @brief Construct a new asm_pointer for a given assembly-defined pointer. + * + * @param pointer A pointer defined in assembly. + */ + constexpr asm_pointer(Type *& pointer) + : m_pointer{&pointer} + { + // Nothing to do + } + + /** + * @brief Access the underlying pointer. + * + * @return The pointer wrapped by this asm_pointer. + */ + auto constexpr operator*() -> pointer & { return *m_pointer; } + + /** + * @brief Access the underlying pointer. + * + * @return The pointer wrapped by this asm_pointer. + */ + auto constexpr operator*() const -> pointer const & { return *m_pointer; } + + private: + pointer * m_pointer; + }; + + /** + * @copydoc asm_pointer + * + * @note This specialization allows the use of this type for pointers to constant data. + * @since 0.0.1 + */ + template + struct asm_pointer + { + /** @copydoc asm_pointer::asm_pointer */ + constexpr asm_pointer(Type const & pointer) + : m_pointer{&pointer} + { + } + + /** @copydoc asm_pointer::operator*() */ + auto constexpr operator*() -> Type const & { return *m_pointer; } + /** @copydoc asm_pointer::operator*() const */ + auto constexpr operator*() const -> Type const & { return *m_pointer; } + + private: + Type const * m_pointer; + }; + +} // namespace teachos::memory + +#endif // TEACHOS_MEMORY_ASM_POINTER_HPP -- cgit v1.2.3