-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kernel+oro: add address space layout interface
- Loading branch information
Showing
6 changed files
with
83 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
//! Implements the address space layout query interface (version 0). | ||
use core::marker::PhantomData; | ||
|
||
use oro::{key, syscall::Error as SysError}; | ||
use oro_mem::mapper::{AddressSpace as _, AddressSegment}; | ||
|
||
use super::KernelInterface; | ||
use crate::{AddressSpace, arch::Arch, syscall::InterfaceResponse, tab::Tab, thread::Thread}; | ||
|
||
/// Version 0 of the thread control kernel interface. | ||
#[repr(transparent)] | ||
pub struct AddrLayoutV0<A: Arch>(pub(crate) PhantomData<A>); | ||
|
||
impl<A: Arch> KernelInterface<A> for AddrLayoutV0<A> { | ||
fn get(&self, _thread: &Tab<Thread<A>>, index: u64, key: u64) -> InterfaceResponse { | ||
let segment = match index { | ||
key!("module") => AddressSpace::<A>::user_data(), | ||
key!("thrdstck") => AddressSpace::<A>::user_thread_stack(), | ||
_ => return InterfaceResponse::immediate(SysError::BadIndex, 0), | ||
}; | ||
|
||
::oro_macro::assert::fits_within::<usize, u64>(); | ||
|
||
match key { | ||
key!("start") => InterfaceResponse::ok(segment.range().0 as u64), | ||
key!("end") => InterfaceResponse::ok(segment.range().1 as u64), | ||
_ => InterfaceResponse::immediate(SysError::BadKey, 0), | ||
} | ||
} | ||
|
||
fn set( | ||
&self, | ||
_thread: &Tab<Thread<A>>, | ||
_index: u64, | ||
_key: u64, | ||
_value: u64, | ||
) -> InterfaceResponse { | ||
InterfaceResponse::immediate(SysError::ReadOnly, 0) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters