aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.vscode/launch.json2
-rw-r--r--.vscode/tasks.json4
-rw-r--r--CMakeLists.txt9
-rw-r--r--arch/x86_64/src/boot/boot.s2
-rw-r--r--arch/x86_64/src/io.cpp14
-rw-r--r--arch/x86_64/src/vga/text.cpp2
-rw-r--r--arch/x86_64/support/grub.cfg.in2
-rw-r--r--cmake/Modules/GenerateBootableIso.cmake22
8 files changed, 44 insertions, 13 deletions
diff --git a/.vscode/launch.json b/.vscode/launch.json
index 3b53048..7778c04 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -11,7 +11,7 @@
"gdbpath": "x86_64-pc-elf-gdb",
"cwd": "${workspaceFolder}",
"preLaunchTask": "QEMU (gdb)",
- "executable": "${command:cmake.buildDirectory}/bin/${command:cmake.buildType}/_kernel.elf",
+ "executable": "${command:cmake.buildDirectory}/bin/${command:cmake.buildType}/kernel.elf",
"autorun": [
"-enable-pretty-printing",
"-break-insert _start"
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index 3b5ae9f..12ec2ea 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -17,7 +17,7 @@
"-d",
"int,cpu_reset",
"-cdrom",
- "${command:cmake.buildDirectory}/teachos-${command:cmake.buildType}.iso"
+ "${command:cmake.buildDirectory}/bin/${command:cmake.buildType}/kernel.iso"
],
"isBackground": true,
"presentation": {
@@ -52,7 +52,7 @@
"-display",
"curses",
"-cdrom",
- "${command:cmake.buildDirectory}/teachos-${command:cmake.buildType}.iso"
+ "${command:cmake.buildDirectory}/bin/${command:cmake.buildType}/kernel.iso"
],
"isBackground": true,
"presentation": {
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a00b043..27500ed 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,6 +7,10 @@ project("kernel"
LANGUAGES ASM C CXX
)
+set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/Modules")
+
+include("GenerateBootableIso")
+
#[============================================================================[
# Global Build System Configuration
#]============================================================================]
@@ -15,8 +19,6 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION YES)
-set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/Modules")
-
set(CMAKE_CXX_STANDARD "20")
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS NO)
@@ -36,6 +38,9 @@ target_link_libraries("kernel" PRIVATE
"os::kern"
)
+target_generate_bootable_iso("kernel")
+
+
# #[============================================================================[
# # Documentation
# #]============================================================================]
diff --git a/arch/x86_64/src/boot/boot.s b/arch/x86_64/src/boot/boot.s
index 5488073..728380d 100644
--- a/arch/x86_64/src/boot/boot.s
+++ b/arch/x86_64/src/boot/boot.s
@@ -105,7 +105,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
+vga_buffer_pointer: .quad 0xb8000
/**
* Code for the bootstrapping process.
diff --git a/arch/x86_64/src/io.cpp b/arch/x86_64/src/io.cpp
index 5fb1c85..8e9e411 100644
--- a/arch/x86_64/src/io.cpp
+++ b/arch/x86_64/src/io.cpp
@@ -6,15 +6,21 @@ namespace teachos::arch::io
auto init() -> void
{
+ x86_64::vga::text::cursor(false);
+
teachos::set_print_handler(
[](auto text) { return x86_64::vga::text::write(text, x86_64::vga::text::common_attributes::green_on_black); });
- teachos::set_println_handler(
- [](auto text) { return x86_64::vga::text::write(text, x86_64::vga::text::common_attributes::green_on_black); });
+ teachos::set_println_handler([](auto text) {
+ x86_64::vga::text::write(text, x86_64::vga::text::common_attributes::green_on_black);
+ x86_64::vga::text::newline();
+ });
teachos::set_print_error_handler(
[](auto text) { return x86_64::vga::text::write(text, x86_64::vga::text::common_attributes::red_on_black); });
- teachos::set_println_error_handler(
- [](auto text) { return x86_64::vga::text::write(text, x86_64::vga::text::common_attributes::red_on_black); });
+ teachos::set_println_error_handler([](auto text) {
+ x86_64::vga::text::write(text, x86_64::vga::text::common_attributes::red_on_black);
+ x86_64::vga::text::newline();
+ });
teachos::println("[x86-64] Basic VGA text output initialized.");
}
diff --git a/arch/x86_64/src/vga/text.cpp b/arch/x86_64/src/vga/text.cpp
index 9b7946d..16abf08 100644
--- a/arch/x86_64/src/vga/text.cpp
+++ b/arch/x86_64/src/vga/text.cpp
@@ -14,8 +14,6 @@ namespace teachos::x86_64::vga::text
{
namespace
{
- // auto constexpr DEFAULT_VGA_TEXT_BUFFER_ADDRESS = 0xB8000;
-
auto buffer_offset = std::ptrdiff_t{};
auto constexpr DEFAULT_TEXT_BUFFER_WIDTH = 80U;
diff --git a/arch/x86_64/support/grub.cfg.in b/arch/x86_64/support/grub.cfg.in
index 86674dd..49f19ce 100644
--- a/arch/x86_64/support/grub.cfg.in
+++ b/arch/x86_64/support/grub.cfg.in
@@ -2,6 +2,6 @@ timeout=2
default=0
menuentry "TeachOS" {
- multiboot2 /$<TARGET_FILE_NAME:teachos::kernel>
+ multiboot2 /$<TARGET_FILE_NAME:kernel>
boot
} \ No newline at end of file
diff --git a/cmake/Modules/GenerateBootableIso.cmake b/cmake/Modules/GenerateBootableIso.cmake
new file mode 100644
index 0000000..368dcf6
--- /dev/null
+++ b/cmake/Modules/GenerateBootableIso.cmake
@@ -0,0 +1,22 @@
+include_guard(GLOBAL)
+
+function(target_generate_bootable_iso TARGET)
+ find_package("grub-mkrescue")
+
+ file(GENERATE
+ OUTPUT "$<TARGET_FILE_DIR:${TARGET}>/isofs/boot/grub/grub.cfg"
+ INPUT "arch/${CMAKE_SYSTEM_PROCESSOR}/support/grub.cfg.in"
+ )
+
+ add_custom_command(TARGET "${TARGET}"
+ POST_BUILD
+ COMMAND "${GRUB_MKRESCUE_EXE}"
+ "-o"
+ "$<TARGET_FILE_DIR:${TARGET}>/${TARGET}.iso"
+ "$<TARGET_FILE_DIR:${TARGET}>/isofs"
+ "$<TARGET_FILE:${TARGET}>"
+ "2>/dev/null"
+ BYPRODUCTS "${PROJECT_BINARY_DIR}/$<CONFIGURATION>/${TARGET}.iso"
+ COMMENT "Creating bootable ISO image"
+ )
+endfunction()