SCHEDULER: added in some super simple bootmodules and run them

This commit is contained in:
able 2023-07-13 03:27:47 -05:00
parent aa5ea3fb8f
commit b9af2ae9c4
9 changed files with 31 additions and 129 deletions

95
Cargo.lock generated
View file

@ -69,12 +69,6 @@ dependencies = [
"memchr", "memchr",
] ]
[[package]]
name = "allocator-api2"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56fc6cf8dc8c4158eed8649f9b8b0ea1518eb62b544fe9490d66fa0b349eafe9"
[[package]] [[package]]
name = "android-tzdata" name = "android-tzdata"
version = "0.1.1" version = "0.1.1"
@ -152,12 +146,6 @@ version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"
[[package]]
name = "beef"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1"
[[package]] [[package]]
name = "bit" name = "bit"
version = "0.1.1" version = "0.1.1"
@ -316,7 +304,7 @@ name = "clparse"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.ablecorp.us/ableos/ableos_userland#a45a19c6b7355ebdac53259d06a1894a096143e6" source = "git+https://git.ablecorp.us/ableos/ableos_userland#a45a19c6b7355ebdac53259d06a1894a096143e6"
dependencies = [ dependencies = [
"hashbrown 0.14.0", "hashbrown 0.12.3",
"log", "log",
"toml", "toml",
] ]
@ -868,37 +856,15 @@ dependencies = [
"ahash 0.8.3", "ahash 0.8.3",
] ]
[[package]]
name = "hashbrown"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a"
dependencies = [
"ahash 0.8.3",
"allocator-api2",
]
[[package]]
name = "hbasm"
version = "0.1.0"
source = "git+https://git.ablecorp.us/ableos/holey-bytes#b6ea49a1b5e45a3f64737ddd40707731e71ac1d2"
dependencies = [
"hashbrown 0.14.0",
"hbbytecode",
"lasso",
"logos",
"paste",
]
[[package]] [[package]]
name = "hbbytecode" name = "hbbytecode"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.ablecorp.us/ableos/holey-bytes#b6ea49a1b5e45a3f64737ddd40707731e71ac1d2" source = "git+https://git.ablecorp.us/ableos/holey-bytes#75995422262a192f2c87713d239856e98c799f41"
[[package]] [[package]]
name = "hbvm" name = "hbvm"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.ablecorp.us/ableos/holey-bytes#b6ea49a1b5e45a3f64737ddd40707731e71ac1d2" source = "git+https://git.ablecorp.us/ableos/holey-bytes#75995422262a192f2c87713d239856e98c799f41"
dependencies = [ dependencies = [
"delegate", "delegate",
"derive_more", "derive_more",
@ -1141,8 +1107,7 @@ dependencies = [
"derive_more", "derive_more",
"embedded-graphics", "embedded-graphics",
"error-stack 0.3.1", "error-stack 0.3.1",
"hashbrown 0.14.0", "hashbrown 0.12.3",
"hbasm",
"hbvm", "hbvm",
"limine", "limine",
"log", "log",
@ -1158,16 +1123,6 @@ dependencies = [
"xml", "xml",
] ]
[[package]]
name = "lasso"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4644821e1c3d7a560fe13d842d13f587c07348a1a05d3a797152d41c90c56df2"
dependencies = [
"ahash 0.8.3",
"hashbrown 0.13.2",
]
[[package]] [[package]]
name = "lazy_static" name = "lazy_static"
version = "1.4.0" version = "1.4.0"
@ -1216,38 +1171,6 @@ version = "0.4.19"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4"
[[package]]
name = "logos"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c000ca4d908ff18ac99b93a062cb8958d331c3220719c52e77cb19cc6ac5d2c1"
dependencies = [
"logos-derive",
]
[[package]]
name = "logos-codegen"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc487311295e0002e452025d6b580b77bb17286de87b57138f3b5db711cded68"
dependencies = [
"beef",
"fnv",
"proc-macro2",
"quote",
"regex-syntax 0.6.29",
"syn 2.0.23",
]
[[package]]
name = "logos-derive"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbfc0d229f1f42d790440136d941afd806bc9e949e2bcb8faa813b0f00d1267e"
dependencies = [
"logos-codegen",
]
[[package]] [[package]]
name = "lzma-sys" name = "lzma-sys"
version = "0.1.20" version = "0.1.20"
@ -1706,7 +1629,7 @@ dependencies = [
"aho-corasick", "aho-corasick",
"memchr", "memchr",
"regex-automata", "regex-automata",
"regex-syntax 0.7.3", "regex-syntax",
] ]
[[package]] [[package]]
@ -1717,15 +1640,9 @@ checksum = "83d3daa6976cffb758ec878f108ba0e062a45b2d6ca3a2cca965338855476caf"
dependencies = [ dependencies = [
"aho-corasick", "aho-corasick",
"memchr", "memchr",
"regex-syntax 0.7.3", "regex-syntax",
] ]
[[package]]
name = "regex-syntax"
version = "0.6.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
[[package]] [[package]]
name = "regex-syntax" name = "regex-syntax"
version = "0.7.3" version = "0.7.3"

0
a.out
View file

View file

@ -7,7 +7,7 @@ version = "0.2.0"
[dependencies] [dependencies]
hbvm = { git = "https://git.ablecorp.us/ableos/holey-bytes" } hbvm = { git = "https://git.ablecorp.us/ableos/holey-bytes" }
hbasm = { git = "https://git.ablecorp.us/ableos/holey-bytes" } # hbasm = { git = "https://git.ablecorp.us/ableos/holey-bytes" }
embedded-graphics = "0.7.1" embedded-graphics = "0.7.1"

View file

@ -63,49 +63,26 @@ pub enum HostError {
// // pub fn rpc_register(_engine: &mut Engine) {} // // pub fn rpc_register(_engine: &mut Engine) {}
// // pub fn rpc_call(_engine: &mut Engine) {} // // pub fn rpc_call(_engine: &mut Engine) {}
use log::error; use {hbvm::vm::mem::HandlePageFault, log::error};
use hbvm::vm::{
mem::{Memory, MemoryAccessReason, PageSize},
trap::HandleTrap,
value::Value,
};
/// AbleOS HBVM traphandler /// AbleOS HBVM traphandler
pub struct TrapHandler; pub struct TrapHandler;
impl HandleTrap for TrapHandler { impl HandlePageFault for TrapHandler {
fn page_fault( fn page_fault(
&mut self, &mut self,
mar: MemoryAccessReason, reason: hbvm::vm::mem::MemoryAccessReason,
memory: &mut Memory, memory: &mut hbvm::vm::mem::Memory,
vaddr: u64, vaddr: u64,
size: PageSize, size: hbvm::vm::mem::PageSize,
dataptr: *mut u8, dataptr: *mut u8,
) -> bool { ) -> bool {
error!( error!(
"MemoryAccessReason: {} "REASON: {}
Memory: {:?} memory: {:?}
VAddr: {} vaddr: {}
Size: {:?} size: {:?}
DataPTR: {:?}", Dataptr {:?}",
mar, memory, vaddr, size, dataptr reason, memory, vaddr, size, dataptr
); );
false false
} }
fn invalid_op(&mut self, _: &mut [Value; 256], _: &mut usize, _: &mut Memory, _: u8) -> bool
where
Self: Sized,
{
log::trace!("Invalid opcode");
false
}
fn ecall(&mut self, _: &mut [Value; 256], _: &mut usize, _: &mut Memory)
where
Self: Sized,
{
log::trace!("ableOS system call made");
}
} }

View file

@ -43,6 +43,7 @@ pub fn kmain(cmdline: &str, boot_modules: BootModules) -> ! {
let mut sched = Scheduler::new(); let mut sched = Scheduler::new();
// AHEM that isn't a valid HBVM program // AHEM that isn't a valid HBVM program
sched.new_process(boot_modules[0].bytes.clone()); sched.new_process(boot_modules[0].bytes.clone());
sched.new_process(boot_modules[1].bytes.clone());
sched.run(); sched.run();
// sloop(); // sloop();

View file

@ -4,9 +4,10 @@ use {
}; };
use {crate::host::TrapHandler, hbvm::vm::Vm}; use {crate::host::TrapHandler, hbvm::vm::Vm};
const TIMER_QUOTIENT: usize = 10_000_000;
pub struct Scheduler<'a> { pub struct Scheduler<'a> {
data: VecDeque<Vm<'a, TrapHandler>>, data: VecDeque<Vm<'a, TrapHandler, TIMER_QUOTIENT>>,
} }
// NOTE: This is a very simple schduler and it sucks and should be replaced with a better one // NOTE: This is a very simple schduler and it sucks and should be replaced with a better one
@ -40,7 +41,7 @@ impl Scheduler<'_> {
pub fn run(&mut self) -> ! { pub fn run(&mut self) -> ! {
loop { loop {
// If there are no programs to run sleep // If there are no programs to run then sleep.
if self.data.is_empty() { if self.data.is_empty() {
use crate::arch::sloop; use crate::arch::sloop;
sloop(); sloop();
@ -48,7 +49,9 @@ impl Scheduler<'_> {
let mut prog = self.data.pop_front().unwrap(); let mut prog = self.data.pop_front().unwrap();
prog.run().unwrap(); prog.run().unwrap();
log::trace!("VM registers {:?}", prog.registers);
// log::info!("VM registers {:?}", prog.registers);
log::info!("Scheduled program");
self.data.push_back(prog); self.data.push_back(prog);
} }
} }

BIN
repbuild/inf_loop.hb Normal file

Binary file not shown.

View file

@ -18,8 +18,8 @@ TERM_BACKDROP=008080
# Setting a default resolution for the framebuffer # Setting a default resolution for the framebuffer
RESOLUTION=1024x768x24 RESOLUTION=1024x768x24
MODULE_PATH=boot:///background.bmp MODULE_PATH=boot:///inf_loop.hb
MODULE_CMDLINE="diskid=123456789" MODULE_CMDLINE="diskid=123456789"
MODULE_PATH=boot:///background.bmp MODULE_PATH=boot:///inf_loop.hb
MODULE_CMDLINE="" MODULE_CMDLINE=""

View file

@ -115,6 +115,10 @@ fn get_fs() -> Result<FileSystem<impl ReadWriteSeek>, io::Error> {
&mut File::open("repbuild/background.bmp")?, &mut File::open("repbuild/background.bmp")?,
&mut fs.root_dir().create_file("background.bmp")?, &mut fs.root_dir().create_file("background.bmp")?,
)?; )?;
io::copy(
&mut File::open("repbuild/inf_loop.hb")?,
&mut fs.root_dir().create_file("inf_loop.hb")?,
)?;
drop(bootdir); drop(bootdir);
Ok(fs) Ok(fs)