diff --git a/kernel/src/arch/aarch64/logging.rs b/kernel/src/arch/aarch64/logging.rs index 0f968b7e..231cf397 100644 --- a/kernel/src/arch/aarch64/logging.rs +++ b/kernel/src/arch/aarch64/logging.rs @@ -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(()) } diff --git a/kernel/src/exe_format.rs b/kernel/src/exe_format.rs new file mode 100644 index 00000000..2d020b1c --- /dev/null +++ b/kernel/src/exe_format.rs @@ -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, + } + } +} diff --git a/kernel/src/kmain.rs b/kernel/src/kmain.rs index f6d55309..efff4584 100644 --- a/kernel/src/kmain.rs +++ b/kernel/src/kmain.rs @@ -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); } diff --git a/kernel/src/lib.rs b/kernel/src/lib.rs index 1a12eeff..fd0b1dd6 100644 --- a/kernel/src/lib.rs +++ b/kernel/src/lib.rs @@ -22,6 +22,7 @@ mod arch; mod bootmodules; mod capabilities; mod device_tree; +mod exe_format; mod handle; mod holeybytes; mod ipc; diff --git a/sysdata/libraries/stn/src/acs.hb b/sysdata/libraries/stn/src/acs.hb index 5f2a2509..e5c7bbbc 100644 --- a/sysdata/libraries/stn/src/acs.hb +++ b/sysdata/libraries/stn/src/acs.hb @@ -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 \ No newline at end of file +ProcessID := struct { + host_id: HostID, + id: ID, +} + +WindowID := struct { + host_id: HostID, + id: ID, +} \ No newline at end of file diff --git a/sysdata/programs/pumpkin_print/meta.toml b/sysdata/programs/pumpkin_print/meta.toml index c1c49b29..23bec9bb 100644 --- a/sysdata/programs/pumpkin_print/meta.toml +++ b/sysdata/programs/pumpkin_print/meta.toml @@ -2,6 +2,7 @@ name = "pumpkin_print" authors = [""] + [dependants.libraries] [dependants.binaries] diff --git a/sysdata/programs/render_example/src/main.hb b/sysdata/programs/render_example/src/main.hb index 336f76d1..052e1cf1 100644 --- a/sysdata/programs/render_example/src/main.hb +++ b/sysdata/programs/render_example/src/main.hb @@ -1,4 +1,4 @@ -.{example} := @use("./examples/random.hb") +.{example} := @use("./examples/square.hb") main := fn(): void { @inline(example)