Skip to content

Commit fad3252

Browse files
committed
Major Structural Rewrite
Added - ipxe iso image - Kconfig files - Modular Makefile system - Qemu-specific shutdown driver - Shutdown function in HAL Changed - Rewrote Multiboot code - Modified Code Struture - Changed build system entirely
1 parent 8c13d28 commit fad3252

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+740
-311
lines changed

.config

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#
2+
# Automatically generated file; DO NOT EDIT.
3+
# Apollo Kernel Configuration
4+
#
5+
CONFIG_ARCH=y
6+
7+
#
8+
# Architectures
9+
#
10+
CONFIG_TARGET="x86"
11+
CONFIG_X86_BASE=y
12+
13+
#
14+
# Drivers
15+
#
16+
17+
#
18+
# Timekeeping
19+
#
20+
CONFIG_CLOCK_RTC_CMOS=y
21+
CONFIG_CLOCK_8254=y
22+
23+
#
24+
# Base System Drivers
25+
#
26+
# CONFIG_QEMU_SHUTDOWN is not set
27+
CONFIG_CONSOLE=y
28+
29+
#
30+
# Console Drivers
31+
#
32+
CONFIG_CONSOLE_VGA=y
33+
34+
#
35+
# Serial Console Drivers
36+
#
37+
CONFIG_TTY_SERIAL_16550_UART=y
38+
39+
#
40+
# IRQ Chips
41+
#
42+
CONFIG_IRQCHIP_8259=y
43+
CONFIG_LIBC=y
44+
45+
#
46+
# Standard Library Functions
47+
#
48+
CONFIG_LIBC_MATH=y
49+
CONFIG_LIBC_STDIO=y
50+
CONFIG_LIBC_STRING=y
51+
# CONFIG_TESTING is not set

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Gitignore file
1+
# User Setting files
2+
.vscode*/
23

34
# Prereq files
45
*.d

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
44
and this project adheres to
55
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.0.3] - 2022-04-40
8+
### Added
9+
- ipxe iso image
10+
- Kconfig files
11+
- Modular Makefile system
12+
- Qemu-specific shutdown driver
13+
- Shutdown function in HAL
14+
### Changed
15+
- Rewrote Multiboot code
16+
- Modified Code Struture
17+
- Changed build system entirely
18+
719
## [0.0.2] - 2018-12-12
820
### Added
921
- MIT License tag for README.md

Kconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
mainmenu "Apollo Kernel Configuration"
2+
3+
source "src/arch/Kconfig"
4+
5+
source "src/drivers/Kconfig"
6+
7+
source "src/libc/Kconfig"
8+
9+
source "src/test/Kconfig"

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2019 Apollo Developers <Allison Sargente et al.>
3+
Copyright (c) 2022 Apollo Developers <Allison Sargente et al.>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Makefile

+26-47
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@
33
#############################
44
.PHONY: all clean link
55

6-
7-
86
# Git revision number
97
GIT_REV != git rev-parse --short HEAD 2> /dev/null
108
BUILD := build
11-
TARGETS != find . -maxdepth 1 -type f -name '*.mk'
12-
TARGETS != echo $(TARGETS) | sed -e 's/.mk//' -e 's/.\/target-//'
139

1410
# Documentation
1511
MDSOURCES != find docs -type f -name '*.md'
@@ -20,75 +16,55 @@ MDFLAGS := --from gfm --to html --standalone \
2016
HTMLDOCS := $(patsubst docs/%.md,$(HTMLDIR)/%.html,$(MDSOURCES))
2117
HTMLDIRS := $(shell cd docs && find -type d | tr '\n' ' ')
2218

23-
24-
# Platform Agnostic Source Code
25-
CSOURCES_TI != find src/core src/libc src/adt -type f -name '*.c'
26-
27-
# Third Party Source Code
28-
CSOURCES_TP != find src/third_party -type f -name '*.c'
29-
30-
CSOURCES_TI := $(CSOURCES_TI) $(CSOURCES_TP)
31-
32-
# Test Source Code
33-
TESTSOURCES != find src/test/core src/test/libc src/test/adt -type f -name '*.c'
34-
3519
INCLUDEDIR != find src -type d -name "include" -printf "-I%p "
3620

