Skip to main content

LoadedImage

Struct LoadedImage 

Source
pub struct LoadedImage { /* private fields */ }
Expand description

An installed image. The input ELF bytes may be discarded after loading.

Implementations§

Source§

impl LoadedImage

Source

pub unsafe fn spawn<T: 'static>( self, manager: &'static Manager, parent: TaskIdentifier, name: &str, stack: Stack, startup: Startup, map: impl FnOnce(i32) -> T + 'static, ) -> Result<impl Future<Output = Result<(JoinHandle<T>, TaskIdentifier)>>, Error>

Prepare to run the ELF entry point on the calling task’s executor.

Allocating the process state can fail with Error::AllocationFailed, which releases the image, the arguments and the streams. Otherwise the returned future spawns the task and resolves to its join handle and identifier, like stackful::spawn_with_result.

The image, the process heap and the host state are released when the task finishes or is cancelled, or when the future is dropped before it completes. So is everything the program holds. A program that returns, exits or is cancelled has its arguments, its startup streams and its graphics objects released, and so are the files, directories, listings, children and sockets it opened and did not close. A cancelled program is a task future that is dropped while its coroutine is suspended: its coroutine stack is freed, with no destructor run on it.

§Safety

The image must come from a trusted source and implement int32_t _xila_start(const XilaStartup *). Its entry and callees must obey the startup lifetime rules, fit on the stack, and return without unwinding or leaving code or data references in other tasks. The caller must meet the executor affinity and single-core requirements of stackful::spawn.

Source

pub unsafe fn start( self, stack: Stack, startup: Startup, ) -> Result<impl Future<Output = i32> + 'static, Error>

Run the ELF entry point on the calling task, as a future that resolves to its exit status, without spawning a task for it.

Dropping the future before it completes cancels the program, as dropping the task future of LoadedImage::spawn does: its coroutine stack is freed, and everything it held is released. The program runs inside the task that polls the future, which is how a process learns its identity.

§Safety

Same as LoadedImage::spawn; the future must be polled on the executor that created it.

Source§

impl LoadedImage

Source

pub fn load( bytes: &[u8], memory: &'static dyn ExecutableMemory, max_image_size: usize, ) -> Result<Self, Error>

Validate, copy and relocate the ELF. Reject images whose full virtual span (including gaps and BSS) exceeds the caller’s memory budget.

Source

pub fn base(&self) -> NonNull<u8>

Source

pub fn execution_base(&self) -> NonNull<u8>

Source

pub fn entry_address(&self) -> NonNull<u8>

Source

pub fn image_size(&self) -> usize

Trait Implementations§

Source§

impl Drop for LoadedImage

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.