Rewriting all project tree

This commit is contained in:
Adrien Bourmault 2020-02-19 22:19:58 +01:00
parent 3c3e64e133
commit 08d2b6bd76
62 changed files with 108 additions and 105 deletions

12
.github/FUNDING.yml vendored
View File

@ -1,12 +0,0 @@
# These are supported funding model platforms
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: os-k-team
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

View File

@ -38,11 +38,13 @@ ASM=nasm
LD=x86_64-elf-ld
OBJCOPY=x86_64-elf-objcopy
CCNAME=x86_64-elf-gcc
# Flags
ASMFLAGS=-f elf64
LDFLAGS=-melf_x86_64
COPTIM=-O2
CWARNS=-Wall -Wextra -Wno-unused-parameter -Wno-implicit-fallthrough -Werror=implicit-function-declaration -Werror=return-type #-Wpadded
CINCLUDES=-Iinclude
CINCLUDES=-Iinclude -Iinclude/drivers -Iinclude/kernel
CFLAGS1=-nostdlib -ffreestanding -mcmodel=large -std=gnu11 -fstack-protector-all -fdump-rtl-expand
CFLAGS2= -c -mno-red-zone -mno-mmx -mno-sse -mno-sse2
CFLAGS= $(CFLAGS1) $(CFLAGS2)
@ -50,12 +52,15 @@ CFLAGS_MATHS= $(CFLAGS1) -c -mno-red-zone -mno-mmx
ifeq ($(mode), release)
CFLAGS += -D_NO_DEBUG
CFLAGS_MATHS += -D_NO_DEBUG
dep += dust
endif
ifeq ($(mode), debug)
CFLAGS += -g
CFLAGS_MATHS += -g
endif
# GCC
KCC=$(CCNAME) $(COPTIM) $(CWARNS) $(CFLAGS) $(CINCLUDES) \
-D_OSK_SOURCE -D_KALEID_KERNEL
@ -66,7 +71,6 @@ KCC_MATHS=$(CCNAME) $(COPTIM) $(CWARNS) $(CFLAGS_MATHS) $(CINCLUDES) \
MBRDIR=boot/grub
LOADERDIR=boot/loader
KALEIDDIR=kaleid
INCLUDEDIR=include
OBJDIR=build/obj
KOBJDIR=build/obj/kaleid
LOBJDIR=build/obj/boot
@ -113,14 +117,25 @@ KernSources = kernel/ke/cpuid.c kernel/mm/paging.c \
kernel/ke/rtc.c kernel/io/keyb.c \
kernel/io/spkr.c kernel/po/shtdwn.c \
kernel/sh/shell.c kernel/sh/shcmds.c \
kernel/sh/musage.c kernel/io/ata.c \
kernel/sh/argv.c kernel/ke/pit.c \
kernel/sh/testcmds.c kernel/mm/palloc.c \
kernel/io/acpi.c kernel/io/pci.c
kernel/sh/musage.c kernel/sh/argv.c \
kernel/ke/pit.c kernel/sh/testcmds.c \
kernel/mm/palloc.c kernel/io/acpi.c \
kernel/io/pci.c
KernObj=$(patsubst %.c,$(KOBJDIR)/%.o,$(KernSources))
KernDep=$(patsubst %.c,$(KOBJDIR)/%.d,$(KernSources))
# Drivers sources
DriverSources = drivers/ata.c
DriverObj=$(patsubst %.c,$(KOBJDIR)/%.o,$(DriverSources))
DriverDep=$(patsubst %.c,$(KOBJDIR)/%.d,$(DriverSources))
-include $(LibCDep)
-include $(KernDep)
-include $(DriverDep)
## MISC MAKEFILE ------------------------------------------------------------- #
./ProjectTree: ./.stylehlp_sh
@ -137,17 +152,14 @@ wc:
@cat $(shell find -name *.[ch]) $(shell find -name *.asm) $(shell find -name *.inc) | wc -l
egypt: CFLAGS := -DNDEBUG $(filter-out -fstack-protector-all,$(CFLAGS))
egypt: dust $(LibCObj) $(KernObj)
egypt: dust $(LibCObj) $(KernObj) $(DriverObj)
@find -name '*.expand' -o -name '*.expand' | xargs cat > rtl_exp.out
@egypt < rtl_exp.out | dot -Tps -o osk-graph.ps
@rm -f rtl_exp.out
@evince osk-graph.ps &
## LIB C MAKEFILE ------------------------------------------------------------ #
-include $(LibCDep)
$(KOBJDIR)/libc/atoi.o: $(KALEIDDIR)/libc/atoi.c | $(KOBJDIR)
@mkdir -p $(shell dirname $@)
@$(KCC) -D_NEED_ATOI $< -o $@.1
@ -174,9 +186,7 @@ $(KOBJDIR)/libc/mem.o: $(KALEIDDIR)/libc/mem.c | $(KOBJDIR)
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
## KERNEL MAKEFILE ----------------------------------------------------------- #
-include $(KernDep)
## KERNEL SPECIAL RECIPES MAKEFILE ------------------------------------------- #
$(KOBJDIR)/kernel/ke/idt.o: $(KALEIDDIR)/kernel/ke/idt.c \
$(KALEIDDIR)/kernel/ke/isr.asm | $(KOBJDIR)
@ -219,15 +229,17 @@ $(KOBJDIR)/kernel/mm/gdt.o: $(KALEIDDIR)/kernel/mm/gdt.c \
@rm -f $@.1 $@.2
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
$(KOBJDIR)/kernel/io/ata.o: $(KALEIDDIR)/kernel/io/ata.c \
$(KALEIDDIR)/kernel/io/ata.asm | $(KOBJDIR)
## DRIVERS SPECIAL RECIPES MAKEFILE ------------------------------------------ #
$(KOBJDIR)/drivers/ata.o: $(KALEIDDIR)/drivers/ata.c $(KALEIDDIR)/drivers/ata.asm | $(KOBJDIR)
@mkdir -p $(shell dirname $@)
@$(ASM) $(ASMFLAGS) $(KALEIDDIR)/kernel/io/ata.asm -o $@.1
@$(ASM) $(ASMFLAGS) $(KALEIDDIR)/drivers/ata.asm -o $@.1
@$(KCC) $< -o $@.2
@$(LD) $(LDFLAGS) -r $@.1 $@.2 -o $@
@rm -f $@.1 $@.2
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
## DEPENDENCIES MAKEFILE ----------------------------------------------------- #
$(KOBJDIR)/%.d: %.c | $(KOBJDIR)
@ -235,7 +247,6 @@ $(KOBJDIR)/%.d: %.c | $(KOBJDIR)
@$(KCC) -MM -MT $(@:%.d=%.o) -MF $@ $<
@echo ${CL2}[$@] ${CL}Dependencies generated.${CL3}
## MAIN MAKEFILE ------------------------------------------------------------- #
$(KOBJDIR)/%.o: %.c | $(KOBJDIR)
@ -246,14 +257,16 @@ $(KOBJDIR)/%.o: %.c | $(KOBJDIR)
$(BINDIR)/kaleid: $(LOBJDIR)/kaleid.x86_64
@echo ${CL2}[$@] ${NC}Objcopy...${CL3}
@mkdir -p $(shell dirname $@)
@$(OBJCOPY) -I elf64-x86-64 -O elf32-i386 $(LOBJDIR)/kaleid.x86_64 $(BINDIR)/kaleid
@$(OBJCOPY) -I elf64-x86-64 -O elf32-i386 $(LOBJDIR)/kaleid.x86_64 \
$(BINDIR)/kaleid
@echo ${CL2}[$@] ${CL}Success.${CL3}
$(LOBJDIR)/kaleid.x86_64: $(LibCObj) $(KernObj) $(LOBJDIR)/loader.o $(BUILDDIR)/kernel.ld
$(LOBJDIR)/kaleid.x86_64: $(LibCObj) $(KernObj) $(DriverObj) \
$(LOBJDIR)/loader.o $(BUILDDIR)/kernel.ld
@echo ${CL2}[$@] ${NC}Linking kernel objects...${CL3}
@mkdir -p $(shell dirname $@)
@$(LD) $(LDFLAGS) -T $(BUILDDIR)/kernel.ld \
$(LOBJDIR)/loader.o $(KernObj) $(LibCObj) \
$(LOBJDIR)/loader.o $(KernObj) $(DriverObj) $(LibCObj) \
-o $(LOBJDIR)/kaleid.x86_64
@echo ${CL2}[$@] ${CL}Success.${CL3}

View File

@ -47,48 +47,52 @@
│   ├── install-os-k.sh
│   └── kernel.ld
├── include
│   ├── ex
│   │   ├── lock.h
│   │   └── malloc.h
│   ├── init
│   │   ├── boot.h
│   │   └── mboot.h
│   ├── io
│   │   ├── acpi.h
│   │   ├── ata.h
│   │   ├── cursor.h
│   │   ├── keyb.h
│   │   ├── pci.h
│   │   ├── spkr.h
│   │   └── vga.h
│   ├── ke
│   │   ├── cpuid.h
│   │   ├── idt.h
│   │   ├── proc.h
│   │   ├── sched.h
│   │   ├── spinlock.h
│   │   └── time.h
│   ├── lib
│   │   ├── buf.h
│   │   └── list.h
│   ├── mm
│   │   ├── gdt.h
│   │   ├── heap.h
│   │   ├── malloc.h
│   │   ├── map.h
│   │   ├── paging.h
│   │   └── palloc.h
│   ├── po
│   │   └── shtdwn.h
│   ├── sh
│   ├── drivers
│   │   └── ata.h
│   ├── kernel
│   │   ├── ex
│   │   │   ├── lock.h
│   │   │   └── malloc.h
│   │   ├── init
│   │   │   ├── boot.h
│   │   │   └── mboot.h
│   │   ├── io
│   │   │   ├── acpi.h
│   │   │   ├── cursor.h
│   │   │   ├── keyb.h
│   │   │   ├── pci.h
│   │   │   ├── spkr.h
│   │   │   └── vga.h
│   │   ├── ke
│   │   │   ├── cpuid.h
│   │   │   ├── idt.h
│   │   │   ├── proc.h
│   │   │   ├── sched.h
│   │   │   ├── spinlock.h
│   │   │   └── time.h
│   │   ├── mm
│   │   │   ├── gdt.h
│   │   │   ├── heap.h
│   │   │   ├── malloc.h
│   │   │   ├── map.h
│   │   │   ├── paging.h
│   │   │   └── palloc.h
│   │   ├── po
│   │   │   └── shtdwn.h
│   │   └── sh
│   │   ├── argv.h
│   │   └── shell.h
│   ├── asm.h
│   ├── errno.h
│   ├── kernel.h
│   ├── libbuf.h
│   ├── libc.h
│   ├── liblist.h
│   └── vers.h
├── kaleid
│   ├── drivers
│   │   ├── ata.asm
│   │   └── ata.c
│   ├── kernel
│   │   ├── init
│   │   │   ├── info.c
@ -97,8 +101,6 @@
│   │   │   └── table.c
│   │   ├── io
│   │   │   ├── acpi.c
│   │   │   ├── ata.asm
│   │   │   ├── ata.c
│   │   │   ├── cursor.c
│   │   │   ├── keyb.c
│   │   │   ├── pci.c
@ -164,4 +166,4 @@
├── ProjectTree
└── README.md
28 directories, 111 files
30 directories, 111 files

