1
0
Fork 0
forked from koniifer/ableos

Getting some basic userland logger setup

This commit is contained in:
able 2023-10-28 08:28:07 -05:00
parent 6885f1cdaf
commit c8f500470e
9 changed files with 59 additions and 16 deletions

6
Cargo.lock generated
View file

@ -457,7 +457,7 @@ dependencies = [
[[package]] [[package]]
name = "hbasm" name = "hbasm"
version = "0.1.0" 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 = [ dependencies = [
"paste", "paste",
"rhai", "rhai",
@ -467,7 +467,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#7b1f6d535db3ac4163b45967d963d31f2c577898" source = "git+https://git.ablecorp.us/ableos/holey-bytes#0f619887c613be3fb3a7dd8c970b7ee76ad0d23b"
dependencies = [ dependencies = [
"with_builtin_macros", "with_builtin_macros",
] ]
@ -475,7 +475,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#7b1f6d535db3ac4163b45967d963d31f2c577898" source = "git+https://git.ablecorp.us/ableos/holey-bytes#0f619887c613be3fb3a7dd8c970b7ee76ad0d23b"
dependencies = [ dependencies = [
"hbbytecode", "hbbytecode",
] ]

View file

@ -7,14 +7,12 @@ use {
}; };
pub fn handler(vm: &mut Vm) { pub fn handler(vm: &mut Vm) {
let r255 = vm.registers[255].cast::<u64>(); let r1 = vm.registers[1].cast::<u64>();
let r254 = vm.registers[254].cast::<u64>();
let r253 = vm.registers[253].cast::<u64>();
debug!("Ecall number {:?}", r255); debug!("Ecall number {:?}", r1);
trace!("Register dump: {:?}", vm.registers); trace!("Register dump: {:?}", vm.registers);
match r255 { match r1 {
0 => { 0 => {
// TODO: explode computer // TODO: explode computer
// hello world ecall // hello world ecall
@ -24,11 +22,8 @@ pub fn handler(vm: &mut Vm) {
} }
1 => { 1 => {
// Make buffer // Make buffer
let r255 = vm.registers[255].cast::<u64>();
let r254 = vm.registers[254].cast::<u64>();
let r253 = vm.registers[253].cast::<u64>();
let bounded = match r254 { let bounded = match vm.registers[2].cast::<u64>() {
0 => false, 0 => false,
1 => true, 1 => true,
_ => { _ => {
@ -36,7 +31,7 @@ pub fn handler(vm: &mut Vm) {
} }
}; };
let length = r254; let length = vm.registers[3].cast::<u64>();
let mut buffs = IPC_BUFFERS.lock(); let mut buffs = IPC_BUFFERS.lock();
let abc; let abc;
@ -80,7 +75,7 @@ pub fn handler(vm: &mut Vm) {
// 4 // 4
// 5 // 5
_ => { _ => {
log::error!("Syscall unknown {:?}", r255) log::error!("Syscall unknown {:?}", r1);
} }
} }
} }

View file

@ -44,8 +44,9 @@ pub fn kmain(cmdline: &str, boot_modules: BootModules) -> ! {
// TODO: schedule the init system from the initramfs // TODO: schedule the init system from the initramfs
let mut executor = crate::task::Executor::default(); let mut executor = crate::task::Executor::default();
let bm_take = boot_modules.len();
unsafe { unsafe {
for module in boot_modules.into_iter().take(2) { for module in boot_modules.into_iter().take(bm_take) {
executor.spawn(async move { executor.spawn(async move {
if let Err(e) = ExecThread::new(&module.bytes, Address::new(0)).await { if let Err(e) = ExecThread::new(&module.bytes, Address::new(0)).await {
log::error!("{e:?}"); log::error!("{e:?}");

1
repbuild/hblib/readme.md Normal file
View file

@ -0,0 +1 @@
A kind of standard library.

25
repbuild/hblib/std.rhai Normal file
View file

@ -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);}

View file

@ -1,3 +1,3 @@
li8 (r1, 0x69); li8 (r1, 0x69);
eca (); // eca ();
tx (); tx ();

View file

@ -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();

View file

@ -23,3 +23,6 @@ TERM_BACKDROP=008080
MODULE_PATH=boot:///ecall.hbf MODULE_PATH=boot:///ecall.hbf
MODULE_CMDLINE="" MODULE_CMDLINE=""
MODULE_PATH=boot:///main.hbf
MODULE_CMDLINE=""

View file

@ -157,6 +157,11 @@ fn get_fs() -> Result<FileSystem<impl ReadWriteSeek>, io::Error> {
&mut fs.root_dir().create_file("ecall.hbf")?, &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); drop(bootdir);
Ok(fs) Ok(fs)
} }