/*
    MMHal.h, Copyright  (c) by Lukas Ruf, lr@lpr.ch,
    Swiss Federal Institute of Technology,
    Computer Engineering and Networks Laboratory.
 
    TOPSY -- A Teachable Operating System.
             Implementation of a tiny and simple
             micro kernel for teaching purposes.
 
    For further information, please visit http://www.tik.ee.ethz.ch/~topsy
 
    This software is provided under the terms of the GNU General Public Licence.
 
    A full copy of the GNU GPL is provided in the file COPYING found in the 
    development root of Topsy.
*/
/*
	
	File:                  $Source: /home/ruf/cvs_Topsy/cvs/Topsy/Memory/ia32/MMHal.h,v $
 	Author(s):             Lukas Ruf, lr@lpr.ch
 	Affiliation:           ETH Zuerich, TIK
 	Version:               $Revision: 2922 $
 	Creation Date:         
 	Last Date of Change:   $Date: 2007-03-19 17:48:52 +0100 (Mon, 19 Mär 2007) $      by: $Author: baderma $
*/
#ifndef __MMHAL_H__
#define __MMHAL_H__

typedef struct GDTE_t
{
  unsigned char   Byte0;
  unsigned char   Byte1;
  unsigned char   Byte2;
  unsigned char   Byte3;
  unsigned char   Byte4;
  unsigned char   Byte5;
  unsigned char   Byte6;
  unsigned char   Byte7;
}
GDTE;
typedef GDTE* GDTEPtr;

typedef struct GDTR_t
{
  unsigned short  limit;
  unsigned long   base;
}
GDTR;
typedef GDTR* GDTRPtr;

typedef struct IDTR_t
{
  unsigned short  limit;
  unsigned long   base;
}
IDTR;
typedef IDTR* IDTRPtr;

typedef struct IDTE_t
{
  unsigned char   Byte0;
  unsigned char   Byte1;
  unsigned char   Byte2;
  unsigned char   Byte3;
  unsigned char   Byte4;
  unsigned char   Byte5;
  unsigned char   Byte6;
  unsigned char   Byte7;
}
IDTE;
typedef IDTE* IDTEPtr;


void GDTInit();
void DispGDTRState();
void Set_GDTEntry(unsigned short pSelector, unsigned long pBase, unsigned long pSize, unsigned char pAccess, unsigned char pType);
void Get_GDTE(unsigned short pSelector, GDTEPtr pGDTE);
unsigned short Get_New_GDTE();

void    IDTInit();
void    Set_Def_IDTEntry(unsigned char pEntry, unsigned long pOffs,
                         unsigned short pType);
void    DispIDTRState();
void    ResetIDR();

void  TSSInit();

unsigned long MaxPhysMem();
unsigned long MaxMemAvail();
void MemoryInit();

#endif