Binary file not shown.

View File

@ -27,7 +27,7 @@
#endif
#ifndef _LIB_LIST_H
#include <lib/list.h>
#include <liblist.h>
#endif
#ifndef _KALKERN_PROC_H

View File

@ -27,7 +27,7 @@
#endif
#ifndef _LIB_LIST_H
#include <lib/list.h>
#include <liblist.h>
#endif
#ifndef _MM_MALLOC_H

View File

@ -22,7 +22,7 @@
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------//
#include <io/ata.h>
#include <drivers/ata.h>
#include <io/vga.h>
void IoDumpFirstSector(void)

View File

@ -22,7 +22,7 @@
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------//
#include <lib/buf.h>
#include <libbuf.h>
#include <io/keyb.h>
#include <ke/idt.h>

View File

@ -24,7 +24,7 @@
#include <io/spkr.h>
#include <ke/time.h>
#include <lib/buf.h>
#include <libbuf.h>
extern bool KeIdtIsInitialized;

View File

@ -22,7 +22,7 @@
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------//
#include <lib/buf.h>
#include <libbuf.h>
#include <init/boot.h>
#include <io/cursor.h>
#include <io/vga.h>

View File

@ -22,7 +22,7 @@
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------//
#include <lib/buf.h>
#include <libbuf.h>
#include <init/boot.h>
#include <ke/idt.h>
#include <io/vga.h>

View File

@ -22,7 +22,7 @@
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------//
#include <lib/buf.h>
#include <libbuf.h>
#include <kernel.h>
#include <ke/time.h>
#include <io/vga.h>

View File

@ -22,7 +22,7 @@
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------//
#include <lib/buf.h>
#include <libbuf.h>
#include <ke/proc.h>
#include <io/vga.h>

View File

@ -22,7 +22,7 @@
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------//
#include <lib/buf.h>
#include <libbuf.h>
#include <ke/time.h>
#include <ke/idt.h>
#include <ke/sched.h>

View File

@ -22,7 +22,7 @@
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------//
#include <lib/buf.h>
#include <libbuf.h>
#include <ke/time.h>
#include <ke/idt.h>

View File

