IBNOS
Classes | Macros | Functions | Variables
gdt.h File Reference
#include <stdint.h>
#include <hardware/context.h>
#include <process/thread.h>
Include dependency graph for gdt.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  GDTTable
 
struct  GDTEntry
 
struct  IDTTable
 
struct  IDTEntry
 

Macros

#define KERNELSTACK_SIZE   PAGE_SIZE
 
#define USERMODE_KERNELSTACK_ADDRESS   0xFF800000
 
#define USERMODE_GDT_ADDRESS   0xFF801000
 
#define USERMODE_IDT_ADDRESS   0xFF811000
 
#define USERMODE_INTJMP_ADDRESS   0xFF812000
 
#define USERMODE_TASK_ADDRESS   0xFF813000
 
#define USERMODE_KERNELSTACK_LIMIT   (USERMODE_KERNELSTACK_ADDRESS + KERNELSTACK_SIZE)
 
#define USERMODE_INTJMP_ENABLE_FPU   (USERMODE_INTJMP_ADDRESS + 2048)
 
GDT Privileges
#define GDT_CPL_MASK   3
 
#define GDT_CPL_RING0   0
 
#define GDT_CPL_RING3   3
 
Interrupt types

For more information take a look at http://wiki.osdev.org/Interrupt_Descriptor_Table

#define INT_TYPE_TASK32   0x5
 
#define INT_TYPE_INT16   0x6
 
#define INT_TYPE_TRAP16   0x7
 
#define INT_TYPE_INT32   0xE
 
#define INT_TYPE_TRAP32   0xF
 
GDT Size
#define GDT_MAX_SIZE   0x10000
 
#define GDT_MAX_PAGES   ((GDT_MAX_SIZE + PAGE_MASK) >> PAGE_BITS)
 
#define GDT_MAX_COUNT   (GDT_MAX_SIZE / sizeof(struct GDTEntry))
 
IDT Size
#define IDT_MAX_SIZE   PAGE_SIZE
 
#define IDT_MAX_COUNT   256
 

Functions

struct GDTTable __attribute__ ((packed))
 
void gdtInit ()
 Initializes the GDT, task registers, and sets up everything required for multiprocessing. More...
 
struct GDTEntrygdtGetFreeEntry ()
 Get a free entry in the GDT. More...
 
uint32_t gdtGetEntryOffset (struct GDTEntry *entry, uint32_t ring)
 Determines the offset of a GDT entry. More...
 
void gdtEntrySetAddress (struct GDTEntry *entry, uint32_t address)
 Helper function to set the address inside a GDTEntry. More...
 
void gdtEntrySetLimit (struct GDTEntry *entry, uint64_t length)
 Helper function to set the length inside a GDTEntry. More...
 
void gdtReleaseEntry (struct GDTEntry *entry)
 Mark a GDTEntry as free. More...
 
uint32_t tssRunUsermodeThread (struct thread *t)
 Run a thread. More...
 
void __attribute__ ((cdecl))
 

Variables

void * kernelStack
 
void * intJmpTable_kernel
 
void * intJmpTable_user
 
struct GDTEntrycodeRing0
 
struct GDTEntrydataRing0
 
struct GDTEntrycodeRing3
 
struct GDTEntrydataRing3
 
struct GDTEntrykernelTask
 
struct GDTEntryusermodeTask
 
uint16_t limit
 
uint32_t address
 
uint16_t limit1
 
uint16_t address1
 
uint8_t address2
 
union {
   uint8_t   access
 
   struct {
      uint8_t   accessed: 1
 
      uint8_t   readWrite: 1
 
      uint8_t   dc: 1
 
      uint8_t   execute: 1
 
      uint8_t   isSystem: 1
 
      uint8_t   privlevel: 2
 
      uint8_t   present: 1
 
   }   accessBits
 
}; 
 
uint8_t limit2
 
uint8_t user
 
uint8_t reserved
 
uint8_t is32bit
 
uint8_t granularity
 
uint8_t address3
 
uint16_t addressLow
 
union {
   uint16_t   csSelector
 
   uint16_t   taskSelector
 
}; 
 
uint8_t zero
 
