Compare commits
5 Commits
master
...
d35463e195
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d35463e195 | ||
|
|
fdf5bb9daf | ||
|
|
0d739522a0 | ||
|
|
846c54653b | ||
|
|
f52da82650 |
46
README.md
46
README.md
@@ -2,50 +2,16 @@ Call me Terry Davis because... actually please don't. I have visions: aspiration
|
|||||||
|
|
||||||
# bootle
|
# bootle
|
||||||
|
|
||||||
hobby kernel written in rust. It's just for playing around... for now :p
|
hobby kernel
|
||||||
|
|
||||||
run with `nix run git+https://git.mtgmonkey.net/andromeda/bootler#bootle`
|
status: basically nothing, come back later
|
||||||
|
|
||||||
# bootler
|
# bootler
|
||||||
|
|
||||||
hobby bootloader written in asm. It's just for playing around... for now :p
|
hobby 1-stage legacy mode bootloader
|
||||||
|
|
||||||
run with `nix run git+https://git.mtgmonkey.net/andromeda/bootler#bootler`
|
status: gets to long mode, loads+jumps to kernel, starts idt and gdt... :)
|
||||||
|
|
||||||
### memory map
|
---
|
||||||
|
|
||||||
```
|
this project follows [Common Changelog](https://common-changelog.org) guidelines
|
||||||
+------ 0x00100000 ------+
|
|
||||||
| hardware, bios stuff |
|
|
||||||
+------ 0x00080000 ------+
|
|
||||||
| |
|
|
||||||
| |
|
|
||||||
+------ 0x00010200 ------+
|
|
||||||
| x86_64 kernel |
|
|
||||||
+------ 0x00010000 ------+
|
|
||||||
| |
|
|
||||||
| |
|
|
||||||
+------ 0x00009000 ------+
|
|
||||||
| IDT |
|
|
||||||
+------ 0x00008000 ------+
|
|
||||||
| |
|
|
||||||
| |
|
|
||||||
+------ 0x00007E00 ------+
|
|
||||||
| bootloader (boot.asm) |
|
|
||||||
+------ 0x00007C00 ------+
|
|
||||||
| stack | TODO get real stack
|
|
||||||
+------ 0x00005000 ------+
|
|
||||||
| PT |
|
|
||||||
+------ 0x00004000 ------+
|
|
||||||
| PDT |
|
|
||||||
+------ 0x00003000 ------+
|
|
||||||
| PDPT |
|
|
||||||
+------ 0x00002000 ------+
|
|
||||||
| PML4T |
|
|
||||||
+------ 0x00001000 ------+
|
|
||||||
| |
|
|
||||||
| |
|
|
||||||
+------ 0x00000500 ------+
|
|
||||||
| bios stuff |
|
|
||||||
+------ 0x00000000 ------+
|
|
||||||
```
|
|
||||||
|
|||||||
0
Cargo.lock → bootle/Cargo.lock
generated
0
Cargo.lock → bootle/Cargo.lock
generated
28
bootle/README.md
Normal file
28
bootle/README.md
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
# bootle
|
||||||
|
|
||||||
|
hobby kernel written in rust. It's just for playing around... for now :p
|
||||||
|
|
||||||
|
run with `nix run git+https://git.mtgmonkey.net/andromeda/bootler#bootle`
|
||||||
|
|
||||||
|
### memory map
|
||||||
|
|
||||||
|
```
|
||||||
|
+------ 0x00100000 ------+
|
||||||
|
| hardware, bios stuff |
|
||||||
|
+------ 0x00080000 ------+
|
||||||
|
| |
|
||||||
|
| |
|
||||||
|
+------ 0x00010200 ------+
|
||||||
|
| kernel |
|
||||||
|
+------ 0x00010000 ------+
|
||||||
|
| bootloader stuff |
|
||||||
|
| includes stack, gdt, |
|
||||||
|
| idt for the time being |
|
||||||
|
+------ 0x00000500 ------+
|
||||||
|
| bios stuff |
|
||||||
|
+------ 0x00000000 ------+
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
this project follows [Common Changelog](https://common-changelog.org) guidelines
|
||||||
@@ -6,27 +6,28 @@
|
|||||||
qemu,
|
qemu,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
rust-toolchain = rust-bin.fromRustupToolchainFile ../../rust-toolchain.toml;
|
rust-toolchain = rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||||
naersk' = callPackage naersk {
|
naersk' = callPackage naersk {
|
||||||
cargo = rust-toolchain;
|
cargo = rust-toolchain;
|
||||||
rustc = rust-toolchain;
|
rustc = rust-toolchain;
|
||||||
clippy = rust-toolchain;
|
clippy = rust-toolchain;
|
||||||
};
|
};
|
||||||
in (naersk'.buildPackage {
|
in (naersk'.buildPackage {
|
||||||
src = ../../.;
|
src = ./.;
|
||||||
|
|
||||||
# deps for rust-src
|
# deps for rust-src
|
||||||
additionalCargoLock = "${rust-toolchain.availableComponents.rust-src}/lib/rustlib/src/rust/library/Cargo.lock";
|
additionalCargoLock = "${rust-toolchain.availableComponents.rust-src}/lib/rustlib/src/rust/library/Cargo.lock";
|
||||||
|
|
||||||
# just library build
|
# just library build
|
||||||
copyBins = false;
|
copyBins = false;
|
||||||
|
copyLibs = true;
|
||||||
release = true;
|
release = true;
|
||||||
|
|
||||||
# build std
|
# build std
|
||||||
cargoBuildOptions = x:
|
cargoBuildOptions = x:
|
||||||
x
|
x
|
||||||
++ [
|
++ [
|
||||||
"-Zbuild-std=core,compiler_builtins"
|
"-Zbuild-std"
|
||||||
];
|
];
|
||||||
|
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
@@ -12,11 +12,13 @@ pub extern "C" fn _start() -> ! {
|
|||||||
fn print_serial(s: &str) {
|
fn print_serial(s: &str) {
|
||||||
let mut bytes = s.bytes();
|
let mut bytes = s.bytes();
|
||||||
while let Some(b) = bytes.next() {
|
while let Some(b) = bytes.next() {
|
||||||
unsafe {core::arch::asm!(
|
unsafe {
|
||||||
"out dx, al"
|
core::arch::asm!(
|
||||||
, in("al") b
|
"out dx, al"
|
||||||
)};
|
, in("al") b
|
||||||
};
|
)
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn println_serial(s: &str) {
|
fn println_serial(s: &str) {
|
||||||
@@ -28,7 +30,11 @@ fn welcome_serial() {
|
|||||||
print_serial(ANSI_PINK);
|
print_serial(ANSI_PINK);
|
||||||
println_serial("\nWelcome to Bootle OS");
|
println_serial("\nWelcome to Bootle OS");
|
||||||
println_serial("All code GPL licensed and freely available on git.mtgmonkey.net");
|
println_serial("All code GPL licensed and freely available on git.mtgmonkey.net");
|
||||||
print_serial("Enjoy your time! Press "); print_serial(ANSI_RED); print_serial("ctrl+a x"); print_serial(ANSI_PINK); println_serial(" to escape Qemu");
|
print_serial("Enjoy your time! Press ");
|
||||||
|
print_serial(ANSI_RED);
|
||||||
|
print_serial("ctrl+a x");
|
||||||
|
print_serial(ANSI_PINK);
|
||||||
|
println_serial(" to escape Qemu");
|
||||||
print_serial(ANSI_CLEAR);
|
print_serial(ANSI_CLEAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,9 +45,7 @@ fn panic(_: &PanicInfo) -> ! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn halt() -> ! {
|
fn halt() -> ! {
|
||||||
unsafe {core::arch::asm!(
|
unsafe { core::arch::asm!("hlt") };
|
||||||
"hlt"
|
|
||||||
)};
|
|
||||||
halt()
|
halt()
|
||||||
}
|
}
|
||||||
|
|
||||||
7
bootler/CHANGELOG.md
Normal file
7
bootler/CHANGELOG.md
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## [0.1.0] - 2026-03-06
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- initialised CHANGELOG.md
|
||||||
43
bootler/README.md
Normal file
43
bootler/README.md
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
# bootler
|
||||||
|
|
||||||
|
hobby bootloader, 1-stage, legacy mode :p
|
||||||
|
|
||||||
|
run with `nix run git+https://git.mtgmonkey.net/andromeda/bootler#bootler`
|
||||||
|
|
||||||
|
### memory map
|
||||||
|
|
||||||
|
```
|
||||||
|
. .
|
||||||
|
: :
|
||||||
|
| longmode kernel |
|
||||||
|
+------ 0x00010000 ------+
|
||||||
|
| |
|
||||||
|
| |
|
||||||
|
+------ 0x00009000 ------+
|
||||||
|
| IDT |
|
||||||
|
+------ 0x00008000 ------+
|
||||||
|
| |
|
||||||
|
| |
|
||||||
|
+------ 0x00007E00 ------+
|
||||||
|
| bootloader (boot.asm) |
|
||||||
|
+------ 0x00007C00 ------+
|
||||||
|
| stack |
|
||||||
|
+------ 0x00005000 ------+
|
||||||
|
| PT |
|
||||||
|
+------ 0x00004000 ------+
|
||||||
|
| PDT |
|
||||||
|
+------ 0x00003000 ------+
|
||||||
|
| PDPT |
|
||||||
|
+------ 0x00002000 ------+
|
||||||
|
| PML4T |
|
||||||
|
+------ 0x00001000 ------+
|
||||||
|
| |
|
||||||
|
| |
|
||||||
|
+------ 0x00000500 ------+
|
||||||
|
| bios stuff |
|
||||||
|
+------ 0x00000000 ------+
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
this project follows [Common Changelog](https://common-changelog.org) guidelines
|
||||||
@@ -9,7 +9,7 @@ in
|
|||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
pname = "bootler";
|
pname = "bootler";
|
||||||
version = "0.1.0";
|
version = "0.1.0";
|
||||||
src = ../../.;
|
src = ./.;
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
${nasm}/bin/nasm asm/boot.asm -o boot.bin
|
${nasm}/bin/nasm asm/boot.asm -o boot.bin
|
||||||
${nasm}/bin/nasm asm/kernel.asm -o dummy.bin
|
${nasm}/bin/nasm asm/kernel.asm -o dummy.bin
|
||||||
12
flake.nix
12
flake.nix
@@ -18,20 +18,24 @@
|
|||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
pkgs = import nixpkgs {
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
pkgsWithRustOverlay = import nixpkgs {
|
||||||
inherit system;
|
inherit system;
|
||||||
overlays = [(import rust-overlay)];
|
overlays = [(import rust-overlay)];
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
packages.${system} = {
|
packages.${system} = {
|
||||||
bootler = pkgs.callPackage ./nix/pkgs/bootler.nix {};
|
bootler = pkgs.callPackage ./bootler/package.nix {};
|
||||||
bootle = pkgs.callPackage ./nix/pkgs/bootle.nix {
|
bootle = pkgsWithRustOverlay.callPackage ./bootle/package.nix {
|
||||||
naersk = naersk;
|
naersk = naersk;
|
||||||
bootler = self.packages.${system}.bootler;
|
bootler = self.packages.${system}.bootler;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
devShells.${system}.default = pkgs.mkShell {
|
devShells.${system}.default = pkgs.mkShell {
|
||||||
inputsFrom = [self.packages.${system}.default];
|
inputsFrom = [
|
||||||
|
self.packages.${system}.bootle
|
||||||
|
self.packages.${system}.bootler
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
{
|
|
||||||
stdenv,
|
|
||||||
nasm,
|
|
||||||
qemu,
|
|
||||||
...
|
|
||||||
}: let
|
|
||||||
bootImg = "boot";
|
|
||||||
in
|
|
||||||
stdenv.mkDerivation {
|
|
||||||
pname = "bootler";
|
|
||||||
version = "0.1.0";
|
|
||||||
src = ../.;
|
|
||||||
buildPhase = ''
|
|
||||||
${nasm}/bin/nasm asm/boot.asm -o boot.bin
|
|
||||||
${nasm}/bin/nasm asm/kernel.asm -o kernel.bin
|
|
||||||
|
|
||||||
dd if=/dev/zero of=${bootImg} bs=512 count=2
|
|
||||||
dd if=boot.bin of=${bootImg} conv=notrunc
|
|
||||||
dd if=kernel.bin of=${bootImg} bs=512 seek=1 conv=notrunc
|
|
||||||
'';
|
|
||||||
installPhase = ''
|
|
||||||
mkdir -p $out/bin
|
|
||||||
cp ${bootImg} $out/bin
|
|
||||||
|
|
||||||
# create emulation binary
|
|
||||||
cat<<EOF>$out/bin/bootler
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# create temp dir
|
|
||||||
mkdir -p ./.bootler
|
|
||||||
cp $(echo $out)/bin/${bootImg} ./.bootler/${bootImg}
|
|
||||||
chmod a+w ./.bootler/${bootImg}
|
|
||||||
|
|
||||||
# run image
|
|
||||||
${qemu}/bin/qemu-system-x86_64 \
|
|
||||||
-nographic \
|
|
||||||
-drive file=./.bootler/${bootImg},format=raw,index=0,media=disk
|
|
||||||
|
|
||||||
# clean up
|
|
||||||
rm ./.bootler -r
|
|
||||||
|
|
||||||
EOF
|
|
||||||
|
|
||||||
chmod +x $out/bin/${bootImg}
|
|
||||||
chmod +x $out/bin/bootler
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user