Loading [MathJax]/extensions/tex2jax.js
CS350 COS
COS
All Data Structures Files Functions Variables Typedefs Macros
amd64.h File Reference
#include <sys/cdefs.h>
#include "amd64op.h"
Include dependency graph for amd64.h:

Go to the source code of this file.

Data Structures

struct  PageTable
 
struct  PseudoDescriptor
 
struct  InteruptGate64
 
struct  TaskStateSegment64
 
struct  XSAVEArea
 

Macros

#define PGNUMMASK   0xFFFFFFFFFFFFF000ULL
 
#define PGIDXSHIFT   9
 
#define PGIDXMASK   (512 - 1)
 
#define PGSHIFT   12
 
#define PGSIZE   (1 << PGSHIFT)
 
#define PGMASK   (PGSIZE - 1)
 
#define LARGE_PGSHIFT   21
 
#define LARGE_PGSIZE   (1 << LARGE_PGSHIFT)
 
#define LARGE_PGMASK   (LARGE_PGSIZE - 1)
 
#define HUGE_PGSHIFT   30
 
#define HUGE_PGSIZE   (1 << HUGE_PGSHIFT)
 
#define HUGE_PGMASK   (HUGE_PGSIZE - 1)
 
#define ROUNDUP_PGSIZE(x)   (((x) + LARGE_PGSIZE - 1) & ~LARGE_PGMASK)
 
#define ROUNDDOWN_PGSIZE(x)   ((x) & ~LARGE_PGMASK)
 
#define PTE_P   0x0001 /* Present */
 
#define PTE_W   0x0002 /* Writeable */
 
#define PTE_U   0x0004 /* User */
 
#define PTE_PWT   0x0008 /* Write Through */
 
#define PTE_PCD   0x0010 /* Cache Disable */
 
#define PTE_A   0x0020 /* Accessed */
 
#define PTE_D   0x0040 /* Dirty */
 
#define PTE_PS   0x0080 /* Page Size */
 
#define PTE_G   0x0100 /* Global */
 
#define PTE_OS1   0x0200 /* Available */
 
#define PTE_OS2   0x0400 /* Available */
 
#define PTE_OS3   0x0800 /* Available */
 
#define PTE_PAT   0x1000 /* Page Attribute Table */
 
#define PTE_NX   0x8000000000000000ULL /* No Execute */
 
#define PAGETABLE_ENTRIES   512
 
#define SEG_G
 
#define SEG_DB
 
#define SEG_L
 
#define SEG_P
 
#define SEG_DPL_SHIFT   45
 
#define SEG_S
 
#define SEG_CS   (0xE << 40)
 
#define SEG_DS   (0x2 << 40)
 
#define SEG_TSA   (0x9 << 40)
 
#define SEG_TSB   (0xB << 40)
 
#define SEL_KCS   0x08
 
#define SEL_KDS   0x10
 
#define SEL_TSS   0x20
 
#define SEL_UCS   0x30
 
#define SEL_UDS   0x38
 
#define CR0_PE   0x00000001 /* Protection Enabled */
 
#define CR0_MP   0x00000002 /* Monitor Coprocessor */
 
#define CR0_EM   0x00000004 /* Emulation */
 
#define CR0_TS   0x00000008 /* Task Switched */
 
#define CR0_ET   0x00000010 /* Extension Type */
 
#define CR0_NE   0x00000020 /* Numeric Error */
 
#define CR0_WP   0x00010000 /* Write Protect */
 
#define CR0_AM   0x00040000 /* Alignment Mask */
 
#define CR0_NW   0x20000000 /* Not Writethrough */
 
#define CR0_CD   0x40000000 /* Cache Disable */
 
#define CR0_PG   0x80000000 /* Paging */
 
#define CR4_VME   0x00000001 /* Virtual 8086 Mode Enable */
 
#define CR4_PVI   0x00000002 /* Protected-Mode Virtual Interupts */
 
#define CR4_TSD   0x00000004 /* Time Stamp Diable */
 
#define CR4_DE   0x00000008 /* Debugging Extensions */
 
