1
0
Fork 0
forked from AbleOS/ableos

more changes

This commit is contained in:
able 2024-02-15 14:21:00 -06:00
parent 7c68609af5
commit 89b495d318
6 changed files with 87 additions and 6 deletions

View file

@ -324,7 +324,7 @@ impl Heap {
(unsafe { *self.bitmap.add(index / 8) } & (1 << (index % 8))) != 0
}
const fn free_chunks(&self) -> usize {
pub const fn free_chunks(&self) -> usize {
self.total_chunks - self.allocated_chunks
}
@ -345,3 +345,7 @@ fn alloc_error_handler(layout: alloc::alloc::Layout) -> ! {
// Todo: Maybe panic here instead
crate::arch::spin_loop()
}
pub fn get_free_chunks_count() -> usize {
ALLOCATOR.0.lock().as_ref().unwrap().free_chunks()
}

View file

@ -1,5 +1,7 @@
//! Environment call handling routines
use crate::allocator;
use {
super::{mem::Memory, Vm},
crate::{arch, holeybytes::mem, ipc::buffer::IpcBuffer, kmain::IPC_BUFFERS},
@ -71,7 +73,10 @@ pub fn handler(vm: &mut Vm) {
Err(err) => log::error!("Improper log format"),
},
2 => match memory_msg_handler(vm, mem_addr, length) {
Ok(()) => {}
Ok(()) => {
let free_chunks = allocator::get_free_chunks_count();
debug!("Free chunk count: {}", free_chunks);
}
Err(err) => log::error!("Improper log format"),
},
buffer_id => {

View file

@ -2,6 +2,7 @@
use {
crate::{
arch::hardware_random_u64,
bootmodules::{build_cmd, BootModules},
capabilities,
device_tree::DeviceTree,
@ -93,6 +94,8 @@ pub fn kmain(cmdline: &str, boot_modules: BootModules) -> ! {
});
}
info!("{}", hardware_random_u64());
executor.run();
};

View file

@ -1,10 +1,14 @@
use std::{fs, io::Write, process::exit};
use {
derive_more::Display,
error_stack::{bail, report, Context, Report, Result, ResultExt},
fatfs::{FileSystem, FormatVolumeOptions, FsOptions, ReadWriteSeek},
std::{fmt::Display, fs::File, io, path::Path, process::Command},
std::{
fmt::Display,
fs::{self, File},
io::{self, Write},
path::Path,
process::{exit, Command},
},
};
fn main() -> Result<(), Error> {

View file

@ -1,10 +1,22 @@
Boolean
Stuffed into a u8 to be indexed into
00_00_00_01
^^--- One Boolean
|the Second Boolean
UTF8 String
"Able The Above" => UTF8 14 bytes long
Date Time (U128 seconds since the beginning of the universe)
Binary Blob
List<T>
Ordered/Unordered
Bound/Unbound
// Ordered/Unordered
Examples:
OSPath Is Unbounded List <String>
Hashmap<K, V>

53
sysdata/testing.idl Normal file
View file

@ -0,0 +1,53 @@
type String {
length uint32,
data [u8; length],
}
// needs three bits to store this
@exhaustive
enum LogLevel {
Error = 0,
Warn = 1,
Info = 2,
Debug = 3,
Trace = 4,
}
type LogMessage {
log_level = LogLevel,
log_message = String,
}
// This is displayed as bits sent over the wire
[
010 // INFO
00000000_00000000_00000000_00000011 // Length of the string
01001000 // H
01101001 // i
00100001 // !
]
enum LogResult {
Ok,
Error,
}
protocol Logger {
fn log(LogMessage) -> LogResult;
fn flush() -> LogResult;
}