summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandromeda <andromeda@lenovo>2026-03-06 20:33:51 +0100
committerandromeda <andromeda@lenovo>2026-03-06 20:33:51 +0100
commit9c65697dd8119ec9cee13f57f870b07e305d27ec (patch)
tree27b61bd7a27df6e25db8b21dc0ee3daed01d79fb
parentfdf5bb9daf8574b7f993e2e38e400c35aedc3b96 (diff)
bunch of stuff idek
-rw-r--r--README.md46
-rw-r--r--bootle/.cargo/config.toml (renamed from .cargo/config.toml)0
-rw-r--r--bootle/CHANGELOG.md (renamed from CHANGELOG.md)0
-rw-r--r--bootle/Cargo.lock (renamed from Cargo.lock)0
-rw-r--r--bootle/Cargo.toml (renamed from Cargo.toml)0
-rw-r--r--bootle/README.md28
-rw-r--r--bootle/package.nix (renamed from nix/pkgs/bootle.nix)4
-rw-r--r--bootle/rust-toolchain.toml (renamed from rust-toolchain.toml)0
-rw-r--r--bootle/src/lib.rs (renamed from src/lib.rs)0
-rw-r--r--bootle/src/linker.ld (renamed from src/linker.ld)0
-rw-r--r--bootler/CHANGELOG.md7
-rw-r--r--bootler/README.md43
-rw-r--r--bootler/asm/boot.asm (renamed from asm/boot.asm)0
-rw-r--r--bootler/asm/kernel.asm (renamed from asm/kernel.asm)0
-rw-r--r--bootler/package.nix (renamed from nix/pkgs/bootler.nix)5
-rw-r--r--flake.nix16
-rw-r--r--nix/package.nix47
-rw-r--r--twasm/README.md32
-rw-r--r--twasm/asm/main.asm161
-rw-r--r--twasm/package.nix41
20 files changed, 329 insertions, 101 deletions
diff --git a/README.md b/README.md
index e206ab9..3a9246b 100644
--- a/README.md
+++ b/README.md
@@ -2,53 +2,15 @@ Call me Terry Davis because... actually please don't. I have visions: aspiration
# 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
-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`
-
-### memory map
-
-```
-+------ 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 ------+
-```
+status: gets to long mode, loads+jumps to kernel, starts idt and gdt... :)
---
diff --git a/.cargo/config.toml b/bootle/.cargo/config.toml
index 74cdc7b..74cdc7b 100644
--- a/.cargo/config.toml
+++ b/bootle/.cargo/config.toml
diff --git a/CHANGELOG.md b/bootle/CHANGELOG.md
index 53c30a7..53c30a7 100644
--- a/CHANGELOG.md
+++ b/bootle/CHANGELOG.md
diff --git a/Cargo.lock b/bootle/Cargo.lock
index f69efc7..f69efc7 100644
--- a/Cargo.lock
+++ b/bootle/Cargo.lock
diff --git a/Cargo.toml b/bootle/Cargo.toml
index c4d5b40..c4d5b40 100644
--- a/Cargo.toml
+++ b/bootle/Cargo.toml
diff --git a/bootle/README.md b/bootle/README.md
new file mode 100644
index 0000000..da47027
--- /dev/null
+++ b/bootle/README.md
@@ -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
diff --git a/nix/pkgs/bootle.nix b/bootle/package.nix
index 99bdb55..a5de5eb 100644
--- a/nix/pkgs/bootle.nix
+++ b/bootle/package.nix
@@ -6,14 +6,14 @@
qemu,
...
}: let
- rust-toolchain = rust-bin.fromRustupToolchainFile ../../rust-toolchain.toml;
+ rust-toolchain = rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
naersk' = callPackage naersk {
cargo = rust-toolchain;
rustc = rust-toolchain;
clippy = rust-toolchain;
};
in (naersk'.buildPackage {
- src = ../../.;
+ src = ./.;
# deps for rust-src
additionalCargoLock = "${rust-toolchain.availableComponents.rust-src}/lib/rustlib/src/rust/library/Cargo.lock";
diff --git a/rust-toolchain.toml b/bootle/rust-toolchain.toml
index 22068c5..22068c5 100644
--- a/rust-toolchain.toml
+++ b/bootle/rust-toolchain.toml
diff --git a/src/lib.rs b/bootle/src/lib.rs
index adc1aab..adc1aab 100644
--- a/src/lib.rs
+++ b/bootle/src/lib.rs
diff --git a/src/linker.ld b/bootle/src/linker.ld
index b523bc5..b523bc5 100644
--- a/src/linker.ld
+++ b/bootle/src/linker.ld
diff --git a/bootler/CHANGELOG.md b/bootler/CHANGELOG.md
new file mode 100644
index 0000000..eff4a62
--- /dev/null
+++ b/bootler/CHANGELOG.md
@@ -0,0 +1,7 @@
+# Changelog
+
+## [0.1.0] - 2026-03-06
+
+### Added
+
+- initialised CHANGELOG.md
diff --git a/bootler/README.md b/bootler/README.md
new file mode 100644
index 0000000..bf50ce2
--- /dev/null
+++ b/bootler/README.md
@@ -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
diff --git a/asm/boot.asm b/bootler/asm/boot.asm
index 5291d58..5291d58 100644
--- a/asm/boot.asm
+++ b/bootler/asm/boot.asm
diff --git a/asm/kernel.asm b/bootler/asm/kernel.asm
index b4cbb30..b4cbb30 100644
--- a/asm/kernel.asm
+++ b/bootler/asm/kernel.asm
diff --git a/nix/pkgs/bootler.nix b/bootler/package.nix
index 3e5d2e4..c4faf29 100644
--- a/nix/pkgs/bootler.nix
+++ b/bootler/package.nix
@@ -9,19 +9,18 @@ in
stdenv.mkDerivation {
pname = "bootler";
version = "0.1.0";
- src = ../../.;
+ src = ./.;
buildPhase = ''
${nasm}/bin/nasm asm/boot.asm -o boot.bin
${nasm}/bin/nasm asm/kernel.asm -o dummy.bin
- dd if=/dev/zero of=${bootImg} bs=512 count=2
+ dd if=/dev/zero of=${bootImg} bs=512 count=2880
dd if=boot.bin of=${bootImg} conv=notrunc
dd if=dummy.bin of=${bootImg} bs=512 seek=1 conv=notrunc
'';
installPhase = ''
mkdir -p $out/bin
cp boot.bin $out/bin
- cp dummy.bin $out/bin
cp ${bootImg} $out/bin
# create emulation binary
diff --git a/flake.nix b/flake.nix
index 81b9289..1ce6341 100644
--- a/flake.nix
+++ b/flake.nix
@@ -18,15 +18,16 @@
...
}: let
system = "x86_64-linux";
- pkgs = import nixpkgs {
- inherit system;
- overlays = [(import rust-overlay)];
- };
+ pkgs = nixpkgs.legacyPackages.${system};
+ pkgsWithRustOverlay = pkgs.extend (import rust-overlay);
in {
packages.${system} = {
- bootler = pkgs.callPackage ./nix/pkgs/bootler.nix {};
- bootle = pkgs.callPackage ./nix/pkgs/bootle.nix {
- naersk = naersk;
+ bootler = pkgs.callPackage ./bootler/package.nix {};
+ bootle = pkgsWithRustOverlay.callPackage ./bootle/package.nix {
+ inherit naersk;
+ bootler = self.packages.${system}.bootler;
+ };
+ twasm = pkgs.callPackage ./twasm/package.nix {
bootler = self.packages.${system}.bootler;
};
};
@@ -34,6 +35,7 @@
inputsFrom = [
self.packages.${system}.bootle
self.packages.${system}.bootler
+ self.packages.${system}.twasm
];
};
};
diff --git a/nix/package.nix b/nix/package.nix
deleted file mode 100644
index 3d56a51..0000000
--- a/nix/package.nix
+++ /dev/null
@@ -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
- '';
- }
diff --git a/twasm/README.md b/twasm/README.md
new file mode 100644
index 0000000..c7a2786
--- /dev/null
+++ b/twasm/README.md
@@ -0,0 +1,32 @@
+# twasm
+
+this will be a self hosted, very minimal subset of 64 bit asm
+
+### goals
+
+I want to compile Bootler and Twasm with the Twasm assembler
+
+### memory map
+
+```
++------ 0x00100000 ------+
+| hardware, bios stuff |
++------ 0x00080000 ------+
+| output binary |
++------ 0x00070000 ------+
+| token table |
++------ 0x00060000 ------+
+| |
+| |
++------------------------+
+| input |
++------------------------+ this is lined up to a sector
+| | and this is less than a sector
++------------------------+
+| assembler |
++------ 0x00010000 ------+
+| bootloader, bios, etc. |
++------------------------+
+```
+
+each word represents a token on the token table.
diff --git a/twasm/asm/main.asm b/twasm/asm/main.asm
new file mode 100644
index 0000000..4cd4e1f
--- /dev/null
+++ b/twasm/asm/main.asm
@@ -0,0 +1,161 @@
+LOAD_ADDR equ 0x00010000 ; address this program is loaded at
+
+TOKEN_TABLE_ADDR equ 0x00060000 ; address the token table is loaded at
+TOKEN_TABLE_SIZE equ 0x1000 ; max length of table
+
+TEST_ARENA_ADDR equ 0x00060000 ; address to run tests at
+TEST_ARENA_SIZE equ 0x1000 ; maximum size tests can use
+
+OUTPUT_ADDR equ 0x00070000 ; address of outputed binary
+OUTPUT_SIZE equ 0x1000 ; max length of outputed binary
+
+[bits 64]
+[org LOAD_ADDR]
+
+start:
+ mov rsi, msg_welcome
+ call print
+
+ call run_tests
+
+ jmp halt
+
+;
+; tokenising
+;
+
+; copy_token
+;
+; description:
+; copies a token from one spot in memory to another
+; and returns metadata about that token
+;
+; parameters:
+; rdi -> start of asm command to be read
+; rsi -> start of buffer to be written
+;
+; returned:
+copy_token:
+ mov rax, rdi
+ .loop:
+ cmp al, " "
+ je .continue
+ jne .break
+ .continue:
+ call copy_byte
+ .break:
+ inc rax
+ ret
+
+; copy_byte
+;
+; description:
+; copies a byte from one spot in memory to another
+;
+; parameters:
+; rdi -> word to be read
+; rsi -> word to be written
+;
+; returned:
+; al = byte that was read
+copy_byte:
+ mov al, [rdi]
+ mov [rsi], al
+ ret
+
+;
+; utilities
+;
+
+; print
+;
+; description:
+; prints a null-terminated string
+;
+; parameters:
+; rsi -> start of null-terminated string
+; dx = port to output to
+print:
+ .loop:
+ mov al, [rsi]
+ test al, al
+ jz .done
+ out dx, al
+ inc rsi
+ jmp .loop
+ .done:
+ ret
+
+; halt
+;
+; description:
+; halts the program, silly :)
+halt:
+ mov rsi, msg_halt
+ call print
+ hlt
+ jmp halt
+
+;
+; tests
+;
+
+; run_tests
+;
+; description:
+; runs all tests
+;
+; parameters:
+; dx = port to output to
+run_tests:
+ mov rsi, .msg
+ call print
+
+ call test_copy_byte
+
+ ret
+ .msg db "running test suite...", 0x0D, 0x0A, 0x00
+
+; test_copy_byte
+;
+; description:
+; makes sure copy_byte function works by testing the following
+; - that it copies one byte to a specified memory address
+; - that it returns the copied byte in al
+;
+; parameters:
+; dx = port to output to
+test_copy_byte:
+ mov rsi, .msg
+ call print
+
+ mov rdi, test_byte ; byte to be copied
+ mov rsi, TEST_ARENA_ADDR ; location of test
+ call copy_byte
+
+ mov cx, [rsi]
+ cmp ax, cx ; compare returned byte to copied byte
+ jne .fail
+ je .pass
+
+ .pass:
+ mov rsi, msg_pass
+ call print
+ ret
+ .fail:
+ mov rsi, msg_fail
+ call print
+ ret
+ .msg db "test_copy_byte...", 0x00
+
+;
+; data
+;
+
+msg_welcome db "Welcome to Twasm", 0x0D, 0x0A, 0x00
+msg_halt db "halted.", 0x0D, 0x0A, 0x00
+msg_pass db "passed.", 0x0D, 0x0A, 0x00
+msg_fail db "failed.", 0x0D, 0x0A, 0x00
+
+test_byte db "T"
+test_token db "Test Token" ; two tokens, one followed by a space and one by nothing
diff --git a/twasm/package.nix b/twasm/package.nix
new file mode 100644
index 0000000..f621780
--- /dev/null
+++ b/twasm/package.nix
@@ -0,0 +1,41 @@
+{
+ bootler,
+ stdenv,
+ nasm,
+ qemu,
+ ...
+}:
+stdenv.mkDerivation {
+ pname = "twasm";
+ version = "0.1.0";
+ src = ./.;
+ buildPhase = ''
+ ${nasm}/bin/nasm asm/main.asm -o out.bin
+ '';
+ installPhase = ''
+ dd if=/dev/zero of=disk bs=512 count=2880
+ dd if=${bootler}/bin/boot.bin of=disk conv=notrunc
+ dd if=out.bin of=disk bs=512 seek=1 conv=notrunc
+
+ mkdir -p $out/bin
+
+ cat<<EOF>$out/bin/twasm
+ #!/usr/bin/env bash
+
+ mkdir -p ./.bootle
+ cp $(echo $out)/bin/disk ./.bootle/disk
+ chmod a+w ./.bootle/disk
+
+ ${qemu}/bin/qemu-system-x86_64 \
+ -nographic \
+ -drive file=./.bootle/disk,format=raw,index=0,media=disk
+
+ rm ./.bootle -r
+ EOF
+
+ chmod +x $out/bin/twasm
+
+ cp out.bin $out/bin
+ cp disk $out/bin
+ '';
+}