revitalized
This commit is contained in:
parent
2190a5c04d
commit
a46f795b5a
12 changed files with 52 additions and 86 deletions
|
@ -1,5 +1,6 @@
|
||||||
[build]
|
|
||||||
target = "x86_64-rustboot.json" # target OS specifications
|
|
||||||
|
|
||||||
[unstable]
|
[unstable]
|
||||||
build-std = ["core", "compiler_builtins"] # recompile these
|
build-std = ["core", "compiler_builtins"] # recompile these
|
||||||
|
build-std-features = ["compiler-builtins-mem"]
|
||||||
|
|
||||||
|
[build]
|
||||||
|
target = "x86_64-rustboot.json" # target OS specifications
|
||||||
|
|
16
Cargo.toml
16
Cargo.toml
|
@ -4,6 +4,14 @@ version = "0.1.0"
|
||||||
edition = "2024"
|
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]
|
[lib]
|
||||||
crate-type = ["staticlib"] # library that contains all dependencies
|
crate-type = ["staticlib"] # library that contains all dependencies
|
||||||
|
|
||||||
|
@ -17,8 +25,8 @@ x86_64 = "0.15"
|
||||||
version = "1.5"
|
version = "1.5"
|
||||||
features = ["spin_no_std"]
|
features = ["spin_no_std"]
|
||||||
|
|
||||||
#[profile.dev]
|
[profile.dev]
|
||||||
#panic = "abort"
|
panic = "abort"
|
||||||
|
|
||||||
#[profile.release]
|
[profile.release]
|
||||||
#panic = "abort"
|
panic = "abort"
|
||||||
|
|
35
Cargo.toml.0
35
Cargo.toml.0
|
@ -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
|
|
24
Makefile
24
Makefile
|
@ -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
|
|
BIN
build/os.iso
BIN
build/os.iso
Binary file not shown.
22
flake.nix
22
flake.nix
|
@ -1,13 +1,14 @@
|
||||||
{
|
{
|
||||||
description = "Rust shells";
|
description = "Rustup";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = inputs @ {...}: let
|
outputs = inputs @ {...}: let
|
||||||
additionalPackages = [
|
additionalPackages = [
|
||||||
|
pkgs.cowsay
|
||||||
|
pkgs.just
|
||||||
|
pkgs.nasm
|
||||||
pkgs.qemu
|
pkgs.qemu
|
||||||
pkgs.xorriso
|
pkgs.xorriso
|
||||||
];
|
];
|
||||||
|
@ -15,7 +16,6 @@
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
overlays = [(import inputs.rust-overlay)];
|
overlays = [(import inputs.rust-overlay)];
|
||||||
};
|
};
|
||||||
|
|
||||||
rustup = {
|
rustup = {
|
||||||
package = pkgs.rustup;
|
package = pkgs.rustup;
|
||||||
path = "${pkgs.rustup}/lib/rustlib.src/rust/library";
|
path = "${pkgs.rustup}/lib/rustlib.src/rust/library";
|
||||||
|
@ -23,12 +23,18 @@
|
||||||
in {
|
in {
|
||||||
devShell.x86_64-linux = pkgs.mkShell {
|
devShell.x86_64-linux = pkgs.mkShell {
|
||||||
packages = [
|
packages = [
|
||||||
rustup.package
|
|
||||||
additionalPackages
|
additionalPackages
|
||||||
|
rustup.package
|
||||||
];
|
];
|
||||||
env = {
|
shellHook = ''
|
||||||
RUST_SRC_PATH = rustup.path;
|
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!"
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
30
justfile
30
justfile
|
@ -1,24 +1,34 @@
|
||||||
all:
|
all: setup asm rust link image clean
|
||||||
|
|
||||||
|
setup:
|
||||||
mkdir temp
|
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
|
asm:
|
||||||
nasm -f elf64 src/boot.asm -o temp/boot.asm.o
|
nasm -f elf64 src/asm/multiboot_header.asm -o temp/multiboot_header.asm.o
|
||||||
cargo update --verbose
|
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
|
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
|
||||||
mkdir isofiles/boot
|
mkdir isofiles/boot
|
||||||
mkdir isofiles/boot/grub
|
mkdir isofiles/boot/grub
|
||||||
cp temp/kernel.bin isofiles/boot/kernel.bin
|
cp temp/kernel.bin isofiles/boot/kernel.bin
|
||||||
cp src/grub.cfg isofiles/boot/grub/grub.cfg
|
cp link-cfg/grub.cfg isofiles/boot/grub/grub.cfg
|
||||||
rm -rf temp
|
|
||||||
grub-mkrescue -o build/os.iso isofiles 2> /dev/null
|
grub-mkrescue -o build/os.iso isofiles 2> /dev/null
|
||||||
rm -rf isofiles
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf temp
|
rm -rf temp
|
||||||
rm -rf isofiles
|
rm -rf isofiles
|
||||||
rm -rf target
|
|
||||||
|
scrub: clean
|
||||||
|
cargo clean
|
||||||
|
cargo update --verbose
|
||||||
|
|
||||||
run:
|
run:
|
||||||
qemu-system-x86_64 -cdrom build/os.iso
|
qemu-system-x86_64 -cdrom build/os.iso
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue