diff --git a/Cargo.lock b/Cargo.lock index bd339415..6bf08253 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -457,7 +457,7 @@ dependencies = [ [[package]] name = "hbasm" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#fbc68fadc3fc84018aa57322ef93af8fe7ec7d10" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#0f619887c613be3fb3a7dd8c970b7ee76ad0d23b" dependencies = [ "paste", "rhai", @@ -467,7 +467,7 @@ dependencies = [ [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/holey-bytes#7b1f6d535db3ac4163b45967d963d31f2c577898" +source = "git+https://git.ablecorp.us/ableos/holey-bytes#0f619887c613be3fb3a7dd8c970b7ee76ad0d23b" dependencies = [ "with_builtin_macros", ] @@ -475,7 +475,7 @@ dependencies = [ [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/holey-bytes#7b1f6d535db3ac4163b45967d963d31f2c577898" +source = "git+https://git.ablecorp.us/ableos/holey-bytes#0f619887c613be3fb3a7dd8c970b7ee76ad0d23b" dependencies = [ "hbbytecode", ] diff --git a/kernel/src/holeybytes/ecah.rs b/kernel/src/holeybytes/ecah.rs index 8cce65d0..7deaf011 100644 --- a/kernel/src/holeybytes/ecah.rs +++ b/kernel/src/holeybytes/ecah.rs @@ -7,14 +7,12 @@ use { }; pub fn handler(vm: &mut Vm) { - let r255 = vm.registers[255].cast::(); - let r254 = vm.registers[254].cast::(); - let r253 = vm.registers[253].cast::(); + let r1 = vm.registers[1].cast::(); - debug!("Ecall number {:?}", r255); + debug!("Ecall number {:?}", r1); trace!("Register dump: {:?}", vm.registers); - match r255 { + match r1 { 0 => { // TODO: explode computer // hello world ecall @@ -24,11 +22,8 @@ pub fn handler(vm: &mut Vm) { } 1 => { // Make buffer - let r255 = vm.registers[255].cast::(); - let r254 = vm.registers[254].cast::(); - let r253 = vm.registers[253].cast::(); - let bounded = match r254 { + let bounded = match vm.registers[2].cast::() { 0 => false, 1 => true, _ => { @@ -36,7 +31,7 @@ pub fn handler(vm: &mut Vm) { } }; - let length = r254; + let length = vm.registers[3].cast::(); let mut buffs = IPC_BUFFERS.lock(); let abc; @@ -80,7 +75,7 @@ pub fn handler(vm: &mut Vm) { // 4 // 5 _ => { - log::error!("Syscall unknown {:?}", r255) + log::error!("Syscall unknown {:?}", r1); } } } diff --git a/kernel/src/kmain.rs b/kernel/src/kmain.rs index 65c05a10..36041dd4 100644 --- a/kernel/src/kmain.rs +++ b/kernel/src/kmain.rs @@ -44,8 +44,9 @@ pub fn kmain(cmdline: &str, boot_modules: BootModules) -> ! { // TODO: schedule the init system from the initramfs let mut executor = crate::task::Executor::default(); + let bm_take = boot_modules.len(); unsafe { - for module in boot_modules.into_iter().take(2) { + for module in boot_modules.into_iter().take(bm_take) { executor.spawn(async move { if let Err(e) = ExecThread::new(&module.bytes, Address::new(0)).await { log::error!("{e:?}"); diff --git a/repbuild/hblib/readme.md b/repbuild/hblib/readme.md new file mode 100644 index 00000000..768cf3ca --- /dev/null +++ b/repbuild/hblib/readme.md @@ -0,0 +1 @@ +A kind of standard library. \ No newline at end of file diff --git a/repbuild/hblib/std.rhai b/repbuild/hblib/std.rhai new file mode 100644 index 00000000..82814cfc --- /dev/null +++ b/repbuild/hblib/std.rhai @@ -0,0 +1,25 @@ + +fn ipc_send(buffer_id, mem_addr, length){ + // set the ecall + li8(r1, 3); + // Set the buffer ID to be the BufferID + li64(r2, buffer_id); + lra(r3, r0, mem_addr); + // set the length + li64(r4, length); + // ecall + eca(); +} + +private fn log(log_level, string){ + let str = data::str(string); + ipc_send(1, str, str.len); +} + +fn Error(string) {log(0, string);} +fn Warn(string) {log(1, string);} +fn Info(string) {log(2, string);} +// Due to rhai limitations this cannot be debug +// because of this all of the log levels are upper case +fn Debug(string) {log(3, string);} +fn Trace(string) {log(4, string);} diff --git a/repbuild/holeybytes/ecall.rhai b/repbuild/holeybytes/ecall.rhai index 556d6f17..996e7065 100644 --- a/repbuild/holeybytes/ecall.rhai +++ b/repbuild/holeybytes/ecall.rhai @@ -1,3 +1,3 @@ li8 (r1, 0x69); -eca (); +// eca (); tx (); diff --git a/repbuild/holeybytes/main.rhai b/repbuild/holeybytes/main.rhai new file mode 100644 index 00000000..803e937a --- /dev/null +++ b/repbuild/holeybytes/main.rhai @@ -0,0 +1,13 @@ +import "repbuild/hblib/std" as std; + +fn main(){ + std::Error(":+)"); + std::Warn("Your mom fell in a well!"); + std::Info("Hello, world!"); + std::Debug("ABC"); + std::Trace("Trace Deez"); + + tx(); +} + +main(); \ No newline at end of file diff --git a/repbuild/limine.cfg b/repbuild/limine.cfg index 4580cedc..840548e0 100644 --- a/repbuild/limine.cfg +++ b/repbuild/limine.cfg @@ -23,3 +23,6 @@ TERM_BACKDROP=008080 MODULE_PATH=boot:///ecall.hbf MODULE_CMDLINE="" + + MODULE_PATH=boot:///main.hbf + MODULE_CMDLINE="" diff --git a/repbuild/src/main.rs b/repbuild/src/main.rs index f522974c..41a010c4 100644 --- a/repbuild/src/main.rs +++ b/repbuild/src/main.rs @@ -157,6 +157,11 @@ fn get_fs() -> Result, io::Error> { &mut fs.root_dir().create_file("ecall.hbf")?, )?; + io::copy( + &mut File::open("target/holeybytes/main.hbf")?, + &mut fs.root_dir().create_file("main.hbf")?, + )?; + drop(bootdir); Ok(fs) }