Skip to content

Commit

Permalink
feat(hal-x86_64): add SystemSegment::boxed_tss (#372)
Browse files Browse the repository at this point in the history
Currently, TSS segments can only be constructed from statics. This makes
it difficult to construct a TSS dynamically when bringing up an
application processor.

This commit adds a new `SystemSegment::boxed_tss` constructor, which
allows TSS segments to be dynamically allocated, as well as stored in a
static.

This was factored out of PR #371.
  • Loading branch information
hawkw committed Nov 16, 2022
1 parent 9b2f885 commit 9699133
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions hal-x86_64/src/segment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,11 @@ impl SystemDescriptor {
const BASE_HIGH: bits::Pack64 = bits::Pack64::least_significant(32);
const BASE_HIGH_PAIR: Pair64 = Self::BASE_HIGH.pair_with(base::HIGH);

#[cfg(feature = "alloc")]
pub fn boxed_tss(tss: alloc::boxed::Box<task::StateSegment>) -> Self {
Self::tss(alloc::boxed::Box::leak(tss))
}

pub fn tss(tss: &'static task::StateSegment) -> Self {
let tss_addr = tss as *const _ as u64;
tracing::trace!(tss_addr = fmt::hex(tss_addr), "making TSS descriptor...");
Expand Down

0 comments on commit 9699133

Please sign in to comment.