37-
all:
38-
39-
ifndef TARGET
40-
# Not a fatal error if clean or doc
41-
ifeq($(MAKECMDGOALS),clean)
42-
else ifeq ($(MAKECMDGOALS),doc)
43-
else
44-
$(error TARGET is not set, availible targets: $(TARGETS))
45-
endif
46-
47-
TARGETL != echo $(TARGET) | tr '[:upper:]' '[:lower:]'
48-
49-
ifdef TARGET
50-
BUILD := build-$(TARGETL)
51-
-include target-$(TARGETL).mk
52-
endif
53-
54-
COBJECTS := $(patsubst %.c,$(BUILD)/%.c.o,$(CSOURCES))
55-
SOBJECTS := $(patsubst %.s,$(BUILD)/%.s.o,$(SSOURCES))
56-
TESTOBJECTS := $(patsubst %.c,$(BUILD)/%.c.o,$(TESTSOURCES))
57-
SRCDIR != find src/ -type d | tr '\n' ' '
21+
include .config
22+
TARGETL != echo $(CONFIG_TARGET) | tr '[:upper:]' '[:lower:]'
23+
BUILD := build-$(TARGETL)
24+
include $(shell pwd)/scripts/target-$(TARGETL).mk
5825

5926
WARNINGS := -Wall -Wextra -Wno-unused-parameter
6027
DEFS := $(INCLUDEDIR) -fbuiltin -DGITREV="\"$(GIT_REV)\""
6128

29+
HELPER_MK := $(shell pwd)/scripts/helper.mk
30+
MK_FLAGS := --no-print-directory -s
31+
SUBDIRS := $(shell find . -name Makefile)
32+
SUBDIRS := $(patsubst %Makefile,%,$(SUBDIRS))
33+
SUBDIRS := $(patsubst %./,%,$(SUBDIRS))
34+
OBJECTS := $(shell for dir in $(SUBDIRS); do\
35+
TOP_DIR=`pwd` $(MAKE) $(MK_FLAGS) -f $(HELPER_MK) -C $$dir;\
36+
done;)
37+
38+
ifeq ($(CONFIG_TESTING),y)
39+
DEFS += -DTEST_HARNESS=1
40+
BIN := test-$(BIN)
41+
endif
6242

43+
OBJECTS := $(patsubst %.o,$(BUILD)/%.o,$(OBJECTS))
44+
SRCDIR != find src/ -type d | tr '\n' ' '
6345

64-
all: test link doc
46+
all: link doc
6547

6648
# C files are compiled universally the same, assembler targets are defined in
6749
# The target specific makefiles
6850
$(BUILD)/%.c.o: %.c Makefile | setup_builddir
6951
@printf "\033[1mCC\033[0m $<\n"
7052
@$(CC) -c $< -o $@ $(DEFS) $(TARGET_DEFS) $(WARNINGS)
7153

72-
link: $(SOBJECTS) $(COBJECTS)
54+
link: $(OBJECTS)
7355
@printf "\033[1mLINK\033[0m $@\n"
7456
@$(CC) $(DEFS) $(WARNINGS) $(LDFLAGS) $(TARGET_LDFLAGS) \
75-
-o bin/$(BIN) $(SOBJECTS) $(COBJECTS)
57+
-o bin/$(BIN) $(OBJECTS)
7658

7759
setup_builddir:
7860
@mkdir -p $(BUILD)
7961
@cd $(BUILD) && mkdir -p `echo $(SRCDIR)`
8062

8163
clean:
8264
@printf "\033[1mCLEAN\033[0m \n"
83-
@find $(BUILD) -type f -name '*.o' -exec rm {} +
65+
@find . -type d -name "build*" -exec rm -rf {} +
8466
@find $(HTMLDIR) -type f -exec rm {} +
8567

