Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 26 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

#export DEBUG = 1
export DEBUG_LOGGING = 1

export SUPPRESS_ACPICA_BUILD_OUTPUT = 1
export SMP_ENABLE = 1

# Global options

Expand Down Expand Up @@ -58,24 +57,32 @@ export CC := clang
export AR := llvm-ar
export STRIP := llvm-strip

SUBDIRS := kernel boot drivers test
SUBDIRS := kernel boot drivers test userland
KERNEL_TARGETS := \
$(OBJ_DIR)/kernel.a
BOOT_TARGETS := \
$(OBJ_DIR)/boot.a \
$(OBJ_DIR)/esp.img
DRIVERS_TARGETS := \
$(OBJ_DIR)/drivers.a \
$(OBJ_DIR)/acpica.a
$(OBJ_DIR)/drivers.a
TEST_TARGETS := \
$(OBJ_DIR)/test_lib.a \
$(OBJ_DIR)/test_testsuite.a

USERLAND_TARGETS := $(OBJ_DIR)/userland_files/

export RUNTIME_DRIVERS_TARGETS := \
$(OBJ_DIR)/drivers/driver_list.txt

TEST_CANIDATES := $(patsubst $(OBJ_DIR)/test_%.a,test-%,$(TEST_TARGETS))
TEST_EXEC := $(basename $(TEST_TARGETS))

COPY_DOC_TO := $(OBJ_DIR)/rootfs/usr/share/doc/ModulOS/

COPY_DRIVERS_TO := $(OBJ_DIR)/rootfs/lib/drivers/

COPY_USERLAND_TO := $(OBJ_DIR)/rootfs/

SRC := $(shell find . -type f \( -name "*.c" -o -name "*.S" -o -name "*.h" \))

include $(SRC_TREE_ROOT)/scripts/Makefile.kcflags
Expand Down Expand Up @@ -115,6 +122,8 @@ cscope.files: $(SRC)
$(KERNEL_TARGETS): kernel
$(BOOT_TARGETS): boot
$(DRIVERS_TARGETS): drivers
$(RUNTIME_DRIVERS_TARGETS): drivers
$(USERLAND_TARGETS): userland

$(TEST_TARGETS): test

Expand All @@ -123,7 +132,15 @@ $(TEST_EXEC): %: %.a $(OBJ_DIR)/boot.a $(OBJ_DIR)/kernel.a $(OBJ_DIR)/drivers.a

.PHONY: copy-doc
copy-doc: COPYING LICENSES | $(COPY_DOC_TO)
cp -r COPYING LICENSES $(COPY_DOC_TO)
cp -r $^ $|

.PHONY: copy-runtime-drivers
copy-runtime-drivers: $(RUNTIME_DRIVERS_TARGETS) | $(COPY_DRIVERS_TO)
cp -r $^ $|

.PHONY: copy-userland
copy-userland: $(USERLAND_TARGETS) | $(COPY_USERLAND_TO)
cp -r $^/* $|

$(OBJ_DIR)/stub.img: | $(OBJ_DIR)/
truncate -s 4G $@
Expand All @@ -139,7 +156,7 @@ $(OBJ_DIR)/stub-esp.dummy: $(OBJ_DIR)/stub.img $(OBJ_DIR)/modulos $(OBJ_DIR)/esp

# 54525952 is for 52MiB offset (512 * 1024 * 1024)
# 1034240 is for 52MiB initial (4MiB align + 48MiB ESP) and 4MiB tail for gpt
$(OBJ_DIR)/stub-fs.dummy: $(OBJ_DIR)/stub.img copy-doc
$(OBJ_DIR)/stub-fs.dummy: $(OBJ_DIR)/stub.img copy-runtime-drivers copy-userland copy-doc
yes | mke2fs -L rootfs -E offset=54525952 -d $(OBJ_DIR)/rootfs/ -t ext2 \
-b 4096 $< 1034240
touch $@
Expand All @@ -159,6 +176,5 @@ $(OBJ_DIR)/modulos: $(OBJ_DIR)/modulos-dbg
$(OBJ_DIR)/modulos-dbg: $(OBJ_DIR)/modulos.ld \
$(OBJ_DIR)/boot.a \
$(OBJ_DIR)/kernel.a \
$(OBJ_DIR)/drivers.a \
$(OBJ_DIR)/acpica.a
$(CC) -o $@ $(LTO) $(LD_FLAGS) -fuse-ld=lld -T $^
$(OBJ_DIR)/drivers.a
$(CC) -o $@ $(LD_FLAGS) -fuse-ld=lld -T $^
17 changes: 11 additions & 6 deletions boot/multiboot2/boot.S
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@

#define EFER 0xC0000080
#define LME 0x100
#define SYS 0x1
#define NXE 0x800

#define PG (1 << 31)

#define KERNEL_PAGE_FLAGS (1 + 2)
Expand Down Expand Up @@ -186,7 +189,9 @@ _start:

movl $EFER, %ecx /* EFER */
rdmsr
orl $SYS, %eax /* syscall enable */
orl $LME, %eax /* LME */
orl $NXE, %eax /* execute disable bit */
wrmsr

movl %cr0, %eax
Expand Down Expand Up @@ -259,19 +264,19 @@ gdt:
.byte 0x92 /* access: P */
.byte 0x00 /* limit 16:19 flag: */
.byte 0x00 /* base 24:31 */
gdt.ucodeseg:
gdt.udataseg:
.short 0x0000 /* limit 0:15 */
.short 0x0000 /* base 0:15 */
.byte 0x00 /* base 16:23 */
.byte 0xF8 /* access: DPL=3 P */
.byte 0x20 /* limit 16:19 flag: L */
.byte 0xF2 /* access: P */
.byte 0x00 /* limit 16:19 flag: */
.byte 0x00 /* base 24:31 */
gdt.udataseg:
gdt.ucodeseg:
.short 0x0000 /* limit 0:15 */
.short 0x0000 /* base 0:15 */
.byte 0x00 /* base 16:23 */
.byte 0x92 /* access: P */
.byte 0x00 /* limit 16:19 flag: */
.byte 0xF8 /* access: DPL=3 P */
.byte 0x20 /* limit 16:19 flag: L */
.byte 0x00 /* base 24:31 */
gdt.tss:
.quad 0
Expand Down
2 changes: 1 addition & 1 deletion boot/multiboot2/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <kernel/core/logging.h>
#include <kernel/core/proc_data.h>

#include <drivers/acpi/tables.h>
#include <kernel/acpi/tables.h>

#ifdef SERIAL
#include <drivers/serial/serial.h>
Expand Down
15 changes: 5 additions & 10 deletions drivers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ include $(SRC_TREE_ROOT)/scripts/Makefile.header

export OBJ_DIR := $(OBJ_DIR)/drivers

$(call add_directory,pic_8259,PIC_8259)
$(call add_directory,apic,APIC)
$(call add_directory,ioapic,IOAPIC)
$(call add_directory,acpi,ACPI)
$(call add_directory,acpica_osl,ACPICA_OSL)
$(call add_directory,pcie,PCIE)
$(call add_directory,disk,DISK)

Expand Down Expand Up @@ -58,12 +53,12 @@ include $(SRC_TREE_ROOT)/scripts/Makefile.targets
all: build

.PHONY: build
build: $(OBJ_DIR)/../drivers.a $(OBJ_DIR)/../acpica.a $(LDS)

.PHONY: $(OBJ_DIR)/acpica.a
$(OBJ_DIR)/acpica.a:
$(MAKE) -C acpica/ build
build: $(OBJ_DIR)/../drivers.a $(LDS) \
$(OBJ_DIR)/driver_list.txt

$(OBJ_DIR)/drivers.a: $(TARGETS) | $(BUILD_DIRS)
rm -f $@
$(AR) rcs $@ $(TARGETS)

$(OBJ_DIR)/driver_list.txt:
echo drivers > $@
Loading
Loading