1
0
Fork 0
forked from koniifer/ableos
This commit is contained in:
mlokr 2024-09-04 19:14:30 +02:00
parent a7517005de
commit 1a2b60b53b
No known key found for this signature in database
GPG key ID: DEA147DDEE644993
4 changed files with 19 additions and 7 deletions

6
Cargo.lock generated
View file

@ -444,7 +444,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#894f73ca35199f524dff6160c57c0916169fbaf6" source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#d9aab2191b57d4c9fa5a57e70c38039e605ad741"
[[package]] [[package]]
name = "hbbytecode" name = "hbbytecode"
@ -454,7 +454,7 @@ source = "git+https://git.ablecorp.us/ableos/holey-bytes#894f73ca35199f524dff616
[[package]] [[package]]
name = "hblang" name = "hblang"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#894f73ca35199f524dff6160c57c0916169fbaf6" source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#d9aab2191b57d4c9fa5a57e70c38039e605ad741"
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)",
] ]
@ -462,7 +462,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#894f73ca35199f524dff6160c57c0916169fbaf6" source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#d9aab2191b57d4c9fa5a57e70c38039e605ad741"
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

@ -74,7 +74,7 @@ pub fn handler(vm: &mut Vm) {
match buffer_id { match buffer_id {
0 => match sds_msg_handler(vm, mem_addr, length) { 0 => match sds_msg_handler(vm, mem_addr, length) {
Ok(()) => {} Ok(()) => {}
Err(err) => log::error!("Improper sds format"), Err(err) => log::error!("Improper sds format: {err:?}"),
}, },
1 => match log_msg_handler(vm, mem_addr, length) { 1 => match log_msg_handler(vm, mem_addr, length) {
Ok(()) => {} Ok(()) => {}
@ -285,6 +285,7 @@ fn log_msg_handler(vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), LogE
#[derive(Debug)] #[derive(Debug)]
pub enum LogError { pub enum LogError {
NoMessages,
InvalidLogFormat, InvalidLogFormat,
} }
use {alloc::vec, log::Record}; use {alloc::vec, log::Record};

View file

@ -23,6 +23,9 @@ pub static SERVICES: Lazy<Mutex<Services>> = Lazy::new(|| {
pub fn sds_msg_handler(vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), LogError> { pub fn sds_msg_handler(vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), LogError> {
let mut msg_vec = block_read(mem_addr, length); let mut msg_vec = block_read(mem_addr, length);
if msg_vec.is_empty() {
return Err(LogError::NoMessages);
}
let sds_event_type: ServiceEventType = msg_vec[0].into(); let sds_event_type: ServiceEventType = msg_vec[0].into();
msg_vec.remove(0); msg_vec.remove(0);

View file

@ -85,9 +85,17 @@ impl Package {
Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => (), Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => (),
Err(e) => panic!("{}", e), Err(e) => panic!("{}", e),
} }
let path = format!("target/programs/{}.hbf", self.name); std::fs::write(format!("target/programs/{}.hbf", self.name), &bytes).unwrap();
let mut file = File::create(path).unwrap(); bytes.clear();
file.write_all(&bytes).unwrap(); let _ = hblang::run_compiler(
&path,
Options {
dump_asm: true,
..Default::default()
},
&mut bytes,
);
std::fs::write(format!("target/programs/{}.hba", self.name), &bytes).unwrap();
} }
} }
} }