Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1.  
  2.  
  3. static Bool
  4. rhdMapMMIO(RHDPtr rhdPtr)
  5. {
  6.   rhdPtr->MMIOMapSize = 1 << rhdPtr->memsize[RHD_MMIO_BAR];
  7.   rhdPtr->MMIOBase = MapIoMem(rhdPtr->memBase[RHD_MMIO_BAR],
  8.                           rhdPtr->MMIOMapSize,PG_SW+PG_NOCACHE);
  9.   if( rhdPtr->MMIOBase==0)
  10.     return 0;
  11.  
  12.   DBG(dbgprintf("Mapped IO at %x (size %x)\n", rhdPtr->MMIOBase, rhdPtr->MMIOMapSize));
  13.   return 1;
  14. }
  15.  
  16. #define RADEON_NB_TOM             0x15c
  17.  
  18. static CARD32
  19. rhdGetVideoRamSize(RHDPtr rhdPtr)
  20. {
  21.   CARD32 RamSize, BARSize;
  22.  
  23.   if (rhdPtr->ChipSet == RHD_RS690)
  24.     RamSize = (_RHDRegRead(rhdPtr, R5XX_CONFIG_MEMSIZE))>>10;
  25.   else
  26.     if (rhdPtr->IsIGP)
  27.     {
  28.       CARD32 tom = _RHDRegRead(rhdPtr, RADEON_NB_TOM);
  29.       RamSize = (((tom >> 16) - (tom & 0xffff) + 1) << 6);
  30.       _RHDRegWrite(rhdPtr,R5XX_CONFIG_MEMSIZE, RamSize<<10);
  31.     }
  32.     else
  33.     {
  34.       if (rhdPtr->ChipSet < RHD_R600)
  35.       {
  36.         RamSize = (_RHDRegRead(rhdPtr, R5XX_CONFIG_MEMSIZE)) >> 10;
  37.         if(RamSize==0) RamSize=8192;
  38.       }
  39.       else
  40.         RamSize = (_RHDRegRead(rhdPtr, R6XX_CONFIG_MEMSIZE)) >> 10;
  41.     };
  42.  
  43.   BARSize = 1 << (rhdPtr->memsize[RHD_FB_BAR] - 10);
  44.   if(BARSize==0)
  45.     BARSize = 0x20000;
  46.  
  47.   if (RamSize > BARSize) {
  48.     DBG(dbgprintf("The detected amount of videoram"
  49.            " exceeds the PCI BAR aperture.\n"));
  50.     DBG(dbgprintf("Using only %dkB of the total "
  51.            "%dkB.\n", (int) BARSize, (int) RamSize));
  52.     return BARSize;
  53.   }
  54.   else return RamSize;
  55. }
  56.  
  57. static Bool
  58. rhdMapFB(RHDPtr rhdPtr)
  59. {
  60.   rhdPtr->FbMapSize = 1 << rhdPtr->memsize[RHD_FB_BAR];
  61.   rhdPtr->PhisBase = rhdPtr->memBase[RHD_FB_BAR];
  62.  
  63.   rhdPtr->FbBase = MapIoMem(rhdPtr->PhisBase, rhdPtr->FbMapSize,PG_SW+PG_NOCACHE);
  64.  
  65.   if (!rhdPtr->FbBase)
  66.     return FALSE;
  67.  
  68.     /* These devices have an internal address reference, which some other
  69.      * address registers in there also use. This can be different from the
  70.      * address in the BAR */
  71.   if (rhdPtr->ChipSet < RHD_R600)
  72.     rhdPtr->FbIntAddress = _RHDRegRead(rhdPtr, HDP_FB_LOCATION)<< 16;
  73.   else
  74.     rhdPtr->FbIntAddress = _RHDRegRead(rhdPtr, R6XX_CONFIG_FB_BASE);
  75.  
  76. //    rhdPtr->FbIntAddress = _RHDRegRead(rhdPtr, 0x6110);
  77. //    dbgprintf("rhdPtr->FbIntAddress %x\n",rhdPtr->FbIntAddress);
  78.  
  79.   if (rhdPtr->FbIntAddress != rhdPtr->PhisBase)
  80.     dbgprintf("PCI FB Address (BAR) is at "
  81.               "0x%08X while card Internal Address is 0x%08X\n",
  82.               (unsigned int) rhdPtr->PhisBase,rhdPtr->FbIntAddress);
  83.   dbgprintf("Mapped FB at %p (size 0x%08X)\n",rhdPtr->FbBase, rhdPtr->FbMapSize);
  84.   return TRUE;
  85. }
  86.  
  87. Bool RHDPreInit()
  88. {
  89.     /* We need access to IO space already */
  90.   if (!rhdMapMMIO(&rhd)) {
  91.     dbgprintf("Failed to map MMIO.\n");
  92.     return FALSE;
  93.   };
  94.  
  95.   rhd.videoRam = rhdGetVideoRamSize(&rhd);
  96.   if (!rhd.videoRam)
  97.   {
  98.     dbgprintf("No Video RAM detected.\n");
  99.     goto error1;
  100.         }
  101.   dbgprintf("VideoRAM: %d kByte\n",rhd.videoRam);
  102.  
  103.   rhd.FbFreeStart = 0;
  104.   rhd.FbFreeSize = rhd.videoRam << 10;
  105.  
  106.   if( !rhdMapFB(&rhd))
  107.     return FALSE;
  108.  
  109.   rhd.FbScanoutStart = 0;
  110.   rhd.FbScanoutSize  = 8*1024*1024;
  111.   rhd.FbFreeStart    = 8*1024*1024;
  112.   rhd.FbFreeSize     = rhd.FbMapSize - 8*1024*1024;
  113.  
  114.   rhdInitHeap(&rhd);
  115.   return TRUE;
  116.  
  117. error1:
  118.   return FALSE;
  119. };
  120.  
  121. int KernelFree(void *p)
  122. {
  123.  
  124.   return 0;
  125. }
  126.  
  127.