revitalized

This commit is contained in:
mtgmonkey 2025-05-13 00:10:37 -04:00
parent 2190a5c04d
commit a46f795b5a
12 changed files with 52 additions and 86 deletions

View file

@ -1,5 +1,6 @@
[build]
target = "x86_64-rustboot.json" # target OS specifications
[unstable]
build-std = ["core", "compiler_builtins"] # recompile these
build-std-features = ["compiler-builtins-mem"]
[build]
target = "x86_64-rustboot.json" # target OS specifications

View file

@ -2,7 +2,15 @@
name = "rustboot"
version = "0.1.0"
edition = "2024"
authors = ["mtgmonkey"]
authors = [ "mtgmonkey" ]
# quit QEMU
[package.metadata.bootimage]
test-args = [ "device", "isa-debug-exit,iobase=0xf4,iosize=0x04",
"-serial", "stdio",
"-display", "none" ]
test-success-exit-code = 33 # (0x10 << 1) | 1
test-timeout = 30 # in seconds
[lib]
crate-type = ["staticlib"] # library that contains all dependencies
@ -17,8 +25,8 @@ x86_64 = "0.15"
version = "1.5"
features = ["spin_no_std"]
#[profile.dev]
#panic = "abort"
[profile.dev]
panic = "abort"
#[profile.release]
#panic = "abort"
[profile.release]
panic = "abort"

View file

@ -1,35 +0,0 @@
[package]
name = "rustos"
version = "0.1.0"
edition = "2024"
authors = [ "mtgmonkey" ]
# Special debug shutdown device in QEMU
[package.metadata.bootimage]
test-args = ["-device", "isa-debug-exit,iobase=0xf4,iosize=0x04",
"-serial", "stdio",
"-display", "none"]
test-success-exit-code = 33 # (0x10 << 1) | 1
test-timeout = 30 # in seconds
[dependencies]
bootloader = { version = "0.9", features = ["map_physical_memory"] }
linked_list_allocator = "0.9.0"
pc-keyboard = "0.7.0"
pic8259 = "0.10.1"
spin = "0.5.2"
uart_16550 = "0.2.0"
volatile = "0.2.6"
x86_64 = "0.14.2"
[dependencies.lazy_static]
version = "1.0"
features = ["spin_no_std"]
[[test]]
name = "should_panic"
harness = false
[[test]]
name = "stack_overflow"
harness = false

View file

@ -1,24 +0,0 @@
all:
mkdir temp
nasm -f elf64 src/multiboot_header.asm -o temp/multiboot_header.asm.o
nasm -f elf64 src/long_mode_init.asm -o temp/long_mode_init.asm.o
nasm -f elf64 src/boot.asm -o temp/boot.asm.o
echo "Run 'RUST_TARGET_PATH=<dollar>(pwd)"
cargo update --verbose
cargo build --target x86_64-rustboot
ld -n -o temp/kernel.bin --gc-sections -T linker.ld temp/multiboot_header.asm.o temp/long_mode_init.asm.o temp/boot.asm.o target/x86_64-rustboot/debug/librustboot.a
mkdir isofiles
mkdir isofiles/boot
mkdir isofiles/boot/grub
cp temp/kernel.bin isofiles/boot/kernel.bin
cp src/grub.cfg isofiles/boot/grub/grub.cfg
rm -rf temp
grub-mkrescue -o build/os.iso isofiles 2> /dev/null
rm -rf isofiles
clean:
rm -rf temp
rm -rf isofiles
run:
qemu-system-x86_64 -cdrom build/os.iso

Binary file not shown.

View file

@ -1,13 +1,14 @@
{
description = "Rust shells";
description = "Rustup";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs = inputs @ {...}: let
additionalPackages = [
pkgs.cowsay
pkgs.just
pkgs.nasm
pkgs.qemu
pkgs.xorriso
];
@ -15,7 +16,6 @@
system = "x86_64-linux";
overlays = [(import inputs.rust-overlay)];
};
rustup = {
package = pkgs.rustup;
path = "${pkgs.rustup}/lib/rustlib.src/rust/library";
@ -23,12 +23,18 @@
in {
devShell.x86_64-linux = pkgs.mkShell {
packages = [
rustup.package
additionalPackages
rustup.package
];
env = {
RUST_SRC_PATH = rustup.path;
};
shellHook = ''
echo "Run 'exit' if you don't see something cowsaid." &&
export RUST_SRC_PATH=rustup.path &&
rustup default nightly &&
rustup component add rust-src &&
rustup component add rust-analyzer &&
export PS1='\h@\[\e[30;48;5;202;1m\]rustboot\[\e[0m\]|\w\\$ ' &&
cowsay "Welcome to rust-boot! Run 'just' to build and 'just run' to launch QEMU!"
'';
};
};
}

View file

@ -1,24 +1,34 @@
all:
mkdir temp
nasm -f elf64 src/multiboot_header.asm -o temp/multiboot_header.asm.o
nasm -f elf64 src/long_mode_init.asm -o temp/long_mode_init.asm.o
nasm -f elf64 src/boot.asm -o temp/boot.asm.o
cargo update --verbose
all: setup asm rust link image clean
setup:
mkdir temp
asm:
nasm -f elf64 src/asm/multiboot_header.asm -o temp/multiboot_header.asm.o
nasm -f elf64 src/asm/long_mode_init.asm -o temp/long_mode_init.asm.o
nasm -f elf64 src/asm/boot.asm -o temp/boot.asm.o
rust:
cargo build
ld -n -o temp/kernel.bin --gc-sections -T linker.ld temp/multiboot_header.asm.o temp/long_mode_init.asm.o temp/boot.asm.o target/x86_64-rustboot/debug/librustboot.a
link:
ld -n -o temp/kernel.bin --gc-sections -T link-cfg/linker.ld temp/multiboot_header.asm.o temp/long_mode_init.asm.o temp/boot.asm.o target/x86_64-rustboot/debug/librustboot.a
image:
mkdir isofiles
mkdir isofiles/boot
mkdir isofiles/boot/grub
cp temp/kernel.bin isofiles/boot/kernel.bin
cp src/grub.cfg isofiles/boot/grub/grub.cfg
rm -rf temp
cp link-cfg/grub.cfg isofiles/boot/grub/grub.cfg
grub-mkrescue -o build/os.iso isofiles 2> /dev/null
rm -rf isofiles
clean:
rm -rf temp
rm -rf isofiles
rm -rf target
scrub: clean
cargo clean
cargo update --verbose
run:
qemu-system-x86_64 -cdrom build/os.iso