mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-25 14:44:28 +02:00
UefiCpuPkg: Added segment descriptors' data structures.
This commit is contained in:
parent
9b8affc22d
commit
25d3704cc6
@ -14,104 +14,174 @@
|
|||||||
// Global descriptor table (GDT) Template
|
// Global descriptor table (GDT) Template
|
||||||
//
|
//
|
||||||
STATIC GDT_ENTRIES mGdtTemplate = {
|
STATIC GDT_ENTRIES mGdtTemplate = {
|
||||||
//
|
.Null = {
|
||||||
// NULL_SEL
|
.SegmentLimit_15_0 = 0x0,
|
||||||
//
|
.BaseAddress_15_0 = 0x0,
|
||||||
{
|
.BaseAddress_23_16 = 0x0,
|
||||||
0x0, // limit 15:0
|
.Type = 0x0,
|
||||||
0x0, // base 15:0
|
.S = 0,
|
||||||
0x0, // base 23:16
|
.DPL = 0,
|
||||||
0x0, // type
|
.P = 0,
|
||||||
0x0, // limit 19:16, flags
|
.SegmentLimit_19_16 = 0x0,
|
||||||
0x0, // base 31:24
|
.AVL = 0,
|
||||||
|
.L = 0,
|
||||||
|
.D_B = 0,
|
||||||
|
.G = 0,
|
||||||
|
.BaseAddress_31_24 = 0x0
|
||||||
},
|
},
|
||||||
//
|
.Linear = {
|
||||||
// LINEAR_SEL
|
.SegmentLimit_15_0 = 0xFFFF,
|
||||||
//
|
.BaseAddress_15_0 = 0x0,
|
||||||
{
|
.BaseAddress_23_16 = 0x0,
|
||||||
0x0FFFF, // limit 15:0
|
|
||||||
0x0, // base 15:0
|
.Accessed = 0,
|
||||||
0x0, // base 23:16
|
.Writable = 1,
|
||||||
0x092, // present, ring 0, data, read/write
|
.ExpansionDirection = 0,
|
||||||
0x0CF, // page-granular, 32-bit
|
.IsCode = 0,
|
||||||
0x0,
|
.IsNotSystemSegment = 1,
|
||||||
|
.DescriptorPrivilegeLevel = 0,
|
||||||
|
.SegmentPresent = 1,
|
||||||
|
|
||||||
|
.SegmentLimit_19_16 = 0xF,
|
||||||
|
.Available = 0,
|
||||||
|
.Reserved = 0,
|
||||||
|
.UpperBound = 1,
|
||||||
|
.Granularity = 1,
|
||||||
|
.BaseAddress_31_24 = 0x0
|
||||||
},
|
},
|
||||||
//
|
.LinearCode = {
|
||||||
// LINEAR_CODE_SEL
|
.SegmentLimit_15_0 = 0xFFFF,
|
||||||
//
|
.BaseAddress_15_0 = 0x0,
|
||||||
{
|
.BaseAddress_23_16 = 0x0,
|
||||||
0x0FFFF, // limit 15:0
|
|
||||||
0x0, // base 15:0
|
.Accessed = 1,
|
||||||
0x0, // base 23:16
|
.Readable = 1,
|
||||||
0x09F, // present, ring 0, code, execute/read, conforming, accessed
|
.Conforming = 1,
|
||||||
0x0CF, // page-granular, 32-bit
|
.IsCode = 1,
|
||||||
0x0,
|
.IsNotSystemSegment = 1,
|
||||||
|
.DescriptorPrivilegeLevel = 0,
|
||||||
|
.SegmentPresent = 1,
|
||||||
|
|
||||||
|
.SegmentLimit_19_16 = 0xF,
|
||||||
|
.Available = 0,
|
||||||
|
.Reserved = 0,
|
||||||
|
.Is32Bit = 1,
|
||||||
|
.Granularity = 1,
|
||||||
|
.BaseAddress_31_24 = 0x0
|
||||||
},
|
},
|
||||||
//
|
.SysData = {
|
||||||
// SYS_DATA_SEL
|
.SegmentLimit_15_0 = 0xFFFF,
|
||||||
//
|
.BaseAddress_15_0 = 0x0,
|
||||||
{
|
.BaseAddress_23_16 = 0x0,
|
||||||
0x0FFFF, // limit 15:0
|
|
||||||
0x0, // base 15:0
|
.Accessed = 1,
|
||||||
0x0, // base 23:16
|
.Writable = 1,
|
||||||
0x093, // present, ring 0, data, read/write, accessed
|
.ExpansionDirection = 0,
|
||||||
0x0CF, // page-granular, 32-bit
|
.IsCode = 0,
|
||||||
0x0,
|
.IsNotSystemSegment = 1,
|
||||||
|
.DescriptorPrivilegeLevel = 0,
|
||||||
|
.SegmentPresent = 1,
|
||||||
|
|
||||||
|
.SegmentLimit_19_16 = 0xF,
|
||||||
|
.Available = 0,
|
||||||
|
.Reserved = 0,
|
||||||
|
.UpperBound = 1,
|
||||||
|
.Granularity = 1,
|
||||||
|
.BaseAddress_31_24 = 0x0
|
||||||
},
|
},
|
||||||
//
|
.SysCode = {
|
||||||
// SYS_CODE_SEL
|
.SegmentLimit_15_0 = 0xFFFF,
|
||||||
//
|
.BaseAddress_15_0 = 0x0,
|
||||||
{
|
.BaseAddress_23_16 = 0x0,
|
||||||
0x0FFFF, // limit 15:0
|
|
||||||
0x0, // base 15:0
|
.Accessed = 0,
|
||||||
0x0, // base 23:16
|
.Readable = 1,
|
||||||
0x09A, // present, ring 0, code, execute/read
|
.Conforming = 0,
|
||||||
0x0CF, // page-granular, 32-bit
|
.IsCode = 1,
|
||||||
0x0,
|
.IsNotSystemSegment = 1,
|
||||||
|
.DescriptorPrivilegeLevel = 0,
|
||||||
|
.SegmentPresent = 1,
|
||||||
|
|
||||||
|
.SegmentLimit_19_16 = 0xF,
|
||||||
|
.Available = 0,
|
||||||
|
.Reserved = 0,
|
||||||
|
.Is32Bit = 1,
|
||||||
|
.Granularity = 1,
|
||||||
|
.BaseAddress_31_24 = 0x0
|
||||||
},
|
},
|
||||||
//
|
.SysCode16 = {
|
||||||
// SYS_CODE16_SEL
|
.SegmentLimit_15_0 = 0xFFFF,
|
||||||
//
|
.BaseAddress_15_0 = 0x0,
|
||||||
{
|
.BaseAddress_23_16 = 0x0,
|
||||||
0x0FFFF, // limit 15:0
|
|
||||||
0x0, // base 15:0
|
.Accessed = 0,
|
||||||
0x0, // base 23:16
|
.Readable = 1,
|
||||||
0x09A, // present, ring 0, code, execute/read
|
.Conforming = 0,
|
||||||
0x08F, // page-granular, 16-bit
|
.IsCode = 1,
|
||||||
0x0, // base 31:24
|
.IsNotSystemSegment = 1,
|
||||||
|
.DescriptorPrivilegeLevel = 0,
|
||||||
|
.SegmentPresent = 1,
|
||||||
|
|
||||||
|
.SegmentLimit_19_16 = 0xF,
|
||||||
|
.Available = 0,
|
||||||
|
.Reserved = 0,
|
||||||
|
.Is32Bit = 0,
|
||||||
|
.Granularity = 1,
|
||||||
|
.BaseAddress_31_24 = 0x0
|
||||||
},
|
},
|
||||||
//
|
.LinearData64 = {
|
||||||
// LINEAR_DATA64_SEL
|
.SegmentLimit_15_0 = 0xFFFF,
|
||||||
//
|
.BaseAddress_15_0 = 0x0,
|
||||||
{
|
.BaseAddress_23_16 = 0x0,
|
||||||
0x0FFFF, // limit 15:0
|
|
||||||
0x0, // base 15:0
|
.Accessed = 0,
|
||||||
0x0, // base 23:16
|
.Writable = 1,
|
||||||
0x092, // present, ring 0, data, read/write
|
.ExpansionDirection = 0,
|
||||||
0x0CF, // page-granular, 32-bit
|
.IsCode = 0,
|
||||||
0x0,
|
.IsNotSystemSegment = 1,
|
||||||
|
.DescriptorPrivilegeLevel = 0,
|
||||||
|
.SegmentPresent = 1,
|
||||||
|
|
||||||
|
.SegmentLimit_19_16 = 0xF,
|
||||||
|
.Available = 0,
|
||||||
|
.Reserved = 0,
|
||||||
|
.UpperBound = 1,
|
||||||
|
.Granularity = 1,
|
||||||
|
.BaseAddress_31_24 = 0x0
|
||||||
},
|
},
|
||||||
//
|
.LinearCode64 = {
|
||||||
// LINEAR_CODE64_SEL
|
.Reserved1 = 0x0,
|
||||||
//
|
.Reserved2 = 0x0,
|
||||||
{
|
|
||||||
0x0FFFF, // limit 15:0
|
.Accessed = 0,
|
||||||
0x0, // base 15:0
|
.Readable = 1,
|
||||||
0x0, // base 23:16
|
.Conforming = 0,
|
||||||
0x09A, // present, ring 0, code, execute/read
|
.IsCode = 1,
|
||||||
0x0AF, // page-granular, 64-bit code
|
.IsNotSystemSegment = 1,
|
||||||
0x0, // base (high)
|
.DescriptorPrivilegeLevel = 0,
|
||||||
|
.SegmentPresent = 1,
|
||||||
|
|
||||||
|
.Reserved3 = 0x0,
|
||||||
|
.Available = 0,
|
||||||
|
.LongMode = 1,
|
||||||
|
.Is32Bit = 0,
|
||||||
|
.Granularity = 1,
|
||||||
|
.Reserved4 = 0x0
|
||||||
},
|
},
|
||||||
//
|
.Spare5 = {
|
||||||
// SPARE5_SEL
|
.SegmentLimit_15_0 = 0x0,
|
||||||
//
|
.BaseAddress_15_0 = 0x0,
|
||||||
{
|
.BaseAddress_23_16 = 0x0,
|
||||||
0x0, // limit 15:0
|
.Type = 0x0,
|
||||||
0x0, // base 15:0
|
.S = 0,
|
||||||
0x0, // base 23:16
|
.DPL = 0,
|
||||||
0x0, // type
|
.P = 0,
|
||||||
0x0, // limit 19:16, flags
|
.SegmentLimit_19_16 = 0x0,
|
||||||
0x0, // base 31:24
|
.AVL = 0,
|
||||||
|
.L = 0,
|
||||||
|
.D_B = 0,
|
||||||
|
.G = 0,
|
||||||
|
.BaseAddress_31_24 = 0x0,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,26 +20,145 @@
|
|||||||
// Global Descriptor Entry structures
|
// Global Descriptor Entry structures
|
||||||
//
|
//
|
||||||
|
|
||||||
typedef struct _GDT_ENTRY {
|
typedef struct {
|
||||||
UINT16 Limit15_0;
|
UINT16 SegmentLimit_15_0;
|
||||||
UINT16 Base15_0;
|
UINT16 BaseAddress_15_0;
|
||||||
UINT8 Base23_16;
|
UINT8 BaseAddress_23_16;
|
||||||
UINT8 Type;
|
UINT8 Type : 4;
|
||||||
UINT8 Limit19_16_and_flags;
|
UINT8 S : 1;
|
||||||
UINT8 Base31_24;
|
UINT8 DPL : 2;
|
||||||
|
UINT8 P : 1;
|
||||||
|
UINT8 SegmentLimit_19_16 : 4;
|
||||||
|
UINT8 AVL : 1;
|
||||||
|
UINT8 L : 1;
|
||||||
|
UINT8 D_B : 1;
|
||||||
|
UINT8 G : 1;
|
||||||
|
UINT8 BaseAddress_31_24;
|
||||||
|
} SEGMENT_DESCRIPTOR;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UINT16 SegmentLimit_15_0;
|
||||||
|
UINT16 BaseAddress_15_0;
|
||||||
|
UINT8 BaseAddress_23_16;
|
||||||
|
//
|
||||||
|
// Type
|
||||||
|
//
|
||||||
|
UINT8 Accessed : 1;
|
||||||
|
UINT8 Writable : 1;
|
||||||
|
UINT8 ExpansionDirection : 1;
|
||||||
|
UINT8 IsCode : 1;
|
||||||
|
UINT8 IsNotSystemSegment : 1;
|
||||||
|
UINT8 DescriptorPrivilegeLevel : 2;
|
||||||
|
UINT8 SegmentPresent : 1;
|
||||||
|
|
||||||
|
UINT8 SegmentLimit_19_16 : 4;
|
||||||
|
UINT8 Available : 1;
|
||||||
|
UINT8 Reserved : 1;
|
||||||
|
UINT8 UpperBound : 1;
|
||||||
|
UINT8 Granularity : 1;
|
||||||
|
UINT8 BaseAddress_31_24;
|
||||||
|
} DATA_SEGMENT_32;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UINT16 SegmentLimit_15_0;
|
||||||
|
UINT16 BaseAddress_15_0;
|
||||||
|
UINT8 BaseAddress_23_16;
|
||||||
|
//
|
||||||
|
// Type
|
||||||
|
//
|
||||||
|
UINT8 Accessed : 1;
|
||||||
|
UINT8 Readable : 1;
|
||||||
|
UINT8 Conforming : 1;
|
||||||
|
UINT8 IsCode : 1;
|
||||||
|
UINT8 IsNotSystemSegment : 1;
|
||||||
|
UINT8 DescriptorPrivilegeLevel : 2;
|
||||||
|
UINT8 SegmentPresent : 1;
|
||||||
|
|
||||||
|
UINT8 SegmentLimit_19_16 : 4;
|
||||||
|
UINT8 Available : 1;
|
||||||
|
UINT8 Reserved : 1;
|
||||||
|
UINT8 Is32Bit : 1;
|
||||||
|
UINT8 Granularity : 1;
|
||||||
|
UINT8 BaseAddress_31_24;
|
||||||
|
} CODE_SEGMENT_32;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UINT32 Reserved1;
|
||||||
|
UINT8 Reserved2;
|
||||||
|
//
|
||||||
|
// Type
|
||||||
|
//
|
||||||
|
UINT8 Accessed : 1;
|
||||||
|
UINT8 Readable : 1;
|
||||||
|
UINT8 Conforming : 1;
|
||||||
|
UINT8 IsCode : 1;
|
||||||
|
UINT8 IsNotSystemSegment : 1;
|
||||||
|
UINT8 DescriptorPrivilegeLevel : 2;
|
||||||
|
UINT8 SegmentPresent : 1;
|
||||||
|
|
||||||
|
UINT8 Reserved3 : 4;
|
||||||
|
UINT8 Available : 1;
|
||||||
|
UINT8 LongMode : 1;
|
||||||
|
UINT8 Is32Bit : 1;
|
||||||
|
UINT8 Granularity : 1;
|
||||||
|
UINT8 Reserved4;
|
||||||
|
} CODE_SEGMENT_64;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UINT16 SegmentLimit_15_0;
|
||||||
|
UINT16 BaseAddress_15_0;
|
||||||
|
UINT8 BaseAddress_23_16;
|
||||||
|
|
||||||
|
UINT8 Type : 4;
|
||||||
|
UINT8 IsNotSystemSegment : 1;
|
||||||
|
UINT8 DescriptorPrivilegeLevel : 2;
|
||||||
|
UINT8 SegmentPresent : 1;
|
||||||
|
|
||||||
|
UINT8 SegmentLimit_19_16 : 4;
|
||||||
|
UINT8 Reserved : 3;
|
||||||
|
UINT8 Granularity : 1;
|
||||||
|
UINT8 BaseAddress_31_24;
|
||||||
|
} SYSTEM_SEGMENT;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UINT16 OffsetInSegment_15_0;
|
||||||
|
UINT16 SegmentSelector;
|
||||||
|
|
||||||
|
UINT8 ParameterCount : 5;
|
||||||
|
UINT8 Reserved : 3;
|
||||||
|
|
||||||
|
UINT8 Type : 4;
|
||||||
|
UINT8 IsNotSystemSegment : 1;
|
||||||
|
UINT8 DescriptorPrivilegeLevel : 2;
|
||||||
|
UINT8 SegmentPresent : 1;
|
||||||
|
UINT16 OffsetInSegment_31_16;
|
||||||
|
} CALL_GATE_32;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
CALL_GATE_32 Common;
|
||||||
|
UINT32 OffsetInSegment_63_31;
|
||||||
|
UINT32 Reserved;
|
||||||
|
} CALL_GATE_64;
|
||||||
|
|
||||||
|
typedef union {
|
||||||
|
DATA_SEGMENT_32 DataSegment32;
|
||||||
|
CODE_SEGMENT_32 CodeSegment32;
|
||||||
|
CODE_SEGMENT_64 CodeSegment64;
|
||||||
|
CALL_GATE_32 CallGate32;
|
||||||
|
SYSTEM_SEGMENT SystemSegment;
|
||||||
|
SEGMENT_DESCRIPTOR SegmentDescriptor;
|
||||||
} GDT_ENTRY;
|
} GDT_ENTRY;
|
||||||
|
|
||||||
typedef
|
typedef struct {
|
||||||
struct _GDT_ENTRIES {
|
SEGMENT_DESCRIPTOR Null;
|
||||||
GDT_ENTRY Null;
|
DATA_SEGMENT_32 Linear;
|
||||||
GDT_ENTRY Linear;
|
CODE_SEGMENT_32 LinearCode;
|
||||||
GDT_ENTRY LinearCode;
|
DATA_SEGMENT_32 SysData;
|
||||||
GDT_ENTRY SysData;
|
CODE_SEGMENT_32 SysCode;
|
||||||
GDT_ENTRY SysCode;
|
CODE_SEGMENT_32 SysCode16;
|
||||||
GDT_ENTRY SysCode16;
|
DATA_SEGMENT_32 LinearData64;
|
||||||
GDT_ENTRY LinearData64;
|
CODE_SEGMENT_64 LinearCode64;
|
||||||
GDT_ENTRY LinearCode64;
|
SEGMENT_DESCRIPTOR Spare5;
|
||||||
GDT_ENTRY Spare5;
|
|
||||||
} GDT_ENTRIES;
|
} GDT_ENTRIES;
|
||||||
|
|
||||||
#pragma pack ()
|
#pragma pack ()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user