Iros
 
Loading...
Searching...
No Matches
segment_descriptor.h
Go to the documentation of this file.
1#pragma once
2
3#include "di/bit/prelude.h"
4
6using namespace di::bit;
7
8// The format of a 64 bit Segment Descriptor is described
9// in the AMD64 Programmer's Manual; Volume 2; Figure 4-20 and 4-21,
10// and on the OSDEV wiki at the page:
11// https://wiki.osdev.org/Global_Descriptor_Table#Segment_Descriptor
12//
13// Note that the format for segment descriptors is identical between
14// 32 bit and 64 bit x86, but in 64 bit mode, most fields are ignored.
15
16struct LimitLow : BitField<0, 16> {};
17struct BaseLow : BitField<16, 16> {};
18struct BaseMid : BitField<32, 8> {};
19
20// This is ignored on x86_64.
21struct Accessed : BitFlag<40> {};
22// This is ignored on x86_64, and should be set to 1. This is valid for code segments.
23struct Readable : BitFlag<41> {};
24// This is ignored on x86_64, and should be set to 1. This is valid for data segments.
25struct Writable : BitFlag<41> {};
26
27// This bit allows a control flow transfer to a segment of higher privledge without changing the current privledge
28// level. This is valid for Code segments.
29struct Conforming : BitFlag<42> {};
30// This is ignored on x86_64, and should be set to 0. This is valid for Data segments.
31struct ExpandDown : BitFlag<42> {};
32
33// The segment loaded into the %cs register must have this bit set.
34struct Code : BitFlag<43> {};
35
36struct DataOrCodeSegment : BitFlag<44> {};
37
38struct DPL : BitField<45, 2> {};
39struct Present : BitFlag<47> {};
40
41struct LimitHigh : BitField<48, 4> {};
42
43struct Available : BitFlag<52> {};
44// This is valid for Code segments.
45struct LongMode : BitFlag<53> {};
46struct Not16Bit : BitFlag<54> {};
47struct Granular : BitFlag<55> {};
48
49struct BaseHigh : BitField<56, 8> {};
50
54}
Definition bit_struct.h:11
Definition bit_proxy_reference.h:5
Definition segment_descriptor.h:5
BitStruct< 8, LimitLow, BaseLow, Accessed, Readable, Writable, Conforming, ExpandDown, Code, DataOrCodeSegment, DPL, Present, LimitHigh, Available, LongMode, Not16Bit, Granular > SegmentDescriptor
Definition segment_descriptor.h:51
constexpr BitField(Value value)
Definition bit_field.h:28
constexpr BitFlag(bool value)
Definition bit_flag.h:19
Definition segment_descriptor.h:21
Definition segment_descriptor.h:43
Definition segment_descriptor.h:49
Definition segment_descriptor.h:17
Definition segment_descriptor.h:18
Definition segment_descriptor.h:34
Definition segment_descriptor.h:29
Definition segment_descriptor.h:38
Definition segment_descriptor.h:36
Definition segment_descriptor.h:31
Definition segment_descriptor.h:47
Definition segment_descriptor.h:41
Definition segment_descriptor.h:16
Definition segment_descriptor.h:45
Definition segment_descriptor.h:46
Definition segment_descriptor.h:39
Definition segment_descriptor.h:23
Definition segment_descriptor.h:25