mirror of https://github.com/acidanthera/audk.git
OVMF VTF0 Reset Vector: Cleanup Global Descriptor Table (GDT)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9676 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
d22d1f535b
commit
141815f3c7
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -63,78 +63,71 @@ gdtr:
|
||||||
|
|
||||||
ALIGN 16
|
ALIGN 16
|
||||||
|
|
||||||
|
;
|
||||||
|
; Macros for GDT entries
|
||||||
|
;
|
||||||
|
|
||||||
|
%define PRESENT_FLAG(p) (p << 7)
|
||||||
|
%define DPL(dpl) (dpl << 5)
|
||||||
|
%define SYSTEM_FLAG(s) (s << 4)
|
||||||
|
%define DESC_TYPE(t) (t)
|
||||||
|
|
||||||
|
; Type: data, expand-up, writable, accessed
|
||||||
|
%define DATA32_TYPE 3
|
||||||
|
|
||||||
|
; Type: execute, readable, expand-up, accessed
|
||||||
|
%define CODE32_TYPE 0xb
|
||||||
|
|
||||||
|
; Type: execute, readable, expand-up, accessed
|
||||||
|
%define CODE64_TYPE 0xb
|
||||||
|
|
||||||
|
%define GRANULARITY_FLAG(g) (g << 7)
|
||||||
|
%define DEFAULT_SIZE32(d) (d << 6)
|
||||||
|
%define CODE64_FLAG(l) (l << 5)
|
||||||
|
%define UPPER_LIMIT(l) (l)
|
||||||
|
|
||||||
|
;
|
||||||
|
; The Global Descriptor Table (GDT)
|
||||||
|
;
|
||||||
|
|
||||||
GDT_BASE:
|
GDT_BASE:
|
||||||
; null descriptor
|
; null descriptor
|
||||||
NULL_SEL equ $-GDT_BASE
|
NULL_SEL equ $-GDT_BASE
|
||||||
dw 0 ; limit 15:0
|
DW 0 ; limit 15:0
|
||||||
dw 0 ; base 15:0
|
DW 0 ; base 15:0
|
||||||
db 0 ; base 23:16
|
DB 0 ; base 23:16
|
||||||
db 0 ; type
|
DB 0 ; sys flag, dpl, type
|
||||||
db 0 ; limit 19:16, flags
|
DB 0 ; limit 19:16, flags
|
||||||
db 0 ; base 31:24
|
DB 0 ; base 31:24
|
||||||
|
|
||||||
; linear data segment descriptor
|
; linear data segment descriptor
|
||||||
LINEAR_SEL equ $-GDT_BASE
|
LINEAR_SEL equ $-GDT_BASE
|
||||||
dw 0FFFFh ; limit 0xFFFFF
|
DW 0xffff ; limit 15:0
|
||||||
dw 0 ; base 0
|
DW 0 ; base 15:0
|
||||||
db 0
|
DB 0 ; base 23:16
|
||||||
db 093h ; present, ring 0, data, expand-up, writable, accessed
|
DB PRESENT_FLAG(1)|DPL(0)|SYSTEM_FLAG(1)|DESC_TYPE(DATA32_TYPE)
|
||||||
db 0CFh ; page-granular, 32-bit
|
DB GRANULARITY_FLAG(1)|DEFAULT_SIZE32(1)|CODE64_FLAG(0)|UPPER_LIMIT(0xf)
|
||||||
db 0
|
DB 0 ; base 31:24
|
||||||
|
|
||||||
; linear code segment descriptor
|
; linear code segment descriptor
|
||||||
LINEAR_CODE_SEL equ $-GDT_BASE
|
LINEAR_CODE_SEL equ $-GDT_BASE
|
||||||
dw 0FFFFh ; limit 0xFFFFF
|
DW 0xffff ; limit 15:0
|
||||||
dw 0 ; base 0
|
DW 0 ; base 15:0
|
||||||
db 0
|
DB 0 ; base 23:16
|
||||||
db 09Bh ; present, ring 0, data, expand-up, writable, accessed
|
DB PRESENT_FLAG(1)|DPL(0)|SYSTEM_FLAG(1)|DESC_TYPE(CODE32_TYPE)
|
||||||
db 0CFh ; page-granular, 32-bit
|
DB GRANULARITY_FLAG(1)|DEFAULT_SIZE32(1)|CODE64_FLAG(0)|UPPER_LIMIT(0xf)
|
||||||
db 0
|
DB 0 ; base 31:24
|
||||||
|
|
||||||
; system data segment descriptor
|
%ifdef ARCH_X64
|
||||||
SYS_DATA_SEL equ $-GDT_BASE
|
; linear code (64-bit) segment descriptor
|
||||||
dw 0FFFFh ; limit 0xFFFFF
|
LINEAR_CODE64_SEL equ $-GDT_BASE
|
||||||
dw 0 ; base 0
|
DW 0xffff ; limit 15:0
|
||||||
db 0
|
DW 0 ; base 15:0
|
||||||
db 093h ; present, ring 0, data, expand-up, writable, accessed
|
DB 0 ; base 23:16
|
||||||
db 0CFh ; page-granular, 32-bit
|
DB PRESENT_FLAG(1)|DPL(0)|SYSTEM_FLAG(1)|DESC_TYPE(CODE64_TYPE)
|
||||||
db 0
|
DB GRANULARITY_FLAG(1)|DEFAULT_SIZE32(0)|CODE64_FLAG(1)|UPPER_LIMIT(0xf)
|
||||||
|
DB 0 ; base 31:24
|
||||||
; system code segment descriptor
|
%endif
|
||||||
SYS_CODE_SEL equ $-GDT_BASE
|
|
||||||
dw 0FFFFh ; limit 0xFFFFF
|
|
||||||
dw 0 ; base 0
|
|
||||||
db 0
|
|
||||||
db 09Bh ; present, ring 0, data, expand-up, writable, accessed
|
|
||||||
db 0CFh ; page-granular, 32-bit
|
|
||||||
db 0
|
|
||||||
|
|
||||||
; spare segment descriptor
|
|
||||||
LINEAR_CODE64_SEL equ $-GDT_BASE
|
|
||||||
DW -1 ; LimitLow
|
|
||||||
DW 0 ; BaseLow
|
|
||||||
DB 0 ; BaseMid
|
|
||||||
DB 9bh
|
|
||||||
DB 0afh ; LimitHigh (CS.L=1, CS.D=0)
|
|
||||||
DB 0 ; BaseHigh
|
|
||||||
|
|
||||||
; spare segment descriptor
|
|
||||||
SPARE4_SEL equ $-GDT_BASE
|
|
||||||
dw 0 ; limit 0xFFFFF
|
|
||||||
dw 0 ; base 0
|
|
||||||
db 0
|
|
||||||
db 0 ; present, ring 0, data, expand-up, writable
|
|
||||||
db 0 ; page-granular, 32-bit
|
|
||||||
db 0
|
|
||||||
|
|
||||||
; spare segment descriptor
|
|
||||||
SPARE5_SEL equ $-GDT_BASE
|
|
||||||
dw 0 ; limit 0xFFFFF
|
|
||||||
dw 0 ; base 0
|
|
||||||
db 0
|
|
||||||
db 0 ; present, ring 0, data, expand-up, writable
|
|
||||||
db 0 ; page-granular, 32-bit
|
|
||||||
db 0
|
|
||||||
|
|
||||||
GDT_END:
|
GDT_END:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue