svga.c

00001 /***************************************************************************
00002                           svga.c  -  description
00003                              -------------------
00004     begin                : Sat Feb 7 2004
00005     copyright            : (C) 2004 by Dynacube Team
00006     email                : 
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018  #include "gui/svga.h"
00019 
00020 
00021  DB vgabios_buffer[0x8000]; //32Kb
00022  DB svga_stack[1024];
00023  DB BIOSData[0x600];
00024 
00025  struct
00026  {
00027    DD addr;
00028    DD entry_off;
00029    DD init_off;
00030    
00031    DD bk_ss, bk_esp, bk_ds;
00032  }pm_info;
00033 
00034  void svga_init()
00035  {
00036   DB *pm = (DB *)(vgabios_buffer + pm_info.addr);
00037   memcpy(vgabios_buffer,0xC0000,0x8000);
00038 
00039   //Bios Data Sel
00040   *(pm + 8) = BIOS_DATA_SEL*8;
00041   *(pm + 9) = 0;
00042 
00043   //A000 Data Sel
00044   *(pm + 10) = A000_SEL * 8;
00045   *(pm + 11) = 0;
00046 
00047   //B000 Data Sel
00048   *(pm + 12) = B000_SEL * 8;
00049   *(pm + 13) = 0;
00050 
00051   //B800 Data Sel
00052   *(pm + 14) = B800_SEL * 8;
00053   *(pm + 15) = 0;
00054 
00055   //SVGA Data Sel
00056   *(pm + 16) = SVGA_DATA_16_SEL * 8;
00057   *(pm + 17) = 0;
00058 
00059   //In Protect Mode
00060   *(pm + 18) = 1;
00061     
00062   asm("movl %%ss,%%eax":"=a"(pm_info.bk_ss));
00063   asm("movl %%ds,%%eax":"=a"(pm_info.bk_ds));
00064   asm("movl %%esp,%%eax":"=a"(pm_info.bk_esp));
00065     
00066   lds(SVGA_DATA_16_SEL * 8);
00067   lss(SVGA_STACK_16_SEL * 8);
00068   asm("movl %%eax, %%esp"::"a"(0x0));
00069 
00070   asm("lcall %0, $0x0"::"i"(SVGA_CODE_16_SEL * 8));
00071  }
00072 
00073  
00074  void PMID_detect()
00075  {
00076    DD temp, temp1 ,temp2, i;
00077    
00078    for( temp2=0,temp1 = 0,temp = 0xA0000 ; temp < 0xFFFFF ; temp++)
00079    {
00080     if(*(DB *)(temp) == 'P' && *(DB *)(temp+1) == 'M' && *(DB *)(temp+2) == 'I' && *(DB *)(temp+3) == 'D')
00081     {
00082       temp1++;
00083       cls();
00084       printf("\nPMID Addr: %x",temp);
00085       
00086       pm_info.addr      = temp;
00087       pm_info.entry_off = *(DW *)(temp+4);
00088       pm_info.init_off =  *(DW *)(temp+6);
00089 
00090       printf("\naddr %x entry %x init %x",pm_info.addr,pm_info.entry_off,pm_info.init_off);
00091       delay(0xFFFFFFFF);
00092       
00093       for(i = 0 ; i < 20 ; i++)
00094       {
00095         printf("\ni: %d %x",i,*(DB *)(temp+i));
00096         delay(0xFFFFFFFF);
00097       }
00098 
00099       break;  
00100     }
00101     else if(*(DB *)(temp) == '_' && *(DB *)(temp+1) == '3' && *(DB *)(temp+2) == '2' && *(DB *)(temp+3) == '_')
00102     {
00103       temp2++;
00104       cls();
00105       printf("\n_32_ Addr: %x",temp);
00106       for(i = 0 ; i < 16 ; i++)
00107       {
00108         printf("\ni: %d %x",i,*(DB *)(temp+i));
00109         delay(0xFFFFFFFF);
00110       }
00111     }
00112     else
00113      printf("\n temp:%x %x",temp,*(DB *)temp);
00114    }
00115    printf("\nOut of PMID detect %d %d",temp1,temp2);
00116    
00117   }

Generated on Thu Jul 27 23:52:27 2006 for Dynacube by  doxygen 1.4.7