Compare commits
2 Commits
1afc66acb1
...
0485052b11
Author | SHA1 | Date | |
---|---|---|---|
0485052b11 | |||
f339c707b7 |
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,2 @@
|
|||||||
/target
|
/target
|
||||||
/iso
|
/build
|
||||||
/gila.iso
|
|
38
Makefile
Normal file
38
Makefile
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
|
||||||
|
TARGET ?= "x86_64-unknown-none"
|
||||||
|
|
||||||
|
all: clean prepare gila iso run
|
||||||
|
|
||||||
|
# Prepare toolchain
|
||||||
|
prepare:
|
||||||
|
rustup install nightly
|
||||||
|
rustup target add $(TARGET)
|
||||||
|
|
||||||
|
# Run the ISO in an emulator.
|
||||||
|
run: build/gila.iso
|
||||||
|
qemu-system-x86_64 -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)
|
||||||
|
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 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/
|
||||||
|
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 \
|
||||||
|
--protective-msdos-label build/iso -o build/gila.iso
|
||||||
|
limine bios-install build/gila.iso
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf build
|
||||||
|
cargo clean
|
13
README.md
13
README.md
@ -28,12 +28,21 @@ Licensed under the GNU Public License v3. See [LICENSE](LICENSE) for details.
|
|||||||
|
|
||||||
To build an ISO image that you can boot, there are several prerequisites:
|
To build an ISO image that you can boot, there are several prerequisites:
|
||||||
|
|
||||||
|
- `rustup` command installed
|
||||||
- `limine` command installed
|
- `limine` command installed
|
||||||
- `xorriso` command installed
|
- `xorriso` command installed
|
||||||
|
- `make` command installed
|
||||||
|
- `qemu-system-x86_64` command installed (for running)
|
||||||
|
|
||||||
Then run the [build_iso.sh](build_iso.sh) script. It will generate `gila.iso`.
|
Then run `make` to invoke the [Makefile](Makefile).
|
||||||
|
|
||||||
Running the kernel requires `qemu-system-{ARCH}`.
|
- `make prepare`: Installs needed Rust toolchain.
|
||||||
|
- `make clean`: Cleans all built files.
|
||||||
|
- `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.
|
||||||
|
|
||||||
|
TODO: This build setup is not compatible with anything other than `x86_64`.
|
||||||
|
|
||||||
You can install all these dependencies automatically by using `nix-shell` and
|
You can install all these dependencies automatically by using `nix-shell` and
|
||||||
supplying [shell.nix](shell.nix) as an argument.
|
supplying [shell.nix](shell.nix) as an argument.
|
||||||
|
31
build_iso.sh
31
build_iso.sh
@ -1,31 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
|
||||||
echo "Argument 1 must be the Rust target triple."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 || exit 1 ; pwd -P )"
|
|
||||||
cd "$SCRIPTPATH" || exit 1
|
|
||||||
|
|
||||||
rm -rf ./iso/
|
|
||||||
rm ./gila.iso
|
|
||||||
#cargo clean
|
|
||||||
|
|
||||||
set -euxo pipefail
|
|
||||||
|
|
||||||
mkdir -p ./iso/limine/
|
|
||||||
cp ./limine.conf ./iso/
|
|
||||||
cp /usr/share/limine/limine-bios.sys ./iso/limine/
|
|
||||||
cp /usr/share/limine/limine-bios-cd.bin ./iso/limine/
|
|
||||||
cp /usr/share/limine/limine-uefi-cd.bin ./iso/limine/
|
|
||||||
|
|
||||||
cargo build --target="$1" --release
|
|
||||||
cp target/"$1"/release/gila ./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 \
|
|
||||||
--protective-msdos-label iso -o gila.iso
|
|
||||||
|
|
||||||
limine bios-install gila.iso
|
|
@ -16,6 +16,7 @@ pkgs.mkShell {
|
|||||||
xorriso
|
xorriso
|
||||||
rustup
|
rustup
|
||||||
qemu
|
qemu
|
||||||
|
make
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
#![allow(unused_variables)]
|
||||||
|
|
||||||
use vga;
|
use vga;
|
||||||
pub use vga::writers::TextWriter;
|
pub use vga::writers::TextWriter;
|
||||||
|
Loading…
Reference in New Issue
Block a user