#[repr(C)]pub struct SegmentDescriptor {
pub flags: SegmentDescriptorFlags,
/* private fields */
}
Expand description
An entry in a segment descriptor table that defines a new segment. This includes code, data, task state (TSS), and local descriptor table (LDT) segments.
Notes on the size of this structure:
- In 32-bit mode, this structure is always 8 bytes and contains a 32-bit base address.
- In 64-bit mode:
- Task state and local descriptor table segment descriptors are expanded to 16 bytes with 64-bit base addresses.
- From the processor’s perspective, code and data segments remain 8 bytes and the address and limit are both ignored. However, this structure is still defined as 16 bytes. This is fine, since the first 8 bytes are compatible and the rest will be ignored.
Fields§
§flags: SegmentDescriptorFlags
Common segment descriptor settings.
Implementations§
Source§impl SegmentDescriptor
impl SegmentDescriptor
Sourcepub const LIMIT_MAX: u32 = 1_048_575u32
pub const LIMIT_MAX: u32 = 1_048_575u32
The maximum supported value of the limit
field (20 bits).
Sourcepub fn address(self) -> usize
pub fn address(self) -> usize
Base virtual address of the segment, to which offsets are added.
In 64-bit mode, this is ignored and assumed to be 0 for code and data segments, but it still applies to task state and local descriptor table segments.
Sourcepub fn set_address(&mut self, address: usize)
pub fn set_address(&mut self, address: usize)
Update the base address.
Sourcepub fn limit(self) -> u32
pub fn limit(self) -> u32
The “limit” of the segment, which is a maximum or minimum offset from the base address.
If this is a stack-like data segment
(data_expand_down
), then this value is the
exclusive minimum offset value. Otherwise, this is the inclusive maximum
offset value (i.e., size - 1).
This value may be in bytes or in 4KB units, depending on
flags.granularity
.
In 64-bit mode, this is ignored (all limit checks are disabled) for code and data segments, but it still applies to task state and local descriptor table segments.
Trait Implementations§
Source§impl Clone for SegmentDescriptor
impl Clone for SegmentDescriptor
Source§fn clone(&self) -> SegmentDescriptor
fn clone(&self) -> SegmentDescriptor
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more