Getting some basic userland logger setup

pull/11/head
able 2023-10-28 08:28:07 -05:00
parent 71465c317d
commit e4d63de7c5
9 changed files with 59 additions and 16 deletions

6
Cargo.lock generated
View File

@ -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",
]

View File

@ -7,14 +7,12 @@ use {
};
pub fn handler(vm: &mut Vm) {
let r255 = vm.registers[255].cast::<u64>();
let r254 = vm.registers[254].cast::<u64>();
let r253 = vm.registers[253].cast::<u64>();
let r1 = vm.registers[1].cast::<u64>();
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::<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,
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 abc;
@ -80,7 +75,7 @@ pub fn handler(vm: &mut Vm) {
// 4
// 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
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:?}");

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);
eca ();
// eca ();
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_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")?,
)?;
io::copy(
&mut File::open("target/holeybytes/main.hbf")?,
&mut fs.root_dir().create_file("main.hbf")?,
)?;
drop(bootdir);
Ok(fs)
}