Skip to content

Commit

Permalink
Merge pull request #4 from vvaucoul/work-in-progress
Browse files Browse the repository at this point in the history
WIP -> Main branch (Fully fonctional Memory / Kernel Heap and Pagination)
  • Loading branch information
vvaucoul authored Dec 6, 2022
2 parents 7cd659c + caf8340 commit 7b50cdd
Show file tree
Hide file tree
Showing 196 changed files with 9,177 additions and 631 deletions.
15 changes: 0 additions & 15 deletions .github/workflows/c-cpp.yml

This file was deleted.

17 changes: 17 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Kronos Kernel Workflow

on:
push:
branches: [ "main", "memory-system", "work-in-progress" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Installing dependencies
run : make install-dependencies
- name: Compiling Kernel
run: make
11 changes: 7 additions & 4 deletions Docker/compil.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,24 @@
# By: vvaucoul <vvaucoul@student.42.Fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/07/03 16:32:59 by vvaucoul #+# #+# #
# Updated: 2022/07/03 16:33:18 by vvaucoul ### ########.fr #
# Updated: 2022/10/12 15:00:20 by vvaucoul ### ########.fr #
# #
# **************************************************************************** #

make -C ../ clean
make -C ../ fclean
sh Docker/clear.sh 2>&1

mkdir -pv build

cp -r ../Makefile build/Makefile
cp -r ../grub.cfg build/grub.cfg
cp -r ../linker.ld build/linker.ld
cp -r ../config build/config
cp -r ../linkers build/linkers
cp -r ../boot build/boot
cp -r ../kernel build/kernel
cp -r ../libkfs build/libkfs
cp -r ../mk-files build/mk-files
cp -r ../xorriso-1.4.6.tar.gz build/xorriso-1.4.6.tar.gz
cp -r ../scripts build/scripts

docker stop vvaucoul-kfs
docker rm vvaucoul-kfs
Expand Down
1 change: 1 addition & 0 deletions Hephaistos
Submodule Hephaistos added at f69315
194 changes: 100 additions & 94 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,60 +6,94 @@
# By: vvaucoul <vvaucoul@student.42.Fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/06/14 18:51:28 by vvaucoul #+# #+# #
# Updated: 2022/08/16 14:48:36 by vvaucoul ### ########.fr #
# Updated: 2022/11/21 12:41:25 by vvaucoul ### ########.fr #
# #
# **************************************************************************** #

#*******************************************************************************
#* VAR *
#* INLCUDES *
#*******************************************************************************

NAME = kfs
ISO = $(NAME).iso
LIBKFS = lkfs
LIBKFS_A = libkfs/libkfs.a
CC = clang
LD = ld
INLCUDES_PATH = -I./kernel/includes/
CFLAGS = -Wall -Wextra -Wfatal-errors \
-fno-builtin -fno-exceptions -fno-stack-protector \
-nostdlib -nodefaultlibs \
-std=gnu99 -ffreestanding -O2
LDFLAGS = -g3 -m32
LD_FLAGS = -m elf_i386

ASM = nasm
ASMFLAGS = -f elf32
BOOT = boot/boot
KDSRCS = srcs/kernel
HEADERS_DIR = kernel/includes/
BIN = kernel.bin
BIN_DIR = bin
LINKER = linker.ld

XORRISO = xorriso-1.4.6
MK_INCLUDE_DIR = mk-files

include $(MK_INCLUDE_DIR)/utils/Colors.mk
include $(MK_INCLUDE_DIR)/dependencies/ShellRules-Dependencies.mk
include $(MK_INCLUDE_DIR)/rules/Rules.mk

include $(MK_INCLUDE_DIR)/includes/Headers.mk

include $(MK_INCLUDE_DIR)/sources/Sources-Boot.mk
include $(MK_INCLUDE_DIR)/sources/Sources.mk
include $(MK_INCLUDE_DIR)/sources/Sources-Workflows.mk
include $(MK_INCLUDE_DIR)/sources/Sources-ASM.mk

#*******************************************************************************
#* INLCUDES *
#* VAR *
#*******************************************************************************

include $(MK_INCLUDE_DIR)/Colors.mk
include $(MK_INCLUDE_DIR)/Sources-Boot.mk
include $(MK_INCLUDE_DIR)/Sources.mk
include $(MK_INCLUDE_DIR)/Sources-ASM.mk
include $(MK_INCLUDE_DIR)/Headers.mk
ifeq ($(CHECK_CLANG_INSTALL), false)
CLANG_INSTALLED = false
else
CLANG_INSTALLED = true
endif

NAME = kfs
ISO = $(NAME).iso

LD = ld
INLCUDES_PATH = -I./kernel/includes/ \
-I./$(LIBKFS_DIR)/$(LIBKFS_DIR)/
CFLAGS = -Wall -Wextra -Wfatal-errors \
-fno-builtin -fno-exceptions -fno-stack-protector \
-nostdlib -nodefaultlibs \
-std=gnu99 -ffreestanding -O2
LDFLAGS = -g3 -m32
LD_FLAGS = -m elf_i386

OBJS_DIR = objs
DEPENDS_DIR = depends

ASM = nasm
ASMFLAGS = -f elf32

KDSRCS = srcs/kernel
HEADERS_DIR = kernel/includes/
BIN = kernel.bin
BIN_DIR = bin

XORRISO = xorriso-1.4.6
XORRISO_INSTALLED = $(CHECK_XORRISO_INSTALL)

CCACHE_INSTALLED = $(CHECK_CCACHE_INSTALL)
CCACHE_DIR = ccache

ifeq ($(CCACHE_INSTALLED), false)
CCACHE = ./$(DEPENDENCIES_DIR)/$(CCACHE_DIR)/ccache
else
CCACHE = ccache
endif

# Todo: Check clang version / do not use gcc -> error
ifeq ($(CLANG_INSTALLED), false)
CC = $(CCACHE) gcc
else
CC = $(CCACHE) clang
endif

DEPENDS = $(KOBJS:.o=.d)
WDEPENDS = $(WOBJS:.o=.d)
DEPENDS_ASM = $(KOBJS_ASM:.o=.d)

#*******************************************************************************
#* KSRCS *
#*******************************************************************************

%.o: %.c
@printf "$(_LWHITE) $(_DIM)- Compiling: $(_END)$(_DIM)--------$(_END)$(_LCYAN) %s $(_END)$(_LGREEN)[$(_LWHITE)$(_LGREEN)]$(_END)\n" $<
@$(CC) $(LDFLAGS) $(CFLAGS) $(INLCUDES_PATH) -c $< -o ${<:.c=.o}
@printf "$(_LWHITE) $(_DIM)- Compiling: $(_END)$(_DIM)--------$(_END)$(_LCYAN) %s $(_END)$(_LGREEN)[$(_LWHITE)$(_LGREEN)]$(_END)\n" $<
@$(CC) $(LDFLAGS) $(CFLAGS) $(INLCUDES_PATH) -MD -c $< -o ${<:.c=.o}

%.o: %.s
@printf "$(_LWHITE) $(_DIM)- Compiling: $(_END)$(_DIM)--------$(_END)$(_LPURPLE) %s $(_END)$(_LGREEN)[$(_LWHITE)$(_LGREEN)]$(_END)\n" $<
@printf "$(_LWHITE) $(_DIM)- Compiling: $(_END)$(_DIM)--------$(_END)$(_LPURPLE) %s $(_END)$(_LGREEN)[$(_LWHITE)$(_LGREEN)]$(_END)\n" $<
@$(ASM) $(ASMFLAGS) $< -o ${<:.s=.o}

#*******************************************************************************
Expand All @@ -68,88 +102,50 @@ include $(MK_INCLUDE_DIR)/Headers.mk

all: $(NAME)

$(NAME): ascii $(XORRISO) $(LIBKFS) $(BOOT) $(KDSRCS) $(HEADERS) $(BIN_DIR)/$(BIN) $(ISO) helper
$(NAME): ascii $(XORRISO) $(CCACHE) lkfs $(BOOT) $(KDSRCS) $(HEADERS) $(BIN_DIR)/$(BIN) $(ISO) helper
@true

$(LIBKFS):
@make -s -C libkfs
lkfs-install:
@sh $(SCRIPTS_DIR)/installHephaistos.sh

lkfs: lkfs-install
@make -s -C $(LIBKFS_DIR) CLANG_INSTALLED=$(CLANG_INSTALLED) CCACHE_INSTALLED=$(CCACHE_INSTALLED)
@printf "$(_LWHITE)- LIBKFS$(_END)$(_END)$(_DIM)-----------------$(_END) $(_LGREEN)[$(_LWHITE)$(_LGREEN)]$(_END)\n"

.PHONY: lkfs

$(BOOT): $(KBOOT_OBJS)
@printf "$(_LWHITE)- ASM BOOT $(_END)$(_DIM)--------------$(_END) $(_LGREEN)[$(_LWHITE)$(_LGREEN)]$(_END)\n"

$(KDSRCS): $(KOBJS) $(KOBJS_ASM) $(HEADERS)
$(KDSRCS): $(KOBJS) $(KOBJS_ASM) $(WOBJS)
@printf "$(_LWHITE)- KERNEL SRCS $(_END)$(_DIM)-----------$(_END) $(_LGREEN)[$(_LWHITE)$(_LGREEN)]$(_END)\n"

$(BIN_DIR)/$(BIN):
@mkdir -p $(BIN_DIR)
@$(LD) $(LD_FLAGS) -T $(LINKER) -o $(BIN_DIR)/$(BIN) $(KBOOT_OBJS) $(KOBJS) $(KOBJS_ASM) $(LIBKFS_A) #> /dev/null 2>&1
@printf "$(_LWHITE) $(_DIM)- Compiling: $(_END)$(_DIM)--------$(_END)$(_LYELLOW) %s $(_END)$(_LGREEN)[$(_LWHITE)$(_LGREEN)]$(_END)\n" "KERNEL / LINKER / BOOT"
@printf "$(_LWHITE)- KERNEL BIN $(_END)$(_DIM)------------$(_END) $(_LGREEN)[$(_LWHITE)$(_LGREEN)]$(_END)$(_DIM) -> ISO CREATION $(_END) \n"
@make -s -C . check

$(XORRISO):
@printf "$(_LYELLOW)- COMPILING XORRISO $(_END)$(_DIM)-----$(_END) $(_LYELLOW)[$(_LWHITE)⚠️ $(_LYELLOW)]$(_END) $(_LYELLOW)>$(_END)$(_DIM)$(shell pwd)/$(XORRISO)/$(_END)$(_LYELLOW)<$(_END)\n"
@tar xf $(XORRISO).tar.gz
@cd $(XORRISO) && ./configure --prefix=/usr > /dev/null 2>&1 && make -j$(nproc) > /dev/null 2>&1
@printf "$(_LWHITE)- $(XORRISO) $(_END)$(_DIM)---------$(_END) $(_LGREEN)[$(_LWHITE)$(_LGREEN)]$(_END)\n"
@sh $(SCRIPTS_DIR)/installXorriso.sh

$(CCACHE):
@sh $(SCRIPTS_DIR)/installCcache.sh

check:
@grub-file --is-x86-multiboot $(BIN_DIR)/$(BIN) && printf "$(_LWHITE)- $(BIN) $(_END)$(_DIM)------------$(_END) $(_LGREEN)[$(_LWHITE)$(_LGREEN)]$(_END)" || printf "$(_LWHITE)- $(BIN) $(_END)$(_DIM)------------$(_END) $(_LRED)[$(_LWHITE)$(_LRED)]$(_END)"
printf "$(_END)$(_DIM) -> ISO CHECKER $(_END)\n"

run:
@printf "$(_LWHITE)Running $(_LYELLOW)KFS$(_LWHITE) with $(_LYELLOW)qemu-system-i386$(_LWHITE) with $(_LYELLOW)kernel$(_LWHITE) !\n"
@qemu-system-i386 -smp 1 -kernel isodir/boot/$(BIN) -display gtk -vga std -full-screen

run-iso:
@printf "$(_LWHITE)Running $(_LYELLOW)KFS$(_LWHITE) with $(_LYELLOW)qemu-system-i386$(_LWHITE) with $(_LYELLOW)cdrom$(_LWHITE) !\n"
@qemu-system-i386 -smp 1 -cdrom $(NAME).iso -display gtk -boot d -vga std -full-screen

run-curses:
@printf "$(_LWHITE)Running $(_LYELLOW)KFS$(_LWHITE) with $(_LYELLOW)qemu-system-i386$(_LWHITE) with $(_LYELLOW)cdrom$(_LWHITE) !\n"
@qemu-system-i386 -smp 1 -cdrom $(NAME).iso -display curses -vga std -full-screen

debug:
@printf "$(_LWHITE)Running $(_LYELLOW)KFS$(_LWHITE) with $(_LYELLOW)qemu-system-i386$(_LWHITE) with $(_LYELLOW)kernel$(_LWHITE) in $(_LRED)debug mode$(_LWHITE) !\n"
@qemu-system-i386 -smp 1 -kernel isodir/boot/$(BIN) -s -S -display gtk -vga std -full-screen

$(ISO):
@mkdir -p isodir/boot/grub
@cp $(BIN_DIR)/kernel.bin isodir/boot/kernel.bin
@cp grub.cfg isodir/boot/grub/grub.cfg
@grub-mkrescue -o $(ISO) isodir \
--xorriso=$(shell pwd)/$(XORRISO)/xorriso/xorriso > /dev/null 2>&1
@printf "$(_LWHITE)- ISO $(_END)$(_DIM)-------------------$(_END) $(_LGREEN)[$(_LWHITE)$(_LGREEN)]$(_END)\n"

clean:
@make -s -C libkfs clean
@rm -rf $(NAME).iso $(KBOOT_OBJS) isodir $(BIN_DIR)/$(BIN) $(KOBJS) $(KOBJS_ASM) $(BIN)
@make -s -C $(LIBKFS_DIR) clean
@make -s -C . clean-disk
@rm -rf $(NAME).iso $(KBOOT_OBJS) isodir $(BIN_DIR)/$(BIN) $(KOBJS) $(KOBJS_ASM) $(WOBJS) $(BIN) $(DEPENDS) $(WDEPENDS) $(DEPENDS_ASM)
@printf "$(_LWHITE)- CLEAN $(_END)$(_DIM)-----------------$(_END) $(_LGREEN)[$(_LWHITE)$(_LGREEN)]$(_END)\n"

fclean: clean clear-docker
@make -s -C libkfs fclean
@rm -rf $(XORRISO) $(BIN_DIR)
fclean: clean docker-clear
@make -s -C $(LIBKFS_DIR) fclean
@rm -rf $(DEPENDENCIES_DIR)/$(XORRISO) $(BIN_DIR) $(DEPENDENCIES_DIR)/$(CCACHE_DIR)
@printf "$(_LWHITE)- FCLEAN $(_END)$(_DIM)----------------$(_END) $(_LGREEN)[$(_LWHITE)$(_LGREEN)]$(_END)\n"

re: clean
@rm -rf $(BIN_DIR)
@make -s -C libkfs re > /dev/null 2>&1
@make -s -C $(LIBKFS_DIR) re #> /dev/null 2>&1
@make -s -C . all

run-docker: ascii
@printf "$(_LCYAN)- DOCKER $(_END)$(_DIM)----------------$(_END) $(_LYELLOW)[$(_LWHITE)⚠️ $(_LYELLOW)]$(_END) $(_LYELLOW)\n$(_END)"
@cd Docker > /dev/null ; sh compil.sh > /dev/null 2>&1
@mkdir -p isodir/boot
@cp Docker/kfs.iso . && cp Docker/kernel.bin . && cp Docker/kernel.bin isodir/boot/kernel.bin
@printf "$(_LWHITE)- KFS.iso $(_END)$(_DIM)---------------$(_END) $(_LGREEN)[$(_LWHITE)$(_LGREEN)]$(_END)\n"
@printf "$(_LWHITE)- KERNEL.bin $(_END)$(_DIM)------------$(_END) $(_LGREEN)[$(_LWHITE)$(_LGREEN)]$(_END)\n"
@printf "$(_LWHITE)- BOOT/KERNEL.bin $(_END)$(_DIM)-------$(_END) $(_LGREEN)[$(_LWHITE)$(_LGREEN)]$(_END)\n"
@make -s -C . helper

clear-docker:
@cd Docker; sh clear.sh > /dev/null 2>&1

ascii:
@printf "$(_LRED)\r██╗ ██╗███████╗███████╗$(_LWHITE) $(_LRED)██████╗ \n$(_END)"
@printf "$(_LRED)\r██║ ██╔╝██╔════╝██╔════╝$(_LWHITE) $(_LRED)╚════██╗\n$(_END)"
Expand All @@ -161,4 +157,14 @@ ascii:
helper:
@printf "\n$(_LWHITE)- Now you use: '$(_LYELLOW)make run$(_END)$(_LWHITE)' or '$(_LYELLOW)make run-iso$(_END)$(_LWHITE)' to start the kernel !$(_END)\n"

.PHONY: all clean fclean re debug run run-iso ascii helper run-curses run-docker clear-docker
include $(MK_INCLUDE_DIR)/kernel-starter/QEMU-Runner.mk
include $(MK_INCLUDE_DIR)/docker/Docker.mk
include $(MK_INCLUDE_DIR)/kernel-maker/Kernel-Maker.mk
include $(MK_INCLUDE_DIR)/dependencies/Dependencies.mk
include $(MK_INCLUDE_DIR)/tiny-kernels/tiny-kernels.mk

-include $(DEPENDS)
-include $(WDEPENDS)
-include $(DEPENDS_ASM)

.PHONY: all clean fclean re debug ascii helper
Loading

0 comments on commit 7b50cdd

Please sign in to comment.