Add qemu UEFI firmware support.
This commit is contained in:
@@ -10,7 +10,7 @@ git clone https://git.zxq5.dev/OsDev/FoundryOS.git
|
||||
* latest rust nightly release
|
||||
* all necessary rust components installed
|
||||
* xorriso: creates ISO images to be booted from.
|
||||
* (Optional / Recommended) Qemu: to run the kernel. (this may be packaged as qemu-desktop)
|
||||
* (Optional / Recommended) qemu: to run the kernel. (this may be packaged as qemu-desktop)
|
||||
* (Optional) GDB: for debugging the kernel.
|
||||
|
||||
```sh
|
||||
@@ -20,12 +20,29 @@ rustup component add rust-src
|
||||
rustup component add llvm-tools-preview
|
||||
```
|
||||
|
||||
## Building & Running in Qemu:
|
||||
## Building & Running in qemu
|
||||
```sh
|
||||
cargo run
|
||||
```
|
||||
|
||||
## Running in GDB:
|
||||
## Running in GDB
|
||||
```sh
|
||||
USE_GDB=1 cargo run
|
||||
```
|
||||
|
||||
## Build errors
|
||||
|
||||
If you see a qemu error like this:
|
||||
|
||||
```
|
||||
qemu-system-x86_64: -drive if=pflash,format=raw,readonly=on,file=/home/jacob/Desktop/Code/FoundryOS/build/OVMF_CODE.fd: Could not open '/home/jacob/Desktop/Code/FoundryOS/build/OVMF_CODE.fd': No such file or directory
|
||||
```
|
||||
|
||||
Simply delete the ./build directory and try to rebuild the program. Using the runner script or `cargo run` will download the required files for you, this is because the script only checks for the presence of one file and not the VARS file.
|
||||
|
||||
Alternatively, you may disable using a UEFI firmware with qemu like so:
|
||||
```sh
|
||||
USE_LEGACY_BIOS=1 cargo run
|
||||
```
|
||||
|
||||
If you have any other issues, feel free to create an issue or a PR.
|
||||
@@ -135,6 +135,23 @@ else
|
||||
debug_flags=""
|
||||
fi
|
||||
|
||||
if [ $USE_LEGACY_BIOS ]; then
|
||||
boot_flags=""
|
||||
else
|
||||
# Check for the presence of the OVMF firmware.
|
||||
if [ ! -f $build_dir/RELEASEX64_OVMF_CODE.fd ]; then
|
||||
info "Downloading OVMF UEFI firmware for QEMU"
|
||||
info "To disable this, set USE_LEGACY_BIOS=1."
|
||||
pushd $build_dir
|
||||
curl https://retrage.github.io/edk2-nightly/bin/RELEASEX64_OVMF_CODE.fd -LO || error "failed to download OVMF firmware for UEFI"
|
||||
curl https://retrage.github.io/edk2-nightly/bin/RELEASEX64_OVMF_VARS.fd -LO || error "failed to download OVMF firmware for UEFI"
|
||||
popd
|
||||
fi
|
||||
|
||||
boot_flags="-drive if=pflash,format=raw,readonly=on,file=$build_dir/RELEASEX64_OVMF_CODE.fd \
|
||||
-drive if=pflash,format=raw,file=$build_dir/RELEASEX64_OVMF_VARS.fd"
|
||||
fi
|
||||
|
||||
# Set up test-specific flags
|
||||
if [ $is_test -eq 1 ]; then
|
||||
test_flags="-device isa-debug-exit,iobase=0xf4,iosize=0x04 -display none"
|
||||
@@ -189,5 +206,6 @@ qemu-system-x86_64 -M q35 \
|
||||
-no-reboot \
|
||||
${test_flags} \
|
||||
${debug_flags} \
|
||||
${boot_flags} \
|
||||
${QEMU_FLAGS:-}
|
||||
|
||||
|
||||
@@ -131,6 +131,23 @@ fi
|
||||
# I'm lazy but I just remove GDB flags when running this script.
|
||||
debug_flags=""
|
||||
|
||||
if [ $USE_LEGACY_BIOS ]; then
|
||||
boot_flags=""
|
||||
else
|
||||
# Check for the presence of the OVMF firmware.
|
||||
if [ ! -f $build_dir/RELEASEX64_OVMF_CODE.fd ]; then
|
||||
info "Downloading OVMF UEFI firmware for QEMU"
|
||||
info "To disable this, set USE_LEGACY_BIOS=1."
|
||||
pushd $build_dir
|
||||
curl https://retrage.github.io/edk2-nightly/bin/RELEASEX64_OVMF_CODE.fd -LO || error "failed to download OVMF firmware for UEFI"
|
||||
curl https://retrage.github.io/edk2-nightly/bin/RELEASEX64_OVMF_VARS.fd -LO || error "failed to download OVMF firmware for UEFI"
|
||||
popd
|
||||
fi
|
||||
|
||||
boot_flags="-drive if=pflash,format=raw,readonly=on,file=$build_dir/RELEASEX64_OVMF_CODE.fd \
|
||||
-drive if=pflash,format=raw,file=$build_dir/RELEASEX64_OVMF_VARS.fd"
|
||||
fi
|
||||
|
||||
# Set up test-specific flags
|
||||
if [ $is_test -eq 1 ]; then
|
||||
test_flags="-device isa-debug-exit,iobase=0xf4,iosize=0x04 -display none"
|
||||
|
||||
Reference in New Issue
Block a user