Skip to content

Commit

Permalink
kconfig: Add kconfig
Browse files Browse the repository at this point in the history
Add kconfig, which allows us to configure the kernel in an easier
fashion.

Signed-off-by: Pedro Falcato <[email protected]>
  • Loading branch information
heatd committed Jul 30, 2024
1 parent 167acba commit a3466c7
Show file tree
Hide file tree
Showing 168 changed files with 23,340 additions and 245 deletions.
25 changes: 12 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ jobs:
# Runs a set of commands using the runners shell
- name: Build Onyx
run: |
cp kernel/configs/kernel.config.x86_64 kernel/kernel.config
export SYSROOT=$PWD/sysroot
export ONYX_ARCH=x86_64
./scripts/setup_build.sh
make -C kernel defconfig
RUN_CLANG_TIDY=0 make -j $(nproc) liveiso
./scripts/create_disk_image.sh disk-image.img --bootable efi
Expand Down Expand Up @@ -106,11 +106,11 @@ jobs:
# Runs a set of commands using the runners shell
- name: Build Onyx
run: |
cp kernel/configs/kernel.config.x86_64 kernel/kernel.config
export CLANG_PATH=$PWD/onyx-llvm
export SYSROOT=$PWD/sysroot
export ONYX_ARCH=x86_64
./scripts/setup_build.sh
make -C kernel defconfig
RUN_CLANG_TIDY=0 make -j $(nproc) liveiso
./scripts/create_disk_image.sh disk-image-llvm.img --bootable efi
Expand Down Expand Up @@ -164,10 +164,10 @@ jobs:
- name: Build Onyx
run: |
cp kernel/configs/kernel.config.riscv kernel/kernel.config
export SYSROOT=$PWD/sysroot
export ONYX_ARCH=riscv64
./scripts/setup_build.sh
make -C kernel defconfig
RUN_CLANG_TIDY=0 make -j $(nproc) fullbuild-plus-initrd
mkdir -p boot
cp kernel/vmonyx boot/
Expand Down Expand Up @@ -216,11 +216,10 @@ jobs:
# Runs a set of commands using the runners shell
- name: Build Onyx
run: |
cp kernel/configs/kernel.config.riscv kernel/kernel.config
export CLANG_PATH=$PWD/onyx-llvm
export SYSROOT=$PWD/sysroot
export ONYX_ARCH=riscv64
./scripts/setup_build.sh
make -C kernel defconfig
make -j $(nproc) fullbuild-plus-initrd
mkdir -p boot
cp kernel/vmonyx boot/
Expand Down Expand Up @@ -287,8 +286,8 @@ jobs:
- name: Build sysroot
run: |
export ONYX_ARCH=${{ matrix.target_arch }}
cp kernel/configs/kernel.config.x86_64 kernel/kernel.config
./scripts/setup_build.sh
make -C kernel defconfig
make install-headers -j $(nproc)
./scripts/build_libc_for_toolchain.sh
tar cvf minimal-sysroot-${{ matrix.target_arch }}.tar sysroot/
Expand Down Expand Up @@ -385,7 +384,6 @@ jobs:
(steps.toolchain-cache-llvm.outputs.cache-hit != 'true' && matrix.toolchain == 'llvm')
run: |
scripts/ci/install_github_ci_deps.sh
cp kernel/configs/kernel.config.x86_64 kernel/kernel.config
export PATH="$PATH:$PWD/gn_bin"
echo "$PWD/gn_bin" >> $GITHUB_PATH
Expand All @@ -400,6 +398,7 @@ jobs:
export SYSROOT=$PWD/sysroot
export ONYX_ARCH=${{ matrix.target_arch }}
./scripts/setup_build.sh
make -C kernel defconfig
mkdir -p toolchain_binaries-${{ matrix.toolchain }}
if ! ./toolchains/scripts/build_toolchain.sh toolchain_build toolchain_binaries-${{ matrix.toolchain }} \
-a ${{ matrix.target_arch }} --toolchain=${{ matrix.toolchain }}; then
Expand Down Expand Up @@ -453,10 +452,10 @@ jobs:
- name: Build Onyx
run: |
cp kernel/configs/kernel.config.arm64 kernel/kernel.config
export SYSROOT=$PWD/sysroot
export ONYX_ARCH=arm64
./scripts/setup_build.sh
make -C kernel defconfig
RUN_CLANG_TIDY=0 make -j $(nproc) fullbuild-plus-initrd
mkdir -p boot
cp kernel/vmonyx boot/
Expand Down Expand Up @@ -505,11 +504,11 @@ jobs:
# Runs a set of commands using the runners shell
- name: Build Onyx
run: |
cp kernel/configs/kernel.config.arm64 kernel/kernel.config
export CLANG_PATH=$PWD/onyx-llvm
export SYSROOT=$PWD/sysroot
export ONYX_ARCH=arm64
./scripts/setup_build.sh
make -C kernel defconfig
make -j $(nproc) fullbuild-plus-initrd
mkdir -p boot
cp kernel/vmonyx boot/
Expand Down Expand Up @@ -556,11 +555,11 @@ jobs:
# Runs a set of commands using the runners shell
- name: Build Onyx
run: |
cp kernel/configs/kernel.config.x86_64 kernel/kernel.config
export SYSROOT=$PWD/sysroot
export ONYX_ARCH=x86_64
cd kernel && ../scripts/ci/enable-debug-kernel.sh && cd ..
./scripts/setup_build.sh
make -C kernel defconfig
make -j $(nproc) liveiso
USE_KVM=0 ./scripts/ci/run-tests.py
Expand Down Expand Up @@ -600,12 +599,12 @@ jobs:
# Runs a set of commands using the runners shell
- name: Build Onyx
run: |
cp kernel/configs/kernel.config.x86_64 kernel/kernel.config
export CLANG_PATH=$PWD/onyx-llvm
export SYSROOT=$PWD/sysroot
export ONYX_ARCH=x86_64
cd kernel && ../scripts/ci/enable-debug-kernel.sh && cd ..
./scripts/setup_build.sh
make -C kernel defconfig
make -j $(nproc) liveiso
USE_KVM=0 ./scripts/ci/run-tests.py
Expand Down Expand Up @@ -643,11 +642,11 @@ jobs:
- name: Build Onyx
run: |
cp kernel/configs/kernel.config.riscv kernel/kernel.config
export SYSROOT=$PWD/sysroot
export ONYX_ARCH=riscv64
cd kernel && ../scripts/ci/enable-debug-kernel.sh && cd ..
./scripts/setup_build.sh
make -C kernel defconfig
make -j $(nproc) fullbuild-plus-full-initrd
USE_KVM=0 ./scripts/ci/run-tests.py
Expand Down Expand Up @@ -687,11 +686,11 @@ jobs:
# Runs a set of commands using the runners shell
- name: Build Onyx
run: |
cp kernel/configs/kernel.config.riscv kernel/kernel.config
export CLANG_PATH=$PWD/onyx-llvm
export SYSROOT=$PWD/sysroot
export ONYX_ARCH=riscv64
cd kernel && ../scripts/ci/enable-debug-kernel.sh && cd ..
./scripts/setup_build.sh
make -C kernel defconfig
make -j $(nproc) fullbuild-plus-full-initrd
USE_KVM=0 ./scripts/ci/run-tests.py
16 changes: 8 additions & 8 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ jobs:
# Runs a set of commands using the runners shell
- name: Build Onyx
run: |
cp kernel/configs/kernel.config.x86_64 kernel/kernel.config
export SYSROOT=$PWD/sysroot
export ONYX_ARCH=x86_64
./scripts/setup_build.sh
make -C kernel defconfig
RUN_CLANG_TIDY=0 make -j $(nproc) iso
./scripts/ci/build_ports.sh
./scripts/create_disk_image.sh disk-image.img --bootable efi
Expand Down Expand Up @@ -103,11 +103,11 @@ jobs:
# Runs a set of commands using the runners shell
- name: Build Onyx
run: |
cp kernel/configs/kernel.config.x86_64 kernel/kernel.config
export CLANG_PATH=$PWD/onyx-llvm
export SYSROOT=$PWD/sysroot
export ONYX_ARCH=x86_64
./scripts/setup_build.sh
make -C kernel defconfig
RUN_CLANG_TIDY=0 make -j $(nproc) iso
./scripts/ci/build_ports.sh llvm
./scripts/create_disk_image.sh disk-image-llvm.img --bootable efi
Expand Down Expand Up @@ -162,10 +162,10 @@ jobs:
- name: Build Onyx
run: |
cp kernel/configs/kernel.config.riscv kernel/kernel.config
export SYSROOT=$PWD/sysroot
export ONYX_ARCH=riscv64
./scripts/setup_build.sh
make -C kernel defconfig
RUN_CLANG_TIDY=0 make -j $(nproc) fullbuild-plus-initrd
mkdir -p boot
cp kernel/vmonyx boot/
Expand Down Expand Up @@ -214,11 +214,11 @@ jobs:
# Runs a set of commands using the runners shell
- name: Build Onyx
run: |
cp kernel/configs/kernel.config.riscv kernel/kernel.config
export CLANG_PATH=$PWD/onyx-llvm
export SYSROOT=$PWD/sysroot
export ONYX_ARCH=riscv64
./scripts/setup_build.sh
make -C kernel defconfig
make -j $(nproc) fullbuild-plus-initrd
mkdir -p boot
cp kernel/vmonyx boot/
Expand Down Expand Up @@ -284,8 +284,8 @@ jobs:
- name: Build sysroot
run: |
export ONYX_ARCH=${{ matrix.target_arch }}
cp kernel/configs/kernel.config.x86_64 kernel/kernel.config
./scripts/setup_build.sh
make -C kernel defconfig
make install-headers -j $(nproc)
./scripts/build_libc_for_toolchain.sh
tar cvf minimal-sysroot-${{ matrix.target_arch }}.tar sysroot/
Expand Down Expand Up @@ -382,7 +382,6 @@ jobs:
(steps.toolchain-cache-llvm.outputs.cache-hit != 'true' && matrix.toolchain == 'llvm')
run: |
scripts/ci/install_github_ci_deps.sh
cp kernel/configs/kernel.config.x86_64 kernel/kernel.config
export PATH="$PATH:$PWD/gn_bin"
echo "$PWD/gn_bin" >> $GITHUB_PATH
Expand All @@ -397,6 +396,7 @@ jobs:
export SYSROOT=$PWD/sysroot
export ONYX_ARCH=${{ matrix.target_arch }}
./scripts/setup_build.sh
make -C kernel defconfig
mkdir -p toolchain_binaries-${{ matrix.toolchain }}
if ! ./toolchains/scripts/build_toolchain.sh --use-lto toolchain_build toolchain_binaries-${{ matrix.toolchain }} \
-a ${{ matrix.target_arch }} --toolchain=${{ matrix.toolchain }}; then
Expand Down Expand Up @@ -449,10 +449,10 @@ jobs:
- name: Build Onyx
run: |
cp kernel/configs/kernel.config.arm64 kernel/kernel.config
export SYSROOT=$PWD/sysroot
export ONYX_ARCH=arm64
./scripts/setup_build.sh
make -C kernel defconfig
RUN_CLANG_TIDY=0 make -j $(nproc) fullbuild-plus-initrd
mkdir -p boot
cp kernel/vmonyx boot/
Expand Down Expand Up @@ -501,11 +501,11 @@ jobs:
# Runs a set of commands using the runners shell
- name: Build Onyx
run: |
cp kernel/configs/kernel.config.arm64 kernel/kernel.config
export CLANG_PATH=$PWD/onyx-llvm
export SYSROOT=$PWD/sysroot
export ONYX_ARCH=arm64
./scripts/setup_build.sh
make -C kernel defconfig
make -j $(nproc) fullbuild-plus-initrd
mkdir -p boot
cp kernel/vmonyx boot/
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ build-gn: musl libtest install-packages
build-usystem: build-srcpackages $(USYSTEM_PROJS) build-gn

build-cleanup: build-usystem
cp kernel/kernel.config sysroot/boot/
cp kernel/.config sysroot/boot/config

# TODO: Do this in kernel/Makefile
$(NM) kernel/vmonyx-unstripped > Kernel.map
Expand Down Expand Up @@ -170,12 +170,12 @@ qemu-efi: iso

qemu-serial-stdio: iso
qemu-system-$(shell scripts/target-triplet-to-arch.sh $(HOST)) \
-s -cdrom Onyx.iso -drive file=hdd.img,format=raw,media=disk -m 512M \
-s -cdrom Onyx.iso -drive file=hdd.img,format=raw,media=disk,aio=io_uring,cache=none,if=none,id=drive -m 4G \
-serial stdio -boot d -netdev user,id=u1 -device virtio-net,netdev=u1 \
-object filter-dump,id=f1,netdev=u1,file=net.pcap \
-enable-kvm -cpu host,migratable=on,+invtsc -smp 4 -vga qxl \
-device usb-ehci -device usb-mouse \
-display gtk,gl=on -machine q35
-display gtk,gl=on -machine q35 -device nvme,drive=drive,serial=deadbeef

ci-test-qemu: liveiso
qemu-system-$(shell scripts/target-triplet-to-arch.sh $(HOST)) \
Expand Down
5 changes: 3 additions & 2 deletions doc/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ in the project root).
## Step 3: Prepare build environment