@ -29,7 +29,7 @@
#include <mm/heap.h>
#include <mm/paging.h>
#include <mm/map.h>
#include <lib/buf.h>
#include <libbuf.h>
#include <io/vga.h>
#include <ke/time.h>

View File

@ -29,7 +29,7 @@
#include <mm/palloc.h>
#include <mm/map.h>
#include <io/vga.h>
#include <lib/buf.h>
#include <libbuf.h>
#include <ke/time.h>
//---------

View File

@ -25,7 +25,7 @@
#include <asm.h>
#include <ke/proc.h>
#include <ke/sched.h>
#include <lib/list.h>
#include <liblist.h>
#include <ke/time.h>
bool PsInitialized = false;

View File

@ -25,11 +25,11 @@
#include <vers.h>
#include <mm/paging.h>
#include <mm/map.h>
#include <io/ata.h>
#include <drivers/ata.h>
#include <io/vga.h>
#include <io/spkr.h>
#include <ke/time.h>
#include <lib/buf.h>
#include <libbuf.h>
#include <sh/shell.h>
#include <po/shtdwn.h>

View File

@ -25,7 +25,7 @@
#include <io/vga.h>
#include <io/keyb.h>
#include <io/spkr.h>
#include <lib/buf.h>
#include <libbuf.h>
#include <sh/argv.h>
#include <sh/shell.h>
#include <po/shtdwn.h>

View File

@ -24,7 +24,7 @@
#include <asm.h>
#include <vers.h>
#include <lib/buf.h>
#include <libbuf.h>
#include <ex/argv.h>
#include <init/boot.h>
#include <ke/time.h>
@ -34,7 +34,7 @@
#include <io/keyb.h>
#include <po/shtdwn.h>
#include <ke/cpuid.h>
#include <io/ata.h>
#include <drivers/ata.h>

View File

@ -26,11 +26,11 @@
#include <mm/paging.h>
#include <mm/palloc.h>
#include <mm/map.h>
#include <io/ata.h>
#include <drivers/ata.h>
#include <io/vga.h>
#include <io/spkr.h>
#include <ke/time.h>
#include <lib/buf.h>
#include <libbuf.h>
#include <sh/shell.h>
#include <po/shtdwn.h>

View File

@ -22,7 +22,7 @@
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------//
#include <lib/buf.h>
#include <libbuf.h>
//
// Closes a buffer, not flushing unless the proper flag is set

View File

@ -22,7 +22,7 @@
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------//
#include <lib/buf.h>
#include <libbuf.h>
//
// Erases buf's content

View File

@ -22,7 +22,7 @@
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------//
#include <lib/buf.h>
#include <libbuf.h>
#ifdef _KALEID_KERNEL
#include <ke/time.h>

View File

@ -22,7 +22,7 @@
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------//
#include <lib/buf.h>
#include <libbuf.h>
// Straightforward functions
int BGetFlags(Buffer_t *buf) { return buf->flags; }

View File

@ -22,7 +22,7 @@
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------//
#include <lib/buf.h>
#include <libbuf.h>
#include <ex/malloc.h>
Buffer_t *BStdIn, *BStdOut, *BStdDbg;

View File

@ -22,7 +22,7 @@
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------//
#include <lib/buf.h>
#include <libbuf.h>
#ifdef _KALEID_KERNEL
#include <io/vga.h>

View File

@ -22,7 +22,7 @@
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------//
#include <lib/buf.h>
#include <libbuf.h>
//
// Writes a character on a buffer

View File

@ -22,7 +22,7 @@
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------//
#include <lib/buf.h>
#include <libbuf.h>
#if 0
error_t BReadBuf(Buffer_t *buf, uchar *out, size_t n)

View File

@ -23,7 +23,7 @@
//----------------------------------------------------------------------------//
#if 0
#include <lib/buf.h>
#include <libbuf.h>
//
// Builds string reading from buf according to fmt

View File

@ -22,7 +22,7 @@
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------//
#include <lib/buf.h>
#include <libbuf.h>
void BEnableAutoScroll(Buffer_t *buf) { buf->flags |= BF_AUTOSCROLL; }
void BDisableAutoScroll(Buffer_t *buf) { buf->flags &= ~BF_AUTOSCROLL; }

View File

@ -22,5 +22,5 @@
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------//
#include <lib/buf.h>
#include <libbuf.h>

View File

@ -22,7 +22,7 @@
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------//
#include <lib/buf.h>
#include <libbuf.h>
//
// XXX

View File

@ -23,7 +23,7 @@
//----------------------------------------------------------------------------//
#include <libc.h>
#include <lib/buf.h>
#include <libbuf.h>
long strtol(const char *str, char **endp, int base) {
ulong n;