⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

ThreadLocalStorage

Struct ThreadLocalStorage 

Source
pub struct ThreadLocalStorage {
    pub base: usize,
    pub size: usize,
    pub data_ptr: usize,
    pub data: BTreeMap<u64, u64>,
}
Expand description

Thread Local Storage (TLS) data

Fields§

§base: usize

TLS base address

§size: usize

TLS size in bytes

§data_ptr: usize

TLS data pointer (architecture-specific)

§data: BTreeMap<u64, u64>

TLS key-value data storage

Implementations§

Source§

impl ThreadLocalStorage

Source

pub fn new() -> Self

Create new TLS area

Source

pub fn allocate(&mut self, size: usize) -> Result<(), KernelError>

Allocate TLS area backed by real physical frames.

Allocates enough physical frames to cover size bytes. The TLS base address is set to the physical frame address (which is identity-mapped in kernel space). The allocated memory is logically zero-filled (.tbss equivalent).

Source

pub fn install_base(&mut self, base: usize)

Install a user-provided TLS base (arch_prctl/TPIDR_EL0/tp).

Source

pub fn set_tls_base(&mut self, base: usize)

Set architecture TLS base register value (for user mode)

Source

pub fn tls_base(&self) -> usize

Get TLS base register value

Source

pub fn set_value(&mut self, key: u64, value: u64)

Set TLS value for key

Source

pub fn get_value(&self, key: u64) -> Option<u64>

Get TLS value for key

Source

pub fn remove_value(&mut self, key: u64) -> Option<u64>

Remove TLS value for key

Source

pub fn keys(&self) -> impl Iterator<Item = &u64>

Get all TLS keys

Source

pub fn activate_tls_register(&self)

Set the architecture-specific TLS base register.

On x86_64, sets FS base (via WRFSBASE or MSR). On AArch64, sets TPIDR_EL0. On RISC-V, sets the tp register.

This should be called during context switch or thread initialization to point the hardware TLS register to this thread’s TLS area.

Trait Implementations§

Source§

impl Default for ThreadLocalStorage

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for ThreadLocalStorage

§

impl RefUnwindSafe for ThreadLocalStorage

§

impl Send for ThreadLocalStorage

§

impl Sync for ThreadLocalStorage

§

impl Unpin for ThreadLocalStorage

§

impl UnwindSafe for ThreadLocalStorage

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.