@@ -6,13 +6,15 @@ use bit_field::BitField;
6
6
use core:: fmt;
7
7
// imports for intra doc links
8
8
#[ cfg( doc) ]
9
- use crate :: registers:: control:: Cr4Flags ;
9
+ use crate :: {
10
+ registers:: control:: Cr4Flags ,
11
+ structures:: gdt:: { Descriptor , DescriptorFlags , GlobalDescriptorTable } ,
12
+ } ;
10
13
11
14
/// An x86 segment
12
15
///
13
16
/// 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
16
18
/// configure the segment itself. Note that most segmentation functionality is
17
19
/// disabled in 64-bit mode. See the individual segments for more information.
18
20
pub trait Segment {
@@ -107,20 +109,27 @@ impl fmt::Debug for SegmentSelector {
107
109
108
110
/// Code Segment
109
111
///
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.
116
125
#[ derive( Debug ) ]
117
126
pub struct CS ;
118
127
119
128
/// Stack Segment
120
129
///
121
130
/// Entirely unused in 64-bit mode; setting the segment register does nothing.
122
131
/// 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
124
133
/// means a user-mode read/write segment descriptor must be present in the GDT.
125
134
///
126
135
/// This register is also set by the `syscall`/`sysret` and
0 commit comments