forked from koniifer/ableos
SEARCHING for dynamically created buffers now works using buffer.create / buffer.search
This commit is contained in:
parent
c7214a5a9b
commit
f4246ae387
|
@ -68,7 +68,7 @@ pub fn handler(vm: &mut Vm) {
|
|||
let buffer_id = vm.registers[3].cast::<u64>();
|
||||
let mem_addr = vm.registers[4].cast::<u64>();
|
||||
let length = vm.registers[5].cast::<u64>() as usize;
|
||||
debug!("IPC address: {:?}", mem_addr);
|
||||
trace!("IPC address: {:?}", mem_addr);
|
||||
use alloc::vec::Vec;
|
||||
|
||||
match buffer_id {
|
||||
|
@ -111,7 +111,7 @@ pub fn handler(vm: &mut Vm) {
|
|||
|
||||
let value = unsafe { x86_in(addr) };
|
||||
|
||||
info!("Read the value {} from address {}", value, addr);
|
||||
trace!("Read the value {} from address {}", value, addr);
|
||||
vm.registers[1] = hbvm::value::Value(value as u64);
|
||||
}
|
||||
1 => {
|
||||
|
@ -125,7 +125,7 @@ pub fn handler(vm: &mut Vm) {
|
|||
|
||||
let value = msg_vec[0];
|
||||
msg_vec.remove(0);
|
||||
info!("Setting the address {} to {}", addr, value);
|
||||
trace!("Setting the address {} to {}", addr, value);
|
||||
unsafe { x86_out(addr, value) };
|
||||
}
|
||||
_ => {}
|
||||
|
|
|
@ -22,14 +22,21 @@ pub fn sds_msg_handler(vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(),
|
|||
let sds_event_type: ServiceEventType = msg_vec[0].into();
|
||||
msg_vec.remove(0);
|
||||
|
||||
info!("Length {}", msg_vec.len());
|
||||
|
||||
use ServiceEventType::*;
|
||||
match sds_event_type {
|
||||
CreateService => {
|
||||
let string = String::from_utf8(msg_vec).expect("Our bytes should be valid utf8");
|
||||
sds_create_service(string);
|
||||
let ret = sds_create_service(string);
|
||||
vm.registers[1] = hbvm::value::Value(ret as u64);
|
||||
}
|
||||
DeleteService => todo!(),
|
||||
SearchServices => todo!(),
|
||||
SearchServices => {
|
||||
let string = String::from_utf8(msg_vec).expect("Our bytes should be valid utf8");
|
||||
let ret = sds_search_service(string);
|
||||
vm.registers[1] = hbvm::value::Value(ret as u64);
|
||||
}
|
||||
}
|
||||
// let buffer_id_raw = &msg_vec[0..8];
|
||||
// let mut arr = [0u8; 8];
|
||||
|
@ -67,8 +74,23 @@ impl From<u8> for ServiceEventType {
|
|||
fn sds_create_service(protocol: String) -> u64 {
|
||||
let buff_id = hardware_random_u64();
|
||||
let mut services = SERVICES.lock();
|
||||
services.0.insert(buff_id, protocol.clone().into());
|
||||
info!("BufferID({}) => {}", buff_id, protocol);
|
||||
let a: protocol::Protocol = protocol.into();
|
||||
|
||||
let protocol_ = Protocol::from(protocol.clone());
|
||||
|
||||
services.0.insert(buff_id, protocol_);
|
||||
trace!("BufferID({}) => {}", buff_id, protocol);
|
||||
// let a: protocol::Protocol = protocol.into();
|
||||
buff_id
|
||||
}
|
||||
|
||||
fn sds_search_service(protocol: String) -> u64 {
|
||||
let mut services = SERVICES.lock();
|
||||
let compare = Protocol::from(protocol.clone());
|
||||
for (bid, protocol_canidate) in &services.0 {
|
||||
if protocol_canidate == &compare {
|
||||
trace!("BufferID({}) => {}", bid, protocol.clone());
|
||||
return *bid;
|
||||
}
|
||||
}
|
||||
0
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ impl IpcBuffer {
|
|||
bounded,
|
||||
length
|
||||
);
|
||||
|
||||
match (bounded, length) {
|
||||
(false, a) => {
|
||||
let buftype = BufferTypes::Unbound(SegQueue::new());
|
||||
|
|
|
@ -3,13 +3,14 @@ use {
|
|||
hashbrown::HashMap,
|
||||
log::info,
|
||||
};
|
||||
|
||||
#[derive(PartialEq)]
|
||||
pub struct Type {}
|
||||
#[derive(PartialEq)]
|
||||
pub struct Funct {
|
||||
takes: Vec<String>,
|
||||
gives: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
pub struct Protocol {
|
||||
types: HashMap<String, Type>,
|
||||
fns: HashMap<String, Funct>,
|
||||
|
@ -29,11 +30,10 @@ impl Protocol {
|
|||
|
||||
impl From<String> for Protocol {
|
||||
fn from(value: alloc::string::String) -> Self {
|
||||
if value.starts_with("protocol") {
|
||||
info!("ABC");
|
||||
}
|
||||
let mut hm_t = HashMap::new();
|
||||
hm_t.insert(value, Type {});
|
||||
Self {
|
||||
types: HashMap::new(),
|
||||
types: hm_t,
|
||||
fns: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,9 +11,15 @@ send_message := fn(buffer_id: int): void {
|
|||
return
|
||||
}
|
||||
|
||||
create := fn(): int {
|
||||
msg := "\{01}Number\0"
|
||||
create := fn(msg: ^u8): int {
|
||||
msg_length := string.length(msg);
|
||||
*msg = 0
|
||||
return @eca(int, 1, 0, msg, msg_length)
|
||||
return @eca(int, 3, 0, msg, msg_length)
|
||||
}
|
||||
|
||||
search := fn(msg: ^u8): int {
|
||||
msg_length := string.length(msg);
|
||||
*msg = 3
|
||||
|
||||
return @eca(int, 3, 0, msg, msg_length)
|
||||
}
|
11
sysdata/programs/serial_driver/meta.toml
Normal file
11
sysdata/programs/serial_driver/meta.toml
Normal file
|
@ -0,0 +1,11 @@
|
|||
[package]
|
||||
name = "serial_driver"
|
||||
authors = ["Able"]
|
||||
|
||||
[dependants.libraries]
|
||||
|
||||
[dependants.binaries]
|
||||
hblang.version = "1.0.0"
|
||||
|
||||
[build]
|
||||
command = "hblang src/main.hb"
|
|
@ -1,7 +1,31 @@
|
|||
stn := @use("../../../libraries/stn/src/lib.hb");
|
||||
.{log, string, memory, buffer} := stn
|
||||
|
||||
serial_print := fn(ptr: ^u8): void {
|
||||
letter := 0
|
||||
loop if *ptr == 0 break else {
|
||||
letter = *ptr
|
||||
memory.outb(3, 248, letter)
|
||||
ptr += 1
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
serial_println := fn(ptr: ^u8): void {
|
||||
serial_print(ptr)
|
||||
memory.outb(3, 248, 12)
|
||||
memory.outb(3, 248, 13)
|
||||
return
|
||||
}
|
||||
|
||||
main := fn(): int {
|
||||
arch := "Arm";
|
||||
ADDR := 0x09000000;
|
||||
loop { }
|
||||
return 0;
|
||||
serial_println("Starting Serial Driver.\0")
|
||||
// Note that the first byte is reserved, pad accordingly.
|
||||
a := buffer.create("XNumber\0")
|
||||
b := buffer.search("XNumber\0")
|
||||
|
||||
if a == b {
|
||||
serial_println("Stopping Serial Driver.\0")
|
||||
}
|
||||
return 0
|
||||
}
|
|
@ -5,7 +5,6 @@ s := stn.string
|
|||
page := 0
|
||||
|
||||
main := fn(): void {
|
||||
|
||||
page += mem.request_page(1)
|
||||
port_str := "\0\0\{47}\0"
|
||||
a := @eca(u8, 3, 3, port_str, 4)
|
||||
|
|
|
@ -19,12 +19,12 @@ resolution = "1024x768x24"
|
|||
|
||||
# [boot.limine.ableos.modules.tests]
|
||||
# path = "boot:///tests.hbf"
|
||||
[boot.limine.ableos.modules.serial_driver]
|
||||
path = "boot:///serial_driver.hbf"
|
||||
|
||||
|
||||
[boot.limine.ableos.modules.diskio_driver]
|
||||
path = "boot:///diskio_driver.hbf"
|
||||
|
||||
[boot.limine.ableos.modules.fb_driver]
|
||||
path = "boot:///fb_driver.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.time_driver]
|
||||
# path = "boot:///time_driver.hbf"
|
||||
|
|
Loading…
Reference in a new issue