From 6c4eee0c56c6141fec17878f477696e8ee38e669 Mon Sep 17 00:00:00 2001 From: able Date: Sat, 15 Jul 2023 05:51:19 -0500 Subject: [PATCH] SCHED: Two programs are now running in ableOS --- Cargo.lock | 4 ++-- kernel/src/kmain.rs | 5 ++--- kernel/src/scheduler.rs | 26 ++++++++++++++++++++++---- repbuild/holeybytes/ecall.hb | Bin 0 -> 112 bytes repbuild/holeybytes/inf_loop.hb | Bin 0 -> 23 bytes repbuild/inf_loop.hb | Bin 11 -> 0 bytes repbuild/limine.cfg | 2 +- repbuild/src/main.rs | 18 ++++++++++++++++-- 8 files changed, 43 insertions(+), 12 deletions(-) create mode 100644 repbuild/holeybytes/ecall.hb create mode 100644 repbuild/holeybytes/inf_loop.hb delete mode 100644 repbuild/inf_loop.hb diff --git a/Cargo.lock b/Cargo.lock index da83d79..f6af26a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -859,12 +859,12 @@ dependencies = [ [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/holey-bytes#75995422262a192f2c87713d239856e98c799f41" +source = "git+https://git.ablecorp.us/ableos/holey-bytes#6a444bd29ea6d474ec98edbc11b27030825b86e2" [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/holey-bytes#75995422262a192f2c87713d239856e98c799f41" +source = "git+https://git.ablecorp.us/ableos/holey-bytes#6a444bd29ea6d474ec98edbc11b27030825b86e2" dependencies = [ "delegate", "derive_more", diff --git a/kernel/src/kmain.rs b/kernel/src/kmain.rs index 0c9fded..ca83248 100644 --- a/kernel/src/kmain.rs +++ b/kernel/src/kmain.rs @@ -4,7 +4,6 @@ use { crate::{ bootmodules::{build_cmd, BootModules}, - capabilities, device_tree::DeviceTree, scheduler::Scheduler, }, @@ -38,10 +37,10 @@ pub fn kmain(cmdline: &str, boot_modules: BootModules) -> ! { // TODO: schedule the filesystem driver from the initramfs // TODO: schedule the init system from the initramfs - capabilities::example(); + // capabilities::example(); let mut sched = Scheduler::new(); - // AHEM that isn't a valid HBVM program + sched.new_process(boot_modules[0].bytes.clone()); sched.new_process(boot_modules[1].bytes.clone()); diff --git a/kernel/src/scheduler.rs b/kernel/src/scheduler.rs index df075b9..fa5980f 100644 --- a/kernel/src/scheduler.rs +++ b/kernel/src/scheduler.rs @@ -48,11 +48,29 @@ impl Scheduler<'_> { } let mut prog = self.data.pop_front().unwrap(); - prog.run().unwrap(); + let ret = prog.run(); + match ret { + Ok(oki) => match oki { + hbvm::vm::VmRunOk::End => { + log::info!( + "Program ended. {} programs remaining.", + // Add one here because we pop a program + self.data.len() + 1 + ) + } + hbvm::vm::VmRunOk::Timer => { + log::info!("Timer exhausted. Scheduled program"); + self.data.push_back(prog); + } + hbvm::vm::VmRunOk::Ecall => { + // panic!(); + log::info!("{:?}", prog.registers); + self.data.push_back(prog); + } + }, - // log::info!("VM registers {:?}", prog.registers); - log::info!("Scheduled program"); - self.data.push_back(prog); + Err(_) => {} + } } } } diff --git a/repbuild/holeybytes/ecall.hb b/repbuild/holeybytes/ecall.hb new file mode 100644 index 0000000000000000000000000000000000000000..3ecd89a82ad402cc2f2d05840c3c5ee47f3b3b2e GIT binary patch literal 112 ycmWe&WME)n00RLgMmUq13C?6;hBH}N;7m4FIFp?X&g5W+GdVe6Obv+f5E1}Ep8+la literal 0 HcmV?d00001 diff --git a/repbuild/holeybytes/inf_loop.hb b/repbuild/holeybytes/inf_loop.hb new file mode 100644 index 0000000000000000000000000000000000000000..0a4fe615153afee88ff9cd9eca80ebf75c40c218 GIT binary patch literal 23 KcmY#nzzP5Z4gewm literal 0 HcmV?d00001 diff --git a/repbuild/inf_loop.hb b/repbuild/inf_loop.hb deleted file mode 100644 index 2896284bd9325d7cce67b69b4bc1c574cd53d540..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11 KcmY#jfCB&lYXBht diff --git a/repbuild/limine.cfg b/repbuild/limine.cfg index bddfbce..6948659 100644 --- a/repbuild/limine.cfg +++ b/repbuild/limine.cfg @@ -21,5 +21,5 @@ TERM_BACKDROP=008080 MODULE_PATH=boot:///inf_loop.hb MODULE_CMDLINE="diskid=123456789" - MODULE_PATH=boot:///inf_loop.hb + MODULE_PATH=boot:///ecall.hb MODULE_CMDLINE="" \ No newline at end of file diff --git a/repbuild/src/main.rs b/repbuild/src/main.rs index d7d688e..041e51b 100644 --- a/repbuild/src/main.rs +++ b/repbuild/src/main.rs @@ -122,10 +122,15 @@ fn get_fs() -> Result, io::Error> { &mut fs.root_dir().create_file("background.bmp")?, )?; io::copy( - &mut File::open("repbuild/inf_loop.hb")?, + &mut File::open("repbuild/holeybytes/inf_loop.hb")?, &mut fs.root_dir().create_file("inf_loop.hb")?, )?; + io::copy( + &mut File::open("repbuild/holeybytes/ecall.hb")?, + &mut fs.root_dir().create_file("ecall.hb")?, + )?; + drop(bootdir); Ok(fs) } @@ -224,8 +229,17 @@ fn run(release: bool, target: Target) -> Result<(), Error> { if target == Target::Aarch64 { com.args([ - "-M", "virt", "-m", // + "-bios", + "target/OVMF_CODE.fd", + "-M", + "virt", + "-device", + "ramfb", + "-m", // "128M", + // + "-drive", + "file=target/disk.img,format=raw", // "-serial", "stdio", ]); }