86-
test: DEFS += -DTEST_HARNESS=1
87-
test: $(SOBJECTS) $(COBJECTS) $(TESTOBJECTS)
88-
@printf "\033[1mLINK TEST\033[0m $0\n"
89-
@$(CC) $(DEFS) $(WARNINGS) $(LDFLAGS) $(TARGET_LDFLAGS) \
90-
-o bin/test-$(BIN) $(SOBJECTS) $(COBJECTS) $(TESTOBJECTS)
91-
9268
doc_setup:
9369
@mkdir -p $(HTMLDIR)
9470
@cd $(HTMLDIR) && mkdir -p $(HTMLDIRS)
@@ -98,3 +74,6 @@ doc: doc_setup | $(HTMLDOCS)
9874
html/%.html: docs/%.md
9975
@printf "\033[1mHTML\033[0m $<\n"
10076
@$(MARKDOWN) $(MDFLAGS) $< --output $@
77+
78+
menuconfig:
79+
@kconfig-mconf Kconfig

README.md

+26-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
### The Apollo Project
2-
_(C) 2013 - 2021 Primis Computers (Allie Sargente et al)_
2+
_(C) 2013 - 2022 Primis Computers (Allie Sargente et al)_
33
![](https://img.shields.io/apm/l/vim-mode.svg)
44

55
Requirements:
66
=================================================
77
This is a kernel project for x86 Hardware. Current compilation needs:
88
* GNU Make (Or Compatible)
99
* NASM, The Netwide Assembler
10-
* GCC
10+
* GCC (cross compiler heavily suggested, such as i586-elf-gcc)
11+
12+
Optionally, for customizing builds, any application capable of reading Kconfig
13+
files will work. If on debian based systems, the package `kconfig-frontends` is suggested.
1114

1215
The kernel is written in X86-Assembly and ANSI-C. We are currently working
1316
on making it as portable as possible.
@@ -27,12 +30,30 @@ The API is in a state of flux. If developing applications, stick to
2730
functions from the standard c library. All others may be depreciated /
2831
removed without notice.
2932

33+
Running
34+
=================================================
35+
The best way to run latest is to use the ipxe images.
36+
These should work on any VM/PC with a network card and
37+
will load the latest kernel from kernel.primis.org
38+
You can also load x86-sys.mod from any multiboot
39+
compatible bootloader such as GRUB.
40+
41+
Building
42+
=================================================
43+
Once all the pre-requisites software has been aquired,
44+
you can build a kernel simply by typing `make`. The make
45+
file defaults to x86 with most of the features set.
46+
To customize features you can either directly edit the
47+
`.config` file in the root directory of the project, or
48+
you can run `make menuconfig` if you have `kconfig-frontends`
49+
or it's equivilent package installed on your distro.
50+
3051
History:
3152
=================================================
3253
This kernel descends from several failed kernel projects;
33-
* ScorchOS; by Bob Moss and Nicholas Sargente. Circa 2010
34-
* Mercury/SaturnOS; by Brandon Cornell and Nicholas Sargente. Circa 2012
35-
* Apollo Kernel Project; Circa 2009-2011. Nicholas Sargente.
54+
* ScorchOS; by Bob Moss and Allie Sargente. Circa 2010
55+
* Mercury/SaturnOS; by Brandon Cornell and Allie Sargente. Circa 2012
56+
* Apollo Kernel Project; Circa 2009-2011. Allie Sargente.
3657

3758
This kernel takes base code from Bkerndev and James Molloy's Tutorials:
3859
* http://www.osdever.net/bkerndev/Docs/title.htm

bin/hosted-sys.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:91f0719f1cd7ce36f5017fc7e76d96176a8ecf83a22664383d8166d1cf94b2d3
3-
size 47416
2+
oid sha256:ce65efe55cad543fd615919645c1e00f1bceffec9d3b6e3eab7e0016c29fbc02
3+
size 34704

bin/ipxe.iso

854 KB
Binary file not shown.

bin/test-hosted-sys.mod

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:926a41938b9d4a859f2401d967e503b192f5d6152f640cc708b10f462619cb0e
3+
size 56440

bin/test-x86-sys.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:881d8057cbecdaf83834a4fb16bf4daf8937dc38c52f5415812bac6780a7a78c
3-
size 78272
2+
oid sha256:3344766812619e1b21fe06877e6e8c87755c6f14f0511f8d682e7e0125486802
3+
size 73548

bin/x86-sys.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:c8560c0fe662f184e717ba162d1a2194fc041c1fd84ae8e276f239a894b15d4a
3-
size 68196
2+
oid sha256:f97156d6ab230840fd73cc35a168b3cf46d9e47920bf3da71580b459ee66e7d3
3+
size 56512

scripts/helper.mk

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
include $(TOP_DIR)/.config
2+
include Makefile
3+
4+
CUR_DIR := $(shell pwd)
5+
CUR_DIR := $(patsubst $(TOP_DIR)/%,./%, $(CUR_DIR))
6+
7+
ifeq ($(CONFIG_TESTING),y)
8+
obj_y += $(test_y)
9+
endif
10+
11+
obj_y := $(patsubst %.c,$(CUR_DIR)/%.c.o,$(obj_y))
12+
obj_y := $(patsubst %.s,$(CUR_DIR)/%.s.o,$(obj_y))
13+
14+
all:
15+
@echo $(obj_y)

target-hosted.mk scripts/target-hosted.mk

-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22

33
BIN := hosted-sys.mod
44
TARGET_DEFS := -DHOSTED=1
5-
CSOURCES := $(shell find src/arch/hosted -type f -name "*.c") $(CSOURCES_TI)
65

76
# That's it!

target-x86.mk scripts/target-x86.mk

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Makefile for Apollo Project
22
# Target is x86
3-
# Copyright 2018 Apollo Developers
3+
# Copyright 2022 Apollo Developers
44

55

66
# Check for different Cross compilers in reverse order
@@ -18,16 +18,11 @@ TARGET_LDFLAGS := -m32 -Tsrc/arch/x86/x86-link.ld -nostdlib -n
1818
$(warning Using default GCC, please consider installing a cross compiler!)
1919
endif
2020

21-
22-
2321
BIN := x86-sys.mod
2422
AS := nasm
2523
ASFLAGS := -felf -dGITREV="'$(GIT_REV)'"
2624
TARGET_DEFS := -DX86=1 -m32 -masm=intel -ffreestanding -nostdlib
2725
TARGET_LDFLAGS ?= -m32 -Tsrc/arch/x86/x86-link.ld -nostdlib -lgcc -n
28-
CSOURCES := $(shell find src/arch/x86 -type f -name "*.c") $(CSOURCES_TI)
29-
SSOURCES := $(shell find src/arch/x86 -type f -name "*.s") $(SSOURCES_TI)
30-
TESTSOURCES += $(shell find src/test/arch/x86 -type f -name "*.c")
3126

3227
$(BUILD)/%.s.o: %.s | setup_builddir
3328
@printf "\033[1mAS\033[0m $<\n"

src/adt/Makefile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
##############################
2+
# Apollo Project #
3+
# ADT Code Makefile #
4+
# (c) 2022 Apollo Developers #
5+
##############################
6+
7+
obj_y := buddy.c bitmap.c ringbuf.c

src/adt/testing/Makefile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
##############################
2+
# Apollo Project #
3+
# ADT Test Makefile #
4+
# (c) 2022 Apollo Developers #
5+
##############################
6+
7+
test_y := test_ringbuf.c

src/test/adt/test_ringbuf.c src/adt/testing/test_ringbuf.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,4 @@ TEST(ringbuf_test, readWriteTest)
2626
char_ringbuf_write(&test_buf, "Hello", 6);
2727
char_ringbuf_read(&test_buf, buff2, 6);
2828
TEST_ASSERT_EQUAL_STRING("Hello", buff2);
29-
}
30-
29+
}

0 commit comments

Comments
 (0)