Compare commits

...

3 commits

Author SHA1 Message Date
able b427ae1c27 Probably this works on someone elses machine. 2024-05-31 10:07:22 -05:00
able a511e99606 Update ecalls to match the spec 2024-05-31 09:15:55 -05:00
able d90016f28e checkpoint 2024-05-31 09:11:45 -05:00
13 changed files with 185 additions and 207 deletions

View file

@ -1,2 +1,2 @@
[alias] [alias]
repbuild = "run --manifest-path ./repbuild/Cargo.toml --" repbuild = "run --manifest-path ./repbuild/Cargo.toml -r --"

188
Cargo.lock generated
View file

@ -29,9 +29,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]] [[package]]
name = "ahash" name = "ahash"
version = "0.7.7" version = "0.7.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9"
dependencies = [ dependencies = [
"getrandom", "getrandom",
"once_cell", "once_cell",
@ -40,16 +40,14 @@ dependencies = [
[[package]] [[package]]
name = "ahash" name = "ahash"
version = "0.8.6" version = "0.8.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"const-random",
"getrandom",
"once_cell", "once_cell",
"version_check", "version_check",
"zerocopy 0.7.18", "zerocopy 0.7.34",
] ]
[[package]] [[package]]
@ -193,26 +191,6 @@ dependencies = [
"toml 0.5.9", "toml 0.5.9",
] ]
[[package]]
name = "const-random"
version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359"
dependencies = [
"const-random-macro",
]
[[package]]
name = "const-random-macro"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e"
dependencies = [
"getrandom",
"once_cell",
"tiny-keccak",
]
[[package]] [[package]]
name = "convert_case" name = "convert_case"
version = "0.4.0" version = "0.4.0"
@ -254,12 +232,6 @@ dependencies = [
"cfg-if", "cfg-if",
] ]
[[package]]
name = "crunchy"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
[[package]] [[package]]
name = "derive_more" name = "derive_more"
version = "0.99.17" version = "0.99.17"
@ -441,7 +413,7 @@ version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
dependencies = [ dependencies = [
"ahash 0.7.7", "ahash 0.7.8",
] ]
[[package]] [[package]]
@ -450,35 +422,42 @@ version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156"
dependencies = [ dependencies = [
"ahash 0.8.6", "ahash 0.8.11",
"allocator-api2", "allocator-api2",
] ]
[[package]]
name = "hbasm"
version = "0.1.0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#796a826cc5e99af341e0e0980c6f0b933896549c"
dependencies = [
"paste",
"rhai",
"with_builtin_macros",
]
[[package]] [[package]]
name = "hbbytecode" name = "hbbytecode"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.ablecorp.us/ableos/holey-bytes#247b2c6614ab81925e96744398632e3b7bb8b7ad" source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#e494785f93dad2722ebd9e5d81c2bcb3c471cc07"
[[package]]
name = "hbbytecode"
version = "0.1.0"
source = "git+https://git.ablecorp.us/ableos/holey-bytes#e494785f93dad2722ebd9e5d81c2bcb3c471cc07"
[[package]]
name = "hblang"
version = "0.1.0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#e494785f93dad2722ebd9e5d81c2bcb3c471cc07"
dependencies = [ dependencies = [
"paste", "hbvm 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)",
"with_builtin_macros",
] ]
[[package]] [[package]]
name = "hbvm" name = "hbvm"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.ablecorp.us/ableos/holey-bytes#247b2c6614ab81925e96744398632e3b7bb8b7ad" source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#e494785f93dad2722ebd9e5d81c2bcb3c471cc07"
dependencies = [ dependencies = [
"hbbytecode", "hbbytecode 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)",
]
[[package]]
name = "hbvm"
version = "0.1.0"
source = "git+https://git.ablecorp.us/ableos/holey-bytes#e494785f93dad2722ebd9e5d81c2bcb3c471cc07"
dependencies = [
"hbbytecode 0.1.0 (git+https://git.ablecorp.us/ableos/holey-bytes)",
] ]
[[package]] [[package]]
@ -602,15 +581,6 @@ dependencies = [
"hashbrown 0.12.3", "hashbrown 0.12.3",
] ]
[[package]]
name = "instant"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
dependencies = [
"cfg-if",
]
[[package]] [[package]]
name = "ipnet" name = "ipnet"
version = "2.9.0" version = "2.9.0"
@ -642,7 +612,7 @@ dependencies = [
"derive_more", "derive_more",
"embedded-graphics", "embedded-graphics",
"hashbrown 0.14.2", "hashbrown 0.14.2",
"hbvm", "hbvm 0.1.0 (git+https://git.ablecorp.us/ableos/holey-bytes)",
"kiam", "kiam",
"limine", "limine",
"log", "log",
@ -836,7 +806,7 @@ dependencies = [
"derive_more", "derive_more",
"error-stack", "error-stack",
"fatfs", "fatfs",
"hbasm", "hblang",
"reqwest", "reqwest",
"str-reader", "str-reader",
"toml 0.5.11", "toml 0.5.11",
@ -882,34 +852,6 @@ dependencies = [
"winreg", "winreg",
] ]
[[package]]
name = "rhai"
version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a7d88770120601ba1e548bb6bc2a05019e54ff01b51479e38e64ec3b59d4759"
dependencies = [
"ahash 0.8.6",
"bitflags 2.4.1",
"instant",
"num-traits",
"once_cell",
"rhai_codegen",
"smallvec",
"smartstring",
"thin-vec",
]
[[package]]
name = "rhai_codegen"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59aecf17969c04b9c0c5d21f6bc9da9fec9dd4980e64d1871443a476589d8c86"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.38",
]
[[package]] [[package]]
name = "ring" name = "ring"
version = "0.17.5" version = "0.17.5"
@ -1062,23 +1004,6 @@ dependencies = [
"autocfg", "autocfg",
] ]
[[package]]
name = "smallvec"
version = "1.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
[[package]]
name = "smartstring"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fb72c633efbaa2dd666986505016c32c3044395ceaf881518399d2f4127ee29"
dependencies = [
"autocfg",
"static_assertions",
"version_check",
]
[[package]] [[package]]
name = "socket2" name = "socket2"
version = "0.4.10" version = "0.4.10"
@ -1108,12 +1033,6 @@ dependencies = [
"lock_api", "lock_api",
] ]
[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]] [[package]]
name = "str-reader" name = "str-reader"
version = "0.1.2" version = "0.1.2"
@ -1163,21 +1082,6 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "thin-vec"
version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a38c90d48152c236a3ab59271da4f4ae63d678c5d7ad6b7714d7cb9760be5e4b"
[[package]]
name = "tiny-keccak"
version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237"
dependencies = [
"crunchy",
]
[[package]] [[package]]
name = "tinyvec" name = "tinyvec"
version = "1.6.0" version = "1.6.0"
@ -1566,26 +1470,6 @@ dependencies = [
"windows-sys", "windows-sys",
] ]
[[package]]
name = "with_builtin_macros"
version = "0.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a59d55032495429b87f9d69954c6c8602e4d3f3e0a747a12dea6b0b23de685da"
dependencies = [
"with_builtin_macros-proc_macros",
]
[[package]]
name = "with_builtin_macros-proc_macros"
version = "0.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15bd7679c15e22924f53aee34d4e448c45b674feb6129689af88593e129f8f42"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]] [[package]]
name = "x2apic" name = "x2apic"
version = "0.4.3" version = "0.4.3"
@ -1631,11 +1515,11 @@ dependencies = [
[[package]] [[package]]
name = "zerocopy" name = "zerocopy"
version = "0.7.18" version = "0.7.34"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ede7d7c7970ca2215b8c1ccf4d4f354c4733201dfaaba72d44ae5b37472e4901" checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087"
dependencies = [ dependencies = [
"zerocopy-derive 0.7.18", "zerocopy-derive 0.7.34",
] ]
[[package]] [[package]]
@ -1651,9 +1535,9 @@ dependencies = [
[[package]] [[package]]
name = "zerocopy-derive" name = "zerocopy-derive"
version = "0.7.18" version = "0.7.34"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b27b1bb92570f989aac0ab7e9cbfbacdd65973f7ee920d9f0e71ebac878fd0b" checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View file

@ -18,12 +18,12 @@ use {
}; };
pub fn handler(vm: &mut Vm) { pub fn handler(vm: &mut Vm) {
let r1 = vm.registers[1].cast::<u64>(); let ecall_number = vm.registers[2].cast::<u64>();
// debug!("Ecall number {:?}", r1); // debug!("Ecall number {:?}", ecall_number);
// trace!("Register dump: {:?}", vm.registers); // trace!("Register dump: {:?}", vm.registers);
match r1 { match ecall_number {
0 => { 0 => {
// TODO: explode computer // TODO: explode computer
// hello world ecall // hello world ecall
@ -34,7 +34,7 @@ pub fn handler(vm: &mut Vm) {
1 => { 1 => {
// Make buffer // Make buffer
let bounded = match vm.registers[2].cast::<u64>() { let bounded = match vm.registers[3].cast::<u64>() {
0 => false, 0 => false,
1 => true, 1 => true,
_ => { _ => {
@ -42,7 +42,7 @@ pub fn handler(vm: &mut Vm) {
} }
}; };
let length = vm.registers[3].cast::<u64>(); let length = vm.registers[4].cast::<u64>();
let mut buffs = IPC_BUFFERS.lock(); let mut buffs = IPC_BUFFERS.lock();
let abc; let abc;
@ -65,13 +65,9 @@ pub fn handler(vm: &mut Vm) {
} }
3 => { 3 => {
// Send a message to a buffer // Send a message to a buffer
let r2 = vm.registers[2].cast::<u64>(); let buffer_id = vm.registers[3].cast::<u64>();
let r3 = vm.registers[3].cast::<u64>(); let mem_addr = vm.registers[4].cast::<u64>();
let r4 = vm.registers[4].cast::<u64>(); let length = vm.registers[5].cast::<u64>() as usize;
let buffer_id = r2;
let mem_addr = r3;
let length = r4 as usize;
trace!("IPC address: {:?}", mem_addr); trace!("IPC address: {:?}", mem_addr);
use alloc::vec::Vec; use alloc::vec::Vec;
@ -119,12 +115,12 @@ pub fn handler(vm: &mut Vm) {
} }
} }
4 => { 4 => {
let r2 = vm.registers[2].cast::<u64>(); let buffer_id = vm.registers[3].cast::<u64>();
let mut buffs = IPC_BUFFERS.lock(); let mut buffs = IPC_BUFFERS.lock();
let mut buff = buffs.get_mut(&r2).unwrap(); let mut buff = buffs.get_mut(&buffer_id).unwrap();
let msg = buff.pop(); let msg = buff.pop();
info!("Recieve {:?} from Buffer({})", msg, r2); info!("Recieve {:?} from Buffer({})", msg, buffer_id);
} }
5 => { 5 => {
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
@ -141,7 +137,7 @@ pub fn handler(vm: &mut Vm) {
} }
// 5 // 5
_ => { _ => {
log::error!("Syscall unknown {:?}{:?}", r1, vm.registers); log::error!("Syscall unknown {:?}{:?}", ecall_number, vm.registers);
} }
} }
} }

View file

@ -12,6 +12,7 @@
ptr_sub_ptr, ptr_sub_ptr,
custom_test_frameworks, custom_test_frameworks,
naked_functions, naked_functions,
pointer_is_aligned_to
)] )]
#![allow(dead_code)] #![allow(dead_code)]
#![test_runner(crate::test_runner)] #![test_runner(crate::test_runner)]

View file

@ -1,6 +1,6 @@
{ {
"llvm-target": "x86_64-unknown-none", "llvm-target": "x86_64-unknown-none",
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128", "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128",
"arch": "x86_64", "arch": "x86_64",
"target-endian": "little", "target-endian": "little",
"target-pointer-width": "64", "target-pointer-width": "64",

View file

@ -9,8 +9,8 @@ derive_more = "0.99"
error-stack = "0.4" error-stack = "0.4"
fatfs = "0.3" fatfs = "0.3"
toml = "0.5.2" toml = "0.5.2"
hbasm.git = "https://git.ablecorp.us/AbleOS/holey-bytes.git" # hbasm.git = "https://git.ablecorp.us/AbleOS/holey-bytes.git"
hblang.git = "https://git.ablecorp.us/AbleOS/holey-bytes.git"
[dependencies.reqwest] [dependencies.reqwest]
version = "0.11" version = "0.11"

100
repbuild/src/dev.rs Normal file
View file

@ -0,0 +1,100 @@
use std::{
fs::{read_to_string, File},
io::{BufWriter, Write},
process::exit,
};
use error_stack::Report;
use crate::Error;
pub struct Package {
name: String,
binaries: Vec<String>,
build_cmd: String,
}
impl Package {
pub fn load_from_file(path: String) -> Self {
let contents = match std::fs::read_to_string(path.clone()) {
// If successful return the files text as `contents`.
// `c` is a local variable.
Ok(c) => c,
// Handle the `error` case.
Err(_) => {
// Write `msg` to `stderr`.
eprintln!("Could not read file `{}`", path);
// Exit the program with exit code `1`.
exit(1);
}
};
use toml::Value;
let mut data: Value = toml::from_str(&contents).unwrap();
let mut name = data
.get("package")
.unwrap()
.get("name")
.unwrap()
.to_string();
name.pop();
name.remove(0);
let dependants = data.get("dependants").unwrap();
let bin_table = dependants.get("binaries").unwrap().as_table().unwrap();
let mut binaries = vec![];
for (count, (name, table)) in bin_table.into_iter().enumerate() {
// if count != 0 {
println!("{}", name);
binaries.push(name.clone());
// }
}
let build_table = data.get("build").unwrap();
let mut build_cmd: String = build_table.get("command").unwrap().as_str().unwrap().into();
build_cmd.remove(0);
// build_cmd.pop();
Self {
name,
binaries,
build_cmd,
}
}
pub fn build(&self) {
if self.binaries.contains(&"hblang".to_string()) {
let file_order = self.build_cmd.split_ascii_whitespace();
let mut files = vec![];
for (count, file) in file_order.enumerate() {
if count != 0 {
println!("{}", file);
files.push(file);
}
}
let mut bundle = vec![];
for file in files {
let contents = read_to_string(file).unwrap();
bundle.push((file, contents));
}
use hblang::{codegen, parser};
let mut codegen = codegen::Codegen::default();
for (path, content) in bundle.iter() {
println!("A");
codegen.files = vec![parser::Ast::new(&path, &content, &parser::no_loader)];
codegen.generate();
}
let mut buf = BufWriter::new(Vec::new());
codegen.dump(&mut buf);
let bytes = buf.into_inner().unwrap();
match std::fs::create_dir("target/programs") {
Ok(_) => (),
Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => (),
Err(e) => panic!(),
}
let path = format!("target/test-programs/{}.hbf", self.name);
let mut file = File::create(path).unwrap();
file.write_all(&bytes).unwrap();
}
}
}

View file

@ -1,5 +1,8 @@
mod dev;
use { use {
derive_more::Display, derive_more::Display,
dev::Package,
error_stack::{bail, report, Context, Report, Result, ResultExt}, error_stack::{bail, report, Context, Report, Result, ResultExt},
fatfs::{FileSystem, FormatVolumeOptions, FsOptions, ReadWriteSeek}, fatfs::{FileSystem, FormatVolumeOptions, FsOptions, ReadWriteSeek},
std::{ std::{
@ -114,8 +117,8 @@ fn assemble() -> Result<(), Error> {
.map_err(Report::from) .map_err(Report::from)
.change_context(Error::Io)?; .change_context(Error::Io)?;
hbasm::assembler(&mut out, |engine| engine.run_file(entry.path())) // hbasm::assembler(&mut out, |engine| engine.run_file(entry.path()))
.map_err(|e| report!(Error::Assembler).attach_printable(e.to_string()))?; // .map_err(|e| report!(Error::Assembler).attach_printable(e.to_string()))?;
} }
Ok(()) Ok(())
@ -136,6 +139,10 @@ fn get_fs() -> Result<FileSystem<impl ReadWriteSeek>, io::Error> {
let fs = FileSystem::new(img, FsOptions::new())?; let fs = FileSystem::new(img, FsOptions::new())?;
// TODO: Do not hard code these here
let p = Package::load_from_file("sysdata/programs/tests/meta.toml".to_owned());
p.build();
// Read the contents of the file using a `match` block // Read the contents of the file using a `match` block
// to return the `data: Ok(c)` as a `String` // to return the `data: Ok(c)` as a `String`
// or handle any `errors: Err(_)`. // or handle any `errors: Err(_)`.

View file

@ -1,3 +1,3 @@
[toolchain] [toolchain]
channel = "nightly-2023-09-17" channel = "nightly-2024-05-17"
components = ["rust-src", "llvm-tools"] components = ["rust-src", "llvm-tools"]

View file

@ -1,6 +1,4 @@
/* char := struct {}
Refer to the spec in "spec/Logging Service spec.md"
*/
log := fn(log_level: int, message: ^char, message_length: int): int { log := fn(log_level: int, message: ^char, message_length: int): int {
@ -26,4 +24,8 @@ debug := fn(message: ^char, message_length: int): int {
trace := fn(message: ^char, message_length: int): int { trace := fn(message: ^char, message_length: int): int {
log(4, message, message_length) log(4, message, message_length)
}
main := fn(): int {
return 0;
} }

View file

@ -0,0 +1,11 @@
[package]
name = "tests"
authors = ["able"]
[dependants.libraries]
[dependants.binaries]
hblang.version = "1.0.0"
[build]
command = "hblang sysdata/libraries/stn/src/lib.hb sysdata/programs/tests/src/main.hb"

View file

@ -0,0 +1,3 @@
main := fn(): int {
return 0;
}

View file

@ -17,32 +17,6 @@ resolution = "1024x768x24"
[boot.limine.ableos.modules] [boot.limine.ableos.modules]
# [boot.limine.ableos.modules.failure] [boot.limine.ableos.modules.tests]
# path = "boot:///failure.hbf" # TODO: Pull from the programs included here
path = "boot:///tests.hbf"
# [boot.limine.ableos.modules.ecall]
# path = "boot:///ecall.hbf"
# [boot.limine.ableos.modules.sds_test]
# path = "boot:///sds_test.hbf"
# [boot.limine.ableos.modules.main]
# path = "boot:///main.hbf"
# [boot.limine.ableos.modules.keyboard_driver]
# path = "boot:///keyboard_driver.hbf"
# cmd_line = "arch=${ARCH}"
# [boot.limine.ableos.modules.vfs_test]
# path = "boot:///vfs_test.hbf"
[boot.limine.ableos.modules.bin]
path = "boot:///bin.hbf"
# [boot.limine.ableos.modules.limine_framebuffer_driver]
# path = "boot:///limine_framebuffer_driver.hbf"
# cmd_line = "height=10 width=10 arch=${ARCH}"
# [boot.limine.ableos.modules.serial_driver]
# path = "boot:///serial_driver.hbf"
# cmd_line = "arch=${ARCH}"