text: #ifndef _GDT_H_INCLUDED
  # define _GDT_H_INCLUDED
  //****************************************************************************
  //**
  //**    gdt.h
  //**
  //**	global descriptor table (gdt) for i86 processors. This handles
  //**	the basic memory map for the system and permission levels
  //**
  //**	The system software should have a gdt set up prior to this being
  //**	used. This sets up a basic gdt interface that can be managed through
  //**	the HAL
  //**
  //****************************************************************************
  
  #ifndef ARCH_X86
  #error "[gdt.h] platform not implimented. Define ARCH_X86 for HAL"
  #endif
  
  //============================================================================
  //    INTERFACE REQUIRED HEADERS
  //============================================================================
  
  #include <stdint.h>
  
  //============================================================================
  //    INTERFACE DEFINITIONS / ENUMERATIONS / SIMPLE TYPEDEFS
  //============================================================================
  
  //! maximum amount of descriptors allowed
  #define MAX_DESCRIPTORS					3
  
  /***	 gdt descriptor access bit flags.	***/
  
  //! set access bit
  #define I86_GDT_DESC_ACCESS			0x0001			//00000001
  
  //! descriptor is readable and writable. default: read only
  #define I86_GDT_DESC_READWRITE			0x0002			//00000010
  
  //! set expansion direction bit
  #define I86_GDT_DESC_EXPANSION			0x0004			//00000100
  
  //! executable code segment. Default: data segment
  #define I86_GDT_DESC_EXEC_CODE			0x0008			//00001000
  
  //! set code or data descriptor. defult: system defined descriptor
  #define I86_GDT_DESC_CODEDATA			0x0010			//00010000
  
  //! set dpl bits
  #define I86_GDT_DESC_DPL			0x0060			//01100000
  
  //! set "in memory" bit
  #define I86_GDT_DESC_MEMORY			0x0080			//10000000
  
  /**	gdt descriptor grandularity bit flags	***/
  
  //! masks out limitHi (High 4 bits of limit)
  #define I86_GDT_GRAND_LIMITHI_MASK		0x0f			//00001111
  
  //! set os defined bit
  #define I86_GDT_GRAND_OS			0x10			//00010000
  
  //! set if 32bit. default: 16 bit
  #define I86_GDT_GRAND_32BIT			0x40			//01000000
  
  //! 4k grandularity. default: none
  #define I86_GDT_GRAND_4K			0x80			//10000000
  
  //============================================================================
  //    INTERFACE CLASS PROTOTYPES / EXTERNAL CLASS REFERENCES
  //============================================================================
  //============================================================================
  //    INTERFACE STRUCTURES / UTILITY CLASSES
  //============================================================================
  
  #ifdef _MSC_VER
  #pragma pack (push, 1)
  #endif
  
  //! gdt descriptor. A gdt descriptor defines the properties of a specific
  //! memory block and permissions.
  
  struct gdt_descriptor {
  
  	//! bits 0-15 of segment limit
  	uint16_t		limit;
  
  	//! bits 0-23 of base address
  	uint16_t		baseLo;
  	uint8_t			baseMid;
  
  	//! descriptor access flags
  	uint8_t			flags;
  
  	uint8_t			grand;
  
  	//! bits 24-32 of base address
  	uint8_t			baseHi;
  };
  
  #ifdef _MSC_VER
  #pragma pack (pop)
  #endif
  
  //============================================================================
  //    INTERFACE DATA DECLARATIONS
  //============================================================================
  //============================================================================
  //    INTERFACE FUNCTION PROTOTYPES
  //============================================================================
  
  //! Setup a descriptor in the Global Descriptor Table
  extern void gdt_set_descriptor(uint32_t i, uint64_t base, uint64_t limit, uint8_t access, uint8_t grand);
  
  //! returns descritor
  extern gdt_descriptor* i86_gdt_get_descriptor (int i);
  
  //! initializes gdt
  extern	int i86_gdt_initialize ();
  
  //============================================================================
  //    INTERFACE OBJECT CLASS DEFINITIONS
  //============================================================================
  //============================================================================
  //    INTERFACE TRAILING HEADERS
  //============================================================================
  //****************************************************************************
  //**
  //**    END [FILE NAME]
  //**
  //****************************************************************************
  #endif
  