forked from AbleOS/ableos
55 lines
1.1 KiB
Plaintext
55 lines
1.1 KiB
Plaintext
fn ipc_send(buffer_id, mem_addr, length){
|
|
// set the ecall
|
|
li64(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();
|
|
}
|
|
|
|
|
|
fn ipc_recv(buffer_id){
|
|
li64(r1, 4);
|
|
eca();
|
|
}
|
|
|
|
|
|
fn ipc_make_bound_buffer(length) {
|
|
li64(r1, 1);
|
|
li64(r2, 1);
|
|
li64(r3, length);
|
|
eca();
|
|
|
|
// The ipc buffer id is in r1
|
|
}
|
|
|
|
private fn log(log_level, string){
|
|
// This is NOT the final format
|
|
let str = data::str(string + log_level);
|
|
|
|
// 1 byte for the log level
|
|
// 8 bytes for the length to the message
|
|
// 8 bytes for the pointer to the 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);}
|
|
|
|
|
|
fn open(string_path){
|
|
let file_path = data::str(string_path);
|
|
ipc_send(2, file_path, file_path.len);
|
|
}
|
|
fn write(){}
|
|
fn read(){}
|
|
fn close(){} |