#define CR4_PSE   0x00000010 /* Page Size Extensions */
 
#define CR4_PAE   0x00000020 /* Physical Address Extension */
 
#define CR4_MCE   0x00000040 /* Machine Check Enable */
 
#define CR4_PGE   0x00000080 /* Page Global Enable */
 
#define CR4_PCE   0x00000100 /* Performance Monitoring Counter Enable */
 
#define CR4_OSFXSR   0x00000200 /* OS FXSAVE/FXRSTOR Support */
 
#define CR4_OSXMMEXCPT   0x00000400 /* OS Unmasked Exception Support */
 
#define CR4_FSGSBASE   0x00010000 /* Enable FS/GS read/write Instructions */
 
#define CR4_OSXSAVE   0x00040000 /* XSAVE and Processor Extended States Enable */
 
#define RFLAGS_CF   0x00000001 /* Carry Flag */
 
#define RFLAGS_PF   0x00000004 /* Parity Flag */
 
#define RFLAGS_AF   0x00000010 /* Adjust Flag */
 
#define RFLAGS_ZF   0x00000040 /* Zero Flag */
 
#define RFLAGS_SF   0x00000080 /* Sign Flag */
 
#define RFLAGS_TF   0x00000100 /* Trap Flag */
 
#define RFLAGS_IF   0x00000200 /* Interrupt Enable Flag */
 
#define RFLAGS_DF   0x00000400 /* Direction Flag */
 
#define RFLAGS_OF   0x00000800 /* Overflow Flag */
 
#define RFLAGS_NT   0x00004000 /* Nested Task Flag */
 
#define RFLAGS_RF   0x00010000 /* Resume Flag */
 
#define RFLAGS_VM   0x00020000 /* Virtual 8086 Mode */
 
#define RFLAGS_AC   0x00040000 /* Alignment Check */
 
#define RFLAGS_VIF   0x00080000 /* Virtual Interrupt Flag */
 
#define RFLAGS_VIP   0x00100000 /* Virtual Interrupt Pending */
 
#define RFLAGS_ID   0x00200000 /* CPUID Supported */
 
#define DR7_DR0L   0x00000001
 
#define DR7_DR0G   0x00000002
 
#define DR7_DR1L   0x00000004
 
#define DR7_DR1G   0x00000008
 
#define DR7_DR2L   0x00000010
 
#define DR7_DR2G   0x00000020
 
#define DR7_DR3L   0x00000040
 
#define DR7_DR3G   0x00000080
 
#define MSR_EFER   0xC0000080
 
#define EFER_SCE   0x0001 /* Syscall Enable */
 
#define EFER_LME   0x0100 /* Long Mode Enable */
 
#define EFER_LMA   0x0400 /* Long Mode Active */
 
#define EFER_NXE   0x0800 /* Enable Execute Disable */
 
#define EFER_SVME   0x1000 /* SVM Enable (AMD) */
 
#define EFER_SLE   0x2000 /* Long Mode Segment Limit Enable (AMD) */
 
#define EFER_FFXSR   0x4000 /* Fast FXSAVE/FXRSTOR (AMD) */
 
#define EFER_TCE   0x8000 /* Translation Cache Extension (AMD) */
 
#define MSR_STAR   0xC0000081
 
#define MSR_LSTAR   0xC0000082
 
#define MSR_CSTAR   0xC0000083
 
#define MSR_SFMASK   0xC0000084
 

Typedefs

typedef uint64_t PageEntry
 
typedef struct PageTable PageTable
 
typedef struct PACKED PseudoDescriptor PseudoDescriptor
 
typedef uint64_t SegmentDescriptor
 
typedef struct PACKED InteruptGate64 InteruptGate64
 
typedef struct PACKED TaskStateSegment64 TaskStateSegment64
 
typedef struct XSAVEArea XSAVEArea
 

Data Structure Documentation

◆ PageTable

struct PageTable

Definition at line 54 of file amd64.h.

Collaboration diagram for PageTable:
[legend]
Data Fields
PageEntry entries[PAGETABLE_ENTRIES]

◆ PseudoDescriptor

struct PseudoDescriptor

Definition at line 62 of file amd64.h.

Collaboration diagram for PseudoDescriptor:
[legend]
Data Fields
uint16_t lim
uint64_t off

◆ InteruptGate64

struct InteruptGate64

Definition at line 92 of file amd64.h.

Collaboration diagram for InteruptGate64:
[legend]
Data Fields
uint32_t _unused1
uint16_t cs
uint8_t ist
uint32_t pc_high
uint16_t pc_low
uint16_t pc_mid
uint8_t type

◆ TaskStateSegment64

struct TaskStateSegment64

Definition at line 106 of file amd64.h.

Collaboration diagram for TaskStateSegment64:
[legend]
Data Fields
uint32_t _unused0
uint64_t _unused1
uint32_t _unused2
uint32_t _unused3
uint16_t _unused4
uint16_t iomap_offset
uint64_t ist1
uint64_t ist2
uint64_t ist3
uint64_t ist4
uint64_t ist5
uint64_t ist6
uint64_t ist7
uint64_t rsp0
uint64_t rsp1
uint64_t rsp2

◆ XSAVEArea

struct XSAVEArea

Definition at line 129 of file amd64.h.

Collaboration diagram for XSAVEArea:
[legend]
Data Fields
uint8_t _rsvd0
uint16_t fcw
uint16_t fop
uint64_t fpudp
uint64_t fpuip
uint16_t fsw
uint8_t ftw
uint64_t mmx[16]
uint32_t mxcsr
uint32_t mxcsr_mask
uint64_t xmm[32]

Macro Definition Documentation

◆ CR0_AM

#define CR0_AM   0x00040000 /* Alignment Mask */

Definition at line 155 of file amd64.h.

◆ CR0_CD

#define CR0_CD   0x40000000 /* Cache Disable */

Definition at line 157 of file amd64.h.

◆ CR0_EM

#define CR0_EM   0x00000004 /* Emulation */

Definition at line 150 of file amd64.h.

◆ CR0_ET

#define CR0_ET   0x00000010 /* Extension Type */

Definition at line 152 of file amd64.h.

◆ CR0_MP

#define CR0_MP   0x00000002 /* Monitor Coprocessor */

Definition at line 149 of file amd64.h.

◆ CR0_NE

#define CR0_NE   0x00000020 /* Numeric Error */

Definition at line 153 of file amd64.h.

◆ CR0_NW

#define CR0_NW   0x20000000 /* Not Writethrough */

Definition at line 156 of file amd64.h.

◆ CR0_PE

#define CR0_PE   0x00000001 /* Protection Enabled */

Definition at line 148 of file amd64.h.

◆ CR0_PG

#define CR0_PG   0x80000000 /* Paging */

Definition at line 158 of file amd64.h.

◆ CR0_TS

#define CR0_TS   0x00000008 /* Task Switched */

Definition at line 151 of file amd64.h.

◆ CR0_WP

#define CR0_WP   0x00010000 /* Write Protect */

Definition at line 154 of file amd64.h.

◆ CR4_DE

#define CR4_DE   0x00000008 /* Debugging Extensions */

Definition at line 163 of file amd64.h.

◆ CR4_FSGSBASE

#define CR4_FSGSBASE   0x00010000 /* Enable FS/GS read/write Instructions */

Definition at line 171 of file amd64.h.

◆ CR4_MCE

#define CR4_MCE   0x00000040 /* Machine Check Enable */

Definition at line 166 of file amd64.h.

◆ CR4_OSFXSR

#define CR4_OSFXSR   0x00000200 /* OS FXSAVE/FXRSTOR Support */

Definition at line 169 of file amd64.h.

◆ CR4_OSXMMEXCPT

#define CR4_OSXMMEXCPT   0x00000400 /* OS Unmasked Exception Support */

Definition at line 170 of file amd64.h.

◆ CR4_OSXSAVE

#define CR4_OSXSAVE   0x00040000 /* XSAVE and Processor Extended States Enable */

