aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/CMakeLists.txt
blob: dd54b390b03befae4839e79fd5eadd025d5eb9a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
add_library("arch-x86_64" OBJECT)
add_library("arch::x86_64" ALIAS "arch-x86_64")

target_include_directories("arch-x86_64" PUBLIC
    "include"
)

target_link_libraries("arch-x86_64" PUBLIC
    "arch::any"
    "libs::multiboot2"
)

target_link_options("arch-x86_64" PUBLIC
    "-T${CMAKE_CURRENT_SOURCE_DIR}/scripts/kernel.ld"
)

set_target_properties("arch-x86_64" PROPERTIES
    LINK_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/kernel.ld"
)

#[============================================================================[
# arch::any Implementation
#]============================================================================]

target_sources("arch-x86_64" PRIVATE
    "src/io.cpp"
    "src/memory.cpp"
    "src/system.cpp"
)

#[============================================================================[
# Bootstrap Code
#]============================================================================]

target_sources("arch-x86_64" PRIVATE
    "src/boot/boot.s"
    "src/boot/crti.s"
    "src/boot/crtn.s"
    "src/boot/multiboot.s"
)

# #[============================================================================[
# # The Kernel Library
# #]============================================================================]

# set(TEACHOS_KERNEL_LINKER_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/kernel.ld")
# mark_as_advanced(TEACHOS_KERNEL_LINKER_SCRIPT)

# target_sources("_kernel" PRIVATE
#   "src/kernel/main.cpp"
#   "src/kernel/cpu/control_register.cpp"
#   "src/kernel/cpu/gdtr.cpp"
#   "src/kernel/cpu/idtr.cpp"
#   "src/kernel/cpu/if.cpp"
#   "src/kernel/cpu/call.cpp"
#   "src/kernel/cpu/msr.cpp"
#   "src/kernel/cpu/segment_register.cpp"
#   "src/kernel/cpu/tlb.cpp"
#   "src/kernel/cpu/tr.cpp"
# )

# target_link_options("_kernel" PRIVATE
#   "-T${TEACHOS_KERNEL_LINKER_SCRIPT}"
# )

# set_target_properties("_kernel" PROPERTIES
#   LINK_DEPENDS "${TEACHOS_KERNEL_LINKER_SCRIPT}"
# )

# #[============================================================================[
# # The Bootstrap Library
# #]============================================================================]

# target_sources("_boot" PRIVATE
#   "src/boot/boot.s"
#   "src/boot/crti.s"
#   "src/boot/crtn.s"
#   "src/boot/multiboot.s"
# )

# #[============================================================================[
# # The Video Library
# #]============================================================================]

# target_sources("_video" PRIVATE
#   "src/video/vga/text.cpp"
# )

# #[============================================================================[
# # The Memory Library
# #]============================================================================]

# target_sources("_memory" PRIVATE
#   "src/memory/main.cpp"
#   "src/memory/multiboot/elf_symbols_section.cpp"
#   "src/memory/multiboot/reader.cpp"
#   "src/memory/allocator/area_frame_allocator.cpp"
#   "src/memory/allocator/tiny_frame_allocator.cpp"
#   "src/memory/allocator/physical_frame.cpp"
#   "src/memory/paging/page_entry.cpp"
#   "src/memory/paging/page_table.cpp"
#   "src/memory/paging/temporary_page.cpp"
#   "src/memory/paging/virtual_page.cpp"
#   "src/memory/paging/active_page_table.cpp"
#   "src/memory/paging/inactive_page_table.cpp"
#   "src/memory/heap/bump_allocator.cpp"
#   "src/memory/heap/user_heap_allocator.cpp"
#   "src/memory/heap/memory_block.cpp"
#   "src/memory/heap/linked_list_allocator.cpp"
#   "src/memory/heap/global_heap_allocator.cpp"
# )

# target_link_libraries("_memory" PUBLIC
#   "libs::kstd"
#   "libs::multiboot2"
# )

# #[============================================================================[
# # The Exception handling Library
# #]============================================================================]

# target_sources("_exception" PRIVATE
#   "src/exception_handling/assert.cpp"
#   "src/exception_handling/abort.cpp"
#   "src/exception_handling/panic.cpp"
#   "src/exception_handling/pure_virtual.cpp"
# )

# #[============================================================================[
# # The Context switching Library
# #]============================================================================]

# target_sources("_context" PRIVATE
#   "src/context_switching/segment_descriptor_table/access_byte.cpp"
#   "src/context_switching/segment_descriptor_table/gdt_flags.cpp"
#   "src/context_switching/segment_descriptor_table/global_descriptor_table_pointer.cpp"
#   "src/context_switching/segment_descriptor_table/global_descriptor_table.cpp"
#   "src/context_switching/segment_descriptor_table/segment_descriptor_base.cpp"
#   "src/context_switching/segment_descriptor_table/segment_descriptor_extension.cpp"
#   "src/context_switching/main.cpp"
#   "src/context_switching/syscall/main.cpp"
#   "src/context_switching/syscall/syscall_enable.cpp"
#   "src/context_switching/syscall/syscall_handler.cpp"
#   "src/context_switching/interrupt_descriptor_table/gate_descriptor.cpp"
#   "src/context_switching/interrupt_descriptor_table/idt_flags.cpp"
#   "src/context_switching/interrupt_descriptor_table/interrupt_descriptor_table_pointer.cpp"
#   "src/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.cpp"
#   "src/context_switching/interrupt_descriptor_table/ist_offset.cpp"
#   "src/context_switching/interrupt_descriptor_table/segment_selector.cpp"
# )

# target_link_libraries("_context" PUBLIC
#   "libs::kstd"
# )

# #[============================================================================[
# # The Interrupt Handlers
# #]============================================================================]

# target_sources("_interrupt_handling" PRIVATE
#   "src/interrupt_handling/generic_interrupt_handler.cpp"
# )

# #[============================================================================[
# # The User code
# #]============================================================================]

# target_sources("_context" PRIVATE
#   "src/user/main.cpp"
# )

# #[============================================================================[
# # The Bootable ISO Image
# #]============================================================================]

# find_package("grub-mkrescue")

# if(grub-mkrescue_FOUND)
#   file(GENERATE
#     OUTPUT "isofs/boot/grub/grub.cfg"
#     INPUT "support/grub.cfg.in"
#   )

#   add_custom_target("bootable-iso"
#     COMMAND "${GRUB_MKRESCUE_EXE}"
#     "-o"
#     "${PROJECT_BINARY_DIR}/teachos-$<CONFIGURATION>.iso"
#     "${CMAKE_CURRENT_BINARY_DIR}/isofs"
#     "$<TARGET_FILE:teachos::kernel>"
#     "2>/dev/null"
#     DEPENDS
#     "$<TARGET_FILE:teachos::kernel>"
#     "isofs/boot/grub/grub.cfg"
#     BYPRODUCTS "${PROJECT_BINARY_DIR}/teachos-$<CONFIGURATION>.iso"
#     COMMENT "Creating bootable ISO image"
#   )
# endif()