Compare commits
47 commits
Author | SHA1 | Date | |
---|---|---|---|
|
7ead8809c2 | ||
|
5be0da8735 | ||
|
895135e97d | ||
|
5db7237341 | ||
|
4b28810372 | ||
|
32e0e9fde1 | ||
|
04dd9a9700 | ||
|
82382d2a99 | ||
|
5659ae1d0a | ||
|
e21bb03912 | ||
|
75db10c339 | ||
|
4560c19652 | ||
|
96dc726c35 | ||
|
c9601fae4a | ||
|
6ec5af6df5 | ||
|
49d00313e2 | ||
|
0e27f57bc6 | ||
|
68f5d64dad | ||
|
3d699d9db8 | ||
|
27376bc101 | ||
|
1eca77abaf | ||
|
7f4f0218d0 | ||
|
8ad1f12ebd | ||
|
c0a4c88c41 | ||
|
6ddc199b6a | ||
|
5a3ffbb1ec | ||
|
eae328afdb | ||
|
8cca5c8d1b | ||
|
9e0ed8a5d7 | ||
|
8a78faecdf | ||
|
6dc17daa09 | ||
|
15b3fde6e6 | ||
|
98c3fa059f | ||
|
5cb3b956d9 | ||
|
afddfea8fb | ||
|
0db997b435 | ||
|
31b3d5e5ba | ||
|
89cd1eec9c | ||
|
8aac85e9cf | ||
|
73c9b633c4 | ||
|
f1598a044e | ||
|
dc43529c7b | ||
|
6475e1bc26 | ||
|
e6bdce0240 | ||
|
a623e62e8c | ||
|
da12a5155c | ||
|
0a863bc1f9 |
.gitignoreCargo.lockCargo.tomlsystem.lispsystem.rlsystem_config.toml
kernel
rlbuild
rust-toolchain.tomlsysdata
libraries
clippy
intouch/src
stn/src
programs
ablefetch/src
adit
ascii_game
ps2_driver
ps2_driver_retired
render_example/src
rtc_driver/src
sdoom/src
sketchpad
sunset_server/src
test/src/tests/stn
test_framework
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1 @@
|
|||
target/
|
||||
out/
|
76
Cargo.lock
generated
76
Cargo.lock
generated
|
@ -73,9 +73,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
|||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.14"
|
||||
version = "1.2.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c3d1b2e905a3a7b00a6141adb0e4c0bb941d11caf55349d863942a1cc44e3c9"
|
||||
checksum = "13208fcbb66eaeffe09b99fffbe1af420f00a7b35aa99ad683dfc1aa76145229"
|
||||
dependencies = [
|
||||
"shlex",
|
||||
]
|
||||
|
@ -142,9 +142,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.2"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
|
||||
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||
|
||||
[[package]]
|
||||
name = "error-stack"
|
||||
|
@ -213,12 +213,12 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "hbbytecode"
|
||||
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#18e8a831ab6b710dbdd9b0d6a0880c67df0cec26"
|
||||
|
||||
[[package]]
|
||||
name = "hblang"
|
||||
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#18e8a831ab6b710dbdd9b0d6a0880c67df0cec26"
|
||||
dependencies = [
|
||||
"hashbrown",
|
||||
"hbbytecode",
|
||||
|
@ -229,7 +229,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "hbvm"
|
||||
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#18e8a831ab6b710dbdd9b0d6a0880c67df0cec26"
|
||||
dependencies = [
|
||||
"hbbytecode",
|
||||
]
|
||||
|
@ -494,9 +494,9 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
|||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.20.3"
|
||||
version = "1.20.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e"
|
||||
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
|
||||
|
||||
[[package]]
|
||||
name = "paste"
|
||||
|
@ -539,9 +539,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "raw-cpuid"
|
||||
version = "11.4.0"
|
||||
version = "11.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "529468c1335c1c03919960dfefdb1b3648858c20d7ec2d0663e728e4a717efbc"
|
||||
checksum = "c6928fa44c097620b706542d428957635951bade7143269085389d42c8a4927e"
|
||||
dependencies = [
|
||||
"bitflags 2.8.0",
|
||||
]
|
||||
|
@ -561,7 +561,7 @@ dependencies = [
|
|||
"fatfs",
|
||||
"hblang",
|
||||
"log",
|
||||
"raw-cpuid 11.4.0",
|
||||
"raw-cpuid 11.3.0",
|
||||
"str-reader",
|
||||
"toml",
|
||||
"ureq",
|
||||
|
@ -569,33 +569,19 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "ring"
|
||||
version = "0.17.9"
|
||||
version = "0.17.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e75ec5e92c4d8aede845126adc388046234541629e76029599ed35a003c7ed24"
|
||||
checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"cfg-if",
|
||||
"getrandom",
|
||||
"libc",
|
||||
"spin",
|
||||
"untrusted",
|
||||
"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#a1cef24e513a89f8d4de8a1cb3ede546bc72aeca"
|
||||
dependencies = [
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
version = "0.4.1"
|
||||
|
@ -607,9 +593,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "rustls"
|
||||
version = "0.23.23"
|
||||
version = "0.23.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "47796c98c480fce5406ef69d1c76378375492c3b0a0de587be0c1d9feb12f395"
|
||||
checksum = "9fb9263ab4eb695e42321db096e3b8fbd715a59b154d5c88d82db2175b681ba7"
|
||||
dependencies = [
|
||||
"log",
|
||||
"once_cell",
|
||||
|
@ -707,9 +693,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.14.0"
|
||||
version = "1.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd"
|
||||
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
|
@ -740,9 +726,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.98"
|
||||
version = "2.0.96"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1"
|
||||
checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -778,9 +764,9 @@ checksum = "696941a0aee7e276a165a978b37918fd5d22c55c3d6bda197813070ca9c0f21c"
|
|||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.8.20"
|
||||
version = "0.8.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148"
|
||||
checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
|
@ -799,9 +785,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.22.24"
|
||||
version = "0.22.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474"
|
||||
checksum = "02a8b472d1a3d7c18e2d61a489aee3453fd9031c33e4f55bd533f4a7adca1bee"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"serde",
|
||||
|
@ -823,9 +809,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.17"
|
||||
version = "1.0.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe"
|
||||
checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
|
@ -899,9 +885,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
|||
|
||||
[[package]]
|
||||
name = "webpki-roots"
|
||||
version = "0.26.8"
|
||||
version = "0.26.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2210b291f7ea53617fbafcc4939f10914214ec15aace5ba62293a668f322c5c9"
|
||||
checksum = "5d642ff16b7e79272ae451b7322067cdc17cadf68c23264be9d94a32319efe7e"
|
||||
dependencies = [
|
||||
"rustls-pki-types",
|
||||
]
|
||||
|
@ -981,9 +967,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
|||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "0.7.2"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "59690dea168f2198d1a3b0cac23b8063efcd11012f10ae4698f284808c8ef603"
|
||||
checksum = "7e49d2d35d3fad69b39b94139037ecfb4f359f08958b9c11e7315ce770462419"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
|
10
Cargo.toml
10
Cargo.toml
|
@ -1,17 +1,9 @@
|
|||
[workspace]
|
||||
resolver = "2"
|
||||
members = ["dev", "kernel", "repbuild", "rlbuild"]
|
||||
members = ["dev", "kernel", "repbuild"]
|
||||
|
||||
# [profile.release]
|
||||
# strip = "symbols"
|
||||
# codegen-units = 1
|
||||
# lto = true
|
||||
# panic = "abort"
|
||||
|
||||
[profile.release.package.hblang]
|
||||
debug-assertions = true
|
||||
overflow-checks = false
|
||||
|
||||
[profile.dev.package.hblang]
|
||||
debug-assertions = true
|
||||
overflow-checks = false
|
||||
|
|
|
@ -5,21 +5,21 @@ extern crate syn;
|
|||
use {
|
||||
proc_macro::TokenStream,
|
||||
quote::quote,
|
||||
syn::{parse::Parse, parse_macro_input, Expr, ItemFn, Token},
|
||||
syn::{parse::Parse, parse_macro_input, Expr, ItemFn, Token}
|
||||
};
|
||||
|
||||
struct KtestInput {
|
||||
lhs: Expr,
|
||||
lhs: Expr,
|
||||
_comma: Token![,],
|
||||
rhs: Expr,
|
||||
rhs: Expr,
|
||||
}
|
||||
|
||||
impl Parse for KtestInput {
|
||||
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
|
||||
Ok(Self {
|
||||
lhs: input.parse()?,
|
||||
lhs: input.parse()?,
|
||||
_comma: input.parse()?,
|
||||
rhs: input.parse()?,
|
||||
rhs: input.parse()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -83,4 +83,4 @@ pub fn ktest(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
|||
};
|
||||
|
||||
TokenStream::from(out)
|
||||
}
|
||||
}
|
1
kernel/src/arch/x86_64/graphics.rs
Normal file
1
kernel/src/arch/x86_64/graphics.rs
Normal file
|
@ -0,0 +1 @@
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
//! Environment call handling routines
|
||||
|
||||
use core::arch::asm;
|
||||
|
||||
use {alloc::boxed::Box, core::cell::LazyCell, hbvm::mem::Address};
|
||||
|
||||
use crate::{
|
||||
|
@ -288,6 +290,20 @@ pub fn handler(thr: &mut ExecThread, pid: &usize) {
|
|||
.buffer_subscribe(*pid, buffer_id);
|
||||
}
|
||||
}
|
||||
8 => {
|
||||
// Disable/enable interrupts.
|
||||
// TODO: This is the quickest dirtiest hack to ever exist.
|
||||
let state = thr.vm.registers[3].cast::<u8>();
|
||||
if state == 0 {
|
||||
debug!("Interrupts disabled.");
|
||||
unsafe {asm!("cli");};
|
||||
}
|
||||
else
|
||||
{
|
||||
debug!("Interrupts enabled.");
|
||||
unsafe {asm!("sti");};
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
log::error!("Syscall unknown {:?}{:?}", ecall_number, thr.vm.registers);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
pub use ktest_macro::*;
|
||||
|
||||
use {
|
||||
alloc::string::String,
|
||||
log::{error, info},
|
||||
alloc::string::String,
|
||||
log::{error, info},
|
||||
};
|
||||
|
||||
extern "C" {
|
||||
|
@ -19,8 +19,8 @@ pub fn test_main() {
|
|||
let mut current_test = &__ktest_start as *const fn() -> Result<String, String>;
|
||||
let test_end = &__ktest_end as *const fn() -> Result<String, String>;
|
||||
|
||||
let mut pass = 0;
|
||||
let mut fail = 0;
|
||||
let mut pass = 0;
|
||||
let mut fail = 0;
|
||||
|
||||
while current_test < test_end {
|
||||
let test_fn = *current_test;
|
||||
|
@ -30,7 +30,7 @@ pub fn test_main() {
|
|||
Ok(name) => {
|
||||
info!("Test: {} passed", name);
|
||||
pass += 1;
|
||||
}
|
||||
},
|
||||
Err(name) => {
|
||||
error!("Test: {} failed", name);
|
||||
fail += 1;
|
||||
|
@ -47,5 +47,5 @@ pub fn test_main() {
|
|||
#[ktest]
|
||||
pub fn trivial_assertion() {
|
||||
ktest_eq!(1, 1);
|
||||
ktest_neq!(0, 1);
|
||||
ktest_neq!(0, 1);
|
||||
}
|
||||
|
|
|
@ -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,38 +0,0 @@
|
|||
;; ! hbpkg.rli ! ;;
|
||||
;; package name & version, non-optional.
|
||||
(package
|
||||
"example"
|
||||
;; Major Minor Patch
|
||||
(version 1 0 1)
|
||||
:authors ("AbleTheAbove")
|
||||
|
||||
:tags ("a" "b" "c")
|
||||
|
||||
(deps
|
||||
;; first item after name is always source.
|
||||
(lily "https://git.ablecorp.us/lily-org/lily.git"
|
||||
;; semantic version. min & max both optional.
|
||||
;; if version is string, exact match will be used.
|
||||
;; if version is "0.x", then the latest of "0.x.y" will be used
|
||||
:version (:min "0.0.2" :max "0.0.5")
|
||||
)
|
||||
(libexample "./src/lib.hb")
|
||||
(third-dep
|
||||
;; Repo lookup refers to the rlrepo project
|
||||
(repo :core "third-dep")
|
||||
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(some_clib "https://example.org/clib.git"
|
||||
:commit "ABCDEFGH" ;; optional
|
||||
:branch "trunk" ;; optional
|
||||
;; optional, probably not required if specifying commit.
|
||||
:hash "abcdefghijklmnopqrstuvwxyz123456"
|
||||
)
|
||||
)
|
||||
)
|
|
@ -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,25 +0,0 @@
|
|||
use rlisp_library::*;
|
||||
|
||||
|
||||
pub fn extend_environ<'a>(mut env: Environ<'a>) -> Environ<'a> {
|
||||
env.data.insert(
|
||||
"system-install".to_string(),
|
||||
Expr::Func(|_args: &[Expr]| -> Result<Expr, RispError> {
|
||||
println!("probably the kernel is installed by now");
|
||||
Ok(Expr::Bool(true))
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
env.data.insert(
|
||||
"use-repo-path".to_string(),
|
||||
Expr::Func(|_args: &[Expr]| -> Result<Expr, RispError> {
|
||||
let repo_name = _args.first().unwrap();
|
||||
|
||||
println!("{:?}", _args);
|
||||
Ok(Expr::Bool(true))
|
||||
}),
|
||||
);
|
||||
|
||||
env
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
use rlisp_library::*;
|
||||
|
||||
mod ext;
|
||||
mod old;
|
||||
|
||||
pub fn extend_environ<'a>(mut env: Environ<'a>) -> Environ<'a> {
|
||||
let mut env = ext::extend_environ(env);
|
||||
let mut env = old::extend_environ(env);
|
||||
|
||||
|
||||
|
||||
|
||||
env
|
||||
}
|
|
@ -1,262 +0,0 @@
|
|||
use std::{
|
||||
fs::{self, File},
|
||||
io::Write,
|
||||
};
|
||||
|
||||
use rlisp_library::{
|
||||
Environ,
|
||||
Expr::{self, Bool},
|
||||
RispError, default_env, parse_eval,
|
||||
};
|
||||
|
||||
|
||||
|
||||
pub
|
||||
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"");
|
||||
|
||||
let path = format!("out/boot/limine/BOOTX64.EFI");
|
||||
let mut x64_file = File::create(&path).unwrap();
|
||||
std::fs::copy("limine/BOOTX64.EFI", &path).unwrap(); // Copy foo.txt to bar.txt
|
||||
|
||||
let path = format!("out/boot/limine/BOOTAA64.EFI");
|
||||
let mut x64_file = File::create(&path).unwrap();
|
||||
std::fs::copy("limine/BOOTAA64.EFI", &path).unwrap(); // Copy foo.txt to bar.txt
|
||||
|
||||
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.
|
||||
|
||||
|
||||
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();
|
||||
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
|
||||
}
|
|
@ -1,71 +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;
|
||||
mod environ;
|
||||
use environ::extend_environ;
|
||||
|
||||
fn main() {
|
||||
let env = &mut default_env();
|
||||
let env = &mut extend_environ(env.clone());
|
||||
// let env = &mut
|
||||
|
||||
let cfg = include_str!("../../sysdata/system.rl");
|
||||
|
||||
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,15 +0,0 @@
|
|||
pub enum Origin {
|
||||
GitRepo(String),
|
||||
Path(String),
|
||||
Repo()
|
||||
}
|
||||
|
||||
pub struct Package {
|
||||
name: String,
|
||||
authors: Vec<String>,
|
||||
tags: Vec<String>,
|
||||
version: u8,
|
||||
depends: Vec<(String, String)>,
|
||||
origin: Origin,
|
||||
}
|
||||
impl Package {}
|
|
@ -1,3 +1,7 @@
|
|||
[toolchain]
|
||||
# old toolchain
|
||||
# channel = "nightly-2024-07-27"
|
||||
# last stable
|
||||
# channel = "nightly-2024-11-20"
|
||||
channel = "nightly"
|
||||
components = ["rust-src", "llvm-tools"]
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
# clippy
|
||||
Uhm maybe change the name haha
|
|
@ -1,11 +0,0 @@
|
|||
[package]
|
||||
name = "clippy"
|
||||
authors = [""]
|
||||
|
||||
[dependants.libraries]
|
||||
|
||||
[dependants.binaries]
|
||||
hblang.version = "1.0.0"
|
||||
|
||||
[build]
|
||||
command = "hblang src/main.hb"
|
|
@ -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 {}
|
|
@ -2,17 +2,17 @@ keycodes := @use("keycodes.hb");
|
|||
.{KeyCode} := keycodes
|
||||
|
||||
KeyEvent := packed struct {
|
||||
up: bool = false,
|
||||
just_triggered: bool = false,
|
||||
key: KeyCode = 0,
|
||||
up: bool,
|
||||
just_triggered: bool,
|
||||
key: KeyCode,
|
||||
}
|
||||
|
||||
MouseEvent := packed struct {
|
||||
x_change: i8 = 0,
|
||||
y_change: i8 = 0,
|
||||
left: bool = false,
|
||||
middle: bool = false,
|
||||
right: bool = false,
|
||||
x_change: i8,
|
||||
y_change: i8,
|
||||
left: bool,
|
||||
middle: bool,
|
||||
right: bool,
|
||||
}
|
||||
|
||||
GamepadEvent := struct {}
|
|
@ -7,89 +7,115 @@ I am now modelling it as I see fit. This is likely not the final version.
|
|||
|
||||
KeyCode := u32
|
||||
|
||||
$NONE: KeyCode = 0
|
||||
$ESCAPE: KeyCode = 1
|
||||
$A: KeyCode = 2
|
||||
$B: KeyCode = 3
|
||||
$C: KeyCode = 4
|
||||
$D: KeyCode = 5
|
||||
$E: KeyCode = 6
|
||||
$F: KeyCode = 7
|
||||
$G: KeyCode = 8
|
||||
$H: KeyCode = 9
|
||||
$I: KeyCode = 10
|
||||
$J: KeyCode = 11
|
||||
$K: KeyCode = 12
|
||||
$L: KeyCode = 13
|
||||
$M: KeyCode = 14
|
||||
$N: KeyCode = 15
|
||||
$O: KeyCode = 16
|
||||
$P: KeyCode = 17
|
||||
$Q: KeyCode = 18
|
||||
$R: KeyCode = 19
|
||||
$S: KeyCode = 20
|
||||
$T: KeyCode = 21
|
||||
$U: KeyCode = 22
|
||||
$V: KeyCode = 23
|
||||
$W: KeyCode = 24
|
||||
$X: KeyCode = 25
|
||||
$Y: KeyCode = 26
|
||||
$Z: KeyCode = 27
|
||||
$NUMBER0: KeyCode = 28
|
||||
$NUMBER1: KeyCode = 29
|
||||
$NUMBER2: KeyCode = 30
|
||||
$NUMBER3: KeyCode = 31
|
||||
$NUMBER4: KeyCode = 32
|
||||
$NUMBER5: KeyCode = 33
|
||||
$NUMBER6: KeyCode = 34
|
||||
$NUMBER7: KeyCode = 35
|
||||
$NUMBER8: KeyCode = 36
|
||||
$NUMBER9: KeyCode = 37
|
||||
$KEYPADNUMBER0: KeyCode = 38
|
||||
$KEYPADNUMBER1: KeyCode = 39
|
||||
$KEYPADNUMBER2: KeyCode = 40
|
||||
$KEYPADNUMBER3: KeyCode = 41
|
||||
$KEYPADNUMBER4: KeyCode = 42
|
||||
$KEYPADNUMBER5: KeyCode = 43
|
||||
$KEYPADNUMBER6: KeyCode = 44
|
||||
$KEYPADNUMBER7: KeyCode = 45
|
||||
$KEYPADNUMBER8: KeyCode = 46
|
||||
$KEYPADNUMBER9: KeyCode = 47
|
||||
$KEYPADPERIOD: KeyCode = 48
|
||||
$KEYPADDIVIDE: KeyCode = 49
|
||||
$KEYPADMULTIPLY: KeyCode = 50
|
||||
$KEYPADMINUS: KeyCode = 51
|
||||
$KEYPADPLUS: KeyCode = 52
|
||||
$KEYPADENTER: KeyCode = 53
|
||||
$KEYPADEQUALS: KeyCode = 54
|
||||
$DELETE: KeyCode = 55
|
||||
$NUMLOCK: KeyCode = 56
|
||||
$CAPSLOCK: KeyCode = 57
|
||||
$SCROLLLOCK: KeyCode = 58
|
||||
$MODE: KeyCode = 59
|
||||
$COMPOSE: KeyCode = 60
|
||||
$LEFTALT: KeyCode = 61
|
||||
$LEFTCONTROL: KeyCode = 62
|
||||
$LEFTMETA: KeyCode = 63
|
||||
$LEFTSHIFT: KeyCode = 64
|
||||
$LEFTSUPER: KeyCode = 65
|
||||
$RIGHTALT: KeyCode = 66
|
||||
$RIGHTCONTROL: KeyCode = 67
|
||||
$RIGHTMETA: KeyCode = 68
|
||||
$RIGHTSHIFT: KeyCode = 69
|
||||
$RIGHTSUPER: KeyCode = 70
|
||||
$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
|
||||
$ANYSUPER: KeyCode = 85
|
||||
// Typically this is not a keycode you will ever recieve.
|
||||
None := KeyCode.(0)
|
||||
|
||||
Escape := KeyCode.(1)
|
||||
/* Alphabet keycodes */
|
||||
|
||||
A := KeyCode.(2)
|
||||
B := KeyCode.(3)
|
||||
C := KeyCode.(4)
|
||||
D := KeyCode.(5)
|
||||
E := KeyCode.(6)
|
||||
F := KeyCode.(7)
|
||||
G := KeyCode.(8)
|
||||
H := KeyCode.(9)
|
||||
I := KeyCode.(10)
|
||||
J := KeyCode.(11)
|
||||
K := KeyCode.(12)
|
||||
L := KeyCode.(13)
|
||||
M := KeyCode.(14)
|
||||
N := KeyCode.(15)
|
||||
O := KeyCode.(16)
|
||||
P := KeyCode.(17)
|
||||
Q := KeyCode.(18)
|
||||
R := KeyCode.(19)
|
||||
S := KeyCode.(20)
|
||||
T := KeyCode.(21)
|
||||
U := KeyCode.(22)
|
||||
V := KeyCode.(23)
|
||||
W := KeyCode.(24)
|
||||
X := KeyCode.(25)
|
||||
Y := KeyCode.(26)
|
||||
Z := KeyCode.(27)
|
||||
|
||||
/* Numeric keycodes*/
|
||||
|
||||
Number0 := KeyCode.(28)
|
||||
Number1 := KeyCode.(29)
|
||||
Number2 := KeyCode.(30)
|
||||
Number3 := KeyCode.(31)
|
||||
Number4 := KeyCode.(32)
|
||||
Number5 := KeyCode.(33)
|
||||
Number6 := KeyCode.(34)
|
||||
Number7 := KeyCode.(35)
|
||||
Number8 := KeyCode.(36)
|
||||
Number9 := KeyCode.(37)
|
||||
|
||||
KeypadNumber0 := KeyCode.(38)
|
||||
KeypadNumber1 := KeyCode.(39)
|
||||
KeypadNumber2 := KeyCode.(40)
|
||||
KeypadNumber3 := KeyCode.(41)
|
||||
KeypadNumber4 := KeyCode.(42)
|
||||
KeypadNumber5 := KeyCode.(43)
|
||||
KeypadNumber6 := KeyCode.(44)
|
||||
KeypadNumber7 := KeyCode.(45)
|
||||
KeypadNumber8 := KeyCode.(46)
|
||||
KeypadNumber9 := KeyCode.(47)
|
||||
|
||||
KeypadPeriod := KeyCode.(48)
|
||||
KeypadDivide := KeyCode.(49)
|
||||
KeypadMultiply := KeyCode.(50)
|
||||
KeypadMinus := KeyCode.(51)
|
||||
KeypadPlus := KeyCode.(52)
|
||||
KeypadEnter := KeyCode.(53)
|
||||
KeypadEquals := KeyCode.(54)
|
||||
|
||||
Delete := KeyCode.(55)
|
||||
/* Locking Keys */
|
||||
NumLock := KeyCode.(56)
|
||||
CapsLock := KeyCode.(57)
|
||||
ScrollLock := KeyCode.(58)
|
||||
|
||||
/* "Alt Gr" key */
|
||||
Mode := KeyCode.(59)
|
||||
|
||||
/* Multi-key compose key */
|
||||
Compose := KeyCode.(60)
|
||||
|
||||
LeftAlt := KeyCode.(61)
|
||||
LeftControl := KeyCode.(62)
|
||||
LeftMeta := KeyCode.(63)
|
||||
LeftShift := KeyCode.(64)
|
||||
/* Left "Windows" key */
|
||||
LeftSuper := KeyCode.(65)
|
||||
|
||||
RightAlt := KeyCode.(66)
|
||||
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)
|
|
@ -5,21 +5,15 @@ keycodes := @use("keycodes.hb")
|
|||
events := @use("events.hb");
|
||||
.{KeyEvent, MouseEvent} := events
|
||||
|
||||
key_buf := 0
|
||||
mouse_buf := 0
|
||||
|
||||
recieve_key_event := fn(): ?KeyEvent {
|
||||
kevent := KeyEvent.{}
|
||||
kevent := KeyEvent.(false, false, 0)
|
||||
|
||||
if key_buf == 0 {
|
||||
key_buf = buffer.search("PS/2 Keyboard")
|
||||
if key_buf == 0 return null
|
||||
}
|
||||
buf_id := buffer.search("PS/2 Keyboard")
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
|
@ -27,17 +21,14 @@ recieve_key_event := fn(): ?KeyEvent {
|
|||
}
|
||||
|
||||
recieve_mouse_event := fn(): ?MouseEvent {
|
||||
mevent := MouseEvent.{}
|
||||
mevent := MouseEvent.(0, 0, false, false, false)
|
||||
|
||||
if mouse_buf == 0 {
|
||||
mouse_buf = buffer.search("PS/2 Mouse")
|
||||
if mouse_buf == 0 return null
|
||||
}
|
||||
buf_id := buffer.search("PS/2 Mouse")
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! This is a reserved file for use with the AbleOS Clustering System
|
||||
|
||||
HostID := uint
|
||||
ID := uint
|
||||
HostID := int
|
||||
ID := int
|
||||
|
||||
FileID := struct {
|
||||
host_id: HostID,
|
||||
|
@ -23,10 +23,6 @@ BufferID := struct {
|
|||
ProcessID := struct {
|
||||
host_id: HostID,
|
||||
id: ID,
|
||||
|
||||
new := fn(hid: uint, pid: uint): Self {
|
||||
return Self.(hid, pid)
|
||||
}
|
||||
}
|
||||
|
||||
WindowID := struct {
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
acs := @use("acs.hb");
|
||||
.{ProcessID} := acs
|
||||
|
||||
// returns PID
|
||||
spawn := fn(proc_exe: ^u8, length: uint): ProcessID {
|
||||
pid_ := @as(uint, @eca(3, 6, proc_exe, length))
|
||||
|
||||
pid := ProcessID.new(0, pid_)
|
||||
return pid
|
||||
$spawn := fn(proc_exe: ^u8, length: uint): uint {
|
||||
return @eca(3, 6, proc_exe, length)
|
||||
}
|
||||
|
||||
// returns: 0 if child process, child PID if parent process
|
||||
|
|
|
@ -4,4 +4,16 @@ $subscribe_to_interrupt := fn(interrupt_number: u8): bool {
|
|||
// Pauses execution until the interrupt occures
|
||||
$sleep_until_interrupt := fn(interrupt_number: u8): void {
|
||||
@eca(6, interrupt_number)
|
||||
}
|
||||
|
||||
//InterruptGuard := struct {}
|
||||
|
||||
// Disables recieving interrupts..
|
||||
$disable_interrupts := fn(): void {
|
||||
@eca(8, false)
|
||||
}
|
||||
|
||||
// Enables recieving interrupts..
|
||||
$enable_interrupts := fn(): void {
|
||||
@eca(8, true)
|
||||
}
|
|
@ -20,32 +20,21 @@ main := fn(): void {
|
|||
return
|
||||
}
|
||||
|
||||
text_label_1 := Label.new_label("kernel : akern 0.2.0", 300)
|
||||
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_4 := Label.new_label("theme : sunset-colors", 300)
|
||||
text_label_5 := Label.new_label("font : tamsyn@10x20", 300)
|
||||
text_label.set_color(render.BLACK, render.WHITE)
|
||||
|
||||
|
||||
text_label_1.set_color(render.BLACK, render.WHITE)
|
||||
text_label_2.set_color(render.BLACK, render.WHITE)
|
||||
text_label_3.set_color(render.BLACK, render.WHITE)
|
||||
text_label_4.set_color(render.BLACK, render.WHITE)
|
||||
text_label_5.set_color(render.BLACK, render.WHITE)
|
||||
|
||||
|
||||
pos1 := Vec2(uint).(1, 1)
|
||||
pos2 := Vec2(uint).(1, 20)
|
||||
pos3 := Vec2(uint).(1, 40)
|
||||
pos4 := Vec2(uint).(1, 60)
|
||||
pos5 := Vec2(uint).(1, 80)
|
||||
|
||||
render_label_to_surface(window.surface, text_label_1, font, pos1)
|
||||
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)
|
||||
render_label_to_surface(window.surface, text_label_4, font, pos4)
|
||||
render_label_to_surface(window.surface, text_label_5, font, pos5)
|
||||
|
||||
loop {
|
||||
// stn.log.info("AAAA")
|
||||
_ = sunset.client.send_frame(window)
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
# adit
|
|
@ -1,11 +0,0 @@
|
|||
[package]
|
||||
name = "adit"
|
||||
authors = [""]
|
||||
|
||||
[dependants.libraries]
|
||||
|
||||
[dependants.binaries]
|
||||
hblang.version = "1.0.0"
|
||||
|
||||
[build]
|
||||
command = "hblang src/main.hb"
|
|
@ -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 +0,0 @@
|
|||
# ascii_game
|
|
@ -1,11 +0,0 @@
|
|||
[package]
|
||||
name = "ascii_game"
|
||||
authors = [""]
|
||||
|
||||
[dependants.libraries]
|
||||
|
||||
[dependants.binaries]
|
||||
hblang.version = "1.0.0"
|
||||
|
||||
[build]
|
||||
command = "hblang src/main.hb"
|
|
@ -1,21 +0,0 @@
|
|||
.{log} := @use("stn")
|
||||
sunset := @use("lib:sunset_proto")
|
||||
render := @use("lib:render")
|
||||
|
||||
|
||||
main := fn(): int {
|
||||
sunset.client.find_server()
|
||||
|
||||
window := sunset.client.new(.(.(400, 400), .(200, 200), "Ascii Game"))
|
||||
|
||||
if window == null {
|
||||
log.error("got no window")
|
||||
return 0
|
||||
}
|
||||
|
||||
loop {
|
||||
window.surface.clear(render.BLACK)
|
||||
_ = sunset.client.send_frame(window)
|
||||
}
|
||||
return 0
|
||||
}
|
|
@ -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,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,150 +1,5 @@
|
|||
.{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
|
||||
}
|
||||
Port := @use("port.hb").Port;
|
||||
|
||||
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 +1,52 @@
|
|||
.{DeviceID, NO_DEVICE} := @use("devices.hb")
|
||||
log := @use("stn:log")
|
||||
|
||||
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,
|
||||
|
||||
Uninitialized := struct {
|
||||
|
||||
}
|
||||
|
||||
$PORT_AT_STARTUP := Port.(
|
||||
true,
|
||||
NO_DEVICE,
|
||||
.[0, 0, 0, 0, 0, 0, 0, 0],
|
||||
0,
|
||||
true,
|
||||
)
|
||||
ThreeButtonMouse := struct {
|
||||
|
||||
}
|
||||
|
||||
ScrollMouse := struct {
|
||||
|
||||
}
|
||||
|
||||
FiveButtonMouse := struct {
|
||||
|
||||
}
|
||||
|
||||
Keyboard := struct {
|
||||
|
||||
}
|
||||
|
||||
DeviceType := enum {
|
||||
None,
|
||||
Uninitialized,
|
||||
ThreeButtonMouse,
|
||||
ScrollMouse,
|
||||
FiveButtonMouse,
|
||||
Keyboard,
|
||||
}
|
||||
|
||||
Port := struct {
|
||||
device_type: DeviceType,
|
||||
_: union {
|
||||
uninitialized: Uninitialized,
|
||||
three_button_mouse: ThreeButtonMouse,
|
||||
scroll_mouse: ScrollMouse,
|
||||
five_button_mouse: FiveButtonMouse,
|
||||
keyboard: Keyboard,
|
||||
},
|
||||
recive_byte := fn(self: Self, byte: u8): void {
|
||||
match self.device_type {
|
||||
.Uninitialized => @inline(self._.uninitialized.recive_byte, byte)
|
||||
.ThreeButtonMouse => @inline(self._.three_button_mouse.recive_byte, byte)
|
||||
.ScrollMouse => @inline(self._.scroll_mouse.recive_byte, byte)
|
||||
.FiveButtonMouse => @inline(self._.five_button_mouse.recive_byte, byte)
|
||||
.Keyboard => @inline(self._.keyboard.recive_byt, byte)
|
||||
}
|
||||
},
|
||||
}
|
23
sysdata/programs/ps2_driver_retired/README.md
Normal file
23
sysdata/programs/ps2_driver_retired/README.md
Normal file
|
@ -0,0 +1,23 @@
|
|||
# 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,6 +1,6 @@
|
|||
[package]
|
||||
name = "sketchpad"
|
||||
authors = [""]
|
||||
name = "ps2_driver"
|
||||
authors = ["Peony"]
|
||||
|
||||
[dependants.libraries]
|
||||
|
101
sysdata/programs/ps2_driver_retired/src/controller.hb
Normal file
101
sysdata/programs/ps2_driver_retired/src/controller.hb
Normal file
|
@ -0,0 +1,101 @@
|
|||
.{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
|
||||
|
||||
//These are implementations of a few simple controller commands.
|
||||
$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
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
}
|
150
sysdata/programs/ps2_driver_retired/src/main.hb
Normal file
150
sysdata/programs/ps2_driver_retired/src/main.hb
Normal file
|
@ -0,0 +1,150 @@
|
|||
.{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
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
21
sysdata/programs/ps2_driver_retired/src/port.hb
Normal file
21
sysdata/programs/ps2_driver_retired/src/port.hb
Normal file
|
@ -0,0 +1,21 @@
|
|||
.{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,
|
||||
)
|
|
@ -1,73 +0,0 @@
|
|||
intouch := @use("lib:intouch")
|
||||
render := @use("lib:render")
|
||||
stn := @use("stn")
|
||||
|
||||
mouse_pos := stn.math.Vec2(int).(0, 0)
|
||||
mouse_event := @as(?intouch.MouseEvent, null)
|
||||
global_lock := false
|
||||
|
||||
DraggableSurface := struct {
|
||||
pos: stn.math.Vec2(int),
|
||||
surface: render.Surface,
|
||||
lock: bool,
|
||||
process := fn(self: ^Self, screen: ^render.Surface): void {
|
||||
screen.put_surface(self.surface, @bitcast(self.pos), false)
|
||||
// funny hblang bug means need to check for boolean equality
|
||||
if global_lock | @unwrap(mouse_event).left {
|
||||
if self.lock == true return
|
||||
}
|
||||
if mouse_pos.x >= self.pos.x & mouse_pos.x <= self.pos.x + @bitcast(self.surface.width) & mouse_pos.y >= self.pos.y & mouse_pos.y <= self.pos.y + @bitcast(self.surface.height) {
|
||||
global_lock = true
|
||||
self.lock = false
|
||||
if @unwrap(mouse_event).left {
|
||||
self.pos = .(
|
||||
stn.math.clamp(int, self.pos.x + @unwrap(mouse_event).x_change, 1, @bitcast(screen.width) - @bitcast(self.surface.width) - 1),
|
||||
stn.math.clamp(int, self.pos.y - @unwrap(mouse_event).y_change, 1, @bitcast(screen.height) - @bitcast(self.surface.height) - 1),
|
||||
)
|
||||
screen.put_rect(@bitcast(self.pos), .(self.surface.width, self.surface.height), render.RED)
|
||||
} else {
|
||||
screen.put_rect(@bitcast(self.pos), .(self.surface.width, self.surface.height), render.CYAN)
|
||||
}
|
||||
} else {
|
||||
global_lock = false
|
||||
self.lock = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
example := fn(): void {
|
||||
screen := render.init(true)
|
||||
image := render.image.from(@bitcast(&@embed("sysdata:assets/mini.qoi")))
|
||||
image2 := render.image.from(@bitcast(&@embed("sysdata:assets/able.bmp")))
|
||||
if image == null | image2 == null {
|
||||
stn.log.error("failed to load images for whatever reason")
|
||||
return
|
||||
}
|
||||
|
||||
thing := DraggableSurface.(
|
||||
.(400, 400),
|
||||
image,
|
||||
false,
|
||||
)
|
||||
|
||||
thing2 := DraggableSurface.(
|
||||
.(0, 0),
|
||||
image2,
|
||||
false,
|
||||
)
|
||||
|
||||
loop {
|
||||
mouse_event = intouch.recieve_mouse_event()
|
||||
if mouse_event == null continue
|
||||
mouse_pos.x = stn.math.clamp(int, mouse_pos.x + mouse_event.x_change, 6, @bitcast(screen.width) - 6)
|
||||
mouse_pos.y = stn.math.clamp(int, mouse_pos.y - @unwrap(mouse_event).y_change, 6, @bitcast(screen.height) - 6)
|
||||
|
||||
thing.process(&screen)
|
||||
thing2.process(&screen)
|
||||
|
||||
screen.put_filled_circle(@bitcast(mouse_pos), 5, render.BLACK)
|
||||
|
||||
screen.sync()
|
||||
screen.clear(render.GRAY)
|
||||
}
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
intouch := @use("lib:intouch")
|
||||
render := @use("lib:render")
|
||||
stn := @use("stn")
|
||||
|
||||
example := fn(): void {
|
||||
screen := render.init(true)
|
||||
mouse_pos := stn.math.Vec2(int).(0, 0)
|
||||
bg_colour := render.BLACK
|
||||
pen_colour := render.WHITE
|
||||
loop {
|
||||
mouse := intouch.recieve_mouse_event()
|
||||
if mouse != null {
|
||||
mouse_pos.x = stn.math.clamp(int, mouse_pos.x + mouse.x_change, 10, @bitcast(screen.width) - 10)
|
||||
mouse_pos.y = stn.math.clamp(int, mouse_pos.y - mouse.y_change, 10, @bitcast(screen.height) - 10)
|
||||
|
||||
if mouse.left {
|
||||
screen.put_filled_circle(@bitcast(mouse_pos), 10, pen_colour)
|
||||
} else if mouse.right {
|
||||
screen.put_filled_circle(@bitcast(mouse_pos), 10, bg_colour)
|
||||
} else if mouse.middle {
|
||||
pen_colour = *screen.indexptr(@bitcast(mouse_pos.x), @bitcast(mouse_pos.y))
|
||||
}
|
||||
}
|
||||
|
||||
kb := intouch.recieve_key_event()
|
||||
if kb != null {
|
||||
if kb.just_triggered {
|
||||
if kb.key == intouch.keycodes.NUMBER1 {
|
||||
pen_colour = render.WHITE
|
||||
} else if kb.key == intouch.keycodes.NUMBER2 {
|
||||
pen_colour = render.BLACK
|
||||
} else if kb.key == intouch.keycodes.NUMBER3 {
|
||||
pen_colour = render.RED
|
||||
} else if kb.key == intouch.keycodes.NUMBER4 {
|
||||
pen_colour = render.YELLOW
|
||||
} else if kb.key == intouch.keycodes.NUMBER5 {
|
||||
pen_colour = render.BLUE
|
||||
} else if kb.key == intouch.keycodes.NUMBER6 {
|
||||
pen_colour = render.CYAN
|
||||
} else if kb.key == intouch.keycodes.NUMBER7 {
|
||||
pen_colour = render.GREEN
|
||||
} else if kb.key == intouch.keycodes.NUMBER8 {
|
||||
pen_colour = render.MAGENTA
|
||||
} else if kb.key == intouch.keycodes.NUMBER9 {
|
||||
pen_colour = render.GRAY
|
||||
} else if kb.key == intouch.keycodes.NUMBER0 {
|
||||
pen_colour = stn.random.any(render.Color)
|
||||
} else {
|
||||
bg_colour = stn.random.any(render.Color)
|
||||
screen.clear(bg_colour)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
screen.sync()
|
||||
}
|
||||
}
|
|
@ -1 +1 @@
|
|||
.{example: main} := @use("./examples/intouch.hb")
|
||||
.{example: main} := @use("./examples/mandelbrot.hb")
|
|
@ -1,12 +1,89 @@
|
|||
stn := @use("stn");
|
||||
.{sleep, log, memory} := stn
|
||||
|
||||
main := fn(): int {
|
||||
loop {
|
||||
log.info("BEFORE")
|
||||
sleep.sleep_until_interrupt(8)
|
||||
log.info("AFTER")
|
||||
$decode_bcd := fn(value: u8): u8 {
|
||||
return (value & 0xF) + ((value & 0xF0) >> 4) * 10
|
||||
}
|
||||
|
||||
read_register := fn(register: u8): u8 {
|
||||
memory.outb(0x70, register | 0x80)
|
||||
return memory.inb(0x71)
|
||||
}
|
||||
|
||||
$MONTH_TABLE := uint.[
|
||||
267840000,
|
||||
0,
|
||||
267840000,
|
||||
259200000,
|
||||
267840000,
|
||||
259200000,
|
||||
267840000,
|
||||
267840000,
|
||||
259200000,
|
||||
267840000,
|
||||
259200000,
|
||||
267840000,
|
||||
]
|
||||
|
||||
fetch_time := fn(): uint {
|
||||
sleep.disable_interrupts()
|
||||
|
||||
format := read_register(0xB)
|
||||
|
||||
second := read_register(0x0)
|
||||
minute := read_register(0x2)
|
||||
hour := read_register(0x4)
|
||||
week := read_register(0x6)
|
||||
day := read_register(0x7)
|
||||
month := read_register(0x8)
|
||||
year := read_register(0x9)
|
||||
|
||||
century := @as(u8, 0x20)
|
||||
if (format & 4) == 4 {
|
||||
century = 20
|
||||
}
|
||||
if read_register(0x6C) != 0 {
|
||||
century = read_register(0x32)
|
||||
}
|
||||
|
||||
return 0
|
||||
sleep.enable_interrupts()
|
||||
|
||||
if (format & 4) != 4 {
|
||||
second = decode_bcd(second)
|
||||
minute = decode_bcd(minute)
|
||||
hour = decode_bcd(hour & 0b1111111)
|
||||
day = decode_bcd(day)
|
||||
month = decode_bcd(month)
|
||||
year = decode_bcd(year)
|
||||
century = decode_bcd(century)
|
||||
}
|
||||
|
||||
if (format & 2) != 2 & (hour & 0x80) == 0x80 {
|
||||
hour = hour & 0b1111111 + 12
|
||||
}
|
||||
|
||||
log.printf("{}-{}-{} at {}:{}:{}", .(@as(u16, year) + @as(u16, century) * 100, month, day, hour, minute, second), .{})
|
||||
|
||||
delta_epoch := @as(uint, year) + @as(uint, century) * 100 - 1970
|
||||
result := (second + (minute + @as(uint, hour) * 60) * 60) * 100 + delta_epoch * 3155692608
|
||||
test_month := 1
|
||||
loop if test_month == month break else {
|
||||
if test_month == 2 {
|
||||
if year % 4 == 0 & year % 100 != 0 | year % 400 == 0 {
|
||||
result += 250560000
|
||||
} else {
|
||||
result += 241920000
|
||||
}
|
||||
} else {
|
||||
result += MONTH_TABLE[test_month]
|
||||
}
|
||||
test_month += 1
|
||||
}
|
||||
result += @as(uint, day - 1) * 8640000
|
||||
|
||||
return result / 100
|
||||
}
|
||||
|
||||
main := fn(): void {
|
||||
log.print(fetch_time(), .{})
|
||||
}
|
48
sysdata/programs/rtc_driver/src/main_legacy.hb
Normal file
48
sysdata/programs/rtc_driver/src/main_legacy.hb
Normal file
|
@ -0,0 +1,48 @@
|
|||
stn := @use("stn");
|
||||
.{sleep, log, memory} := stn
|
||||
|
||||
microseconds := @as(u32, 0)
|
||||
seconds := @as(uint, 0)
|
||||
|
||||
padding := fn(): void {
|
||||
iter := 0
|
||||
loop if iter == 0xFFFF break else iter += 1
|
||||
}
|
||||
|
||||
read_register := fn(register: u8): u8 {
|
||||
memory.outb(0x70, register)
|
||||
padding()
|
||||
return memory.inb(0x71)
|
||||
}
|
||||
|
||||
write_register := fn(register: u8, value: u8): void {
|
||||
memory.outb(0x70, register)
|
||||
padding()
|
||||
memory.outb(0x71, value)
|
||||
}
|
||||
|
||||
main := fn(): void {
|
||||
sleep.disable_interrupts()
|
||||
|
||||
reg_a := read_register(0x8A)
|
||||
write_register(0x8A, 3 | 0xF0 & reg_a)
|
||||
|
||||
log.print(read_register(0x86), log.fmt.FormatOptions.(2, 10, log.LogLevel.Info))
|
||||
|
||||
reg_b := read_register(0x8B)
|
||||
write_register(0xB, 0x40 | reg_b)
|
||||
|
||||
sleep.enable_interrupts()
|
||||
|
||||
loop {
|
||||
sleep.sleep_until_interrupt(8)
|
||||
read_register(0xC)
|
||||
|
||||
microseconds += 122
|
||||
if microseconds >= 1000000 {
|
||||
microseconds -= 1000000
|
||||
seconds += 1
|
||||
}
|
||||
log.print(seconds, log.fmt.FormatOptions.(2, 10, log.LogLevel.Info))
|
||||
}
|
||||
}
|
|
@ -5,8 +5,14 @@ stn := @use("stn");
|
|||
.{log} := stn;
|
||||
.{Vec2} := stn.math
|
||||
|
||||
player := @use("player.hb");
|
||||
.{Player} := player;
|
||||
Player := struct {
|
||||
x: i8,
|
||||
y: i8,
|
||||
|
||||
$new := fn(x: i8, y: i8): Self {
|
||||
return Self.(x, y)
|
||||
}
|
||||
}
|
||||
|
||||
GameState := struct {
|
||||
player: Player,
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
|
||||
Player := struct {
|
||||
x: i8,
|
||||
y: i8,
|
||||
|
||||
$new := fn(x: i8, y: i8): Self {
|
||||
return Self.(x, y)
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
# sketchpad
|
|
@ -1,74 +0,0 @@
|
|||
sunset := @use("lib:sunset_proto")
|
||||
intouch := @use("lib:intouch")
|
||||
render := @use("lib:render")
|
||||
stn := @use("stn");
|
||||
.{log} := stn;
|
||||
|
||||
Tools := struct {
|
||||
pen_size: u8 = 10,
|
||||
bg_colour: render.Color = render.WHITE,
|
||||
pen_colour: render.Color = render.BLACK,
|
||||
}
|
||||
|
||||
main := fn(): void {
|
||||
tools := Tools.{}
|
||||
|
||||
sunset.client.find_server()
|
||||
|
||||
window := sunset.client.new(.(.(600, 400), .(200, 200), "Sketch Pad"))
|
||||
if window == null {
|
||||
log.error("got no window")
|
||||
return
|
||||
}
|
||||
window.surface.clear(tools.bg_colour)
|
||||
|
||||
mouse_pos := stn.math.Vec2(int).(0, 0)
|
||||
|
||||
loop {
|
||||
mouse := intouch.recieve_mouse_event()
|
||||
if mouse != null {
|
||||
mouse_pos.x = stn.math.clamp(int, mouse_pos.x + mouse.x_change, tools.pen_size, @bitcast(window.surface.width) - tools.pen_size)
|
||||
mouse_pos.y = stn.math.clamp(int, mouse_pos.y - mouse.y_change, tools.pen_size, @bitcast(window.surface.height) - tools.pen_size)
|
||||
|
||||
if mouse.left {
|
||||
window.surface.put_filled_circle(@bitcast(mouse_pos), tools.pen_size, tools.pen_colour)
|
||||
} else if mouse.right {
|
||||
window.surface.put_filled_circle(@bitcast(mouse_pos), tools.pen_size, tools.bg_colour)
|
||||
} else if mouse.middle {
|
||||
tools.pen_colour = *window.surface.indexptr(@bitcast(mouse_pos.x), @bitcast(mouse_pos.y))
|
||||
}
|
||||
}
|
||||
|
||||
kb := intouch.recieve_key_event()
|
||||
if kb != null {
|
||||
if kb.just_triggered {
|
||||
if kb.key == intouch.keycodes.NUMBER1 {
|
||||
tools.pen_colour = render.WHITE
|
||||
} else if kb.key == intouch.keycodes.NUMBER2 {
|
||||
tools.pen_colour = render.BLACK
|
||||
} else if kb.key == intouch.keycodes.NUMBER3 {
|
||||
tools.pen_colour = render.RED
|
||||
} else if kb.key == intouch.keycodes.NUMBER4 {
|
||||
tools.pen_colour = render.YELLOW
|
||||
} else if kb.key == intouch.keycodes.NUMBER5 {
|
||||
tools.pen_colour = render.BLUE
|
||||
} else if kb.key == intouch.keycodes.NUMBER6 {
|
||||
tools.pen_colour = render.CYAN
|
||||
} else if kb.key == intouch.keycodes.NUMBER7 {
|
||||
tools.pen_colour = render.GREEN
|
||||
} else if kb.key == intouch.keycodes.NUMBER8 {
|
||||
tools.pen_colour = render.MAGENTA
|
||||
} else if kb.key == intouch.keycodes.NUMBER9 {
|
||||
tools.pen_colour = render.GRAY
|
||||
} else if kb.key == intouch.keycodes.NUMBER0 {
|
||||
tools.pen_colour = stn.random.any(render.Color)
|
||||
} else {
|
||||
tools.bg_colour = stn.random.any(render.Color)
|
||||
window.surface.clear(tools.bg_colour)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_ = sunset.client.send_frame(window)
|
||||
}
|
||||
}
|
|
@ -26,13 +26,13 @@ Mouse := struct {
|
|||
|
||||
return Self.(@bitcast(center_x), @bitcast(center_y), 3, max_x, max_y)
|
||||
}
|
||||
/*
|
||||
center := fn(self: Self){
|
||||
center_x := max_x / 2
|
||||
center_y := max_y / 2
|
||||
|
||||
// center := fn(self: Self): Self {
|
||||
// center_x := self.max_x / 2
|
||||
// center_y := self.max_y / 2
|
||||
|
||||
// return Self.(center_x, center_y, 3, self.max_x, self.max_y)
|
||||
// }
|
||||
return Self.(center_x, center_y, 3, max_x, max_y)
|
||||
}*/
|
||||
}
|
||||
|
||||
main := fn(): int {
|
||||
|
@ -55,25 +55,25 @@ main := fn(): int {
|
|||
// mouse_y := 100
|
||||
|
||||
mouse := Mouse.new(screen.width, screen.height)
|
||||
// mouse.center()
|
||||
//mouse.center()
|
||||
|
||||
text_label := Label.new_label("", 1024)
|
||||
text_label.set_color(sunset.server.DECO_COLOUR, render.BLACK)
|
||||
|
||||
loop {
|
||||
// mouse_event := intouch.recieve_mouse_event()
|
||||
// if mouse_event != null {
|
||||
// mouse.x = clamp(int, mouse.x + mouse_event.x_change, mouse.cursor_width + 1, @bitcast(screen.width - mouse.cursor_width - 1))
|
||||
// mouse.y = clamp(int, mouse.y - mouse_event.y_change, mouse.cursor_width + 1, @bitcast(screen.height - mouse.cursor_width - 1))
|
||||
mouse_event := intouch.recieve_mouse_event()
|
||||
if mouse_event != null {
|
||||
mouse.x = clamp(int, mouse.x + mouse_event.x_change, mouse.cursor_width, @bitcast(screen.width - mouse.cursor_width))
|
||||
mouse.y = clamp(int, mouse.y - mouse_event.y_change, mouse.cursor_width, @bitcast(screen.height - mouse.cursor_width))
|
||||
|
||||
// if mouse_event.left {
|
||||
// text_label.set_label_text("LEFT CLICK")
|
||||
// } else if mouse_event.middle {
|
||||
// text_label.set_label_text("MIDDLE CLICK")
|
||||
// } else if mouse_event.right {
|
||||
// text_label.set_label_text("RIGHT CLICK")
|
||||
// }
|
||||
// }
|
||||
if mouse_event.left {
|
||||
text_label.set_label_text("LEFT CLICK")
|
||||
} else if mouse_event.middle {
|
||||
text_label.set_label_text("MIDDLE CLICK")
|
||||
} else if mouse_event.right {
|
||||
text_label.set_label_text("RIGHT CLICK")
|
||||
}
|
||||
}
|
||||
{
|
||||
screen.put_surface(wallpaper, .(0, 0), false)
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
.{log, sleep} := @use("stn")
|
||||
|
||||
main := fn(): void {
|
||||
log.info("Hello, World!")
|
||||
// fake interrupt, sleep forever
|
||||
sleep.sleep_until_interrupt(100)
|
||||
}
|
|
@ -5,11 +5,13 @@
|
|||
* assume that `*a` never changes (program doesnt work otherwise)
|
||||
* (this is a reason why memory sharing is bad)
|
||||
*/
|
||||
opaque := fn(ptr: ^bool): bool {
|
||||
return *ptr
|
||||
}
|
||||
|
||||
// axe := @embed("assets/lily.axe")
|
||||
|
||||
test := fn(): uint {
|
||||
// causes segfault on fakern due to hblang soundness :thumbsup:
|
||||
// process.spawn(@bitcast(&axe), @sizeof(@TypeOf(axe)))
|
||||
|
||||
a: ^bool = @bitcast(memory.request_page(1, true))
|
||||
|
@ -20,8 +22,8 @@ test := fn(): uint {
|
|||
if x == 0 {
|
||||
// ! NOTE: NEVER DO THIS!!! USE BUFFERS INSTEAD!!! :)
|
||||
// acts as a lock. when parent is done, this can go ahead.
|
||||
loop if *a break else {
|
||||
};
|
||||
loop if opaque(a) break else {
|
||||
}
|
||||
log.info("child done.")
|
||||
} else {
|
||||
*a = true
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
# test_framework
|
|
@ -1,11 +0,0 @@
|
|||
[package]
|
||||
name = "test_framework"
|
||||
authors = [""]
|
||||
|
||||
[dependants.libraries]
|
||||
|
||||
[dependants.binaries]
|
||||
hblang.version = "1.0.0"
|
||||
|
||||
[build]
|
||||
command = "hblang src/main.hb"
|
|
@ -1,35 +0,0 @@
|
|||
stn := @use("stn")
|
||||
|
||||
main := fn(): int {
|
||||
|
||||
exe := u8.[
|
||||
0x15, 145, 210,
|
||||
0, 0, 0, 0,
|
||||
2, 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,
|
||||
85, 0
|
||||
]
|
||||
|
||||
test(@bitcast(&exe), 49)
|
||||
|
||||
loop{}
|
||||
return 0
|
||||
}
|
||||
|
||||
assert_eq := fn(lhs: bool, rhs: bool): bool {
|
||||
lhs == rhs
|
||||
}
|
||||
|
||||
assert_neq := fn(lhs: bool, rhs: bool): bool {
|
||||
lhs != rhs
|
||||
}
|
||||
|
||||
test := fn(exe_data: ^u8, exe_size: uint): uint {
|
||||
// TODO: Spawn new process
|
||||
pid := @inline(stn.process.spawn, exe_data, exe_size)
|
||||
stn.log.info("PID")
|
||||
return 0
|
||||
}
|
114
sysdata/system.lisp
Normal file
114
sysdata/system.lisp
Normal file
|
@ -0,0 +1,114 @@
|
|||
;;;;;;;;;;;
|
||||
;; Repos ;;
|
||||
;;;;;;;;;;;
|
||||
|
||||
;; This is the core repo that is used for core things like networking ;;
|
||||
(use-repo core "https://repo.ablecorp.us/core")
|
||||
;; Add a secondary repo ;;
|
||||
;; (use-repo able "https://repo.ablecorp.us/able")
|
||||
|
||||
;; Set the default pkg-install to be binary ;;
|
||||
(pkg-defaults binary:true)
|
||||
|
||||
;; Install compilers ;;
|
||||
;; pkg-install <repo> <pkg-name>
|
||||
;; pkg-name : A string or atom to search.
|
||||
(pkg-install core hblang2)
|
||||
;; Install the rust compiler ;;
|
||||
(pkg-install core rustc)
|
||||
(pkg-install core clang)
|
||||
|
||||
;;;;;;;;;;;;;;;
|
||||
;; Compilers ;;
|
||||
;;;;;;;;;;;;;;;
|
||||
|
||||
;; Set default compilers to use ;;
|
||||
;; the dev tool pulls from this ;;
|
||||
(compilers
|
||||
hblang: 'hblang2
|
||||
rust: 'rustc
|
||||
;; Clang is not supported :thumbsup:
|
||||
;; c: 'clang
|
||||
)
|
||||
|
||||
;;;;;;;;;;;;;;;;;
|
||||
;; Boot Loader ;;
|
||||
;;;;;;;;;;;;;;;;;
|
||||
(pkg-install core limine)
|
||||
|
||||
(def limine_res (resolution 1024 768 24))
|
||||
(boot-loader
|
||||
default-entry:1
|
||||
timeout:0
|
||||
interface_resolution: 'limine_res)
|
||||
|
||||
(boot-loader-entry "ableos"
|
||||
comment: "Default AbleOS boot entry."
|
||||
protocol: "limine"
|
||||
kernel_path: "boot:///kernel_${ARCH}"
|
||||
kernel_cmdline: ""
|
||||
resolution: 'limine_res)
|
||||
|
||||
(boot-loader-entry "ableos-no-cluster"
|
||||
comment: "Default AbleOS boot entry."
|
||||
protocol: "limine"
|
||||
kernel_path: "boot:///kernel_${ARCH}"
|
||||
kernel_cmdline: "cluster=false"
|
||||
resolution: 'limine_res)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;
|
||||
;; Kernel Options ;;
|
||||
;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; A kernel package is required
|
||||
(pkg-install core kernel-rust)
|
||||
|
||||
;; Set the kernel to be used by ableOS ;;
|
||||
;; Maybe set a default if this isn't set? ;;
|
||||
;; Must be installed already ;;
|
||||
(kernel 'kernel-rust)
|
||||
|
||||
;;;;;;;;;;;;
|
||||
;; Config ;;
|
||||
;;;;;;;;;;;;
|
||||
|
||||
;; Install packages ;;
|
||||
(pkg-install core sunset)
|
||||
(pkg-install core ps2-driver)
|
||||
|
||||
;; A list of programs to run on startup ;;
|
||||
(start '())
|
||||
|
||||
;; A list of programs to add to the driver supervisor ;;
|
||||
(start-driver '(ps2-driver))
|
||||
|
||||
;; Set the window system to be used by ableOS ;;
|
||||
;; Must be installed already ;;
|
||||
;; adds the window system to the driver supervisor ;;
|
||||
;; (def window-system (fn (a) (start-driver a)))
|
||||
(window-system 'sunset)
|
||||
|
||||
;;;;;;;;;;;;;;;;
|
||||
;; Networking ;;
|
||||
;;;;;;;;;;;;;;;;
|
||||
|
||||
(networking
|
||||
;; set the network hostname
|
||||
;; TODO Namespace this somehow ;;
|
||||
(hostname "ableOS")
|
||||
;; use dhcp to find an ip ;;
|
||||
(ipv4 dhcp)
|
||||
(ipv6 dhcp)
|
||||
;; Set the time server ;;
|
||||
(ntp "time.nist.gov")
|
||||
(dns 'router-dns-steal))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Cluster Software ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; Install the cluster software ;;
|
||||
(pkg-install core cluster)
|
||||
|
||||
;; Defaults to false ;;
|
||||
(cluster enabled:false)
|
|
@ -1,71 +0,0 @@
|
|||
;; If passed into a use-repo function this will
|
||||
;; download source code and build it.
|
||||
(def use-sources true)
|
||||
;; Set to false so that binaries are downloaded.
|
||||
(def use-binaries false)
|
||||
|
||||
(def system-path "sample")
|
||||
;;;;;;;;;;;;;;;;;;
|
||||
;; REPOSITORIES ;;
|
||||
;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(use-repo :core "https://repo.ablecorp.us/core" use-sources)
|
||||
;; another repo example.
|
||||
(use-repo :games "https://repo.ablecorp.us/games" use-binaries)
|
||||
(use-repo :personal "https://repo.ablecorp.us/able-personal" use-sources)
|
||||
|
||||
;; Treat a path like a repo
|
||||
(use-repo-path :src "sysdata/")
|
||||
|
||||
;;;;;;;;;;;;;;;;
|
||||
;; BOOTLOADER ;;
|
||||
;;;;;;;;;;;;;;;;
|
||||
|
||||
(def resolution (fn (x y fps) (println x "x" y "@" fps)))
|
||||
|
||||
(pkg-install :core :bootloader-limine)
|
||||
(pkg-configure :bootloader-limine
|
||||
:comment "Default"
|
||||
:kernel :kernel-rust
|
||||
:boot-protocol "limine"
|
||||
:verbose true
|
||||
:resolution 1024 768 24
|
||||
:timeout 10)
|
||||
|
||||
(bootloader-install :bootloader-limine)
|
||||
|
||||
;;;;;;;;;;;;;
|
||||
;; DRIVERS ;;
|
||||
;;;;;;;;;;;;;
|
||||
|
||||
(pkg-install :core :ps2-driver)
|
||||
(pkg-install :core :ata-pio)
|
||||
|
||||
;;;;;;;;;;;;;;
|
||||
;; SERVICES ;;
|
||||
;;;;;;;;;;;;;;
|
||||
(pkg-install :core :vfsaur)
|
||||
|
||||
(pkg-install :core :angels-halo)
|
||||
(pkg-configure :angels-halo)
|
||||
|
||||
(pkg-install :core :sunset)
|
||||
(pkg-install :core :cluster)
|
||||
|
||||
|
||||
;; Init System
|
||||
(pkg-install :core :genesis)
|
||||
|
||||
;; Typically drivers should not have dependencies. Thus simplifing dependency solving.
|
||||
;; Services might have dependencies on drivers or other services that can be auto-started even if you don:t specify them
|
||||
(pkg-configure :genesis
|
||||
(reincarnation-server :angels-halo)
|
||||
(drivers :ata-pio :serial)
|
||||
(services :sunset :vfsaur :fat32))
|
||||
|
||||
;;;;;;;;;;;;
|
||||
;; KERNEL ;;
|
||||
;;;;;;;;;;;;
|
||||
(system-install :core :kernel-rust)
|
||||
;; Set the program to be launched to init the system.
|
||||
|
|
@ -26,8 +26,8 @@ resolution = "1024x768x24"
|
|||
# [boot.limine.ableos.modules.render_example]
|
||||
# path = "boot:///render_example.hbf"
|
||||
|
||||
[boot.limine.ableos.modules.sunset_server]
|
||||
path = "boot:///sunset_server.hbf"
|
||||
# [boot.limine.ableos.modules.sunset_server]
|
||||
# path = "boot:///sunset_server.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.ps2_mouse_driver]
|
||||
# path = "boot:///ps2_mouse_driver.hbf"
|
||||
|
@ -41,14 +41,11 @@ path = "boot:///sunset_server.hbf"
|
|||
# [boot.limine.ableos.modules.sunset_client]
|
||||
# path = "boot:///sunset_client.hbf"
|
||||
|
||||
[boot.limine.ableos.modules.adit]
|
||||
path = "boot:///adit.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.ablefetch]
|
||||
# path = "boot:///ablefetch.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.sketchpad]
|
||||
# path = "boot:///sketchpad.hbf"
|
||||
# [boot.limine.ableos.modules.diskio_driver]
|
||||
# path = "boot:///diskio_driver.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.angels_halo]
|
||||
# path = "boot:///angels_halo.hbf"
|
||||
|
@ -58,3 +55,6 @@ path = "boot:///adit.hbf"
|
|||
|
||||
# [boot.limine.ableos.modules.vfsaur]
|
||||
# path = "boot:///vfsaur.hbf"
|
||||
|
||||
[boot.limine.ableos.modules.rtc_driver]
|
||||
path = "boot:///rtc_driver.hbf"
|
Loading…
Reference in a new issue