Definition at line 172 of file amd64.h.

◆ CR4_PAE

#define CR4_PAE   0x00000020 /* Physical Address Extension */

Definition at line 165 of file amd64.h.

◆ CR4_PCE

#define CR4_PCE   0x00000100 /* Performance Monitoring Counter Enable */

Definition at line 168 of file amd64.h.

◆ CR4_PGE

#define CR4_PGE   0x00000080 /* Page Global Enable */

Definition at line 167 of file amd64.h.

◆ CR4_PSE

#define CR4_PSE   0x00000010 /* Page Size Extensions */

Definition at line 164 of file amd64.h.

◆ CR4_PVI

#define CR4_PVI   0x00000002 /* Protected-Mode Virtual Interupts */

Definition at line 161 of file amd64.h.

◆ CR4_TSD

#define CR4_TSD   0x00000004 /* Time Stamp Diable */

Definition at line 162 of file amd64.h.

◆ CR4_VME

#define CR4_VME   0x00000001 /* Virtual 8086 Mode Enable */

Definition at line 160 of file amd64.h.

◆ DR7_DR0G

#define DR7_DR0G   0x00000002

Definition at line 197 of file amd64.h.

◆ DR7_DR0L

#define DR7_DR0L   0x00000001

Definition at line 196 of file amd64.h.

◆ DR7_DR1G

#define DR7_DR1G   0x00000008

Definition at line 199 of file amd64.h.

◆ DR7_DR1L

#define DR7_DR1L   0x00000004

Definition at line 198 of file amd64.h.

◆ DR7_DR2G

#define DR7_DR2G   0x00000020

Definition at line 201 of file amd64.h.

◆ DR7_DR2L

#define DR7_DR2L   0x00000010

Definition at line 200 of file amd64.h.

◆ DR7_DR3G

#define DR7_DR3G   0x00000080

Definition at line 203 of file amd64.h.

◆ DR7_DR3L

#define DR7_DR3L   0x00000040

Definition at line 202 of file amd64.h.

◆ EFER_FFXSR

#define EFER_FFXSR   0x4000 /* Fast FXSAVE/FXRSTOR (AMD) */

Definition at line 217 of file amd64.h.

◆ EFER_LMA

#define EFER_LMA   0x0400 /* Long Mode Active */

Definition at line 213 of file amd64.h.

◆ EFER_LME

#define EFER_LME   0x0100 /* Long Mode Enable */

Definition at line 212 of file amd64.h.

◆ EFER_NXE

#define EFER_NXE   0x0800 /* Enable Execute Disable */

Definition at line 214 of file amd64.h.

◆ EFER_SCE

#define EFER_SCE   0x0001 /* Syscall Enable */

Definition at line 211 of file amd64.h.

◆ EFER_SLE

#define EFER_SLE   0x2000 /* Long Mode Segment Limit Enable (AMD) */

Definition at line 216 of file amd64.h.

◆ EFER_SVME

#define EFER_SVME   0x1000 /* SVM Enable (AMD) */

Definition at line 215 of file amd64.h.

◆ EFER_TCE

#define EFER_TCE   0x8000 /* Translation Cache Extension (AMD) */

Definition at line 218 of file amd64.h.

◆ HUGE_PGMASK

#define HUGE_PGMASK   (HUGE_PGSIZE - 1)

Definition at line 30 of file amd64.h.

◆ HUGE_PGSHIFT

#define HUGE_PGSHIFT   30

Definition at line 28 of file amd64.h.

◆ HUGE_PGSIZE

#define HUGE_PGSIZE   (1 << HUGE_PGSHIFT)

Definition at line 29 of file amd64.h.

◆ LARGE_PGMASK

#define LARGE_PGMASK   (LARGE_PGSIZE - 1)

Definition at line 26 of file amd64.h.

◆ LARGE_PGSHIFT

#define LARGE_PGSHIFT   21

Definition at line 24 of file amd64.h.

◆ LARGE_PGSIZE

#define LARGE_PGSIZE   (1 << LARGE_PGSHIFT)

Definition at line 25 of file amd64.h.

◆ MSR_CSTAR

#define MSR_CSTAR   0xC0000083

Definition at line 223 of file amd64.h.

◆ MSR_EFER

#define MSR_EFER   0xC0000080

Definition at line 209 of file amd64.h.

◆ MSR_LSTAR

#define MSR_LSTAR   0xC0000082

Definition at line 222 of file amd64.h.

◆ MSR_SFMASK

#define MSR_SFMASK   0xC0000084

Definition at line 224 of file amd64.h.

◆ MSR_STAR

#define MSR_STAR   0xC0000081

Definition at line 221 of file amd64.h.

◆ PAGETABLE_ENTRIES

#define PAGETABLE_ENTRIES   512

Definition at line 50 of file amd64.h.

◆ PGIDXMASK

#define PGIDXMASK   (512 - 1)

Definition at line 18 of file amd64.h.

◆ PGIDXSHIFT

#define PGIDXSHIFT   9

Definition at line 17 of file amd64.h.

◆ PGMASK

#define PGMASK   (PGSIZE - 1)

Definition at line 22 of file amd64.h.

◆ PGNUMMASK

#define PGNUMMASK   0xFFFFFFFFFFFFF000ULL

Definition at line 15 of file amd64.h.

◆ PGSHIFT

#define PGSHIFT   12

Definition at line 20 of file amd64.h.

◆ PGSIZE

#define PGSIZE   (1 << PGSHIFT)

Definition at line 21 of file amd64.h.

◆ PTE_A

#define PTE_A   0x0020 /* Accessed */

Definition at line 40 of file amd64.h.

◆ PTE_D

#define PTE_D   0x0040 /* Dirty */

Definition at line 41 of file amd64.h.

◆ PTE_G

#define PTE_G   0x0100 /* Global */

Definition at line 43 of file amd64.h.

◆ PTE_NX

#define PTE_NX   0x8000000000000000ULL /* No Execute */

Definition at line 48 of file amd64.h.

◆ PTE_OS1

#define PTE_OS1   0x0200 /* Available */

Definition at line 44 of file amd64.h.

◆ PTE_OS2

#define PTE_OS2   0x0400 /* Available */

Definition at line 45 of file amd64.h.

◆ PTE_OS3

#define PTE_OS3   0x0800 /* Available */

Definition at line 46 of file amd64.h.

◆ PTE_P

#define PTE_P   0x0001 /* Present */

Definition at line 35 of file amd64.h.

◆ PTE_PAT

#define PTE_PAT   0x1000 /* Page Attribute Table */

Definition at line 47 of file amd64.h.

◆ PTE_PCD

#define PTE_PCD   0x0010 /* Cache Disable */

Definition at line 39 of file amd64.h.

◆ PTE_PS

#define PTE_PS   0x0080 /* Page Size */

Definition at line 42 of file amd64.h.

◆ PTE_PWT

#define PTE_PWT   0x0008 /* Write Through */

Definition at line 38 of file amd64.h.

◆ PTE_U

#define PTE_U   0x0004 /* User */

Definition at line 37 of file amd64.h.

◆ PTE_W

#define PTE_W   0x0002 /* Writeable */

Definition at line 36 of file amd64.h.

◆ RFLAGS_AC

#define RFLAGS_AC   0x00040000 /* Alignment Check */

Definition at line 187 of file amd64.h.

◆ RFLAGS_AF

#define RFLAGS_AF   0x00000010 /* Adjust Flag */

Definition at line 176 of file amd64.h.

◆ RFLAGS_CF

#define RFLAGS_CF   0x00000001 /* Carry Flag */

Definition at line 174 of file amd64.h.

◆ RFLAGS_DF

#define RFLAGS_DF   0x00000400 /* Direction Flag */

Definition at line 181 of file amd64.h.

◆ RFLAGS_ID

#define RFLAGS_ID   0x00200000 /* CPUID Supported */

Definition at line 190 of file amd64.h.

◆ RFLAGS_IF

