summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.cargo/config.toml16
-rw-r--r--Cargo.lock921
-rw-r--r--Cargo.toml36
-rw-r--r--OVMF_VARS.4m.fdbin540672 -> 0 bytes
-rw-r--r--README.md24
-rw-r--r--kernel/Cargo.toml8
-rw-r--r--kernel/src/io.rs2
-rw-r--r--kernel/src/io/input.rs (renamed from src/io/render/fb/graphic.rs)0
-rw-r--r--kernel/src/io/output.rs (renamed from src/io.rs)1
-rw-r--r--kernel/src/io/output/render.rs0
-rw-r--r--kernel/src/io/output/serial.rs1
-rw-r--r--kernel/src/io/output/serial/uart_16550.rs15
-rw-r--r--kernel/src/io/render/fb.rs (renamed from src/io/render/fb.rs)0
-rw-r--r--kernel/src/io/render/fb/graphic.rs0
-rw-r--r--kernel/src/io/render/fb/text.rs (renamed from src/io/render/fb/text.rs)0
-rw-r--r--kernel/src/lib.rs (renamed from src/lib.rs)1
-rw-r--r--kernel/src/main.rs16
-rw-r--r--kernel/src/pm.rs10
-rw-r--r--kernel/src/pm/panic.rs8
m---------limine0
-rw-r--r--limine.conf6
-rw-r--r--linker.ld47
-rw-r--r--qemu.log5
-rw-r--r--qemu_output.txt4
-rw-r--r--readelf.out23
-rw-r--r--report.typ3
-rw-r--r--src/io/render.rs1
-rw-r--r--src/main.rs76
-rw-r--r--target.json19
-rw-r--r--x/.cargo/config.toml2
-rw-r--r--x/Cargo.toml11
-rw-r--r--x/build.rs25
-rw-r--r--x/src/main.rs62
33 files changed, 1083 insertions, 260 deletions
diff --git a/.cargo/config.toml b/.cargo/config.toml
index 12f8cca..dfa84e8 100644
--- a/.cargo/config.toml
+++ b/.cargo/config.toml
@@ -1,16 +1,2 @@
-[build]
-target = "target.json"
-
[unstable]
-build-std = ["core", "compiler_builtins", "alloc"]
-build-std-features = ["compiler-builtins-mem"]
-
-[target.target]
-# Limage compatibility with `cargo run`
-runner = "limage runner"
-# Required for Cargo to pass the correct flags to the linker before running `limage runner`
-rustflags = ["-C", "relocation-model=static", "-C", "link-arg=linker.ld", "-C", "code-model=kernel"]
-
-# [target.target]
-# rustflags = ["-C", "link-arg=-Tlinker.ld", "-C", "link-arg=-zmax-page-size=0x1000"]
-# runner = "./run.sh "
+bindeps = true
diff --git a/Cargo.lock b/Cargo.lock
index c3ebf11..7da61da 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3,21 +3,926 @@
version = 4
[[package]]
-name = "font8x8"
+name = "anyhow"
+version = "1.0.104"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470"
+
+[[package]]
+name = "base16ct"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fd307490d624467aa6f74b0eabb77633d1f758a7b25f12bceb0b22e08d9726f6"
+
+[[package]]
+name = "base64"
+version = "0.23.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5"
+
+[[package]]
+name = "bincode"
+version = "1.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"
+dependencies = [
+ "serde",
+]
+
+[[package]]
+name = "bitflags"
+version = "1.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
+
+[[package]]
+name = "bitflags"
+version = "2.13.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da"
+
+[[package]]
+name = "bitvec"
+version = "1.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ddcec3d12c579d40898fe0a9a358a803c23e9c52ca3c425707f81c9436211837"
+dependencies = [
+ "funty",
+ "radium",
+ "tap",
+ "wyz",
+]
+
+[[package]]
+name = "block-buffer"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d2f6c7dbe95a6ed67ad9f18e57daf93a2f034c524b99fd2b76d18fdfeb6660aa"
+dependencies = [
+ "hybrid-array",
+]
+
+[[package]]
+name = "bootloader"
+version = "0.11.17"
+source = "git+https://github.com/rust-osdev/bootloader#3d7f72e36d4101ecf78b70cef2475d700bb01721"
+dependencies = [
+ "anyhow",
+ "bootloader-boot-config",
+ "fatfs",
+ "gpt",
+ "llvm-tools",
+ "mbrman",
+ "serde_json",
+ "tempfile",
+]
+
+[[package]]
+name = "bootloader-boot-config"
+version = "0.11.17"
+source = "git+https://github.com/rust-osdev/bootloader#3d7f72e36d4101ecf78b70cef2475d700bb01721"
+dependencies = [
+ "serde",
+]
+
+[[package]]
+name = "bootloader_api"
+version = "0.11.17"
+source = "git+https://github.com/rust-osdev/bootloader#3d7f72e36d4101ecf78b70cef2475d700bb01721"
+
+[[package]]
+name = "bumpalo"
+version = "3.20.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"
+
+[[package]]
+name = "byteorder"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
+
+[[package]]
+name = "bytes"
+version = "1.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04"
+
+[[package]]
+name = "cc"
+version = "1.4.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "005ec2760ca554fae18df7a11195552ec576cd665632a881bc011d5bb2fd4d80"
+dependencies = [
+ "find-msvc-tools",
+ "shlex",
+]
+
+[[package]]
+name = "cfg-if"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
+
+[[package]]
+name = "const-oid"
+version = "0.10.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c"
+
+[[package]]
+name = "cpufeatures"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "875488b8711a968268c7cf5d139578713097ca4635a76044e8fe8eedf831d07e"
+checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "crc"
+version = "3.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5eb8a2a1cd12ab0d987a5d5e825195d372001a4094a0376319d5a0ad71c1ba0d"
+dependencies = [
+ "crc-catalog",
+]
+
+[[package]]
+name = "crc-catalog"
+version = "2.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "217698eaf96b4a3f0bc4f3662aaa55bdf913cd54d7204591faa790070c6d0853"
+
+[[package]]
+name = "crypto-common"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453"
+dependencies = [
+ "hybrid-array",
+]
+
+[[package]]
+name = "digest"
+version = "0.11.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2"
+dependencies = [
+ "block-buffer",
+ "const-oid",
+ "crypto-common",
+]
+
+[[package]]
+name = "errno"
+version = "0.3.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
+dependencies = [
+ "libc",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "fastrand"
+version = "2.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223"
+
+[[package]]
+name = "fatfs"
+version = "0.3.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "05669f8e7e2d7badc545c513710f0eba09c2fbef683eb859fd79c46c355048e0"
+dependencies = [
+ "bitflags 1.3.2",
+ "byteorder",
+ "log",
+]
+
+[[package]]
+name = "filetime"
+version = "0.2.29"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c287a33c7f0a620c38e641e7f60827713987b3c0f26e8ddc9462cc69cf75759"
+dependencies = [
+ "cfg-if",
+ "libc",
+]
+
+[[package]]
+name = "find-msvc-tools"
+version = "0.1.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3e0f1c7c3a72c66fd80abe965175f7523475c0489a87d3ff9d6e8c87d87a9d2d"
+
+[[package]]
+name = "funty"
+version = "2.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c"
+
+[[package]]
+name = "futures-core"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e"
+
+[[package]]
+name = "futures-task"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd"
+
+[[package]]
+name = "futures-util"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc"
+dependencies = [
+ "futures-core",
+ "futures-task",
+ "pin-project-lite",
+ "slab",
+]
+
+[[package]]
+name = "getrandom"
+version = "0.2.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "wasi",
+]
+
+[[package]]
+name = "getrandom"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "r-efi",
+]
+
+[[package]]
+name = "gpt"
+version = "3.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8283e7331b8c93b9756e0cfdbcfb90312852f953c6faf9bf741e684cc3b6ad69"
+dependencies = [
+ "bitflags 2.13.1",
+ "crc",
+ "log",
+ "uuid",
+]
+
+[[package]]
+name = "http"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0"
+dependencies = [
+ "bytes",
+ "itoa",
+]
+
+[[package]]
+name = "httparse"
+version = "1.10.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87"
+
+[[package]]
+name = "hybrid-array"
+version = "0.4.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "707114b52a152fa7bdb290cd7cd5912d9467273b6d74e21b8d81aca1f8533f6b"
+dependencies = [
+ "typenum",
+]
+
+[[package]]
+name = "itoa"
+version = "1.0.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
+
+[[package]]
+name = "js-sys"
+version = "0.3.105"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ce57d20d1ea864ce2ac172ab472d409214f4fd359f0b2a2775abdf522e2af99e"
+dependencies = [
+ "cfg-if",
+ "futures-util",
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "kernel"
+version = "0.1.0"
+dependencies = [
+ "bootloader_api",
+ "uart_16550",
+]
+
+[[package]]
+name = "libc"
+version = "0.2.189"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
+
+[[package]]
+name = "linux-raw-sys"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"
+
+[[package]]
+name = "llvm-tools"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "955be5d0ca0465caf127165acb47964f911e2bc26073e865deb8be7189302faf"
+
+[[package]]
+name = "log"
+version = "0.4.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6"
+
+[[package]]
+name = "lzma-rs"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "297e814c836ae64db86b36cf2a557ba54368d03f6afcd7d947c266692f71115e"
+dependencies = [
+ "byteorder",
+ "crc",
+]
+
+[[package]]
+name = "mbrman"
+version = "0.5.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b1fc3bff63c208d4a14301c6cb807af2d1a0760052584ce3f9a737b55fb85498"
+dependencies = [
+ "bincode",
+ "bitvec",
+ "serde",
+ "serde-big-array",
+ "thiserror",
+]
+
+[[package]]
+name = "memchr"
+version = "2.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
+
+[[package]]
+name = "once_cell"
+version = "1.21.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
+
+[[package]]
+name = "ovmf-prebuilt"
+version = "0.2.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8b2ed5d406bc56f93035547fe364feb90395682dd8cc9efea09e806f8f845a17"
+dependencies = [
+ "base16ct",
+ "log",
+ "lzma-rs",
+ "sha2",
+ "tar",
+ "ureq",
+]
+
+[[package]]
+name = "percent-encoding"
+version = "2.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
+
+[[package]]
+name = "pin-project-lite"
+version = "0.2.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.107"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.47"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "r-efi"
+version = "6.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
+
+[[package]]
+name = "radium"
+version = "0.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09"
+
+[[package]]
+name = "ring"
+version = "0.17.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7"
+dependencies = [
+ "cc",
+ "cfg-if",
+ "getrandom 0.2.17",
+ "libc",
+ "untrusted",
+ "windows-sys 0.52.0",
+]
+
+[[package]]
+name = "rustix"
+version = "1.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190"
+dependencies = [
+ "bitflags 2.13.1",
+ "errno",
+ "libc",
+ "linux-raw-sys",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "rustls"
+version = "0.23.43"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0283386ce02abc0151e1761d08802dfe86c173b0b494af5cbc086574e453da06"
+dependencies = [
+ "log",
+ "once_cell",
+ "ring",
+ "rustls-pki-types",
+ "rustls-webpki",
+ "subtle",
+ "zeroize",
+]
+
+[[package]]
+name = "rustls-pki-types"
+version = "1.15.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2f4925028c7eb5d1fcdaf196971378ed9d2c1c4efc7dc5d011256f76c99c0a96"
+dependencies = [
+ "zeroize",
+]
+
+[[package]]
+name = "rustls-webpki"
+version = "0.103.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f3c3cf1d8b1e7d4927e2d154c3fcb02979afb9939629c62cd9048d4f07b60ac2"
+dependencies = [
+ "ring",
+ "rustls-pki-types",
+ "untrusted",
+]
+
+[[package]]
+name = "rustversion"
+version = "1.0.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
+
+[[package]]
+name = "serde"
+version = "1.0.229"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
+dependencies = [
+ "serde_core",
+ "serde_derive",
+]
+
+[[package]]
+name = "serde-big-array"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "11fc7cc2c76d73e0f27ee52abbd64eec84d46f370c88371120433196934e4b7f"
+dependencies = [
+ "serde",
+]
[[package]]
-name = "limine"
-version = "0.6.5"
+name = "serde_core"
+version = "1.0.229"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "29363c0f37e66e18575fadf7141c56ee7ea04ae5fecbeb25eff303f77af203a9"
+checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
+dependencies = [
+ "serde_derive",
+]
[[package]]
-name = "rust-os"
+name = "serde_derive"
+version = "1.0.229"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.5",
+]
+
+[[package]]
+name = "serde_json"
+version = "1.0.151"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14"
+dependencies = [
+ "itoa",
+ "memchr",
+ "serde",
+ "serde_core",
+ "zmij",
+]
+
+[[package]]
+name = "sha2"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "446ba717509524cb3f22f17ecc096f10f4822d76ab5c0b9822c5f9c284e825f4"
+dependencies = [
+ "cfg-if",
+ "cpufeatures",
+ "digest",
+]
+
+[[package]]
+name = "shlex"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
+
+[[package]]
+name = "slab"
+version = "0.4.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
+
+[[package]]
+name = "subtle"
+version = "2.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
+
+[[package]]
+name = "syn"
+version = "2.0.119"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "syn"
+version = "3.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "12df2e0110f65b775f769bb17ef989067a1d931b2eb822bd4346631eeada89f9"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "tap"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
+
+[[package]]
+name = "tar"
+version = "0.4.46"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3f6221d9a6003c78398e3b239969f352578258df48c8eb051caadae0015bc840"
+dependencies = [
+ "filetime",
+ "libc",
+ "xattr",
+]
+
+[[package]]
+name = "tempfile"
+version = "3.27.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
+dependencies = [
+ "fastrand",
+ "getrandom 0.4.3",
+ "once_cell",
+ "rustix",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "thiserror"
+version = "1.0.69"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
+dependencies = [
+ "thiserror-impl",
+]
+
+[[package]]
+name = "thiserror-impl"
+version = "1.0.69"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "typenum"
+version = "1.20.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
+
+[[package]]
+name = "uart_16550"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f9c24d1751f909d9e2d192475ca5527964e13dbc3126ce20c288dfa8f3a3e734"
+dependencies = [
+ "bitflags 2.13.1",
+]
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.24"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
+
+[[package]]
+name = "untrusted"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
+
+[[package]]
+name = "ureq"
+version = "3.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "972d7902c8735f2695410b8aed7df6ed12a47394aa1c8d7af49f0497b731a94d"
+dependencies = [
+ "base64",
+ "log",
+ "percent-encoding",
+ "rustls",
+ "rustls-pki-types",
+ "ureq-proto",
+ "utf8-zero",
+ "webpki-roots",
+]
+
+[[package]]
+name = "ureq-proto"
+version = "0.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "da5f78b09e6941e1a0f2e30e695e4b120377b54d5e0aec11b594bb57b3971613"
+dependencies = [
+ "base64",
+ "http",
+ "httparse",
+ "log",
+]
+
+[[package]]
+name = "utf8-zero"
+version = "0.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b8c0a043c9540bae7c578c88f91dda8bd82e59ae27c21baca69c8b191aaf5a6e"
+
+[[package]]
+name = "uuid"
+version = "1.26.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b5772d71c9be8a8a6ac2117d949c5b224c1b72241bb611d9a3012edcf8af7812"
+dependencies = [
+ "getrandom 0.4.3",
+ "js-sys",
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "wasi"
+version = "0.11.1+wasi-snapshot-preview1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
+
+[[package]]
+name = "wasm-bindgen"
+version = "0.2.128"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "aecb87a33d3b0c5e3b7aa46336eaf486cffafbd281b195e4c8b80d50df2351bf"
+dependencies = [
+ "cfg-if",
+ "once_cell",
+ "rustversion",
+ "wasm-bindgen-macro",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-macro"
+version = "0.2.128"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a690d511e3c1a8b3a55e33511e3c2c00c78415cd23650f32b808627f5696b9ed"
+dependencies = [
+ "quote",
+ "wasm-bindgen-macro-support",
+]
+
+[[package]]
+name = "wasm-bindgen-macro-support"
+version = "0.2.128"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "411e4887f0071ef2d2164a9d5fdf2d20efbef78fccd3a78b0c10a1dc5295e48a"
+dependencies = [
+ "bumpalo",
+ "proc-macro2",
+ "quote",
+ "syn 3.0.5",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-shared"
+version = "0.2.128"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "81941cd78d0c92026c33e5e01312845a4cb1e9af3407f9134b100dd03144103e"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "webpki-roots"
+version = "1.0.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7dcd9d09a39985f5344844e66b0c530a33843579125f23e21e9f0f220850f22a"
+dependencies = [
+ "rustls-pki-types",
+]
+
+[[package]]
+name = "windows-link"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
+
+[[package]]
+name = "windows-sys"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
+dependencies = [
+ "windows-targets",
+]
+
+[[package]]
+name = "windows-sys"
+version = "0.61.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
+dependencies = [
+ "windows-link",
+]
+
+[[package]]
+name = "windows-targets"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
+dependencies = [
+ "windows_aarch64_gnullvm",
+ "windows_aarch64_msvc",
+ "windows_i686_gnu",
+ "windows_i686_gnullvm",
+ "windows_i686_msvc",
+ "windows_x86_64_gnu",
+ "windows_x86_64_gnullvm",
+ "windows_x86_64_msvc",
+]
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
+
+[[package]]
+name = "windows_i686_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
+
+[[package]]
+name = "wyz"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed"
+dependencies = [
+ "tap",
+]
+
+[[package]]
+name = "x"
version = "0.1.0"
dependencies = [
- "font8x8",
- "limine",
+ "bootloader",
+ "kernel",
+ "ovmf-prebuilt",
+]
+
+[[package]]
+name = "xattr"
+version = "1.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32e45ad4206f6d2479085147f02bc2ef834ac85886624a23575ae137c8aa8156"
+dependencies = [
+ "libc",
+ "rustix",
]
+
+[[package]]
+name = "zeroize"
+version = "1.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e"
+
+[[package]]
+name = "zmij"
+version = "1.0.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
diff --git a/Cargo.toml b/Cargo.toml
index 4f49da8..335cae7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,32 +1,4 @@
-[package]
-name = "rust-os"
-version = "0.1.0"
-edition = "2024"
-
-[[bin]]
-name = "rust-os"
-test = false
-bench = false
-
-[lib]
-test = false
-
-[profile.dev]
-panic = "abort"
-
-[profile.release]
-panic = "abort"
-
-[dependencies]
-font8x8 = { version = "0.3.1", default-features = false, features = ["unicode"] }
-limine = "0.6.5"
-
-[package.metadata.limage]
-run-command = [
- "qemu-system-x86_64",
- "-drive", "if=pflash,format=raw,readonly=on,file=/usr/share/edk2-ovmf/x64/OVMF_CODE.4m.fd",
- "-drive", "if=pflash,format=raw,file=OVMF_VARS.4m.fd",
- "-no-reboot",
- "-d", "int",
- "-cdrom", "{}"
-]
+[workspace]
+resolver = "3"
+members = ["kernel", "x"]
+default-members = ["x"]
diff --git a/OVMF_VARS.4m.fd b/OVMF_VARS.4m.fd
deleted file mode 100644
index c363987..0000000
--- a/OVMF_VARS.4m.fd
+++ /dev/null
Binary files differ
diff --git a/README.md b/README.md
deleted file mode 100644
index bb7be93..0000000
--- a/README.md
+++ /dev/null
@@ -1,24 +0,0 @@
-# Rust OS
-
-A bare-metal Rust OS kernel utilizing the Limine bootloader protocol v8.x.
-
-This repository demonstrates how to set up a minimal `x86_64` rust kernel that uses `limine` `0.6.5` to retrieve a framebuffer, draw a built-in bitmap font (`font8x8`) to print "Hello World!" on the screen, and output "Hello World!" to the serial port as a fallback.
-
-## Building and Running
-
-1. **Build and Run**
- ```bash
- cargo run
- ```
- The `runner.sh` script will automatically:
- - Build the Rust kernel via Cargo
- - Clone the Limine binary release
- - Build a bootable ISO with `xorriso` and deploy `limine`
- - Boot the ISO in QEMU
-
-## Design Notes
-
-- The Limine crate version `0.6.5` relies on raw protocol structures such as `BaseRevision`, `RequestsStartMarker`, `RequestsEndMarker`, and the standard `FramebufferRequest`.
-- Built-in terminal requests were dropped from Limine 5.x+ and therefore they do not exist in the `limine` `0.6.5` crate.
-- We utilize `font8x8` to iterate over character glyphs and plot the pixels directly to the `Framebuffer` slice obtained via Limine.
-- Serial port output is written to `0x3F8` using inline `outb` assembly.
diff --git a/kernel/Cargo.toml b/kernel/Cargo.toml
new file mode 100644
index 0000000..fda2a4a
--- /dev/null
+++ b/kernel/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "kernel"
+version = "0.1.0"
+edition = "2024"
+
+[dependencies]
+bootloader_api = { git = "https://github.com/rust-osdev/bootloader" }
+uart_16550 = "0.8.0"
diff --git a/kernel/src/io.rs b/kernel/src/io.rs
new file mode 100644
index 0000000..7d1a548
--- /dev/null
+++ b/kernel/src/io.rs
@@ -0,0 +1,2 @@
+pub mod input;
+pub mod output;
diff --git a/src/io/render/fb/graphic.rs b/kernel/src/io/input.rs
index e69de29..e69de29 100644
--- a/src/io/render/fb/graphic.rs
+++ b/kernel/src/io/input.rs
diff --git a/src/io.rs b/kernel/src/io/output.rs
index cf25e6c..19bad9c 100644
--- a/src/io.rs
+++ b/kernel/src/io/output.rs
@@ -1 +1,2 @@
pub mod render;
+pub mod serial;
diff --git a/kernel/src/io/output/render.rs b/kernel/src/io/output/render.rs
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/kernel/src/io/output/render.rs
diff --git a/kernel/src/io/output/serial.rs b/kernel/src/io/output/serial.rs
new file mode 100644
index 0000000..0fb7194
--- /dev/null
+++ b/kernel/src/io/output/serial.rs
@@ -0,0 +1 @@
+pub mod uart_16550;
diff --git a/kernel/src/io/output/serial/uart_16550.rs b/kernel/src/io/output/serial/uart_16550.rs
new file mode 100644
index 0000000..984854a
--- /dev/null
+++ b/kernel/src/io/output/serial/uart_16550.rs
@@ -0,0 +1,15 @@
+pub enum SerialPortAddress {
+ Com1 = 0x3F8,
+ Com2 = 0x2F8,
+ Com3 = 0x3E8,
+ Com4 = 0x2E8,
+}
+
+#[derive(Default)]
+pub struct Uart16550 {}
+
+impl Uart16550 {
+ pub fn new() -> Self {
+ Self {}
+ }
+}
diff --git a/src/io/render/fb.rs b/kernel/src/io/render/fb.rs
index 2924838..2924838 100644
--- a/src/io/render/fb.rs
+++ b/kernel/src/io/render/fb.rs
diff --git a/kernel/src/io/render/fb/graphic.rs b/kernel/src/io/render/fb/graphic.rs
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/kernel/src/io/render/fb/graphic.rs
diff --git a/src/io/render/fb/text.rs b/kernel/src/io/render/fb/text.rs
index 8b13789..8b13789 100644
--- a/src/io/render/fb/text.rs
+++ b/kernel/src/io/render/fb/text.rs
diff --git a/src/lib.rs b/kernel/src/lib.rs
index f0111d3..2832ab2 100644
--- a/src/lib.rs
+++ b/kernel/src/lib.rs
@@ -1,3 +1,4 @@
#![no_std]
pub mod io;
+pub mod pm;
diff --git a/kernel/src/main.rs b/kernel/src/main.rs
new file mode 100644
index 0000000..bfa20e6
--- /dev/null
+++ b/kernel/src/main.rs
@@ -0,0 +1,16 @@
+#![no_std]
+#![no_main]
+#![feature(used_with_arg)]
+
+// extern crate alloc;
+
+use bootloader_api::{BootInfo, BootloaderConfig, entry_point};
+use kernel::pm::hcf;
+
+const CONFIG: BootloaderConfig = BootloaderConfig::new_default();
+
+fn kmain(boot_info: &'static mut BootInfo) -> ! {
+ hcf()
+}
+
+entry_point!(kmain);
diff --git a/kernel/src/pm.rs b/kernel/src/pm.rs
new file mode 100644
index 0000000..1b45b84
--- /dev/null
+++ b/kernel/src/pm.rs
@@ -0,0 +1,10 @@
+pub mod panic;
+
+pub fn hcf() -> ! {
+ unsafe {
+ core::arch::asm!("cli");
+ loop {
+ core::arch::asm!("hlt");
+ }
+ }
+}
diff --git a/kernel/src/pm/panic.rs b/kernel/src/pm/panic.rs
new file mode 100644
index 0000000..6446cd9
--- /dev/null
+++ b/kernel/src/pm/panic.rs
@@ -0,0 +1,8 @@
+use core::panic::PanicInfo;
+
+use crate::pm::hcf;
+
+#[panic_handler]
+fn panic(_info: &PanicInfo) -> ! {
+ hcf()
+}
diff --git a/limine b/limine
deleted file mode 160000
-Subproject aad3edd370955449717a334f0289dee10e2c5f0
diff --git a/limine.conf b/limine.conf
deleted file mode 100644
index be16e24..0000000
--- a/limine.conf
+++ /dev/null
@@ -1,6 +0,0 @@
-timeout: 0
-serial: yes
-
-/Rust OS
- protocol: limine
- kernel_path: boot():/boot/kernel/kernel
diff --git a/linker.ld b/linker.ld
deleted file mode 100644
index f71177b..0000000
--- a/linker.ld
+++ /dev/null
@@ -1,47 +0,0 @@
-OUTPUT_FORMAT(elf64-x86-64)
-OUTPUT_ARCH(i386:x86-64)
-
-ENTRY(_start)
-
-PHDRS
-{
- text PT_LOAD FLAGS((1 << 0) | (1 << 2)) ; /* Execute + Read */
- rodata PT_LOAD FLAGS((1 << 2)) ; /* Read only */
- data PT_LOAD FLAGS((1 << 1) | (1 << 2)) ; /* Write + Read */
- dynamic PT_DYNAMIC FLAGS((1 << 1) | (1 << 2)) ; /* Dynamic */
-}
-
-SECTIONS
-{
- . = 0xffffffff80000000;
-
- .text : {
- *(.text .text.*)
- } :text
-
- . += CONSTANT(MAXPAGESIZE);
-
- .rodata : {
- *(.rodata .rodata.*)
- } :rodata
-
- . += CONSTANT(MAXPAGESIZE);
-
- .data : {
- *(.data .data.*)
-
- KEEP(*(.requests_start_marker))
- KEEP(*(.requests))
- KEEP(*(.requests_end_marker))
- } :data
-
- .bss : {
- *(COMMON)
- *(.bss .bss.*)
- } :data
-
- /DISCARD/ : {
- *(.eh_frame)
- *(.note .note.*)
- }
-}
diff --git a/qemu.log b/qemu.log
deleted file mode 100644
index 02feb78..0000000
--- a/qemu.log
+++ /dev/null
@@ -1,5 +0,0 @@
-limine: Loading executable `boot():/boot/rust-os`...
-Entered _start!
-BASE_REVISION not supported!
-Hello World!
-qemu-system-x86_64: terminating on signal 15 from pid 773461 (timeout)
diff --git a/qemu_output.txt b/qemu_output.txt
deleted file mode 100644
index 3441336..0000000
--- a/qemu_output.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-limine: Loading executable `boot():/boot/rust-os`...
-Entered _start!
-BASE_REVISION not supported!
-qemu-system-x86_64: terminating on signal 15 from pid 799698 (timeout)
diff --git a/readelf.out b/readelf.out
deleted file mode 100644
index f47369f..0000000
--- a/readelf.out
+++ /dev/null
@@ -1,23 +0,0 @@
-
-Elf file type is EXEC (Executable file)
-Entry point 0xffffffff80000400
-There are 4 program headers, starting at offset 64
-
-Program Headers:
- Type Offset VirtAddr PhysAddr
- FileSiz MemSiz Flags Align
- LOAD 0x0000000000001000 0xffffffff80000000 0xffffffff80000000
- 0x000000000000d8dc 0x000000000000d8dc R E 0x1000
- LOAD 0x000000000000e8e0 0xffffffff8000e8e0 0xffffffff8000e8e0
- 0x0000000000003dbd 0x0000000000003dbd R 0x1000
- LOAD 0x00000000000126a0 0xffffffff800136a0 0xffffffff800136a0
- 0x0000000000000078 0x0000000000000078 RW 0x1000
- DYNAMIC 0x0000000000000000 0x0000000000000000 0x0000000000000000
- 0x0000000000000000 0x0000000000000000 RW 0x0
-
- Section to Segment mapping:
- Segment Sections...
- 00 .text
- 01 .rodata
- 02 .data
- 03
diff --git a/report.typ b/report.typ
index eb02d77..6c37e8a 100644
--- a/report.typ
+++ b/report.typ
@@ -11,3 +11,6 @@ rejected because:
- due to that it's tightly coupled with it
#link("https://crates.io/crates/limine")[limine]
- cons: no documentation
+
+== spinlock
+thanks ("https://www.reddit.com/r/cpp/comments/1w6us70/optimizing_a_spinlock/")[this reddit post] and subsequently ("https://david.alvarezrosa.com/posts/optimizing-a-spin-lock/")[this blog] making me realize this was even a possibility
diff --git a/src/io/render.rs b/src/io/render.rs
deleted file mode 100644
index 402daf7..0000000
--- a/src/io/render.rs
+++ /dev/null
@@ -1 +0,0 @@
-pub mod fb;
diff --git a/src/main.rs b/src/main.rs
deleted file mode 100644
index bf338df..0000000
--- a/src/main.rs
+++ /dev/null
@@ -1,76 +0,0 @@
-#![no_std]
-#![no_main]
-#![feature(used_with_arg)]
-
-use core::panic::PanicInfo;
-use font8x8::UnicodeFonts;
-use limine::{BaseRevision, request::FramebufferRequest};
-
-#[used(linker)]
-#[unsafe(link_section = ".requests")]
-static BASE_REVISION: BaseRevision = BaseRevision::new();
-
-#[used(linker)]
-#[unsafe(link_section = ".requests")]
-static FRAMEBUFFER_REQUEST: FramebufferRequest = FramebufferRequest::new();
-
-#[unsafe(no_mangle)]
-pub extern "C" fn _start() -> ! {
- if !BASE_REVISION.is_supported() {
- panic!("Limine Base Revision not supported");
- }
-
- if let Some(response) = FRAMEBUFFER_REQUEST.response() {
- if let Some(fb) = response
- .framebuffers()
- .first()
- {
- let pitch = fb.pitch as usize;
- let bpp = fb.bpp as usize;
-
- if bpp == 32 {
- let slice = unsafe { fb.as_slice_mut() };
- let msg = "Hello World!";
- let mut cursor_x = 10;
- let cursor_y = 10;
-
- for c in msg.chars() {
- if let Some(glyph) = font8x8::BASIC_FONTS.get(c) {
- for (y, row) in glyph
- .iter()
- .enumerate()
- {
- for x in 0..8 {
- if (*row & (1 << x)) != 0 {
- let pixel_offset = (cursor_y + y) * pitch + (cursor_x + x) * 4;
- if pixel_offset + 3 < slice.len() {
- slice[pixel_offset] = 0xFF; // B
- slice[pixel_offset + 1] = 0xFF; // G
- slice[pixel_offset + 2] = 0xFF; // R
- }
- }
- }
- }
- }
- cursor_x += 8;
- }
- }
- }
- }
-
- hcf();
-}
-
-fn hcf() -> ! {
- unsafe {
- core::arch::asm!("cli");
- loop {
- core::arch::asm!("hlt");
- }
- }
-}
-
-#[panic_handler]
-fn panic(_info: &PanicInfo) -> ! {
- hcf()
-}
diff --git a/target.json b/target.json
deleted file mode 100644
index 7914b12..0000000
--- a/target.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "llvm-target": "x86_64-unknown-none",
- "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",
- "arch": "x86_64",
- "target-endian": "little",
- "target-pointer-width": 64,
- "target-c-int-width": 32,
- "os": "none",
- "executables": true,
- "linker-flavor": "ld.lld",
- "linker": "rust-lld",
- "panic-strategy": "abort",
- "disable-redzone": true,
- "features": "-mmx,-sse,+soft-float",
- "rustc-abi": "x86-softfloat",
- "relocation-model": "static",
- "position-independent-executables": false,
- "code-model": "kernel"
-}
diff --git a/x/.cargo/config.toml b/x/.cargo/config.toml
new file mode 100644
index 0000000..dfa84e8
--- /dev/null
+++ b/x/.cargo/config.toml
@@ -0,0 +1,2 @@
+[unstable]
+bindeps = true
diff --git a/x/Cargo.toml b/x/Cargo.toml
new file mode 100644
index 0000000..0dc6279
--- /dev/null
+++ b/x/Cargo.toml
@@ -0,0 +1,11 @@
+[package]
+name = "x"
+version = "0.1.0"
+edition = "2024"
+
+[dependencies]
+ovmf-prebuilt = "0.2.4"
+
+[build-dependencies]
+kernel = { path = "../kernel", artifact = "bin", target = "x86_64-unknown-none" }
+bootloader = { git = "https://github.com/rust-osdev/bootloader" }
diff --git a/x/build.rs b/x/build.rs
new file mode 100644
index 0000000..37200d3
--- /dev/null
+++ b/x/build.rs
@@ -0,0 +1,25 @@
+use std::path::PathBuf;
+
+fn main() {
+ // set by cargo, build scripts should use this directory for output files
+ let out_dir = PathBuf::from(std::env::var_os("OUT_DIR").unwrap());
+ // set by cargo's artifact dependency feature, see
+ // https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#artifact-dependencies
+ let kernel = PathBuf::from(std::env::var_os("CARGO_BIN_FILE_KERNEL_kernel").unwrap());
+
+ // create an UEFI disk image (optional)
+ let uefi_path = out_dir.join("uefi.img");
+ bootloader::UefiBoot::new(&kernel)
+ .create_disk_image(&uefi_path)
+ .unwrap();
+
+ // create a BIOS disk image
+ let bios_path = out_dir.join("bios.img");
+ bootloader::BiosBoot::new(&kernel)
+ .create_disk_image(&bios_path)
+ .unwrap();
+
+ // pass the disk image paths as env variables to the
+ println!("cargo:rustc-env=UEFI_PATH={}", uefi_path.display());
+ println!("cargo:rustc-env=BIOS_PATH={}", bios_path.display());
+}
diff --git a/x/src/main.rs b/x/src/main.rs
new file mode 100644
index 0000000..f2eabf9
--- /dev/null
+++ b/x/src/main.rs
@@ -0,0 +1,62 @@
+use ovmf_prebuilt::{Arch, FileType, Prebuilt, Source};
+use std::{
+ env,
+ process::{Command, exit},
+};
+
+fn main() {
+ // read env variables that were set in build script
+ let uefi_path = env!("UEFI_PATH");
+ let bios_path = env!("BIOS_PATH");
+
+ // parse mode from CLI
+ let args: Vec<String> = env::args().collect();
+ let prog = &args[0];
+
+ // choose whether to start the UEFI or BIOS image
+ let uefi = match args.get(1).map(|s| s.to_lowercase()) {
+ Some(ref s) if s == "uefi" => true,
+ Some(ref s) if s == "bios" => false,
+ Some(ref s) if s == "-h" || s == "--help" => {
+ println!("Usage: {prog} [uefi|bios]");
+ println!(" uefi - boot using OVMF (UEFI)");
+ println!(" bios - boot using legacy BIOS");
+ exit(0);
+ }
+ _ => true,
+ };
+
+ let mut cmd = Command::new("qemu-system-x86_64");
+ // print serial output to the shell
+ cmd.arg("-serial").arg("mon:stdio");
+ // don't display video output
+ cmd.arg("-display").arg("none");
+ // enable the guest to exit qemu
+ cmd.arg("-device").arg("isa-debug-exit,iobase=0xf4,iosize=0x04");
+
+ if uefi {
+ let prebuilt =
+ Prebuilt::fetch(Source::LATEST, "target/ovmf").expect("failed to update prebuilt");
+
+ let code = prebuilt.get_file(Arch::X64, FileType::Code);
+ let vars = prebuilt.get_file(Arch::X64, FileType::Vars);
+
+ cmd.arg("-drive").arg(format!("format=raw,file={uefi_path}"));
+ cmd.arg("-drive")
+ .arg(format!("if=pflash,format=raw,unit=0,file={},readonly=on", code.display()));
+ // copy vars and enable rw instead of snapshot if you want to store data
+ // (e.g. enroll secure boot keys)
+ cmd.arg("-drive")
+ .arg(format!("if=pflash,format=raw,unit=1,file={},snapshot=on", vars.display()));
+ } else {
+ cmd.arg("-drive").arg(format!("format=raw,file={bios_path}"));
+ }
+
+ let mut child = cmd.spawn().expect("failed to start qemu-system-x86_64");
+ let status = child.wait().expect("failed to wait on qemu");
+ match status.code().unwrap_or(1) {
+ 0x10 => 0, // success
+ 0x11 => 1, // failure
+ _ => 2, // unknown fault
+ };
+}