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 {
|
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
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);
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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,
|
||||||
|
}
|
|
@ -2,6 +2,7 @@
|
||||||
name = "pumpkin_print"
|
name = "pumpkin_print"
|
||||||
authors = [""]
|
authors = [""]
|
||||||
|
|
||||||
|
|
||||||
[dependants.libraries]
|
[dependants.libraries]
|
||||||
|
|
||||||
[dependants.binaries]
|
[dependants.binaries]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.{example} := @use("./examples/random.hb")
|
.{example} := @use("./examples/square.hb")
|
||||||
|
|
||||||
main := fn(): void {
|
main := fn(): void {
|
||||||
@inline(example)
|
@inline(example)
|
||||||
|
|
Loading…
Reference in a new issue