@@ -6,13 +6,15 @@ use bit_field::BitField;
66use core:: fmt;
77// imports for intra doc links
88#[ cfg( doc) ]
9- use crate :: registers:: control:: Cr4Flags ;
9+ use crate :: {
10+ registers:: control:: Cr4Flags ,
11+ structures:: gdt:: { Descriptor , DescriptorFlags , GlobalDescriptorTable } ,
12+ } ;
1013
1114/// An x86 segment
1215///
1316/// Segment registers on x86 are 16-bit [`SegmentSelector`]s, which index into
14- /// the [`GlobalDescriptorTable`](crate::structures::gdt::GlobalDescriptorTable). The
15- /// corresponding GDT entry is used to
17+ /// the [`GlobalDescriptorTable`]. The corresponding GDT entry is used to
1618/// configure the segment itself. Note that most segmentation functionality is
1719/// disabled in 64-bit mode. See the individual segments for more information.
1820pub trait Segment {
@@ -107,20 +109,27 @@ impl fmt::Debug for SegmentSelector {
107109
108110/// Code Segment
109111///
110- /// Most fields like the segment base and limit are unused in 64-bit mode.
111- /// Only the LONG_MODE, PRESENT, USER_SEGMENT, EXECUTABLE, DEFAULT_SIZE (default operand size)
112- /// and DPL_RING_3 (descriptor privilege-level) fields of the
113- /// descriptor are recognized by the CPU. Some of them (e.g. DEFAULT_SIZE) are required to hold
114- /// a specific value and can't be changed. Others like the DPL_RING_3 and LONG_MODE
115- /// can be used to change privilege level or enable/disable long mode.
112+ /// While most fields in the Code-Segment [`Descriptor`] are unused in 64-bit
113+ /// long mode, some of them must be set to a specific value. The
114+ /// [`EXECUTABLE`](DescriptorFlags::EXECUTABLE),
115+ /// [`USER_SEGMENT`](DescriptorFlags::USER_SEGMENT), and
116+ /// [`LONG_MODE`](DescriptorFlags::LONG_MODE) bits must be set, while the
117+ /// [`DEFAULT_SIZE`](DescriptorFlags::DEFAULT_SIZE) bit must be unset.
118+ ///
119+ /// The [`DPL_RING_3`](DescriptorFlags::DPL_RING_3) field can be used to change
120+ /// privilege level. The [`PRESENT`](DescriptorFlags::PRESENT) bit can be used
121+ /// to make a segment present or not present.
122+ ///
123+ /// All other fields (like the segment base and limit) are ignored by the
124+ /// processor and setting them has no effect.
116125#[ derive( Debug ) ]
117126pub struct CS ;
118127
119128/// Stack Segment
120129///
121130/// Entirely unused in 64-bit mode; setting the segment register does nothing.
122131/// However, in ring 3, the SS register still has to point to a valid
123- /// [`Descriptor`](crate::structures::gdt::Descriptor) (it cannot be zero). This
132+ /// [`Descriptor`] (it cannot be zero). This
124133/// means a user-mode read/write segment descriptor must be present in the GDT.
125134///
126135/// This register is also set by the `syscall`/`sysret` and
0 commit comments