Compare commits
8 commits
master
...
kold/inter
Author | SHA1 | Date | |
---|---|---|---|
|
7acf2a869f | ||
|
a658189efe | ||
|
4b9107c4d6 | ||
|
6534340a86 | ||
|
5a9fe9a0bd | ||
|
4a45c929a1 | ||
|
f65a5bd79c | ||
|
2b33a65e6b |
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1 @@
|
||||||
target/
|
target/
|
||||||
out/
|
|
180
Cargo.lock
generated
180
Cargo.lock
generated
|
@ -13,15 +13,15 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "allocator-api2"
|
name = "allocator-api2"
|
||||||
version = "0.2.21"
|
version = "0.2.20"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
|
checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.95"
|
version = "1.0.93"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04"
|
checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
|
@ -61,9 +61,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "2.8.0"
|
version = "2.6.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36"
|
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "byteorder"
|
name = "byteorder"
|
||||||
|
@ -73,9 +73,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.2.14"
|
version = "1.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0c3d1b2e905a3a7b00a6141adb0e4c0bb941d11caf55349d863942a1cc44e3c9"
|
checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"shlex",
|
"shlex",
|
||||||
]
|
]
|
||||||
|
@ -88,18 +88,18 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam-queue"
|
name = "crossbeam-queue"
|
||||||
version = "0.3.12"
|
version = "0.3.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115"
|
checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crossbeam-utils",
|
"crossbeam-utils",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam-utils"
|
name = "crossbeam-utils"
|
||||||
version = "0.8.21"
|
version = "0.8.20"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
|
checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "derive_more"
|
name = "derive_more"
|
||||||
|
@ -142,9 +142,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "equivalent"
|
name = "equivalent"
|
||||||
version = "1.0.2"
|
version = "1.0.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
|
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "error-stack"
|
name = "error-stack"
|
||||||
|
@ -175,9 +175,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "foldhash"
|
name = "foldhash"
|
||||||
version = "0.1.4"
|
version = "0.1.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f"
|
checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "form_urlencoded"
|
name = "form_urlencoded"
|
||||||
|
@ -201,9 +201,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hashbrown"
|
name = "hashbrown"
|
||||||
version = "0.15.2"
|
version = "0.15.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289"
|
checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"allocator-api2",
|
"allocator-api2",
|
||||||
"equivalent",
|
"equivalent",
|
||||||
|
@ -213,12 +213,12 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hbbytecode"
|
name = "hbbytecode"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#b6d72dbc69983545108b36856c92566414acd11f"
|
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#a3355a59c0727e58519a94a8f65013beb9c2331b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hblang"
|
name = "hblang"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#b6d72dbc69983545108b36856c92566414acd11f"
|
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#a3355a59c0727e58519a94a8f65013beb9c2331b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
"hbbytecode",
|
"hbbytecode",
|
||||||
|
@ -229,7 +229,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hbvm"
|
name = "hbvm"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#b6d72dbc69983545108b36856c92566414acd11f"
|
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#a3355a59c0727e58519a94a8f65013beb9c2331b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hbbytecode",
|
"hbbytecode",
|
||||||
]
|
]
|
||||||
|
@ -375,9 +375,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "indexmap"
|
name = "indexmap"
|
||||||
version = "2.7.1"
|
version = "2.6.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652"
|
checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"equivalent",
|
"equivalent",
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
|
@ -401,7 +401,7 @@ dependencies = [
|
||||||
"uart_16550",
|
"uart_16550",
|
||||||
"versioning",
|
"versioning",
|
||||||
"x2apic",
|
"x2apic",
|
||||||
"x86_64 0.15.2",
|
"x86_64 0.15.1",
|
||||||
"xml",
|
"xml",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -421,9 +421,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.169"
|
version = "0.2.164"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a"
|
checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "limine"
|
name = "limine"
|
||||||
|
@ -449,24 +449,24 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "log"
|
name = "log"
|
||||||
version = "0.4.25"
|
version = "0.4.22"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f"
|
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "logos"
|
name = "logos"
|
||||||
version = "0.14.4"
|
version = "0.14.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7251356ef8cb7aec833ddf598c6cb24d17b689d20b993f9d11a3d764e34e6458"
|
checksum = "1c6b6e02facda28ca5fb8dbe4b152496ba3b1bd5a4b40bb2b1b2d8ad74e0f39b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"logos-derive",
|
"logos-derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "logos-codegen"
|
name = "logos-codegen"
|
||||||
version = "0.14.4"
|
version = "0.14.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "59f80069600c0d66734f5ff52cc42f2dabd6b29d205f333d61fd7832e9e9963f"
|
checksum = "b32eb6b5f26efacd015b000bfc562186472cd9b34bdba3f6b264e2a052676d10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"beef",
|
"beef",
|
||||||
"fnv",
|
"fnv",
|
||||||
|
@ -479,9 +479,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "logos-derive"
|
name = "logos-derive"
|
||||||
version = "0.14.4"
|
version = "0.14.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "24fb722b06a9dc12adb0963ed585f19fc61dc5413e6a9be9422ef92c091e731d"
|
checksum = "3e5d0c5463c911ef55624739fc353238b4e310f0144be1f875dc42fec6bfd5ec"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"logos-codegen",
|
"logos-codegen",
|
||||||
]
|
]
|
||||||
|
@ -494,9 +494,9 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "once_cell"
|
name = "once_cell"
|
||||||
version = "1.20.3"
|
version = "1.20.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e"
|
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "paste"
|
name = "paste"
|
||||||
|
@ -512,18 +512,18 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.93"
|
version = "1.0.92"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99"
|
checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.38"
|
version = "1.0.37"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc"
|
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
@ -539,11 +539,11 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "raw-cpuid"
|
name = "raw-cpuid"
|
||||||
version = "11.4.0"
|
version = "11.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "529468c1335c1c03919960dfefdb1b3648858c20d7ec2d0663e728e4a717efbc"
|
checksum = "1ab240315c661615f2ee9f0f2cd32d5a7343a84d5ebcccb99d46e6637565e7b0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.8.0",
|
"bitflags 2.6.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -561,7 +561,7 @@ dependencies = [
|
||||||
"fatfs",
|
"fatfs",
|
||||||
"hblang",
|
"hblang",
|
||||||
"log",
|
"log",
|
||||||
"raw-cpuid 11.4.0",
|
"raw-cpuid 11.2.0",
|
||||||
"str-reader",
|
"str-reader",
|
||||||
"toml",
|
"toml",
|
||||||
"ureq",
|
"ureq",
|
||||||
|
@ -569,33 +569,19 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ring"
|
name = "ring"
|
||||||
version = "0.17.9"
|
version = "0.17.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e75ec5e92c4d8aede845126adc388046234541629e76029599ed35a003c7ed24"
|
checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"getrandom",
|
"getrandom",
|
||||||
"libc",
|
"libc",
|
||||||
|
"spin",
|
||||||
"untrusted",
|
"untrusted",
|
||||||
"windows-sys",
|
"windows-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rlbuild"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"rlisp_library",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rlisp_library"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "git+https://git.ablecorp.us/able/rlisp.git#e349916bb67ad74ca5f868da57c733d00d97397f"
|
|
||||||
dependencies = [
|
|
||||||
"hashbrown",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc_version"
|
name = "rustc_version"
|
||||||
version = "0.4.1"
|
version = "0.4.1"
|
||||||
|
@ -607,9 +593,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustls"
|
name = "rustls"
|
||||||
version = "0.23.23"
|
version = "0.23.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "47796c98c480fce5406ef69d1c76378375492c3b0a0de587be0c1d9feb12f395"
|
checksum = "9c9cc1d47e243d655ace55ed38201c19ae02c148ae56412ab8750e8f0166ab7f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
@ -622,9 +608,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustls-pki-types"
|
name = "rustls-pki-types"
|
||||||
version = "1.11.0"
|
version = "1.10.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "917ce264624a4b4db1c364dcc35bfca9ded014d0a958cd47ad3e960e988ea51c"
|
checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustls-webpki"
|
name = "rustls-webpki"
|
||||||
|
@ -639,9 +625,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustversion"
|
name = "rustversion"
|
||||||
version = "1.0.19"
|
version = "1.0.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4"
|
checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sbi"
|
name = "sbi"
|
||||||
|
@ -657,24 +643,24 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "semver"
|
name = "semver"
|
||||||
version = "1.0.25"
|
version = "1.0.23"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f79dfe2d285b0488816f30e700a7438c5a73d816b5b7d3ac72fbc48b0d185e03"
|
checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.217"
|
version = "1.0.215"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70"
|
checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.217"
|
version = "1.0.215"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0"
|
checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -707,9 +693,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "smallvec"
|
name = "smallvec"
|
||||||
version = "1.14.0"
|
version = "1.13.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd"
|
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "spin"
|
name = "spin"
|
||||||
|
@ -740,9 +726,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.98"
|
version = "2.0.89"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1"
|
checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -778,9 +764,9 @@ checksum = "696941a0aee7e276a165a978b37918fd5d22c55c3d6bda197813070ca9c0f21c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml"
|
name = "toml"
|
||||||
version = "0.8.20"
|
version = "0.8.19"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148"
|
checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_spanned",
|
"serde_spanned",
|
||||||
|
@ -799,9 +785,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml_edit"
|
name = "toml_edit"
|
||||||
version = "0.22.24"
|
version = "0.22.22"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474"
|
checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"serde",
|
"serde",
|
||||||
|
@ -816,16 +802,16 @@ version = "0.3.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e492212ac378a5e00da953718dafb1340d9fbaf4f27d6f3c5cab03d931d1c049"
|
checksum = "e492212ac378a5e00da953718dafb1340d9fbaf4f27d6f3c5cab03d931d1c049"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.8.0",
|
"bitflags 2.6.0",
|
||||||
"rustversion",
|
"rustversion",
|
||||||
"x86",
|
"x86",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
version = "1.0.17"
|
version = "1.0.14"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe"
|
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-xid"
|
name = "unicode-xid"
|
||||||
|
@ -841,9 +827,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ureq"
|
name = "ureq"
|
||||||
version = "2.12.1"
|
version = "2.10.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "02d1a66277ed75f640d608235660df48c8e3c19f3b4edb6a263315626cc3c01d"
|
checksum = "b74fc6b57825be3373f7054754755f03ac3a8f5d70015ccad699ba2029956f4a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"log",
|
"log",
|
||||||
|
@ -899,9 +885,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "webpki-roots"
|
name = "webpki-roots"
|
||||||
version = "0.26.8"
|
version = "0.26.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2210b291f7ea53617fbafcc4939f10914214ec15aace5ba62293a668f322c5c9"
|
checksum = "5d642ff16b7e79272ae451b7322067cdc17cadf68c23264be9d94a32319efe7e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rustls-pki-types",
|
"rustls-pki-types",
|
||||||
]
|
]
|
||||||
|
@ -981,9 +967,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winnow"
|
name = "winnow"
|
||||||
version = "0.7.2"
|
version = "0.6.20"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "59690dea168f2198d1a3b0cac23b8063efcd11012f10ae4698f284808c8ef603"
|
checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
@ -1010,7 +996,7 @@ dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"paste",
|
"paste",
|
||||||
"raw-cpuid 10.7.0",
|
"raw-cpuid 10.7.0",
|
||||||
"x86_64 0.14.13",
|
"x86_64 0.14.12",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1026,24 +1012,24 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "x86_64"
|
name = "x86_64"
|
||||||
version = "0.14.13"
|
version = "0.14.12"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c101112411baafbb4bf8d33e4c4a80ab5b02d74d2612331c61e8192fc9710491"
|
checksum = "96cb6fd45bfeab6a5055c5bffdb08768bd0c069f1d946debe585bbb380a7c062"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bit_field",
|
"bit_field",
|
||||||
"bitflags 2.8.0",
|
"bitflags 2.6.0",
|
||||||
"rustversion",
|
"rustversion",
|
||||||
"volatile",
|
"volatile",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "x86_64"
|
name = "x86_64"
|
||||||
version = "0.15.2"
|
version = "0.15.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0f042214de98141e9c8706e8192b73f56494087cc55ebec28ce10f26c5c364ae"
|
checksum = "4bc79523af8abf92fb1a970c3e086c5a343f6bcc1a0eb890f575cbb3b45743df"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bit_field",
|
"bit_field",
|
||||||
"bitflags 2.8.0",
|
"bitflags 2.6.0",
|
||||||
"rustversion",
|
"rustversion",
|
||||||
"volatile",
|
"volatile",
|
||||||
]
|
]
|
||||||
|
|
10
Cargo.toml
10
Cargo.toml
|
@ -1,17 +1,9 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
members = ["dev", "kernel", "repbuild", "rlbuild"]
|
members = ["dev", "kernel", "repbuild"]
|
||||||
|
|
||||||
# [profile.release]
|
# [profile.release]
|
||||||
# strip = "symbols"
|
# strip = "symbols"
|
||||||
# codegen-units = 1
|
# codegen-units = 1
|
||||||
# lto = true
|
# lto = true
|
||||||
# panic = "abort"
|
# panic = "abort"
|
||||||
|
|
||||||
[profile.release.package.hblang]
|
|
||||||
debug-assertions = true
|
|
||||||
overflow-checks = false
|
|
||||||
|
|
||||||
[profile.dev.package.hblang]
|
|
||||||
debug-assertions = true
|
|
||||||
overflow-checks = false
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ ktest = []
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# embedded-graphics = "0.8"
|
# embedded-graphics = "0.8"
|
||||||
hbvm = { git = "https://git.ablecorp.us/AbleOS/holey-bytes.git", features = [
|
hbvm = { git = "https://git.ablecorp.us/AbleOS/holey-bytes.git", features = [
|
||||||
"nightly", "alloc", "disasm"
|
"nightly",
|
||||||
] }
|
] }
|
||||||
ktest_macro = { path = "ktest_macro" }
|
ktest_macro = { path = "ktest_macro" }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
|
|
@ -1,85 +1,28 @@
|
||||||
extern crate proc_macro;
|
extern crate proc_macro;
|
||||||
extern crate quote;
|
extern crate quote;
|
||||||
extern crate syn;
|
extern crate syn;
|
||||||
|
|
||||||
use {
|
use {
|
||||||
proc_macro::TokenStream,
|
proc_macro::TokenStream,
|
||||||
quote::quote,
|
quote::quote,
|
||||||
syn::{parse::Parse, parse_macro_input, Expr, ItemFn, Token},
|
syn::{parse_macro_input, ItemFn}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct KtestInput {
|
|
||||||
lhs: Expr,
|
|
||||||
_comma: Token![,],
|
|
||||||
rhs: Expr,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Parse for KtestInput {
|
|
||||||
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
|
|
||||||
Ok(Self {
|
|
||||||
lhs: input.parse()?,
|
|
||||||
_comma: input.parse()?,
|
|
||||||
rhs: input.parse()?,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[proc_macro]
|
|
||||||
pub fn ktest_eq(item: TokenStream) -> TokenStream {
|
|
||||||
let input = parse_macro_input!(item as KtestInput);
|
|
||||||
|
|
||||||
let lhs = input.lhs;
|
|
||||||
let rhs = input.rhs;
|
|
||||||
|
|
||||||
let out = quote! {
|
|
||||||
if #lhs != #rhs {
|
|
||||||
return Err(name);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
TokenStream::from(out)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[proc_macro]
|
|
||||||
pub fn ktest_neq(item: TokenStream) -> TokenStream {
|
|
||||||
let input = parse_macro_input!(item as KtestInput);
|
|
||||||
|
|
||||||
let lhs = input.lhs;
|
|
||||||
let rhs = input.rhs;
|
|
||||||
|
|
||||||
let out = quote! {
|
|
||||||
if #lhs == #rhs {
|
|
||||||
return Err(name);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
TokenStream::from(out)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[proc_macro_attribute]
|
#[proc_macro_attribute]
|
||||||
pub fn ktest(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
pub fn ktest(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||||
let input = parse_macro_input!(item as ItemFn);
|
let input = parse_macro_input!(item as ItemFn);
|
||||||
let test_name = &input.sig.ident;
|
let test_name = &input.sig.ident;
|
||||||
let test_string = test_name.to_string();
|
|
||||||
let static_var_name = syn::Ident::new(
|
let static_var_name = syn::Ident::new(
|
||||||
&format!("__ktest_{}", test_name).to_uppercase(),
|
&format!("__ktest_{}", test_name),
|
||||||
test_name.span(),
|
test_name.span(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let block = &input.block;
|
|
||||||
let out = quote! {
|
let out = quote! {
|
||||||
#[cfg(feature = "ktest")]
|
// #[cfg(feature = "ktest")]
|
||||||
fn #test_name() -> Result<String, String> {
|
#input
|
||||||
use crate::alloc::string::ToString;
|
|
||||||
let name = #test_string.to_string();
|
|
||||||
|
|
||||||
#block
|
// #[cfg(feature = "ktest")]
|
||||||
|
|
||||||
return Ok(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "ktest")]
|
|
||||||
#[unsafe(link_section = ".note.ktest")]
|
#[unsafe(link_section = ".note.ktest")]
|
||||||
#[used]
|
#[used]
|
||||||
pub static #static_var_name: fn() -> Result<String, String> = #test_name;
|
pub static #static_var_name: fn() = #test_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
TokenStream::from(out)
|
TokenStream::from(out)
|
||||||
|
|
|
@ -6,11 +6,6 @@ SECTIONS
|
||||||
.text.boot : { *(.text.boot) }
|
.text.boot : { *(.text.boot) }
|
||||||
.text : { *(.text) }
|
.text : { *(.text) }
|
||||||
.data : { *(.data) }
|
.data : { *(.data) }
|
||||||
.note.ktest : {
|
|
||||||
__ktest_start = .;
|
|
||||||
*(.note.ktest)
|
|
||||||
__ktest_end = .;
|
|
||||||
}
|
|
||||||
.rodata : { *(.rodata) }
|
.rodata : { *(.rodata) }
|
||||||
.bss : {
|
.bss : {
|
||||||
*(COMMON)
|
*(COMMON)
|
||||||
|
|
|
@ -83,29 +83,31 @@ extern "x86-interrupt" fn spurious(_: InterruptStackFrame) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_imports)]
|
|
||||||
fn interrupt(interrupt_type: Interrupt) {
|
fn interrupt(interrupt_type: Interrupt) {
|
||||||
use crate::{arch::INTERRUPT_LIST, kmain::EXECUTOR};
|
use crate::arch::INTERRUPT_LIST;
|
||||||
// let il = INTERRUPT_LIST.lock();
|
use crate::kmain::EXECUTOR;
|
||||||
// let val = il.list.get(&interrupt_type).unwrap();
|
let il = INTERRUPT_LIST.lock();
|
||||||
|
let val = il.list.get(&interrupt_type).unwrap();
|
||||||
|
|
||||||
// use crate::holeybytes::kernel_services::service_definition_service::sds_search_service;
|
use crate::holeybytes::kernel_services::service_definition_service::sds_search_service;
|
||||||
// let buffer = sds_search_service(val);
|
let buffer = sds_search_service(val);
|
||||||
// if buffer != 0 {
|
if buffer != 0 {
|
||||||
// use {crate::kmain::IPC_BUFFERS, alloc::vec::Vec};
|
use {crate::kmain::IPC_BUFFERS, alloc::vec::Vec};
|
||||||
// let mut buffs = IPC_BUFFERS.lock();
|
let mut buffs = IPC_BUFFERS.lock();
|
||||||
// match buffs.get_mut(&buffer) {
|
match buffs.get_mut(&buffer) {
|
||||||
// Some(buff) => {
|
Some(buff) => {
|
||||||
// let mut msg_vec = Vec::new();
|
let mut msg_vec = Vec::new();
|
||||||
// msg_vec.push(0xFF);
|
msg_vec.push(0xFF);
|
||||||
// buff.push(msg_vec.to_vec());
|
buff.push(msg_vec.to_vec());
|
||||||
// log::debug!("Sent Message {:?} to Buffer({})", msg_vec, buffer);
|
log::debug!("Sent Message {:?} to Buffer({})", msg_vec, buffer);
|
||||||
// }
|
}
|
||||||
// None => {
|
None => {
|
||||||
// log::error!("Access of non-existent buffer {}", buffer)
|
log::error!("Access of non-existent buffer {}", buffer)
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
|
// log::info!("{}", buffer);
|
||||||
|
}
|
||||||
|
|
||||||
unsafe{
|
unsafe{
|
||||||
EXECUTOR.send_interrupt(interrupt_type as u8);
|
EXECUTOR.send_interrupt(interrupt_type as u8);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
//! Environment call handling routines
|
//! Environment call handling routines
|
||||||
|
|
||||||
|
use log::log;
|
||||||
|
|
||||||
use {alloc::boxed::Box, core::cell::LazyCell, hbvm::mem::Address};
|
use {alloc::boxed::Box, core::cell::LazyCell, hbvm::mem::Address};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -8,13 +10,14 @@ use crate::{
|
||||||
block_read, dt_msg_handler::dt_msg_handler, logging_service::log_msg_handler,
|
block_read, dt_msg_handler::dt_msg_handler, logging_service::log_msg_handler,
|
||||||
service_definition_service::sds_msg_handler,
|
service_definition_service::sds_msg_handler,
|
||||||
},
|
},
|
||||||
ExecThread, STACK_SIZE,
|
ExecThread,
|
||||||
},
|
},
|
||||||
kmain::EXECUTOR,
|
kmain::EXECUTOR,
|
||||||
task::Executor,
|
task::Executor,
|
||||||
};
|
};
|
||||||
|
|
||||||
use {
|
use {
|
||||||
|
super::Vm,
|
||||||
crate::{arch, ipc::buffer::IpcBuffer, kmain::IPC_BUFFERS},
|
crate::{arch, ipc::buffer::IpcBuffer, kmain::IPC_BUFFERS},
|
||||||
hbvm::value::Value,
|
hbvm::value::Value,
|
||||||
log::{debug, error, info, trace},
|
log::{debug, error, info, trace},
|
||||||
|
@ -32,21 +35,21 @@ unsafe fn x86_in<T: x86_64::instructions::port::PortRead>(address: u16) -> T {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn handler(thr: &mut ExecThread, pid: &usize) {
|
pub fn handler(vm: &mut Vm, pid: &usize) {
|
||||||
let ecall_number = thr.vm.registers[2].cast::<u64>();
|
let ecall_number = vm.registers[2].cast::<u64>();
|
||||||
|
|
||||||
match ecall_number {
|
match ecall_number {
|
||||||
0 => {
|
0 => {
|
||||||
// TODO: explode computer
|
// TODO: explode computer
|
||||||
// hello world ecall
|
// hello world ecall
|
||||||
for x in 0u64..=255 {
|
for x in 0u64..=255 {
|
||||||
thr.vm.registers[x as usize] = x.into();
|
vm.registers[x as usize] = x.into();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
1 => {
|
1 => {
|
||||||
// Make buffer
|
// Make buffer
|
||||||
|
|
||||||
let bounded = match thr.vm.registers[3] {
|
let bounded = match vm.registers[3] {
|
||||||
Value(0) => false,
|
Value(0) => false,
|
||||||
Value(1) => true,
|
Value(1) => true,
|
||||||
_ => {
|
_ => {
|
||||||
|
@ -54,7 +57,7 @@ pub fn handler(thr: &mut ExecThread, pid: &usize) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let length = thr.vm.registers[4].cast::<u64>();
|
let length = vm.registers[4].cast::<u64>();
|
||||||
|
|
||||||
let mut buffs = IPC_BUFFERS.lock();
|
let mut buffs = IPC_BUFFERS.lock();
|
||||||
|
|
||||||
|
@ -66,7 +69,7 @@ pub fn handler(thr: &mut ExecThread, pid: &usize) {
|
||||||
true => IpcBuffer::new(true, length),
|
true => IpcBuffer::new(true, length),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
thr.vm.registers[1] = hbvm::value::Value(buff_id);
|
vm.registers[1] = hbvm::value::Value(buff_id);
|
||||||
}
|
}
|
||||||
2 => {
|
2 => {
|
||||||
log::error!("Oops, deleting buffers is not implemented.")
|
log::error!("Oops, deleting buffers is not implemented.")
|
||||||
|
@ -74,27 +77,23 @@ pub fn handler(thr: &mut ExecThread, pid: &usize) {
|
||||||
}
|
}
|
||||||
3 => {
|
3 => {
|
||||||
// Send a message to a buffer
|
// Send a message to a buffer
|
||||||
let buffer_id = thr.vm.registers[3].cast::<u64>();
|
let buffer_id = vm.registers[3].cast::<u64>();
|
||||||
let mem_addr = thr.vm.registers[4].cast::<u64>();
|
let mem_addr = vm.registers[4].cast::<u64>();
|
||||||
let length = thr.vm.registers[5].cast::<u64>() as usize;
|
let length = vm.registers[5].cast::<u64>() as usize;
|
||||||
trace!("IPC address: {:?}", mem_addr);
|
trace!("IPC address: {:?}", mem_addr);
|
||||||
|
|
||||||
unsafe { LazyCell::<Executor>::get_mut(&mut EXECUTOR) }
|
|
||||||
.unwrap()
|
|
||||||
.send_buffer(buffer_id as usize);
|
|
||||||
|
|
||||||
match buffer_id {
|
match buffer_id {
|
||||||
0 => match sds_msg_handler(&mut thr.vm, mem_addr, length) {
|
0 => match sds_msg_handler(vm, mem_addr, length) {
|
||||||
Ok(()) => {}
|
Ok(()) => {}
|
||||||
Err(err) => log::error!("Improper sds format: {err:?}"),
|
Err(err) => log::error!("Improper sds format: {err:?}"),
|
||||||
},
|
},
|
||||||
1 => match log_msg_handler(&mut thr.vm, mem_addr, length) {
|
1 => match log_msg_handler(vm, mem_addr, length) {
|
||||||
Ok(()) => {}
|
Ok(()) => {}
|
||||||
Err(_) => log::error!("Improper log format"),
|
Err(_) => log::error!("Improper log format"),
|
||||||
},
|
},
|
||||||
2 => {
|
2 => {
|
||||||
use crate::holeybytes::kernel_services::mem_serve::memory_msg_handler;
|
use crate::holeybytes::kernel_services::mem_serve::memory_msg_handler;
|
||||||
match memory_msg_handler(&mut thr.vm, mem_addr, length) {
|
match memory_msg_handler(vm, mem_addr, length) {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(_) => {}
|
Err(_) => {}
|
||||||
}
|
}
|
||||||
|
@ -115,7 +114,7 @@ pub fn handler(thr: &mut ExecThread, pid: &usize) {
|
||||||
_ => panic!("Trying to read size other than: 8, 16, 32 from port."),
|
_ => panic!("Trying to read size other than: 8, 16, 32 from port."),
|
||||||
};
|
};
|
||||||
// info!("Read the value {} from address {}", value, addr);
|
// info!("Read the value {} from address {}", value, addr);
|
||||||
thr.vm.registers[1] = hbvm::value::Value(value);
|
vm.registers[1] = hbvm::value::Value(value);
|
||||||
},
|
},
|
||||||
1 => unsafe {
|
1 => unsafe {
|
||||||
let size = msg_vec[1];
|
let size = msg_vec[1];
|
||||||
|
@ -149,9 +148,9 @@ pub fn handler(thr: &mut ExecThread, pid: &usize) {
|
||||||
&crate::arch::hardware_random_u64().to_le_bytes()[..chunk.len()],
|
&crate::arch::hardware_random_u64().to_le_bytes()[..chunk.len()],
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
thr.vm.registers[1] = hbvm::value::Value(mem_addr);
|
vm.registers[1] = hbvm::value::Value(mem_addr);
|
||||||
}
|
}
|
||||||
5 => match dt_msg_handler(&mut thr.vm, mem_addr, length) {
|
5 => match dt_msg_handler(vm, mem_addr, length) {
|
||||||
Ok(()) => {}
|
Ok(()) => {}
|
||||||
Err(_) => log::error!("Improper dt query"),
|
Err(_) => log::error!("Improper dt query"),
|
||||||
},
|
},
|
||||||
|
@ -180,39 +179,18 @@ pub fn handler(thr: &mut ExecThread, pid: &usize) {
|
||||||
let end = (code_length + data_length) as usize;
|
let end = (code_length + data_length) as usize;
|
||||||
log::debug!("{code_length} + {data_length} = {end}");
|
log::debug!("{code_length} + {data_length} = {end}");
|
||||||
|
|
||||||
let thr2 = ExecThread::new(program[offset..end].into(), Address::new(0));
|
let thr = ExecThread::new(&program[offset..end], Address::new(0));
|
||||||
thr.vm.registers[1] = Value(
|
vm.registers[1] = Value(
|
||||||
LazyCell::<Executor>::get_mut(&mut EXECUTOR)
|
LazyCell::<Executor>::get_mut(&mut EXECUTOR)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.spawn(Box::pin(async move {
|
.spawn(Box::pin(async move {
|
||||||
if let Err(e) = thr2.await {
|
if let Err(e) = thr.await {
|
||||||
log::error!("{e:?}");
|
log::error!("{e:?}");
|
||||||
}
|
}
|
||||||
})) as u64,
|
})) as u64,
|
||||||
);
|
);
|
||||||
log::debug!("spawned a process");
|
log::debug!("spawned a process");
|
||||||
},
|
},
|
||||||
7 => unsafe {
|
|
||||||
let mut thr2 = ExecThread::new(
|
|
||||||
thr.program,
|
|
||||||
thr.vm.pc.wrapping_sub(thr.program.as_ptr() as u64),
|
|
||||||
);
|
|
||||||
thr.stack_bottom
|
|
||||||
.copy_to_nonoverlapping(thr2.stack_bottom, STACK_SIZE);
|
|
||||||
thr2.vm.registers = thr.vm.registers;
|
|
||||||
thr2.vm.registers[1] = Value(0);
|
|
||||||
|
|
||||||
thr.vm.registers[1] = Value(
|
|
||||||
LazyCell::<Executor>::get_mut(&mut EXECUTOR)
|
|
||||||
.unwrap()
|
|
||||||
.spawn(Box::pin(async move {
|
|
||||||
if let Err(e) = thr2.await {
|
|
||||||
log::error!("{e:?}");
|
|
||||||
}
|
|
||||||
})) as u64,
|
|
||||||
);
|
|
||||||
log::debug!("forked a process")
|
|
||||||
},
|
|
||||||
|
|
||||||
buffer_id => {
|
buffer_id => {
|
||||||
let mut buffs = IPC_BUFFERS.lock();
|
let mut buffs = IPC_BUFFERS.lock();
|
||||||
|
@ -230,9 +208,9 @@ pub fn handler(thr: &mut ExecThread, pid: &usize) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
4 => {
|
4 => {
|
||||||
let buffer_id = thr.vm.registers[3].cast::<u64>();
|
let buffer_id = vm.registers[3].cast::<u64>();
|
||||||
let map_ptr = thr.vm.registers[4].cast::<u64>();
|
let map_ptr = vm.registers[4].cast::<u64>();
|
||||||
let max_length = thr.vm.registers[5].cast::<u64>();
|
let max_length = vm.registers[5].cast::<u64>();
|
||||||
let mut buffs = IPC_BUFFERS.lock();
|
let mut buffs = IPC_BUFFERS.lock();
|
||||||
let buff: &mut IpcBuffer = match buffs.get_mut(&buffer_id) {
|
let buff: &mut IpcBuffer = match buffs.get_mut(&buffer_id) {
|
||||||
Some(buff) => buff,
|
Some(buff) => buff,
|
||||||
|
@ -260,36 +238,23 @@ pub fn handler(thr: &mut ExecThread, pid: &usize) {
|
||||||
5 => {
|
5 => {
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
{
|
{
|
||||||
let r2 = thr.vm.registers[2].cast::<u64>();
|
let r2 = vm.registers[2].cast::<u64>();
|
||||||
let x = hbvm::value::Value(unsafe { x86_in::<u8>(r2 as u16) } as u64);
|
let x = hbvm::value::Value(unsafe { x86_in::<u8>(r2 as u16) } as u64);
|
||||||
// info!("Read {:?} from Port {:?}", x, r2);
|
// info!("Read {:?} from Port {:?}", x, r2);
|
||||||
thr.vm.registers[3] = x
|
vm.registers[3] = x
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
6 => {
|
6 => { // Wait till interrupt
|
||||||
// Wait till interrupt
|
|
||||||
use crate::kmain::EXECUTOR;
|
use crate::kmain::EXECUTOR;
|
||||||
let interrupt_type = thr.vm.registers[3].cast::<u8>();
|
let interrupt_type = vm.registers[3].cast::<u8>();
|
||||||
debug!("Interrupt subscribed: {}", interrupt_type);
|
info!("Interrupt subscribled: {}", interrupt_type);
|
||||||
unsafe{
|
unsafe{
|
||||||
LazyCell::<Executor>::get_mut(&mut EXECUTOR)
|
EXECUTOR.pause(pid.clone());
|
||||||
.unwrap()
|
LazyCell::<Executor>::get_mut(&mut EXECUTOR).unwrap().interrupt_subscribe(pid.clone(), interrupt_type);
|
||||||
.interrupt_subscribe(*pid, interrupt_type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
7 => {
|
|
||||||
// Wait till buffer
|
|
||||||
use crate::kmain::EXECUTOR;
|
|
||||||
let buffer_id = thr.vm.registers[3].cast::<u64>() as usize;
|
|
||||||
debug!("Buffer subscribed: {}", buffer_id);
|
|
||||||
unsafe {
|
|
||||||
LazyCell::<Executor>::get_mut(&mut EXECUTOR)
|
|
||||||
.unwrap()
|
|
||||||
.buffer_subscribe(*pid, buffer_id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
log::error!("Syscall unknown {:?}{:?}", ecall_number, thr.vm.registers);
|
log::error!("Syscall unknown {:?}{:?}", ecall_number, vm.registers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use {
|
use {
|
||||||
crate::holeybytes::{kernel_services::block_read, Vm},
|
crate::holeybytes::{kernel_services::block_read, Vm},
|
||||||
alloc::alloc::{alloc, alloc_zeroed, dealloc, realloc},
|
alloc::alloc::{alloc, dealloc},
|
||||||
core::alloc::Layout,
|
core::alloc::Layout,
|
||||||
log::{debug, info},
|
log::{debug, info},
|
||||||
};
|
};
|
||||||
|
@ -48,29 +48,29 @@ pub fn memory_msg_handler(
|
||||||
let msg_type = msg_vec[0];
|
let msg_type = msg_vec[0];
|
||||||
match msg_type {
|
match msg_type {
|
||||||
0 => unsafe {
|
0 => unsafe {
|
||||||
let page_count = u64::from_le_bytes(msg_vec[1..9].try_into().unwrap()) as usize;
|
let page_count = msg_vec[1];
|
||||||
let zeroed = msg_vec[9];
|
|
||||||
let ptr = if zeroed > 0 {
|
|
||||||
alloc_zeroed(Layout::from_size_align_unchecked(page_count * 4096, 8))
|
|
||||||
} else {
|
|
||||||
alloc(Layout::from_size_align_unchecked(page_count * 4096, 8))
|
|
||||||
};
|
|
||||||
|
|
||||||
log::debug!("Allocating {} pages @ {:?}", page_count, ptr);
|
let ptr = alloc(Layout::from_size_align_unchecked(
|
||||||
|
page_count as usize * 4096,
|
||||||
|
8,
|
||||||
|
));
|
||||||
|
|
||||||
|
log::debug!("Allocating {} pages @ {:x}", page_count, ptr as u64);
|
||||||
|
|
||||||
vm.registers[1] = hbvm::value::Value(ptr as u64);
|
vm.registers[1] = hbvm::value::Value(ptr as u64);
|
||||||
|
log::debug!("Kernel ptr: {:x}", ptr as u64);
|
||||||
},
|
},
|
||||||
|
|
||||||
1 => unsafe {
|
1 => unsafe {
|
||||||
let page_count = u64::from_le_bytes(msg_vec[1..9].try_into().unwrap()) as usize;
|
let page_count = msg_vec[1];
|
||||||
|
|
||||||
let mptr = u64::from_le_bytes(msg_vec[9..17].try_into().unwrap()) as *mut u8;
|
let mptr_raw: [u8; 8] = msg_vec[2..10].try_into().unwrap();
|
||||||
debug_assert!(mptr.addr() & 0xFFFF000000000000 != 0);
|
let mptr: u64 = u64::from_le_bytes(mptr_raw);
|
||||||
log::debug!("Deallocating {} pages @ {:?}", page_count, mptr);
|
log::debug!("Deallocating {} pages @ {:x}", page_count, mptr);
|
||||||
|
|
||||||
dealloc(
|
dealloc(
|
||||||
mptr,
|
mptr as *mut u8,
|
||||||
Layout::from_size_align_unchecked(page_count * 4096, 8),
|
Layout::from_size_align_unchecked(page_count as usize * 4096, 8),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
2 => {
|
2 => {
|
||||||
|
@ -96,51 +96,19 @@ pub fn memory_msg_handler(
|
||||||
log::debug!(" {} pages", page_count);
|
log::debug!(" {} pages", page_count);
|
||||||
}
|
}
|
||||||
4 => unsafe {
|
4 => unsafe {
|
||||||
let count = u64::from_le_bytes(msg_vec[1..9].try_into().unwrap_unchecked()) as usize;
|
let count = u32::from_le_bytes(msg_vec[1..5].try_into().unwrap_unchecked()) as usize;
|
||||||
let src = u64::from_le_bytes(msg_vec[9..17].try_into().unwrap_unchecked()) as *const u8;
|
let src = u64::from_le_bytes(msg_vec[5..13].try_into().unwrap_unchecked()) as *const u8;
|
||||||
let dest = u64::from_le_bytes(msg_vec[17..25].try_into().unwrap_unchecked()) as *mut u8;
|
let dest = u64::from_le_bytes(msg_vec[13..21].try_into().unwrap_unchecked()) as *mut u8;
|
||||||
debug_assert!(src.addr() & 0xFFFF000000000000 != 0);
|
|
||||||
debug_assert!(dest.addr() & 0xFFFF000000000000 != 0);
|
|
||||||
src.copy_to_nonoverlapping(dest, count);
|
src.copy_to_nonoverlapping(dest, count);
|
||||||
},
|
},
|
||||||
5 => unsafe {
|
5 => unsafe {
|
||||||
let count = u64::from_le_bytes(msg_vec[1..9].try_into().unwrap_unchecked()) as usize;
|
let count = u32::from_le_bytes(msg_vec[1..5].try_into().unwrap_unchecked()) as usize;
|
||||||
let size = u64::from_le_bytes(msg_vec[9..17].try_into().unwrap_unchecked()) as usize;
|
let size = u32::from_le_bytes(msg_vec[5..9].try_into().unwrap_unchecked()) as usize;
|
||||||
let src =
|
|
||||||
u64::from_le_bytes(msg_vec[17..25].try_into().unwrap_unchecked()) as *const u8;
|
|
||||||
let dest = u64::from_le_bytes(msg_vec[25..33].try_into().unwrap_unchecked()) as *mut u8;
|
|
||||||
debug_assert!(src.addr() & 0xFFFF000000000000 != 0);
|
|
||||||
debug_assert!(dest.addr() & 0xFFFF000000000000 != 0);
|
|
||||||
memset(dest, src, count, size);
|
|
||||||
},
|
|
||||||
6 => unsafe {
|
|
||||||
let count = u64::from_le_bytes(msg_vec[1..9].try_into().unwrap_unchecked()) as usize;
|
|
||||||
let src = u64::from_le_bytes(msg_vec[9..17].try_into().unwrap_unchecked()) as *const u8;
|
let src = u64::from_le_bytes(msg_vec[9..17].try_into().unwrap_unchecked()) as *const u8;
|
||||||
let dest = u64::from_le_bytes(msg_vec[17..25].try_into().unwrap_unchecked()) as *mut u8;
|
let dest = u64::from_le_bytes(msg_vec[17..25].try_into().unwrap_unchecked()) as *mut u8;
|
||||||
debug_assert!(src.addr() & 0xFFFF000000000000 != 0);
|
|
||||||
debug_assert!(dest.addr() & 0xFFFF000000000000 != 0);
|
|
||||||
src.copy_to(dest, count);
|
|
||||||
},
|
|
||||||
7 => unsafe {
|
|
||||||
let page_count = u64::from_le_bytes(msg_vec[1..9].try_into().unwrap()) as usize;
|
|
||||||
let page_count_new = u64::from_le_bytes(msg_vec[9..17].try_into().unwrap()) as usize;
|
|
||||||
let ptr = u64::from_le_bytes(msg_vec[17..25].try_into().unwrap()) as *mut u8;
|
|
||||||
debug_assert!(ptr.addr() & 0xFFFF000000000000 != 0);
|
|
||||||
let ptr_new = realloc(
|
|
||||||
ptr,
|
|
||||||
Layout::from_size_align_unchecked(page_count * 4096, 8),
|
|
||||||
page_count_new * 4096,
|
|
||||||
);
|
|
||||||
|
|
||||||
log::debug!(
|
memset(dest, src, count, size);
|
||||||
"Re-allocating {} (now {}) pages from {:?} to {:?}",
|
|
||||||
page_count,
|
|
||||||
page_count_new,
|
|
||||||
ptr,
|
|
||||||
ptr_new
|
|
||||||
);
|
|
||||||
|
|
||||||
vm.registers[1] = hbvm::value::Value(ptr_new as u64);
|
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
log::debug!("Unknown memory service message type: {}", msg_type);
|
log::debug!("Unknown memory service message type: {}", msg_type);
|
||||||
|
|
|
@ -15,10 +15,8 @@ fn calc_start_of_page(ptr: u64) -> u64 {
|
||||||
panic!("unaligned");
|
panic!("unaligned");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
|
||||||
pub struct Memory {
|
pub struct Memory {
|
||||||
// TODO: map page aligned segments of memory into a table or some sort here
|
// TODO: map page aligned segments of memory into a table or some sort here
|
||||||
logger: hbvm::mem::InstrLogger,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Memory {
|
impl Memory {
|
||||||
|
@ -58,12 +56,4 @@ impl hbvm::mem::Memory for Memory {
|
||||||
unsafe fn prog_read<T: Copy>(&mut self, addr: Address) -> T {
|
unsafe fn prog_read<T: Copy>(&mut self, addr: Address) -> T {
|
||||||
(addr.get() as *const T).read()
|
(addr.get() as *const T).read()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
#[allow(unused)]
|
|
||||||
fn log_instr(&mut self, at: Address, regs: &[hbvm::value::Value]) {
|
|
||||||
// log::debug!("exec: [{:02x}] {}", at.get(), unsafe {
|
|
||||||
// self.logger.display_instr(at, regs)
|
|
||||||
// });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ type Vm = hbvm::Vm<mem::Memory, TIMER_QUOTIENT>;
|
||||||
pub struct ExecThread {
|
pub struct ExecThread {
|
||||||
vm: Vm,
|
vm: Vm,
|
||||||
stack_bottom: *mut u8,
|
stack_bottom: *mut u8,
|
||||||
program: &'static [u8],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for ExecThread {}
|
unsafe impl Send for ExecThread {}
|
||||||
|
@ -35,9 +34,9 @@ impl ExecThread {
|
||||||
self.vm.registers[2] = hbvm::value::Value(length);
|
self.vm.registers[2] = hbvm::value::Value(length);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn new(program: &'static [u8], entrypoint: Address) -> Self {
|
pub unsafe fn new(program: &[u8], entrypoint: Address) -> Self {
|
||||||
let mut vm = Vm::new(
|
let mut vm = Vm::new(
|
||||||
mem::Memory::default(),
|
mem::Memory {},
|
||||||
Address::new(program.as_ptr() as u64 + entrypoint.get()),
|
Address::new(program.as_ptr() as u64 + entrypoint.get()),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -45,11 +44,7 @@ impl ExecThread {
|
||||||
|
|
||||||
vm.write_reg(254, (stack_bottom as usize + STACK_SIZE - 1) as u64);
|
vm.write_reg(254, (stack_bottom as usize + STACK_SIZE - 1) as u64);
|
||||||
|
|
||||||
ExecThread {
|
ExecThread { vm, stack_bottom }
|
||||||
vm,
|
|
||||||
stack_bottom,
|
|
||||||
program,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +66,7 @@ impl<'p> Future for ExecThread {
|
||||||
}
|
}
|
||||||
Ok(VmRunOk::End) => return Poll::Ready(Ok(())),
|
Ok(VmRunOk::End) => return Poll::Ready(Ok(())),
|
||||||
Ok(VmRunOk::Ecall) => ecah::handler(
|
Ok(VmRunOk::Ecall) => ecah::handler(
|
||||||
&mut self,
|
&mut self.vm,
|
||||||
cx.ext()
|
cx.ext()
|
||||||
.downcast_ref()
|
.downcast_ref()
|
||||||
.expect("PID did not exist in Context"),
|
.expect("PID did not exist in Context"),
|
||||||
|
|
|
@ -19,13 +19,13 @@ use {
|
||||||
spin::{Lazy, Mutex},
|
spin::{Lazy, Mutex},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn kmain(_cmdline: &str, boot_modules: BootModules<'static>) -> ! {
|
pub fn kmain(_cmdline: &str, boot_modules: BootModules) -> ! {
|
||||||
debug!("Entered kmain");
|
debug!("Entered kmain");
|
||||||
|
|
||||||
#[cfg(feature = "ktest")]
|
#[cfg(feature = "ktest")]
|
||||||
{
|
{
|
||||||
use {crate::ktest, log::info};
|
use crate::ktest;
|
||||||
info!("Running tests");
|
debug!("TESTING");
|
||||||
ktest::test_main();
|
ktest::test_main();
|
||||||
|
|
||||||
loop {}
|
loop {}
|
||||||
|
|
|
@ -1,51 +1,38 @@
|
||||||
pub use ktest_macro::*;
|
pub use ktest_macro::ktest;
|
||||||
|
use log::debug;
|
||||||
use {
|
|
||||||
alloc::string::String,
|
|
||||||
log::{error, info},
|
|
||||||
};
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
static __ktest_start: fn() -> Result<String, String>;
|
static __ktest_start: fn();
|
||||||
static __ktest_end: fn() -> Result<String, String>;
|
static __ktest_end: fn();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Implement ktest for arm and riscv (Later problems, see below)
|
// TODO: Get test_fn linker name (may require no_mangle in macro)
|
||||||
|
// More info on tests (run the rest even if panic)
|
||||||
|
// Implement ktest for arm and riscv (Later problems, see below)
|
||||||
// Allow for arch specific tests (Leave for now)
|
// Allow for arch specific tests (Leave for now)
|
||||||
// Should panic tests
|
// Allow for ktest test name attr
|
||||||
// Test specific panic handler
|
// Usefull message at the end of testing
|
||||||
pub fn test_main() {
|
pub fn test_main() {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut current_test = &__ktest_start as *const fn() -> Result<String, String>;
|
let mut current_test = &__ktest_start as *const fn();
|
||||||
let test_end = &__ktest_end as *const fn() -> Result<String, String>;
|
let mut current = 1;
|
||||||
|
let test_end = &__ktest_end as *const fn();
|
||||||
let mut pass = 0;
|
|
||||||
let mut fail = 0;
|
|
||||||
|
|
||||||
while current_test < test_end {
|
while current_test < test_end {
|
||||||
let test_fn = *current_test;
|
let test_fn = *current_test;
|
||||||
|
|
||||||
let test_name = test_fn();
|
debug!("Running test {}", current);
|
||||||
match test_name {
|
|
||||||
Ok(name) => {
|
test_fn();
|
||||||
info!("Test: {} passed", name);
|
debug!("Test {} passed", current);
|
||||||
pass += 1;
|
|
||||||
}
|
|
||||||
Err(name) => {
|
|
||||||
error!("Test: {} failed", name);
|
|
||||||
fail += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
current_test = current_test.add(1);
|
current_test = current_test.add(1);
|
||||||
|
current += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("{}/{} tests passed", pass, pass + fail);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[ktest]
|
#[ktest]
|
||||||
pub fn trivial_assertion() {
|
pub fn trivial_assertion() {
|
||||||
ktest_eq!(1, 1);
|
assert_eq!(1, 1);
|
||||||
ktest_neq!(0, 1);
|
|
||||||
}
|
}
|
|
@ -34,10 +34,10 @@ mod memory;
|
||||||
mod task;
|
mod task;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
#[allow(improper_ctypes, non_upper_case_globals)]
|
// #[cfg(feature = "tests")]
|
||||||
mod ktest;
|
mod ktest;
|
||||||
|
|
||||||
use versioning::Version;
|
use {alloc::string::ToString, versioning::Version};
|
||||||
|
|
||||||
/// Kernel's version
|
/// Kernel's version
|
||||||
pub const VERSION: Version = Version {
|
pub const VERSION: Version = Version {
|
||||||
|
@ -49,7 +49,6 @@ pub const VERSION: Version = Version {
|
||||||
#[panic_handler]
|
#[panic_handler]
|
||||||
#[cfg(target_os = "none")]
|
#[cfg(target_os = "none")]
|
||||||
fn panic(info: &core::panic::PanicInfo) -> ! {
|
fn panic(info: &core::panic::PanicInfo) -> ! {
|
||||||
use alloc::string::ToString;
|
|
||||||
arch::register_dump();
|
arch::register_dump();
|
||||||
|
|
||||||
if let Some(loc) = info.location() {
|
if let Some(loc) = info.location() {
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
use {
|
use {
|
||||||
alloc::{
|
alloc::{boxed::Box, sync::Arc},
|
||||||
boxed::Box,
|
|
||||||
collections::{BTreeMap, BTreeSet},
|
|
||||||
sync::Arc,
|
|
||||||
},
|
|
||||||
core::{
|
core::{
|
||||||
future::Future,
|
future::Future,
|
||||||
pin::Pin,
|
pin::Pin,
|
||||||
|
@ -40,7 +36,6 @@ pub struct Executor {
|
||||||
tasks: Slab<Task>,
|
tasks: Slab<Task>,
|
||||||
task_queue: Arc<SegQueue<usize>>,
|
task_queue: Arc<SegQueue<usize>>,
|
||||||
interrupt_lookup: [Option<usize>; u8::MAX as usize],
|
interrupt_lookup: [Option<usize>; u8::MAX as usize],
|
||||||
buffer_lookup: BTreeMap<usize, BTreeSet<usize>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Executor {
|
impl Executor {
|
||||||
|
@ -49,7 +44,6 @@ impl Executor {
|
||||||
tasks: Slab::new(),
|
tasks: Slab::new(),
|
||||||
task_queue: Arc::new(SegQueue::new()),
|
task_queue: Arc::new(SegQueue::new()),
|
||||||
interrupt_lookup: [None; u8::MAX as usize],
|
interrupt_lookup: [None; u8::MAX as usize],
|
||||||
buffer_lookup: BTreeMap::new(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,19 +68,9 @@ impl Executor {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn interrupt_subscribe(&mut self, pid : usize, interrupt_type: u8){
|
pub fn interrupt_subscribe(&mut self, pid : usize, interrupt_type: u8){
|
||||||
self.pause(pid);
|
|
||||||
self.interrupt_lookup[interrupt_type as usize] = Some(pid);
|
self.interrupt_lookup[interrupt_type as usize] = Some(pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn buffer_subscribe(&mut self, pid: usize, buffer_id: usize) {
|
|
||||||
self.pause(pid);
|
|
||||||
if let Some(buf) = self.buffer_lookup.get_mut(&buffer_id) {
|
|
||||||
buf.insert(pid);
|
|
||||||
} else {
|
|
||||||
self.buffer_lookup.insert(buffer_id, BTreeSet::from([pid]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn run(&mut self) {
|
pub fn run(&mut self) {
|
||||||
let mut task_batch = [0; 32];
|
let mut task_batch = [0; 32];
|
||||||
loop {
|
loop {
|
||||||
|
@ -124,9 +108,6 @@ impl Executor {
|
||||||
}
|
}
|
||||||
return pid;
|
return pid;
|
||||||
});
|
});
|
||||||
self.buffer_lookup.iter_mut().for_each(|(_, pid_set)| {
|
|
||||||
pid_set.remove(&id);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,11 +120,6 @@ impl Executor {
|
||||||
self.unpause(id);
|
self.unpause(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn send_buffer(&self, id: usize) {
|
|
||||||
if let Some(buf) = self.buffer_lookup.get(&id) {
|
|
||||||
buf.iter().for_each(|pid| self.unpause(*pid));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Task {
|
struct Task {
|
||||||
|
|
|
@ -21,5 +21,5 @@
|
||||||
"target-c-int-width": "32",
|
"target-c-int-width": "32",
|
||||||
"target-endian": "little",
|
"target-endian": "little",
|
||||||
"target-pointer-width": "64",
|
"target-pointer-width": "64",
|
||||||
"vendor": "ablecorp"
|
"vendor": ""
|
||||||
}
|
}
|
|
@ -15,7 +15,6 @@ fatfs = { version = "0.3", default-features = false, features = [
|
||||||
] }
|
] }
|
||||||
toml = "0.8"
|
toml = "0.8"
|
||||||
hblang.git = "https://git.ablecorp.us/AbleOS/holey-bytes.git"
|
hblang.git = "https://git.ablecorp.us/AbleOS/holey-bytes.git"
|
||||||
# hblang.path = "../../holey-bytes/lang/"
|
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
raw-cpuid = "11"
|
raw-cpuid = "11"
|
||||||
ureq = { version = "2", default-features = false, features = ["tls"] }
|
ureq = { version = "2", default-features = false, features = ["tls"] }
|
||||||
|
|
|
@ -83,8 +83,7 @@ impl Package {
|
||||||
&path,
|
&path,
|
||||||
Options {
|
Options {
|
||||||
fmt: true,
|
fmt: true,
|
||||||
resolver: Some(hblang::ABLEOS_PATH_RESOLVER),
|
in_house_regalloc: true,
|
||||||
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
out,
|
out,
|
||||||
|
@ -100,7 +99,7 @@ impl Package {
|
||||||
hblang::run_compiler(
|
hblang::run_compiler(
|
||||||
&path,
|
&path,
|
||||||
Options {
|
Options {
|
||||||
resolver: Some(hblang::ABLEOS_PATH_RESOLVER),
|
in_house_regalloc: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
out,
|
out,
|
||||||
|
@ -109,20 +108,18 @@ impl Package {
|
||||||
std::fs::write(format!("target/programs/{}.hbf", self.name), &out)?;
|
std::fs::write(format!("target/programs/{}.hbf", self.name), &out)?;
|
||||||
out.clear();
|
out.clear();
|
||||||
|
|
||||||
let err = hblang::run_compiler(
|
hblang::run_compiler(
|
||||||
&path,
|
&path,
|
||||||
Options {
|
Options {
|
||||||
resolver: Some(hblang::ABLEOS_PATH_RESOLVER),
|
|
||||||
dump_asm: true,
|
dump_asm: true,
|
||||||
|
in_house_regalloc: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
out,
|
out,
|
||||||
&mut warnings,
|
&mut warnings,
|
||||||
);
|
)?;
|
||||||
std::fs::write(format!("target/programs/{}.hba", self.name), &out)?;
|
std::fs::write(format!("target/programs/{}.hba", self.name), &out)?;
|
||||||
out.clear();
|
out.clear();
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -253,10 +253,10 @@ TERM_BACKDROP={}
|
||||||
);
|
);
|
||||||
match p.build(&mut out) {
|
match p.build(&mut out) {
|
||||||
Ok(()) => {}
|
Ok(()) => {}
|
||||||
Err(e) => {
|
Err(_) => {
|
||||||
writeln!(errors, "========= while compiling {} {} =========", path, e)
|
writeln!(errors, "========= while compiling {} =========", path)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
errors.push_str(&String::from_utf8_lossy(&out));
|
errors.push_str(core::str::from_utf8(&out).expect("no"));
|
||||||
out.clear();
|
out.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -411,7 +411,6 @@ fn run(release: bool, target: Target, do_accel: bool) -> Result<(), Error> {
|
||||||
};
|
};
|
||||||
let (mut com, mut com2) = (Command::new(target_str), Command::new(target_str));
|
let (mut com, mut com2) = (Command::new(target_str), Command::new(target_str));
|
||||||
let ovmf_path = fetch_ovmf(target);
|
let ovmf_path = fetch_ovmf(target);
|
||||||
let mut cpu = "max";
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
let accel = if do_accel {
|
let accel = if do_accel {
|
||||||
let supported = String::from_utf8(
|
let supported = String::from_utf8(
|
||||||
|
@ -441,8 +440,7 @@ fn run(release: bool, target: Target, do_accel: bool) -> Result<(), Error> {
|
||||||
{
|
{
|
||||||
"accel=hax"
|
"accel=hax"
|
||||||
} else if supported.contains("whpx") {
|
} else if supported.contains("whpx") {
|
||||||
cpu = "Westmere";
|
"accel=whpx"
|
||||||
"accel=whpx,kernel-irqchip=off"
|
|
||||||
} else {
|
} else {
|
||||||
"accel=tcg"
|
"accel=tcg"
|
||||||
}
|
}
|
||||||
|
@ -457,16 +455,19 @@ fn run(release: bool, target: Target, do_accel: bool) -> Result<(), Error> {
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
com.args([
|
com.args([
|
||||||
"-bios", &ovmf_path.change_context(Error::OvmfFetch)?,
|
"-bios", &ovmf_path.change_context(Error::OvmfFetch)?,
|
||||||
//"-hda", "target/disk.img",
|
"-drive", "file=target/disk.img,format=raw",
|
||||||
"-drive", "file=target/disk.img,index=0,if=ide,format=raw",
|
|
||||||
"-device", "vmware-svga",
|
"-device", "vmware-svga",
|
||||||
// "-serial", "stdio",
|
// "-serial", "stdio",
|
||||||
"-m", "2G",
|
"-m", "2G",
|
||||||
"-smp", "1",
|
"-smp", "1",
|
||||||
|
"-audiodev",
|
||||||
|
"pa,id=speaker",
|
||||||
|
"-machine",
|
||||||
|
"pcspk-audiodev=speaker",
|
||||||
"-parallel", "none",
|
"-parallel", "none",
|
||||||
"-monitor", "none",
|
"-monitor", "none",
|
||||||
"-machine", accel,
|
"-machine", accel,
|
||||||
"-cpu", cpu,
|
"-cpu", "max",
|
||||||
"-device", "isa-debug-exit,iobase=0xf4,iosize=0x04",
|
"-device", "isa-debug-exit,iobase=0xf4,iosize=0x04",
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -509,6 +510,7 @@ fn run(release: bool, target: Target, do_accel: bool) -> Result<(), Error> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn fetch_ovmf(target: Target) -> Result<String, OvmfFetchError> {
|
fn fetch_ovmf(target: Target) -> Result<String, OvmfFetchError> {
|
||||||
let (ovmf_url, ovmf_path) = match target {
|
let (ovmf_url, ovmf_path) = match target {
|
||||||
Target::X86_64 | Target::X86_64Avx2 => (
|
Target::X86_64 | Target::X86_64Avx2 => (
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "rlbuild"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2024"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
rlisp_library = { git="https://git.ablecorp.us/able/rlisp.git"}
|
|
|
@ -1,9 +0,0 @@
|
||||||
# RLBuild
|
|
||||||
|
|
||||||
|
|
||||||
## Repos
|
|
||||||
rlbuild was built with the ability to point to multiple repos to fetch packages
|
|
||||||
|
|
||||||
repos have a url in the format
|
|
||||||
|
|
||||||
repos.ablecorp.us/<repo_name>/<?sub_repo_name>/<pkg_name>
|
|
|
@ -1,318 +0,0 @@
|
||||||
#![feature(slice_take)]
|
|
||||||
#![allow(special_module_name)]
|
|
||||||
|
|
||||||
use std::{
|
|
||||||
fs::{self, File},
|
|
||||||
io::Write,
|
|
||||||
};
|
|
||||||
|
|
||||||
use rlisp_library::{
|
|
||||||
Environ,
|
|
||||||
Expr::{self, Bool},
|
|
||||||
RispError, default_env, parse_eval,
|
|
||||||
};
|
|
||||||
|
|
||||||
mod packages;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn extend_environ<'a>(mut env: Environ<'a>) -> Environ<'a> {
|
|
||||||
env.data.insert(
|
|
||||||
"quit".to_string(),
|
|
||||||
Expr::Func(|_args: &[Expr]| -> Result<Expr, RispError> {
|
|
||||||
// TODO: let this function take in arguments
|
|
||||||
println!("Exiting.");
|
|
||||||
std::process::exit(0);
|
|
||||||
#[allow(unreachable_code)]
|
|
||||||
Err(RispError::Reason("Cannot exit process".to_string()))
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
env.data.insert(
|
|
||||||
"print".to_string(),
|
|
||||||
Expr::Func(|args: &[Expr]| -> Result<Expr, RispError> {
|
|
||||||
let mut stri = String::new();
|
|
||||||
for arg in args {
|
|
||||||
let fmted = match arg {
|
|
||||||
Expr::Str(string) => {
|
|
||||||
let string = string.clone();
|
|
||||||
// string.pop();
|
|
||||||
// string.remove(0);
|
|
||||||
|
|
||||||
format!("{}", string)
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
format!("{}", arg)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
stri.push_str(&fmted);
|
|
||||||
if args.len() > 1 {
|
|
||||||
stri.push_str(" ")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
print!("{}", stri);
|
|
||||||
|
|
||||||
Ok(Expr::Bool(true))
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
env.data.insert(
|
|
||||||
"println".to_string(),
|
|
||||||
Expr::Func(|args: &[Expr]| -> Result<Expr, RispError> {
|
|
||||||
let mut stri = String::new();
|
|
||||||
for arg in args {
|
|
||||||
let fmted = match arg {
|
|
||||||
Expr::Str(string) => {
|
|
||||||
let string = string.clone();
|
|
||||||
// string.pop();
|
|
||||||
// string.remove(0);
|
|
||||||
|
|
||||||
format!("{}", string)
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
format!("{}", arg)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
stri.push_str(&fmted);
|
|
||||||
if args.len() > 1 {
|
|
||||||
stri.push_str(" ")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
println!("{}", stri);
|
|
||||||
|
|
||||||
Ok(Expr::Bool(true))
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
env.data.insert(
|
|
||||||
"use-repo".to_string(),
|
|
||||||
Expr::Func(|args: &[Expr]| -> Result<Expr, RispError> {
|
|
||||||
let repo_name = &args[0].clone();
|
|
||||||
let mut repo_name_str = repo_name.to_string();
|
|
||||||
repo_name_str.remove(0);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let repo_url = &args[1].clone();
|
|
||||||
let use_sources = &args[2].clone();
|
|
||||||
|
|
||||||
let msg = match use_sources {
|
|
||||||
Bool(b) => match b {
|
|
||||||
true => "build_from_src = true",
|
|
||||||
false => "build_from_src = false",
|
|
||||||
},
|
|
||||||
_ => {
|
|
||||||
panic!("AHHH");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let path = format!("out/system/repos");
|
|
||||||
fs::create_dir_all(path).unwrap();
|
|
||||||
|
|
||||||
let path = format!("out/system/repos/{}.repo", repo_name_str);
|
|
||||||
println!("repo name {} repo url {} {}", repo_name, repo_url, msg);
|
|
||||||
|
|
||||||
let mut file = File::create(path).unwrap();
|
|
||||||
let msg = format!("url = {}\n{}", repo_url, msg);
|
|
||||||
let _ = file.write(msg.as_bytes());
|
|
||||||
|
|
||||||
Ok(Expr::Bool(true))
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
env.data.insert(
|
|
||||||
"bootloader-install".to_string(),
|
|
||||||
Expr::Func(|_args: &[Expr]| -> Result<Expr, RispError> {
|
|
||||||
// let loader_name = &args[1].clone();
|
|
||||||
// let mut loader_name_str = loader_name.to_string();
|
|
||||||
// loader_name_str.remove(0);
|
|
||||||
|
|
||||||
let path = format!("out/boot/limine");
|
|
||||||
fs::create_dir_all(path).unwrap();
|
|
||||||
|
|
||||||
let path = format!("out/boot/limine/config.rl");
|
|
||||||
let mut file = File::create(path).unwrap();
|
|
||||||
let _ = file.write_all(b"()");
|
|
||||||
|
|
||||||
let path = format!("out/boot/limine/limine.conf");
|
|
||||||
let mut file = File::create(path).unwrap();
|
|
||||||
let _ = file.write_all(b"");
|
|
||||||
|
|
||||||
Ok(Expr::Bool(true))
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
env.data.insert(
|
|
||||||
"pkg-install".to_string(),
|
|
||||||
Expr::Func(|args: &[Expr]| -> Result<Expr, RispError> {
|
|
||||||
let repo_name = &args[0].clone();
|
|
||||||
let pkg_name = &args[1].clone();
|
|
||||||
let mut pkg_name_str = pkg_name.to_string();
|
|
||||||
pkg_name_str.remove(0);
|
|
||||||
|
|
||||||
println!(
|
|
||||||
"installing package {} from repo {}",
|
|
||||||
pkg_name_str, repo_name
|
|
||||||
);
|
|
||||||
let path = format!("out/programs/{}", pkg_name_str);
|
|
||||||
fs::create_dir_all(path).unwrap();
|
|
||||||
|
|
||||||
let path = format!("out/programs/{}/src", pkg_name_str);
|
|
||||||
fs::create_dir_all(path).unwrap();
|
|
||||||
|
|
||||||
|
|
||||||
let path = format!("out/programs/{}/app.axe", pkg_name_str);
|
|
||||||
let mut file = File::create(path).unwrap();
|
|
||||||
|
|
||||||
|
|
||||||
let _ = file.write_all(b"");
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: build the code with the hblang compiler.
|
|
||||||
// TODO: use the meta.rli to map dependencies.
|
|
||||||
|
|
||||||
Ok(Expr::Bool(true))
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
env.data.insert(
|
|
||||||
"pkg-configure".to_string(),
|
|
||||||
Expr::Func(|args: &[Expr]| -> Result<Expr, RispError> {
|
|
||||||
let pkg_name = &args[0].clone();
|
|
||||||
let mut pkg_name_str = pkg_name.to_string();
|
|
||||||
pkg_name_str.remove(0);
|
|
||||||
|
|
||||||
println!("installing package {}.", pkg_name_str);
|
|
||||||
let path = format!("out/programs/{}/config.rl", pkg_name_str);
|
|
||||||
|
|
||||||
println!("configuring package {}", pkg_name_str);
|
|
||||||
// TODO: build the code with the hblang compiler.
|
|
||||||
// TODO: use the meta.rli to map dependencies.
|
|
||||||
let mut file = File::create(path).unwrap();
|
|
||||||
|
|
||||||
let _ = file.write_all(b"()");
|
|
||||||
|
|
||||||
Ok(Expr::Bool(true))
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
env.data.insert(
|
|
||||||
"drivers".to_string(),
|
|
||||||
Expr::Func(|args: &[Expr]| -> Result<Expr, RispError> {
|
|
||||||
let mut stri = String::new();
|
|
||||||
for arg in args {
|
|
||||||
let fmted = match arg {
|
|
||||||
Expr::Str(string) => {
|
|
||||||
let string = string.clone();
|
|
||||||
format!("{}", string)
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
format!("{}", arg)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
stri.push_str(&fmted);
|
|
||||||
if args.len() > 1 {
|
|
||||||
stri.push_str(" ")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
println!("Drivers {}", stri);
|
|
||||||
|
|
||||||
Ok(Expr::Bool(true))
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
env.data.insert(
|
|
||||||
"services".to_string(),
|
|
||||||
Expr::Func(|args: &[Expr]| -> Result<Expr, RispError> {
|
|
||||||
let mut stri = String::new();
|
|
||||||
for arg in args {
|
|
||||||
let fmted = match arg {
|
|
||||||
Expr::Str(string) => {
|
|
||||||
let string = string.clone();
|
|
||||||
// string.pop();
|
|
||||||
// string.remove(0);
|
|
||||||
|
|
||||||
format!("{}", string)
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
format!("{}", arg)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
stri.push_str(&fmted);
|
|
||||||
if args.len() > 1 {
|
|
||||||
stri.push_str(" ")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
println!("Services {}", stri);
|
|
||||||
|
|
||||||
Ok(Expr::Bool(true))
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
env.data.insert(
|
|
||||||
"reincarnation-server".to_string(),
|
|
||||||
Expr::Func(|args: &[Expr]| -> Result<Expr, RispError> {
|
|
||||||
let reinc = &args[0].clone();
|
|
||||||
println!("Reincarnation Server {}", reinc);
|
|
||||||
|
|
||||||
Ok(Expr::Bool(true))
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
env
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let env = &mut default_env();
|
|
||||||
let env = &mut extend_environ(env.clone());
|
|
||||||
|
|
||||||
let cfg = include_str!("../../sysdata/system.lisp");
|
|
||||||
|
|
||||||
let mut complete_exprs: Vec<String> = vec![];
|
|
||||||
let mut left_parens = 0;
|
|
||||||
let mut idx_of_first_left_paran = 0;
|
|
||||||
|
|
||||||
for (i, character) in cfg.chars().enumerate() {
|
|
||||||
if character == '(' {
|
|
||||||
if left_parens == 0 {
|
|
||||||
idx_of_first_left_paran = i;
|
|
||||||
}
|
|
||||||
left_parens += 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if character == ')' {
|
|
||||||
left_parens -= 1;
|
|
||||||
if left_parens == 0 {
|
|
||||||
let idx_of_last_right_paran = i + 1;
|
|
||||||
|
|
||||||
complete_exprs
|
|
||||||
.push(cfg[idx_of_first_left_paran..idx_of_last_right_paran].to_string());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if left_parens != 0 {
|
|
||||||
panic!("unmatched parens. Good luck finding them!");
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Mount the disk image here.
|
|
||||||
|
|
||||||
for expr in complete_exprs {
|
|
||||||
match parse_eval(expr, env) {
|
|
||||||
Ok(_res) => {}
|
|
||||||
Err(e) => {
|
|
||||||
panic!("{:?}", e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let path = format!("out/system/config.rl");
|
|
||||||
|
|
||||||
let mut file = File::create(path).unwrap();
|
|
||||||
|
|
||||||
let _ = file.write_all(cfg.as_bytes());
|
|
||||||
|
|
||||||
// TODO: unmount the disk image here.
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
pub enum GitOrRepo {
|
|
||||||
Git(String),
|
|
||||||
Repo(String)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pub struct Package {
|
|
||||||
name: String,
|
|
||||||
authors: Vec<String>,
|
|
||||||
tags: Vec<String>,
|
|
||||||
version: u8,
|
|
||||||
depends: Vec<(String, String)>,
|
|
||||||
git_or_repo: GitOrRepo,
|
|
||||||
}
|
|
||||||
impl Package{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "nightly"
|
# old toolchain
|
||||||
|
# channel = "nightly-2024-07-27"
|
||||||
|
channel = "nightly-2024-11-20"
|
||||||
components = ["rust-src", "llvm-tools"]
|
components = ["rust-src", "llvm-tools"]
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
# clippy
|
|
||||||
Uhm maybe change the name haha
|
|
|
@ -1,63 +0,0 @@
|
||||||
TagType := enum {
|
|
||||||
Binary,
|
|
||||||
// Text is in UTF8 format.
|
|
||||||
Text,
|
|
||||||
// Images are in QOI format
|
|
||||||
Image,
|
|
||||||
// A path to a file or folder on disk. In the format of FileID.
|
|
||||||
Path,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Transdimensionally located here to make following code easier
|
|
||||||
FileID := struct {
|
|
||||||
host_id: HostID,
|
|
||||||
id: ID,
|
|
||||||
}
|
|
||||||
|
|
||||||
Note := struct {
|
|
||||||
tag: TagType,
|
|
||||||
data_length: uint,
|
|
||||||
data: ^u8,
|
|
||||||
next_note: ^Note,
|
|
||||||
last_note: ^Note,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Clipboard = struct {
|
|
||||||
current_note_count: u8,
|
|
||||||
// Maybe max it at like 5.
|
|
||||||
total_note_count: u8,
|
|
||||||
start_notes: ^Note,
|
|
||||||
// Does it even make sense to have this?
|
|
||||||
end_notes: ^Note,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Ctrl + Up arrow moves the clip board forward
|
|
||||||
flip_board_forward = fn(): void {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ctrl + arrow moves the clip board backward
|
|
||||||
flip_board_backward = fn(): void {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Ctrl + V soft paste. Pastes text without removing it from your clipboard.
|
|
||||||
soft_paste = fn(): void {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Ctrl + Shift + V hard paste. Pastes text removing it from your clipboard.
|
|
||||||
hard_paste = fn(): void {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ctrl + C copy. Copies text into the clipboard on a new page. Filling a blank one or pushing the oldest page out.
|
|
||||||
copy = fn(): void {}
|
|
||||||
|
|
||||||
|
|
||||||
// Ctrl + X Cut. Cuts text into the clipboard on a new page. Filling a blank one or pushing the oldest page out.
|
|
||||||
cut = fn(): void {}
|
|
|
@ -9,19 +9,19 @@ widgets := @use("widgets/widgets.hb")
|
||||||
ui := @use("ui.hb")
|
ui := @use("ui.hb")
|
||||||
|
|
||||||
WindowID := struct {
|
WindowID := struct {
|
||||||
host_id: uint,
|
host_id: int,
|
||||||
window_id: uint,
|
window_id: int,
|
||||||
}
|
}
|
||||||
|
|
||||||
VoidWindowID := WindowID.(0, 0)
|
VoidWindowID := WindowID.(0, 0)
|
||||||
|
|
||||||
create_window := fn(channel: uint): ^render.Surface {
|
create_window := fn(channel: int): ^render.Surface {
|
||||||
// get the horizon buffer
|
// get the horizon buffer
|
||||||
// request a new window and provide the callback buffer
|
// request a new window and provide the callback buffer
|
||||||
// wait to recieve a message
|
// wait to recieve a message
|
||||||
|
|
||||||
windowing_system_buffer := buffer.search("XHorizon")
|
windowing_system_buffer := buffer.search("XHorizon\0")
|
||||||
mem_buf := memory.request_page(1, false)
|
mem_buf := memory.request_page(1)
|
||||||
|
|
||||||
if windowing_system_buffer == 0 {
|
if windowing_system_buffer == 0 {
|
||||||
return @as(^render.Surface, idk)
|
return @as(^render.Surface, idk)
|
||||||
|
@ -29,13 +29,13 @@ create_window := fn(channel: uint): ^render.Surface {
|
||||||
x := 0
|
x := 0
|
||||||
loop if x > 1000 break else x += 1
|
loop if x > 1000 break else x += 1
|
||||||
|
|
||||||
ret := buffer.recv([4096]u8, windowing_system_buffer, mem_buf)
|
ret := buffer.recv([u8; 4096], windowing_system_buffer, mem_buf)
|
||||||
if ret == null {
|
if ret == null {
|
||||||
log.info("No messages")
|
log.info("No messages\0")
|
||||||
}
|
}
|
||||||
|
|
||||||
if *mem_buf == 0 {
|
if *mem_buf == 0 {
|
||||||
log.info("No messages")
|
log.info("No messages\0")
|
||||||
}
|
}
|
||||||
|
|
||||||
return @as(^render.Surface, idk)
|
return @as(^render.Surface, idk)
|
||||||
|
|
|
@ -6,7 +6,7 @@ render := @use("../../../libraries/render/src/lib.hb");
|
||||||
.{Surface} := render;
|
.{Surface} := render;
|
||||||
.{Font} := render.text
|
.{Font} := render.text
|
||||||
|
|
||||||
UI := struct {raw: []u8, is_dirty: bool, surface: Surface, // Each child has their WidgetType as their first byte
|
UI := struct {raw: ^u8, raw_length: uint, is_dirty: bool, surface: Surface, // Each child has their WidgetType as their first byte
|
||||||
// children: ^^u8,
|
// children: ^^u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,26 +19,29 @@ render_ui := fn(surface: Surface, ui: UI): void {
|
||||||
render.put_surface(surface, ui.surface, pos, false)
|
render.put_surface(surface, ui.surface, pos, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
sexpr_parser := fn(sexpr: []u8): UI {
|
sexpr_parser := fn(sexpr: ^u8): UI {
|
||||||
i := 0
|
cursor := sexpr
|
||||||
paren_balance := 0
|
paren_balance := 0
|
||||||
loop {
|
loop {
|
||||||
if i == sexpr.len {
|
if *cursor == 0 {
|
||||||
if paren_balance != 0 {
|
if paren_balance != 0 {
|
||||||
log.error("Unbalanced Parens")
|
log.error("Unbalanced Parens\0")
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
} else if sexpr[i] == '(' {
|
} else if *cursor == 40 {
|
||||||
log.info("Open paren")
|
log.info("Open paren\0")
|
||||||
paren_balance += 1
|
paren_balance += 1
|
||||||
} else if sexpr[i] == ')' {
|
} else if *cursor == 41 {
|
||||||
log.info("Closed paren")
|
log.info("Closed paren\0")
|
||||||
paren_balance -= 1
|
paren_balance -= 1
|
||||||
}
|
}
|
||||||
|
|
||||||
i += 1
|
cursor += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
length := string.length(sexpr)
|
||||||
|
|
||||||
ui_surface := render.new_surface(100, 100)
|
ui_surface := render.new_surface(100, 100)
|
||||||
return UI.(sexpr, true, ui_surface)
|
|
||||||
|
return UI.(sexpr, length, true, ui_surface)
|
||||||
}
|
}
|
|
@ -10,22 +10,27 @@ Label := struct {
|
||||||
magic: uint,
|
magic: uint,
|
||||||
is_dirty: bool,
|
is_dirty: bool,
|
||||||
surface: Surface,
|
surface: Surface,
|
||||||
text: []u8,
|
text: ^u8,
|
||||||
|
text_length: uint,
|
||||||
bg: Color,
|
bg: Color,
|
||||||
fg: Color,
|
fg: Color,
|
||||||
|
|
||||||
new_label := fn(text: []u8, width: uint): Self {
|
new_label := fn(text: ^u8): Self {
|
||||||
text_surface := render.Surface.new(width, 20)
|
text_surface := render.new_surface(1024, 20)
|
||||||
label := Self.(3, true, text_surface, text, render.BLACK, render.WHITE)
|
text_length := string.length(text)
|
||||||
|
label := Self.(3, true, text_surface, text, text_length, render.black, render.white)
|
||||||
return label
|
return label
|
||||||
}
|
}
|
||||||
|
|
||||||
$set_label_text := fn(self: ^Self, text: []u8): void {
|
set_label_text := fn(self: Self, text: ^u8): void {
|
||||||
|
text_length := string.length(text)
|
||||||
|
|
||||||
self.is_dirty = true
|
self.is_dirty = true
|
||||||
self.text = text
|
self.text = text
|
||||||
|
self.text_length = text_length
|
||||||
}
|
}
|
||||||
|
|
||||||
$set_color := fn(self: ^Self, bg: Color, fg: Color): void {
|
$set_color := fn(self: Self, bg: Color, fg: Color): void {
|
||||||
self.bg = bg
|
self.bg = bg
|
||||||
self.fg = fg
|
self.fg = fg
|
||||||
self.is_dirty = true
|
self.is_dirty = true
|
||||||
|
@ -34,8 +39,8 @@ Label := struct {
|
||||||
|
|
||||||
render_label_to_surface := fn(surface: Surface, label: Label, font: Font, pos: Vec2(uint)): void {
|
render_label_to_surface := fn(surface: Surface, label: Label, font: Font, pos: Vec2(uint)): void {
|
||||||
if label.is_dirty {
|
if label.is_dirty {
|
||||||
label.surface.clear(label.bg)
|
render.clear(label.surface, label.bg)
|
||||||
label.surface.put_text(font, .(0, 0), label.fg, label.text)
|
render.put_text(label.surface, font, .(0, 0), label.fg, label.text)
|
||||||
}
|
}
|
||||||
surface.put_surface(label.surface, pos, false)
|
render.put_surface(surface, label.surface, pos, false)
|
||||||
}
|
}
|
|
@ -2,17 +2,17 @@ keycodes := @use("keycodes.hb");
|
||||||
.{KeyCode} := keycodes
|
.{KeyCode} := keycodes
|
||||||
|
|
||||||
KeyEvent := packed struct {
|
KeyEvent := packed struct {
|
||||||
up: bool = false,
|
up: bool,
|
||||||
just_triggered: bool = false,
|
just_triggered: bool,
|
||||||
key: KeyCode = 0,
|
key: KeyCode,
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseEvent := packed struct {
|
MouseEvent := packed struct {
|
||||||
x_change: i8 = 0,
|
x_change: i8,
|
||||||
y_change: i8 = 0,
|
y_change: i8,
|
||||||
left: bool = false,
|
left: bool,
|
||||||
middle: bool = false,
|
middle: bool,
|
||||||
right: bool = false,
|
right: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
GamepadEvent := struct {}
|
GamepadEvent := struct {}
|
|
@ -7,89 +7,115 @@ I am now modelling it as I see fit. This is likely not the final version.
|
||||||
|
|
||||||
KeyCode := u32
|
KeyCode := u32
|
||||||
|
|
||||||
$NONE: KeyCode = 0
|
// Typically this is not a keycode you will ever recieve.
|
||||||
$ESCAPE: KeyCode = 1
|
None := KeyCode.(0)
|
||||||
$A: KeyCode = 2
|
|
||||||
$B: KeyCode = 3
|
Escape := KeyCode.(1)
|
||||||
$C: KeyCode = 4
|
/* Alphabet keycodes */
|
||||||
$D: KeyCode = 5
|
|
||||||
$E: KeyCode = 6
|
A := KeyCode.(2)
|
||||||
$F: KeyCode = 7
|
B := KeyCode.(3)
|
||||||
$G: KeyCode = 8
|
C := KeyCode.(4)
|
||||||
$H: KeyCode = 9
|
D := KeyCode.(5)
|
||||||
$I: KeyCode = 10
|
E := KeyCode.(6)
|
||||||
$J: KeyCode = 11
|
F := KeyCode.(7)
|
||||||
$K: KeyCode = 12
|
G := KeyCode.(8)
|
||||||
$L: KeyCode = 13
|
H := KeyCode.(9)
|
||||||
$M: KeyCode = 14
|
I := KeyCode.(10)
|
||||||
$N: KeyCode = 15
|
J := KeyCode.(11)
|
||||||
$O: KeyCode = 16
|
K := KeyCode.(12)
|
||||||
$P: KeyCode = 17
|
L := KeyCode.(13)
|
||||||
$Q: KeyCode = 18
|
M := KeyCode.(14)
|
||||||
$R: KeyCode = 19
|
N := KeyCode.(15)
|
||||||
$S: KeyCode = 20
|
O := KeyCode.(16)
|
||||||
$T: KeyCode = 21
|
P := KeyCode.(17)
|
||||||
$U: KeyCode = 22
|
Q := KeyCode.(18)
|
||||||
$V: KeyCode = 23
|
R := KeyCode.(19)
|
||||||
$W: KeyCode = 24
|
S := KeyCode.(20)
|
||||||
$X: KeyCode = 25
|
T := KeyCode.(21)
|
||||||
$Y: KeyCode = 26
|
U := KeyCode.(22)
|
||||||
$Z: KeyCode = 27
|
V := KeyCode.(23)
|
||||||
$NUMBER0: KeyCode = 28
|
W := KeyCode.(24)
|
||||||
$NUMBER1: KeyCode = 29
|
X := KeyCode.(25)
|
||||||
$NUMBER2: KeyCode = 30
|
Y := KeyCode.(26)
|
||||||
$NUMBER3: KeyCode = 31
|
Z := KeyCode.(27)
|
||||||
$NUMBER4: KeyCode = 32
|
|
||||||
$NUMBER5: KeyCode = 33
|
/* Numeric keycodes*/
|
||||||
$NUMBER6: KeyCode = 34
|
|
||||||
$NUMBER7: KeyCode = 35
|
Number0 := KeyCode.(28)
|
||||||
$NUMBER8: KeyCode = 36
|
Number1 := KeyCode.(29)
|
||||||
$NUMBER9: KeyCode = 37
|
Number2 := KeyCode.(30)
|
||||||
$KEYPADNUMBER0: KeyCode = 38
|
Number3 := KeyCode.(31)
|
||||||
$KEYPADNUMBER1: KeyCode = 39
|
Number4 := KeyCode.(32)
|
||||||
$KEYPADNUMBER2: KeyCode = 40
|
Number5 := KeyCode.(33)
|
||||||
$KEYPADNUMBER3: KeyCode = 41
|
Number6 := KeyCode.(34)
|
||||||
$KEYPADNUMBER4: KeyCode = 42
|
Number7 := KeyCode.(35)
|
||||||
$KEYPADNUMBER5: KeyCode = 43
|
Number8 := KeyCode.(36)
|
||||||
$KEYPADNUMBER6: KeyCode = 44
|
Number9 := KeyCode.(37)
|
||||||
$KEYPADNUMBER7: KeyCode = 45
|
|
||||||
$KEYPADNUMBER8: KeyCode = 46
|
KeypadNumber0 := KeyCode.(38)
|
||||||
$KEYPADNUMBER9: KeyCode = 47
|
KeypadNumber1 := KeyCode.(39)
|
||||||
$KEYPADPERIOD: KeyCode = 48
|
KeypadNumber2 := KeyCode.(40)
|
||||||
$KEYPADDIVIDE: KeyCode = 49
|
KeypadNumber3 := KeyCode.(41)
|
||||||
$KEYPADMULTIPLY: KeyCode = 50
|
KeypadNumber4 := KeyCode.(42)
|
||||||
$KEYPADMINUS: KeyCode = 51
|
KeypadNumber5 := KeyCode.(43)
|
||||||
$KEYPADPLUS: KeyCode = 52
|
KeypadNumber6 := KeyCode.(44)
|
||||||
$KEYPADENTER: KeyCode = 53
|
KeypadNumber7 := KeyCode.(45)
|
||||||
$KEYPADEQUALS: KeyCode = 54
|
KeypadNumber8 := KeyCode.(46)
|
||||||
$DELETE: KeyCode = 55
|
KeypadNumber9 := KeyCode.(47)
|
||||||
$NUMLOCK: KeyCode = 56
|
|
||||||
$CAPSLOCK: KeyCode = 57
|
KeypadPeriod := KeyCode.(48)
|
||||||
$SCROLLLOCK: KeyCode = 58
|
KeypadDivide := KeyCode.(49)
|
||||||
$MODE: KeyCode = 59
|
KeypadMultiply := KeyCode.(50)
|
||||||
$COMPOSE: KeyCode = 60
|
KeypadMinus := KeyCode.(51)
|
||||||
$LEFTALT: KeyCode = 61
|
KeypadPlus := KeyCode.(52)
|
||||||
$LEFTCONTROL: KeyCode = 62
|
KeypadEnter := KeyCode.(53)
|
||||||
$LEFTMETA: KeyCode = 63
|
KeypadEquals := KeyCode.(54)
|
||||||
$LEFTSHIFT: KeyCode = 64
|
|
||||||
$LEFTSUPER: KeyCode = 65
|
Delete := KeyCode.(55)
|
||||||
$RIGHTALT: KeyCode = 66
|
/* Locking Keys */
|
||||||
$RIGHTCONTROL: KeyCode = 67
|
NumLock := KeyCode.(56)
|
||||||
$RIGHTMETA: KeyCode = 68
|
CapsLock := KeyCode.(57)
|
||||||
$RIGHTSHIFT: KeyCode = 69
|
ScrollLock := KeyCode.(58)
|
||||||
$RIGHTSUPER: KeyCode = 70
|
|
||||||
$ANYNUMBER0: KeyCode = 71
|
/* "Alt Gr" key */
|
||||||
$ANYNUMBER1: KeyCode = 72
|
Mode := KeyCode.(59)
|
||||||
$ANYNUMBER2: KeyCode = 73
|
|
||||||
$ANYNUMBER3: KeyCode = 74
|
/* Multi-key compose key */
|
||||||
$ANYNUMBER4: KeyCode = 75
|
Compose := KeyCode.(60)
|
||||||
$ANYNUMBER5: KeyCode = 76
|
|
||||||
$ANYNUMBER6: KeyCode = 77
|
LeftAlt := KeyCode.(61)
|
||||||
$ANYNUMBER7: KeyCode = 78
|
LeftControl := KeyCode.(62)
|
||||||
$ANYNUMBER8: KeyCode = 79
|
LeftMeta := KeyCode.(63)
|
||||||
$ANYNUMBER9: KeyCode = 80
|
LeftShift := KeyCode.(64)
|
||||||
$ANYALT: KeyCode = 81
|
/* Left "Windows" key */
|
||||||
$ANYCONTROL: KeyCode = 82
|
LeftSuper := KeyCode.(65)
|
||||||
$ANYMETA: KeyCode = 83
|
|
||||||
$ANYSHIFT: KeyCode = 84
|
RightAlt := KeyCode.(66)
|
||||||
$ANYSUPER: KeyCode = 85
|
RightControl := KeyCode.(67)
|
||||||
|
RightMeta := KeyCode.(68)
|
||||||
|
RightShift := KeyCode.(69)
|
||||||
|
/* Right "Windows" key */
|
||||||
|
RightSuper := KeyCode.(70)
|
||||||
|
|
||||||
|
/*
|
||||||
|
This block of any triggers on any press of any of the keys.
|
||||||
|
Typically this is the event to care about.
|
||||||
|
*/
|
||||||
|
AnyNumber0 := KeyCode.(71)
|
||||||
|
AnyNumber1 := KeyCode.(72)
|
||||||
|
AnyNumber2 := KeyCode.(73)
|
||||||
|
AnyNumber3 := KeyCode.(74)
|
||||||
|
AnyNumber4 := KeyCode.(75)
|
||||||
|
AnyNumber5 := KeyCode.(76)
|
||||||
|
AnyNumber6 := KeyCode.(77)
|
||||||
|
AnyNumber7 := KeyCode.(78)
|
||||||
|
AnyNumber8 := KeyCode.(79)
|
||||||
|
AnyNumber9 := KeyCode.(80)
|
||||||
|
|
||||||
|
AnyAlt := KeyCode.(81)
|
||||||
|
AnyControl := KeyCode.(82)
|
||||||
|
AnyMeta := KeyCode.(83)
|
||||||
|
AnyShift := KeyCode.(84)
|
||||||
|
/* Any "Windows" key */
|
||||||
|
AnySuper := KeyCode.(85)
|
|
@ -1,25 +1,19 @@
|
||||||
stn := @use("stn");
|
stn := @use("../../stn/src/lib.hb");
|
||||||
.{log, buffer, memory} := stn
|
.{log, buffer, memory} := stn
|
||||||
keycodes := @use("keycodes.hb")
|
keycodes := @use("keycodes.hb")
|
||||||
|
|
||||||
events := @use("events.hb");
|
events := @use("events.hb");
|
||||||
.{KeyEvent, MouseEvent} := events
|
.{KeyEvent, MouseEvent} := events
|
||||||
|
|
||||||
key_buf := 0
|
|
||||||
mouse_buf := 0
|
|
||||||
|
|
||||||
recieve_key_event := fn(): ?KeyEvent {
|
recieve_key_event := fn(): ?KeyEvent {
|
||||||
kevent := KeyEvent.{}
|
kevent := KeyEvent.(false, false, 0)
|
||||||
|
|
||||||
if key_buf == 0 {
|
buf_id := buffer.search("PS/2 Keyboard\0")
|
||||||
key_buf = buffer.search("PS/2 Keyboard")
|
|
||||||
if key_buf == 0 return null
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read out of the Keyboard buffer here
|
// Read out of the Keyboard buffer here
|
||||||
buffer.recv(KeyEvent, key_buf, &kevent)
|
buffer.recv(KeyEvent, buf_id, &kevent)
|
||||||
|
|
||||||
if kevent != .{} {
|
if kevent.just_triggered {
|
||||||
return kevent
|
return kevent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,17 +21,14 @@ recieve_key_event := fn(): ?KeyEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
recieve_mouse_event := fn(): ?MouseEvent {
|
recieve_mouse_event := fn(): ?MouseEvent {
|
||||||
mevent := MouseEvent.{}
|
mevent := MouseEvent.(0, 0, false, false, false)
|
||||||
|
|
||||||
if mouse_buf == 0 {
|
buf_id := buffer.search("PS/2 Mouse\0")
|
||||||
mouse_buf = buffer.search("PS/2 Mouse")
|
|
||||||
if mouse_buf == 0 return null
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read out of the Mouse buffer here
|
// Read out of the Mouse buffer here
|
||||||
buffer.recv(MouseEvent, mouse_buf, &mevent)
|
buffer.recv(MouseEvent, buf_id, &mevent)
|
||||||
|
|
||||||
if mevent != .{} {
|
if mevent.x_change != 0 | mevent.y_change != 0 | mevent.left | mevent.middle | mevent.right {
|
||||||
return mevent
|
return mevent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.{string, memory, buffer, log} := @use("stn")
|
.{string, memory, buffer, log} := @use("../../stn/src/lib.hb")
|
||||||
|
|
||||||
PCIAddress := struct {
|
PCIAddress := struct {
|
||||||
bus: u8,
|
bus: u8,
|
||||||
|
@ -51,9 +51,9 @@ check_device := fn(bus: u8, device: u8): PciDeviceInfo {
|
||||||
pci_id := get_ids(bus, device, 0)
|
pci_id := get_ids(bus, device, 0)
|
||||||
|
|
||||||
if pci_id.vendor == 0xFFFF {
|
if pci_id.vendor == 0xFFFF {
|
||||||
log.warn(":|")
|
log.warn(":|\0")
|
||||||
} else {
|
} else {
|
||||||
log.info(":)")
|
log.info(":)\0")
|
||||||
}
|
}
|
||||||
address := calculate_address(bus, device, 0, 0x8)
|
address := calculate_address(bus, device, 0, 0x8)
|
||||||
reg2 := config_read32(bus, device, 0, 0x8)
|
reg2 := config_read32(bus, device, 0, 0x8)
|
||||||
|
|
|
@ -4,3 +4,6 @@ Rendering interface for SVGA and Software renderers
|
||||||
|
|
||||||
- SVGA Driver
|
- SVGA Driver
|
||||||
- needs pci driver
|
- needs pci driver
|
||||||
|
- needs init (requiring program)
|
||||||
|
- Double Buffer mode for Software renderer
|
||||||
|
- needs init (requiring program)
|
|
@ -1,5 +1,5 @@
|
||||||
.{Color, Surface, new_surface, put_surface} := @use("lib:render");
|
.{Color, Surface, new_surface, put_surface} := @use("../lib.hb");
|
||||||
.{log} := @use("stn")
|
.{log} := @use("../../../stn/src/lib.hb")
|
||||||
|
|
||||||
BitmapFileHeader := packed struct {
|
BitmapFileHeader := packed struct {
|
||||||
magic: u16,
|
magic: u16,
|
||||||
|
@ -37,13 +37,13 @@ from := fn(bmp: ^u8): ?Surface {
|
||||||
info_header := @as(^BitmapInfoHeader, @bitcast(bmp + @sizeof(BitmapFileHeader)))
|
info_header := @as(^BitmapInfoHeader, @bitcast(bmp + @sizeof(BitmapFileHeader)))
|
||||||
|
|
||||||
if file_header.magic != 0x4D42 | info_header.width == 0 | info_header.height == 0 {
|
if file_header.magic != 0x4D42 | info_header.width == 0 | info_header.height == 0 {
|
||||||
log.error("Invalid BMP image.")
|
log.error("Invalid BMP image.\0")
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
lhs := Surface.(@bitcast(bmp + file_header.offset), info_header.width, info_header.height, info_header.width * info_header.height)
|
lhs := Surface.(@bitcast(bmp + file_header.offset), info_header.width, info_header.height, info_header.width * info_header.height)
|
||||||
rhs := Surface.new(info_header.width, info_header.height)
|
rhs := new_surface(info_header.width, info_header.height)
|
||||||
rhs.put_surface(lhs, .(0, 0), true)
|
put_surface(rhs, lhs, .(0, 0), true)
|
||||||
|
|
||||||
return rhs
|
return rhs
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
.{log} := @use("stn");
|
.{log} := @use("../../../stn/src/lib.hb");
|
||||||
.{Surface} := @use("lib:render")
|
.{Surface} := @use("../lib.hb")
|
||||||
bmp := @use("bmp.hb")
|
bmp := @use("bmp.hb")
|
||||||
qoi := @use("qoi.hb")
|
qoi := @use("qoi.hb")
|
||||||
$BMP := 0x4D42
|
$BMP := 0x4D42
|
||||||
|
@ -19,7 +19,7 @@ from := fn(file: ^u8): ?Surface {
|
||||||
format := get_format(file)
|
format := get_format(file)
|
||||||
|
|
||||||
if format == null {
|
if format == null {
|
||||||
log.error("Could not detect image format.")
|
log.error("Could not detect image format.\0")
|
||||||
return null
|
return null
|
||||||
} else if format == BMP {
|
} else if format == BMP {
|
||||||
return bmp.from(file)
|
return bmp.from(file)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
.{Color, Surface, new_surface} := @use("lib:render");
|
.{Color, Surface, new_surface} := @use("../lib.hb");
|
||||||
.{log} := @use("stn")
|
.{log} := @use("../../../stn/src/lib.hb")
|
||||||
|
|
||||||
/* source:
|
/* source:
|
||||||
https://github.com/phoboslab/qoi/blob/master/qoi.h */
|
https://github.com/phoboslab/qoi/blob/master/qoi.h */
|
||||||
|
@ -40,12 +40,12 @@ from := fn(qoi: ^u8): ?Surface {
|
||||||
height := be_to_le(header.height)
|
height := be_to_le(header.height)
|
||||||
|
|
||||||
if be_to_le(header.magic) != QOI_MAGIC | width == 0 | height == 0 | header.channels < 3 | header.channels > 4 {
|
if be_to_le(header.magic) != QOI_MAGIC | width == 0 | height == 0 | header.channels < 3 | header.channels > 4 {
|
||||||
log.error("Invalid QOI image.")
|
log.error("Invalid QOI image.\0")
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
surface := Surface.new(width, height)
|
surface := new_surface(width, height)
|
||||||
index := @as([64]Color, idk)
|
index := @as([Color; 64], idk)
|
||||||
|
|
||||||
run := 0
|
run := 0
|
||||||
px := Color.(0, 0, 0, 255)
|
px := Color.(0, 0, 0, 255)
|
||||||
|
|
|
@ -6,23 +6,52 @@ text := @use("text.hb")
|
||||||
mode := software
|
mode := software
|
||||||
|
|
||||||
init := mode.init
|
init := mode.init
|
||||||
|
doublebuffer := mode.doublebuffer
|
||||||
Surface := mode.Surface
|
Surface := mode.Surface
|
||||||
|
new_surface := mode.new_surface
|
||||||
|
surface_from_ptr := mode.surface_from_ptr
|
||||||
|
clone_surface := mode.clone_surface
|
||||||
|
free_surface := mode.free_surface
|
||||||
|
index := mode.index
|
||||||
|
indexptr := mode.indexptr
|
||||||
|
|
||||||
// Colours
|
// Colours
|
||||||
Color := packed struct {b: u8, g: u8, r: u8, a: u8}
|
Color := packed struct {b: u8, g: u8, r: u8, a: u8}
|
||||||
$WHITE := Color.(255, 255, 255, 255)
|
$white := Color.(255, 255, 255, 255)
|
||||||
$BLACK := Color.(0, 0, 0, 255)
|
$black := Color.(0, 0, 0, 255)
|
||||||
$GRAY := Color.(127, 127, 127, 255)
|
$gray := Color.(127, 127, 127, 255)
|
||||||
$RED := Color.(0, 0, 205, 255)
|
$red := Color.(0, 0, 205, 255)
|
||||||
$GREEN := Color.(0, 205, 0, 255)
|
$green := Color.(0, 205, 0, 255)
|
||||||
$YELLOW := Color.(0, 205, 205, 255)
|
$yellow := Color.(0, 205, 205, 255)
|
||||||
$BLUE := Color.(205, 0, 0, 255)
|
$blue := Color.(205, 0, 0, 255)
|
||||||
$MAGENTA := Color.(205, 0, 205, 255)
|
$magenta := Color.(205, 0, 205, 255)
|
||||||
$CYAN := Color.(205, 205, 0, 255)
|
$cyan := Color.(205, 205, 0, 255)
|
||||||
$LIGHT_GRAY := Color.(229, 229, 229, 255)
|
$light_gray := Color.(229, 229, 229, 255)
|
||||||
$LIGHT_RED := Color.(0, 0, 255, 255)
|
$light_red := Color.(0, 0, 255, 255)
|
||||||
$LIGHT_GREEN := Color.(0, 255, 0, 255)
|
$light_green := Color.(0, 255, 0, 255)
|
||||||
$LIGHT_YELLOW := Color.(0, 255, 255, 255)
|
$light_yellow := Color.(0, 255, 255, 255)
|
||||||
$LIGHT_BLUE := Color.(255, 0, 0, 255)
|
$light_blue := Color.(255, 0, 0, 255)
|
||||||
$LIGHT_MAGENTA := Color.(255, 0, 255, 255)
|
$light_magenta := Color.(255, 0, 255, 255)
|
||||||
$LIGHT_CYAN := Color.(255, 255, 0, 255)
|
$light_cyan := Color.(255, 255, 0, 255)
|
||||||
|
|
||||||
|
// Drawing
|
||||||
|
put_pixel := mode.put_pixel
|
||||||
|
put_rect := mode.put_rect
|
||||||
|
put_filled_rect := mode.put_filled_rect
|
||||||
|
put_trirect := mode.put_trirect
|
||||||
|
put_circle := mode.put_circle
|
||||||
|
put_filled_circle := mode.put_filled_circle
|
||||||
|
put_textured_circle := mode.put_textured_circle
|
||||||
|
put_line := mode.put_line
|
||||||
|
put_vline := mode.put_vline
|
||||||
|
put_hline := mode.put_hline
|
||||||
|
clear := mode.clear
|
||||||
|
put_surface := mode.put_surface
|
||||||
|
put_text := mode.put_text
|
||||||
|
// thanks peony for these three!
|
||||||
|
//put_trirect := mode.put_trirect
|
||||||
|
//put_vline := mode.put_vline
|
||||||
|
//put_hline := mode.put_hline
|
||||||
|
|
||||||
|
// Display
|
||||||
|
sync := mode.sync
|
|
@ -1,100 +1,104 @@
|
||||||
.{math, memory, dt} := @use("stn");
|
.{math, memory, dt} := @use("../../stn/src/lib.hb");
|
||||||
.{Color, text} := @use("lib:render");
|
.{Color, text} := @use("lib.hb");
|
||||||
.{get_glyph, get_glyph_unicode, Font, UNC_TABLE_SIZE} := text;
|
.{get_glyph, get_glyph_unicode, Font, UNC_TABLE_SIZE} := text;
|
||||||
.{Vec2} := math
|
.{Vec2} := math
|
||||||
|
|
||||||
// safety: don't use before init() or you will get a memory access violation
|
// safety: don't use before init() or you will get a memory access violation
|
||||||
framebuffer := memory.dangling(Color)
|
framebuffer := memory.dangling(Color)
|
||||||
utf8_len_table := u8.[0, 0, 2, 3]
|
|
||||||
|
|
||||||
init := fn(doublebuffer: bool): Surface {
|
|
||||||
framebuffer = dt.get(^Color, "framebuffer/fb0/ptr")
|
|
||||||
width := dt.get(uint, "framebuffer/fb0/width")
|
|
||||||
height := dt.get(uint, "framebuffer/fb0/height")
|
|
||||||
if doublebuffer {
|
|
||||||
return Surface.new(width, height)
|
|
||||||
} else {
|
|
||||||
return .(framebuffer, width, height, width * height)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Surface := struct {
|
Surface := struct {
|
||||||
buf: ^Color,
|
buf: ^Color,
|
||||||
width: uint,
|
width: uint,
|
||||||
height: uint,
|
height: uint,
|
||||||
size: uint,
|
size: uint,
|
||||||
|
}
|
||||||
|
|
||||||
new := fn(width: uint, height: uint): Self {
|
new_surface := fn(width: uint, height: uint): Surface {
|
||||||
size := width * height
|
|
||||||
return .(
|
return .(
|
||||||
memory.alloc(Color, size),
|
memory.alloc(Color, width * height),
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
size,
|
width * height,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
clone := fn(self: ^Self): Self {
|
clone_surface := fn(surface: ^Surface): Surface {
|
||||||
new_self := Self.new(self.width, self.height)
|
new := new_surface(surface.width, surface.height)
|
||||||
memory.copy(Color, self.buf, new_self.buf, self.size)
|
memory.copy(Color, surface.buf, new.buf, @intcast(surface.size))
|
||||||
return new_self
|
return new
|
||||||
}
|
|
||||||
$clear := fn(self: Self, color: Color): void {
|
|
||||||
memory.set(Color, &color, self.buf, self.size)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$sync := fn(self: Self): void {
|
init := fn(doublebuffer: bool): Surface {
|
||||||
memory.copy(Color, self.buf, framebuffer, self.size)
|
framebuffer = dt.get(^Color, "framebuffer/fb0/ptr\0")
|
||||||
|
width := dt.get(uint, "framebuffer/fb0/width\0")
|
||||||
|
height := dt.get(uint, "framebuffer/fb0/height\0")
|
||||||
|
if doublebuffer {
|
||||||
|
return new_surface(width, height)
|
||||||
|
} else {
|
||||||
|
return .(framebuffer, width, height, width * height)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$index := fn(self: Self, x: uint, y: uint): uint {
|
$clear := fn(surface: Surface, color: Color): void {
|
||||||
return x + self.width * y
|
memory.set(Color, &color, surface.buf, surface.width * surface.height)
|
||||||
}
|
}
|
||||||
|
|
||||||
$indexptr := fn(self: Self, x: uint, y: uint): ^Color {
|
$sync := fn(surface: Surface): void {
|
||||||
return self.buf + self.index(x, y)
|
memory.copy(Color, surface.buf, framebuffer, @bitcast(surface.width * surface.height))
|
||||||
}
|
}
|
||||||
|
|
||||||
$put_pixel := fn(self: Self, pos: Vec2(uint), color: Color): void {
|
$index := fn(surface: Surface, x: uint, y: uint): uint {
|
||||||
*self.indexptr(pos.x, pos.y) = color
|
return x + surface.width * y
|
||||||
}
|
}
|
||||||
|
|
||||||
put_filled_rect := fn(self: Self, pos: Vec2(uint), tr: Vec2(uint), color: Color): void {
|
$indexptr := fn(surface: Surface, x: uint, y: uint): ^Color {
|
||||||
top_start_idx := self.indexptr(pos.x, pos.y)
|
return surface.buf + index(surface, x, y)
|
||||||
bottom_start_idx := self.indexptr(pos.x, pos.y + tr.y - 1)
|
}
|
||||||
|
|
||||||
|
$put_pixel := fn(surface: Surface, pos: Vec2(uint), color: Color): void {
|
||||||
|
return *indexptr(surface, pos.x, pos.y) = color
|
||||||
|
}
|
||||||
|
|
||||||
|
put_filled_rect := fn(surface: Surface, pos: Vec2(uint), tr: Vec2(uint), color: Color): void {
|
||||||
|
top_start_idx := indexptr(surface, pos.x, pos.y)
|
||||||
|
bottom_start_idx := indexptr(surface, pos.x, pos.y + tr.y - 1)
|
||||||
rows_to_fill := tr.y
|
rows_to_fill := tr.y
|
||||||
|
|
||||||
loop if rows_to_fill <= 1 break else {
|
loop if rows_to_fill <= 1 break else {
|
||||||
memory.set(Color, &color, top_start_idx, tr.x)
|
memory.set(Color, &color, top_start_idx, tr.x)
|
||||||
memory.set(Color, &color, bottom_start_idx, tr.x)
|
memory.set(Color, &color, bottom_start_idx, tr.x)
|
||||||
|
|
||||||
top_start_idx += self.width
|
top_start_idx += surface.width
|
||||||
bottom_start_idx -= self.width
|
bottom_start_idx -= surface.width
|
||||||
rows_to_fill -= 2
|
rows_to_fill -= 2
|
||||||
}
|
}
|
||||||
|
|
||||||
if rows_to_fill == 1 {
|
if rows_to_fill == 1 {
|
||||||
memory.set(Color, &color, top_start_idx, tr.x)
|
memory.set(Color, &color, top_start_idx, tr.x)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
put_rect := fn(self: Self, pos: Vec2(uint), tr: Vec2(uint), color: Color): void {
|
put_rect := fn(surface: Surface, pos: Vec2(uint), tr: Vec2(uint), color: Color): void {
|
||||||
start_idx := self.indexptr(pos.x, pos.y)
|
start_idx := indexptr(surface, pos.x, pos.y)
|
||||||
end_idx := self.indexptr(pos.x, pos.y + tr.y)
|
end_idx := indexptr(surface, pos.x, pos.y + tr.y)
|
||||||
right_start_idx := self.indexptr(pos.x + tr.x, pos.y)
|
right_start_idx := indexptr(surface, pos.x + tr.x, pos.y)
|
||||||
|
|
||||||
loop if start_idx > end_idx break else {
|
loop if start_idx > end_idx break else {
|
||||||
*start_idx = color;
|
*start_idx = color;
|
||||||
*right_start_idx = color
|
*right_start_idx = color
|
||||||
start_idx += self.width
|
start_idx += surface.width
|
||||||
right_start_idx += self.width
|
right_start_idx += surface.width
|
||||||
}
|
}
|
||||||
|
|
||||||
memory.set(Color, &color, self.indexptr(pos.x, pos.y), @bitcast(tr.x + 1))
|
memory.set(Color, &color, indexptr(surface, pos.x, pos.y), @bitcast(tr.x + 1))
|
||||||
memory.set(Color, &color, self.indexptr(pos.x, pos.y + tr.y), @bitcast(tr.x + 1))
|
memory.set(Color, &color, indexptr(surface, pos.x, pos.y + tr.y), @bitcast(tr.x + 1))
|
||||||
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
put_line_low := fn(self: Self, p0: Vec2(uint), p1: Vec2(uint), color: Color): void {
|
put_line_low := fn(surface: Surface, p0: Vec2(uint), p1: Vec2(uint), color: Color): void {
|
||||||
dx := @as(int, @bitcast(p1.x - p0.x))
|
dx := @as(int, @bitcast(p1.x - p0.x))
|
||||||
dy := @as(int, @bitcast(p1.y - p0.y))
|
dy := @as(int, @bitcast(p1.y - p0.y))
|
||||||
yi := 1
|
yi := 1
|
||||||
|
@ -106,7 +110,7 @@ Surface := struct {
|
||||||
y := p0.y
|
y := p0.y
|
||||||
x := p0.x
|
x := p0.x
|
||||||
loop if x == p1.x break else {
|
loop if x == p1.x break else {
|
||||||
*self.indexptr(x, y) = color
|
*indexptr(surface, x, y) = color
|
||||||
if D > 0 {
|
if D > 0 {
|
||||||
y += yi
|
y += yi
|
||||||
D += 2 * (dy - dx)
|
D += 2 * (dy - dx)
|
||||||
|
@ -115,9 +119,10 @@ Surface := struct {
|
||||||
}
|
}
|
||||||
x += 1
|
x += 1
|
||||||
}
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
put_line_high := fn(self: Self, p0: Vec2(uint), p1: Vec2(uint), color: Color): void {
|
put_line_high := fn(surface: Surface, p0: Vec2(uint), p1: Vec2(uint), color: Color): void {
|
||||||
dx := @as(int, @bitcast(p1.x - p0.x))
|
dx := @as(int, @bitcast(p1.x - p0.x))
|
||||||
dy := @as(int, @bitcast(p1.y - p0.y))
|
dy := @as(int, @bitcast(p1.y - p0.y))
|
||||||
xi := 1
|
xi := 1
|
||||||
|
@ -129,7 +134,7 @@ Surface := struct {
|
||||||
x := p0.x
|
x := p0.x
|
||||||
y := p0.y
|
y := p0.y
|
||||||
loop if y == p1.y break else {
|
loop if y == p1.y break else {
|
||||||
*self.indexptr(x, y) = color
|
*indexptr(surface, x, y) = color
|
||||||
if D > 0 {
|
if D > 0 {
|
||||||
x += xi
|
x += xi
|
||||||
D += 2 * (dx - dy)
|
D += 2 * (dx - dy)
|
||||||
|
@ -138,32 +143,34 @@ Surface := struct {
|
||||||
}
|
}
|
||||||
y += 1
|
y += 1
|
||||||
}
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
put_line := fn(self: Self, p0: Vec2(uint), p1: Vec2(uint), color: Color): void {
|
put_line := fn(surface: Surface, p0: Vec2(uint), p1: Vec2(uint), color: Color): void {
|
||||||
if math.abs(int, @bitcast(p1.y - p0.y)) < math.abs(int, @bitcast(p1.x - p0.x)) {
|
if math.abs(uint, p1.y - p0.y) < math.abs(uint, p1.x - p0.x) {
|
||||||
if p0.x > p1.x {
|
if p0.x > p1.x {
|
||||||
@inline(put_line_low, self, p1, p0, color)
|
@inline(put_line_low, surface, p1, p0, color)
|
||||||
} else {
|
} else {
|
||||||
@inline(put_line_low, self, p0, p1, color)
|
@inline(put_line_low, surface, p0, p1, color)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if p0.y > p1.y {
|
if p0.y > p1.y {
|
||||||
@inline(put_line_high, self, p1, p0, color)
|
@inline(put_line_high, surface, p1, p0, color)
|
||||||
} else {
|
} else {
|
||||||
@inline(put_line_high, self, p0, p1, color)
|
@inline(put_line_high, surface, p0, p1, color)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
put_surface := fn(self: Self, top: Self, pos: Vec2(uint), flip_v: bool): void {
|
put_surface := fn(surface: Surface, top: Surface, pos: Vec2(uint), flip_v: bool): void {
|
||||||
src_top_cursor := top.buf
|
src_top_cursor := top.buf
|
||||||
src_bottom_cursor := top.buf + top.width * (top.height - 1)
|
src_bottom_cursor := top.buf + top.width * (top.height - 1)
|
||||||
|
|
||||||
dst_top_idx := self.indexptr(pos.x, pos.y)
|
dst_top_idx := indexptr(surface, pos.x, pos.y)
|
||||||
dst_bottom_idx := self.indexptr(pos.x, pos.y + top.height - 1)
|
dst_bottom_idx := indexptr(surface, pos.x, pos.y + top.height - 1)
|
||||||
|
|
||||||
dst_increment := self.width
|
dst_increment := surface.width
|
||||||
|
|
||||||
if flip_v {
|
if flip_v {
|
||||||
dst_increment = -dst_increment
|
dst_increment = -dst_increment
|
||||||
|
@ -188,10 +195,12 @@ Surface := struct {
|
||||||
if rows_to_copy == 1 {
|
if rows_to_copy == 1 {
|
||||||
memory.copy(Color, src_top_cursor, dst_top_idx, top.width)
|
memory.copy(Color, src_top_cursor, dst_top_idx, top.width)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// peony-made
|
// peony-made
|
||||||
put_trirect := fn(self: Self, pos: Vec2(uint), size: Vec2(int), color0: Color, color1: Color): void {
|
put_trirect := fn(surface: Surface, pos: Vec2(uint), size: Vec2(int), color0: Color, color1: Color): void {
|
||||||
step := Vec2(int).(1, 1)
|
step := Vec2(int).(1, 1)
|
||||||
if size.x < 0 {
|
if size.x < 0 {
|
||||||
step.x = -1
|
step.x = -1
|
||||||
|
@ -204,14 +213,16 @@ Surface := struct {
|
||||||
target := pos + @bitcast(size)
|
target := pos + @bitcast(size)
|
||||||
|
|
||||||
loop if pos.x == target.x break else {
|
loop if pos.x == target.x break else {
|
||||||
@inline(put_vline, self, pos.x, pos.y, target.y, color0)
|
@inline(put_vline, surface, pos.x, pos.y, target.y, color0)
|
||||||
@inline(put_vline, self, pos.x, pos.y, start_y, color1)
|
@inline(put_vline, surface, pos.x, pos.y, start_y, color1)
|
||||||
pos += @bitcast(step)
|
pos += @bitcast(step)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// peony-made
|
// peony-made
|
||||||
put_vline := fn(self: Self, x: uint, y0: uint, y1: uint, color: Color): void {
|
put_vline := fn(surface: Surface, x: uint, y0: uint, y1: uint, color: Color): void {
|
||||||
if y1 < y0 {
|
if y1 < y0 {
|
||||||
tmp := y0
|
tmp := y0
|
||||||
y0 = y1
|
y0 = y1
|
||||||
|
@ -220,144 +231,161 @@ Surface := struct {
|
||||||
y := y0
|
y := y0
|
||||||
|
|
||||||
loop if y == y1 break else {
|
loop if y == y1 break else {
|
||||||
*self.indexptr(x, y) = color
|
*indexptr(surface, x, y) = color
|
||||||
y += 1
|
y += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// peony-made
|
// peony-made
|
||||||
put_hline := fn(self: Self, y: uint, x0: uint, x1: uint, color: Color): void {
|
put_hline := fn(surface: Surface, y: uint, x0: uint, x1: uint, color: Color): void {
|
||||||
if x1 < x0 {
|
if x1 < x0 {
|
||||||
tmp := x0
|
tmp := x0
|
||||||
x0 = x1
|
x0 = x1
|
||||||
x1 = tmp
|
x1 = tmp
|
||||||
}
|
}
|
||||||
memory.set(Color, &color, self.indexptr(x0, y), @bitcast(x1 - x0))
|
// x0 = math.min(x0, x1)
|
||||||
|
memory.set(Color, &color, indexptr(surface, x0, y), @bitcast(x1 - x0 - 1))
|
||||||
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
put_circle := fn(self: Self, pos: Vec2(uint), radius: uint, color: Color): void {
|
put_circle := fn(surface: Surface, pos: Vec2(uint), radius: uint, color: Color): void {
|
||||||
x := 0
|
x := 0
|
||||||
y := radius
|
y := radius
|
||||||
error := @as(int, 3) - 2 * @intcast(radius)
|
error := @as(int, 3) - @intcast(2 * radius);
|
||||||
loop if x > y break else {
|
*indexptr(surface, pos.x + radius, pos.y) = color;
|
||||||
self.put_pixel(pos + .(x, y), color)
|
*indexptr(surface, pos.x - radius, pos.y) = color;
|
||||||
self.put_pixel(pos + .(-x, y), color)
|
*indexptr(surface, pos.x, pos.y + radius) = color;
|
||||||
self.put_pixel(pos + .(x, -y), color)
|
*indexptr(surface, pos.x, pos.y - radius) = color
|
||||||
self.put_pixel(pos + .(-x, -y), color)
|
|
||||||
self.put_pixel(pos + .(y, x), color)
|
loop if y < x break else {
|
||||||
self.put_pixel(pos + .(-y, x), color)
|
|
||||||
self.put_pixel(pos + .(y, -x), color)
|
|
||||||
self.put_pixel(pos + .(-y, -x), color)
|
|
||||||
if error < 0 {
|
|
||||||
error += 4 * @intcast(x) + 6
|
|
||||||
} else {
|
|
||||||
error += 4 * (@intcast(x) - @intcast(y)) + 10
|
|
||||||
y -= 1
|
|
||||||
}
|
|
||||||
x += 1
|
x += 1
|
||||||
}
|
|
||||||
|
if error > 0 {
|
||||||
|
y -= 1
|
||||||
|
error += 4 * (@intcast(x) - @intcast(y)) + 10
|
||||||
|
} else {
|
||||||
|
error += 4 * @intcast(x) + 6
|
||||||
|
};
|
||||||
|
*indexptr(surface, pos.x + x, pos.y + y) = color;
|
||||||
|
*indexptr(surface, pos.x + y, pos.y + x) = color;
|
||||||
|
*indexptr(surface, pos.x - x, pos.y + y) = color;
|
||||||
|
*indexptr(surface, pos.x - y, pos.y + x) = color;
|
||||||
|
*indexptr(surface, pos.x + x, pos.y - y) = color;
|
||||||
|
*indexptr(surface, pos.x + y, pos.y - x) = color;
|
||||||
|
*indexptr(surface, pos.x - x, pos.y - y) = color;
|
||||||
|
*indexptr(surface, pos.x - y, pos.y - x) = color
|
||||||
}
|
}
|
||||||
|
|
||||||
put_filled_circle := fn(self: Self, pos: Vec2(uint), radius: uint, color: Color): void {
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
put_filled_circle := fn(surface: Surface, pos: Vec2(uint), radius: uint, color: Color): void {
|
||||||
x := 0
|
x := 0
|
||||||
y := radius
|
y := radius
|
||||||
error := @as(int, 3) - 2 * @intcast(radius)
|
error := @as(int, 3) - @intcast(2 * radius)
|
||||||
|
put_hline(surface, pos.y - x, pos.x - radius, pos.x + radius, color);
|
||||||
|
*indexptr(surface, pos.x, pos.y + radius) = color;
|
||||||
|
*indexptr(surface, pos.x, pos.y - radius) = color
|
||||||
|
|
||||||
loop if x > y break else {
|
loop if y < x break else {
|
||||||
self.put_hline(pos.y + y, pos.x - x, pos.x + x, color)
|
|
||||||
self.put_hline(pos.y - y, pos.x - x, pos.x + x, color)
|
|
||||||
|
|
||||||
if x != y {
|
|
||||||
self.put_hline(pos.y + x, pos.x - y, pos.x + y, color)
|
|
||||||
self.put_hline(pos.y - x, pos.x - y, pos.x + y, color)
|
|
||||||
}
|
|
||||||
|
|
||||||
if error < 0 {
|
|
||||||
error += 4 * @intcast(x) + 6
|
|
||||||
} else {
|
|
||||||
error += 4 * (@intcast(x) - @intcast(y)) + 10
|
|
||||||
y -= 1
|
|
||||||
}
|
|
||||||
x += 1
|
x += 1
|
||||||
|
|
||||||
|
if error > 0 {
|
||||||
|
put_hline(surface, pos.y + y, pos.x - x, pos.x + x, color)
|
||||||
|
put_hline(surface, pos.y - y, pos.x - x, pos.x + x, color)
|
||||||
|
y -= 1
|
||||||
|
error += 4 * (@intcast(x) - @intcast(y)) + 10
|
||||||
|
} else {
|
||||||
|
error += 4 * @intcast(x) + 6
|
||||||
}
|
}
|
||||||
|
put_hline(surface, pos.y + x, pos.x - y, pos.x + y, color)
|
||||||
|
put_hline(surface, pos.y - x, pos.x - y, pos.x + y, color)
|
||||||
}
|
}
|
||||||
|
|
||||||
put_textured_circle := fn(self: Self, source: Self, source_pos: Vec2(uint), pos: Vec2(uint), radius: uint): void {
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
put_textured_circle := fn(surface: Surface, source: Surface, source_pos: Vec2(uint), pos: Vec2(uint), radius: uint): void {
|
||||||
x := 0
|
x := 0
|
||||||
y := radius
|
y := radius
|
||||||
error := @as(int, 3) - 2 * @intcast(radius)
|
error := @as(int, 3) - @intcast(2 * radius)
|
||||||
|
memory.copy(Color, indexptr(source, source_pos.x - y, source_pos.y), indexptr(surface, pos.x - y, pos.y), 2 * y);
|
||||||
|
*indexptr(surface, pos.x, pos.y + y) = *indexptr(source, source_pos.x, source_pos.y + y);
|
||||||
|
*indexptr(surface, pos.x, pos.y - y) = *indexptr(source, source_pos.x, source_pos.y - y)
|
||||||
|
|
||||||
loop if x > y break else {
|
loop if y < x break else {
|
||||||
memory.copy(Color, source.indexptr(source_pos.x - x, source_pos.y + y), self.indexptr(pos.x - x, pos.y + y), 2 * x)
|
|
||||||
memory.copy(Color, source.indexptr(source_pos.x - x, source_pos.y - y), self.indexptr(pos.x - x, pos.y - y), 2 * x)
|
|
||||||
|
|
||||||
if x != y {
|
|
||||||
memory.copy(Color, source.indexptr(source_pos.x - y, source_pos.y + x), self.indexptr(pos.x - y, pos.y + x), 2 * y)
|
|
||||||
memory.copy(Color, source.indexptr(source_pos.x - y, source_pos.y - x), self.indexptr(pos.x - y, pos.y - x), 2 * y)
|
|
||||||
}
|
|
||||||
|
|
||||||
if error < 0 {
|
|
||||||
error += 4 * @intcast(x) + 6
|
|
||||||
} else {
|
|
||||||
error += 4 * (@intcast(x) - @intcast(y)) + 10
|
|
||||||
y -= 1
|
|
||||||
}
|
|
||||||
x += 1
|
x += 1
|
||||||
|
|
||||||
|
if error > 0 {
|
||||||
|
memory.copy(Color, indexptr(source, source_pos.x - x, source_pos.y + y), indexptr(surface, pos.x - x, pos.y + y), 2 * x)
|
||||||
|
memory.copy(Color, indexptr(source, source_pos.x - x, source_pos.y - y), indexptr(surface, pos.x - x, pos.y - y), 2 * x)
|
||||||
|
y -= 1
|
||||||
|
error += 4 * (@intcast(x) - @intcast(y)) + 10
|
||||||
|
} else {
|
||||||
|
error += 4 * @intcast(x) + 6
|
||||||
}
|
}
|
||||||
|
memory.copy(Color, indexptr(source, source_pos.x - y, source_pos.y + x), indexptr(surface, pos.x - y, pos.y + x), 2 * y)
|
||||||
|
memory.copy(Color, indexptr(source, source_pos.x - y, source_pos.y - x), indexptr(surface, pos.x - y, pos.y - x), 2 * y)
|
||||||
}
|
}
|
||||||
|
|
||||||
put_text := fn(self: Self, font: Font, pos: Vec2(uint), color: Color, str: []u8): void {
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
utf8_len_table := [u8].(0, 0, 2, 3)
|
||||||
|
|
||||||
|
put_text := fn(surface: Surface, font: Font, pos: Vec2(uint), color: Color, str: ^u8): void {
|
||||||
cursor := Vec2(uint).(pos.x, pos.y)
|
cursor := Vec2(uint).(pos.x, pos.y)
|
||||||
|
|
||||||
max_y := self.height - font.height
|
max_y := surface.height - font.height
|
||||||
next_line_y := font.height + font.line_gap
|
next_line_y := font.height + font.line_gap
|
||||||
char_advance := font.width + font.char_gap
|
char_advance := font.width + font.char_gap
|
||||||
self_width := self.width
|
surface_width := surface.width
|
||||||
|
|
||||||
i := 0
|
loop if *str == 0 break else {
|
||||||
|
|
||||||
loop if i >= str.len break else {
|
|
||||||
if cursor.y > max_y break
|
if cursor.y > max_y break
|
||||||
|
|
||||||
glyph_data := @as(^u8, idk)
|
glyph_data := @as(^u8, idk)
|
||||||
code_point := @as(uint, 0)
|
code_point := @as(uint, 0)
|
||||||
|
|
||||||
if (str[i] & 0x80) == 0 {
|
if (*str & 0x80) == 0 {
|
||||||
if str[i] == '\n' {
|
if *str == 10 {
|
||||||
cursor.x = pos.x
|
cursor.x = pos.x
|
||||||
cursor.y += next_line_y
|
cursor.y += next_line_y
|
||||||
i += 1
|
str += 1
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if font.unicode == null {
|
if font.unicode == null {
|
||||||
if str[i] > font.num_glyphs {
|
if *str > font.num_glyphs {
|
||||||
i += 1
|
str += 1
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
glyph_data = get_glyph(font, str[i])
|
glyph_data = get_glyph(font, *str)
|
||||||
} else {
|
} else {
|
||||||
if str[i] < UNC_TABLE_SIZE {
|
if *str < UNC_TABLE_SIZE {
|
||||||
glyph_index := *(font.unicode + str[i])
|
glyph_index := *(font.unicode + *str)
|
||||||
if glyph_index == 0xFFFF {
|
if glyph_index == 0xFFFF {
|
||||||
i += 1
|
str += 1
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
glyph_data = font.data + glyph_index * font.bytes_per_glyph
|
glyph_data = font.data + glyph_index * font.bytes_per_glyph
|
||||||
} else {
|
} else {
|
||||||
i += 1
|
str += 1
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i += 1
|
str += 1
|
||||||
} else if font.unicode != null {
|
} else if font.unicode != null {
|
||||||
first_byte := str[i]
|
first_byte := *str
|
||||||
num_bytes := @as(uint, 0)
|
num_bytes := @as(uint, 0)
|
||||||
|
|
||||||
num_bytes = utf8_len_table[first_byte >> 5 & 0x3]
|
num_bytes = utf8_len_table[first_byte >> 5 & 0x3]
|
||||||
|
|
||||||
if num_bytes == 0 {
|
if num_bytes == 0 {
|
||||||
i += 1
|
str += 1
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,25 +395,25 @@ Surface := struct {
|
||||||
bytes_processed := 1
|
bytes_processed := 1
|
||||||
|
|
||||||
loop if bytes_processed >= num_bytes break else {
|
loop if bytes_processed >= num_bytes break else {
|
||||||
i += 1
|
str += 1
|
||||||
if i == str.len | (str[i] & 0xC0) != 0x80 {
|
if *str == 0 | (*str & 0xC0) != 0x80 {
|
||||||
valid_sequence = false
|
valid_sequence = false
|
||||||
}
|
}
|
||||||
if valid_sequence == false {
|
if valid_sequence == false {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
code_point = code_point << 6 | str[i] & 0x3F
|
code_point = code_point << 6 | *str & 0x3F
|
||||||
bytes_processed += 1
|
bytes_processed += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if valid_sequence == false {
|
if valid_sequence == false {
|
||||||
i += 1
|
str += 1
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
i += 1
|
str += 1
|
||||||
|
|
||||||
if code_point == '\n' {
|
if code_point == 10 {
|
||||||
cursor.x = pos.x
|
cursor.x = pos.x
|
||||||
cursor.y += next_line_y
|
cursor.y += next_line_y
|
||||||
continue
|
continue
|
||||||
|
@ -402,12 +430,12 @@ Surface := struct {
|
||||||
glyph_data = font.data + glyph_index * font.bytes_per_glyph
|
glyph_data = font.data + glyph_index * font.bytes_per_glyph
|
||||||
}
|
}
|
||||||
|
|
||||||
if cursor.x + font.width >= self_width {
|
if cursor.x + font.width >= surface_width {
|
||||||
cursor.x = pos.x
|
cursor.x = pos.x
|
||||||
cursor.y += next_line_y
|
cursor.y += next_line_y
|
||||||
}
|
}
|
||||||
|
|
||||||
dest := self.indexptr(cursor.x, cursor.y)
|
dest := indexptr(surface, cursor.x, cursor.y)
|
||||||
rows := font.height
|
rows := font.height
|
||||||
|
|
||||||
loop if rows == 0 break else {
|
loop if rows == 0 break else {
|
||||||
|
@ -433,11 +461,12 @@ Surface := struct {
|
||||||
if mask != 0x80 {
|
if mask != 0x80 {
|
||||||
glyph_data += 1
|
glyph_data += 1
|
||||||
}
|
}
|
||||||
dest += self_width
|
dest += surface_width
|
||||||
rows -= 1
|
rows -= 1
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor.x += char_advance
|
cursor.x += char_advance
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
return
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
.{log, memory} := @use("stn")
|
.{log, memory} := @use("../../stn/src/lib.hb")
|
||||||
|
|
||||||
PSF1Header := packed struct {
|
PSF1Header := packed struct {
|
||||||
magic: u16,
|
magic: u16,
|
||||||
|
@ -31,7 +31,7 @@ Font := struct {
|
||||||
font_from_psf1 := fn(psf: ^u8): ?Font {
|
font_from_psf1 := fn(psf: ^u8): ?Font {
|
||||||
header := @as(^PSF1Header, @bitcast(psf))
|
header := @as(^PSF1Header, @bitcast(psf))
|
||||||
if header.magic != 0x436 {
|
if header.magic != 0x436 {
|
||||||
log.error("failed to load psf font: not a psf1 font, idiot")
|
log.error("failed to load psf font: not a psf1 font, idiot\0")
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ font_from_psf1 := fn(psf: ^u8): ?Font {
|
||||||
font_from_psf2 := fn(psf: ^u8, unicode: bool): ?Font {
|
font_from_psf2 := fn(psf: ^u8, unicode: bool): ?Font {
|
||||||
header := @as(^PSF2Header, @bitcast(psf))
|
header := @as(^PSF2Header, @bitcast(psf))
|
||||||
if header.magic != 0x864AB572 {
|
if header.magic != 0x864AB572 {
|
||||||
log.error("failed to load psf font: not a psf2 font, idiot")
|
log.error("failed to load psf font: not a psf2 font, idiot\0")
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.{log, panic, memory} := @use("stn")
|
.{log, panic, memory} := @use("../lib.hb")
|
||||||
alloc_return := @use("alloc_return.hb")
|
alloc_return := @use("alloc_return.hb")
|
||||||
|
|
||||||
/* the block size is 64 bytes, 64 blocks of 64 bytes.
|
/* the block size is 64 bytes, 64 blocks of 64 bytes.
|
||||||
|
@ -10,7 +10,7 @@ BlockAlloc := struct {
|
||||||
ptr: ?^u8,
|
ptr: ?^u8,
|
||||||
|
|
||||||
$init := fn(): Self {
|
$init := fn(): Self {
|
||||||
alloc_page_ptr := memory.request_page(1, false)
|
alloc_page_ptr := memory.request_page(1)
|
||||||
state := 0xFFFFFFFFFFFFFFFF
|
state := 0xFFFFFFFFFFFFFFFF
|
||||||
return .(state, alloc_page_ptr)
|
return .(state, alloc_page_ptr)
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ BlockAlloc := struct {
|
||||||
offset += 1
|
offset += 1
|
||||||
return .(0, null)
|
return .(0, null)
|
||||||
} else {
|
} else {
|
||||||
log.info("Already Allocated")
|
log.info("Already Allocated\0")
|
||||||
}
|
}
|
||||||
|
|
||||||
// else {
|
// else {
|
||||||
|
@ -40,7 +40,7 @@ BlockAlloc := struct {
|
||||||
// if self.ptr != null {
|
// if self.ptr != null {
|
||||||
// return .(64, self.ptr + offset * 64)
|
// return .(64, self.ptr + offset * 64)
|
||||||
// } else {
|
// } else {
|
||||||
// // panic.panic("Allocator is not inited.")
|
// // panic.panic("Allocator is not inited.\0")
|
||||||
// // return .(0, null)
|
// // return .(0, null)
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
$await := fn(buffer_id: uint): void {
|
string := @use("string.hb")
|
||||||
return @eca(7, buffer_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
$recv := fn($Expr: type, buffer_id: uint, memory_map_location: ^Expr): void {
|
$recv := fn($Expr: type, buffer_id: uint, memory_map_location: ^Expr): void {
|
||||||
return @eca(4, buffer_id, memory_map_location, @sizeof(Expr))
|
return @eca(4, buffer_id, memory_map_location, @sizeof(Expr))
|
||||||
|
@ -20,18 +18,18 @@ $write_length := fn(length: uint, msg: ^u8, buffer_id: uint): void {
|
||||||
|
|
||||||
BufferMsg := packed struct {operation: u8, msg: ^u8, msg_len: uint}
|
BufferMsg := packed struct {operation: u8, msg: ^u8, msg_len: uint}
|
||||||
|
|
||||||
$create := fn(msg: []u8): uint {
|
create := fn(msg: ^u8): uint {
|
||||||
return @eca(3, 0, BufferMsg.(0, msg.ptr, msg.len), @sizeof(BufferMsg))
|
return @eca(3, 0, BufferMsg.(0, msg, @inline(string.length, msg)), @sizeof(BufferMsg))
|
||||||
}
|
}
|
||||||
|
|
||||||
$create_nameless := fn(): uint {
|
$create_nameless := fn(): uint {
|
||||||
return @eca(1, 0)
|
return @eca(1, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
$delete := fn(buffer_id: uint): void {
|
$delete_buffer := fn(buffer_id: uint): void {
|
||||||
return @eca(2, buffer_id)
|
return @eca(2, buffer_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
$search := fn(msg: []u8): uint {
|
search := fn(msg: ^u8): uint {
|
||||||
return @eca(3, 0, BufferMsg.(3, msg.ptr, msg.len), @sizeof(BufferMsg))
|
return @eca(3, 0, BufferMsg.(3, msg, @inline(string.length, msg)), @sizeof(BufferMsg))
|
||||||
}
|
}
|
|
@ -1,3 +1,5 @@
|
||||||
$get := fn($Expr: type, query: []u8): Expr {
|
.{string} := @use("../../stn/src/lib.hb")
|
||||||
return @eca(3, 5, query.ptr, query.len)
|
|
||||||
|
get := fn($Expr: type, query: ^u8): Expr {
|
||||||
|
return @eca(3, 5, query, @inline(string.length, query))
|
||||||
}
|
}
|
|
@ -2,7 +2,7 @@ acs := @use("acs.hb");
|
||||||
.{DiskID, FileID} := acs
|
.{DiskID, FileID} := acs
|
||||||
|
|
||||||
// Paths without a node-disk component are to be treated as local files.
|
// Paths without a node-disk component are to be treated as local files.
|
||||||
// file_path := "DID:/test"
|
// file_path := "DID:/test\0";
|
||||||
Path := struct {
|
Path := struct {
|
||||||
// DiskID holds the host id
|
// DiskID holds the host id
|
||||||
disk_id: DiskID,
|
disk_id: DiskID,
|
||||||
|
|
|
@ -1,285 +0,0 @@
|
||||||
.{Kind, usize, string, signed_int, panic, float, integer, memory, log: .{LogLevel}} := @use("stn")
|
|
||||||
|
|
||||||
fmt_int := fn(v: @Any(), str: []u8, radix: @TypeOf(v)): uint {
|
|
||||||
is_negative := signed_int(@TypeOf(v)) & v < 0
|
|
||||||
prefix_len := 0
|
|
||||||
if is_negative {
|
|
||||||
v = -v
|
|
||||||
str[0] = '-'
|
|
||||||
prefix_len += 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if radix == 16 {
|
|
||||||
*@as(^[2]u8, @bitcast(str.ptr + prefix_len)) = *@bitcast("0x".ptr)
|
|
||||||
prefix_len += 2
|
|
||||||
} else if radix == 2 {
|
|
||||||
*@as(^[2]u8, @bitcast(str.ptr + prefix_len)) = *@bitcast("0b".ptr)
|
|
||||||
prefix_len += 2
|
|
||||||
} else if radix == 8 {
|
|
||||||
*@as(^[2]u8, @bitcast(str.ptr + prefix_len)) = *@bitcast("0o".ptr)
|
|
||||||
prefix_len += 2
|
|
||||||
}
|
|
||||||
|
|
||||||
if v == 0 {
|
|
||||||
str[prefix_len] = '0'
|
|
||||||
return prefix_len + 1
|
|
||||||
}
|
|
||||||
|
|
||||||
i := prefix_len
|
|
||||||
loop if v <= 0 break else {
|
|
||||||
remainder := v % radix
|
|
||||||
v /= radix
|
|
||||||
if remainder > 9 {
|
|
||||||
str[i] = @intcast(remainder - 10 + 'A')
|
|
||||||
} else {
|
|
||||||
str[i] = @intcast(remainder + '0')
|
|
||||||
}
|
|
||||||
i += 1
|
|
||||||
}
|
|
||||||
|
|
||||||
string.reverse(str[prefix_len..i])
|
|
||||||
return i
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt_bool := fn(v: bool, str: []u8): uint {
|
|
||||||
if v {
|
|
||||||
*@as(^[4]u8, @bitcast(str.ptr)) = *@bitcast("true".ptr)
|
|
||||||
return 4
|
|
||||||
} else {
|
|
||||||
*@as(^[5]u8, @bitcast(str.ptr)) = *@bitcast("false".ptr)
|
|
||||||
return 5
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$FP_TOLERANCE := 0.00000001
|
|
||||||
|
|
||||||
fmt_float := fn(v: @Any(), str: []u8, precision: uint, radix: int): uint {
|
|
||||||
is_negative := v < 0
|
|
||||||
|
|
||||||
prefix_len := 0
|
|
||||||
|
|
||||||
if is_negative {
|
|
||||||
v = -v
|
|
||||||
str[0] = '-'
|
|
||||||
prefix_len += 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if radix == 16 {
|
|
||||||
*@as(^[2]u8, @bitcast(str.ptr + prefix_len)) = *@bitcast("0x".ptr)
|
|
||||||
prefix_len += 2
|
|
||||||
} else if radix == 2 {
|
|
||||||
*@as(^[2]u8, @bitcast(str.ptr + prefix_len)) = *@bitcast("0b".ptr)
|
|
||||||
prefix_len += 2
|
|
||||||
} else if radix == 8 {
|
|
||||||
*@as(^[2]u8, @bitcast(str.ptr + prefix_len)) = *@bitcast("0o".ptr)
|
|
||||||
prefix_len += 2
|
|
||||||
}
|
|
||||||
|
|
||||||
integer_part := @fti(v)
|
|
||||||
fractional_part := v - @itf(integer_part)
|
|
||||||
|
|
||||||
i := prefix_len
|
|
||||||
loop if integer_part == 0 & i > prefix_len break else {
|
|
||||||
remainder := integer_part % radix
|
|
||||||
integer_part /= radix
|
|
||||||
if remainder > 9 {
|
|
||||||
str[i] = @intcast(remainder - 10 + 'A')
|
|
||||||
} else {
|
|
||||||
str[i] = @intcast(remainder + '0')
|
|
||||||
}
|
|
||||||
i += 1
|
|
||||||
}
|
|
||||||
|
|
||||||
string.reverse(str[prefix_len..i])
|
|
||||||
str[i] = '.'
|
|
||||||
i += 1
|
|
||||||
|
|
||||||
p := precision
|
|
||||||
loop if p <= 0 | fractional_part < FP_TOLERANCE break else {
|
|
||||||
fractional_part *= @itf(radix)
|
|
||||||
digit := @fti(fractional_part)
|
|
||||||
if digit > 9 {
|
|
||||||
str[i] = @intcast(digit - 10 + 'A')
|
|
||||||
} else {
|
|
||||||
str[i] = @intcast(digit + '0')
|
|
||||||
}
|
|
||||||
i += 1
|
|
||||||
fractional_part -= @itf(digit)
|
|
||||||
p -= 1
|
|
||||||
}
|
|
||||||
|
|
||||||
return i
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt_container := fn(v: @Any(), str: []u8, opts: FormatOptions): uint {
|
|
||||||
T2 := @TypeOf(v)
|
|
||||||
kind := Kind.of(T2)
|
|
||||||
i := 0
|
|
||||||
len := 0
|
|
||||||
if kind == .Struct {
|
|
||||||
*@as(^[@intcast(@nameof(T2).len)]u8, @bitcast(str.ptr + len)) = *@bitcast(@nameof(T2).ptr)
|
|
||||||
len += @nameof(T2).len;
|
|
||||||
*@as(^[2]u8, @bitcast(str.ptr + len)) = *@bitcast(".(".ptr)
|
|
||||||
len += 2
|
|
||||||
} else if kind == .Slice {
|
|
||||||
*@as(^[@intcast(@nameof(@ChildOf(T2)).len)]u8, @bitcast(str.ptr + len)) = *@bitcast(@nameof(@ChildOf(T2)).ptr)
|
|
||||||
len += @nameof(@ChildOf(T2)).len;
|
|
||||||
*@as(^[2]u8, @bitcast(str.ptr + len)) = *@bitcast(".[".ptr)
|
|
||||||
len += 2
|
|
||||||
} else if kind == .Tuple {
|
|
||||||
*@as(^[2]u8, @bitcast(str.ptr + len)) = *@bitcast(".(".ptr)
|
|
||||||
len += 2
|
|
||||||
}
|
|
||||||
|
|
||||||
if kind == .Slice {
|
|
||||||
loop {
|
|
||||||
len += @inline(format, v[i], str[len..], opts)
|
|
||||||
i += 1
|
|
||||||
if i == v.len break else {
|
|
||||||
*@as(^[2]u8, @bitcast(str.ptr + len)) = *@bitcast(", ".ptr)
|
|
||||||
len += 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$loop {
|
|
||||||
len += @inline(format, v[i], str[len..], opts)
|
|
||||||
i += 1
|
|
||||||
if i == @lenof(T2) break else {
|
|
||||||
*@as(^[2]u8, @bitcast(str.ptr + len)) = *@bitcast(", ".ptr)
|
|
||||||
len += 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if kind == .Struct | kind == .Tuple {
|
|
||||||
*@as(^[1]u8, @bitcast(str.ptr + len)) = *@bitcast(")".ptr)
|
|
||||||
len += 1
|
|
||||||
} else if kind == .Slice {
|
|
||||||
*@as(^[1]u8, @bitcast(str.ptr + len)) = *@bitcast("]".ptr)
|
|
||||||
len += 1
|
|
||||||
}
|
|
||||||
return len
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt_nullable := fn(v: @Any(), str: []u8, opts: FormatOptions): uint {
|
|
||||||
if v == null {
|
|
||||||
*@as(^[4]u8, @bitcast(str.ptr)) = *@bitcast("null".ptr)
|
|
||||||
return 4
|
|
||||||
} else {
|
|
||||||
return @inline(format, @as(@ChildOf(@TypeOf(v)), v), str, opts)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt_enum := fn(v: @Any(), str: []u8, opts: FormatOptions): uint {
|
|
||||||
T := @TypeOf(v)
|
|
||||||
len := @nameof(T).len;
|
|
||||||
*@as(^[@intcast(@nameof(T).len)]u8, @bitcast(str.ptr)) = *@bitcast(@nameof(T).ptr);
|
|
||||||
*@as(^[2]u8, @bitcast(str.ptr + len)) = *@bitcast(".(".ptr)
|
|
||||||
len += 2
|
|
||||||
len += fmt_int(@as(usize(T), @bitcast(v)), str[len..], 10);
|
|
||||||
*@as(^[2]u8, @bitcast(str.ptr + len)) = *@bitcast(")".ptr)
|
|
||||||
return len + 1
|
|
||||||
}
|
|
||||||
|
|
||||||
/* TODO:
|
|
||||||
* Custom formatters using struct methods (T._fmt(self, str): uint),
|
|
||||||
* Format struct fields "Name.{a: x, b: y, c: z}"
|
|
||||||
* Optionally tabulate
|
|
||||||
* Add more FormatOption fields
|
|
||||||
* Support scientific notation for floating point
|
|
||||||
* Support format string
|
|
||||||
*/
|
|
||||||
|
|
||||||
FormatOptions := struct {
|
|
||||||
precision: uint = 2,
|
|
||||||
radix: uint = 10,
|
|
||||||
// temporarily here, will change later maybe
|
|
||||||
log: LogLevel = .Info,
|
|
||||||
}
|
|
||||||
|
|
||||||
/* SAFETY:
|
|
||||||
* Assumes the buffer is wide enough for the formatted text and a null char
|
|
||||||
* Does not clear the buffer for you
|
|
||||||
*/
|
|
||||||
|
|
||||||
format := fn(v: @Any(), str: []u8, opts: FormatOptions): uint {
|
|
||||||
T := @TypeOf(v)
|
|
||||||
match Kind.of(T) {
|
|
||||||
.Pointer => return @inline(fmt_int, @as(uint, @bitcast(v)), str, 16),
|
|
||||||
.Builtin => {
|
|
||||||
if integer(T) {
|
|
||||||
return @inline(fmt_int, v, str, @intcast(opts.radix))
|
|
||||||
} else if T == bool {
|
|
||||||
return @inline(fmt_bool, v, str)
|
|
||||||
} else if float(T) {
|
|
||||||
return @inline(fmt_float, v, str, opts.precision, @intcast(opts.radix))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
.Opt => return @inline(fmt_nullable, v, str, opts),
|
|
||||||
.Enum => return @inline(fmt_enum, v, str, opts),
|
|
||||||
.Struct => return @inline(fmt_container, v, str, opts),
|
|
||||||
.Tuple => return @inline(fmt_container, v, str, opts),
|
|
||||||
.Slice => if T != []u8 return @inline(fmt_container, v, str, opts) else {
|
|
||||||
i := 0
|
|
||||||
loop if i == v.len break else {
|
|
||||||
str[i] = v[i]
|
|
||||||
i += 1
|
|
||||||
}
|
|
||||||
return v.len
|
|
||||||
},
|
|
||||||
_ => @error("Type: \"", T, "\" is not supported."),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
format_with_str := fn(v: @Any(), read: []u8, write: []u8, opts: FormatOptions): uint {
|
|
||||||
T := @TypeOf(v)
|
|
||||||
n := string.count(read, '{')
|
|
||||||
if n != string.count(read, '}') panic("Missing closing '}' in format string.")
|
|
||||||
if Kind.of(T) == .Tuple {
|
|
||||||
if @lenof(T) != n panic("Format string has different number of '{}' than args given.")
|
|
||||||
m := 0
|
|
||||||
i := 0
|
|
||||||
j := 0
|
|
||||||
$loop if m > @lenof(T) break else {
|
|
||||||
if m == @lenof(T) {
|
|
||||||
loop if i == read.len break else {
|
|
||||||
write[j] = read[i]
|
|
||||||
i += 1
|
|
||||||
j += 1
|
|
||||||
}
|
|
||||||
m += 1
|
|
||||||
} else {
|
|
||||||
v2 := v[m]
|
|
||||||
loop if i == read.len break else {
|
|
||||||
if read[i] == '{' & read[i + 1] == '}' {
|
|
||||||
j += format(v2, write[j..], opts)
|
|
||||||
i += 2
|
|
||||||
break
|
|
||||||
} else {
|
|
||||||
write[j] = read[i]
|
|
||||||
i += 1
|
|
||||||
j += 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m += 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return j
|
|
||||||
} else if n > 1 {
|
|
||||||
panic("Format string has multiple '{}' but value provided is not a tuple.")
|
|
||||||
} else {
|
|
||||||
i := 0
|
|
||||||
j := 0
|
|
||||||
loop if i == read.len break else {
|
|
||||||
if read[i] == '{' & read[i + 1] == '}' {
|
|
||||||
j += format(v, write[j..], opts)
|
|
||||||
i += 2
|
|
||||||
} else {
|
|
||||||
write[j] = read[i]
|
|
||||||
i += 1
|
|
||||||
j += 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return j
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -26,7 +26,7 @@
|
||||||
* 3. This notice may not be removed or altered from any source distribution.
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
*/;
|
*/;
|
||||||
|
|
||||||
.{math, random} := @use("stn")
|
.{math, random} := @use("../lib.hb")
|
||||||
|
|
||||||
$ARBITRARY0 := 0x243F6A8885A308D3
|
$ARBITRARY0 := 0x243F6A8885A308D3
|
||||||
$ARBITRARY1 := 0x13198A2E03707344
|
$ARBITRARY1 := 0x13198A2E03707344
|
||||||
|
@ -38,7 +38,7 @@ $ARBITRARY6 := 0xC0AC29B7C97C50DD
|
||||||
$ARBITRARY7 := 0x3F84D5B5B5470917
|
$ARBITRARY7 := 0x3F84D5B5B5470917
|
||||||
$ARBITRARY8 := 0x9216D5D98979FB1B
|
$ARBITRARY8 := 0x9216D5D98979FB1B
|
||||||
$ARBITRARY9 := 0xD1310BA698DFB5AC
|
$ARBITRARY9 := 0xD1310BA698DFB5AC
|
||||||
$FIXED_GLOBAL_SEED := uint.[ARBITRARY4, ARBITRARY5, ARBITRARY6, ARBITRARY7]
|
$FIXED_GLOBAL_SEED := [uint].(ARBITRARY4, ARBITRARY5, ARBITRARY6, ARBITRARY7)
|
||||||
|
|
||||||
global_seed := 0
|
global_seed := 0
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ hash_bytes_long := fn(bytes: ^u8, len: uint, s0: uint, s1: uint, s2: uint, s3: u
|
||||||
|
|
||||||
if remainder > 0 {
|
if remainder > 0 {
|
||||||
remainder_start := bytes + len - math.max(uint, remainder, 16)
|
remainder_start := bytes + len - math.max(uint, remainder, 16)
|
||||||
return @inline(hash_bytes_medium, remainder_start, math.max(uint, remainder, 16), s0, s1, fold_seed)
|
return hash_bytes_medium(remainder_start, math.max(uint, remainder, 16), s0, s1, fold_seed)
|
||||||
}
|
}
|
||||||
|
|
||||||
return s0 ^ s1
|
return s0 ^ s1
|
||||||
|
@ -159,9 +159,17 @@ FoldHasher := struct {
|
||||||
}
|
}
|
||||||
self.accumulator = folded_multiply(s0, s1)
|
self.accumulator = folded_multiply(s0, s1)
|
||||||
} else if len < 256 {
|
} else if len < 256 {
|
||||||
self.accumulator = @inline(hash_bytes_medium, bytes, len, s0, s1, self.fold_seed)
|
self.accumulator = hash_bytes_medium(bytes, len, s0, s1, self.fold_seed)
|
||||||
} else {
|
} else {
|
||||||
self.accumulator = @inline(hash_bytes_long, bytes, len, s0, s1, self.expand_seed2, self.expand_seed3, self.fold_seed)
|
self.accumulator = hash_bytes_long(
|
||||||
|
bytes,
|
||||||
|
len,
|
||||||
|
s0,
|
||||||
|
s1,
|
||||||
|
self.expand_seed2,
|
||||||
|
self.expand_seed3,
|
||||||
|
self.fold_seed,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
acs := @use("acs.hb")
|
acs := @use("acs.hb")
|
||||||
allocators := @use("alloc/lib.hb")
|
allocators := @use("alloc/lib.hb")
|
||||||
fmt := @use("fmt.hb")
|
|
||||||
hashers := @use("hash/lib.hb")
|
hashers := @use("hash/lib.hb")
|
||||||
string := @use("string.hb")
|
string := @use("string.hb")
|
||||||
log := @use("log.hb")
|
log := @use("log.hb")
|
||||||
|
@ -11,56 +10,13 @@ random := @use("random.hb")
|
||||||
file := @use("file_io.hb")
|
file := @use("file_io.hb")
|
||||||
dt := @use("dt.hb")
|
dt := @use("dt.hb")
|
||||||
process := @use("process.hb")
|
process := @use("process.hb")
|
||||||
sleep := @use("sleep.hb")
|
|
||||||
|
|
||||||
panic := fn(message: ?[]u8): never {
|
panic := fn(message: ?^u8): never {
|
||||||
log.printf("HBLang Panic: {}", message, .{log: .Error})
|
log.error("Error: Panic Called, Message:\0")
|
||||||
|
if message == null {
|
||||||
|
log.error("None\0")
|
||||||
|
} else {
|
||||||
|
log.error(message)
|
||||||
|
}
|
||||||
die
|
die
|
||||||
}
|
}
|
||||||
|
|
||||||
Kind := enum {
|
|
||||||
Builtin,
|
|
||||||
Struct,
|
|
||||||
Tuple,
|
|
||||||
Enum,
|
|
||||||
Union,
|
|
||||||
Pointer,
|
|
||||||
Slice,
|
|
||||||
Opt,
|
|
||||||
Function,
|
|
||||||
Template,
|
|
||||||
Global,
|
|
||||||
Const,
|
|
||||||
Module,
|
|
||||||
$of := fn($T: type): Self {
|
|
||||||
return @bitcast(@kindof(T))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$unsigned_int := fn($T: type): bool {
|
|
||||||
return T == uint | T == u8 | T == u16 | T == u32
|
|
||||||
}
|
|
||||||
|
|
||||||
$signed_int := fn($T: type): bool {
|
|
||||||
return T == int | T == i8 | T == i16 | T == i32
|
|
||||||
}
|
|
||||||
|
|
||||||
$integer := fn($T: type): bool {
|
|
||||||
return unsigned_int(T) | signed_int(T)
|
|
||||||
}
|
|
||||||
|
|
||||||
$float := fn($T: type): bool {
|
|
||||||
return T == f32 | T == f64
|
|
||||||
}
|
|
||||||
|
|
||||||
$usize := fn($T: type): type {
|
|
||||||
if @sizeof(T) == 1 return u8 else if @sizeof(T) == 2 return u16 else if @sizeof(T) == 4 return u32 else return uint
|
|
||||||
}
|
|
||||||
|
|
||||||
$bits := fn($T: type): usize(T) {
|
|
||||||
return @sizeof(T) << 3
|
|
||||||
}
|
|
||||||
|
|
||||||
$bitmask := fn($T: type): usize(T) {
|
|
||||||
return -1
|
|
||||||
}
|
|
|
@ -1,41 +1,13 @@
|
||||||
.{string, fmt, memory} := @use("stn")
|
string := @use("string.hb")
|
||||||
|
|
||||||
LogMsg := packed struct {level: LogLevel, string: ^u8, strlen: uint}
|
LogMsg := packed struct {level: u8, string: ^u8, strlen: uint}
|
||||||
|
|
||||||
LogLevel := enum {
|
log := fn(level: u8, message: ^u8): void {
|
||||||
Error,
|
return @eca(3, 1, LogMsg.(level, message, @inline(string.length, message)), @sizeof(LogMsg))
|
||||||
Warn,
|
|
||||||
Info,
|
|
||||||
Debug,
|
|
||||||
Trace,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$log := fn(level: LogLevel, message: []u8): void {
|
error := fn(message: ^u8): void return @inline(log, 0, message)
|
||||||
return @eca(3, 1, LogMsg.(level, message.ptr, message.len), @sizeof(LogMsg))
|
warn := fn(message: ^u8): void return @inline(log, 1, message)
|
||||||
}
|
info := fn(message: ^u8): void return @inline(log, 2, message)
|
||||||
|
debug := fn(message: ^u8): void return @inline(log, 3, message)
|
||||||
$error := fn(message: []u8): void return log(LogLevel.Error, message)
|
trace := fn(message: ^u8): void return @inline(log, 4, message)
|
||||||
$warn := fn(message: []u8): void return log(LogLevel.Warn, message)
|
|
||||||
$info := fn(message: []u8): void return log(LogLevel.Info, message)
|
|
||||||
$debug := fn(message: []u8): void return log(LogLevel.Debug, message)
|
|
||||||
$trace := fn(message: []u8): void return log(LogLevel.Trace, message)
|
|
||||||
|
|
||||||
print_buffer := memory.dangling(u8)
|
|
||||||
|
|
||||||
print := fn(v: @Any(), opts: fmt.FormatOptions): void {
|
|
||||||
if print_buffer == memory.dangling(u8) {
|
|
||||||
print_buffer = memory.request_page(1, false)
|
|
||||||
}
|
|
||||||
len := @inline(fmt.format, v, print_buffer[0..memory.PAGE_SIZE], opts)
|
|
||||||
@eca(3, 1, LogMsg.(opts.log, print_buffer, len), @sizeof(LogMsg))
|
|
||||||
memory.set(u8, &0, print_buffer, len)
|
|
||||||
}
|
|
||||||
|
|
||||||
printf := fn(str: []u8, v: @Any(), opts: fmt.FormatOptions): void {
|
|
||||||
if print_buffer == memory.dangling(u8) {
|
|
||||||
print_buffer = memory.request_page(1, false)
|
|
||||||
}
|
|
||||||
len := @inline(fmt.format_with_str, v, str, print_buffer[0..memory.PAGE_SIZE], opts)
|
|
||||||
@eca(3, 1, LogMsg.(opts.log, print_buffer, len), @sizeof(LogMsg))
|
|
||||||
memory.set(u8, &0, print_buffer, len)
|
|
||||||
}
|
|
File diff suppressed because one or more lines are too long
|
@ -1,10 +1,8 @@
|
||||||
$PAGE_SIZE := 4096
|
$PAGE_SIZE := 4096
|
||||||
|
$MAX_ALLOC := 0xFF
|
||||||
|
$MAX_FREE := 0xFF
|
||||||
|
|
||||||
$uninit := fn($Expr: type): Expr {
|
$uninit := fn($Expr: type): ?Expr {
|
||||||
return idk
|
|
||||||
}
|
|
||||||
|
|
||||||
$nulled := fn($Expr: type): ?Expr {
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,30 +11,37 @@ $dangling := fn($Expr: type): ^Expr {
|
||||||
}
|
}
|
||||||
|
|
||||||
$calc_pages := fn($Expr: type, num: uint): uint {
|
$calc_pages := fn($Expr: type, num: uint): uint {
|
||||||
return (num + PAGE_SIZE - 1) / PAGE_SIZE
|
return 1 + @sizeof(Expr) * num / PAGE_SIZE
|
||||||
}
|
}
|
||||||
|
|
||||||
// ! will be replaced, don't get attached
|
// ! will be replaced, don't get attached
|
||||||
$alloc := fn($Expr: type, num: uint): ^Expr {
|
alloc := fn($Expr: type, num: uint): ^Expr {
|
||||||
return @bitcast(request_page(calc_pages(Expr, num * @sizeof(Expr)), false))
|
pages := calc_pages(Expr, num)
|
||||||
|
if pages <= MAX_ALLOC {
|
||||||
|
return @bitcast(request_page(@intcast(pages)))
|
||||||
}
|
}
|
||||||
|
ptr := request_page(MAX_ALLOC)
|
||||||
$alloc_zeroed := fn($Expr: type, num: uint): ^Expr {
|
remaining := pages - MAX_ALLOC
|
||||||
return @bitcast(request_page(calc_pages(Expr, num * @sizeof(Expr)), true))
|
loop if remaining < MAX_ALLOC break else {
|
||||||
|
_ = request_page(MAX_ALLOC)
|
||||||
|
remaining -= MAX_ALLOC
|
||||||
|
}
|
||||||
|
_ = request_page(@intcast(remaining))
|
||||||
|
return @bitcast(ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ! stub
|
// ! stub
|
||||||
$free := fn($Expr: type, ptr: ^Expr, num: uint): void {
|
$free := fn($Expr: type, ptr: ^Expr, num: uint, nullify: bool): void {
|
||||||
release_page(@bitcast(ptr), calc_pages(Expr, num * @sizeof(Expr)))
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
RqPageMsg := packed struct {a: u8, count: uint, zeroed: bool}
|
RqPageMsg := packed struct {a: u8, count: u8}
|
||||||
$request_page := fn(count: uint, zeroed: bool): ^u8 {
|
$request_page := fn(count: u8): ^u8 {
|
||||||
return @eca(3, 2, &RqPageMsg.(0, count, zeroed), @sizeof(RqPageMsg))
|
return @eca(3, 2, &RqPageMsg.(0, count), @sizeof(RqPageMsg))
|
||||||
}
|
}
|
||||||
|
|
||||||
RlPageMsg := packed struct {a: u8, count: uint, ptr: ^u8}
|
RlPageMsg := packed struct {a: u8, count: u8, ptr: ^u8}
|
||||||
$release_page := fn(ptr: ^u8, count: uint): void {
|
$release_page := fn(ptr: ^u8, count: u8): void {
|
||||||
return @eca(3, 2, &RlPageMsg.(1, count, ptr), @sizeof(RlPageMsg))
|
return @eca(3, 2, &RlPageMsg.(1, count, ptr), @sizeof(RlPageMsg))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,26 +65,12 @@ $inl := fn(addr: u16): u32 {
|
||||||
return @eca(3, 3, &InlMsg.(0, 2, addr), @sizeof(InlMsg))
|
return @eca(3, 3, &InlMsg.(0, 2, addr), @sizeof(InlMsg))
|
||||||
}
|
}
|
||||||
|
|
||||||
OutsMsg := packed struct {a: u8, b: u8, addr: u16, value: u16}
|
CopyMsg := packed struct {a: u8, count: u32, src: ^u8, dest: ^u8}
|
||||||
$outs := fn(addr: u16, value: u32): void {
|
|
||||||
return @eca(3, 3, &OutsMsg.(1, 1, addr, value), @sizeof(OutsMsg))
|
|
||||||
}
|
|
||||||
|
|
||||||
InsMsg := packed struct {a: u8, b: u8, addr: u16}
|
|
||||||
$ins := fn(addr: u16): u16 {
|
|
||||||
return @eca(3, 3, &InsMsg.(0, 1, addr), @sizeof(InsMsg))
|
|
||||||
}
|
|
||||||
|
|
||||||
CopyMsg := packed struct {a: u8, count: uint, src: ^u8, dest: ^u8}
|
|
||||||
$copy := fn($Expr: type, src: ^Expr, dest: ^Expr, count: uint): void {
|
$copy := fn($Expr: type, src: ^Expr, dest: ^Expr, count: uint): void {
|
||||||
return @eca(3, 2, &CopyMsg.(4, count * @sizeof(Expr), @bitcast(src), @bitcast(dest)), @sizeof(CopyMsg))
|
return @eca(3, 2, &CopyMsg.(4, @intcast(count * @sizeof(Expr)), @bitcast(src), @bitcast(dest)), @sizeof(CopyMsg))
|
||||||
}
|
}
|
||||||
|
|
||||||
SetMsg := packed struct {a: u8, count: uint, size: uint, src: ^u8, dest: ^u8}
|
SetMsg := packed struct {a: u8, count: u32, size: u32, src: ^u8, dest: ^u8}
|
||||||
$set := fn($Expr: type, src: ^Expr, dest: ^Expr, count: uint): void {
|
$set := fn($Expr: type, src: ^Expr, dest: ^Expr, count: uint): void {
|
||||||
return @eca(3, 2, &SetMsg.(5, count, @sizeof(Expr), @bitcast(src), @bitcast(dest)), @sizeof(SetMsg))
|
return @eca(3, 2, &SetMsg.(5, @intcast(count), @intcast(@sizeof(Expr)), @bitcast(src), @bitcast(dest)), @sizeof(SetMsg))
|
||||||
}
|
|
||||||
|
|
||||||
$move := fn($Expr: type, src: ^Expr, dest: ^Expr, count: uint): void {
|
|
||||||
return @eca(3, 2, &CopyMsg.(7, count * @sizeof(Expr), @bitcast(src), @bitcast(dest)), @sizeof(CopyMsg))
|
|
||||||
}
|
}
|
|
@ -1,11 +1,9 @@
|
||||||
|
// ! will be rewritten to take a file object when filesystem is exist
|
||||||
// returns PID
|
// returns PID
|
||||||
$spawn := fn(proc_exe: ^u8, length: uint): uint {
|
$spawn := fn(proc_exe: ^u8, length: uint): uint {
|
||||||
return @eca(3, 6, proc_exe, length)
|
return @eca(3, 6, proc_exe, length)
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns: 0 if child process, child PID if parent process
|
|
||||||
$fork := fn(): uint return @eca(3, 7)
|
|
||||||
|
|
||||||
/* TODO:
|
/* TODO:
|
||||||
- Spawn an empty process
|
- Spawn an empty process
|
||||||
- Call a function to load bytes into that process from a function
|
- Call a function to load bytes into that process from a function
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
$subscribe_to_interrupt := fn(interrupt_number: u8): bool {
|
subscribe_to_interrupt := fn(interrupt_number: u8): bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// Pauses execution until the interrupt occures
|
// Pauses execution until the interrupt occures
|
||||||
$sleep_until_interrupt := fn(interrupt_number: u8): void {
|
sleep_until_interrupt := fn(interrupt_number: u8): void {
|
||||||
@eca(6, interrupt_number)
|
@eca(6, interrupt_number)
|
||||||
}
|
}
|
|
@ -1,172 +1,216 @@
|
||||||
// todo: splice function
|
length := fn(ptr: ^u8): uint {
|
||||||
|
len := 0
|
||||||
|
loop if *(ptr + len) == 0 return len else len += 1
|
||||||
|
}
|
||||||
|
|
||||||
reverse := fn(str: []u8): void {
|
display_int := fn(num: int, p: ^u8, radix: uint): ^u8 {
|
||||||
if str.len == 0 return;
|
is_negative := num < 0
|
||||||
j := str.len - 1
|
if is_negative num = -num
|
||||||
i := 0
|
|
||||||
|
ptr := p
|
||||||
|
|
||||||
|
if num == 0 {
|
||||||
|
*ptr = 0x30;
|
||||||
|
*(ptr + 1) = 0
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
loop if num == 0 break else {
|
||||||
|
remainder := num % @bitcast(radix)
|
||||||
|
num /= @bitcast(radix);
|
||||||
|
*ptr = @intcast(remainder + 0x30)
|
||||||
|
if remainder > 9 {
|
||||||
|
*ptr = @intcast(remainder - 10 + 0x41)
|
||||||
|
}
|
||||||
|
ptr += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if is_negative {
|
||||||
|
*ptr = 0x2D
|
||||||
|
ptr += 1
|
||||||
|
}
|
||||||
|
// ! it gets broked when you do this ??
|
||||||
|
// *ptr = 0
|
||||||
|
|
||||||
|
@inline(reverse, p)
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
reverse := fn(s: ^u8): void {
|
||||||
|
j := s + @inline(length, s) - 1
|
||||||
temp := @as(u8, 0)
|
temp := @as(u8, 0)
|
||||||
loop if i < j {
|
loop if s < j {
|
||||||
temp = str[i]
|
temp = *s;
|
||||||
str[i] = str[j]
|
*s = *j;
|
||||||
str[j] = temp
|
*j = temp
|
||||||
i += 1
|
s += 1
|
||||||
j -= 1
|
j -= 1
|
||||||
} else return
|
} else return
|
||||||
}
|
}
|
||||||
|
|
||||||
equals := fn(lhs: []u8, rhs: []u8): bool {
|
equals := fn(lhs: ^u8, rhs: ^u8): bool {
|
||||||
if lhs.len != rhs.len return false
|
if lhs == rhs {
|
||||||
if lhs.ptr == rhs.ptr return true
|
|
||||||
i := 0
|
|
||||||
loop if i == lhs.len break else {
|
|
||||||
if lhs[i] != rhs[i] return false
|
|
||||||
i += 1
|
|
||||||
}
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
loop if *lhs != *rhs {
|
||||||
clear := fn(str: []u8): void {
|
return false
|
||||||
i := 0
|
} else if *lhs == 0 {
|
||||||
loop if i == str.len break else {
|
return true
|
||||||
str[i] = 0
|
} else {
|
||||||
i += 1
|
lhs += 1
|
||||||
|
rhs += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
split_once := fn(haystack: []u8, needle: @Any()): ?struct {left: []u8, right: []u8} {
|
clear := fn(ptr: ^u8): void {
|
||||||
T := @TypeOf(needle)
|
loop if *ptr == 0 break else {
|
||||||
i := 0
|
*ptr = 0
|
||||||
if T == []u8 {
|
ptr += 1
|
||||||
if needle.len == 0 return null
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
split_once := fn(haystack: ^u8, needle: u8): ?^u8 {
|
||||||
|
loop if *haystack == needle return haystack else if *haystack == 0 return null else haystack += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
split_once_str := fn(haystack: ^u8, needle: ^u8): ?^u8 {
|
||||||
|
if *needle == 0 return null
|
||||||
|
|
||||||
|
loop if *haystack == 0 return null else {
|
||||||
|
if *haystack == *needle {
|
||||||
|
h := haystack
|
||||||
|
n := needle
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if i + needle.len > haystack.len return null
|
n += 1
|
||||||
if haystack[i] == needle[0] {
|
h += 1
|
||||||
matches := true
|
if *n == 0 {
|
||||||
n := 1
|
return haystack
|
||||||
loop {
|
} else if *h == 0 | *h != *n {
|
||||||
if n == needle.len break
|
|
||||||
if haystack[i + n] != needle[n] {
|
|
||||||
matches = false
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
n += 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if matches return .(haystack[0..i], haystack[i + needle.len..])
|
|
||||||
}
|
}
|
||||||
i += 1
|
haystack += 1
|
||||||
}
|
|
||||||
} else if T == u8 {
|
|
||||||
loop {
|
|
||||||
if haystack[i] == needle {
|
|
||||||
return .(haystack[0..i], haystack[i + 1..])
|
|
||||||
} else if i == haystack.len return null
|
|
||||||
i += 1
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
@error("Type of needle must be []u8 or u8.")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
split := fn(iter: []u8, needle: @Any()): struct {
|
Split := struct {
|
||||||
str: []u8,
|
str: ^u8,
|
||||||
needle: @TypeOf(needle),
|
needle: u8,
|
||||||
done: bool,
|
done: bool,
|
||||||
|
|
||||||
next := fn(self: ^Self): ?[]u8 {
|
|
||||||
if self.done return null;
|
|
||||||
|
|
||||||
splits := split_once(self.str, self.needle)
|
|
||||||
if splits != null {
|
|
||||||
self.str = splits.right
|
|
||||||
return splits.left
|
|
||||||
} else {
|
|
||||||
self.done = true
|
|
||||||
return self.str
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} {
|
|
||||||
T := @TypeOf(needle)
|
|
||||||
if T != []u8 & T != u8 {
|
|
||||||
@error("Type of needle must be []u8 or u8.")
|
|
||||||
}
|
|
||||||
return .(iter, needle, false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
chars := fn(iter: []u8): struct {
|
split := fn(iter: ^u8, needle: u8): Split {
|
||||||
str: []u8,
|
return .(
|
||||||
|
iter,
|
||||||
next := fn(self: ^Self): ?u8 {
|
needle,
|
||||||
if self.str.len == 0 return null
|
false,
|
||||||
self.str = self.str[1..]
|
)
|
||||||
return self.str[0]
|
|
||||||
}
|
|
||||||
} {
|
|
||||||
return .(iter)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
count := fn(haystack: []u8, needle: @Any()): uint {
|
iter_split := fn(iter: ^Split): ?^u8 {
|
||||||
T := @TypeOf(needle)
|
if iter.done | *iter.str == 0 {
|
||||||
i := 0
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
next := split_once(iter.str + 1, iter.needle)
|
||||||
|
|
||||||
|
if next == null {
|
||||||
|
iter.done = true
|
||||||
|
return iter.str
|
||||||
|
}
|
||||||
|
s := iter.str
|
||||||
|
iter.str = next + 1
|
||||||
|
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
SplitStr := struct {
|
||||||
|
str: ^u8,
|
||||||
|
needle: ^u8,
|
||||||
|
done: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
split_str := fn(iter: ^u8, needle: ^u8): SplitStr {
|
||||||
|
return .(
|
||||||
|
iter,
|
||||||
|
needle,
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
iter_split_str := fn(iter: ^SplitStr): ?^u8 {
|
||||||
|
if iter.done | *iter.str == 0 {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
next := split_once_str(iter.str, iter.needle)
|
||||||
|
|
||||||
|
if next == null {
|
||||||
|
iter.done = true
|
||||||
|
return iter.str
|
||||||
|
}
|
||||||
|
|
||||||
|
s := iter.str
|
||||||
|
|
||||||
|
iter.str = next + length(iter.needle)
|
||||||
|
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
find_once := fn(haystack: ^u8, needle: u8): ?uint {
|
||||||
|
return @bitcast(@inline(split_once, haystack, needle) - haystack)
|
||||||
|
}
|
||||||
|
|
||||||
|
find_once_str := fn(haystack: ^u8, needle: ^u8): ?uint {
|
||||||
|
return @bitcast(@inline(split_once_str, haystack, needle) - haystack)
|
||||||
|
}
|
||||||
|
|
||||||
|
count := fn(haystack: ^u8, needle: ^u8): uint {
|
||||||
c := 0
|
c := 0
|
||||||
if T == []u8 {
|
loop if *haystack == needle {
|
||||||
if needle.len == 0 return null
|
c += 1
|
||||||
loop {
|
haystack += 1
|
||||||
if i + needle.len > haystack.len return c
|
} else if *haystack == 0 return c else haystack += 1
|
||||||
if haystack[i] == needle[0] {
|
|
||||||
matches := true
|
|
||||||
n := 1
|
|
||||||
loop {
|
|
||||||
if n == needle.len break
|
|
||||||
if haystack[i + n] != needle[n] {
|
|
||||||
matches = false
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
count_str := fn(haystack: ^u8, needle: ^u8): uint {
|
||||||
|
if *needle == 0 return 0
|
||||||
|
c := 0
|
||||||
|
loop if *haystack == 0 return c else {
|
||||||
|
if *haystack == *needle {
|
||||||
|
h := haystack
|
||||||
|
n := needle
|
||||||
|
|
||||||
|
loop {
|
||||||
n += 1
|
n += 1
|
||||||
}
|
h += 1
|
||||||
|
if *n == 0 {
|
||||||
if matches c += 1
|
c += 1
|
||||||
}
|
|
||||||
i += 1
|
|
||||||
}
|
|
||||||
} else if T == u8 {
|
|
||||||
loop {
|
|
||||||
if haystack[i] == needle c += 1 else if i == haystack.len return c
|
|
||||||
i += 1
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
@error("Type of needle must be []u8 or u8.")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
left_trim := fn(str: []u8, sub: []u8): []u8 {
|
|
||||||
i := 0
|
|
||||||
if str[0] == sub[0] {
|
|
||||||
loop if i == sub.len {
|
|
||||||
return str[i..str.len]
|
|
||||||
} else if str[i] != sub[i] | i == str.len {
|
|
||||||
break
|
break
|
||||||
|
} else if *h == 0 | *h != *n {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
haystack += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
left_trim := fn(str: ^u8, sub: ^u8): ^u8 {
|
||||||
|
original := str
|
||||||
|
if *str == *sub {
|
||||||
|
loop if *sub == 0 {
|
||||||
|
return str
|
||||||
|
} else if *str != *sub {
|
||||||
|
return original
|
||||||
|
} else if *str == 0 {
|
||||||
|
return original
|
||||||
} else {
|
} else {
|
||||||
i += 1
|
str += 1
|
||||||
|
sub += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
|
||||||
right_trim := fn(str: []u8, sub: []u8): []u8 {
|
|
||||||
i := 0
|
|
||||||
if str[str.len - 1] == sub[sub.len - 1] {
|
|
||||||
loop if i == sub.len {
|
|
||||||
return str[0..str.len - i]
|
|
||||||
} else if str[str.len - i - 1] != sub[sub.len - i - 1] | i == str.len {
|
|
||||||
break
|
|
||||||
} else {
|
|
||||||
i += 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return str
|
|
||||||
}
|
|
||||||
|
|
||||||
trim := fn(str: []u8, sub: []u8): []u8 {
|
|
||||||
return right_trim(left_trim(str, sub), sub)
|
|
||||||
}
|
|
|
@ -1,16 +1,16 @@
|
||||||
.{math: .{Vec2}, buffer, log, memory, string} := @use("stn");
|
.{math: .{Vec2}, buffer, log, memory, string} := @use("../../stn/src/lib.hb");
|
||||||
.{Channel, Window, send_header, send_message, await_channel, await_header, await_message, message, BUFFER_SERVER, BUFFER_CLIENT, WindowProps, WindowData} := @use("lib:sunset_proto");
|
.{Channel, Window, send_header, send_message, await_channel, await_header, await_message, message, BUFFER_SERVER, BUFFER_CLIENT, WindowProps, WindowData} := @use("./lib.hb");
|
||||||
.{Surface, Color} := @use("lib:render")
|
.{new_surface, Color} := @use("../../render/src/lib.hb")
|
||||||
|
|
||||||
// ! in the future this should be safely handled
|
// ! in the future this should be safely handled
|
||||||
channel := Channel.(0, 0)
|
channel := Channel.(0, 0)
|
||||||
|
|
||||||
find_server := fn(): void {
|
find_server := fn(): void {
|
||||||
log.info("client: locating server")
|
log.info("client: locating server\0")
|
||||||
channel2 := await_channel()
|
channel2 := await_channel()
|
||||||
channel.server = channel2.server
|
channel.server = channel2.server
|
||||||
channel.client = channel2.client
|
channel.client = channel2.client
|
||||||
log.info("client: server located")
|
log.info("client: server located\0")
|
||||||
}
|
}
|
||||||
|
|
||||||
new := fn(props: WindowProps): ?Window {
|
new := fn(props: WindowProps): ?Window {
|
||||||
|
@ -19,14 +19,14 @@ new := fn(props: WindowProps): ?Window {
|
||||||
if response.header.kind != message.ack {
|
if response.header.kind != message.ack {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
log.info("client: recv ack")
|
log.info("client: recv ack\0")
|
||||||
send_message(WindowProps, message.props, props, response.body.server)
|
send_message(WindowProps, message.props, props, response.body.server)
|
||||||
windowdata := await_message(WindowData, response.body.client)
|
windowdata := await_message(WindowData, response.body.client)
|
||||||
if windowdata.header.kind != message.ack {
|
if windowdata.header.kind != message.ack {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
log.info("client: recv windowdata")
|
log.info("client: recv windowdata\0")
|
||||||
surface := Surface.new(windowdata.body.props.dimensions.x, windowdata.body.props.dimensions.y)
|
surface := new_surface(windowdata.body.props.dimensions.x, windowdata.body.props.dimensions.y)
|
||||||
return .(windowdata.body, surface)
|
return .(windowdata.body, surface)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
.{math: .{Vec2}, buffer, memory} := @use("stn");
|
.{math: .{Vec2}, buffer, memory} := @use("../../stn/src/lib.hb");
|
||||||
.{Surface} := @use("lib:render")
|
.{Surface} := @use("../../render/src/lib.hb")
|
||||||
|
|
||||||
$BUFFER_SERVER := "sunset_server"
|
$BUFFER_SERVER := "sunset_server\0"
|
||||||
$BUFFER_CLIENT := "sunset_client"
|
$BUFFER_CLIENT := "sunset_client\0"
|
||||||
|
|
||||||
Channel := packed struct {
|
Channel := packed struct {
|
||||||
client: uint,
|
client: uint,
|
||||||
|
@ -48,8 +48,6 @@ await_channel := fn(): Channel {
|
||||||
await_message := fn($Expr: type, buffer_id: uint): Message(Expr) {
|
await_message := fn($Expr: type, buffer_id: uint): Message(Expr) {
|
||||||
response := @as(?Message(Expr), null)
|
response := @as(?Message(Expr), null)
|
||||||
loop {
|
loop {
|
||||||
// awaiting here causes flickering... idk why
|
|
||||||
buffer.await(buffer_id)
|
|
||||||
buffer.recv(?Message(Expr), buffer_id, &response)
|
buffer.recv(?Message(Expr), buffer_id, &response)
|
||||||
if response != null {
|
if response != null {
|
||||||
return @as(Message(Expr), response)
|
return @as(Message(Expr), response)
|
||||||
|
@ -60,11 +58,9 @@ await_message := fn($Expr: type, buffer_id: uint): Message(Expr) {
|
||||||
await_header := fn(buffer_id: uint): MessageHeader {
|
await_header := fn(buffer_id: uint): MessageHeader {
|
||||||
response := @as(?MessageHeader, null)
|
response := @as(?MessageHeader, null)
|
||||||
loop {
|
loop {
|
||||||
// awaiting here causes flickering... idk why
|
|
||||||
buffer.await(buffer_id)
|
|
||||||
buffer.recv(?MessageHeader, buffer_id, &response)
|
buffer.recv(?MessageHeader, buffer_id, &response)
|
||||||
if response != null {
|
if response != null {
|
||||||
return @as(MessageHeader, response)
|
return @as(?MessageHeader, response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,7 +81,8 @@ Message := fn($Expr: type): type {
|
||||||
WindowProps := struct {
|
WindowProps := struct {
|
||||||
position: Vec2(uint),
|
position: Vec2(uint),
|
||||||
dimensions: Vec2(uint),
|
dimensions: Vec2(uint),
|
||||||
title: []u8,
|
// ! replace with owned string type later
|
||||||
|
title: ^u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowData := struct {
|
WindowData := struct {
|
||||||
|
|
|
@ -1,33 +1,33 @@
|
||||||
.{math, log, string, random, buffer, memory} := @use("stn");
|
.{math, log, string, random, buffer, memory} := @use("../../stn/src/lib.hb");
|
||||||
.{Color, Surface, text} := @use("lib:render");
|
.{Color, Surface, new_surface, put_surface, sync, put_rect, put_filled_rect, text, put_text, clear, white, black} := @use("../../render/src/lib.hb");
|
||||||
.{Channel, Window, WindowProps, WindowData, MessageHeader, BUFFER_SERVER, BUFFER_CLIENT, message, permissions, recv_header, recv_message, send_message, send_header, await_message} := @use("lib:sunset_proto")
|
.{Channel, Window, WindowProps, WindowData, MessageHeader, BUFFER_SERVER, BUFFER_CLIENT, message, permissions, recv_header, recv_message, send_message, send_header, await_message} := @use("./lib.hb")
|
||||||
|
|
||||||
WindowServer := struct {
|
WindowServer := struct {
|
||||||
window_count: uint,
|
window_count: uint,
|
||||||
channel: Channel,
|
channel: Channel,
|
||||||
// ! replace this with a collection when we get an allocator
|
// ! replace this with a collection when we get an allocator
|
||||||
windows: [10]?Window,
|
windows: [?Window; 10],
|
||||||
font: text.Font,
|
font: text.Font,
|
||||||
}
|
}
|
||||||
|
|
||||||
// ! in the future this should be safely handled
|
// ! in the future this should be safely handled
|
||||||
server := @as(WindowServer, idk)
|
server := @as(WindowServer, idk)
|
||||||
|
|
||||||
psf := @embed("sysdata:assets/consolefonts/tamsyn/10x20r.psf")
|
psf := @embed("../../../assets/consolefonts/tamsyn/10x20r.psf")
|
||||||
|
|
||||||
start := fn(): void {
|
start := fn(): void {
|
||||||
font := text.font_from_psf2(@bitcast(&psf), false)
|
font := text.font_from_psf2(@bitcast(&psf), false)
|
||||||
if font == null {
|
if font == null {
|
||||||
log.error("server: failed to load asset")
|
log.error("server: failed to load asset\0")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
server = .(
|
server = .(
|
||||||
0,
|
0,
|
||||||
.{client: buffer.create(BUFFER_CLIENT), server: buffer.create(BUFFER_SERVER)},
|
.{client: buffer.create(BUFFER_CLIENT), server: buffer.create(BUFFER_SERVER)},
|
||||||
.[null, null, null, null, null, null, null, null, null, null],
|
.(null, null, null, null, null, null, null, null, null, null),
|
||||||
@as(text.Font, font),
|
@as(text.Font, font),
|
||||||
)
|
)
|
||||||
log.info("server: started server")
|
log.info("server: started server\0")
|
||||||
}
|
}
|
||||||
|
|
||||||
incoming := fn(): bool {
|
incoming := fn(): bool {
|
||||||
|
@ -36,14 +36,14 @@ incoming := fn(): bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if msg.kind == message.syn {
|
if msg.kind == message.syn {
|
||||||
log.info("server: recv syn")
|
log.info("server: recv syn\0")
|
||||||
channel := Channel.(buffer.create_nameless(), buffer.create_nameless())
|
channel := Channel.(buffer.create_nameless(), buffer.create_nameless())
|
||||||
send_message(Channel, message.ack, channel, server.channel.client)
|
send_message(Channel, message.ack, channel, server.channel.client)
|
||||||
props := await_message(WindowProps, channel.server)
|
props := await_message(WindowProps, channel.server)
|
||||||
if props.header.kind != message.props {
|
if props.header.kind != message.props {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
log.info("server: recv props")
|
log.info("server: recv props\0")
|
||||||
// ! do inspection of requested props here
|
// ! do inspection of requested props here
|
||||||
data := WindowData.(props.body, channel, permissions.default)
|
data := WindowData.(props.body, channel, permissions.default)
|
||||||
send_message(WindowData, message.ack, data, channel.client)
|
send_message(WindowData, message.ack, data, channel.client)
|
||||||
|
@ -51,16 +51,17 @@ incoming := fn(): bool {
|
||||||
// decorations
|
// decorations
|
||||||
{
|
{
|
||||||
title := data.props.title
|
title := data.props.title
|
||||||
deco_length := title.len * 10
|
title_length := string.length(title)
|
||||||
|
deco_length := title_length * 10
|
||||||
// draw the window tab bar
|
// draw the window tab bar
|
||||||
surface.put_filled_rect(.(0, 0), .(data.props.dimensions.x + DECO_WIDTH + deco_length, DECO_HEIGHT_TOP), DECO_COLOUR)
|
put_filled_rect(surface, .(0, 0), .(data.props.dimensions.x + DECO_WIDTH + deco_length, DECO_HEIGHT_TOP), DECO_COLOUR)
|
||||||
// Draw the window tab
|
// Draw the window tab
|
||||||
surface.put_filled_rect(.(0, 0), .(deco_length, DECO_HEIGHT_TOP - 1), DECO_COLOUR_DARKER)
|
put_filled_rect(surface, .(0, 0), .(deco_length, DECO_HEIGHT_TOP - 1), DECO_COLOUR_DARKER)
|
||||||
|
|
||||||
// Draw the outside box
|
// Draw the outside box
|
||||||
surface.put_rect(.(0, 0), data.props.dimensions + .(DECO_WIDTH - 1, DECO_HEIGHT_TOP + DECO_HEIGHT_BOTTOM - 1), DECO_COLOUR)
|
put_rect(surface, .(0, 0), data.props.dimensions + .(DECO_WIDTH - 1, DECO_HEIGHT_TOP + DECO_HEIGHT_BOTTOM - 1), DECO_COLOUR)
|
||||||
|
|
||||||
surface.put_text(server.font, .(2, 1), .(0, 0, 0, 255), data.props.title)
|
put_text(surface, server.font, .(2, 1), .(0, 0, 0, 255), data.props.title)
|
||||||
}
|
}
|
||||||
server.windows[server.window_count] = .(data, surface)
|
server.windows[server.window_count] = .(data, surface)
|
||||||
server.window_count += 1
|
server.window_count += 1
|
||||||
|
@ -75,7 +76,10 @@ $DECO_COLOUR := Color.(100, 200, 255, 255)
|
||||||
$DECO_COLOUR_DARKER := Color.(89, 57, 89, 255)
|
$DECO_COLOUR_DARKER := Color.(89, 57, 89, 255)
|
||||||
|
|
||||||
new_window_decorations := fn(dimensions: math.Vec2(uint)): Surface {
|
new_window_decorations := fn(dimensions: math.Vec2(uint)): Surface {
|
||||||
return @inline(Surface.new, dimensions.x + DECO_WIDTH, dimensions.y + DECO_HEIGHT_TOP + DECO_HEIGHT_BOTTOM)
|
return new_surface(
|
||||||
|
dimensions.x + DECO_WIDTH,
|
||||||
|
dimensions.y + DECO_HEIGHT_TOP + DECO_HEIGHT_BOTTOM,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ! compositor code. this currently disallows tearing.
|
// ! compositor code. this currently disallows tearing.
|
||||||
|
@ -100,10 +104,10 @@ collect_frames := fn(): void {
|
||||||
send_header(message.ack, window.data.channel.client)
|
send_header(message.ack, window.data.channel.client)
|
||||||
ptr := await_message(^Color, window.data.channel.server)
|
ptr := await_message(^Color, window.data.channel.server)
|
||||||
if ptr.header.kind != message.ack {
|
if ptr.header.kind != message.ack {
|
||||||
i += 1
|
return
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
window.surface.put_surface(
|
put_surface(
|
||||||
|
window.surface,
|
||||||
Surface.(
|
Surface.(
|
||||||
ptr.body,
|
ptr.body,
|
||||||
window.data.props.dimensions.x,
|
window.data.props.dimensions.x,
|
||||||
|
@ -125,7 +129,7 @@ render_clients := fn(screen: Surface): void {
|
||||||
i += 1
|
i += 1
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
screen.put_surface(window.surface, window.data.props.position, false)
|
put_surface(screen, window.surface, window.data.props.position, false)
|
||||||
i += 1
|
i += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1 +0,0 @@
|
||||||
# ablefetch
|
|
|
@ -1,43 +0,0 @@
|
||||||
stn := @use("stn")
|
|
||||||
sunset := @use("lib:sunset_proto")
|
|
||||||
render := @use("lib:render")
|
|
||||||
psf := @embed("sysdata:assets/consolefonts/tamsyn/10x20r.psf")
|
|
||||||
horizon_api := @use("lib:horizon_api");
|
|
||||||
|
|
||||||
.{Vec2} := stn.math;
|
|
||||||
.{log} := stn;
|
|
||||||
.{set_color, render_label_to_surface, Label} := horizon_api.widgets.label
|
|
||||||
|
|
||||||
main := fn(): void {
|
|
||||||
sunset.client.find_server()
|
|
||||||
|
|
||||||
window := sunset.client.new(.(.(10, 10), .(400, 300), "ableFetch!"))
|
|
||||||
font := @unwrap(render.text.font_from_psf2(@bitcast(&psf), false))
|
|
||||||
// pos := Vec2(uint).(1, 100)
|
|
||||||
|
|
||||||
if window == null {
|
|
||||||
log.error("got no window")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
text_label := Label.new_label("kernel : akern 0.2.0", 300)
|
|
||||||
text_label_2 := Label.new_label("os : ableos", 300)
|
|
||||||
text_label_3 := Label.new_label("wm : sunset", 300)
|
|
||||||
text_label.set_color(render.BLACK, render.WHITE)
|
|
||||||
|
|
||||||
text_label_2.set_color(render.BLACK, render.WHITE)
|
|
||||||
text_label_3.set_color(render.BLACK, render.WHITE)
|
|
||||||
|
|
||||||
pos1 := Vec2(uint).(1, 1)
|
|
||||||
pos2 := Vec2(uint).(1, 20)
|
|
||||||
pos3 := Vec2(uint).(1, 40)
|
|
||||||
|
|
||||||
render_label_to_surface(window.surface, text_label, font, pos1)
|
|
||||||
render_label_to_surface(window.surface, text_label_2, font, pos2)
|
|
||||||
render_label_to_surface(window.surface, text_label_3, font, pos3)
|
|
||||||
loop {
|
|
||||||
// stn.log.info("AAAA")
|
|
||||||
_ = sunset.client.send_frame(window)
|
|
||||||
// stn.sleep.sleep_until_interrupt(100)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
# adit
|
|
|
@ -1,15 +0,0 @@
|
||||||
render := @use("lib:render")
|
|
||||||
|
|
||||||
psf := @embed("sysdata:assets/consolefonts/tamsyn/10x20r.psf")
|
|
||||||
|
|
||||||
Assets := struct {
|
|
||||||
font: render.text.Font,
|
|
||||||
|
|
||||||
new := fn(): Self {
|
|
||||||
font := render.text.font_from_psf2(@bitcast(&psf), false)
|
|
||||||
if font == null {
|
|
||||||
die
|
|
||||||
}
|
|
||||||
return Self.(font)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,74 +0,0 @@
|
||||||
theme := @use("theme.hb")
|
|
||||||
render := @use("lib:render")
|
|
||||||
sunset := @use("lib:sunset_proto")
|
|
||||||
assets := @use("assets.hb")
|
|
||||||
stn := @use("stn")
|
|
||||||
|
|
||||||
Editor := struct {
|
|
||||||
msg: ?^u8,
|
|
||||||
|
|
||||||
// is_shift_pressed: bool = false,
|
|
||||||
// is_ctrl_pressed: bool = false,
|
|
||||||
// is_extended: bool = false,
|
|
||||||
assets: assets.Assets,
|
|
||||||
line_lines: bool = false,
|
|
||||||
theme: theme.Theme,
|
|
||||||
window: sunset.client.Window,
|
|
||||||
|
|
||||||
new := fn(): Self {
|
|
||||||
sunset.client.find_server()
|
|
||||||
|
|
||||||
window_width := 800
|
|
||||||
window_height := 400
|
|
||||||
window := sunset.client.new(.(.(60, 40), .(window_width, window_height), "Adit"))
|
|
||||||
if window == null {
|
|
||||||
stn.log.error("got no window")
|
|
||||||
die
|
|
||||||
}
|
|
||||||
return Self.(null, assets.Assets.new(), true, theme.Theme.new(), window)
|
|
||||||
}
|
|
||||||
|
|
||||||
clear := fn(self: Self): void {
|
|
||||||
self.window.surface.clear(self.theme.bg_color)
|
|
||||||
}
|
|
||||||
|
|
||||||
frame_sync := fn(self: Self): void {
|
|
||||||
// +++ Frame Sync +++
|
|
||||||
_ = sunset.client.send_frame(self.window)
|
|
||||||
}
|
|
||||||
|
|
||||||
theme_render := fn(self: Self): void {
|
|
||||||
window_width := 800
|
|
||||||
window_height := 400
|
|
||||||
line_end := 20
|
|
||||||
if self.line_lines {
|
|
||||||
line := 1
|
|
||||||
loop {
|
|
||||||
defer line += 1
|
|
||||||
if line == line_end break
|
|
||||||
self.window.surface.put_hline(20 * line, 10, window_width - self.theme.padding, self.theme.bg_line_color)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if self.theme.padding_line {
|
|
||||||
self.window.surface.put_vline(10, 20, 20 * line_end - 20, self.theme.fg_padding_line_color)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
frame_render := fn(self: Self): void {
|
|
||||||
// TODO: Render text here with a loop to iterate through Ropes.
|
|
||||||
|
|
||||||
if self.line_lines self.theme_render()
|
|
||||||
}
|
|
||||||
|
|
||||||
handle_input := fn(self: Self): void {
|
|
||||||
// input := memory.inb(96)
|
|
||||||
}
|
|
||||||
|
|
||||||
map_keys := fn(scancode: u8): u8 {
|
|
||||||
// if is_shift_pressed {
|
|
||||||
// return ps2_table[scancode + 0x40]
|
|
||||||
// }
|
|
||||||
return ps2_table[scancode]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ps2_table := u8.[0x0, 0x1B, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x2D, 0x3D, 0x8, 0x9, 0x71, 0x77, 0x65, 0x72, 0x74, 0x79, 0x75, 0x69, 0x6F, 0x70, 0x5B, 0x5D, 0xA, 0x0, 0x61, 0x73, 0x64, 0x66, 0x67, 0x68, 0x6A, 0x6B, 0x6C, 0x3B, 0x27, 0x60, 0x0, 0x5C, 0x7A, 0x78, 0x63, 0x76, 0x62, 0x6E, 0x6D, 0x2C, 0x2E, 0x2F, 0x0, 0x2A, 0x0, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1B, 0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0x28, 0x29, 0x5F, 0x2B, 0x8, 0x9, 0x51, 0x57, 0x45, 0x52, 0x54, 0x59, 0x55, 0x49, 0x4F, 0x50, 0x7B, 0x7D, 0xA, 0x0, 0x41, 0x53, 0x44, 0x46, 0x47, 0x48, 0x4A, 0x4B, 0x4C, 0x3A, 0x22, 0x7E, 0x0, 0x7C, 0x5A, 0x58, 0x43, 0x56, 0x42, 0x4E, 0x4D, 0x3C, 0x3E, 0x3F, 0x0, 0x0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
|
@ -1,68 +0,0 @@
|
||||||
/*!! expected result: pretty decent notepad app
|
|
||||||
-----------------
|
|
||||||
features:
|
|
||||||
- basic keys
|
|
||||||
- holding support with DAS
|
|
||||||
- visible cursor
|
|
||||||
- l+r arrow key support
|
|
||||||
- proper insertion and deletion
|
|
||||||
- shift key support
|
|
||||||
*/
|
|
||||||
stn := @use("stn");
|
|
||||||
.{memory, log, string, math} := stn;
|
|
||||||
.{Vec2, clamp} := math
|
|
||||||
|
|
||||||
sunset := @use("lib:sunset_proto")
|
|
||||||
render := @use("lib:render")
|
|
||||||
horizon_api := @use("lib:horizon_api");
|
|
||||||
.{set_color, render_label_to_surface, Label} := horizon_api.widgets.label
|
|
||||||
|
|
||||||
rope := @use("rope.hb")
|
|
||||||
theme := @use("theme.hb");
|
|
||||||
.{Theme} := theme
|
|
||||||
|
|
||||||
psf := @embed("sysdata:assets/consolefonts/tamsyn/10x20r.psf")
|
|
||||||
img := @embed("sysdata:assets/wallpaper.qoi");
|
|
||||||
.{Editor} := @use("editor.hb")
|
|
||||||
|
|
||||||
main := fn(): void {
|
|
||||||
window_width := 800
|
|
||||||
window_height := 400
|
|
||||||
|
|
||||||
editor := Editor.new()
|
|
||||||
|
|
||||||
font := render.text.font_from_psf2(@bitcast(&psf), false)
|
|
||||||
if font == null {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
text_1_label := Label.new_label("main := fn() : void {", window_width - editor.theme.padding)
|
|
||||||
text_2_label := Label.new_label(" log.error(\"print!\")", window_width - editor.theme.padding)
|
|
||||||
text_3_label := Label.new_label("}", window_width)
|
|
||||||
text_1_label.set_color(editor.theme.bg_color, editor.theme.fg_text_color)
|
|
||||||
text_2_label.set_color(editor.theme.bg_color, editor.theme.fg_text_color)
|
|
||||||
text_3_label.set_color(editor.theme.bg_color, editor.theme.fg_text_color)
|
|
||||||
pos_1 := Vec2(uint).(10, 1)
|
|
||||||
pos_2 := Vec2(uint).(10, 1 + 20)
|
|
||||||
pos_3 := Vec2(uint).(10, 1 + 40)
|
|
||||||
|
|
||||||
line_end := 20
|
|
||||||
editor.window.surface.clear(editor.theme.bg_color)
|
|
||||||
|
|
||||||
render_label_to_surface(editor.window.surface, text_1_label, font, pos_1)
|
|
||||||
render_label_to_surface(editor.window.surface, text_2_label, font, pos_2)
|
|
||||||
render_label_to_surface(editor.window.surface, text_3_label, font, pos_3)
|
|
||||||
|
|
||||||
loop {
|
|
||||||
// +++ Clear +++
|
|
||||||
// editor.clear()
|
|
||||||
|
|
||||||
// +++ Input +++
|
|
||||||
editor.handle_input()
|
|
||||||
|
|
||||||
// +++ RENDER +++
|
|
||||||
editor.frame_render()
|
|
||||||
// if editor.line_lines editor.theme_render()
|
|
||||||
editor.frame_sync()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,243 +0,0 @@
|
||||||
.{memory, log, string, math} := @use("stn")
|
|
||||||
render := @use("lib:render")
|
|
||||||
|
|
||||||
/* expected result: pretty decent notepad app
|
|
||||||
slightly jank
|
|
||||||
-----------------
|
|
||||||
features:
|
|
||||||
- basic keys
|
|
||||||
- holding support with DAS
|
|
||||||
- visible cursor
|
|
||||||
- l+r arrow key support
|
|
||||||
- proper insertion and deletion
|
|
||||||
- shift key support
|
|
||||||
*/
|
|
||||||
|
|
||||||
psf := @embed("sysdata:assets/consolefonts/tamsyn/10x20r.psf")
|
|
||||||
img := @embed("sysdata:assets/wallpaper.qoi")
|
|
||||||
|
|
||||||
is_shift_pressed := false
|
|
||||||
is_ctrl_pressed := false
|
|
||||||
is_extended := false
|
|
||||||
$initial_delay := 50
|
|
||||||
$repeat_delay := 7
|
|
||||||
$left_arrow := 0x4B
|
|
||||||
$right_arrow := 0x4D
|
|
||||||
$up_arrow := 0x48
|
|
||||||
$down_arrow := 0x50
|
|
||||||
|
|
||||||
example := fn(): void {
|
|
||||||
screen := render.init(true)
|
|
||||||
window := render.Surface.new(600, 300)
|
|
||||||
font := render.text.font_from_psf2(@bitcast(&psf), false)
|
|
||||||
wallpaper := render.image.from(@bitcast(&img))
|
|
||||||
|
|
||||||
if font == null {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if wallpaper == null {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
msg := "sticky note:\n"
|
|
||||||
msg_len := string.length(msg)
|
|
||||||
|
|
||||||
buf := memory.alloc(u8, 4096)
|
|
||||||
|
|
||||||
bottom := buf + msg_len
|
|
||||||
|
|
||||||
memory.copy(u8, msg, buf, msg_len)
|
|
||||||
cursor := bottom
|
|
||||||
|
|
||||||
draw_window(window, font, buf, cursor)
|
|
||||||
draw_screen(screen, window, wallpaper)
|
|
||||||
|
|
||||||
memory.outb(96, 238)
|
|
||||||
memory.outb(96, 238)
|
|
||||||
memory.outb(96, 244)
|
|
||||||
|
|
||||||
prev_input := @as(u8, 0xFF)
|
|
||||||
current_key := @as(u8, 0)
|
|
||||||
holding_timer := 0
|
|
||||||
|
|
||||||
loop {
|
|
||||||
input := memory.inb(96)
|
|
||||||
if input != prev_input {
|
|
||||||
if input == 0xE0 {
|
|
||||||
is_extended = true
|
|
||||||
} else {
|
|
||||||
if (input & 0x80) != 0 {
|
|
||||||
if (input & 0x7F) == current_key {
|
|
||||||
current_key = 0
|
|
||||||
holding_timer = 0
|
|
||||||
} else if input == 0xAA | input == 0xB6 {
|
|
||||||
is_shift_pressed = false
|
|
||||||
} else if input == 0x9D {
|
|
||||||
is_ctrl_pressed = false
|
|
||||||
}
|
|
||||||
is_extended = false
|
|
||||||
} else {
|
|
||||||
if is_extended {
|
|
||||||
current_key = input
|
|
||||||
holding_timer = 1
|
|
||||||
cursor = handle_extended_key(input, cursor, bottom, font)
|
|
||||||
} else {
|
|
||||||
if input == 0x2A | input == 0x36 {
|
|
||||||
is_shift_pressed = true
|
|
||||||
} else if input == 0x1D {
|
|
||||||
is_ctrl_pressed = true
|
|
||||||
} else {
|
|
||||||
current_key = input
|
|
||||||
holding_timer = 1
|
|
||||||
cursor = handle_char(map_keys(current_key), cursor, bottom)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
prev_input = input
|
|
||||||
}
|
|
||||||
|
|
||||||
if current_key != 0 & holding_timer > 0 {
|
|
||||||
holding_timer += 1
|
|
||||||
|
|
||||||
if holding_timer >= initial_delay {
|
|
||||||
if is_extended {
|
|
||||||
cursor = handle_extended_key(current_key, cursor, bottom, font)
|
|
||||||
} else {
|
|
||||||
cursor = handle_char(map_keys(current_key), cursor, bottom)
|
|
||||||
}
|
|
||||||
holding_timer = initial_delay - repeat_delay
|
|
||||||
}
|
|
||||||
}
|
|
||||||
draw_window(window, font, buf, cursor)
|
|
||||||
draw_screen(screen, window, wallpaper)
|
|
||||||
|
|
||||||
if holding_timer > 0 & current_key != 0 {
|
|
||||||
if (memory.inb(96) & 0x80) != 0 {
|
|
||||||
current_key = 0
|
|
||||||
holding_timer = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handle_extended_key := fn(scancode: u8, cursor: ^u8, bottom: ^u8, font: render.text.Font): ^u8 {
|
|
||||||
if scancode == left_arrow {
|
|
||||||
if cursor > bottom {
|
|
||||||
return cursor - 1
|
|
||||||
}
|
|
||||||
} else if scancode == right_arrow {
|
|
||||||
if *cursor != 0 {
|
|
||||||
return cursor + 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return cursor
|
|
||||||
}
|
|
||||||
|
|
||||||
padding := 3 * @sizeof(render.Color)
|
|
||||||
|
|
||||||
draw_window := fn(window: render.Surface, font: render.text.Font, buf: ^u8, cursor: ^u8): void {
|
|
||||||
window.clear(.(0x88, 0xF4, 0xFC, 0x0))
|
|
||||||
line := font.height + padding - 1
|
|
||||||
window.put_rect(.(0, 0), .(window.width - 1, window.height - 1), render.BLACK)
|
|
||||||
|
|
||||||
loop if line >= window.height break else {
|
|
||||||
window.put_hline(line, padding, window.width - padding, render.YELLOW)
|
|
||||||
line += font.height
|
|
||||||
}
|
|
||||||
|
|
||||||
window.put_text(font, .(padding, padding), render.BLACK, buf)
|
|
||||||
|
|
||||||
cursor_offset := cursor - buf
|
|
||||||
|
|
||||||
y_pos := padding
|
|
||||||
x_pos := padding
|
|
||||||
i := 0
|
|
||||||
|
|
||||||
loop if i >= cursor_offset break else {
|
|
||||||
if *(buf + i) == 10 {
|
|
||||||
y_pos += font.height + font.line_gap
|
|
||||||
x_pos = padding
|
|
||||||
} else {
|
|
||||||
if x_pos + font.width >= window.width - padding {
|
|
||||||
y_pos += font.height + font.line_gap
|
|
||||||
x_pos = padding - font.width
|
|
||||||
}
|
|
||||||
x_pos += font.width
|
|
||||||
}
|
|
||||||
i += 1
|
|
||||||
}
|
|
||||||
|
|
||||||
window.put_rect(.(x_pos, y_pos), .(1, font.height - 1), render.BLACK)
|
|
||||||
}
|
|
||||||
|
|
||||||
draw_screen := fn(screen: render.Surface, window: render.Surface, wallpaper: render.Surface): void {
|
|
||||||
screen.put_surface(wallpaper, .(0, 0), false)
|
|
||||||
screen.put_surface(window, .(100, 100), false)
|
|
||||||
screen.sync()
|
|
||||||
}
|
|
||||||
|
|
||||||
handle_char := fn(char: u8, cursor: ^u8, bottom: ^u8): ^u8 {
|
|
||||||
if char == 0 {
|
|
||||||
return cursor
|
|
||||||
}
|
|
||||||
|
|
||||||
if is_ctrl_pressed & char == 48 {
|
|
||||||
cursor = bottom
|
|
||||||
} else if char != 0x8 {
|
|
||||||
end := cursor
|
|
||||||
loop if *end == 0 break else {
|
|
||||||
end += 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if cursor < end {
|
|
||||||
src := end
|
|
||||||
dst := end + 1
|
|
||||||
loop if src < cursor break else {
|
|
||||||
*dst = *src
|
|
||||||
dst -= 1
|
|
||||||
src -= 1
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
*cursor = char
|
|
||||||
return cursor + 1
|
|
||||||
} else if char == 0xA {
|
|
||||||
*cursor = 32
|
|
||||||
cursor += 1;
|
|
||||||
*cursor = 92
|
|
||||||
return cursor + 1
|
|
||||||
} else if cursor > bottom {
|
|
||||||
if cursor == bottom {
|
|
||||||
return cursor
|
|
||||||
}
|
|
||||||
|
|
||||||
end := cursor
|
|
||||||
loop if *end == 0 break else {
|
|
||||||
end += 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if cursor < end {
|
|
||||||
src := cursor
|
|
||||||
dst := cursor - 1
|
|
||||||
loop if src > end break else {
|
|
||||||
*dst = *src
|
|
||||||
dst += 1
|
|
||||||
src += 1
|
|
||||||
}
|
|
||||||
return cursor - 1
|
|
||||||
} else {
|
|
||||||
cursor -= 1;
|
|
||||||
*cursor = 32
|
|
||||||
return cursor
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return cursor
|
|
||||||
}
|
|
||||||
map_keys := fn(scancode: u8): u8 {
|
|
||||||
if is_shift_pressed {
|
|
||||||
return ps2_table[scancode + 0x40]
|
|
||||||
}
|
|
||||||
return ps2_table[scancode]
|
|
||||||
}
|
|
||||||
ps2_table := u8.[0x0, 0x1B, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x2D, 0x3D, 0x8, 0x9, 0x71, 0x77, 0x65, 0x72, 0x74, 0x79, 0x75, 0x69, 0x6F, 0x70, 0x5B, 0x5D, 0xA, 0x0, 0x61, 0x73, 0x64, 0x66, 0x67, 0x68, 0x6A, 0x6B, 0x6C, 0x3B, 0x27, 0x60, 0x0, 0x5C, 0x7A, 0x78, 0x63, 0x76, 0x62, 0x6E, 0x6D, 0x2C, 0x2E, 0x2F, 0x0, 0x2A, 0x0, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1B, 0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0x28, 0x29, 0x5F, 0x2B, 0x8, 0x9, 0x51, 0x57, 0x45, 0x52, 0x54, 0x59, 0x55, 0x49, 0x4F, 0x50, 0x7B, 0x7D, 0xA, 0x0, 0x41, 0x53, 0x44, 0x46, 0x47, 0x48, 0x4A, 0x4B, 0x4C, 0x3A, 0x22, 0x7E, 0x0, 0x7C, 0x5A, 0x58, 0x43, 0x56, 0x42, 0x4E, 0x4D, 0x3C, 0x3E, 0x3F, 0x0, 0x0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
|
@ -1,36 +0,0 @@
|
||||||
/*! A Rope is a very special data structure
|
|
||||||
that can quickly append split and represent a single editors line worth of text.
|
|
||||||
|
|
||||||
Inspo:
|
|
||||||
- https://github.com/kavirajk/rope
|
|
||||||
*/
|
|
||||||
|
|
||||||
Node := struct {
|
|
||||||
weight: uint,
|
|
||||||
left: ?^Leaf,
|
|
||||||
right: ?^Leaf,
|
|
||||||
}
|
|
||||||
|
|
||||||
Leaf := struct {
|
|
||||||
buf: []u8,
|
|
||||||
start: uint,
|
|
||||||
end: uint,
|
|
||||||
|
|
||||||
new := fn(str: []u8): Self {
|
|
||||||
return Self.(str, 0, str.len)
|
|
||||||
}
|
|
||||||
|
|
||||||
weight := fn(self: Self): uint {
|
|
||||||
return self.end - self.start + 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Rope := struct {
|
|
||||||
node: ?^Node,
|
|
||||||
leaf: ?^Leaf,
|
|
||||||
|
|
||||||
new := fn(str: []u8): Self {
|
|
||||||
leaf := Leaf.new(str)
|
|
||||||
return Self.(null, &leaf)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
render := @use("lib:render")
|
|
||||||
|
|
||||||
Theme := struct {
|
|
||||||
bg_color: render.Color = render.Color.(0x88, 0xF4, 0xFC, 0x0),
|
|
||||||
bg_line_color: render.Color = render.YELLOW,
|
|
||||||
fg_text_color: render.Color = render.BLACK,
|
|
||||||
fg_padding_line_color: render.Color = render.RED,
|
|
||||||
padding: uint = 10,
|
|
||||||
padding_line: bool = true,
|
|
||||||
|
|
||||||
new := fn(): Self {
|
|
||||||
return Self.(.(0x88, 0xF4, 0xFC, 0x0), render.YELLOW, render.BLACK, render.RED, 10, true)
|
|
||||||
}
|
|
||||||
}
|
|
1
sysdata/programs/alloc_test/README.md
Normal file
1
sysdata/programs/alloc_test/README.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# alloc_test
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "adit"
|
name = "alloc_test"
|
||||||
authors = [""]
|
authors = [""]
|
||||||
|
|
||||||
[dependants.libraries]
|
[dependants.libraries]
|
30
sysdata/programs/alloc_test/src/main.hb
Normal file
30
sysdata/programs/alloc_test/src/main.hb
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
stn := @use("../../../libraries/stn/src/lib.hb");
|
||||||
|
.{allocators, panic, log} := stn
|
||||||
|
|
||||||
|
AStruct := struct {
|
||||||
|
a_field: u8,
|
||||||
|
}
|
||||||
|
|
||||||
|
main := fn(): void {
|
||||||
|
// alloc := allocators.FakeAlloc.init()
|
||||||
|
// astruct := alloc.alloc(AStruct, 2)
|
||||||
|
// if astruct.ptr != null{
|
||||||
|
// panic.panic("FakeAlloc actually allocated.")
|
||||||
|
// }
|
||||||
|
// alloc.dealloc(&astruct.ptr, AStruct, 2)
|
||||||
|
// alloc.deinit()
|
||||||
|
|
||||||
|
balloc := allocators.BlockAlloc.init()
|
||||||
|
// defer {
|
||||||
|
// balloc.deinit()
|
||||||
|
// }
|
||||||
|
bstruct := balloc.alloc(AStruct, 2)
|
||||||
|
// if bstruct.ptr == null {
|
||||||
|
// log.info("Hi\0")
|
||||||
|
// // panic.panic("BlockAlloc actually didn't allocate.")
|
||||||
|
// } else {
|
||||||
|
// log.info("Allocator functioned.\0")
|
||||||
|
// }
|
||||||
|
// balloc.dealloc(bstruct_ptr, AStruct, 2)
|
||||||
|
return
|
||||||
|
}
|
|
@ -1,5 +0,0 @@
|
||||||
# angels_halo
|
|
||||||
|
|
||||||
A Minix 3 style reincarnation service.
|
|
||||||
|
|
||||||
Running in the background restarting your drivers.
|
|
|
@ -1,7 +0,0 @@
|
||||||
(pkg angels-halo
|
|
||||||
(authors ("able"))
|
|
||||||
(version 0 1 0))
|
|
||||||
|
|
||||||
(dependencies
|
|
||||||
(libraries ())
|
|
||||||
(programs (hblang)))
|
|
|
@ -1,18 +0,0 @@
|
||||||
stn := @use("stn");
|
|
||||||
.{log} := stn;
|
|
||||||
.{ProcessID} := stn.acs
|
|
||||||
|
|
||||||
Strategy := enum {
|
|
||||||
None,
|
|
||||||
Restart,
|
|
||||||
}
|
|
||||||
|
|
||||||
MonitoredProcess := struct {
|
|
||||||
pid: ProcessID,
|
|
||||||
}
|
|
||||||
|
|
||||||
main := fn(): int {
|
|
||||||
log.info("Angels Halo reincarnation server started.")
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
|
@ -1,111 +1,13 @@
|
||||||
.{memory: .{inb, outb, ins, alloc}, log} := @use("stn")
|
.{memory, buffer} := @use("../../../libraries/stn/src/lib.hb")
|
||||||
|
|
||||||
$ATA_PRIMARY_DATA := 0x1F0
|
main := fn(): int {
|
||||||
$ATA_PRIMARY_ERR := 0x1F1
|
// shuts down ableOS
|
||||||
$ATA_PRIMARY_SECCOUNT := 0x1F2
|
// memory.outb(0xF400, 0)
|
||||||
$ATA_PRIMARY_LBA_LO := 0x1F3
|
|
||||||
$ATA_PRIMARY_LBA_MID := 0x1F4
|
|
||||||
$ATA_PRIMARY_LBA_HI := 0x1F5
|
|
||||||
$ATA_PRIMARY_DRIVE_HEAD := 0x1F6
|
|
||||||
$ATA_PRIMARY_COMM_REGSTAT := 0x1F7
|
|
||||||
$ATA_PRIMARY_ALTSTAT_DCR := 0x3F6
|
|
||||||
|
|
||||||
$STAT_ERR := 1 << 0
|
a := memory.inb(0x4600)
|
||||||
$STAT_DRQ := 1 << 3
|
b := memory.inb(0x4700)
|
||||||
$STAT_SRV := 1 << 4
|
|
||||||
$STAT_DF := 1 << 5
|
|
||||||
$STAT_RDY := 1 << 6
|
|
||||||
$STAT_BSY := 1 << 7
|
|
||||||
|
|
||||||
Drive := enum {Master, Slave}
|
c := buffer.search("XNumber\0")
|
||||||
|
|
||||||
select_drive := fn(drive: Drive): void {
|
|
||||||
match drive {
|
|
||||||
.Master => outb(ATA_PRIMARY_DRIVE_HEAD, 0xA0),
|
|
||||||
.Slave => outb(ATA_PRIMARY_DRIVE_HEAD, 0xB0),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
identify := fn(drive: Drive): u8 {
|
|
||||||
if inb(ATA_PRIMARY_COMM_REGSTAT) == 0xFF {
|
|
||||||
log.error("(ata: drive not present) status=0xFF")
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
select_drive(drive)
|
|
||||||
inb(ATA_PRIMARY_COMM_REGSTAT)
|
|
||||||
outb(ATA_PRIMARY_SECCOUNT, 0)
|
|
||||||
inb(ATA_PRIMARY_COMM_REGSTAT)
|
|
||||||
outb(ATA_PRIMARY_LBA_LO, 0)
|
|
||||||
inb(ATA_PRIMARY_COMM_REGSTAT)
|
|
||||||
outb(ATA_PRIMARY_LBA_MID, 0)
|
|
||||||
inb(ATA_PRIMARY_COMM_REGSTAT)
|
|
||||||
outb(ATA_PRIMARY_LBA_HI, 0)
|
|
||||||
inb(ATA_PRIMARY_COMM_REGSTAT)
|
|
||||||
outb(ATA_PRIMARY_COMM_REGSTAT, 0xEC)
|
|
||||||
outb(ATA_PRIMARY_COMM_REGSTAT, 0xE7)
|
|
||||||
|
|
||||||
status := inb(ATA_PRIMARY_COMM_REGSTAT)
|
|
||||||
|
|
||||||
loop if (status & STAT_BSY) == 0 break else {
|
|
||||||
if DEBUG_PRINT log.printf("(ata: waiting for status) status={}", .(status), .{radix: 16, log: .Warn})
|
|
||||||
status = inb(ATA_PRIMARY_COMM_REGSTAT)
|
|
||||||
}
|
|
||||||
|
|
||||||
if status == 0 {
|
|
||||||
log.error("(ata: drive not present) status=0")
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
loop if (status & STAT_BSY) == 0 break else {
|
|
||||||
if DEBUG_PRINT log.printf("(ata: waiting for busy to end) status={}", .(status), .{radix: 16, log: .Warn})
|
|
||||||
status = inb(ATA_PRIMARY_COMM_REGSTAT)
|
|
||||||
}
|
|
||||||
|
|
||||||
mid := inb(ATA_PRIMARY_LBA_MID)
|
|
||||||
hi := inb(ATA_PRIMARY_LBA_HI)
|
|
||||||
if (mid | hi) != 0 {
|
|
||||||
log.error("the drive is not ata...?")
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
loop if (status & (STAT_ERR | STAT_DRQ)) != 0 break else {
|
|
||||||
if DEBUG_PRINT log.printf("(ata: waiting for ERR or DRQ) status={}", .(status), .{radix: 16, log: .Warn})
|
|
||||||
status = inb(ATA_PRIMARY_COMM_REGSTAT)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status & STAT_ERR) != 0 {
|
|
||||||
if DEBUG_PRINT log.printf("(ata: drive error) status={}", .(status), .{radix: 16, log: .Error})
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
if DEBUG_PRINT log.printf("status={}", .(status), .{radix: 16})
|
|
||||||
|
|
||||||
buffer := alloc(u16, 255)[0..255]
|
|
||||||
read(buffer)
|
|
||||||
|
|
||||||
if DEBUG_PRINT {
|
|
||||||
if (buffer[83] & 1 << 10) != 0 {
|
|
||||||
log.info("LBA48 mode supported")
|
|
||||||
log.printf("{} 48 bit addressable sectors", *@as(^uint, @bitcast(buffer[100..].ptr)), .{})
|
|
||||||
}
|
|
||||||
log.print(buffer, .{})
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
read := fn(buffer: []u16): void {
|
|
||||||
i := 0
|
|
||||||
loop if i == buffer.len break else {
|
|
||||||
buffer[i] = ins(ATA_PRIMARY_DATA)
|
|
||||||
i += 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// inflates asm a lot
|
|
||||||
$DEBUG_PRINT := true
|
|
||||||
|
|
||||||
main := fn(): void {
|
|
||||||
identify(.Master)
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
// $ATA_PRIMARY_DATA := @intcast(0x1F0)
|
|
||||||
// $ATA_PRIMARY_ERR := @intcast(0x1F1)
|
|
||||||
// $ATA_PRIMARY_SECCOUNT := @intcast(0x1F2)
|
|
||||||
// $ATA_PRIMARY_LBA_LO := @intcast(0x1F3)
|
|
||||||
// $ATA_PRIMARY_LBA_MID := @intcast(0x1F4)
|
|
||||||
// $ATA_PRIMARY_LBA_HI := @intcast(0x1F5)
|
|
||||||
// $ATA_PRIMARY_DRIVE_HEAD := @intcast(0x1F6)
|
|
||||||
// $ATA_PRIMARY_COMM_REGSTAT := @intcast(0x1F7)
|
|
||||||
// $ATA_PRIMARY_ALTSTAT_DCR := @intcast(0x3F6)
|
|
||||||
|
|
||||||
$ATA_PRIMARY_IO := @intcast(0x1F0)
|
|
||||||
|
|
||||||
$ATA_PRIMARY_DEVCTL := @intcast(0x3F6)
|
|
||||||
$ATA_SECONDARY_DEVCTL := @intcast(0x3F6)
|
|
||||||
|
|
||||||
$ATA_REG_STAT := @intcast(0x7)
|
|
||||||
|
|
||||||
// // Indicates an error occurred. Send a new command to clear it
|
|
||||||
// STAT_ERR := 1 << 0
|
|
||||||
// // Set when the drive has PIO data to transfer, or is ready to accept PIO data.
|
|
||||||
// STAT_DRQ := 1 << 3
|
|
||||||
// // Overlapped Mode Service Request.
|
|
||||||
// STAT_SRV := 1 << 4
|
|
||||||
// // Drive Fault Error (does not set ERR).
|
|
||||||
// STAT_DF := 1 << 5
|
|
||||||
// // Bit is clear when drive is spun down, or after an error. Set otherwise.
|
|
||||||
// STAT_RDY := 1 << 6
|
|
||||||
// // Indicates the drive is preparing to send/receive data (wait for it to clear).
|
|
||||||
// // In case of 'hang' (it never clears), do a software reset.
|
|
||||||
// STAT_BSY := 1 << 7
|
|
||||||
|
|
||||||
$ATA_SR_BSY := 0x80
|
|
||||||
$ATA_SR_DF := 0x20
|
|
||||||
$ATA_SR_DRQ := 0x8
|
|
||||||
$ATA_SR_ERR := 0x1
|
|
1
sysdata/programs/dt_buffer_test/README.md
Normal file
1
sysdata/programs/dt_buffer_test/README.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# dt_buffer_test
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "angels_halo"
|
name = "dt_buffer_test"
|
||||||
authors = ["able"]
|
authors = ["able"]
|
||||||
|
|
||||||
[dependants.libraries]
|
[dependants.libraries]
|
13
sysdata/programs/dt_buffer_test/src/main.hb
Normal file
13
sysdata/programs/dt_buffer_test/src/main.hb
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
.{dt} := @use("../../../libraries/stn/src/lib.hb")
|
||||||
|
|
||||||
|
main := fn(): void {
|
||||||
|
dt.get(void, "framebuffer/fb0/width\0")
|
||||||
|
dt.get(void, "cpu/cpu0/architecture\0")
|
||||||
|
|
||||||
|
// Checking if the first detected serial port is memory mapped or port mapped
|
||||||
|
// 0 -> memory mapped
|
||||||
|
// 1 -> port mapped
|
||||||
|
dt.get(void, "serial_ports/sp0/mapping\0")
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
$READ_ONLY := 0x1
|
READ_ONLY := @as(u32, 0x1)
|
||||||
$HIDDEN := 0x2
|
HIDDEN := @as(u32, 0x2)
|
||||||
$SYSTEM := 0x4
|
SYSTEM := @as(u32, 0x4)
|
||||||
$VOLUME_ID := 0x8
|
VOLUME_ID := @as(u32, 0x8)
|
||||||
$DIRECTORY: 0x10
|
DIRECTORY := @as(u32, 0x10)
|
||||||
$ARCHIVE := 0x20
|
ARCHIVE := @as(u32, 0x20)
|
||||||
LFN := READ_ONLY | HIDDEN | SYSTEM | VOLUME_ID
|
LFN := READ_ONLY | HIDDEN | SYSTEM | VOLUME_ID
|
|
@ -1,19 +1,19 @@
|
||||||
stn := @use("stn");
|
stn := @use("../../../libraries/stn/src/lib.hb");
|
||||||
.{string, memory, buffer, log} := stn
|
.{string, memory, buffer, log} := stn
|
||||||
|
|
||||||
VALID_JUMP_BYTES := u8.[0xEB, 0x3C, 0x90]
|
VALID_JUMP_BYTES := [u8].(0xEB, 0x3C, 0x90)
|
||||||
|
|
||||||
OemIdent := struct {
|
OemIdent := struct {
|
||||||
dos_version: [8]u8,
|
dos_version: [u8; 8],
|
||||||
dos_version_name: [8]u8,
|
dos_version_name: [u8; 8],
|
||||||
|
|
||||||
new := fn(major: int, minor: int): OemIdent {
|
|
||||||
return .(.[0, 0, 0, 0, 0, 0, 0, 0], .[0, 0, 0, 0, 0, 0, 0, 0])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new_oem_ident := fn(major: int, minor: int): OemIdent {
|
||||||
|
return .(.(0, 0, 0, 0, 0, 0, 0, 0), .(0, 0, 0, 0, 0, 0, 0, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
BiosParameterBlock := struct {
|
BiosParameterBlock := struct {
|
||||||
jump_bytes: [3]u8,
|
jump_bytes: [u8; 3],
|
||||||
oem_ident: OemIdent,
|
oem_ident: OemIdent,
|
||||||
bytes_per_sector: u16,
|
bytes_per_sector: u16,
|
||||||
sectors_per_cluster: u8,
|
sectors_per_cluster: u8,
|
||||||
|
@ -30,13 +30,14 @@ BiosParameterBlock := struct {
|
||||||
head_count: u16,
|
head_count: u16,
|
||||||
hidden_sectors: u32,
|
hidden_sectors: u32,
|
||||||
large_sector_count: u32,
|
large_sector_count: u32,
|
||||||
|
}
|
||||||
|
|
||||||
sanity_check := fn(bpb: BiosParameterBlock): int {
|
bpb_sanity_check := fn(bpb: BiosParameterBlock): int {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
new := fn(): BiosParameterBlock {
|
new_bpb := fn(): BiosParameterBlock {
|
||||||
return .(VALID_JUMP_BYTES, OemIdent.new(0, 0), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
return .(VALID_JUMP_BYTES, new_oem_ident(0, 0), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
sector_count := fn(bpb: BiosParameterBlock): u32 {
|
sector_count := fn(bpb: BiosParameterBlock): u32 {
|
||||||
|
@ -46,23 +47,22 @@ BiosParameterBlock := struct {
|
||||||
return bpb.total_sectors
|
return bpb.total_sectors
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
FatVersionNumber := struct {
|
FatVersionNumber := struct {
|
||||||
major_version: u8,
|
major_version: u8,
|
||||||
minor_version: u8,
|
minor_version: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
FormatReservation := [12]u8
|
FormatReservation := [u8; 12]
|
||||||
|
|
||||||
// Padded with spaces.
|
// Padded with spaces.
|
||||||
VolumeName := [11]u8
|
VolumeName := [u8; 11]
|
||||||
|
|
||||||
SystemIdentifierString := [8]u8
|
SystemIdentifierString := [u8; 8]
|
||||||
VALID_SYSTEM_IDENTIFIER_STRING := u8.[46, 41, 54, 33, 32, 20, 20, 20]
|
VALID_SYSTEM_IDENTIFIER_STRING := [u8].(46, 41, 54, 33, 32, 20, 20, 20)
|
||||||
BOOTABLE_PARTITION_SIGNATURE := @as(u32, 0xAA55)
|
BOOTABLE_PARTITION_SIGNATURE := @as(u32, 0xAA55)
|
||||||
|
|
||||||
BootCode := [420]u8
|
BootCode := [u8; 420]
|
||||||
|
|
||||||
ExtendedBootRecord := struct {
|
ExtendedBootRecord := struct {
|
||||||
sectors_per_fat: u32,
|
sectors_per_fat: u32,
|
||||||
|
@ -85,29 +85,30 @@ ExtendedBootRecord := struct {
|
||||||
system_identifier_string: SystemIdentifierString,
|
system_identifier_string: SystemIdentifierString,
|
||||||
boot_code: BootCode,
|
boot_code: BootCode,
|
||||||
partition_signature: u16,
|
partition_signature: u16,
|
||||||
|
}
|
||||||
|
|
||||||
sanity_check := fn(ebr: ExtendedBootRecord): int {
|
ebr_sanity_check := fn(ebr: ExtendedBootRecord): int {
|
||||||
ret := 0
|
ret := 0
|
||||||
if ebr.drive_number != 0x0 | ebr.drive_number != 0x80 {
|
if ebr.drive_number != 0x0 | ebr.drive_number != 0x80 {
|
||||||
log.warn("EBR-Drive-Number sanity check failed")
|
log.warn("EBR-Drive-Number sanity check failed\0")
|
||||||
}
|
}
|
||||||
|
|
||||||
if ebr.signature != 0x28 | ebr.signature != 0x29 {
|
if ebr.signature != 0x28 | ebr.signature != 0x29 {
|
||||||
log.warn("EBR-Signature sanity check failed")
|
log.warn("EBR-Signature sanity check failed\0")
|
||||||
}
|
}
|
||||||
|
|
||||||
// ! comparison between [u8] is not supported in hblang
|
// ! comparison between [u8] is not supported in hblang
|
||||||
// if ebr.system_identifier_string != VALID_SYSTEM_IDENTIFIER_STRING {
|
// if ebr.system_identifier_string != VALID_SYSTEM_IDENTIFIER_STRING {
|
||||||
// log.warn("EBR-Signature-Identifier-String sanity check failed")
|
// log.warn("EBR-Signature-Identifier-String sanity check failed\0")
|
||||||
// }
|
// }
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
new := fn(): ExtendedBootRecord {
|
new_ebr := fn(): ExtendedBootRecord {
|
||||||
version := FatVersionNumber.(0, 0)
|
version := FatVersionNumber.(0, 0)
|
||||||
fmt_res := u8.[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
fmt_res := FormatReservation.(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||||
vol_name := @as([11]u8, idk)
|
vol_name := @as([u8; 11], idk)
|
||||||
boot_code := @as([420]u8, idk)
|
boot_code := @as([u8; 420], idk)
|
||||||
|
|
||||||
return ExtendedBootRecord.(
|
return ExtendedBootRecord.(
|
||||||
0,
|
0,
|
||||||
|
@ -127,7 +128,6 @@ ExtendedBootRecord := struct {
|
||||||
0,
|
0,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
VALID_LEAD_FS_INFO := @as(u32, 0x41615252)
|
VALID_LEAD_FS_INFO := @as(u32, 0x41615252)
|
||||||
VALID_TRAIL_FS_INFO := @as(u32, 0xAA550000)
|
VALID_TRAIL_FS_INFO := @as(u32, 0xAA550000)
|
||||||
|
@ -135,38 +135,39 @@ VALID_TRAIL_FS_INFO := @as(u32, 0xAA550000)
|
||||||
FSInfo := struct {
|
FSInfo := struct {
|
||||||
// Must be 0x41615252 to indicate a valid FSInfo structure
|
// Must be 0x41615252 to indicate a valid FSInfo structure
|
||||||
lead_signature: u32,
|
lead_signature: u32,
|
||||||
lead_reserved: [480]u8,
|
lead_reserved: [u8; 480],
|
||||||
// If the value is 0xFFFFFFFF, then the free count is unknown and must be computed. However, this value might be incorrect and should at least be range checked (<= volume cluster count)
|
// If the value is 0xFFFFFFFF, then the free count is unknown and must be computed. However, this value might be incorrect and should at least be range checked (<= volume cluster count)
|
||||||
last_known_free_cluster_count: u32,
|
last_known_free_cluster_count: u32,
|
||||||
last_known_avalible_cluster: u32,
|
last_known_avalible_cluster: u32,
|
||||||
trail_reserved: [12]u8,
|
trail_reserved: [u8; 12],
|
||||||
trail_signature: u32,
|
trail_signature: u32,
|
||||||
|
}
|
||||||
|
|
||||||
sanity_check := fn(fs_info: FSInfo): uint {
|
fs_info_sanity_check := fn(fs_info: FSInfo): uint {
|
||||||
ret := 0
|
ret := 0
|
||||||
if fs_info.lead_signature != VALID_LEAD_FS_INFO {
|
if fs_info.lead_signature != VALID_LEAD_FS_INFO {
|
||||||
ret &= 1
|
ret &= 1
|
||||||
log.warn("Invalid leading signature in FSInfo.")
|
log.warn("Invalid leading signature in FSInfo.\0")
|
||||||
}
|
}
|
||||||
if fs_info.last_known_free_cluster_count == 0xFFFFFFFF {
|
if fs_info.last_known_free_cluster_count == 0xFFFFFFFF {
|
||||||
ret &= 2
|
ret &= 2
|
||||||
log.warn("Last known free cluster count unknown.")
|
log.warn("Last known free cluster count unknown.\0")
|
||||||
}
|
}
|
||||||
if fs_info.last_known_avalible_cluster == 0xFFFFFFFF {
|
if fs_info.last_known_avalible_cluster == 0xFFFFFFFF {
|
||||||
ret &= 4
|
ret &= 4
|
||||||
log.warn("Last known avalible cluster count unknown.")
|
log.warn("Last known avalible cluster count unknown.\0")
|
||||||
}
|
}
|
||||||
if fs_info.trail_signature != VALID_TRAIL_FS_INFO {
|
if fs_info.trail_signature != VALID_TRAIL_FS_INFO {
|
||||||
ret &= 8
|
ret &= 8
|
||||||
log.warn("Invalid trailing signature in FSInfo.")
|
log.warn("Invalid trailing signature in FSInfo.\0")
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
new := fn(): FSInfo {
|
new_fs_info := fn(): FSInfo {
|
||||||
lead_reserved := @as([480]u8, idk)
|
lead_reserved := @as([u8; 480], idk)
|
||||||
trail_reserved := @as([12]u8, idk)
|
trail_reserved := @as([u8; 12], idk)
|
||||||
return FSInfo.(
|
return FSInfo.(
|
||||||
VALID_LEAD_FS_INFO,
|
VALID_LEAD_FS_INFO,
|
||||||
lead_reserved,
|
lead_reserved,
|
||||||
|
@ -176,4 +177,3 @@ FSInfo := struct {
|
||||||
VALID_TRAIL_FS_INFO,
|
VALID_TRAIL_FS_INFO,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
|
@ -2,6 +2,12 @@ Date := struct {
|
||||||
year: u16,
|
year: u16,
|
||||||
month: u16,
|
month: u16,
|
||||||
day: u16,
|
day: u16,
|
||||||
|
}
|
||||||
|
Time := struct {
|
||||||
|
hour: u16,
|
||||||
|
minutes: u16,
|
||||||
|
seconds: u16,
|
||||||
|
}
|
||||||
|
|
||||||
compress_date := fn(year: u16, month: u16, day: u16): u16 {
|
compress_date := fn(year: u16, month: u16, day: u16): u16 {
|
||||||
return 0
|
return 0
|
||||||
|
@ -9,12 +15,6 @@ Date := struct {
|
||||||
decompress_date := fn(date: u16): Date {
|
decompress_date := fn(date: u16): Date {
|
||||||
return Date.(0, 0, 0)
|
return Date.(0, 0, 0)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Time := struct {
|
|
||||||
hour: u16,
|
|
||||||
minutes: u16,
|
|
||||||
seconds: u16,
|
|
||||||
|
|
||||||
compress_time := fn(hour: u16, minutes: u16, seconds: u16): u16 {
|
compress_time := fn(hour: u16, minutes: u16, seconds: u16): u16 {
|
||||||
return 0
|
return 0
|
||||||
|
@ -23,4 +23,3 @@ Time := struct {
|
||||||
decompress_time := fn(time: u16): Time {
|
decompress_time := fn(time: u16): Time {
|
||||||
return Time.(0, 0, 0)
|
return Time.(0, 0, 0)
|
||||||
}
|
}
|
||||||
}
|
|
|
@ -1,7 +1,7 @@
|
||||||
attributes := @use("attributes.hb")
|
attributes := @use("attributes.hb")
|
||||||
datetime := @use("datetime.hb")
|
datetime := @use("datetime.hb")
|
||||||
|
|
||||||
FileName := [11]u8
|
FileName := [u8; 11]
|
||||||
|
|
||||||
// This is the File Allocation Table entry that tells us where on disk the File is.
|
// This is the File Allocation Table entry that tells us where on disk the File is.
|
||||||
FileEntry := struct {
|
FileEntry := struct {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
stn := @use("stn");
|
stn := @use("../../../libraries/stn/src/lib.hb");
|
||||||
.{string, memory, buffer, log} := stn
|
.{string, memory, buffer, log} := stn
|
||||||
|
|
||||||
attributes := @use("attributes.hb")
|
attributes := @use("attributes.hb")
|
||||||
|
@ -6,19 +6,19 @@ datetime := @use("datetime.hb")
|
||||||
directory := @use("file.hb")
|
directory := @use("file.hb")
|
||||||
bios_parameter_block := @use("bios_parameter_block.hb");
|
bios_parameter_block := @use("bios_parameter_block.hb");
|
||||||
.{bpb_sanity_check, ebr_sanity_check, fs_info_sanity_check} := bios_parameter_block;
|
.{bpb_sanity_check, ebr_sanity_check, fs_info_sanity_check} := bios_parameter_block;
|
||||||
.{BiosParameterBlock, ExtendedBootRecord, FSInfo} := bios_parameter_block
|
.{new_bpb, new_ebr, new_fs_info} := bios_parameter_block
|
||||||
|
|
||||||
$FAT12_THRESHOLD := 4085
|
FAT12_THRESHOLD := 4085
|
||||||
$FAT16_THRESHOLD := 65525
|
FAT16_THRESHOLD := 65525
|
||||||
|
|
||||||
$EXFAT := 0
|
ExFAT := 0
|
||||||
$FAT12 := 1
|
FAT12 := 1
|
||||||
$FAT16 := 2
|
FAT16 := 2
|
||||||
$FAT32 := 3
|
FAT32 := 3
|
||||||
|
|
||||||
calculate_fat_type := fn(sector_size: uint, total_clusters: uint): uint {
|
calculate_fat_type := fn(sector_size: uint, total_clusters: uint): uint {
|
||||||
if sector_size == 0 {
|
if sector_size == 0 {
|
||||||
return EXFAT
|
return ExFAT
|
||||||
} else if total_clusters < 4085 {
|
} else if total_clusters < 4085 {
|
||||||
return FAT12
|
return FAT12
|
||||||
} else if total_clusters < 65525 {
|
} else if total_clusters < 65525 {
|
||||||
|
@ -29,19 +29,19 @@ calculate_fat_type := fn(sector_size: uint, total_clusters: uint): uint {
|
||||||
}
|
}
|
||||||
|
|
||||||
main := fn(): int {
|
main := fn(): int {
|
||||||
bpb := BiosParameterBlock.new()
|
bpb := new_bpb()
|
||||||
ebr := ExtendedBootRecord.new()
|
ebr := new_ebr()
|
||||||
fsi := FSInfo.new()
|
fsi := new_fs_info()
|
||||||
|
|
||||||
fat_type := calculate_fat_type(1, 100)
|
fat_type := calculate_fat_type(1, 100)
|
||||||
|
|
||||||
if fat_type != FAT32 {
|
if fat_type != FAT32 {
|
||||||
log.warn("filesystem_fat32 driver only supports Fat32.")
|
log.warn("filesystem_fat32 driver only supports Fat32.\0")
|
||||||
}
|
}
|
||||||
|
|
||||||
bsc := bpb.sanity_check()
|
bsc := bpb_sanity_check(bpb)
|
||||||
esc := ebr.sanity_check()
|
esc := ebr_sanity_check(ebr)
|
||||||
fssc := fsi.sanity_check()
|
fssc := fs_info_sanity_check(fsi)
|
||||||
|
|
||||||
msg_type := 0
|
msg_type := 0
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ main := fn(): int {
|
||||||
// Open file
|
// Open file
|
||||||
if msg_type == 0 {
|
if msg_type == 0 {
|
||||||
// Paths without a node-disk component are to be treated as local files.
|
// Paths without a node-disk component are to be treated as local files.
|
||||||
file_path := "node-disk:/test"
|
file_path := "node-disk:/test\0"
|
||||||
} else {
|
} else {
|
||||||
// error
|
// error
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "hblang2"
|
name = "hash_test"
|
||||||
authors = [""]
|
authors = [""]
|
||||||
|
|
||||||
[dependants.libraries]
|
[dependants.libraries]
|
31
sysdata/programs/hash_test/src/main.hb
Normal file
31
sysdata/programs/hash_test/src/main.hb
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
.{hashers, log, memory, string} := @use("../../../libraries/stn/src/lib.hb")
|
||||||
|
|
||||||
|
main := fn(): void {
|
||||||
|
buffer := memory.request_page(1)
|
||||||
|
target := "abcdefghijklmnop\0"
|
||||||
|
strings := [^u8].("abcdefshijklmnop\0", "abcdefghijklnnop\0", "abcdefshijklmnop\0", "abcdefghijklmnop\0", "abcdefghijflmnop\0", "dbcdefghijklmnop\0", "abcdefghijklmnop\0")
|
||||||
|
len := @sizeof(@TypeOf(strings)) / @sizeof(^u8)
|
||||||
|
strlen := string.length(target)
|
||||||
|
|
||||||
|
// hasher := hashers.foldhash.FoldHasher.new(1)
|
||||||
|
hasher := hashers.foldhash.FoldHasher.default()
|
||||||
|
hasher.write(target, strlen)
|
||||||
|
correct := hasher.finish()
|
||||||
|
|
||||||
|
log.warn("target:\0")
|
||||||
|
log.warn(target)
|
||||||
|
|
||||||
|
i := 0
|
||||||
|
loop if i == len break else {
|
||||||
|
defer i += 1
|
||||||
|
hasher.reset()
|
||||||
|
hasher.write(strings[i], strlen)
|
||||||
|
d := hasher.finish()
|
||||||
|
if d == correct {
|
||||||
|
log.warn("match found\0")
|
||||||
|
}
|
||||||
|
log.info(strings[i])
|
||||||
|
log.debug(string.display_int(@bitcast(d), buffer, 16))
|
||||||
|
string.clear(buffer)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +0,0 @@
|
||||||
# hblang²
|
|
||||||
The hblang² or hblang2 compiler is intended to compile hblang to hbvm bytecode while also being written in hblang.
|
|
||||||
|
|
||||||
This is the first step in bootstrapping ableOS.
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
stn := @use("stn")
|
|
||||||
|
|
||||||
main := fn(): int {
|
|
||||||
return 0
|
|
||||||
}
|
|
|
@ -1,16 +1,16 @@
|
||||||
stn := @use("stn");
|
stn := @use("../../../libraries/stn/src/lib.hb");
|
||||||
.{string, memory, buffer, random, log} := stn;
|
.{string, memory, buffer, random, log} := stn;
|
||||||
.{Vec2} := stn.math
|
.{Vec2} := stn.math
|
||||||
|
|
||||||
horizon_api := @use("lib:horizon_api");
|
horizon_api := @use("../../../libraries/horizon_api/src/lib.hb");
|
||||||
.{new_label, render_label_to_surface, set_label_text} := horizon_api.widgets.label;
|
.{new_label, render_label_to_surface, set_label_text} := horizon_api.widgets.label;
|
||||||
.{sexpr_parser, render_ui} := horizon_api.ui
|
.{sexpr_parser, render_ui} := horizon_api.ui
|
||||||
|
|
||||||
render := @use("lib:render");
|
render := @use("../../../libraries/render/src/lib.hb");
|
||||||
.{Surface} := render;
|
.{Surface} := render;
|
||||||
.{Font} := render.text
|
.{Font} := render.text
|
||||||
|
|
||||||
intouch := @use("lib:intouch")
|
intouch := @use("../../../libraries/intouch/src/lib.hb")
|
||||||
|
|
||||||
Window := struct {
|
Window := struct {
|
||||||
// TODO: Replace this with widgets
|
// TODO: Replace this with widgets
|
||||||
|
@ -21,25 +21,25 @@ Window := struct {
|
||||||
y: int,
|
y: int,
|
||||||
}
|
}
|
||||||
|
|
||||||
psf := @embed("sysdata:assets/consolefonts/tamsyn/10x20r.psf")
|
psf := @embed("../../../assets/consolefonts/tamsyn/10x20r.psf")
|
||||||
img := @embed("sysdata:assets/wallpaper.qoi")
|
img := @embed("../../../assets/wallpaper.qoi")
|
||||||
|
|
||||||
main := fn(): int {
|
main := fn(): int {
|
||||||
win_buff := buffer.create("XHorizon")
|
win_buff := buffer.create("XHorizon\0")
|
||||||
|
|
||||||
screen := render.init(true)
|
screen := render.init(true)
|
||||||
|
|
||||||
// Clear the screen to black.
|
// Clear the screen to black.
|
||||||
screen.clear(render.BLACK)
|
render.clear(screen, render.black)
|
||||||
|
|
||||||
wallpaper := render.image.from(@bitcast(&img))
|
wallpaper := render.image.from(@bitcast(&img))
|
||||||
if wallpaper == null {
|
if wallpaper == null {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
window := render.Surface.new(screen.width / 3, screen.height / 3)
|
window := render.new_surface(screen.width / 3, screen.height / 3)
|
||||||
|
|
||||||
mem_buf := memory.request_page(1, false)
|
mem_buf := memory.request_page(1)
|
||||||
color := random.any(render.Color)
|
color := random.any(render.Color)
|
||||||
side := window.width / 8
|
side := window.width / 8
|
||||||
|
|
||||||
|
@ -48,16 +48,16 @@ main := fn(): int {
|
||||||
|
|
||||||
mouse_x := @as(i16, 0)
|
mouse_x := @as(i16, 0)
|
||||||
mouse_y := @as(i16, 0)
|
mouse_y := @as(i16, 0)
|
||||||
text_label := new_label("Hi")
|
text_label := new_label("Hi\0")
|
||||||
|
|
||||||
// widgets := "()"
|
// widgets := "()\0"
|
||||||
// ui := sexpr_parser(widgets)
|
// ui := sexpr_parser(widgets)
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
// Clear the screen
|
// Clear the screen
|
||||||
screen.clear(render.BLACK)
|
render.clear(screen, render.black)
|
||||||
|
|
||||||
screen.put_surface(wallpaper, .(0, 0), false)
|
render.put_surface(screen, wallpaper, .(0, 0), false)
|
||||||
|
|
||||||
// TODO: Read the window buffer here
|
// TODO: Read the window buffer here
|
||||||
{
|
{
|
||||||
|
@ -65,33 +65,33 @@ main := fn(): int {
|
||||||
|
|
||||||
if false {
|
if false {
|
||||||
// Scroll bar :ThumbsUp:
|
// Scroll bar :ThumbsUp:
|
||||||
screen.put_rect(.(100, 100), .(100, 10), render.WHITE)
|
render.put_rect(screen, .(100, 100), .(100, 10), render.white)
|
||||||
screen.put_filled_rect(.(110, 100), .(20, 10), render.WHITE)
|
render.put_filled_rect(screen, .(110, 100), .(20, 10), render.white)
|
||||||
|
|
||||||
screen.put_rect(.(90, 110), .(10, 100), render.WHITE)
|
render.put_rect(screen, .(90, 110), .(10, 100), render.white)
|
||||||
screen.put_filled_rect(.(90, 120), .(10, 20), render.WHITE)
|
render.put_filled_rect(screen, .(90, 120), .(10, 20), render.white)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// osu dots
|
// osu dots
|
||||||
screen.put_rect(.(400, 100), .(100, 100), render.RED)
|
render.put_rect(screen, .(400, 100), .(100, 100), render.red)
|
||||||
screen.put_rect(.(100, 100 + 300), .(100, 100), render.RED)
|
render.put_rect(screen, .(100, 100 + 300), .(100, 100), render.red)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
pos := Vec2(uint).(1, screen.height - 21)
|
pos := Vec2(uint).(1, screen.height - 21)
|
||||||
render_label_to_surface(screen, text_label, font, pos)
|
render_label_to_surface(screen, text_label, font, pos)
|
||||||
screen.put_rect(.(0, screen.height - 21), .(screen.width - 1, 20), render.WHITE)
|
render.put_rect(screen, .(0, screen.height - 21), .(screen.width - 1, 20), render.white)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Screen border
|
// Screen border
|
||||||
screen.put_rect(.(0, 0), .(screen.width - 1, screen.height - 1), render.WHITE)
|
render.put_rect(screen, .(0, 0), .(screen.width - 1, screen.height - 1), render.white)
|
||||||
|
|
||||||
// get input events from drivers via intouch
|
// get input events from drivers via intouch
|
||||||
if false {
|
if false {
|
||||||
key_event := intouch.recieve_key_event()
|
key_event := intouch.recieve_key_event()
|
||||||
if key_event != null {
|
if key_event != null {
|
||||||
log.info("Key event ")
|
log.info("Key event \0")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ main := fn(): int {
|
||||||
//
|
//
|
||||||
|
|
||||||
if mouse_event != null {
|
if mouse_event != null {
|
||||||
// log.warn("Mouse event received")
|
// log.warn("Mouse event received\0")
|
||||||
|
|
||||||
change_x := @as(i16, mouse_event.x_change)
|
change_x := @as(i16, mouse_event.x_change)
|
||||||
change_x = change_x << 8
|
change_x = change_x << 8
|
||||||
|
@ -127,18 +127,18 @@ main := fn(): int {
|
||||||
mouse_y -= change_y
|
mouse_y -= change_y
|
||||||
|
|
||||||
if mouse_event.left {
|
if mouse_event.left {
|
||||||
set_label_text(text_label, "LEFT CLICK")
|
set_label_text(text_label, "LEFT CLICK\0")
|
||||||
}
|
}
|
||||||
if mouse_event.middle {
|
if mouse_event.middle {
|
||||||
set_label_text(text_label, "MIDDLE CLICK")
|
set_label_text(text_label, "MIDDLE CLICK\0")
|
||||||
}
|
}
|
||||||
if mouse_event.right {
|
if mouse_event.right {
|
||||||
set_label_text(text_label, "RIGHT CLICK")
|
set_label_text(text_label, "RIGHT CLICK\0")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
screen.put_filled_rect(.(mouse_x, mouse_y), .(20, 20), render.BLACK)
|
render.put_filled_rect(screen, .(mouse_x, mouse_y), .(20, 20), render.black)
|
||||||
screen.put_rect(.(mouse_x, mouse_y), .(20, 20), render.WHITE)
|
render.put_rect(screen, .(mouse_x, mouse_y), .(20, 20), render.white)
|
||||||
|
|
||||||
// Send events to focused window
|
// Send events to focused window
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ main := fn(): int {
|
||||||
// TODO: Get windows out of a collection and iter through
|
// TODO: Get windows out of a collection and iter through
|
||||||
|
|
||||||
// Sync the screen
|
// Sync the screen
|
||||||
screen.sync()
|
render.sync(screen)
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
stn := @use("stn");
|
stn := @use("../../../libraries/stn/src/lib.hb");
|
||||||
.{string, memory, buffer, log} := stn
|
.{string, memory, buffer, log} := stn
|
||||||
|
|
||||||
horizon_api := @use("lib:horizon_api");
|
horizon_api := @use("../../../libraries/horizon_api/src/lib.hb");
|
||||||
.{create_window} := horizon_api
|
.{create_window} := horizon_api
|
||||||
|
|
||||||
ignim := @use("lib:ignim");
|
ignim := @use("../../../libraries/ignim/src/lib.hb");
|
||||||
.{errors} := ignim
|
.{errors} := ignim
|
||||||
|
|
||||||
psf := @embed("sysdata:assets/consolefonts/tamsyn/10x20r.psf")
|
psf := @embed("../../../consolefonts/tamsyn/10x20r.psf")
|
||||||
|
|
||||||
main := fn(): int {
|
main := fn(): int {
|
||||||
x := 0
|
x := 0
|
||||||
// loop if x > 10000 break else x += 1
|
// loop if x > 10000 break else x += 1
|
||||||
|
|
||||||
windowing_system_buffer := buffer.search("XHorizon")
|
windowing_system_buffer := buffer.search("XHorizon\0")
|
||||||
// TODO: get WindowID
|
// TODO: get WindowID
|
||||||
wid := create_window(windowing_system_buffer)
|
wid := create_window(windowing_system_buffer)
|
||||||
if false {
|
if false {
|
||||||
program_name := "Horizon Testing Program"
|
program_name := "Horizon Testing Program\0"
|
||||||
program_version := ignim.version.make_version(0, 1, 0)
|
program_version := ignim.version.make_version(0, 1, 0)
|
||||||
engine_name := "None"
|
engine_name := "None\0"
|
||||||
engine_version := ignim.version.make_version(0, 0, 0)
|
engine_version := ignim.version.make_version(0, 0, 0)
|
||||||
api_version := ignim.version.make_api_version(0, 1, 0, 0)
|
api_version := ignim.version.make_api_version(0, 1, 0, 0)
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ main := fn(): int {
|
||||||
// // TODO: recursively follow this https://vulkan-tutorial.com/Drawing_a_triangle/Setup/Instance
|
// // TODO: recursively follow this https://vulkan-tutorial.com/Drawing_a_triangle/Setup/Instance
|
||||||
ret := ignim.instance.create_instance(&create_info, 0, &instance)
|
ret := ignim.instance.create_instance(&create_info, 0, &instance)
|
||||||
if ret == errors.IncompatibleDriver {
|
if ret == errors.IncompatibleDriver {
|
||||||
log.error("Driver Incompatible with Vulkan")
|
log.error("Driver Incompatible with Vulkan\0")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
stn := @use("stn");
|
stn := @use("../../../libraries/stn/src/lib.hb");
|
||||||
.{memory, buffer, log, string, math} := stn;
|
.{memory, buffer, log, string, math} := stn;
|
||||||
.{inb, outb} := memory
|
.{inb, outb} := memory
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "clippy"
|
name = "processes"
|
||||||
authors = [""]
|
authors = ["koniifer"]
|
||||||
|
|
||||||
[dependants.libraries]
|
[dependants.libraries]
|
||||||
|
|
7
sysdata/programs/processes/src/hello_world_and_spin.hb
Normal file
7
sysdata/programs/processes/src/hello_world_and_spin.hb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
.{log} := @use("../../../libraries/stn/src/lib.hb")
|
||||||
|
|
||||||
|
main := fn(): void {
|
||||||
|
log.info("Hello, World!\0")
|
||||||
|
loop {
|
||||||
|
}
|
||||||
|
}
|
BIN
sysdata/programs/processes/src/hello_world_and_spin.hbf
Normal file
BIN
sysdata/programs/processes/src/hello_world_and_spin.hbf
Normal file
Binary file not shown.
19
sysdata/programs/processes/src/main.hb
Normal file
19
sysdata/programs/processes/src/main.hb
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
.{process, log, string, memory} := @use("../../../libraries/stn/src/lib.hb")
|
||||||
|
|
||||||
|
exe := @embed("./hello_world_and_spin.hbf")
|
||||||
|
|
||||||
|
main := fn(): void {
|
||||||
|
buf := "\0\0\0\0\0\0\0"
|
||||||
|
loop {
|
||||||
|
log.info(
|
||||||
|
string.display_int(
|
||||||
|
@bitcast(process.spawn(@bitcast(&exe), 356)),
|
||||||
|
buf,
|
||||||
|
10,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
// spin so we don't spawn 10 quattuordecillion processes
|
||||||
|
i := 0
|
||||||
|
loop if i == 1000000 break else i += 1
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,23 +0,0 @@
|
||||||
# Unified PS/2 Driver
|
|
||||||
|
|
||||||
Te entire thing is held together inspite
|
|
||||||
|
|
||||||
## !!Assumptions!!
|
|
||||||
Anyone who works on this should work to keep this list as small as possible/remove as many of these as possible.
|
|
||||||
- Bit 5 of the response form 0x64 indicates which port the data is coming from. (Not true on all systems)
|
|
||||||
- A parity or timeout error never occurs.
|
|
||||||
- PS/2 controller exists.
|
|
||||||
- Both PS/2 ports being broken doesn't need handling.
|
|
||||||
- One PS/2 port being broken doesn't need special attention.
|
|
||||||
- PS/2 controller doesn't need to perform a self-check.
|
|
||||||
- These DeviceIDs never exist:
|
|
||||||
- 0xFFFD
|
|
||||||
- 0xFFFE
|
|
||||||
- 0xFFFF
|
|
||||||
- 0x01xx
|
|
||||||
- 0x03xx
|
|
||||||
- 0x04xx
|
|
||||||
- Literally all PS/2 keyboards can be handeled the exact same way. We have the capability for detecting different keyboard types, I just don't bother with it because that would litreally take months to get working.
|
|
||||||
- The device doesn't send any data while we're waiting for an `ACK`.
|
|
||||||
|
|
||||||
Supporting mice in the keyboard port and vice versa was a ***bad*** idea, but I do not regret it because it means we're "superior" to real world operating systems.
|
|
|
@ -1,11 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "ps2_driver"
|
|
||||||
authors = ["Peony"]
|
|
||||||
|
|
||||||
[dependants.libraries]
|
|
||||||
|
|
||||||
[dependants.binaries]
|
|
||||||
hblang.version = "1.0.0"
|
|
||||||
|
|
||||||
[build]
|
|
||||||
command = "hblang src/main.hb"
|
|
|
@ -1,26 +0,0 @@
|
||||||
//Do not question.
|
|
||||||
|
|
||||||
$bit0 := fn(value: u8): bool {
|
|
||||||
return (value & 0x1) > 0
|
|
||||||
}
|
|
||||||
$bit1 := fn(value: u8): bool {
|
|
||||||
return (value & 0x2) > 0
|
|
||||||
}
|
|
||||||
$bit2 := fn(value: u8): bool {
|
|
||||||
return (value & 0x4) > 0
|
|
||||||
}
|
|
||||||
$bit3 := fn(value: u8): bool {
|
|
||||||
return (value & 0x8) > 0
|
|
||||||
}
|
|
||||||
$bit4 := fn(value: u8): bool {
|
|
||||||
return (value & 0x10) > 0
|
|
||||||
}
|
|
||||||
$bit5 := fn(value: u8): bool {
|
|
||||||
return (value & 0x20) > 0
|
|
||||||
}
|
|
||||||
$bit6 := fn(value: u8): bool {
|
|
||||||
return (value & 0x40) > 0
|
|
||||||
}
|
|
||||||
$bit7 := fn(value: u8): bool {
|
|
||||||
return (value & 0x80) > 0
|
|
||||||
}
|
|
|
@ -1,101 +0,0 @@
|
||||||
.{memory, log} := @use("stn");
|
|
||||||
.{bit0, bit1, bit5, bit6, bit7} := @use("bits.hb");
|
|
||||||
.{Port, PORT_AT_STARTUP} := @use("port.hb")
|
|
||||||
|
|
||||||
port1 := @as(Port, PORT_AT_STARTUP)
|
|
||||||
port2 := @as(Port, PORT_AT_STARTUP)
|
|
||||||
|
|
||||||
//wiki.osdev.org/"8042"_PS/2_Controller#PS/2_Controller_IO_Ports
|
|
||||||
$CONTROLLER_PORT := 0x64
|
|
||||||
$DATA_PORT := 0x60
|
|
||||||
|
|
||||||
$disable_port1 := fn(): void memory.outb(CONTROLLER_PORT, 0xAD)
|
|
||||||
$enable_port1 := fn(): void memory.outb(CONTROLLER_PORT, 0xAE)
|
|
||||||
$disable_port2 := fn(): void memory.outb(CONTROLLER_PORT, 0xA7)
|
|
||||||
$enable_port2 := fn(): void memory.outb(CONTROLLER_PORT, 0xA8)
|
|
||||||
|
|
||||||
test_port1 := fn(): bool {
|
|
||||||
memory.outb(CONTROLLER_PORT, 0xAB)
|
|
||||||
loop if has_input(get_info()) break
|
|
||||||
input := get_input()
|
|
||||||
return input == 0x0
|
|
||||||
}
|
|
||||||
|
|
||||||
test_port2 := fn(): bool {
|
|
||||||
memory.outb(CONTROLLER_PORT, 0xA9)
|
|
||||||
loop if has_input(get_info()) break
|
|
||||||
input := get_input()
|
|
||||||
return input == 0x0
|
|
||||||
}
|
|
||||||
|
|
||||||
get_config_byte := fn(): u8 {
|
|
||||||
memory.outb(CONTROLLER_PORT, 0x20)
|
|
||||||
loop if has_input(get_info()) break
|
|
||||||
return get_input()
|
|
||||||
}
|
|
||||||
|
|
||||||
Info := struct {d: u8}
|
|
||||||
|
|
||||||
$get_info := fn(): Info return .(memory.inb(CONTROLLER_PORT))
|
|
||||||
//inline when can
|
|
||||||
has_input := fn(info: Info): bool return bit0(info.d)
|
|
||||||
can_send := fn(info: Info): bool return bit1(info.d) == false
|
|
||||||
timed_out := fn(info: Info): bool return bit6(info.d)
|
|
||||||
check_parity := fn(info: Info): bool return bit7(info.d)
|
|
||||||
get_port := fn(info: Info): ^Port {
|
|
||||||
if bit5(info.d) {
|
|
||||||
return &port2
|
|
||||||
} else {
|
|
||||||
return &port1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//T
|
|
||||||
port2_ptr := &port2
|
|
||||||
send_byte := fn(port: ^Port, byte: u8): void {
|
|
||||||
if port == port2_ptr {
|
|
||||||
memory.outb(CONTROLLER_PORT, 0xD4)
|
|
||||||
}
|
|
||||||
loop if can_send(get_info()) break
|
|
||||||
memory.outb(DATA_PORT, byte)
|
|
||||||
}
|
|
||||||
|
|
||||||
$get_input := fn(): u8 return memory.inb(DATA_PORT)
|
|
||||||
$write_out := fn(data: u8): void memory.outb(DATA_PORT, data)
|
|
||||||
|
|
||||||
flush_input := fn(): void {
|
|
||||||
loop if has_input(get_info()) == false break else get_info()
|
|
||||||
}
|
|
||||||
|
|
||||||
init := fn(): void {
|
|
||||||
disable_port1()
|
|
||||||
disable_port2()
|
|
||||||
//Disables ports to make sure that they won't interfere with the setup process.
|
|
||||||
|
|
||||||
flush_input()
|
|
||||||
|
|
||||||
enable_port2()
|
|
||||||
port2.exists = bit5(@inline(get_config_byte)) == false
|
|
||||||
disable_port2()
|
|
||||||
|
|
||||||
flush_input()
|
|
||||||
|
|
||||||
port1.exists = test_port1()
|
|
||||||
|
|
||||||
if port2.exists {
|
|
||||||
port2.exists = test_port2()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (port1.exists | port2.exists) == false {
|
|
||||||
log.error("No ports detected! No input will be processed! Cannot handle this!")
|
|
||||||
}
|
|
||||||
|
|
||||||
if port1.exists {
|
|
||||||
log.info("Port 1 exists.")
|
|
||||||
enable_port1()
|
|
||||||
}
|
|
||||||
if port2.exists {
|
|
||||||
log.info("Port 2 exists.")
|
|
||||||
enable_port2()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
DeviceID := struct {value: u16}
|
|
||||||
|
|
||||||
$MOUSE_3_BUTTON := DeviceID.(0x0)
|
|
||||||
$MOUSE_SCROLLWHEEL := DeviceID.(0x3)
|
|
||||||
$MOUSE_5_BUTTON := DeviceID.(0x4)
|
|
||||||
$KEYBOARD_SPACESAVER := DeviceID.(0x84AB)
|
|
||||||
$KEYBOARD_122_KEY := DeviceID.(0x86AB)
|
|
||||||
$KEYBOARD_JAPANESE_G := DeviceID.(0x90AB)
|
|
||||||
$KEYBOARD_JAPANESE_P := DeviceID.(0x91AB)
|
|
||||||
$KEYBOARD_JAPANESE_A := DeviceID.(0x92AB)
|
|
||||||
$KEYBOARD_NCD_SUN := DeviceID.(0xA1AC)
|
|
||||||
|
|
||||||
$MOUSE_INIT_1 := DeviceID.(0xFFFD)
|
|
||||||
$MOUSE_INIT_2 := DeviceID.(0xFFFE)
|
|
||||||
$NO_DEVICE := DeviceID.(0xFFFF)
|
|
|
@ -1,150 +0,0 @@
|
||||||
.{memory, log, buffer, string} := @use("stn");
|
|
||||||
.{MouseEvent} := @use("lib:intouch").events;
|
|
||||||
.{bit0, bit1, bit2, bit3, bit4} := @use("bits.hb")
|
|
||||||
devices := @use("devices.hb")
|
|
||||||
controller := @use("controller.hb");
|
|
||||||
.{Info, Port} := controller
|
|
||||||
mouse := @use("mouse.hb")
|
|
||||||
|
|
||||||
mouse_buffer := 0
|
|
||||||
keyboard_buffer := 0
|
|
||||||
info := Info.(0)
|
|
||||||
|
|
||||||
send_command := fn(port: ^Port, byte: u8): void {
|
|
||||||
tries := 3
|
|
||||||
loop if tries == 0 break else {
|
|
||||||
controller.send_byte(port, byte)
|
|
||||||
loop {
|
|
||||||
info = controller.get_info()
|
|
||||||
if controller.has_input(info) == false {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
input := controller.get_input()
|
|
||||||
if controller.get_port(info) != port {
|
|
||||||
if check_complete(port) == false {
|
|
||||||
port.packet[port.packet_length] = input
|
|
||||||
port.packet_length += 1
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if input == 0xFA {
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tries -= 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enable_streaming := fn(port: ^Port): void {
|
|
||||||
@inline(send_command, port, 0xF4)
|
|
||||||
}
|
|
||||||
|
|
||||||
process := fn(port: ^controller.Port): void {
|
|
||||||
if port.device.value < devices.MOUSE_5_BUTTON.value {
|
|
||||||
event := MouseEvent.(0, 0, false, false, false)
|
|
||||||
|
|
||||||
event.left = bit0(port.packet[0])
|
|
||||||
event.right = bit1(port.packet[0])
|
|
||||||
event.middle = bit2(port.packet[0])
|
|
||||||
|
|
||||||
event.x_change = @intcast(port.packet[1])
|
|
||||||
event.y_change = @intcast(port.packet[2])
|
|
||||||
|
|
||||||
buffer.write(MouseEvent, mouse_buffer, &event)
|
|
||||||
} else if port.device == devices.MOUSE_INIT_1 {
|
|
||||||
port.device.value = port.packet[0]
|
|
||||||
if port.device != devices.MOUSE_SCROLLWHEEL {
|
|
||||||
enable_streaming(port)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
port.device = devices.MOUSE_INIT_2
|
|
||||||
} else if port.device == devices.MOUSE_INIT_2 {
|
|
||||||
port.device.value = port.packet[0]
|
|
||||||
} else if port.device == devices.NO_DEVICE {
|
|
||||||
if port.packet_length == 1 {
|
|
||||||
port.device.value = port.packet[0]
|
|
||||||
enable_streaming(port)
|
|
||||||
//TODO: Upgrade mouse.
|
|
||||||
} else {
|
|
||||||
port.device.value = port.packet[1] | port.packet[0] << 8
|
|
||||||
enable_streaming(port)
|
|
||||||
}
|
|
||||||
log.info("Identified device!")
|
|
||||||
log.print(port.device.value, .{radix: 16})
|
|
||||||
} else {
|
|
||||||
log.info("KEY PRESSED")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
check_complete := fn(port: ^controller.Port): bool {
|
|
||||||
last_value := port.packet[port.packet_length - 1]
|
|
||||||
if port.device == devices.NO_DEVICE {
|
|
||||||
if last_value == 0 | last_value == 3 | last_value == 4 {
|
|
||||||
return true
|
|
||||||
} else if port.packet_length == 2 {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
} else if port.device == devices.MOUSE_3_BUTTON {
|
|
||||||
if port.packet_length == 3 return true
|
|
||||||
} else if port.device == devices.MOUSE_SCROLLWHEEL | port.device == devices.MOUSE_5_BUTTON {
|
|
||||||
if port.packet_length == 4 return true
|
|
||||||
} else {
|
|
||||||
if port.packet[0] == 0xE1 {
|
|
||||||
if port.packet_length == 6 {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
} else if port.packet[0] != 0xE0 {
|
|
||||||
return true
|
|
||||||
} else if port.packet_length == 2 & port.packet[1] != 0x2A & port.packet[1] != 0xB7 {
|
|
||||||
return true
|
|
||||||
} else if port.packet_length == 4 {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
main := fn(): void {
|
|
||||||
mouse_buffer = buffer.create("PS/2 Mouse")
|
|
||||||
|
|
||||||
controller.init()
|
|
||||||
|
|
||||||
if controller.port1.exists {
|
|
||||||
//log.info("Port 1 exists.")
|
|
||||||
controller.send_byte(@bitcast(0), 0xF4)
|
|
||||||
}
|
|
||||||
if controller.port2.exists {
|
|
||||||
//controller.send_byte(&controller.port2, 0xF4)
|
|
||||||
}
|
|
||||||
|
|
||||||
loop {
|
|
||||||
info = controller.get_info()
|
|
||||||
|
|
||||||
if controller.timed_out(info) {
|
|
||||||
log.error("Timeout error! Cannot handle these!")
|
|
||||||
}
|
|
||||||
if controller.check_parity(info) {
|
|
||||||
log.error("Parity error! Cannot handle these!")
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
if controller.has_input(info) {
|
|
||||||
port := controller.get_port(info)
|
|
||||||
if port.packet_length > 0 & check_complete(port) {
|
|
||||||
process(port)
|
|
||||||
}
|
|
||||||
input := controller.get_input()
|
|
||||||
/*if input == 0xAA & port.can_hot_plug {
|
|
||||||
port.device = devices.NO_DEVICE
|
|
||||||
controller.send_byte(port, 0xF4)
|
|
||||||
}*/
|
|
||||||
port.packet[port.packet_length] = input
|
|
||||||
port.packet_length += 1
|
|
||||||
if check_complete(port) {
|
|
||||||
process(port)
|
|
||||||
port.packet_length = 0
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
Button := struct {id: u8}
|
|
||||||
$LEFT_BUTTON := Button.(1)
|
|
||||||
$RIGHT_BUTTON := Button.(2)
|
|
||||||
$MIDDLE_BUTTON := Button.(4)
|
|
||||||
$BUTTON4 := Button.(8)
|
|
||||||
$BUTTON5 := Button.(16)
|
|
||||||
|
|
||||||
SampleRate := struct {value: u8}
|
|
||||||
$SR10 := SampleRate.(10)
|
|
||||||
$SR20 := SampleRate.(20)
|
|
||||||
$SR40 := SampleRate.(40)
|
|
||||||
$SR60 := SampleRate.(60)
|
|
||||||
$SR80 := SampleRate.(80)
|
|
||||||
$SR100 := SampleRate.(100)
|
|
||||||
$SR200 := SampleRate.(200)
|
|
||||||
|
|
||||||
Resolution := struct {value: u8}
|
|
||||||
$RES_1COUNT_PER_MM := Resolution.(0)
|
|
||||||
$RES_2COUNT_PER_MM := Resolution.(1)
|
|
||||||
$RES_4COUNT_PER_MM := Resolution.(2)
|
|
||||||
$RES_8COUNT_PER_MM := Resolution.(3)
|
|
|
@ -1,21 +0,0 @@
|
||||||
.{DeviceID, NO_DEVICE} := @use("devices.hb")
|
|
||||||
|
|
||||||
State := struct {s: u8}
|
|
||||||
$Recive := State.(0)
|
|
||||||
$Reboot := State.(1)
|
|
||||||
|
|
||||||
Port := packed struct {
|
|
||||||
exists: bool,
|
|
||||||
device: DeviceID,
|
|
||||||
packet: [8]u8,
|
|
||||||
packet_length: u8,
|
|
||||||
can_hot_plug: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
$PORT_AT_STARTUP := Port.(
|
|
||||||
true,
|
|
||||||
NO_DEVICE,
|
|
||||||
.[0, 0, 0, 0, 0, 0, 0, 0],
|
|
||||||
0,
|
|
||||||
true,
|
|
||||||
)
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue