Compare commits

...

2 Commits

Author SHA1 Message Date
89f21f577d
Fix README 2025-03-05 23:05:38 -05:00
e432b5a48e
Makefile updates 2025-03-05 23:01:38 -05:00
8 changed files with 42 additions and 18 deletions

18
Cargo.lock generated
View File

@ -9,7 +9,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e42f25ac5fa51f4188d14baf8f387a97dcd8639644b2f3df948bf5f6dd7d6fa"
dependencies = [
"bit_field",
"bitflags 2.8.0",
"bitflags 2.9.0",
"log",
]
@ -33,9 +33,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
version = "2.8.0"
version = "2.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36"
checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
[[package]]
name = "conquer-once"
@ -89,7 +89,7 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ca87cab008b8efeebdbe037cd4d1438037d48c5cb6fed939ffa5aa06315a321"
dependencies = [
"bitflags 2.8.0",
"bitflags 2.9.0",
]
[[package]]
@ -129,15 +129,15 @@ dependencies = [
[[package]]
name = "portable-atomic"
version = "1.10.0"
version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6"
checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e"
[[package]]
name = "rustversion"
version = "1.0.19"
version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4"
checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2"
[[package]]
name = "scopeguard"
@ -199,7 +199,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c101112411baafbb4bf8d33e4c4a80ab5b02d74d2612331c61e8192fc9710491"
dependencies = [
"bit_field",
"bitflags 2.8.0",
"bitflags 2.9.0",
"rustversion",
"volatile",
]

View File

@ -1,8 +1,13 @@
# Default target is x86_64-unknown-none
TARGET ?= "x86_64-unknown-none"
# Limine BIOS file directory
LIMINE-DIR ?= "/usr/share/limine"
# QEMU system is set accordingly and automatically
qemu = "qemu-system-x86_64"
# List of required BIOS files
limine-files = limine-bios.sys limine-bios-cd.bin limine-bios-uefi-cd.bin
# Properly set QEMU command
ifeq ($(TARGET),x86_64-unknown-none)
@ -17,34 +22,50 @@ else ifeq ($(TARGET),loongarch64-unknown-none)
qemu = "qemu-system-loongarch64"
endif
executables = rustup xorriso limine $(qemu)
all: gila iso run
checkenv:
$(foreach file,$(limine-files),\
$(if $(shell test -f $(LIMINE-DIR)/$(file) | echo "it exists"),$(info "Found $(file)"),$(error "No $(file) in $(LIMINE-DIR)")))
$(foreach exec,$(executables),\
$(if $(shell which $(exec)),$(info "Found $(exec)"),$(error "No $(exec) in PATH")))
# Prepare toolchain
prepare:
prepare: checkenv
rustup install nightly
rustup update
rustup target add $(TARGET)
# Run the ISO in an emulator.
run: build/gila.iso
$(qemu) -drive file=build/gila.iso,format=raw,index=0,media=disk
# Build the bootable kernel image.
.PHONY: build/iso/gila
gila: prepare $(wildcard src/*.rs) $(wildcard linker-scripts/*.ld)
gila: prepare $(shell find src -type f -name *.rs) $(shell find src -type f -name linker.ld)
mkdir -p build/iso/
cargo build --release -Z unstable-options --target=$(TARGET) --artifact-dir build/iso/
# Build a bootable ISO and install Limine.
.PHONY: build/gila.iso
iso: build/iso/gila limine.conf
mkdir -p build/iso/limine
mkdir -p build/iso/EFI/BOOT
cp ./limine.conf build/iso/
cp /usr/share/limine/limine-bios.sys build/iso/limine/
cp /usr/share/limine/limine-bios-cd.bin build/iso/limine/
cp /usr/share/limine/limine-uefi-cd.bin build/iso/limine/
cp $(LIMINE-DIR)/limine-bios.sys build/iso/limine/
cp $(LIMINE-DIR)/limine-bios-cd.bin build/iso/limine/
cp $(LIMINE-DIR)/limine-uefi-cd.bin build/iso/limine/
tree build/iso/
xorriso -as mkisofs -b limine/limine-bios-cd.bin -no-emul-boot \
-boot-load-size 4 -boot-info-table --efi-boot \
limine/limine-uefi-cd.bin -efi-boot-part --efi-boot-image \

View File

@ -65,14 +65,17 @@ To build an ISO image that you can boot, there are several prerequisites:
Then run `make` to invoke the [Makefile](Makefile).
- `make checkenv`: Asserts all needed commands and resources are accessible.
- `make prepare`: Installs needed Rust toolchain.
- `make clean`: Cleans all built files.
- `make clean`: Cleans all built binaries, libraries, and ISOs.
- `make gila`: Builds the kernel ELF file.
- `make iso`: Builds the bootable ISO with Limine installed.
- `make run`: Builds the ISO and boots it in QEMU.
By supplying `TARGET=(rustc target triple)` as an additional argument, you can change the architecture that gila will be compiled & run for. The default is `x86_64-unknown-none`.
The default limine BIOS file search directory is `/usr/share/limine`. You can change this by supplying a path (no trailing slash) like so: `LIMINE-DIR=/home/user/Downloads/limine`.
You can install all these dependencies automatically by using `nix-shell` and
supplying [shell.nix](shell.nix) as an argument.

View File

@ -1,7 +1,7 @@
fn main() {
let arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
// Tell cargo to pass the linker script to the linker..
println!("cargo:rustc-link-arg=-Tlinker-scripts/linker-{arch}.ld");
println!("cargo:rustc-link-arg=-Tsrc/arch/{arch}/linker.ld");
// ..and to re-run if it changes.
println!("cargo:rerun-if-changed=linker-scripts/linker-{arch}.ld");
println!("cargo:rerun-if-changed=src/arch/{arch}linker.ld");
}