summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhenyu Wang <zhenyu.z.wang@intel.com>2008-10-16 10:28:16 +0800
committerZhenyu Wang <zhenyu.z.wang@intel.com>2008-10-16 10:28:16 +0800
commit2419bce9efbff63529074e64af5ec5c2e62e368b (patch)
treeb94d2671e99e1aa75567efc6fa908bfe902b94fd
parent986c8df79e83c369655ad786a6bf6342b53c535d (diff)
Make GTT dumper work on other 9XX chips
-rw-r--r--src/reg_dumper/gtt.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/reg_dumper/gtt.c b/src/reg_dumper/gtt.c
index cf9e37a6..eca4bc65 100644
--- a/src/reg_dumper/gtt.c
+++ b/src/reg_dumper/gtt.c
@@ -36,22 +36,42 @@
#include "reg_dumper.h"
#include "../i810_reg.h"
-#define INGTT(offset) INREG(gtt_base + (offset) / (KB(4) / 4))
+#define INGTT(offset) (*(volatile uint32_t *)(gtt + (offset) / (KB(4) / 4)))
int main(int argc, char **argv)
{
I830Rec i830;
I830Ptr pI830 = &i830;
- int gtt_base, start, aper_size;
+ int start, aper_size;
+ unsigned char *gtt;
+
intel_i830rec_init(pI830);
+ if (!IS_I9XX(pI830)) {
+ printf("Unsupported chipset for gtt dumper\n");
+ exit(1);
+ }
+
if (IS_G4X(pI830) || IS_GM45(pI830))
- gtt_base = MB(2);
+ gtt = (unsigned char *)(pI830->mmio + MB(2));
+ else if (IS_I965G(pI830))
+ gtt = (unsigned char *)(pI830->mmio + KB(512));
else {
- printf("Unsupported chipset for gtt dumper\n");
+ /* 915/945 chips has GTT range in bar 3*/
+ int err = 0;
+ err = pci_device_map_range (pI830->pci_dev,
+ pI830->pci_dev->regions[3].base_addr,
+ pI830->pci_dev->regions[3].size,
+ PCI_DEV_MAP_FLAG_WRITABLE,
+ (void **)&gtt);
+ if (err != 0) {
+ fprintf(stderr, "mapping GTT bar failed\n");
+ exit(1);
+ }
}
- aper_size = MB(256);
+ aper_size = pI830->pci_dev->regions[2].size;
+
for (start = 0; start < aper_size; start += KB(4)) {
uint32_t start_pte = INGTT(start);
uint32_t end;