mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 09:17:35 +00:00
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>
This commit is contained in:
parent
357ddd393e
commit
7e94b090fe
30 changed files with 1207 additions and 181 deletions
|
@ -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" \
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
28
Meta/run.sh
28
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue