Skip to content

Commit 8e1d5f8

Browse files
committed
add an example for Descriptor::tss_segment_with_iomap
1 parent 6667531 commit 8e1d5f8

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/structures/gdt.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,27 @@ impl Descriptor {
444444
}
445445

446446
/// Creates a TSS system descriptor for the given TSS, setting up the IO permissions bitmap.
447+
///
448+
/// # Example
449+
///
450+
/// ```
451+
/// use x86_64::structures::gdt::Descriptor;
452+
/// use x86_64::structures::tss::TaskStateSegment;
453+
///
454+
/// /// A helper that places some I/O map bytes behind a TSS.
455+
/// #[repr(C)]
456+
/// struct TssWithIOMap {
457+
/// tss: TaskStateSegment,
458+
/// iomap: [u8; 5],
459+
/// }
460+
///
461+
/// static TSS: TssWithIOMap = TssWithIOMap {
462+
/// tss: TaskStateSegment::new(),
463+
/// iomap: [0xff, 0xff, 0x00, 0x80, 0xff],
464+
/// };
465+
///
466+
/// let tss = Descriptor::tss_segment_with_iomap(&TSS.tss, &TSS.iomap).unwrap();
467+
/// ```
447468
pub fn tss_segment_with_iomap(
448469
tss: &'static TaskStateSegment,
449470
iomap: &'static [u8],

0 commit comments

Comments
 (0)