diff --git a/Makefile b/Makefile index 7e28da0de..3baab772c 100644 --- a/Makefile +++ b/Makefile @@ -4,9 +4,9 @@ RESOURCES = resources ISO_DIR = isodir ISO_NAME = axle.iso -OBJ_DIR = .objs +OBJ_DIR = .kernel_objs SRC_DIR = kernel -COMPILED_RUST_KERNEL_LIBS_DIR = compiled_rust_kernel_libs +COMPILED_RUST_KERNEL_LIBS_DIR = .compiled_rust_kernel_libs ARCH = x86_64 diff --git a/bootloader/main.c b/bootloader/main.c index ae502fa2f..203fe4251 100644 --- a/bootloader/main.c +++ b/bootloader/main.c @@ -169,7 +169,7 @@ bool map_file(const char* file_path, uint64_t* out_base, uint64_t* out_size) { printf(": Reading %s buffer...\n", file_path); fread((void*)file_buf, file_size, 1, file); print_time(); - printf(": Mapped initrd\n"); + printf(": Mapped %s\n", file_path); fclose(file); *out_base = file_buf; @@ -353,7 +353,7 @@ int main(int argc, char** argv) { efi_configuration_table_t* table = &config_table[i]; //printf("Looking at table %d at %x\n", i, table); efi_guid_t* guid = &table->VendorGuid; - printf("guid %08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x\n", guid->Data1, guid->Data2, guid->Data3, guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3], guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]); + //printf("guid %08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x\n", guid->Data1, guid->Data2, guid->Data3, guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3], guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]); if (!memcmp(guid, &acpi_1_0_rsdp_guid, sizeof(acpi_1_0_rsdp_guid))) { printf("\tFound ACPI 1.0 RSDP at index %d\n", i); } @@ -367,9 +367,11 @@ int main(int argc, char** argv) { // Finally, exit UEFI-land and jump to the kernel printf("Jumping to kernel entry point at %p\n", kernel_entry_point); - if (exit_bs()) { + status = exit_bs(); + if (status != 0) { + printf("Status %d\n", status); // Red - draw(boot_info, 0x00ff0000); + draw(boot_info, 0x0000ffff); printf("Failed to exit boot services!\n"); while (1) {} return 0; diff --git a/kernel/kernel/segmentation/gdt.c b/kernel/kernel/segmentation/gdt.c index bec657274..8fc5f3aad 100644 --- a/kernel/kernel/segmentation/gdt.c +++ b/kernel/kernel/segmentation/gdt.c @@ -206,7 +206,7 @@ void gdt_init() { .base_middle = 0x0, .accessed = 0, .readable = 1, - // In the code segment, "Conforming": Whether code in this segment can be run in less-priviliged rings + // In the code segment, "Conforming": Whether code in this segment can be run in less-privileged rings .contextual = 0, .is_code = 1, .belongs_to_os = 1, diff --git a/kernel/kernel/util/unistd/write.c b/kernel/kernel/util/unistd/write.c index bdbe2cbb7..56df2dc76 100644 --- a/kernel/kernel/util/unistd/write.c +++ b/kernel/kernel/util/unistd/write.c @@ -21,6 +21,8 @@ int stdout_write(task_small_t* task, int fd, const void* buf, int len) { } int write(int fd, char* buf, int len) { + // TODO(PT): Handle clearly invalid buf pointers. Perhaps enumerate each page in the slice and ensure that each + // is mapped and readable. //printf("write(%d, %x, %d)\n", fd, buf, len); assert(tasking_is_active(), "Can't write via fd until multitasking is active"); if (!len) return 0; diff --git a/kernel/std/common.h b/kernel/std/common.h index 7019e9574..2d7580d3a 100644 --- a/kernel/std/common.h +++ b/kernel/std/common.h @@ -15,7 +15,6 @@ __BEGIN_DECLS #define kernel_end_critical() __asm__("sti"); - //write byte to port STDAPI void outb(uint16_t port, uint8_t val); //write word to port diff --git a/scripts/build_os_image.py b/scripts/build_os_image.py index c0e34512d..50919cecc 100644 --- a/scripts/build_os_image.py +++ b/scripts/build_os_image.py @@ -17,6 +17,8 @@ ARCH = "x86_64" +_REPO_ROOT = Path(__file__).parents[1] + def _is_macos() -> bool: return os.uname().sysname == 'Darwin' @@ -50,15 +52,15 @@ def build_iso() -> Path: if not bootloader_binary_path.exists(): raise ValueError(f"Bootloader binary missing: {bootloader_binary_path}") - kernel_binary_path = Path(__file__).parents[1] / "isodir" / "boot" / "axle.bin" + kernel_binary_path = _REPO_ROOT / "isodir" / "boot" / "axle.bin" if not kernel_binary_path.exists(): raise ValueError(f"Kernel binary missing: {kernel_binary_path}") - fs_server_path = Path(__file__).parents[1] / "axle-sysroot" / "usr" / "applications" / "initrd_fs" + fs_server_path = _REPO_ROOT / "axle-sysroot" / "usr" / "applications" / "initrd_fs" if not fs_server_path.exists(): raise ValueError(f"fs_server missing: {fs_server_path}") - initrd_path = Path(__file__).parents[1] / "isodir" / "boot" / "initrd.img" + initrd_path = _REPO_ROOT / "isodir" / "boot" / "initrd.img" if not initrd_path.exists(): raise ValueError(f"initrd missing: {initrd_path}") @@ -84,6 +86,8 @@ def build_initrd() -> None: # This will also build mkinitrd, if necessary run_and_check(['cargo', 'run', '--release'], cwd=mkinitrd_path) + # TODO(PT): How to select whether to build or not? + # run_and_check(["./target/release/mkinitrd"], cwd=mkinitrd_path) generated_initrd = mkinitrd_path / "output.img" if not generated_initrd.exists(): diff --git a/scripts/build_rust_toolchain.py b/scripts/build_rust_toolchain.py index 45a6964ba..058b79e1b 100755 --- a/scripts/build_rust_toolchain.py +++ b/scripts/build_rust_toolchain.py @@ -18,7 +18,7 @@ _RUST_KERNEL_LIBS_DIR = _REPO_ROOT / "rust_kernel_libs" _KERNEL_TARGET_SPEC_FILE = _RUST_KERNEL_LIBS_DIR / "x86_64-unknown-axle_kernel.json" -_COMPILED_RUST_KERNEL_LIBS_DIR = _REPO_ROOT / "compiled_rust_kernel_libs" +_COMPILED_RUST_KERNEL_LIBS_DIR = _REPO_ROOT / ".compiled_rust_kernel_libs" _CACHE_DIR = Path(__file__).parent / "caches" diff --git a/scripts/mkinitrd/src/main.rs b/scripts/mkinitrd/src/main.rs index 09d4b269d..4270ce709 100644 --- a/scripts/mkinitrd/src/main.rs +++ b/scripts/mkinitrd/src/main.rs @@ -95,7 +95,7 @@ fn main() -> Result<(), Box> { let fs_image = traverse(&sysroot, &sysroot).expect("traverse failed"); println!("Finished generating directory image"); - let mut file = std::io::BufWriter::new(std::fs::File::create("./output.img").unwrap()); + let mut file = io::BufWriter::new(std::fs::File::create("./output.img").unwrap()); let v = postcard::to_allocvec(&fs_image).expect("Failed to encode"); file.write(&v).expect("Failed to write to file"); diff --git a/scripts/run_axle.py b/scripts/run_axle.py index 90ff55e09..bc55efdc3 100644 --- a/scripts/run_axle.py +++ b/scripts/run_axle.py @@ -23,7 +23,7 @@ def run_iso(image_path: Path) -> None: "hvf", "-cpu", "host", - # Capture data sent to serial port + # Capture data sent to serial port "-serial", "file:syslog.log", # SATA drive