Skip to content

Commit

Permalink
chore: update rust-toolchain, nix dev shell
Browse files Browse the repository at this point in the history
  • Loading branch information
marekvospel committed Oct 25, 2024
1 parent 6ff683f commit 2838589
Show file tree
Hide file tree
Showing 8 changed files with 169 additions and 11 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
9 changes: 8 additions & 1 deletion .rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
[toolchain]
channel = "nightly"
channel = "nightly"
components = [
"rust-src",
]
targets = [
"x86_64-unknown-none"
]

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ arch ?= x86_64
target ?= $(arch)-custom
kernel := build/kernel-$(arch).bin
iso := build/image-$(arch).iso
rust_kernel :=target/$(target)/release/libkernel.a
rust_kernel := target/$(target)/release/libkernel.a

ld_script := arch/$(arch)/linker.ld
grub_cfg := arch/$(arch)/grub.cfg
Expand All @@ -18,7 +18,7 @@ clean:
@rm -rf build

$(kernel): kernel $(asm_obj) $(ld_script)
@ld -n -T $(ld_script) -o $(kernel) $(asm_obj) $(rust_kernel)
@ld -n -T $(ld_script) -static -o $(kernel) $(asm_obj) $(rust_kernel)

kernel:
@RUST_TARGET_PATH=$(shell pwd)/targets cargo build --target $(target) --release
Expand Down
8 changes: 7 additions & 1 deletion arch/x86_64/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ SECTIONS {
. = ALIGN(4K);
}

.got :
{
*(.got .got.*)
. = ALIGN(4K);
}

.bss :
{
*(.bss .bss.*)
Expand All @@ -49,4 +55,4 @@ SECTIONS {
. = ALIGN(4K);
}

}
}
100 changes: 100 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
description = "A very basic flake";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};

};

outputs =
inputs:
inputs.flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = inputs.nixpkgs.legacyPackages.${system};
toolchain = inputs.fenix.packages.${pkgs.pkgsBuildHost.system}.fromToolchainFile {
file = ./.rust-toolchain.toml;
sha256 = "sha256-xgApk6OFxgHuss/VOC9hWwDhDuVF7QoSuWFiozdEWTk=";
};
buildInputs = with pkgs; [
toolchain
nasm
# We need ld
binutils
# Grub-mkrescue (to be replaced with a script maybe?)
grub2
libisoburn
# Testing
qemu
];
in
{

devShells.default = pkgs.mkShell {
buildInputs = buildInputs;
};
}
);

}
10 changes: 5 additions & 5 deletions src/memory/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,16 @@ fn remap_kernel<A: FrameAlloc>(
continue;
}

println!(
"Remapping {:}...",
section.name().unwrap_or("<Invalid section name>")
);

assert!(
section.start_address() % PAGE_SIZE == 0,
"sections need to be page aligned"
);

println!(
"Remapping {:}",
section.name().unwrap_or("<Invalid section name>")
);

let mut flags = EntryFlags::PRESENT;

if section.flags().contains(ElfSectionFlags::WRITABLE) {
Expand Down
4 changes: 2 additions & 2 deletions targets/x86_64-custom.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"llvm-target": "x86_64-unknown-none",
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
"data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128",
"linker-flavor": "gcc",
"target-endian": "little",
"target-pointer-width": "64",
Expand All @@ -10,4 +10,4 @@
"disable-redzone": true,
"features": "-mmx,-sse,+soft-float",
"panic-strategy": "abort"
}
}

0 comments on commit 2838589

Please sign in to comment.