union {
   uint8_t   typeAttr
 
   struct {
      uint8_t   type: 4
 
      uint8_t   storageSegment: 1
 
      uint8_t   dpl: 2
 
      uint8_t   present: 1
 
   }   typeBits
 
}; 
 
uint16_t addressHigh
 

Macro Definition Documentation

◆ USERMODE_GDT_ADDRESS

#define USERMODE_GDT_ADDRESS   0xFF801000

Definition at line 94 of file gdt.h.

◆ USERMODE_IDT_ADDRESS

#define USERMODE_IDT_ADDRESS   0xFF811000

Definition at line 95 of file gdt.h.

◆ USERMODE_INTJMP_ADDRESS

#define USERMODE_INTJMP_ADDRESS   0xFF812000

Definition at line 96 of file gdt.h.

◆ USERMODE_INTJMP_ENABLE_FPU

#define USERMODE_INTJMP_ENABLE_FPU   (USERMODE_INTJMP_ADDRESS + 2048)

Definition at line 102 of file gdt.h.

◆ USERMODE_KERNELSTACK_ADDRESS

#define USERMODE_KERNELSTACK_ADDRESS   0xFF800000

Definition at line 93 of file gdt.h.

◆ USERMODE_KERNELSTACK_LIMIT

#define USERMODE_KERNELSTACK_LIMIT   (USERMODE_KERNELSTACK_ADDRESS + KERNELSTACK_SIZE)

Definition at line 99 of file gdt.h.

◆ USERMODE_TASK_ADDRESS

#define USERMODE_TASK_ADDRESS   0xFF813000

Definition at line 97 of file gdt.h.

Variable Documentation

◆ @11

union { ... }

◆ @13

union { ... }

◆ @3

union { ... }

◆ access

uint8_t access

Definition at line 121 of file gdt.h.

◆ accessBits

struct { ... } accessBits

◆ accessed

uint8_t accessed

Definition at line 123 of file gdt.h.

◆ address

uint32_t address

Definition at line 118 of file gdt.h.

◆ address1

uint16_t address1

Definition at line 118 of file gdt.h.

◆ address2

uint8_t address2

Definition at line 119 of file gdt.h.

◆ address3

uint8_t address3

Definition at line 137 of file gdt.h.

◆ addressHigh

uint16_t addressHigh

Definition at line 132 of file gdt.h.

◆ addressLow

uint16_t addressLow

Definition at line 117 of file gdt.h.

◆ csSelector

uint16_t csSelector

Definition at line 119 of file gdt.h.

◆ dc

uint8_t dc

Definition at line 125 of file gdt.h.

◆ dpl

uint8_t dpl

Definition at line 128 of file gdt.h.

◆ execute

uint8_t execute

Definition at line 126 of file gdt.h.

◆ granularity

uint8_t granularity

Definition at line 136 of file gdt.h.

◆ is32bit

uint8_t is32bit

Definition at line 135 of file gdt.h.

◆ isSystem

uint8_t isSystem

Definition at line 127 of file gdt.h.

◆ limit

uint16_t limit

Definition at line 117 of file gdt.h.

◆ limit1

uint16_t limit1

Definition at line 117 of file gdt.h.

◆ limit2

uint8_t limit2

Definition at line 132 of file gdt.h.

◆ present

uint8_t present

Definition at line 129 of file gdt.h.

◆ privlevel

uint8_t privlevel

Definition at line 128 of file gdt.h.

◆ readWrite

uint8_t readWrite

Definition at line 124 of file gdt.h.

◆ reserved

uint8_t reserved

Definition at line 134 of file gdt.h.

◆ storageSegment

uint8_t storageSegment

Definition at line 127 of file gdt.h.

◆ taskSelector

uint16_t taskSelector

Definition at line 120 of file gdt.h.

◆ type

uint8_t type

Definition at line 126 of file gdt.h.

◆ typeAttr

uint8_t typeAttr

Definition at line 124 of file gdt.h.

◆ typeBits

struct { ... } typeBits

◆ user

uint8_t user

Definition at line 133 of file gdt.h.

◆ zero

uint8_t zero

Definition at line 122 of file gdt.h.