-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Move default target and rustflags to `.cargo/config.toml` - Remove use of mtools/parted and use target directory as a drive - Remove `startup.nsh` script and document how to load the driver in QEMU - Remove `deps.sh` now that Make and Rust are the only dependencies - Replace use of `emit` with specifying the normal binary path Signed-off-by: Tim Crawford <[email protected]>
- Loading branch information
Showing
7 changed files
with
53 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,13 @@ | ||
[registries.crates-io] | ||
protocol = "sparse" | ||
[build] | ||
target = "x86_64-unknown-uefi" | ||
|
||
[target.x86_64-unknown-uefi] | ||
rustflags = [ | ||
"-Clink-arg=/heap:0,0", | ||
"-Clink-arg=/stack:0,0", | ||
"-Clink-arg=/dll", | ||
"-Clink-arg=/base:0", | ||
"-Clink-arg=/align:32", | ||
"-Clink-arg=/filealign:32", | ||
"-Clink-arg=/subsystem:efi_boot_service_driver" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,26 @@ | ||
# SPDX-License-Identifier: GPL-3.0-only | ||
|
||
TARGET = x86_64-unknown-uefi | ||
BUILD = build/$(TARGET) | ||
QEMU = qemu-system-x86_64 | ||
OVMF = /usr/share/OVMF | ||
|
||
all: $(BUILD)/boot.efi | ||
.PHONY: build | ||
build: | ||
cargo build --release | ||
|
||
.PHONY: clean | ||
clean: | ||
cargo clean | ||
rm -rf build | ||
|
||
update: | ||
git submodule update --init --recursive --remote | ||
cargo update | ||
|
||
$(BUILD)/OVMF_VARS.fd: /usr/share/OVMF/OVMF_VARS.fd | ||
cp $< $@ | ||
|
||
qemu: $(BUILD)/boot.img $(BUILD)/OVMF_VARS.fd | ||
kvm -M q35 -m 1024 -net none -vga std $< \ | ||
-drive if=pflash,format=raw,readonly,file=/usr/share/OVMF/OVMF_CODE.fd \ | ||
-drive if=pflash,format=raw,file=$(BUILD)/OVMF_VARS.fd \ | ||
-chardev stdio,id=debug -device isa-debugcon,iobase=0x402,chardev=debug | ||
|
||
$(BUILD)/boot.img: $(BUILD)/efi.img | ||
dd if=/dev/zero of=$@.tmp bs=512 count=100352 | ||
parted $@.tmp -s -a minimal mklabel gpt | ||
parted $@.tmp -s -a minimal mkpart EFI FAT16 2048s 93716s | ||
parted $@.tmp -s -a minimal toggle 1 boot | ||
dd if=$< of=$@.tmp bs=512 count=98304 seek=2048 conv=notrunc | ||
mv $@.tmp $@ | ||
|
||
$(BUILD)/efi.img: $(BUILD)/boot.efi | ||
dd if=/dev/zero of=$@.tmp bs=512 count=98304 | ||
mkfs.vfat $@.tmp | ||
mmd -i $@.tmp efi | ||
mmd -i $@.tmp efi/boot | ||
mcopy -i $@.tmp $< ::driver.efi | ||
mcopy -i $@.tmp res/startup.nsh ::startup.nsh | ||
mv $@.tmp $@ | ||
|
||
$(BUILD)/boot.efi: Cargo.lock Cargo.toml res/* src/* src/*/* | ||
mkdir -p $(BUILD) | ||
cargo rustc \ | ||
--target $(TARGET) \ | ||
--release \ | ||
-- \ | ||
-C link-arg=/heap:0,0 \ | ||
-C link-arg=/stack:0,0 \ | ||
-C link-arg=/dll \ | ||
-C link-arg=/base:0 \ | ||
-C link-arg=/align:32 \ | ||
-C link-arg=/filealign:32 \ | ||
-C link-arg=/subsystem:efi_boot_service_driver \ | ||
--emit link=$@ | ||
.PHONY: qemu | ||
qemu: build $(OVMF)/OVMF_VARS.fd $(OVMF)/OVMF_CODE.fd | ||
cp $(OVMF)/OVMF_CODE.fd target/ | ||
cp $(OVMF)/OVMF_VARS.fd target/ | ||
$(QEMU) -enable-kvm -M q35 -m 1024 -vga std \ | ||
-chardev stdio,mux=on,id=debug \ | ||
-device isa-serial,index=2,chardev=debug \ | ||
-device isa-debugcon,iobase=0x402,chardev=debug \ | ||
-drive if=pflash,format=raw,readonly=on,file=target/OVMF_CODE.fd \ | ||
-drive if=pflash,format=raw,readonly=on,file=target/OVMF_VARS.fd \ | ||
-drive format=raw,file=fat:rw:target/$(TARGET) \ | ||
-net none |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,21 @@ | ||
# System76 Firmware Setup | ||
|
||
firmware-setup is a UEFI application that implements the user interface for | ||
firmware-setup is a UEFI driver that implements the user interface for | ||
System76 Open Firmware. It is basic by design, with its only functionality | ||
being selecting the boot device and changing the boot order. | ||
|
||
## Testing | ||
|
||
As a basic test, the driver can be loaded in QEMU to use the UI. | ||
|
||
``` | ||
make qemu | ||
``` | ||
|
||
In QEMU: | ||
|
||
``` | ||
Shell> fs0: | ||
FS0:\> load release\system76_firmware_setup.efi | ||
FS0:\> exit | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,9 @@ | ||
[Defines] | ||
INF_VERSION = 0x00010005 | ||
INF_VERSION = 1.5 | ||
BASE_NAME = system76-firmware-setup | ||
FILE_GUID = 76ff62c9-7915-4e98-b964-154524023fa7 | ||
MODULE_TYPE = UEFI_DRIVER | ||
VERSION_STRING = 1.0 | ||
|
||
# | ||
# The following information is for reference only and not required by the build tools. | ||
# | ||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC | ||
# | ||
|
||
VALID_ARCHITECTURES = X64 | ||
|
||
[Binaries.X64] | ||
PE32|build/x86_64-unknown-uefi/boot.efi|* | ||
|
||
PE32|target/x86_64-unknown-uefi/release/system76_firmware_setup.efi|* |
This file was deleted.
Oops, something went wrong.