feat(init): add init crate with declarative boot manifest, boot sequence, supervisor and shutdown stubs
Also: make types from_raw/raw const fn, add create_process/kill/delegate/revoke to userspace syscall stubs.
This commit is contained in:
92
crates/init/src/manifest.rs
Normal file
92
crates/init/src/manifest.rs
Normal file
@@ -0,0 +1,92 @@
|
||||
use types::address::PhysicalAddress;
|
||||
use types::bounded::{CapSlot, Priority};
|
||||
use types::id::IrqId;
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum HardwareCap {
|
||||
Framebuffer { base: PhysicalAddress, pages: usize },
|
||||
Irq { irq: IrqId },
|
||||
Memory { base: PhysicalAddress, pages: usize },
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum EndpointBinding {
|
||||
Own { name: &'static str },
|
||||
ConnectTo { server: &'static str, endpoint: &'static str },
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ServerEntry {
|
||||
pub name: &'static str,
|
||||
pub priority: Priority,
|
||||
pub memory_pages: usize,
|
||||
pub hardware_caps: &'static [HardwareCap],
|
||||
pub endpoints: &'static [EndpointBinding],
|
||||
pub restartable: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct AppEntry {
|
||||
pub name: &'static str,
|
||||
pub priority: Priority,
|
||||
pub memory_pages: usize,
|
||||
pub connects_to: &'static [(&'static str, &'static str)],
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct BootManifest {
|
||||
pub servers: &'static [ServerEntry],
|
||||
pub apps: &'static [AppEntry],
|
||||
}
|
||||
|
||||
pub static SNAKE_MANIFEST: BootManifest = BootManifest {
|
||||
servers: &[
|
||||
ServerEntry {
|
||||
name: "log",
|
||||
priority: Priority::DEFAULT,
|
||||
memory_pages: 64,
|
||||
hardware_caps: &[],
|
||||
endpoints: &[EndpointBinding::Own { name: "log" }],
|
||||
restartable: true,
|
||||
},
|
||||
ServerEntry {
|
||||
name: "permission",
|
||||
priority: Priority::DEFAULT,
|
||||
memory_pages: 32,
|
||||
hardware_caps: &[],
|
||||
endpoints: &[EndpointBinding::Own { name: "permission" }],
|
||||
restartable: true,
|
||||
},
|
||||
ServerEntry {
|
||||
name: "display",
|
||||
priority: Priority::DEFAULT,
|
||||
memory_pages: 256,
|
||||
hardware_caps: &[
|
||||
HardwareCap::Framebuffer {
|
||||
base: PhysicalAddress::from_raw(0x10008000),
|
||||
pages: 75,
|
||||
},
|
||||
],
|
||||
endpoints: &[EndpointBinding::Own { name: "display" }],
|
||||
restartable: true,
|
||||
},
|
||||
ServerEntry {
|
||||
name: "input",
|
||||
priority: Priority::DEFAULT,
|
||||
memory_pages: 32,
|
||||
hardware_caps: &[
|
||||
HardwareCap::Irq { irq: IrqId::from_raw(10) },
|
||||
],
|
||||
endpoints: &[EndpointBinding::Own { name: "input" }],
|
||||
restartable: true,
|
||||
},
|
||||
],
|
||||
apps: &[
|
||||
AppEntry {
|
||||
name: "snake",
|
||||
priority: Priority::DEFAULT,
|
||||
memory_pages: 64,
|
||||
connects_to: &[("display", "display"), ("input", "input")],
|
||||
},
|
||||
],
|
||||
};
|
||||
Reference in New Issue
Block a user