/*
 * debug.c
 *
 * Written by Vicente Esteve LLoret <viesllo@inf.upv.es>
 * Copyright (C) Feb, 2003 OCERA Consortium.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation version 2.
 *
 * Some Visualization Functions.
 */

#include <deblin/vhal.h>
#include <arch/mprot.h>
#include <rtl_conf.h>
#include "video.c"

unsigned long idt_[2];

unsigned long auxx;
static char cadena[]="              ";

unsigned long getbaseidt(void)  /* Obtiene la direccion linea de la IDT */
{
/*  __asm("sidt idt_");
     
  idt_[0]=(idt_[0]>>16);
  idt_[1]=(idt_[1]<<16);
  idt_[0]=(idt_[0]|idt_[1]);*/
       
  return idt_[0];
};
                      /* Visualiza información sobre una entrada en
                         la IDT */
void hexatoascii(unsigned long valor,char *ptr)
{    
  unsigned long hex;
#if CONFIG_KERNEL_MEMORYPROT   
  mprot_t mprot;
#endif 
  int despl=28;
  int mascara=0xF0000000;

  STARTKERNELCODE(mprot);
  
  while (despl>=0) 
  {
    hex=(valor & mascara)>>despl;
    if (hex<0xa) 
    {
      *ptr='0'+(char) hex;
      ptr++;
    }
    else
    {
      *ptr='A'+((char) hex-0xa);
      ptr++;
    };          
    
    despl=despl-4;
    mascara=(mascara>>4) & 0x0fffffff;
  };
  ENDKERNELCODE(mprot);
};

void DebugValue(unsigned long valor)
{
   
  hexatoascii(valor,&cadena[0]);
  PutString(1,40,&cadena[0],0x12);
};
 

void analizaentrada(unsigned char entrada) 
{
};

void bytetoascii(unsigned char unbyte,char *ptr)
{
  unsigned char temp;
  temp=(unbyte & 0xf0)>>4;
  if (temp<0xa)
  {
    *ptr='0'+temp;
    ptr++;
  }
  else
  {
    *ptr='A'+(temp-0xa);
    ptr++; 
  }; 

  temp=(unbyte & 0xf);

  if (temp<0xa)
  {
    *ptr='0'+temp;
    ptr++;
  }
  else
  {
    *ptr='A'+(temp-0xa);
    ptr++; 
  }; 

};


void analizairqsentry(void)
{
};

void DisplayStartupAddress(void)
{
};
