summaryrefslogtreecommitdiff
path: root/Meta
diff options
context:
space:
mode:
authorGunnar Beutner <gbeutner@serenityos.org>2021-07-18 14:47:32 +0200
committerAndreas Kling <kling@serenityos.org>2021-07-18 17:31:13 +0200
commit7e94b090fed491f3ca9c0957e7ed2af8ed2e8468 (patch)
tree1ca195269e74ef7fa879229db362a47290d67eba /Meta
parent357ddd393ebd38321f8bc02274942fcad29a1ac9 (diff)
downloadserenity-7e94b090fed491f3ca9c0957e7ed2af8ed2e8468.zip
Kernel: Introduce basic pre-kernel environment
This implements a simple bootloader that is capable of loading ELF64 kernel images. It does this by using QEMU/GRUB to load the kernel image from disk and pass it to our bootloader as a Multiboot module. The bootloader then parses the ELF image and sets it up appropriately. The kernel's entry point is a C++ function with architecture-native code. Co-authored-by: Liav A <liavalb@gmail.com>
Diffstat (limited to 'Meta')
-rwxr-xr-xMeta/debug-kernel.sh4
-rw-r--r--Meta/grub-ebr.cfg14
-rw-r--r--Meta/grub-gpt.cfg14
-rw-r--r--Meta/grub-mbr.cfg12
-rwxr-xr-xMeta/run.sh28
5 files changed, 50 insertions, 22 deletions
diff --git a/Meta/debug-kernel.sh b/Meta/debug-kernel.sh
index 15c255c356..c33c3da4a0 100755
--- a/Meta/debug-kernel.sh
+++ b/Meta/debug-kernel.sh
@@ -10,14 +10,12 @@
#
if [ "$SERENITY_ARCH" = "x86_64" ]; then
gdb_arch=i386:x86-64
- kernel_binary=Kernel64
else
gdb_arch=i386:intel
- kernel_binary=Kernel
fi
exec $SERENITY_KERNEL_DEBUGGER \
- -ex "file $(dirname "$0")/../Build/${SERENITY_ARCH:-i686}/Kernel/$kernel_binary" \
+ -ex "file $(dirname "$0")/../Build/${SERENITY_ARCH:-i686}/Kernel/Kernel" \
-ex "set arch $gdb_arch" \
-ex 'target remote localhost:1234' \
-ex "source $(dirname "$0")/serenity_gdb.py" \
diff --git a/Meta/grub-ebr.cfg b/Meta/grub-ebr.cfg
index 4c1a49174f..d0b555ad0b 100644
--- a/Meta/grub-ebr.cfg
+++ b/Meta/grub-ebr.cfg
@@ -2,21 +2,25 @@ timeout=1
menuentry 'SerenityOS (normal)' {
root=hd0,5
- multiboot /boot/Kernel root=/dev/hda4
+ multiboot /boot/Bootloader root=/dev/hda4
+ module /boot/Kernel
}
menuentry 'SerenityOS (text mode)' {
root=hd0,5
- multiboot /boot/Kernel boot_mode=no-fbdev root=/dev/hda4
+ multiboot /boot/Bootloader boot_mode=no-fbdev root=/dev/hda4
+ module /boot/Kernel
}
menuentry 'SerenityOS (No ACPI)' {
root=hd0,5
- multiboot /boot/Kernel root=/dev/hda4 acpi=off
+ multiboot /boot/Bootloader root=/dev/hda4 acpi=off
+ module /boot/Kernel
}
menuentry 'SerenityOS (with serial debug)' {
- root=hd0,5
- multiboot /boot/Kernel serial_debug root=/dev/hda4
+ root=hd0,5
+ multiboot /boot/Bootloader serial_debug root=/dev/hda4
+ module /boot/Kernel
}
diff --git a/Meta/grub-gpt.cfg b/Meta/grub-gpt.cfg
index 5314518a69..72f16b805c 100644
--- a/Meta/grub-gpt.cfg
+++ b/Meta/grub-gpt.cfg
@@ -2,20 +2,24 @@ timeout=1
menuentry 'SerenityOS (normal)' {
root=hd0,2
- multiboot /boot/Kernel root=/dev/hda2
+ multiboot /boot/Bootloader root=/dev/hda2
+ module /boot/Kernel
}
menuentry 'SerenityOS (text mode)' {
root=hd0,2
- multiboot /boot/Kernel boot_mode=no-fbdev root=/dev/hda2
+ multiboot /boot/Bootloader boot_mode=no-fbdev root=/dev/hda2
+ module /boot/Kernel
}
menuentry 'SerenityOS (No ACPI)' {
root=hd0,2
- multiboot /boot/Kernel root=/dev/hda2 acpi=off
+ multiboot /boot/Bootloader root=/dev/hda2 acpi=off
+ module /boot/Kernel
}
menuentry 'SerenityOS (with serial debug)' {
- root=hd0,2
- multiboot /boot/Kernel serial_debug root=/dev/hda2
+ root=hd0,2
+ multiboot /boot/Bootloader serial_debug root=/dev/hda2
+ module /boot/Kernel
}
diff --git a/Meta/grub-mbr.cfg b/Meta/grub-mbr.cfg
index 150bce4f49..34e727430b 100644
--- a/Meta/grub-mbr.cfg
+++ b/Meta/grub-mbr.cfg
@@ -2,20 +2,24 @@ timeout=1
menuentry 'SerenityOS (normal)' {
root=hd0,1
- multiboot /boot/Kernel root=/dev/hda1
+ multiboot /boot/Bootloader root=/dev/hda1
+ module /boot/Kernel
}
menuentry 'SerenityOS (text mode)' {
root=hd0,1
- multiboot /boot/Kernel boot_mode=no-fbdev root=/dev/hda1
+ multiboot /boot/Bootloader boot_mode=no-fbdev root=/dev/hda1
+ module /boot/Kernel
}
menuentry 'SerenityOS (No ACPI)' {
root=hd0,1
- multiboot /boot/Kernel root=/dev/hda1 acpi=off
+ multiboot /boot/Bootloader root=/dev/hda1 acpi=off
+ module /boot/Kernel
}
menuentry 'SerenityOS (with serial debug)' {
root=hd0,1
- multiboot /boot/Kernel serial_debug root=/dev/hda1
+ multiboot /boot/Bootloader serial_debug root=/dev/hda1
+ module /boot/Kernel
}
diff --git a/Meta/run.sh b/Meta/run.sh
index 48398a25f0..1da7bc6020 100755
--- a/Meta/run.sh
+++ b/Meta/run.sh
@@ -204,7 +204,8 @@ elif [ "$SERENITY_RUN" = "qn" ]; then
"$SERENITY_QEMU_BIN" \
$SERENITY_COMMON_QEMU_ARGS \
-device e1000 \
- -kernel Kernel/Kernel \
+ -kernel Kernel/Prekernel/Prekernel \
+ -initrd Kernel/Kernel \
-append "${SERENITY_KERNEL_CMDLINE}"
elif [ "$SERENITY_RUN" = "qtap" ]; then
# Meta/run.sh qtap: qemu with tap
@@ -216,7 +217,8 @@ elif [ "$SERENITY_RUN" = "qtap" ]; then
$SERENITY_PACKET_LOGGING_ARG \
-netdev tap,ifname=tap0,id=br0 \
-device e1000,netdev=br0 \
- -kernel Kernel/Kernel \
+ -kernel Kernel/Prekernel/Prekernel \
+ -initrd Kernel/Kernel \
-append "${SERENITY_KERNEL_CMDLINE}"
sudo ip tuntap del dev tap0 mode tap
elif [ "$SERENITY_RUN" = "qgrub" ]; then
@@ -235,8 +237,22 @@ elif [ "$SERENITY_RUN" = "q35" ]; then
$SERENITY_VIRT_TECH_ARG \
-netdev user,id=breh,hostfwd=tcp:127.0.0.1:8888-10.0.2.15:8888,hostfwd=tcp:127.0.0.1:8823-10.0.2.15:23 \
-device e1000,netdev=breh \
- -kernel Kernel/Kernel \
+ -kernel Kernel/Prekernel/Prekernel \
+ -initrd Kernel/Kernel \
-append "${SERENITY_KERNEL_CMDLINE}"
+elif [ "$SERENITY_RUN" = "bootloader_test" ]; then
+ # Meta/run.sh q35: qemu (q35 chipset) with SerenityOS
+ echo "Starting SerenityOS with QEMU Q35 machine, Commandline: ${SERENITY_KERNEL_CMDLINE}"
+ "$SERENITY_QEMU_BIN" \
+ $SERENITY_COMMON_QEMU_Q35_ARGS \
+ $SERENITY_VIRT_TECH_ARG \
+ -netdev user,id=breh,hostfwd=tcp:127.0.0.1:8888-10.0.2.15:8888,hostfwd=tcp:127.0.0.1:8823-10.0.2.15:23 \
+ -device e1000,netdev=breh \
+ -kernel Kernel/Prekernel/Prekernel \
+ -initrd Kernel/Kernel \
+ -append "${SERENITY_KERNEL_CMDLINE}" \
+ -no-reboot \
+ -no-shutdown
elif [ "$SERENITY_RUN" = "ci" ]; then
# Meta/run.sh ci: qemu in text mode
echo "Running QEMU in CI"
@@ -252,7 +268,8 @@ elif [ "$SERENITY_RUN" = "ci" ]; then
-nographic \
-display none \
-debugcon file:debug.log \
- -kernel Kernel/Kernel \
+ -kernel Kernel/Prekernel/Prekernel \
+ -initrd Kernel/Kernel \
-append "${SERENITY_KERNEL_CMDLINE}"
else
# Meta/run.sh: qemu with user networking
@@ -262,6 +279,7 @@ else
$SERENITY_PACKET_LOGGING_ARG \
-netdev user,id=breh,hostfwd=tcp:127.0.0.1:8888-10.0.2.15:8888,hostfwd=tcp:127.0.0.1:8823-10.0.2.15:23,hostfwd=tcp:127.0.0.1:8000-10.0.2.15:8000,hostfwd=tcp:127.0.0.1:2222-10.0.2.15:22 \
-device e1000,netdev=breh \
- -kernel Kernel/Kernel \
+ -kernel Kernel/Prekernel/Prekernel \
+ -initrd Kernel/Kernel \
-append "${SERENITY_KERNEL_CMDLINE}"
fi