MP3 1.0
This is the Doxygen document for ECE391 MP3.
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions | Variables
x86_desc.h File Reference

Defines for various x86 descriptors, descriptor tables, and selectors. More...

#include "types.h"

Go to the source code of this file.

Data Structures

struct  x86_desc
 This structure is used to load descriptor base registers like the GDTR and IDTR. More...
 
struct  seg_desc
 This is a segment descriptor. It goes in the GDT. More...
 
struct  pde_kb_desc
 
struct  pde_mb_desc
 Page-Directory Entry Descriptor. (4-MB Page Table) More...
 
union  pde_desc
 Page-Directory Entry Descriptor. (4-kB Page Table) More...
 
struct  pte_desc
 Page-Table Entry Descriptor. (4-kB Page) More...
 
union  idt_desc_t
 

Macros

#define KERNEL_CS   0x0010
 
#define KERNEL_DS   0x0018
 
#define USER_CS   0x0023
 
#define USER_DS   0x002B
 
#define KERNEL_TSS   0x0030
 
#define KERNEL_LDT   0x0038
 
#define TSS_SIZE   104
 
#define NUM_VEC   256
 
#define SET_LDT_PARAMS(str, addr, lim)
 
#define SET_TSS_PARAMS(str, addr, lim)
 
#define SET_IDT_ENTRY(str, handler)
 Sets runtime parameters for an IDT entry. More...
 
#define ltr(desc)
 Load task register. More...
 
#define lidt(desc)
 Load the interrupt descriptor table (IDT). More...
 
#define lldt(desc)
 Load the local descriptor table (LDT) register. More...
 
#define lgdt(desc)
 Load the global descriptor table (GDT). More...
 

Typedefs

typedef struct x86_desc x86_desc_t
 This structure is used to load descriptor base registers like the GDTR and IDTR. More...
 
typedef struct seg_desc seg_desc_t
 This is a segment descriptor. It goes in the GDT. More...
 
typedef struct pde_kb_desc pde_kb_desc_t
 
typedef struct pde_mb_desc pde_mb_desc_t
 Page-Directory Entry Descriptor. (4-MB Page Table) More...
 
typedef union pde_desc pde_desc_t
 Page-Directory Entry Descriptor. (4-kB Page Table) More...
 
typedef struct pte_desc pte_desc_t
 Page-Table Entry Descriptor. (4-kB Page) More...
 
typedef union idt_desc_t idt_desc_t
 

Functions

struct __attribute__ ((packed)) tss_t
 TSS structure. More...
 

Variables

uint16_t seg_lim_15_00
 
uint16_t base_15_00
 
uint8_t base_23_16
 
uint32_t type
 
uint32_t sys
 
uint32_t dpl
 
uint32_t present
 
uint32_t seg_lim_19_16
 
uint32_t avail
 
uint32_t reserved
 
uint32_t opsize
 
uint32_t granularity
 
uint8_t base_31_24
 
 tss_t
 
x86_desc_t gdt_desc
 
uint16_t ldt_desc
 
uint32_t ldt_size
 
seg_desc_t ldt_desc_ptr
 
seg_desc_t gdt_ptr
 
uint32_t ldt
 
uint32_t tss_size
 
seg_desc_t tss_desc_ptr
 
tss_t tss
 
uint16_t offset_15_00
 
uint16_t seg_selector
 
uint8_t reserved4
 
uint32_t reserved3
 
uint32_t reserved2
 
uint32_t reserved1
 
uint32_t size
 
uint32_t reserved0
 
uint16_t offset_31_16
 
idt_desc_t idt [NUM_VEC]
 
x86_desc_t idt_desc_ptr
 

Detailed Description

Defines for various x86 descriptors, descriptor tables, and selectors.

Author
Group 8, ECE391 staff
Version
1.0
Date
2023-03-04

Macro Definition Documentation

◆ KERNEL_CS

#define KERNEL_CS   0x0010

◆ KERNEL_DS

#define KERNEL_DS   0x0018

◆ KERNEL_LDT

#define KERNEL_LDT   0x0038

◆ KERNEL_TSS

#define KERNEL_TSS   0x0030

◆ lgdt

#define lgdt (   desc)
Value:
do { \
asm volatile ("lgdt (%0)" \
: \
: "g" (desc) \
: "memory" \
); \
} while (0)

Load the global descriptor table (GDT).

This macro takes a 32-bit address which points to a 6-byte structure. The 6-byte structure (defined as "struct x86_desc" above) contains a 2-byte size field specifying the size of the GDT, and a 4-byte address field specifying the base address of the GDT.

◆ lidt

#define lidt (   desc)
Value:
do { \
asm volatile ("lidt (%0)" \
: \
: "g" (desc) \
: "memory" \
); \
} while (0)

Load the interrupt descriptor table (IDT).

This macro takes a 32-bit address which points to a 6-byte structure. The 6-byte structure (defined as "struct x86_desc" above) contains a 2-byte size field specifying the size of the IDT, and a 4-byte address field specifying the base address of the IDT.

◆ lldt

#define lldt (   desc)
Value:
do { \
asm volatile ("lldt %%ax" \
: \
: "a" (desc) \
: "memory" \
); \
} while (0)

