obkrnl/context/
setup.rs

1use super::{Base, Context};
2use crate::uma::Uma;
3use alloc::sync::Arc;
4use core::marker::PhantomData;
5use core::mem::offset_of;
6
7/// Struct to setup CPU context.
8pub struct ContextSetup {
9    phantom: PhantomData<*const ()>, // !Send and !Sync.
10}
11
12impl ContextSetup {
13    pub(super) fn new() -> Self {
14        Self {
15            phantom: PhantomData,
16        }
17    }
18
19    pub fn set_uma(&mut self, v: Arc<Uma>) {
20        unsafe { Context::store_ptr::<{ offset_of!(Base, uma) }, _>(Arc::into_raw(v)) };
21    }
22}