1. `export ONYX_ARCH=x86_64`
2. Install appropriate kernel config under `kernel/kernel.config`. There are pre-existing examples in
`kernel/configs`, these are fine choices.
2. Run `make -C kernel defconfig` or obtain a .config through other means. The `menuconfig`
target can be used to change a config graphically, and you can also use `oldconfig` to update
an older config file.

## Step 4: Build or obtain the toolchains

Expand Down
3 changes: 2 additions & 1 deletion kernel/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ vmonyx*
*.d
kernel/syscall_thunk.cpp
include/onyx/gen/*

.config
.config.old
7 changes: 7 additions & 0 deletions kernel/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mainmenu "Onyx $(ONYX_ARCH) kernel configuration"

source "arch/$(ONYX_ARCH)/Kconfig"

source "drivers/Kconfig"
source "kernel/Kconfig"
source "lib/Kconfig"
21 changes: 18 additions & 3 deletions kernel/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export ONYX_ARCH:=$(shell ../scripts/onyx_arch.sh)
HOSTARCH:=$(ONYX_ARCH)

include kernel.config
-include .config

ifeq ($(CONFIG_CC_OPTIMIZE_SIZE), y)
CFLAGS?=-Os -g
Expand Down Expand Up @@ -70,8 +71,8 @@ ARCHDIR:=arch/$(HOSTARCH)

GENERATED_HEADERS:=include/onyx/config.h include/onyx/gen/syscall.h

include/onyx/config.h: ../scripts/config_to_header.py kernel.config
../scripts/config_to_header.py include/onyx/config.h
include/onyx/config.h: .config
grep -v "#" .config | sed -E -e 's/=/ /' -e 's/^[^\n]/#define C/' > include/onyx/config.h

include $(ARCHDIR)/make.config

Expand Down Expand Up @@ -418,3 +419,17 @@ endif
mkdir -p $(DESTDIR)/usr/share/man
mkdir -p $(DESTDIR)/usr/share/man/man9
cp onyx.9 $(DESTDIR)/usr/share/man/man9

help:
@$(MAKE) -C scripts/kconfig help obj=$(shell pwd)/scripts/kconfig src=$(shell pwd)/scripts/kconfig

kconfig_targets:= config nconfig menuconfig xconfig gconfig defconfig oldconfig
.PHONY: $(kconfig_targets)

$(kconfig_targets):
@$(MAKE) -C scripts/kconfig $@ obj=$(shell pwd)/scripts/kconfig src=$(shell pwd)/scripts/kconfig

%_defconfig:
@$(MAKE) -C scripts/kconfig $@ obj=$(shell pwd)/scripts/kconfig src=$(shell pwd)/scripts/kconfig

all: vmonyx
3 changes: 3 additions & 0 deletions kernel/arch/arm64/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
config ARM64
def_bool y
select DEVICE_TREE
2 changes: 1 addition & 1 deletion kernel/arch/arm64/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ arm64-y:= image.o fpu.o copy_user.o stubs.o vdso_helper.o mmu.o early_mmu.o virt

obj-y+= $(patsubst %, arch/arm64/%, $(arm64-y))

arch/arm64/vdso_helper.o: arch/arm64/vdso_helper.S onyx-vdso.so.0 kernel.config
arch/arm64/vdso_helper.o: arch/arm64/vdso_helper.S onyx-vdso.so.0 .config
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
Loading

0 comments on commit a3466c7

Please sign in to comment.