WIP changes for rust bootloader

This commit is contained in:
Jeremy Soller 2022-02-07 17:13:28 -07:00
parent 7e0938d674
commit 35cd0b2ab0
No known key found for this signature in database
GPG key ID: 87F211AF2BE4C2FE
10 changed files with 40 additions and 31 deletions

View file

@ -49,6 +49,9 @@ fetch:
# Cross compiler recipes
include mk/prefix.mk
# Bootloader recipes
include mk/bootloader.mk
# Kernel recipes
include mk/kernel.mk

@ -1 +1 @@
Subproject commit c96eb83d18ba15e758d896bfba3c35700416f669
Subproject commit 6ed05fcaa4f493f8b9c46e716f5edf5bcecc83e5

@ -1 +1 @@
Subproject commit 91809e79c07e815d06397e04d09dd31648291027
Subproject commit 0cb6f5afd3eab51085a460d331495e2693565b5e

2
kernel

@ -1 +1 @@
Subproject commit bbc4a4aefe12e4a66b4177324c07a40fbc202e48
Subproject commit 413238a0a65dc03b9964843523ddd96ffc29276f

View file

@ -1,2 +1,2 @@
bochs: build/livedisk.bin
bochs: build/harddrive.bin
bochs -f bochs.$(ARCH)

23
mk/bootloader.mk Normal file
View file

@ -0,0 +1,23 @@
bootloader/build/$(BOOTLOADER_TARGET)/bootloader.bin: FORCE
env --unset=RUST_TARGET_PATH --unset=RUSTUP_TOOLCHAIN --unset=XARGO_RUST_SRC \
$(MAKE) -C bootloader build/$(BOOTLOADER_TARGET)/bootloader.bin TARGET=$(BOOTLOADER_TARGET)
build/bootloader.bin: bootloader/build/$(BOOTLOADER_TARGET)/bootloader.bin
mkdir -p build
cp -v $< $@
bootloader-coreboot/build/bootloader: build/kernel_coreboot
env --unset=RUST_TARGET_PATH --unset=RUSTUP_TOOLCHAIN --unset=XARGO_RUST_SRC \
$(MAKE) -C bootloader-coreboot clean build/bootloader KERNEL="$(ROOT)/$<"
build/coreboot.elf: bootloader-coreboot/build/bootloader
mkdir -p build
cp -v $< $@
bootloader-efi/build/$(EFI_TARGET)/boot.efi: FORCE
env --unset=RUST_TARGET_PATH --unset=RUSTUP_TOOLCHAIN --unset=XARGO_RUST_SRC \
$(MAKE) -C bootloader-efi build/$(EFI_TARGET)/boot.efi TARGET=$(EFI_TARGET)
build/bootloader.efi: bootloader-efi/build/$(EFI_TARGET)/boot.efi
mkdir -p build
cp -v $< $@

View file

@ -55,6 +55,11 @@ INSTALLER=\
installer/target/release/redox_installer $(INSTALLER_FLAGS)
## Bootloader variables
ifeq ($(ARCH),x86_64)
BOOTLOADER_TARGET=x86-unknown-none
else
BOOTLOADER_TARGET=$(ARCH)-unknown-none
endif
EFI_TARGET=$(ARCH)-unknown-uefi
PARTED=/sbin/parted

View file

@ -1,14 +1,9 @@
build/bootloader: bootloader/$(ARCH)/**
mkdir -p build
nasm -f bin -o $@ -D ARCH_$(ARCH) -ibootloader/$(ARCH)/ bootloader/$(ARCH)/disk.asm
build/harddrive.bin: build/filesystem.bin bootloader/$(ARCH)/**
nasm -f bin -o build/bootsector.bin -D ARCH_$(ARCH) -ibootloader/$(ARCH)/ bootloader/$(ARCH)/disk.asm
build/harddrive.bin: build/filesystem.bin build/bootloader.bin
dd if=/dev/zero of=$@.partial bs=1M count=$$(expr $$(du -m $< | cut -f1) + 2)
$(PARTED) -s -a minimal $@.partial mklabel msdos
$(PARTED) -s -a minimal $@.partial mkpart primary 2048s $$(expr $$(du -m $< | cut -f1) \* 2048 + 2048)s
dd if=build/bootsector.bin of=$@.partial bs=1 count=446 conv=notrunc
dd if=build/bootsector.bin of=$@.partial bs=512 skip=1 seek=1 conv=notrunc
dd if=build/bootloader.bin of=$@.partial bs=1 count=446 conv=notrunc
dd if=build/bootloader.bin of=$@.partial bs=512 skip=1 seek=1 conv=notrunc
dd if=$< of=$@.partial bs=1M seek=1 conv=notrunc
mv $@.partial $@
@ -25,22 +20,6 @@ build/livedisk.iso: build/livedisk.bin.gz
build/iso/
isohybrid $@
bootloader-coreboot/build/bootloader: build/kernel_coreboot
env --unset=RUST_TARGET_PATH --unset=RUSTUP_TOOLCHAIN --unset=XARGO_RUST_SRC \
$(MAKE) -C bootloader-coreboot clean build/bootloader KERNEL="$(ROOT)/$<"
build/coreboot.elf: bootloader-coreboot/build/bootloader
mkdir -p build
cp -v $< $@
bootloader-efi/build/$(EFI_TARGET)/boot.efi: FORCE
env --unset=RUST_TARGET_PATH --unset=RUSTUP_TOOLCHAIN --unset=XARGO_RUST_SRC \
$(MAKE) -C bootloader-efi build/$(EFI_TARGET)/boot.efi TARGET=$(EFI_TARGET)
build/bootloader.efi: bootloader-efi/build/$(EFI_TARGET)/boot.efi
mkdir -p build
cp -v $< $@
build/harddrive-efi.bin: build/bootloader.efi build/filesystem.bin
# TODO: Validate the correctness of this \
# Populate an EFI system partition \

View file

@ -1,4 +1,4 @@
build/filesystem.bin: filesystem.toml build/bootloader build/kernel prefix
build/filesystem.bin: filesystem.toml build/kernel prefix
cargo build --manifest-path cookbook/Cargo.toml --release
cargo build --manifest-path installer/Cargo.toml --release
cargo build --manifest-path redoxfs/Cargo.toml --release
@ -11,7 +11,6 @@ build/filesystem.bin: filesystem.toml build/bootloader build/kernel prefix
sleep 2
pgrep redoxfs
cp $< build/filesystem/filesystem.toml
cp build/bootloader build/filesystem/bootloader
cp build/kernel build/filesystem/kernel
cp -r $(ROOT)/$(PREFIX_INSTALL)/$(TARGET)/include build/filesystem/include
cp -r $(ROOT)/$(PREFIX_INSTALL)/$(TARGET)/lib build/filesystem/lib

@ -1 +1 @@
Subproject commit 9083dd07c95752b2ebaefc91117e5f4629f2d578
Subproject commit cfe5841646df0044e9e689a43b97c9aff3a65444