#[repr(C, packed)]
pub struct TaskStateSegment { pub reserved: u32, pub rsp: [u64; 3], pub reserved2: u64, pub ist: [u64; 7], pub reserved3: u64, pub reserved4: u16, pub iomap_base: u16, }
Expand description

Although hardware task-switching is not supported in 64-bit mode, a 64-bit task state segment (TSS) must exist.

The TSS holds information important to 64-bit mode and that is not directly related to the task-switch mechanism. This information includes:

RSPn

The full 64-bit canonical forms of the stack pointers (RSP) for privilege levels 0-2. RSPx is loaded in whenever an interrupt causes the CPU to change RPL to x. Note on a syscall entry this field is not used to load a stack, setting the stack there is the handler’s responsibility (however when using the int instruction in user-space, we load the stack from RSPn).

ISTn

The full 64-bit canonical forms of the interrupt stack table (IST) pointers. You can set an interrupt vector to use an IST entry in the Interrupt Descriptor Table by giving it a number from 0 - 7. If 0 is selected, then the IST mechanism is not used. If any other number is selected then when that interrupt vector is called the CPU will load RSP from the corresponding IST entry. This is useful for handling things like double faults, since you don’t have to worry about switching stacks; the CPU will do it for you.

I/O map base address

The 16-bit offset to the I/O permission bit map from the 64-bit TSS base.

The operating system must create at least one 64-bit TSS after activating IA-32e mode. It must execute the LTR instruction (in 64-bit mode) to load the TR register with a pointer to the 64-bit TSS responsible for both 64-bitmode programs and compatibility-mode programs (load_tr).

Fields

reserved: u32rsp: [u64; 3]

The full 64-bit canonical forms of the stack pointers (RSP) for privilege levels 0-2.

reserved2: u64ist: [u64; 7]

The full 64-bit canonical forms of the interrupt stack table (IST) pointers.

reserved3: u64reserved4: u16iomap_base: u16

The 16-bit offset to the I/O permission bit map from the 64-bit TSS base.

Implementations

Creates a new empty TSS.

Sets the stack pointer (stack_ptr) to be used for when an interrupt causes the CPU to change RPL to pl.

Sets the stack pointer (stack_ptr) to be used when an interrupt with a corresponding IST entry in the Interrupt Descriptor table pointing to the given index is raised.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.