Compare commits
No commits in common. "090441ad04ec9d19d44ae9e218b66ee588717323" and "7825d1861a3bfb74a777a705f6b1195fa31b2fd4" have entirely different histories.
090441ad04
...
7825d1861a
|
@ -17,16 +17,6 @@ dependencies = [
|
||||||
"unicode-segmentation",
|
"unicode-segmentation",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "denali"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"mammoth",
|
|
||||||
"yunq",
|
|
||||||
"yunq-derive",
|
|
||||||
"yunqc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "linked_list_allocator"
|
name = "linked_list_allocator"
|
||||||
version = "0.10.5"
|
version = "0.10.5"
|
||||||
|
@ -123,7 +113,7 @@ name = "testbed"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"mammoth",
|
"mammoth",
|
||||||
"yellowstone-yunq",
|
"yellowstone",
|
||||||
"yunq",
|
"yunq",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -134,7 +124,7 @@ dependencies = [
|
||||||
"mammoth",
|
"mammoth",
|
||||||
"victoriafalls",
|
"victoriafalls",
|
||||||
"voyageurs",
|
"voyageurs",
|
||||||
"yellowstone-yunq",
|
"yellowstone",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -154,7 +144,7 @@ name = "victoriafalls"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"mammoth",
|
"mammoth",
|
||||||
"yellowstone-yunq",
|
"yellowstone",
|
||||||
"yunq",
|
"yunq",
|
||||||
"yunq-derive",
|
"yunq-derive",
|
||||||
"yunqc",
|
"yunqc",
|
||||||
|
@ -165,7 +155,7 @@ name = "voyageurs"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"mammoth",
|
"mammoth",
|
||||||
"yellowstone-yunq",
|
"yellowstone",
|
||||||
"yunq",
|
"yunq",
|
||||||
"yunq-derive",
|
"yunq-derive",
|
||||||
"yunqc",
|
"yunqc",
|
||||||
|
@ -174,18 +164,6 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "yellowstone"
|
name = "yellowstone"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
|
||||||
"denali",
|
|
||||||
"mammoth",
|
|
||||||
"victoriafalls",
|
|
||||||
"voyageurs",
|
|
||||||
"yellowstone-yunq",
|
|
||||||
"yunq",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "yellowstone-yunq"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"mammoth",
|
"mammoth",
|
||||||
"yunq",
|
"yunq",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
|
|
||||||
members = [ "lib/denali",
|
members = [
|
||||||
"lib/mammoth", "lib/victoriafalls", "lib/voyageurs", "lib/yellowstone", "lib/yunq", "lib/yunq-derive", "sys/teton", "sys/yellowstone", "usr/testbed",
|
"lib/mammoth", "lib/victoriafalls", "lib/voyageurs", "lib/yellowstone", "lib/yunq", "lib/yunq-derive", "sys/teton", "usr/testbed",
|
||||||
]
|
]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "denali"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
mammoth = { path = "../mammoth" }
|
|
||||||
yunq = {path = "../yunq"}
|
|
||||||
yunq-derive = {path = "../yunq-derive"}
|
|
||||||
|
|
||||||
[build-dependencies]
|
|
||||||
yunqc = {path = "../../../yunq/rust"}
|
|
|
@ -1,14 +0,0 @@
|
||||||
use std::fs;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let input_file = "../../../sys/denali/lib/denali/denali.yunq";
|
|
||||||
|
|
||||||
println!("cargo::rerun-if-changed={input_file}");
|
|
||||||
|
|
||||||
let input = fs::read_to_string(input_file).expect("Failed to read input file");
|
|
||||||
|
|
||||||
let code = yunqc::codegen(&input).expect("Failed to generate yunq code.");
|
|
||||||
|
|
||||||
let out = std::env::var("OUT_DIR").unwrap() + "/yunq.rs";
|
|
||||||
fs::write(out, code).expect("Failed to write generated code.");
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
#![no_std]
|
|
||||||
|
|
||||||
use core::include;
|
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/yunq.rs"));
|
|
|
@ -13,7 +13,9 @@ const ELF_IDENT_64BIT: u8 = 0x2;
|
||||||
|
|
||||||
const ELF_ENDIAN_LITTLE: u8 = 0x1;
|
const ELF_ENDIAN_LITTLE: u8 = 0x1;
|
||||||
const ELF_ENDIAN_BIG: u8 = 0x2;
|
const ELF_ENDIAN_BIG: u8 = 0x2;
|
||||||
|
|
||||||
const ELF_VERSION_CURRENT: u8 = 0x1;
|
const ELF_VERSION_CURRENT: u8 = 0x1;
|
||||||
|
|
||||||
const ELF_ABI_SYSV: u8 = 0x0;
|
const ELF_ABI_SYSV: u8 = 0x0;
|
||||||
const ELF_ABI_LINUX: u8 = 0x3;
|
const ELF_ABI_LINUX: u8 = 0x3;
|
||||||
|
|
||||||
|
@ -310,10 +312,7 @@ fn load_elf_program(elf_file: &[u8], vmas: &Capability) -> Result<u64, ZError> {
|
||||||
Ok(header.entry)
|
Ok(header.entry)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn spawn_process_from_elf_and_init(
|
pub fn spawn_process_from_elf(elf_file: &[u8]) -> Result<Capability, ZError> {
|
||||||
elf_file: &[u8],
|
|
||||||
init_cap: Capability,
|
|
||||||
) -> Result<Capability, ZError> {
|
|
||||||
let self_cap = Capability::take_copy(unsafe { init::SELF_PROC_CAP })?;
|
let self_cap = Capability::take_copy(unsafe { init::SELF_PROC_CAP })?;
|
||||||
let port_cap = syscall::port_create()?;
|
let port_cap = syscall::port_create()?;
|
||||||
|
|
||||||
|
@ -329,7 +328,8 @@ pub fn spawn_process_from_elf_and_init(
|
||||||
new_proc_cap.duplicate(Capability::PERMS_ALL)?,
|
new_proc_cap.duplicate(Capability::PERMS_ALL)?,
|
||||||
)?;
|
)?;
|
||||||
port.write_u64_and_cap(crate::init::Z_INIT_SELF_VMAS, new_as_cap)?;
|
port.write_u64_and_cap(crate::init::Z_INIT_SELF_VMAS, new_as_cap)?;
|
||||||
port.write_u64_and_cap(crate::init::Z_INIT_ENDPOINT, init_cap)?;
|
let yellowstone = Capability::take_copy(unsafe { crate::init::INIT_ENDPOINT })?;
|
||||||
|
port.write_u64_and_cap(crate::init::Z_INIT_ENDPOINT, yellowstone)?;
|
||||||
|
|
||||||
let thread_cap = syscall::thread_create(&new_proc_cap)?;
|
let thread_cap = syscall::thread_create(&new_proc_cap)?;
|
||||||
|
|
||||||
|
@ -337,8 +337,3 @@ pub fn spawn_process_from_elf_and_init(
|
||||||
|
|
||||||
Ok(new_proc_cap)
|
Ok(new_proc_cap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn spawn_process_from_elf(elf_file: &[u8]) -> Result<Capability, ZError> {
|
|
||||||
let yellowstone = Capability::take_copy(unsafe { crate::init::INIT_ENDPOINT })?;
|
|
||||||
spawn_process_from_elf_and_init(elf_file, yellowstone)
|
|
||||||
}
|
|
||||||
|
|
|
@ -6,21 +6,11 @@ use crate::zion::z_cap_t;
|
||||||
pub const Z_INIT_SELF_PROC: u64 = 0x4000_0000;
|
pub const Z_INIT_SELF_PROC: u64 = 0x4000_0000;
|
||||||
pub const Z_INIT_SELF_VMAS: u64 = 0x4000_0001;
|
pub const Z_INIT_SELF_VMAS: u64 = 0x4000_0001;
|
||||||
pub const Z_INIT_ENDPOINT: u64 = 0x4100_0000;
|
pub const Z_INIT_ENDPOINT: u64 = 0x4100_0000;
|
||||||
const Z_BOOT_DENALI_VMMO: u64 = 0x4200_0000;
|
|
||||||
const Z_BOOT_VICTORIA_FALLS_VMMO: u64 = 0x4200_0001;
|
|
||||||
const Z_BOOT_PCI_VMMO: u64 = 0x4200_0002;
|
|
||||||
const Z_BOOT_FRAMEBUFFER_INFO_VMMO: u64 = 0x4200_0003;
|
|
||||||
|
|
||||||
pub static mut SELF_PROC_CAP: z_cap_t = 0;
|
pub static mut SELF_PROC_CAP: z_cap_t = 0;
|
||||||
pub static mut SELF_VMAS_CAP: z_cap_t = 0;
|
pub static mut SELF_VMAS_CAP: z_cap_t = 0;
|
||||||
pub static mut INIT_ENDPOINT: z_cap_t = 0;
|
pub static mut INIT_ENDPOINT: z_cap_t = 0;
|
||||||
|
|
||||||
// Boot capabilities, are generally only passed to yellowstone.
|
|
||||||
pub static mut BOOT_DENALI_VMMO: z_cap_t = 0;
|
|
||||||
pub static mut BOOT_VICTORIA_FALLS_VMMO: z_cap_t = 0;
|
|
||||||
pub static mut BOOT_PCI_VMMO: z_cap_t = 0;
|
|
||||||
pub static mut BOOT_FRAMEBUFFER_INFO_VMMO: z_cap_t = 0;
|
|
||||||
|
|
||||||
pub fn parse_init_port(port_cap: z_cap_t) {
|
pub fn parse_init_port(port_cap: z_cap_t) {
|
||||||
let init_port = Capability::take(port_cap);
|
let init_port = Capability::take(port_cap);
|
||||||
loop {
|
loop {
|
||||||
|
@ -39,10 +29,6 @@ pub fn parse_init_port(port_cap: z_cap_t) {
|
||||||
Z_INIT_SELF_PROC => SELF_PROC_CAP = caps[0],
|
Z_INIT_SELF_PROC => SELF_PROC_CAP = caps[0],
|
||||||
Z_INIT_SELF_VMAS => SELF_VMAS_CAP = caps[0],
|
Z_INIT_SELF_VMAS => SELF_VMAS_CAP = caps[0],
|
||||||
Z_INIT_ENDPOINT => INIT_ENDPOINT = caps[0],
|
Z_INIT_ENDPOINT => INIT_ENDPOINT = caps[0],
|
||||||
Z_BOOT_DENALI_VMMO => BOOT_DENALI_VMMO = caps[0],
|
|
||||||
Z_BOOT_VICTORIA_FALLS_VMMO => BOOT_VICTORIA_FALLS_VMMO = caps[0],
|
|
||||||
Z_BOOT_PCI_VMMO => BOOT_PCI_VMMO = caps[0],
|
|
||||||
Z_BOOT_FRAMEBUFFER_INFO_VMMO => BOOT_FRAMEBUFFER_INFO_VMMO = caps[0],
|
|
||||||
_ => syscall::debug("Unknown Cap in Init"),
|
_ => syscall::debug("Unknown Cap in Init"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ pub mod elf;
|
||||||
pub mod init;
|
pub mod init;
|
||||||
pub mod mem;
|
pub mod mem;
|
||||||
pub mod port;
|
pub mod port;
|
||||||
pub mod sync;
|
|
||||||
pub mod syscall;
|
pub mod syscall;
|
||||||
pub mod thread;
|
pub mod thread;
|
||||||
pub mod zion;
|
pub mod zion;
|
||||||
|
|
|
@ -78,10 +78,6 @@ impl MemoryRegion {
|
||||||
pub fn cap(&self) -> &Capability {
|
pub fn cap(&self) -> &Capability {
|
||||||
&self.mem_cap
|
&self.mem_cap
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn duplicate(&self, offset: u64, length: u64) -> Result<Capability, ZError> {
|
|
||||||
syscall::memory_obj_duplicate(&self.mem_cap, offset, length)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for MemoryRegion {
|
impl Drop for MemoryRegion {
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
use crate::{cap::Capability, syscall, zion::ZError};
|
|
||||||
|
|
||||||
pub struct Semaphore {
|
|
||||||
cap: Capability,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Semaphore {
|
|
||||||
pub fn new() -> Result<Self, ZError> {
|
|
||||||
syscall::semaphore_create().map(|cap| Self { cap })
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn wait(&self) -> Result<(), ZError> {
|
|
||||||
syscall::semaphone_wait(&self.cap)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn signal(&self) -> Result<(), ZError> {
|
|
||||||
syscall::semaphone_signal(&self.cap)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -167,24 +167,6 @@ pub fn memory_object_inspect(mem_cap: &Capability) -> Result<u64, ZError> {
|
||||||
Ok(mem_size)
|
Ok(mem_size)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn memory_obj_duplicate(
|
|
||||||
mem_cap: &Capability,
|
|
||||||
base_offset: u64,
|
|
||||||
length: u64,
|
|
||||||
) -> Result<Capability, ZError> {
|
|
||||||
let mut new_cap = 0;
|
|
||||||
syscall(
|
|
||||||
zion::kZionMemoryObjectDuplicate,
|
|
||||||
&zion::ZMemoryObjectDuplicateReq {
|
|
||||||
vmmo_cap: mem_cap.raw(),
|
|
||||||
base_offset,
|
|
||||||
length,
|
|
||||||
new_vmmo_cap: &mut new_cap,
|
|
||||||
},
|
|
||||||
)?;
|
|
||||||
Ok(Capability::take(new_cap))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn address_space_map(vmmo_cap: &Capability) -> Result<u64, ZError> {
|
pub fn address_space_map(vmmo_cap: &Capability) -> Result<u64, ZError> {
|
||||||
let mut vaddr: u64 = 0;
|
let mut vaddr: u64 = 0;
|
||||||
// FIXME: Allow caller to pass these options.
|
// FIXME: Allow caller to pass these options.
|
||||||
|
@ -381,33 +363,3 @@ pub fn reply_port_recv(
|
||||||
|
|
||||||
Ok((num_bytes, num_caps))
|
Ok((num_bytes, num_caps))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn semaphore_create() -> Result<Capability, ZError> {
|
|
||||||
let mut sem_cap: z_cap_t = 0;
|
|
||||||
syscall(
|
|
||||||
zion::kZionSemaphoreCreate,
|
|
||||||
&zion::ZSemaphoreCreateReq {
|
|
||||||
semaphore_cap: &mut sem_cap,
|
|
||||||
},
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(Capability::take(sem_cap))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn semaphone_signal(sem_cap: &Capability) -> Result<(), ZError> {
|
|
||||||
syscall(
|
|
||||||
zion::kZionSemaphoreSignal,
|
|
||||||
&zion::ZSemaphoreSignalReq {
|
|
||||||
semaphore_cap: sem_cap.raw(),
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn semaphone_wait(sem_cap: &Capability) -> Result<(), ZError> {
|
|
||||||
syscall(
|
|
||||||
zion::kZionSemaphoreWait,
|
|
||||||
&zion::ZSemaphoreWaitReq {
|
|
||||||
semaphore_cap: sem_cap.raw(),
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
mammoth = { path = "../mammoth" }
|
mammoth = { path = "../mammoth" }
|
||||||
yellowstone-yunq = { path = "../yellowstone" }
|
yellowstone = { path = "../yellowstone" }
|
||||||
yunq = {path = "../yunq"}
|
yunq = {path = "../yunq"}
|
||||||
yunq-derive = {path = "../yunq-derive"}
|
yunq-derive = {path = "../yunq-derive"}
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,8 @@ static mut VFS_CLIENT: Option<VFSClient> = None;
|
||||||
fn get_client() -> &'static mut VFSClient {
|
fn get_client() -> &'static mut VFSClient {
|
||||||
unsafe {
|
unsafe {
|
||||||
if let None = VFS_CLIENT {
|
if let None = VFS_CLIENT {
|
||||||
let endpoint_cap = yellowstone_yunq::from_init_endpoint()
|
let endpoint_cap = yellowstone::from_init_endpoint()
|
||||||
.get_endpoint(&yellowstone_yunq::GetEndpointRequest {
|
.get_endpoint(&yellowstone::GetEndpointRequest {
|
||||||
endpoint_name: "victoriafalls".to_string(),
|
endpoint_name: "victoriafalls".to_string(),
|
||||||
})
|
})
|
||||||
.expect("Failed to get VFS endpoint");
|
.expect("Failed to get VFS endpoint");
|
||||||
|
|
|
@ -5,7 +5,7 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
mammoth = { path = "../mammoth" }
|
mammoth = { path = "../mammoth" }
|
||||||
yellowstone-yunq = { path = "../yellowstone" }
|
yellowstone = { path = "../yellowstone" }
|
||||||
yunq = {path = "../yunq"}
|
yunq = {path = "../yunq"}
|
||||||
yunq-derive = {path = "../yunq-derive"}
|
yunq-derive = {path = "../yunq-derive"}
|
||||||
|
|
||||||
|
|
|
@ -211,8 +211,8 @@ impl KeyboardListener {
|
||||||
handler,
|
handler,
|
||||||
});
|
});
|
||||||
|
|
||||||
let voyageur_endpoint = yellowstone_yunq::from_init_endpoint()
|
let voyageur_endpoint = yellowstone::from_init_endpoint()
|
||||||
.get_endpoint(&yellowstone_yunq::GetEndpointRequest {
|
.get_endpoint(&yellowstone::GetEndpointRequest {
|
||||||
endpoint_name: "voyageurs".to_string(),
|
endpoint_name: "voyageurs".to_string(),
|
||||||
})?
|
})?
|
||||||
.endpoint;
|
.endpoint;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "yellowstone-yunq"
|
name = "yellowstone"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
|
|
@ -33,16 +33,10 @@ fn serialize_field(name: &Ident, ind: usize, path: &Path) -> proc_macro2::TokenS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
quote! {
|
panic!(
|
||||||
{
|
"Serialization not implemented for: {}",
|
||||||
let msg_offset = next_extension;
|
path.to_token_stream()
|
||||||
let msg_length = self.#name.serialize(buf, offset + next_extension as usize, caps)? as u32;
|
)
|
||||||
next_extension += msg_length;
|
|
||||||
|
|
||||||
buf.write_at(yunq::message::field_offset(offset, #ind), msg_offset)?;
|
|
||||||
buf.write_at(yunq::message::field_offset(offset, #ind) + 4, msg_length)?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,13 +62,7 @@ fn parse_field(name: &Ident, ind: usize, path: &Path) -> proc_macro2::TokenStrea
|
||||||
let #name = buf.at::<u64>(yunq::message::field_offset(offset, #ind))?;
|
let #name = buf.at::<u64>(yunq::message::field_offset(offset, #ind))?;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
quote! {
|
panic!("Parsing not implemented for: {}", path.into_token_stream());
|
||||||
let #name = {
|
|
||||||
let msg_offset = buf.at::<u32>(yunq::message::field_offset(offset, #ind))? as usize;
|
|
||||||
|
|
||||||
#path::parse(buf, offset + msg_offset, caps)?
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ use mammoth::zion::z_cap_t;
|
||||||
use mammoth::zion::ZError;
|
use mammoth::zion::ZError;
|
||||||
|
|
||||||
pub trait YunqServer {
|
pub trait YunqServer {
|
||||||
fn server_loop(&mut self) {
|
fn server_loop(&self) {
|
||||||
loop {
|
loop {
|
||||||
let mut byte_buffer = ByteBuffer::<1024>::new();
|
let mut byte_buffer = ByteBuffer::<1024>::new();
|
||||||
let mut cap_buffer = vec![0; 10];
|
let mut cap_buffer = vec![0; 10];
|
||||||
|
@ -38,13 +38,8 @@ pub trait YunqServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn endpoint_cap(&self) -> &Capability;
|
fn endpoint_cap(&self) -> &Capability;
|
||||||
|
|
||||||
fn create_client_cap(&self) -> Result<Capability, ZError> {
|
|
||||||
self.endpoint_cap()
|
|
||||||
.duplicate(!mammoth::zion::kZionPerm_Read)
|
|
||||||
}
|
|
||||||
fn handle_request(
|
fn handle_request(
|
||||||
&mut self,
|
&self,
|
||||||
method_number: u64,
|
method_number: u64,
|
||||||
byte_buffer: &mut ByteBuffer<1024>,
|
byte_buffer: &mut ByteBuffer<1024>,
|
||||||
cap_buffer: &mut Vec<z_cap_t>,
|
cap_buffer: &mut Vec<z_cap_t>,
|
||||||
|
|
|
@ -7,4 +7,4 @@ edition = "2021"
|
||||||
mammoth = { path = "../../lib/mammoth" }
|
mammoth = { path = "../../lib/mammoth" }
|
||||||
victoriafalls = { path = "../../lib/victoriafalls" }
|
victoriafalls = { path = "../../lib/victoriafalls" }
|
||||||
voyageurs = { path = "../../lib/voyageurs" }
|
voyageurs = { path = "../../lib/voyageurs" }
|
||||||
yellowstone-yunq = { path = "../../lib/yellowstone" }
|
yellowstone = { path = "../../lib/yellowstone" }
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use mammoth::{mem::MemoryRegion, zion::ZError};
|
use mammoth::{mem::MemoryRegion, zion::ZError};
|
||||||
use yellowstone_yunq::FramebufferInfo;
|
use yellowstone::FramebufferInfo;
|
||||||
|
|
||||||
pub struct Framebuffer {
|
pub struct Framebuffer {
|
||||||
fb_info: FramebufferInfo,
|
fb_info: FramebufferInfo,
|
||||||
|
|
|
@ -20,7 +20,7 @@ define_entry!();
|
||||||
extern "C" fn main() -> z_err_t {
|
extern "C" fn main() -> z_err_t {
|
||||||
debug!("Teton Starting");
|
debug!("Teton Starting");
|
||||||
|
|
||||||
let yellowstone = yellowstone_yunq::from_init_endpoint();
|
let yellowstone = yellowstone::from_init_endpoint();
|
||||||
let framebuffer_info = yellowstone
|
let framebuffer_info = yellowstone
|
||||||
.get_framebuffer_info()
|
.get_framebuffer_info()
|
||||||
.expect("Failed to get framebuffer info.");
|
.expect("Failed to get framebuffer info.");
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "yellowstone"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
mammoth = { path = "../../lib/mammoth" }
|
|
||||||
denali = { path = "../../lib/denali" }
|
|
||||||
victoriafalls = { path = "../../lib/victoriafalls" }
|
|
||||||
voyageurs = { path = "../../lib/voyageurs" }
|
|
||||||
yellowstone-yunq = { path = "../../lib/yellowstone" }
|
|
||||||
yunq = { path = "../../lib/yunq" }
|
|
|
@ -1,62 +0,0 @@
|
||||||
#![no_std]
|
|
||||||
#![no_main]
|
|
||||||
|
|
||||||
extern crate alloc;
|
|
||||||
|
|
||||||
use mammoth::{
|
|
||||||
cap::Capability,
|
|
||||||
define_entry, elf,
|
|
||||||
init::BOOT_PCI_VMMO,
|
|
||||||
mem::MemoryRegion,
|
|
||||||
zion::{z_cap_t, z_err_t, ZError},
|
|
||||||
};
|
|
||||||
use yellowstone_yunq::YellowstoneServer;
|
|
||||||
use yunq::server::YunqServer;
|
|
||||||
|
|
||||||
mod pci;
|
|
||||||
mod server;
|
|
||||||
|
|
||||||
define_entry!();
|
|
||||||
|
|
||||||
fn spawn_from_vmmo(vmmo_cap: z_cap_t, server_cap: Capability) -> Result<(), ZError> {
|
|
||||||
let region = mammoth::mem::MemoryRegion::from_cap(Capability::take(vmmo_cap))?;
|
|
||||||
elf::spawn_process_from_elf_and_init(region.slice(), server_cap)?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
extern "C" fn main() -> z_err_t {
|
|
||||||
let pci_region = MemoryRegion::from_cap(Capability::take(unsafe { BOOT_PCI_VMMO }))
|
|
||||||
.expect("Failed to create PCI region");
|
|
||||||
let context = alloc::rc::Rc::new(
|
|
||||||
server::YellowstoneServerContext::new(pci_region)
|
|
||||||
.expect("Failed to create yellowstone context"),
|
|
||||||
);
|
|
||||||
let handler = server::YellowstoneServerImpl::new(context.clone());
|
|
||||||
let server = YellowstoneServer::new(handler).expect("Couldn't create yellowstone server");
|
|
||||||
|
|
||||||
let server_thread = server.run_server().expect("Failed to run server");
|
|
||||||
|
|
||||||
spawn_from_vmmo(
|
|
||||||
unsafe { mammoth::init::BOOT_DENALI_VMMO },
|
|
||||||
server
|
|
||||||
.create_client_cap()
|
|
||||||
.expect("Failed to create client cap for denali"),
|
|
||||||
)
|
|
||||||
.expect("Failed to spawn denali");
|
|
||||||
|
|
||||||
context.wait_denali().expect("Failed to wait for denali");
|
|
||||||
mammoth::debug!("Denali registered.");
|
|
||||||
|
|
||||||
spawn_from_vmmo(
|
|
||||||
unsafe { mammoth::init::BOOT_VICTORIA_FALLS_VMMO },
|
|
||||||
server.create_client_cap().unwrap(),
|
|
||||||
)
|
|
||||||
.expect("Failed to spawn victoriafalls");
|
|
||||||
|
|
||||||
context.wait_victoria_falls().unwrap();
|
|
||||||
mammoth::debug!("VFS Registered");
|
|
||||||
|
|
||||||
server_thread.join().expect("Failed to join thread");
|
|
||||||
0
|
|
||||||
}
|
|
|
@ -1,122 +0,0 @@
|
||||||
use mammoth::{cap::Capability, mem::MemoryRegion, zion::ZError};
|
|
||||||
|
|
||||||
pub struct PciReader {
|
|
||||||
memory_region: MemoryRegion,
|
|
||||||
}
|
|
||||||
|
|
||||||
type DevPredicate = fn(u8, u8, u8) -> bool;
|
|
||||||
|
|
||||||
impl PciReader {
|
|
||||||
pub fn new(memory_region: MemoryRegion) -> Self {
|
|
||||||
Self { memory_region }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_ahci_region(&self) -> Result<Capability, ZError> {
|
|
||||||
match self.probe_pci(|class, _, _| class == 0x1) {
|
|
||||||
Some(m) => Ok(m),
|
|
||||||
None => Err(ZError::NOT_FOUND),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn probe_pci(&self, pred: DevPredicate) -> Option<Capability> {
|
|
||||||
let base_header = self.pci_header(0, 0, 0);
|
|
||||||
if (base_header.header_type & 0x80) == 0 {
|
|
||||||
if let Some(dev) = self.probe_bus(pred, 0) {
|
|
||||||
return Some(dev);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for fun in 0..8 {
|
|
||||||
let fun_hdr = self.pci_header(0, 0, fun);
|
|
||||||
if fun_hdr.vendor_id != 0xFFFF {
|
|
||||||
if let Some(dev) = self.probe_bus(pred, fun) {
|
|
||||||
return Some(dev);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
fn probe_bus(&self, pred: DevPredicate, bus: u8) -> Option<Capability> {
|
|
||||||
for dev in 0..0x20 {
|
|
||||||
if let Some(dev) = self.probe_device(pred, bus, dev) {
|
|
||||||
return Some(dev);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
fn probe_device(&self, pred: DevPredicate, bus: u8, dev: u8) -> Option<Capability> {
|
|
||||||
let device_base_header = self.pci_header(bus, dev, 0);
|
|
||||||
if device_base_header.vendor_id == 0xFFFF {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(dev) = self.probe_function(pred, bus, dev, 0) {
|
|
||||||
return Some(dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (device_base_header.header_type & 0x80) != 0 {
|
|
||||||
for fun in 1..8 {
|
|
||||||
if let Some(dev) = self.probe_function(pred, bus, dev, fun) {
|
|
||||||
return Some(dev);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
fn probe_function(&self, pred: DevPredicate, bus: u8, dev: u8, fun: u8) -> Option<Capability> {
|
|
||||||
let function_header = self.pci_header(bus, dev, fun);
|
|
||||||
|
|
||||||
mammoth::debug!(
|
|
||||||
"PCI Function: {:#x} {:#x} {:#x}",
|
|
||||||
function_header.class_code,
|
|
||||||
function_header.subclass,
|
|
||||||
function_header.prog_interface
|
|
||||||
);
|
|
||||||
|
|
||||||
if pred(
|
|
||||||
function_header.class_code,
|
|
||||||
function_header.subclass,
|
|
||||||
function_header.prog_interface,
|
|
||||||
) {
|
|
||||||
mammoth::debug!("Found!");
|
|
||||||
let offset = pci_header_offset(bus, dev, fun);
|
|
||||||
Some(
|
|
||||||
self.memory_region
|
|
||||||
.duplicate(offset as u64, 0x1000)
|
|
||||||
.expect("Failed to duplicate PCI cap"),
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn pci_header(&self, bus: u8, dev: u8, fun: u8) -> &PciHeader {
|
|
||||||
let offset = pci_header_offset(bus, dev, fun);
|
|
||||||
let header_slice: &[u8] =
|
|
||||||
&self.memory_region.slice()[offset..offset + size_of::<PciHeader>()];
|
|
||||||
unsafe { header_slice.as_ptr().cast::<PciHeader>().as_ref().unwrap() }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[repr(C, packed)]
|
|
||||||
struct PciHeader {
|
|
||||||
vendor_id: u16,
|
|
||||||
device_id: u16,
|
|
||||||
command_reg: u16,
|
|
||||||
status_reg: u16,
|
|
||||||
revision: u8,
|
|
||||||
prog_interface: u8,
|
|
||||||
subclass: u8,
|
|
||||||
class_code: u8,
|
|
||||||
cache_line_size: u8,
|
|
||||||
latency_timer: u8,
|
|
||||||
header_type: u8,
|
|
||||||
bist: u8,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn pci_header_offset(bus: u8, dev: u8, fun: u8) -> usize {
|
|
||||||
((bus as usize) << 20) | ((dev as usize) << 15) | ((fun as usize) << 12)
|
|
||||||
}
|
|
|
@ -1,93 +0,0 @@
|
||||||
use alloc::rc::Rc;
|
|
||||||
use alloc::{collections::BTreeMap, string::String};
|
|
||||||
use mammoth::{cap::Capability, mem::MemoryRegion, zion::ZError};
|
|
||||||
use yellowstone_yunq::{
|
|
||||||
AhciInfo, DenaliInfo, Endpoint, FramebufferInfo, GetEndpointRequest, RegisterEndpointRequest,
|
|
||||||
XhciInfo, YellowstoneServerHandler,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::pci::PciReader;
|
|
||||||
|
|
||||||
pub struct YellowstoneServerContext {
|
|
||||||
denali_semaphore: mammoth::sync::Semaphore,
|
|
||||||
victoria_falls_semaphore: mammoth::sync::Semaphore,
|
|
||||||
pci_reader: PciReader,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl YellowstoneServerContext {
|
|
||||||
pub fn new(pci_region: MemoryRegion) -> Result<Self, ZError> {
|
|
||||||
Ok(Self {
|
|
||||||
denali_semaphore: mammoth::sync::Semaphore::new()?,
|
|
||||||
victoria_falls_semaphore: mammoth::sync::Semaphore::new()?,
|
|
||||||
pci_reader: PciReader::new(pci_region),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn wait_denali(&self) -> Result<(), ZError> {
|
|
||||||
self.denali_semaphore.wait()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn wait_victoria_falls(&self) -> Result<(), ZError> {
|
|
||||||
self.victoria_falls_semaphore.wait()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct YellowstoneServerImpl {
|
|
||||||
context: Rc<YellowstoneServerContext>,
|
|
||||||
service_map: BTreeMap<String, Capability>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl YellowstoneServerImpl {
|
|
||||||
pub fn new(context: Rc<YellowstoneServerContext>) -> Self {
|
|
||||||
Self {
|
|
||||||
context,
|
|
||||||
service_map: BTreeMap::new(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl YellowstoneServerHandler for YellowstoneServerImpl {
|
|
||||||
fn register_endpoint(&mut self, req: RegisterEndpointRequest) -> Result<(), ZError> {
|
|
||||||
let signal_denali = req.endpoint_name == "denali";
|
|
||||||
let signal_vfs = req.endpoint_name == "victoriafalls";
|
|
||||||
|
|
||||||
self.service_map
|
|
||||||
.insert(req.endpoint_name, Capability::take(req.endpoint_capability));
|
|
||||||
|
|
||||||
if signal_denali {
|
|
||||||
self.context.denali_semaphore.signal()?
|
|
||||||
}
|
|
||||||
if signal_vfs {
|
|
||||||
self.context.victoria_falls_semaphore.signal()?
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_endpoint(&mut self, req: GetEndpointRequest) -> Result<Endpoint, ZError> {
|
|
||||||
match self.service_map.get(&req.endpoint_name) {
|
|
||||||
Some(cap) => Ok(Endpoint {
|
|
||||||
endpoint: cap.duplicate(Capability::PERMS_ALL)?.release(),
|
|
||||||
}),
|
|
||||||
None => Err(ZError::NOT_FOUND),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_ahci_info(&mut self) -> Result<AhciInfo, ZError> {
|
|
||||||
Ok(AhciInfo {
|
|
||||||
ahci_region: self.context.pci_reader.get_ahci_region()?.release(),
|
|
||||||
region_length: 0x1000,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_xhci_info(&mut self) -> Result<XhciInfo, ZError> {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_framebuffer_info(&mut self) -> Result<FramebufferInfo, ZError> {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_denali(&mut self) -> Result<DenaliInfo, ZError> {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,5 +5,5 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
mammoth = { path = "../../lib/mammoth" }
|
mammoth = { path = "../../lib/mammoth" }
|
||||||
yellowstone-yunq = { path = "../../lib/yellowstone" }
|
yellowstone = { path = "../../lib/yellowstone" }
|
||||||
yunq = { path = "../../lib/yunq" }
|
yunq = { path = "../../lib/yunq" }
|
||||||
|
|
|
@ -8,7 +8,7 @@ use mammoth::debug;
|
||||||
use mammoth::define_entry;
|
use mammoth::define_entry;
|
||||||
use mammoth::thread;
|
use mammoth::thread;
|
||||||
use mammoth::zion::z_err_t;
|
use mammoth::zion::z_err_t;
|
||||||
use yellowstone_yunq::GetEndpointRequest;
|
use yellowstone::GetEndpointRequest;
|
||||||
|
|
||||||
define_entry!();
|
define_entry!();
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ define_entry!();
|
||||||
pub extern "C" fn main() -> z_err_t {
|
pub extern "C" fn main() -> z_err_t {
|
||||||
debug!("Testing!");
|
debug!("Testing!");
|
||||||
|
|
||||||
let yellowstone = yellowstone_yunq::from_init_endpoint();
|
let yellowstone = yellowstone::from_init_endpoint();
|
||||||
|
|
||||||
debug!("Get endpoint");
|
debug!("Get endpoint");
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ cp /usr/share/limine/limine-bios.sys efi/
|
||||||
cp ../zion/boot/limine.cfg efi/
|
cp ../zion/boot/limine.cfg efi/
|
||||||
cp zion/zion efi/
|
cp zion/zion efi/
|
||||||
mkdir -p efi/sys
|
mkdir -p efi/sys
|
||||||
cp ../sysroot/bin/yellowstone efi/sys/yellowstone
|
cp sys/yellowstone/yellowstone efi/sys/yellowstone
|
||||||
cp sys/denali/denali efi/sys/denali
|
cp sys/denali/denali efi/sys/denali
|
||||||
cp sys/victoriafalls/victoriafalls efi/sys/victoriafalls
|
cp sys/victoriafalls/victoriafalls efi/sys/victoriafalls
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ fn generate_server_case(method: &Method) -> TokenStream {
|
||||||
(Some(req), Some(_)) => quote! {
|
(Some(req), Some(_)) => quote! {
|
||||||
#id => {
|
#id => {
|
||||||
let req = #req::parse_from_request(byte_buffer, cap_buffer)?;
|
let req = #req::parse_from_request(byte_buffer, cap_buffer)?;
|
||||||
let resp = self.handler.#name(req)?;
|
let resp = self.handler.#name(&req)?;
|
||||||
cap_buffer.resize(0, 0);
|
cap_buffer.resize(0, 0);
|
||||||
let resp_len = resp.serialize_as_request(0, byte_buffer, cap_buffer)?;
|
let resp_len = resp.serialize_as_request(0, byte_buffer, cap_buffer)?;
|
||||||
Ok(resp_len)
|
Ok(resp_len)
|
||||||
|
@ -91,7 +91,7 @@ fn generate_server_case(method: &Method) -> TokenStream {
|
||||||
(Some(req), None) => quote! {
|
(Some(req), None) => quote! {
|
||||||
#id => {
|
#id => {
|
||||||
let req = #req::parse_from_request(byte_buffer, cap_buffer)?;
|
let req = #req::parse_from_request(byte_buffer, cap_buffer)?;
|
||||||
self.handler.#name(req)?;
|
self.handler.#name(&req)?;
|
||||||
cap_buffer.resize(0, 0);
|
cap_buffer.resize(0, 0);
|
||||||
// TODO: Implement serialization for EmptyMessage so this is less hacky.
|
// TODO: Implement serialization for EmptyMessage so this is less hacky.
|
||||||
yunq::message::serialize_error(byte_buffer, ZError::from(0));
|
yunq::message::serialize_error(byte_buffer, ZError::from(0));
|
||||||
|
@ -116,13 +116,13 @@ fn generate_server_method(method: &Method) -> TokenStream {
|
||||||
let maybe_resp = method.response.clone().map(|r| ident(&r));
|
let maybe_resp = method.response.clone().map(|r| ident(&r));
|
||||||
match (maybe_req, maybe_resp) {
|
match (maybe_req, maybe_resp) {
|
||||||
(Some(req), Some(resp)) => quote! {
|
(Some(req), Some(resp)) => quote! {
|
||||||
fn #name (&mut self, req: #req) -> Result<#resp, ZError>;
|
fn #name (&self, req: & #req) -> Result<#resp, ZError>;
|
||||||
},
|
},
|
||||||
(Some(req), None) => quote! {
|
(Some(req), None) => quote! {
|
||||||
fn #name (&mut self, req: #req) -> Result<(), ZError>;
|
fn #name (&self, req: & #req) -> Result<(), ZError>;
|
||||||
},
|
},
|
||||||
(None, Some(resp)) => quote! {
|
(None, Some(resp)) => quote! {
|
||||||
fn #name (&mut self) -> Result<#resp, ZError>;
|
fn #name (&self) -> Result<#resp, ZError>;
|
||||||
},
|
},
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ fn generate_server(interface: &Interface) -> TokenStream {
|
||||||
|
|
||||||
pub fn run_server(&self) -> Result<Box<thread::Thread>, ZError> {
|
pub fn run_server(&self) -> Result<Box<thread::Thread>, ZError> {
|
||||||
let thread_entry = |server_ptr: *const c_void| {
|
let thread_entry = |server_ptr: *const c_void| {
|
||||||
let server = unsafe { (server_ptr as *mut #server_name<T>).as_mut().expect("Failed to convert to server") };
|
let server = unsafe { (server_ptr as *const #server_name<T>).as_ref().expect("Failed to convert to server") };
|
||||||
server.server_loop();
|
server.server_loop();
|
||||||
};
|
};
|
||||||
thread::Thread::spawn(
|
thread::Thread::spawn(
|
||||||
|
@ -169,7 +169,7 @@ fn generate_server(interface: &Interface) -> TokenStream {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_request(
|
fn handle_request(
|
||||||
&mut self,
|
&self,
|
||||||
method_number: u64,
|
method_number: u64,
|
||||||
byte_buffer: &mut ByteBuffer<1024>,
|
byte_buffer: &mut ByteBuffer<1024>,
|
||||||
cap_buffer: &mut Vec<z_cap_t>,
|
cap_buffer: &mut Vec<z_cap_t>,
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#include "scheduler/process_manager.h"
|
#include "scheduler/process_manager.h"
|
||||||
#include "scheduler/scheduler.h"
|
#include "scheduler/scheduler.h"
|
||||||
|
|
||||||
#define K_INIT_DEBUG 1
|
#define K_INIT_DEBUG 0
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -67,9 +67,6 @@ uint64_t LoadElfProgram(Process& dest_proc, uint64_t base, uint64_t offset) {
|
||||||
reinterpret_cast<Elf64ProgramHeader*>(base + header->phoff);
|
reinterpret_cast<Elf64ProgramHeader*>(base + header->phoff);
|
||||||
for (uint64_t i = 0; i < header->phnum; i++) {
|
for (uint64_t i = 0; i < header->phnum; i++) {
|
||||||
Elf64ProgramHeader& program = programs[i];
|
Elf64ProgramHeader& program = programs[i];
|
||||||
if (program.type != 1) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
#if K_INIT_DEBUG
|
#if K_INIT_DEBUG
|
||||||
dbgln(
|
dbgln(
|
||||||
"prog: type: {}, flags: {}, offset: {}\n vaddr: {x}, paddr: {x}\n "
|
"prog: type: {}, flags: {}, offset: {}\n vaddr: {x}, paddr: {x}\n "
|
||||||
|
@ -77,19 +74,12 @@ uint64_t LoadElfProgram(Process& dest_proc, uint64_t base, uint64_t offset) {
|
||||||
program.type, program.flags, program.offset, program.vaddr,
|
program.type, program.flags, program.offset, program.vaddr,
|
||||||
program.paddr, program.filesz, program.memsz, program.align);
|
program.paddr, program.filesz, program.memsz, program.align);
|
||||||
#endif
|
#endif
|
||||||
uint64_t page_offset = program.vaddr & 0xFFF;
|
auto mem_obj = glcr::MakeRefCounted<VariableMemoryObject>(program.memsz);
|
||||||
auto mem_obj =
|
mem_obj->CopyBytesToObject(base + program.offset, program.filesz);
|
||||||
glcr::MakeRefCounted<VariableMemoryObject>(program.memsz + page_offset);
|
PANIC_ON_ERR(
|
||||||
|
dest_proc.vmas()->MapInMemoryObject(
|
||||||
// Super hacky but if we adjust the offsets to handle a non-aligned page.
|
program.vaddr, glcr::StaticCastRefPtr<MemoryObject>(mem_obj)),
|
||||||
mem_obj->CopyBytesToObject(base + program.offset - page_offset,
|
"Couldn't map in init program.");
|
||||||
program.filesz + page_offset);
|
|
||||||
auto map_res = dest_proc.vmas()->MapInMemoryObject(
|
|
||||||
program.vaddr - page_offset,
|
|
||||||
glcr::StaticCastRefPtr<MemoryObject>(mem_obj));
|
|
||||||
if (map_res != glcr::OK) {
|
|
||||||
panic("Couldn't map in init program {}", map_res);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return header->entry;
|
return header->entry;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue