Compare commits
2 commits
9686349476
...
ec25c0f207
Author | SHA1 | Date | |
---|---|---|---|
Able | ec25c0f207 | ||
Able | 1b5cb54a2b |
|
@ -7,6 +7,7 @@ use crate::{
|
|||
holeybytes::kernel_services::{
|
||||
block_read,
|
||||
dt_msg_handler::dt_msg_handler,
|
||||
logging_service::log_msg_handler,
|
||||
service_definition_service::{sds_msg_handler, SERVICES},
|
||||
},
|
||||
};
|
||||
|
@ -145,6 +146,7 @@ pub fn handler(vm: &mut Vm) {
|
|||
let mut buffs = IPC_BUFFERS.lock();
|
||||
match buffs.get_mut(&buffer_id) {
|
||||
Some(buff) => {
|
||||
use alloc::vec;
|
||||
let mut msg_vec = vec![];
|
||||
|
||||
for x in 0..(length as isize) {
|
||||
|
@ -222,40 +224,6 @@ pub fn handler(vm: &mut Vm) {
|
|||
}
|
||||
}
|
||||
|
||||
fn log_msg_handler(vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), LogError> {
|
||||
// let message_length = 8 + 8 + 8;
|
||||
// log::info!("Mem Addr 0x{:x?} length {}", mem_addr, length);
|
||||
let mut msg_vec = block_read(mem_addr, length);
|
||||
|
||||
let log_level = msg_vec.pop().unwrap();
|
||||
match String::from_utf8(msg_vec) {
|
||||
Ok(strr) => {
|
||||
// use LogLevel::*;
|
||||
let ll = match log_level {
|
||||
0 | 48 => error!("{}", strr),
|
||||
1 | 49 => warn!("{}", strr),
|
||||
2 | 50 => info!("{}", strr),
|
||||
3 | 51 => debug!("{}", strr),
|
||||
4 | 52 => trace!("{}", strr),
|
||||
_ => {
|
||||
return Err(LogError::InvalidLogFormat);
|
||||
}
|
||||
};
|
||||
}
|
||||
Err(e) => {
|
||||
error!("{:?}", e);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum LogError {
|
||||
InvalidLogFormat,
|
||||
}
|
||||
use {alloc::vec, log::Record};
|
||||
|
||||
// fn memory_msg_handler(vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), LogError> {
|
||||
// let mut val = alloc::vec::Vec::new();
|
||||
// for _ in 0..4096 {
|
||||
|
|
54
kernel/src/holeybytes/kernel_services/logging_service.rs
Normal file
54
kernel/src/holeybytes/kernel_services/logging_service.rs
Normal file
|
@ -0,0 +1,54 @@
|
|||
use crate::logger::TermLogger;
|
||||
|
||||
use {
|
||||
crate::holeybytes::{kernel_services::block_read, Vm},
|
||||
alloc::string::String,
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum LogError {
|
||||
InvalidLogFormat,
|
||||
}
|
||||
use {alloc::vec, log::Record};
|
||||
|
||||
pub fn log_msg_handler(vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), LogError> {
|
||||
let mut msg_vec = block_read(mem_addr, length);
|
||||
|
||||
let log_level = msg_vec.pop().unwrap();
|
||||
|
||||
let file_name = "None";
|
||||
let line_number = 0;
|
||||
|
||||
match String::from_utf8(msg_vec) {
|
||||
Ok(strr) => {
|
||||
use log::Level::*;
|
||||
let log_level = match log_level {
|
||||
0 | 48 => Error,
|
||||
1 | 49 => Warn,
|
||||
2 | 50 => Info,
|
||||
3 | 51 => Debug,
|
||||
4 | 52 => Trace,
|
||||
_ => {
|
||||
return Err(LogError::InvalidLogFormat);
|
||||
}
|
||||
};
|
||||
|
||||
log::logger().log(
|
||||
&Record::builder()
|
||||
.args(format_args!("{}", strr))
|
||||
.level(log_level)
|
||||
.target("Userspace")
|
||||
.file(Some(file_name))
|
||||
.line(Some(line_number))
|
||||
.module_path(Some(&file_name))
|
||||
.build(),
|
||||
);
|
||||
}
|
||||
|
||||
Err(e) => {
|
||||
log::error!("{:?}", e);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
use {
|
||||
crate::holeybytes::{
|
||||
ecah::LogError,
|
||||
kernel_services::{block_read, mem_serve},
|
||||
Vm,
|
||||
},
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use alloc::{vec, vec::Vec};
|
||||
|
||||
pub mod dt_msg_handler;
|
||||
pub mod logging_service;
|
||||
pub mod mem_serve;
|
||||
pub mod service_definition_service;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ use {
|
|||
crate::{
|
||||
alloc::string::ToString,
|
||||
arch::hardware_random_u64,
|
||||
holeybytes::{ecah::LogError, kernel_services::block_read, Vm},
|
||||
holeybytes::{kernel_services::block_read, Vm},
|
||||
ipc::{
|
||||
buffer::IpcBuffer,
|
||||
protocol::{self, Protocol},
|
||||
|
@ -20,8 +20,10 @@ pub static SERVICES: Lazy<Mutex<Services>> = Lazy::new(|| {
|
|||
dt.0.insert(0, Protocol::void());
|
||||
Mutex::new(dt)
|
||||
});
|
||||
|
||||
pub fn sds_msg_handler(vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), LogError> {
|
||||
pub enum ServiceError {
|
||||
InvalidFormat,
|
||||
}
|
||||
pub fn sds_msg_handler(vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), ServiceError> {
|
||||
let mut msg_vec = block_read(mem_addr, length);
|
||||
let sds_event_type: ServiceEventType = msg_vec[0].into();
|
||||
msg_vec.remove(0);
|
||||
|
|
16
sysdata/libraries/ignim/src/errors.hb
Normal file
16
sysdata/libraries/ignim/src/errors.hb
Normal file
|
@ -0,0 +1,16 @@
|
|||
// the 0- thing is scuffed
|
||||
|
||||
OutOfHostMemory := 0 - 1
|
||||
OutOfDeviceMemory := 0 - 2
|
||||
InitializationFailed := 0 - 3
|
||||
DeviceLost := 0 - 4
|
||||
MemoryMapFailed := 0 - 5
|
||||
|
||||
LayerNotPresent := 0 - 6
|
||||
ExtensionNotPresent := 0 - 7
|
||||
FeatureNotPresent := 0 - 8
|
||||
IncompatibleDriver := 0 - 9
|
||||
TooManyObjects := 0 - 10
|
||||
FormatNotSupported := 0 - 11
|
||||
FragmentedPool := 0 - 12
|
||||
Unknown := 0 - 13
|
|
@ -1,7 +1,9 @@
|
|||
VK_VERSION_MAJOR := 1;
|
||||
VK_VERSION_MINOR := 0;
|
||||
results := @use("rel:results.hb")
|
||||
errors := @use("rel:errors.hb")
|
||||
|
||||
init_vulkan := fn(): void {
|
||||
|
||||
return
|
||||
VK_VERSION_MAJOR := 1
|
||||
VK_VERSION_MINOR := 0
|
||||
|
||||
init_vulkan := fn(): int {
|
||||
return errors.IncompatibleDriver
|
||||
}
|
7
sysdata/libraries/ignim/src/results.hb
Normal file
7
sysdata/libraries/ignim/src/results.hb
Normal file
|
@ -0,0 +1,7 @@
|
|||
// NonErrors
|
||||
Success := 0
|
||||
NotReady := 1
|
||||
Timeout := 2
|
||||
EventSet := 3
|
||||
EventReset := 4
|
||||
Incomplete := 5
|
|
@ -1,8 +1,14 @@
|
|||
dt_api := @use("../../../libraries/dt_api/src/lib.hb")
|
||||
dt_api := @use("../../../libraries/dt_api/src/lib.hb");
|
||||
.{dt_get} := dt_api
|
||||
|
||||
main := fn(): int {
|
||||
dt_api.dt_get("framebuffer/fb0/width\0")
|
||||
dt_api.dt_get("cpu/architecture\0")
|
||||
dt_api.dt_get("cpu/cpu0/architecture\0")
|
||||
|
||||
// Checking if the first detected serial port is memory mapped or port mapped
|
||||
// 0 -> memory mapped
|
||||
// 1 -> port mapped
|
||||
dt_get("serial_ports/sp0/mapping\0")
|
||||
|
||||
return 0
|
||||
}
|
|
@ -4,9 +4,19 @@ stn := @use("../../../libraries/stn/src/lib.hb");
|
|||
horizon_api := @use("../../../libraries/horizon_api/src/lib.hb");
|
||||
.{create_window} := horizon_api
|
||||
|
||||
ignim := @use("../../../libraries/ignim/src/lib.hb");
|
||||
.{init_vulkan} := ignim
|
||||
|
||||
main := fn(): int {
|
||||
windowing_system_buffer := buffer.create("XHorizon\0")
|
||||
|
||||
create_window(windowing_system_buffer)
|
||||
// TODO: get WindowID
|
||||
|
||||
vk_state := init_vulkan()
|
||||
if vk_state == ignim.errors.IncompatibleDriver {
|
||||
stn.log.info("Incompatible Vulkan Driver\0")
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
|
@ -19,19 +19,19 @@ resolution = "1024x768x24"
|
|||
|
||||
# [boot.limine.ableos.modules.tests]
|
||||
# path = "boot:///tests.hbf"
|
||||
[boot.limine.ableos.modules.a_serial_driver]
|
||||
path = "boot:///a_serial_driver.hbf"
|
||||
# [boot.limine.ableos.modules.a_serial_driver]
|
||||
# path = "boot:///a_serial_driver.hbf"
|
||||
|
||||
|
||||
[boot.limine.ableos.modules.diskio_driver]
|
||||
path = "boot:///diskio_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.serial_driver_test]
|
||||
path = "boot:///serial_driver_test.hbf"
|
||||
# [boot.limine.ableos.modules.serial_driver_test]
|
||||
# path = "boot:///serial_driver_test.hbf"
|
||||
|
||||
|
||||
[boot.limine.ableos.modules.horizon]
|
||||
|
@ -41,5 +41,5 @@ path = "boot:///horizon.hbf"
|
|||
path = "boot:///horizon_testing_program.hbf"
|
||||
|
||||
|
||||
[boot.limine.ableos.modules.dt_buffer_test]
|
||||
path = "boot:///dt_buffer_test.hbf"
|
||||
# [boot.limine.ableos.modules.dt_buffer_test]
|
||||
# path = "boot:///dt_buffer_test.hbf"
|
||||
|
|
Loading…
Reference in a new issue