1
0
Fork 0
forked from AbleOS/ableos

did some stuff /shrug

This commit is contained in:
Able 2024-07-07 08:35:07 -05:00
parent 5f136a66af
commit f33cc0bf70
10 changed files with 121 additions and 95 deletions

6
Cargo.lock generated
View file

@ -429,7 +429,7 @@ dependencies = [
[[package]] [[package]]
name = "hbbytecode" name = "hbbytecode"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#59705c062dbd0eeeaf2feb4a76230a393672c646" source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#efa7271a5917c9b78ed06563df2bea13f895f8ca"
[[package]] [[package]]
name = "hbbytecode" name = "hbbytecode"
@ -439,7 +439,7 @@ source = "git+https://git.ablecorp.us/ableos/holey-bytes#e494785f93dad2722ebd9e5
[[package]] [[package]]
name = "hblang" name = "hblang"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#59705c062dbd0eeeaf2feb4a76230a393672c646" source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#efa7271a5917c9b78ed06563df2bea13f895f8ca"
dependencies = [ dependencies = [
"hbvm 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)", "hbvm 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)",
] ]
@ -447,7 +447,7 @@ dependencies = [
[[package]] [[package]]
name = "hbvm" name = "hbvm"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#59705c062dbd0eeeaf2feb4a76230a393672c646" source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#efa7271a5917c9b78ed06563df2bea13f895f8ca"
dependencies = [ dependencies = [
"hbbytecode 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)", "hbbytecode 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)",
] ]

View file

@ -116,12 +116,26 @@ pub fn handler(vm: &mut Vm) {
} }
4 => { 4 => {
let buffer_id = vm.registers[3].cast::<u64>(); let buffer_id = vm.registers[3].cast::<u64>();
let mut map_ptr = vm.registers[4].cast::<u64>();
let max_length = vm.registers[5].cast::<u64>();
let mut buffs = IPC_BUFFERS.lock(); let mut buffs = IPC_BUFFERS.lock();
let mut buff = buffs.get_mut(&buffer_id).unwrap(); let mut buff = buffs.get_mut(&buffer_id).unwrap();
let msg = buff.pop(); let msg = buff.pop();
if msg.len() > max_length.try_into().unwrap() {
info!("{}", max_length);
error!("Message is too long to map in.");
} else {
unsafe {
let ptr: *mut u64 = &mut map_ptr;
for (index, byte) in msg.iter().enumerate() {
ptr.offset(index.try_into().unwrap()).write_bytes(*byte, 1);
}
}
info!("Recieve {:?} from Buffer({})", msg, buffer_id); info!("Recieve {:?} from Buffer({})", msg, buffer_id);
} }
}
5 => { 5 => {
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
{ {

View file

@ -5,7 +5,7 @@ use std::{
process::exit, process::exit,
}; };
use error_stack::Report; use {error_stack::Report, hblang::Options};
use crate::Error; use crate::Error;
pub struct Package { pub struct Package {
@ -69,8 +69,16 @@ impl Package {
let path = format!("sysdata/programs/{}/{}", self.name, file); let path = format!("sysdata/programs/{}/{}", self.name, file);
let mut bytes = Vec::new(); let mut bytes = Vec::new();
// compile here // compile here
let _ = hblang::run_compiler(&path, Default::default(), &mut bytes);
// let _ = hblang::run_compiler(
// &path,
// Options {
// fmt: true,
// ..Default::default()
// },
// &mut bytes,
// );
let _ = hblang::run_compiler(&path, Default::default(), &mut bytes);
match std::fs::create_dir("target/programs") { match std::fs::create_dir("target/programs") {
Ok(_) => (), Ok(_) => (),
Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => (), Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => (),

View file

@ -0,0 +1,20 @@
string := @use("rel:string.hb");
receive_message := fn(buffer_id: int, memory_map_location: ^u8, length: int): ^u8 {
return @eca(void, 4, buffer_id, memory_map_location, length);
}
send_message := fn(buffer_id: int): void {
message := "Hello there\0";
message_length := string.length(message);
@eca(i32, 3, buffer_id, message, message_length);
return;
}
create := fn(): int {
msg := "\{01}Number\0";
msg_length := string.length(msg);
*msg = 0;
return @eca(int, 1, 0, msg, msg_length);
}

View file

@ -1,31 +1,4 @@
char := struct {} string := @use("rel:string.hb");
log := @use("rel:log.hb");
memory := @use("rel:memory.hb");
log := fn(log_level: int, message: ^char, message_length: int): int { buffer := @use("rel:buffer.hb");
@eca(i32,1, 1, 1)
return 0;
}
error := fn(message: ^char, message_length: int): int {
log(0, message, message_length)
}
warn := fn(message: ^char, message_length: int): int {
log(1, message, message_length)
}
info := fn(message: ^char, message_length: int): int {
log(2, message, message_length)
}
debug := fn(message: ^char, message_length: int): int {
log(3, message, message_length)
}
trace := fn(message: ^char, message_length: int): int {
log(4, message, message_length)
}
test := fn(): int {
@eca(i32, 1, 1, 1);
}

View file

@ -0,0 +1,15 @@
string := @use("rel:string.hb");
log := fn(message: ^u8, level: u8): void {
message_length := string.length(message);
*(message + message_length) = level;
@eca(i32, 3, 1, message, message_length + 1);
return;
}
error:= fn(message: ^u8):void return log(message, 0);
warn:= fn(message: ^u8):void return log(message, 1);
info:= fn(message: ^u8):void return log(message, 2);
debug:= fn(message: ^u8):void return log(message, 3);
trace:= fn(message: ^u8):void return log(message, 4);

View file

@ -0,0 +1,18 @@
request_page := fn(page_count: u8): ^u8 {
msg := "\{00}\{01}xxxxxxxx\0";
msg_page_count := msg + 1;
*msg_page_count = page_count;
return @eca(^u8, 3, 2, msg, 12);
}
release_page := fn(ptr: ^u8, page_count: u8): void {
msg := "\{01}\{00}xxxxxxxx\0";
msg_page_count := msg + 1;
*msg_page_count = page_count;
msg_ptr := @as(^^u8, @bitcast(msg+2));
*msg_ptr = ptr;
return @eca(void, 3, 2, msg, 12);
}

View file

@ -0,0 +1,8 @@
length := fn(ptr: ^u8): int {
len := 0;
loop if *ptr == 0 break else {
len += 1;
ptr += 1;
}
return len;
}

View file

@ -1,16 +1,15 @@
main := fn(): int { main := fn(): int {
frame_buffer := @as(^u32, @bitcast(18446603339442421760)); frame_buffer := @as(^u8, @bitcast(18446603339442421760));
color := 0; color := 17;
loop { loop {
len := 786432*4; len := (786432 * 4)+1;
loop if len == 0 break else { loop if len == 0 break else {
fb := frame_buffer + @as(^u32, @bitcast(len)); fb := frame_buffer + len;
*fb = color; *fb = color;
len -= 1; len = len - 1;
color += 100; color += len;
} }
} }
return 0; return 0;
} }

View file

@ -1,49 +1,20 @@
log := fn(message: ^u8, level: u8): void { stn := @use("../../../libraries/stn/src/lib.hb");
message_2 := message; log := stn.log;
len := 0; string := stn.string;
loop if *message_2 == 0 { memory := stn.memory;
*message_2 = level; buffer := stn.buffer;
break
} else {
len += 1;
message_2 += 1;
}
len += 1;
@eca(i32, 3, 1, message, len);
return;
}
error:= fn(message: ^u8):void return log(message, 0);
warn:= fn(message: ^u8):void return log(message, 1);
info:= fn(message: ^u8):void return log(message, 2);
debug:= fn(message: ^u8):void return log(message, 3);
trace:= fn(message: ^u8):void return log(message, 4);
request_mem_page := fn(page_count: u8): ^u8 {
msg := "\{00}\{01}xxxxxxxx\0";
msg_mem_page_count := msg + 1;
*msg_mem_page_count = page_count;
return @eca(^u8, 3, 2, msg, 12);
}
release_mem_page := fn(ptr: ^u8, page_count: u8): void {
msg := "\{01}\{00}xxxxxxxx\0";
msg_mem_page_count := msg + 1;
*msg_mem_page_count = page_count;
msg_mem_ptr := @as(^^u8, @bitcast(msg+2));
*msg_mem_ptr = ptr;
a := @eca(void, 3, 2, msg, 12);
return;
}
main := fn(): int { main := fn(): int {
buffer := request_mem_page(3); // Create a buffer
release_mem_page(buffer, 3); buffer_id := buffer.create();
buffer.send_message(buffer_id);
memory_pages := memory.request_page(3);
buffer.receive_message(buffer_id, memory_pages, 4096*3);
log.info("abc\0");
memory.release_page(memory_pages, 3);
return 0; return 0;
} }