#define RFLAGS_IF   0x00000200 /* Interrupt Enable Flag */

Definition at line 180 of file amd64.h.

◆ RFLAGS_NT

#define RFLAGS_NT   0x00004000 /* Nested Task Flag */

Definition at line 184 of file amd64.h.

◆ RFLAGS_OF

#define RFLAGS_OF   0x00000800 /* Overflow Flag */

Definition at line 182 of file amd64.h.

◆ RFLAGS_PF

#define RFLAGS_PF   0x00000004 /* Parity Flag */

Definition at line 175 of file amd64.h.

◆ RFLAGS_RF

#define RFLAGS_RF   0x00010000 /* Resume Flag */

Definition at line 185 of file amd64.h.

◆ RFLAGS_SF

#define RFLAGS_SF   0x00000080 /* Sign Flag */

Definition at line 178 of file amd64.h.

◆ RFLAGS_TF

#define RFLAGS_TF   0x00000100 /* Trap Flag */

Definition at line 179 of file amd64.h.

◆ RFLAGS_VIF

#define RFLAGS_VIF   0x00080000 /* Virtual Interrupt Flag */

Definition at line 188 of file amd64.h.

◆ RFLAGS_VIP

#define RFLAGS_VIP   0x00100000 /* Virtual Interrupt Pending */

Definition at line 189 of file amd64.h.

◆ RFLAGS_VM

#define RFLAGS_VM   0x00020000 /* Virtual 8086 Mode */

Definition at line 186 of file amd64.h.

◆ RFLAGS_ZF

#define RFLAGS_ZF   0x00000040 /* Zero Flag */

Definition at line 177 of file amd64.h.

◆ ROUNDDOWN_PGSIZE

#define ROUNDDOWN_PGSIZE (   x)    ((x) & ~LARGE_PGMASK)

Definition at line 33 of file amd64.h.

◆ ROUNDUP_PGSIZE

#define ROUNDUP_PGSIZE (   x)    (((x) + LARGE_PGSIZE - 1) & ~LARGE_PGMASK)

Definition at line 32 of file amd64.h.

◆ SEG_CS

#define SEG_CS   (0xE << 40)

Definition at line 74 of file amd64.h.

◆ SEG_DB

#define SEG_DB

Definition at line 68 of file amd64.h.

◆ SEG_DPL_SHIFT

#define SEG_DPL_SHIFT   45

Definition at line 71 of file amd64.h.

◆ SEG_DS

#define SEG_DS   (0x2 << 40)

Definition at line 75 of file amd64.h.

◆ SEG_G

#define SEG_G

Definition at line 67 of file amd64.h.

◆ SEG_L

#define SEG_L

Definition at line 69 of file amd64.h.

◆ SEG_P

#define SEG_P

Definition at line 70 of file amd64.h.

◆ SEG_S

#define SEG_S

Definition at line 72 of file amd64.h.

◆ SEG_TSA

#define SEG_TSA   (0x9 << 40)

Definition at line 77 of file amd64.h.

◆ SEG_TSB

#define SEG_TSB   (0xB << 40)

Definition at line 78 of file amd64.h.

◆ SEL_KCS

#define SEL_KCS   0x08

Definition at line 80 of file amd64.h.

◆ SEL_KDS

#define SEL_KDS   0x10

Definition at line 81 of file amd64.h.

◆ SEL_TSS

#define SEL_TSS   0x20

Definition at line 82 of file amd64.h.

◆ SEL_UCS

#define SEL_UCS   0x30

Definition at line 83 of file amd64.h.

◆ SEL_UDS

#define SEL_UDS   0x38

Definition at line 84 of file amd64.h.

Typedef Documentation

◆ InteruptGate64

◆ PageEntry

Definition at line 52 of file amd64.h.

◆ PageTable

typedef struct PageTable PageTable

◆ PseudoDescriptor

◆ SegmentDescriptor

Definition at line 86 of file amd64.h.

◆ TaskStateSegment64

◆ XSAVEArea

typedef struct XSAVEArea XSAVEArea