diff options
| author | Alexey Gavrilov <alexey.gavrilov@mail.com> | 2026-03-27 14:03:55 +0700 |
|---|---|---|
| committer | Alexey Gavrilov <alexey.gavrilov@mail.com> | 2026-03-27 14:03:55 +0700 |
| commit | 6ffe96d1e3f0289c2070e050cf8e1a30288e6d91 (patch) | |
| tree | 746485cfc0f55dad82d1d0daad9677bf63475cba /arch | |
| parent | a4dea4148157a94a9143dbbd92fdd88b4358676c (diff) | |
Cmake build generator support: build stage
Multi-target architecture implementation:
each root source code directory presents the one
*INTERFACE* target to it's subdirectory subtargets
that link only as *STATIC* library.
For instance, *arch* directory presents *Architecture* target
then *Architecture* target has *CPUID*, *IO*, *PORT*
and etc. dependencies
Exact order of linking targets is: boot.o CRTIBUNDLE <TARGETS> CRTNBUNDLE.
Sequence destruction cause to UB. Please to pay attention to this.
TODO
- Debug information
- Build type
- Toolchain file
- Image creation
- Build by WinGW compiler on Windows platform (optional)
Signed-off-by: Alexey Gavrilov <alexey.gavrilov@mail.com>
Diffstat (limited to 'arch')
| -rw-r--r-- | arch/CMakeLists.txt | 17 | ||||
| -rw-r--r-- | arch/SecondaryInit.h | 2 | ||||
| -rw-r--r-- | arch/x86/CMakeLists.txt | 34 | ||||
| -rw-r--r-- | arch/x86/boot.nasm | 16 | ||||
| -rw-r--r-- | arch/x86/cpuid/CMakeLists.txt | 25 | ||||
| -rw-r--r-- | arch/x86/cpuid/Cpuid.h | 2 | ||||
| -rw-r--r-- | arch/x86/cpuid/CpuidCheck.nasm (renamed from arch/x86/cpuid/CpuidCheck.s) | 0 | ||||
| -rw-r--r-- | arch/x86/gdt/CMakeLists.txt | 23 | ||||
| -rwxr-xr-x | arch/x86/gdt/Gdt.h | 2 | ||||
| -rw-r--r-- | arch/x86/gdt/SwitchToGdt.nasm (renamed from arch/x86/gdt/SwitchToGdt.s) | 0 | ||||
| -rw-r--r-- | arch/x86/ic/CMakeLists.txt | 16 | ||||
| -rw-r--r-- | arch/x86/ic/IPic.h | 2 | ||||
| -rw-r--r-- | arch/x86/idt/CMakeLists.txt | 15 | ||||
| -rw-r--r-- | arch/x86/io/CMakeLists.txt | 16 | ||||
| -rw-r--r-- | arch/x86/io/VGADisplayInfo.h | 2 | ||||
| -rw-r--r-- | arch/x86/msr/CMakeLists.txt | 15 | ||||
| -rw-r--r-- | arch/x86/port/CMakeLists.txt | 16 | ||||
| -rw-r--r-- | arch/x86/port/PortOps.h | 2 |
18 files changed, 199 insertions, 6 deletions
diff --git a/arch/CMakeLists.txt b/arch/CMakeLists.txt new file mode 100644 index 0000000..c8719ce --- /dev/null +++ b/arch/CMakeLists.txt @@ -0,0 +1,17 @@ +add_library(Architecture INTERFACE) + +add_library(Initialization STATIC) +target_link_libraries(Initialization PUBLIC CXX_COMPILER_REQUIREMENTS) + +target_sources(Initialization PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/SecondaryInit.cpp +) + +target_sources(Initialization + PUBLIC + FILE_SET HEADERS + FILES + ${CMAKE_CURRENT_LIST_DIR}/SecondaryInit.h +) + +add_subdirectory(${ARCH}) diff --git a/arch/SecondaryInit.h b/arch/SecondaryInit.h index 53ff191..104f44c 100644 --- a/arch/SecondaryInit.h +++ b/arch/SecondaryInit.h @@ -1,6 +1,6 @@ -#include <types.h> #include "../kernel/mem/Segments.h" #include "../kernel/mem/Kheap.h" +#include <Types.h> #if defined(__IAPC) #include "x86/PrimaryInit.h" diff --git a/arch/x86/CMakeLists.txt b/arch/x86/CMakeLists.txt new file mode 100644 index 0000000..5601efa --- /dev/null +++ b/arch/x86/CMakeLists.txt @@ -0,0 +1,34 @@ +target_link_options(CXX_LINKER_REQUIREMENTS INTERFACE + LINKER:-L${CMAKE_CURRENT_LIST_DIR} +) + +target_sources(Initialization PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/PrimaryInit.cpp +) + +target_sources(Initialization + PUBLIC + FILE_SET HEADERS + FILES + ${CMAKE_CURRENT_LIST_DIR}/PrimaryInit.h +) + +target_link_libraries(Architecture INTERFACE Initialization) + +# Create library for assembler build +add_library(ArchitectureAssemblerSources STATIC) + +add_library(Boot OBJECT) +target_sources(Boot PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/boot.nasm +) + +add_subdirectory(cpuid) +add_subdirectory(idt) +add_subdirectory(gdt) +add_subdirectory(ic) +add_subdirectory(io) +add_subdirectory(msr) +add_subdirectory(port) + +target_link_libraries(Architecture INTERFACE ArchitectureAssemblerSources) diff --git a/arch/x86/boot.nasm b/arch/x86/boot.nasm new file mode 100644 index 0000000..11175af --- /dev/null +++ b/arch/x86/boot.nasm @@ -0,0 +1,16 @@ +section .text +extern main, _estack, _init +global _start:function +_start: + ; Stack setup + mov eax, _estack + ; Align stack to odd address + and eax, 0xFFFFFFFE + mov esp, eax + + call _init + call main + cli +.hang: hlt + jmp .hang +; .end: diff --git a/arch/x86/cpuid/CMakeLists.txt b/arch/x86/cpuid/CMakeLists.txt new file mode 100644 index 0000000..e8528e8 --- /dev/null +++ b/arch/x86/cpuid/CMakeLists.txt @@ -0,0 +1,25 @@ +add_library(CPUID STATIC) +target_link_libraries(CPUID PUBLIC CXX_COMPILER_REQUIREMENTS) + +target_sources(CPUID PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/Cpuid.cpp +) + +target_sources(CPUID + PUBLIC + FILE_SET HEADERS + BASE_DIRS + ${CMAKE_CURRENT_LIST_DIR} + FILES + ${CMAKE_CURRENT_LIST_DIR}/Cpuid.h +) + +target_link_libraries(Architecture INTERFACE CPUID) + +add_library(CPUIDASM OBJECT) + +target_sources(CPUIDASM PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/CpuidCheck.nasm +) + +target_sources(ArchitectureAssemblerSources PRIVATE $<TARGET_OBJECTS:CPUIDASM>) diff --git a/arch/x86/cpuid/Cpuid.h b/arch/x86/cpuid/Cpuid.h index a65cdc8..c8ad4aa 100644 --- a/arch/x86/cpuid/Cpuid.h +++ b/arch/x86/cpuid/Cpuid.h @@ -1,6 +1,6 @@ #ifndef CPUID_H #define CPUID_H -#include <types.h> +#include <Types.h> #include <MemoryOperations.h> // To declare cpuid::Executor::Executor() diff --git a/arch/x86/cpuid/CpuidCheck.s b/arch/x86/cpuid/CpuidCheck.nasm index 67bc9eb..67bc9eb 100644 --- a/arch/x86/cpuid/CpuidCheck.s +++ b/arch/x86/cpuid/CpuidCheck.nasm diff --git a/arch/x86/gdt/CMakeLists.txt b/arch/x86/gdt/CMakeLists.txt new file mode 100644 index 0000000..57e3c26 --- /dev/null +++ b/arch/x86/gdt/CMakeLists.txt @@ -0,0 +1,23 @@ +add_library(GDT STATIC) +target_link_libraries(GDT PUBLIC CXX_COMPILER_REQUIREMENTS) + +target_sources(GDT PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/Gdt.cpp +) + +target_sources(GDT + PUBLIC + FILE_SET HEADERS + FILES + ${CMAKE_CURRENT_LIST_DIR}/Gdt.h +) + +target_link_libraries(Architecture INTERFACE GDT) + +add_library(GDTASM OBJECT) + +target_sources(GDTASM PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/SwitchToGdt.nasm +) + +target_sources(ArchitectureAssemblerSources PRIVATE $<TARGET_OBJECTS:GDTASM>) diff --git a/arch/x86/gdt/Gdt.h b/arch/x86/gdt/Gdt.h index 321d67c..8f1d967 100755 --- a/arch/x86/gdt/Gdt.h +++ b/arch/x86/gdt/Gdt.h @@ -1,7 +1,7 @@ #ifndef GDT_H #define GDT_H -#include <types.h> +#include <Types.h> #include <MemoryOperations.h> diff --git a/arch/x86/gdt/SwitchToGdt.s b/arch/x86/gdt/SwitchToGdt.nasm index 52ebbc7..52ebbc7 100644 --- a/arch/x86/gdt/SwitchToGdt.s +++ b/arch/x86/gdt/SwitchToGdt.nasm diff --git a/arch/x86/ic/CMakeLists.txt b/arch/x86/ic/CMakeLists.txt new file mode 100644 index 0000000..e6130d7 --- /dev/null +++ b/arch/x86/ic/CMakeLists.txt @@ -0,0 +1,16 @@ +add_library(IC STATIC) +target_link_libraries(IC PUBLIC CXX_COMPILER_REQUIREMENTS) + +target_sources(IC PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/Pic.cpp +) + +target_sources(IC + PUBLIC + FILE_SET HEADERS + FILES + ${CMAKE_CURRENT_LIST_DIR}/Pic.h + ${CMAKE_CURRENT_LIST_DIR}/IPic.h +) + +target_link_libraries(Architecture INTERFACE IC) diff --git a/arch/x86/ic/IPic.h b/arch/x86/ic/IPic.h index 9bb1b4f..5e0449b 100644 --- a/arch/x86/ic/IPic.h +++ b/arch/x86/ic/IPic.h @@ -1,7 +1,7 @@ #ifndef IPIC_H #define IPIC_H -#include <types.h> +#include <Types.h> // Defines diff --git a/arch/x86/idt/CMakeLists.txt b/arch/x86/idt/CMakeLists.txt new file mode 100644 index 0000000..da7bdae --- /dev/null +++ b/arch/x86/idt/CMakeLists.txt @@ -0,0 +1,15 @@ +add_library(IDT STATIC) +target_link_libraries(IDT PUBLIC CXX_COMPILER_REQUIREMENTS) + +target_sources(IDT PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/Idt.cpp +) + +target_sources(IDT + PUBLIC + FILE_SET HEADERS + FILES + ${CMAKE_CURRENT_LIST_DIR}/Idt.h +) + +target_link_libraries(Architecture INTERFACE IDT) diff --git a/arch/x86/io/CMakeLists.txt b/arch/x86/io/CMakeLists.txt new file mode 100644 index 0000000..9c2dd33 --- /dev/null +++ b/arch/x86/io/CMakeLists.txt @@ -0,0 +1,16 @@ +add_library(IO STATIC) +target_link_libraries(IO PUBLIC CXX_COMPILER_REQUIREMENTS) + +target_sources(IO PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/VGADisplay.cpp +) + +target_sources(IO + PUBLIC + FILE_SET HEADERS + FILES + ${CMAKE_CURRENT_LIST_DIR}/VGADisplay.h + ${CMAKE_CURRENT_LIST_DIR}/VGADisplayInfo.h +) + +target_link_libraries(Architecture INTERFACE IO) diff --git a/arch/x86/io/VGADisplayInfo.h b/arch/x86/io/VGADisplayInfo.h index 875e7e5..55303dd 100644 --- a/arch/x86/io/VGADisplayInfo.h +++ b/arch/x86/io/VGADisplayInfo.h @@ -1,7 +1,7 @@ #ifndef VGAINFOCLASS_H #define VGAINFOCLASS_H -#include <types.h> +#include <Types.h> #define TOBG(attr) attr << 4 diff --git a/arch/x86/msr/CMakeLists.txt b/arch/x86/msr/CMakeLists.txt new file mode 100644 index 0000000..86d3330 --- /dev/null +++ b/arch/x86/msr/CMakeLists.txt @@ -0,0 +1,15 @@ +add_library(MSR STATIC) +target_link_libraries(MSR PUBLIC CXX_COMPILER_REQUIREMENTS) + +target_sources(MSR PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/Msr.cpp +) + +target_sources(MSR + PUBLIC + FILE_SET HEADERS + FILES + ${CMAKE_CURRENT_LIST_DIR}/Msr.h +) + +target_link_libraries(Architecture INTERFACE MSR) diff --git a/arch/x86/port/CMakeLists.txt b/arch/x86/port/CMakeLists.txt new file mode 100644 index 0000000..6ad61ef --- /dev/null +++ b/arch/x86/port/CMakeLists.txt @@ -0,0 +1,16 @@ +add_library(Port STATIC) +target_link_libraries(Port PUBLIC CXX_COMPILER_REQUIREMENTS) + +target_sources(Port PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/PortOps.cpp +) + +target_sources(Port + PUBLIC + FILE_SET HEADERS + FILES + ${CMAKE_CURRENT_LIST_DIR}/PortOps.h + ${CMAKE_CURRENT_LIST_DIR}/Operations +) + +target_link_libraries(Architecture INTERFACE Port) diff --git a/arch/x86/port/PortOps.h b/arch/x86/port/PortOps.h index 7db3a5f..f8dac63 100644 --- a/arch/x86/port/PortOps.h +++ b/arch/x86/port/PortOps.h @@ -1,7 +1,7 @@ #ifndef PORT_H #define PORT_H -#include <types.h> +#include <Types.h> using regb = uint8; |