Load the local descriptor table (LDT) register.

This macro takes a 16-bit index into the GDT, which points to the LDT entry. x86 then reads the GDT's LDT descriptor and loads the base address specified in that descriptor into the LDT register.

◆ ltr

#define ltr (   desc)
Value:
do { \
asm volatile ("ltr %w0" \
: \
: "r" (desc) \
: "memory", "cc" \
); \
} while (0)

Load task register.

This macro takes a 16-bit index into the GDT, which points to the TSS entry. x86 then reads the GDT's TSS descriptor and loads the base address specified in that descriptor into the task register.

◆ NUM_VEC

#define NUM_VEC   256

◆ SET_IDT_ENTRY

#define SET_IDT_ENTRY (   str,
  handler 
)
Value:
do { \
str.offset_31_16 = ((uint32_t)(handler) & 0xFFFF0000) >> 16; \
str.offset_15_00 = ((uint32_t)(handler) & 0xFFFF); \
} while (0)
unsigned int uint32_t
Definition: types.h:19

Sets runtime parameters for an IDT entry.

◆ SET_LDT_PARAMS

#define SET_LDT_PARAMS (   str,
  addr,
  lim 
)
Value:
do { \
str.base_31_24 = ((uint32_t)(addr) & 0xFF000000) >> 24; \
str.base_23_16 = ((uint32_t)(addr) & 0x00FF0000) >> 16; \
str.base_15_00 = (uint32_t)(addr) & 0x0000FFFF; \
str.seg_lim_19_16 = ((lim) & 0x000F0000) >> 16; \
str.seg_lim_15_00 = (lim) & 0x0000FFFF; \
} while (0)

◆ SET_TSS_PARAMS

#define SET_TSS_PARAMS (   str,
  addr,
  lim 
)
Value:
do { \
str.base_31_24 = ((uint32_t)(addr) & 0xFF000000) >> 24; \
str.base_23_16 = ((uint32_t)(addr) & 0x00FF0000) >> 16; \
str.base_15_00 = (uint32_t)(addr) & 0x0000FFFF; \
str.seg_lim_19_16 = ((lim) & 0x000F0000) >> 16; \
str.seg_lim_15_00 = (lim) & 0x0000FFFF; \
} while (0)

◆ TSS_SIZE

#define TSS_SIZE   104

◆ USER_CS

#define USER_CS   0x0023

◆ USER_DS

#define USER_DS   0x002B

Typedef Documentation

◆ idt_desc_t

typedef union idt_desc_t idt_desc_t

◆ pde_desc_t

typedef union pde_desc pde_desc_t

Page-Directory Entry Descriptor. (4-kB Page Table)

◆ pde_kb_desc_t

typedef struct pde_kb_desc pde_kb_desc_t

◆ pde_mb_desc_t

typedef struct pde_mb_desc pde_mb_desc_t

Page-Directory Entry Descriptor. (4-MB Page Table)

◆ pte_desc_t

typedef struct pte_desc pte_desc_t

Page-Table Entry Descriptor. (4-kB Page)

◆ seg_desc_t

typedef struct seg_desc seg_desc_t

This is a segment descriptor. It goes in the GDT.

◆ x86_desc_t

typedef struct x86_desc x86_desc_t

This structure is used to load descriptor base registers like the GDTR and IDTR.

Function Documentation

◆ __attribute__()

struct __attribute__ ( (packed)  )

TSS structure.

Variable Documentation

◆ avail

uint32_t avail

◆ base_15_00

uint16_t base_15_00

◆ base_23_16

uint8_t base_23_16

◆ base_31_24

uint8_t base_31_24

◆ dpl

uint32_t dpl

◆ gdt_desc

x86_desc_t gdt_desc
extern

◆ gdt_ptr

seg_desc_t gdt_ptr
extern

◆ granularity

uint32_t granularity

◆ idt

idt_desc_t idt[NUM_VEC]
extern

◆ idt_desc_ptr

x86_desc_t idt_desc_ptr
extern

◆ ldt

uint32_t ldt
extern

◆ ldt_desc

uint16_t ldt_desc
extern

◆ ldt_desc_ptr

seg_desc_t ldt_desc_ptr
extern

◆ ldt_size

uint32_t ldt_size
extern

◆ offset_15_00

uint16_t offset_15_00

◆ offset_31_16

uint16_t offset_31_16

◆ opsize

uint32_t opsize

◆ present

uint32_t present

◆ reserved

uint32_t reserved

◆ reserved0

uint32_t reserved0

◆ reserved1

uint32_t reserved1

◆ reserved2

uint32_t reserved2

◆ reserved3

uint32_t reserved3

◆ reserved4

uint8_t reserved4

◆ seg_lim_15_00

uint16_t seg_lim_15_00

◆ seg_lim_19_16

uint32_t seg_lim_19_16

◆ seg_selector

uint16_t seg_selector

◆ size

uint32_t size

◆ sys

uint32_t sys

◆ tss

tss_t tss
extern

◆ tss_desc_ptr

seg_desc_t tss_desc_ptr
extern

◆ tss_size

uint32_t tss_size
extern

◆ tss_t

tss_t

◆ type

uint32_t type