forked from AbleOS/ableos
misc
This commit is contained in:
parent
2edc8148ca
commit
07c7d52b8c
|
@ -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
35
kernel/src/exe_format.rs
Normal 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,
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ mod arch;
|
|||
mod bootmodules;
|
||||
mod capabilities;
|
||||
mod device_tree;
|
||||
mod exe_format;
|
||||
mod handle;
|
||||
mod holeybytes;
|
||||
mod ipc;
|
||||
|
|
|
@ -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,
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
name = "pumpkin_print"
|
||||
authors = [""]
|
||||
|
||||
|
||||
[dependants.libraries]
|
||||
|
||||
[dependants.binaries]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.{example} := @use("./examples/random.hb")
|
||||
.{example} := @use("./examples/square.hb")
|
||||
|
||||
main := fn(): void {
|
||||
@inline(example)
|
||||
|
|
Loading…
Reference in a new issue