From faed2a66f113fbc6ad38a20eaac4e11e7dea116b Mon Sep 17 00:00:00 2001 From: starnakin Date: Tue, 17 Sep 2024 11:55:29 +0200 Subject: [PATCH 1/3] add: readme --- README.md | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..f51eeb3 --- /dev/null +++ b/README.md @@ -0,0 +1,69 @@ +# KFS (Kernel From Scratch) + +This project aims to explore how a kernel works by building our own, gaining hands-on experience with core concepts like memory management, interrupt, keyboard driver, etc + +## INSTALLATION + +### Cross compile the compile +[THE DOCUMENTATION](https://wiki.osdev.org/GCC_Cross-Compiler) +- install requirement follow [THE DOCUMENTATION](https://wiki.osdev.org/GCC_Cross-Compiler) +- Setup the shell +``` sh +export PREFIX="$HOME/opt/cross" +export TARGET=i386-elf +export PATH="$PREFIX/bin:$PATH" +mkdir $HOME/src +cd $HOME/src +``` +- Download [binutils](https://ftp.gnu.org/gnu/binutils/?C=M;O=D) +- Download [gcc](https://ftp.gnu.org/gnu/gcc/?C=M;O=D) +- Download [gdb](https://ftp.gnu.org/gnu/gdb/?C=M;O=D) +- extract archives +``` sh +tar xf [your binutils archive] +tar xf [your gcc archive] +tar xf [your gdb archive] +``` +- (protips use -j [nb core]) +- Compile binutils +``` sh +cd $HOME/src +mkdir build-binutils + +cd build-binutils +../binutils-x.y.z/configure --target=$TARGET --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror +make +make install +``` +- Compile gdb +``` sh +cd $HOME/src +mkdir build-gdb + +cd build-gdb +../gdb.x.y.z/configure --target=$TARGET --prefix="$PREFIX" --disable-werror +make all-gdb +make install-gdb +make +make install +``` +- Compile gcc +``` sh +cd $HOME/src + +# The $PREFIX/bin dir _must_ be in the PATH. We did that above. +which -- $TARGET-as || echo $TARGET-as is not in the PATH + +mkdir build-gcc +cd build-gcc +../gcc-x.y.z/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ --without-headers +make all-gcc +make all-target-libgcc +make install-gcc +make install-target-libgcc +``` + +### Compile and the start the kernel +``` sh +make run +``` \ No newline at end of file From 2f14074e4b5f9231c729c80041daa247ea16efeb Mon Sep 17 00:00:00 2001 From: starnakin Date: Tue, 17 Sep 2024 13:16:07 +0200 Subject: [PATCH 2/3] fix: print eip instead of ebp --- src/debug/print_stack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/debug/print_stack.c b/src/debug/print_stack.c index 3d92e3e..8ae7def 100644 --- a/src/debug/print_stack.c +++ b/src/debug/print_stack.c @@ -7,7 +7,7 @@ void print_stack(void) (struct stackframe *)__builtin_frame_address(0); while (stack) { - kprintf(0, "stack->ebp: %d\n", stack->ebp); + kprintf(0, "stack->ebp: %d\n", stack->eip); stack = stack->ebp; } } From e314ff97f734534667c1929a60c7fdd653a6dacf Mon Sep 17 00:00:00 2001 From: starnakin Date: Tue, 17 Sep 2024 13:19:56 +0200 Subject: [PATCH 3/3] apagna --- src/debug/print_stack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/debug/print_stack.c b/src/debug/print_stack.c index 8ae7def..df27d42 100644 --- a/src/debug/print_stack.c +++ b/src/debug/print_stack.c @@ -7,7 +7,7 @@ void print_stack(void) (struct stackframe *)__builtin_frame_address(0); while (stack) { - kprintf(0, "stack->ebp: %d\n", stack->eip); + kprintf(0, "fn: %d\n", stack->eip); stack = stack->ebp; } }