diff --git a/.gitignore b/.gitignore index e736961..242ab52 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,12 @@ -bin/ +src/bin/ *.bin *.o -os-image +src/os-image *.dis -boot/ +src/boot/ *.iso + + +# Added by cargo + +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..126f9a5 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "eOS" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..5c517d6 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "eOS" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] + +[profile.release] +panic = "abort" + +[profile.dev] +panic = "abort" + diff --git a/Makefile b/src/Makefile similarity index 77% rename from Makefile rename to src/Makefile index ba82ddd..66e2c51 100644 --- a/Makefile +++ b/src/Makefile @@ -4,12 +4,6 @@ CC = gcc CFLAGS = -fno-pie -m32 -Os -ffreestanding -# Rust -RC = rustc -# WARN: target might not exist on your machine. Just swap it out to whatever 32bit target that you have. -RTARGET = i686-unknown-linux-gnu -RFLAGS = --emit=obj --target $(RTARGET) - # Assembly AA = nasm AFLAGS = @@ -25,10 +19,8 @@ VMFLAGS = # Do not touch these. C_SOURCES = $(wildcard kernel/*.c drivers/*.c lib/*.c) HEADERS = $(wildcard kernel/*.h drivers/*.h lib/*.h) -R_SOURCES = $(wildcard kernel/*.rs drivers/*.rs lib/*.rs) OBJ = $(C_SOURCES:.c=.o) -ROBJ = $(R_SOURCES:.rs=.o) all: eos.iso @@ -49,15 +41,12 @@ eos_grub.iso : kernel.bin grub/grub.cfg eos.iso: bootloader/bootloader.bin kernel.bin cat $^ > eos.iso -kernel.bin: kernel/kernel_entry.o kernel/enable_paging.o $(OBJ) $(ROBJ) +kernel.bin: kernel/kernel_entry.o kernel/enable_paging.o $(OBJ) $(LD) -o $@ $^ $(LDFLAGS) %.o : %.c ${HEADERS} $(CC) $(CFLAGS) -c $< -o $@ -%.o : %.rs - $(RC) $< -o $@ $(RFLAGS) - %.o : %.asm $(AA) $< -f elf -o $@ $(AFLAGS) diff --git a/bootloader/bios/convert.asm b/src/bootloader/bios/convert.asm similarity index 100% rename from bootloader/bios/convert.asm rename to src/bootloader/bios/convert.asm diff --git a/bootloader/bios/disk.asm b/src/bootloader/bios/disk.asm similarity index 100% rename from bootloader/bios/disk.asm rename to src/bootloader/bios/disk.asm diff --git a/bootloader/bios/memory.asm b/src/bootloader/bios/memory.asm similarity index 100% rename from bootloader/bios/memory.asm rename to src/bootloader/bios/memory.asm diff --git a/bootloader/bios/print.asm b/src/bootloader/bios/print.asm similarity index 100% rename from bootloader/bios/print.asm rename to src/bootloader/bios/print.asm diff --git a/bootloader/bootloader.asm b/src/bootloader/bootloader.asm similarity index 100% rename from bootloader/bootloader.asm rename to src/bootloader/bootloader.asm diff --git a/bootloader/equ/ascii.asm b/src/bootloader/equ/ascii.asm similarity index 100% rename from bootloader/equ/ascii.asm rename to src/bootloader/equ/ascii.asm diff --git a/bootloader/equ/bios.asm b/src/bootloader/equ/bios.asm similarity index 100% rename from bootloader/equ/bios.asm rename to src/bootloader/equ/bios.asm diff --git a/bootloader/equ/vga.asm b/src/bootloader/equ/vga.asm similarity index 100% rename from bootloader/equ/vga.asm rename to src/bootloader/equ/vga.asm diff --git a/bootloader/pm/gdt.asm b/src/bootloader/pm/gdt.asm similarity index 100% rename from bootloader/pm/gdt.asm rename to src/bootloader/pm/gdt.asm diff --git a/bootloader/pm/vga/print.asm b/src/bootloader/pm/vga/print.asm similarity index 100% rename from bootloader/pm/vga/print.asm rename to src/bootloader/pm/vga/print.asm diff --git a/drivers/vga.c b/src/drivers/vga.c similarity index 100% rename from drivers/vga.c rename to src/drivers/vga.c diff --git a/drivers/vga.h b/src/drivers/vga.h similarity index 100% rename from drivers/vga.h rename to src/drivers/vga.h diff --git a/grub/grub.cfg b/src/grub/grub.cfg similarity index 100% rename from grub/grub.cfg rename to src/grub/grub.cfg diff --git a/kernel/enable_paging.asm b/src/kernel/enable_paging.asm similarity index 100% rename from kernel/enable_paging.asm rename to src/kernel/enable_paging.asm diff --git a/kernel/io.c b/src/kernel/io.c similarity index 100% rename from kernel/io.c rename to src/kernel/io.c diff --git a/kernel/io.h b/src/kernel/io.h similarity index 100% rename from kernel/io.h rename to src/kernel/io.h diff --git a/kernel/kernel.c b/src/kernel/kernel.c similarity index 100% rename from kernel/kernel.c rename to src/kernel/kernel.c diff --git a/kernel/kernel.h b/src/kernel/kernel.h similarity index 100% rename from kernel/kernel.h rename to src/kernel/kernel.h diff --git a/kernel/kernel_entry.asm b/src/kernel/kernel_entry.asm similarity index 100% rename from kernel/kernel_entry.asm rename to src/kernel/kernel_entry.asm diff --git a/kernel/memory.c b/src/kernel/memory.c similarity index 100% rename from kernel/memory.c rename to src/kernel/memory.c diff --git a/kernel/memory.h b/src/kernel/memory.h similarity index 100% rename from kernel/memory.h rename to src/kernel/memory.h diff --git a/kernel/paging.c b/src/kernel/paging.c similarity index 100% rename from kernel/paging.c rename to src/kernel/paging.c diff --git a/kernel/paging.h b/src/kernel/paging.h similarity index 100% rename from kernel/paging.h rename to src/kernel/paging.h diff --git a/kernel/test.rs b/src/kernel/test.rs similarity index 100% rename from kernel/test.rs rename to src/kernel/test.rs diff --git a/lib/conv.c b/src/lib/conv.c similarity index 100% rename from lib/conv.c rename to src/lib/conv.c diff --git a/lib/conv.h b/src/lib/conv.h similarity index 100% rename from lib/conv.h rename to src/lib/conv.h diff --git a/lib/math.c b/src/lib/math.c similarity index 100% rename from lib/math.c rename to src/lib/math.c diff --git a/lib/math.h b/src/lib/math.h similarity index 100% rename from lib/math.h rename to src/lib/math.h diff --git a/lib/str.c b/src/lib/str.c similarity index 100% rename from lib/str.c rename to src/lib/str.c diff --git a/lib/str.h b/src/lib/str.h similarity index 100% rename from lib/str.h rename to src/lib/str.h diff --git a/lib/types.h b/src/lib/types.h similarity index 100% rename from lib/types.h rename to src/lib/types.h diff --git a/lib/util.c b/src/lib/util.c similarity index 100% rename from lib/util.c rename to src/lib/util.c diff --git a/lib/util.h b/src/lib/util.h similarity index 100% rename from lib/util.h rename to src/lib/util.h diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..716751a --- /dev/null +++ b/src/main.rs @@ -0,0 +1,14 @@ +#![no_std] +#![no_main] + +use core::panic::PanicInfo; + +#[no_mangle] +pub extern "C" fn _start() -> ! { + loop {} +} + +#[panic_handler] +fn panic(_info: &PanicInfo) -> ! { + loop {} +}