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: usizeTLS base address
size: usizeTLS size in bytes
data_ptr: usizeTLS data pointer (architecture-specific)
data: BTreeMap<u64, u64>TLS key-value data storage
Implementations§
Source§impl ThreadLocalStorage
impl ThreadLocalStorage
Sourcepub fn allocate(&mut self, size: usize) -> Result<(), KernelError>
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).
Sourcepub fn install_base(&mut self, base: usize)
pub fn install_base(&mut self, base: usize)
Install a user-provided TLS base (arch_prctl/TPIDR_EL0/tp).
Sourcepub fn set_tls_base(&mut self, base: usize)
pub fn set_tls_base(&mut self, base: usize)
Set architecture TLS base register value (for user mode)
Sourcepub fn remove_value(&mut self, key: u64) -> Option<u64>
pub fn remove_value(&mut self, key: u64) -> Option<u64>
Remove TLS value for key
Sourcepub fn activate_tls_register(&self)
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.