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 { pub fn log(args: core::fmt::Arguments<'_>) -> core::fmt::Result {
SERIAL_CONSOLE.lock().write_fmt(args)?; SERIAL_CONSOLE.lock().write_fmt(args)?;
TERMINAL_LOGGER.lock().write_fmt(args)?; // TERMINAL_LOGGER.lock().write_fmt(args)?;
Ok(()) 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); 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 { if cmd_len > 0 {
thr.set_arguments(cmd.as_ptr() as u64, cmd_len); thr.set_arguments(cmd.as_ptr() as u64, cmd_len);
} }

View file

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

View file

@ -1,16 +1,31 @@
//! This is a reserved file for use with the AbleOS Clustering System //! This is a reserved file for use with the AbleOS Clustering System
HostID := int HostID := int
ID := int
FileID := struct { FileID := struct {
host_id: HostID, host_id: HostID,
id: int, id: ID,
} }
// A DeviceID points to a specific device in the ACS. // A DeviceID points to a specific device in the ACS.
DeviceID := struct { DeviceID := struct {
host_id: HostID, 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" name = "pumpkin_print"
authors = [""] authors = [""]
[dependants.libraries] [dependants.libraries]
[dependants.binaries] [dependants.binaries]

View file

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