work
This commit is contained in:
parent
62c181fb6a
commit
54d7e6b02b
6
Cargo.lock
generated
6
Cargo.lock
generated
|
@ -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#e494785f93dad2722ebd9e5d81c2bcb3c471cc07"
|
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#59705c062dbd0eeeaf2feb4a76230a393672c646"
|
||||||
|
|
||||||
[[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#e494785f93dad2722ebd9e5d81c2bcb3c471cc07"
|
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#59705c062dbd0eeeaf2feb4a76230a393672c646"
|
||||||
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#e494785f93dad2722ebd9e5d81c2bcb3c471cc07"
|
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#59705c062dbd0eeeaf2feb4a76230a393672c646"
|
||||||
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)",
|
||||||
]
|
]
|
||||||
|
|
|
@ -68,7 +68,7 @@ pub fn handler(vm: &mut Vm) {
|
||||||
let buffer_id = vm.registers[3].cast::<u64>();
|
let buffer_id = vm.registers[3].cast::<u64>();
|
||||||
let mem_addr = vm.registers[4].cast::<u64>();
|
let mem_addr = vm.registers[4].cast::<u64>();
|
||||||
let length = vm.registers[5].cast::<u64>() as usize;
|
let length = vm.registers[5].cast::<u64>() as usize;
|
||||||
trace!("IPC address: {:?}", mem_addr);
|
// debug!("IPC address: {:?}", mem_addr);
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
|
|
||||||
match buffer_id {
|
match buffer_id {
|
||||||
|
|
|
@ -37,16 +37,17 @@ pub fn memory_msg_handler(
|
||||||
) -> Result<(), MemoryServiceError> {
|
) -> Result<(), MemoryServiceError> {
|
||||||
let mut msg_vec = block_read(mem_addr, length);
|
let mut msg_vec = block_read(mem_addr, length);
|
||||||
let msg_type = msg_vec[0];
|
let msg_type = msg_vec[0];
|
||||||
|
|
||||||
msg_vec.remove(0);
|
msg_vec.remove(0);
|
||||||
match msg_type {
|
match msg_type {
|
||||||
0 => {
|
0 => {
|
||||||
let page_count = msg_vec[0];
|
let page_count = msg_vec[0];
|
||||||
msg_vec.remove(0);
|
msg_vec.remove(0);
|
||||||
|
|
||||||
// let mptr_raw: [u8; 8] = msg_vec[0..8].try_into().unwrap();
|
let mptr_raw: [u8; 8] = msg_vec[0..8].try_into().unwrap();
|
||||||
// let mptr: u64 = u64::from_le_bytes(mptr_raw);
|
let mptr: u64 = u64::from_le_bytes(mptr_raw);
|
||||||
|
|
||||||
// log::debug!("Allocating {} pages @ {}", page_count, mptr);
|
log::debug!("Allocating {} pages @ {:x}", page_count, mptr);
|
||||||
|
|
||||||
let mut val = alloc::vec::Vec::new();
|
let mut val = alloc::vec::Vec::new();
|
||||||
for _ in 0..(page_count as isize * 4096) {
|
for _ in 0..(page_count as isize * 4096) {
|
||||||
|
@ -85,7 +86,15 @@ pub fn memory_msg_handler(
|
||||||
hid, pid, quota_type
|
hid, pid, quota_type
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
_ => {}
|
3 => {
|
||||||
|
let page_count = msg_vec[0];
|
||||||
|
log::debug!(" {} pages", page_count);
|
||||||
|
msg_vec.remove(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
_ => {
|
||||||
|
log::debug!("Unknown memory service message type: {}", msg_type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -64,37 +64,17 @@ impl Package {
|
||||||
}
|
}
|
||||||
pub fn build(&self) {
|
pub fn build(&self) {
|
||||||
if self.binaries.contains(&"hblang".to_string()) {
|
if self.binaries.contains(&"hblang".to_string()) {
|
||||||
let file_order = self.build_cmd.split_ascii_whitespace();
|
let file = self.build_cmd.split_ascii_whitespace().last().unwrap();
|
||||||
let mut files = vec![];
|
|
||||||
for (count, file) in file_order.enumerate() {
|
let path = format!("sysdata/programs/{}/{}", self.name, file);
|
||||||
if count != 0 {
|
let mut bytes = Vec::new();
|
||||||
files.push(file);
|
// compile here
|
||||||
}
|
let _ = hblang::run_compiler(&path, Default::default(), &mut bytes);
|
||||||
}
|
|
||||||
let mut bundle = vec![];
|
|
||||||
for file in files {
|
|
||||||
let file_path = if file.starts_with("libraries") {
|
|
||||||
format!("sysdata/{}", file)
|
|
||||||
} else {
|
|
||||||
format!("sysdata/programs/{}/{}", self.name, file)
|
|
||||||
};
|
|
||||||
let contents = read_to_string(file_path).unwrap();
|
|
||||||
bundle.push((file, contents));
|
|
||||||
}
|
|
||||||
|
|
||||||
use hblang::{codegen, parser};
|
|
||||||
let mut codegen = codegen::Codegen::default();
|
|
||||||
for (path, content) in bundle.iter() {
|
|
||||||
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") {
|
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 => (),
|
||||||
Err(e) => panic!(),
|
Err(e) => panic!("{}", e),
|
||||||
}
|
}
|
||||||
let path = format!("target/programs/{}.hbf", self.name);
|
let path = format!("target/programs/{}.hbf", self.name);
|
||||||
let mut file = File::create(path).unwrap();
|
let mut file = File::create(path).unwrap();
|
||||||
|
|
|
@ -26,10 +26,6 @@ trace := fn(message: ^char, message_length: int): int {
|
||||||
log(4, message, message_length)
|
log(4, message, message_length)
|
||||||
}
|
}
|
||||||
|
|
||||||
main := fn(): int {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
test := fn(): int {
|
test := fn(): int {
|
||||||
@eca(i32, 1, 1, 1);
|
@eca(i32, 1, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,4 +8,4 @@ authors = ["able"]
|
||||||
hblang.version = "1.0.0"
|
hblang.version = "1.0.0"
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
command = "hblang libraries/stn/src/lib.hb src/main.hb"
|
command = "hblang src/main.hb"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
buffer := 18446603339442421960;
|
buffer := @as(^u32, @bitcast(18446603339442422060));
|
||||||
|
|
||||||
send_msg := fn(): int {
|
send_msg := fn(): int {
|
||||||
msg := 10;
|
msg := 10;
|
||||||
|
|
|
@ -8,4 +8,4 @@ authors = ["able"]
|
||||||
hblang.version = "1.0.0"
|
hblang.version = "1.0.0"
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
command = "hblang libraries/stn/src/lib.hb src/main.hb"
|
command = "hblang src/main.hb"
|
||||||
|
|
|
@ -1,4 +1,42 @@
|
||||||
|
log := fn(message: ^u8, level: u8): void {
|
||||||
|
message_2 := message;
|
||||||
|
len := 0;
|
||||||
|
loop if *message_2 == 0 {
|
||||||
|
*message_2 = level;
|
||||||
|
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 := "\{01}\{01}00000\0";
|
||||||
|
msg_mem_page_count := msg + 1;
|
||||||
|
*msg_mem_page_count = page_count;
|
||||||
|
return @eca(^u8, 3, 2, msg, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
alloc := fn(): void {
|
||||||
|
error("Did not allocate.\0");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
main := fn(): int {
|
main := fn(): int {
|
||||||
|
buffer := request_mem_page(3);
|
||||||
|
|
||||||
|
alloc();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -4,7 +4,7 @@ The memory service uses the first byte in the message to identify the request ty
|
||||||
## Allocate (12 bytes)
|
## Allocate (12 bytes)
|
||||||
[U8] -> 0
|
[U8] -> 0
|
||||||
[U8] -> Page count
|
[U8] -> Page count
|
||||||
<!-- Currently this does not allocate here, check r1 for a ptr to alloc to -->
|
<!-- Currently this does not allocate here, check r2 for a ptr to alloc to -->
|
||||||
[U64] -> ptr to alloc at
|
[U64] -> ptr to alloc at
|
||||||
|
|
||||||
## Deallocate (12 bytes)
|
## Deallocate (12 bytes)
|
||||||
|
|
|
@ -21,8 +21,8 @@ resolution = "1024x768x24"
|
||||||
[boot.limine.ableos.modules.tests]
|
[boot.limine.ableos.modules.tests]
|
||||||
path = "boot:///tests.hbf"
|
path = "boot:///tests.hbf"
|
||||||
|
|
||||||
[boot.limine.ableos.modules.diskio_driver]
|
# [boot.limine.ableos.modules.diskio_driver]
|
||||||
path = "boot:///diskio_driver.hbf"
|
# path = "boot:///diskio_driver.hbf"
|
||||||
|
|
||||||
[boot.limine.ableos.modules.fat32_filesystem_driver]
|
# [boot.limine.ableos.modules.fb_driver]
|
||||||
path = "boot:///fat32_filesystem_driver.hbf"
|
# path = "boot:///fb_driver.hbf"
|
||||||
|
|
Loading…
Reference in a new issue