int Permedia3MemorySizeDetect(ScrnInfoPtr pScrn) { GLINTPtr pGlint = GLINTPTR (pScrn); CARD32 size = 0, temp, temp1, temp2, i; /* We can map 64MB, as that's the size of the Permedia3 aperture * regardless of memory configuration */ pGlint->FbMapSize = 64*1024*1024; #ifndef XSERVER_LIBPCIACCESS /* Mark as VIDMEM_MMIO to avoid write-combining while detecting memory */ pGlint->FbBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO, pGlint->PciTag, pGlint->FbAddress, pGlint->FbMapSize); #else { void** result = (void**)&pGlint->FbBase; int err = pci_device_map_range(pGlint->PciInfo, pGlint->FbAddress, pGlint->FbMapSize, PCI_DEV_MAP_FLAG_WRITABLE, result); if (err) return FALSE; } #endif if (pGlint->FbBase == NULL) return 0; temp = GLINT_READ_REG(PM3MemBypassWriteMask); GLINT_SLOW_WRITE_REG(0xffffffff, PM3MemBypassWriteMask); /* The Permedia3 splits up memory, and even replicates it. Grrr. * So that each 32MB appears at offset 0, and offset 32, unless * there's really 64MB attached to the chip. * So, 16MB appears at offset 0, nothing between 16-32, then it re-appears * at offset 32. * This below is to detect the cases of memory combinations */ /* Test first 32MB */ for(i=0;i<32;i++) { /* write test pattern */ MMIO_OUT32(pGlint->FbBase, i*1024*1024, i*0x00345678); mem_barrier(); temp1 = MMIO_IN32(pGlint->FbBase, i*1024*1024); /* Let's check for wrapover, write will fail at 16MB boundary */ if (temp1 == (i*0x00345678)) size = i; else break; } /* Ok, we're satisfied we've got 32MB, let's test the second lot */ if ((size + 1) == i) { for(i=0;i<32;i++) { /* Clear first 32MB */ MMIO_OUT32(pGlint->FbBase, i*1024*1024, 0); } mem_barrier(); for(i=32;i<64;i++) { /* write test pattern */ MMIO_OUT32(pGlint->FbBase, i*1024*1024, i*0x00345678); mem_barrier(); temp1 = MMIO_IN32(pGlint->FbBase, i*1024*1024); temp2 = MMIO_IN32(pGlint->FbBase, (i-32)*1024*1024); /* Let's check for wrapover */ if ( (temp1 == (i*0x00345678)) && (temp2 == 0) ) size = i; else break; } } GLINT_SLOW_WRITE_REG(temp, PM3MemBypassWriteMask); #ifndef XSERVER_LIBPCIACCESS xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pGlint->FbBase, pGlint->FbMapSize); #else pci_device_unmap_range(pGlint->PciInfo, pGlint->FbBase, pGlint->FbMapSize); #endif pGlint->FbBase = NULL; pGlint->FbMapSize = 0; return ( (size+1) * 1024 ); }
int readDense32(pointer Base, register unsigned long Offset) { mem_barrier(); return *(volatile CARD32*)((unsigned long)Base+(Offset)); }
static int readSparse32(pointer Base, register unsigned long Offset) { mem_barrier(); return *(vuip)((unsigned long)Base+(Offset)); }