1
0
Fork 0
forked from AbleOS/ableos
This commit is contained in:
Able 2024-09-19 06:05:11 -05:00
parent 2edc8148ca
commit 07c7d52b8c
7 changed files with 76 additions and 6 deletions

View file

@ -22,7 +22,7 @@ unsafe impl Send for SerialConsole {}
pub fn log(args: core::fmt::Arguments<'_>) -> core::fmt::Result {
SERIAL_CONSOLE.lock().write_fmt(args)?;
TERMINAL_LOGGER.lock().write_fmt(args)?;
// TERMINAL_LOGGER.lock().write_fmt(args)?;
Ok(())
}

35
kernel/src/exe_format.rs Normal file
View file

@ -0,0 +1,35 @@
enum Sections {
Header,
Code,
Data,
Debug,
Config,
Metadata,
}
// 64 byte header
#[repr(packed)]
struct AbleOsExecutableHeader {
magic_number: [u8; 3],
executable_version: u32,
code_length: u64,
data_length: u64,
debug_length: u64,
config_length: u64,
metadata_length: u64,
}
impl AbleOsExecutableHeader {
fn new() -> Self {
Self {
magic_number: [0x15, 0x91, 0xD2],
executable_version: 0,
code_length: 0,
config_length: 0,
data_length: 0,
debug_length: 0,
metadata_length: 0,
}
}
}

View file

@ -74,7 +74,25 @@ pub fn kmain(_cmdline: &str, boot_modules: BootModules) -> ! {
log::info!("Spawning {} with arguments \"{}\"", module.path, cmd);
let mut thr = ExecThread::new(&module.bytes, Address::new(0));
// decode AbleOS Executable format
let header = &module.bytes[0..46];
let magic_slice = &header[0..3];
if magic_slice != [0x15, 0x91, 0xD2] {
log::warn!("Non-AbleOS Executable was attempted to be run.")
}
let executable_format_version = u32::from_be_bytes(header[3..7].try_into().unwrap());
let offset = if executable_format_version == 0 {
47
} else {
0
};
// let code_length = u64::from_be_bytes(header[7..15].try_into().unwrap());
// let data_length = u64::from_be_bytes(header[15..23].try_into().unwrap());
// let end = (code_length + data_length) as usize;
let mut thr = ExecThread::new(&module.bytes[offset..], Address::new(0));
if cmd_len > 0 {
thr.set_arguments(cmd.as_ptr() as u64, cmd_len);
}

View file

@ -22,6 +22,7 @@ mod arch;
mod bootmodules;
mod capabilities;
mod device_tree;
mod exe_format;
mod handle;
mod holeybytes;
mod ipc;

View file

@ -1,16 +1,31 @@
//! This is a reserved file for use with the AbleOS Clustering System
HostID := int
ID := int
FileID := struct {
host_id: HostID,
id: int,
id: ID,
}
// A DeviceID points to a specific device in the ACS.
DeviceID := struct {
host_id: HostID,
id: int,
id: ID,
}
DiskID := DeviceID
BufferID := struct {
host_id: HostID,
id: ID,
}
DiskID := DeviceID
ProcessID := struct {
host_id: HostID,
id: ID,
}
WindowID := struct {
host_id: HostID,
id: ID,
}

View file

@ -2,6 +2,7 @@
name = "pumpkin_print"
authors = [""]
[dependants.libraries]
[dependants.binaries]

View file

@ -1,4 +1,4 @@
.{example} := @use("./examples/random.hb")
.{example} := @use("./examples/square.hb")
main := fn(): void {
@inline(example)