All pastes #794820 Raw Edit

Untitled

public text v1 · immutable
#794820 ·published 2007-11-23 13:10 UTC
rendered paste body
diff --git a/src/revenge_detect.c b/src/revenge_detect.c
index 5ed41da..7873689 100644
--- a/src/revenge_detect.c
+++ b/src/revenge_detect.c
@@ -153,6 +153,22 @@ detect_pcigart_aperture (void)
 }
 
 void
+detect_rs690gart_aperture (void)
+{
+  pcigart_addr = register_read_rs690 (RADEON_RS690GART_BASE_ADDR);
+  pcigart_start = (register_read_rs690 (RADEON_RS690GART_LOCATION) & 0xffff) << 16;
+  pcigart_end = (register_read_rs690 (RADEON_RS690GART_LOCATION) & 0xffff0000);
+  pcigart_len = pcigart_end - pcigart_start;
+
+  if (option_debug)
+    {
+      printf
+	("%s: pcigart_addr = 0x%08x pcigart_len = 0x%08x pcigart_start = 0x%08x pcigart_end = 0x%08x\n",
+	 __func__, pcigart_addr, pcigart_len, pcigart_start, pcigart_end);
+    }
+}
+
+void
 detect_igpgart_aperture (void)
 {
   unsigned int agp_addr;
diff --git a/src/revenge_detect.h b/src/revenge_detect.h
index b53fae2..b7ea81a 100644
--- a/src/revenge_detect.h
+++ b/src/revenge_detect.h
@@ -40,6 +40,7 @@ void detect_agp_aperture (void);
 void detect_fb_aperture (void);
 void detect_pcigart_aperture (void);
 void detect_igpgart_aperture (void);
+void detect_rs690gart_aperture (void);
 void detect_reg_aperture (void);
 void detect_max_texture_units (void);
 
diff --git a/src/revenge_main.c b/src/revenge_main.c
index b8d363a..ce4cf87 100644
--- a/src/revenge_main.c
+++ b/src/revenge_main.c
@@ -103,6 +103,7 @@ static struct option long_options[] = {
   {"output", required_argument, 0, 'o'},
   {"pci", no_argument, &option_interface, INTERFACE_PCI},
   {"pci-e", no_argument, &option_interface, INTERFACE_PCI_E},
+  {"rs690", no_argument, &option_interface, INTERFACE_RS690},
   {"verbose", no_argument, &option_verbose, 1},
   {0, 0, 0, 0},
 };
@@ -216,6 +217,17 @@ main (int argc, char **argv)
 	  exit (EXIT_FAILURE);
 	}
       break;
+    case INTERFACE_RS690:
+      detect_rs690gart_aperture ();
+      if ((pcigart_mem_map =
+	   mmap (NULL, pcigart_len, PROT_READ | PROT_WRITE, MAP_SHARED,
+		 mem_fd, pcigart_addr)) == MAP_FAILED)
+	{
+	  fprintf (stderr, "%s: %s\n", program_invocation_short_name,
+		   strerror (errno));
+	  exit (EXIT_FAILURE);
+	}
+      break;
     default:
       assert (0);
       break;
@@ -269,6 +281,7 @@ main (int argc, char **argv)
 	  exit (EXIT_FAILURE);
 	}
       break;
+    case INTERFACE_RS690:
     case INTERFACE_IGP:
     case INTERFACE_PCI:
     case INTERFACE_PCI_E:
diff --git a/src/revenge_main.h b/src/revenge_main.h
index a79c990..ef220c1 100644
--- a/src/revenge_main.h
+++ b/src/revenge_main.h
@@ -29,6 +29,7 @@ enum interface_t
   INTERFACE_IGP,
   INTERFACE_PCI,
   INTERFACE_PCI_E,
+  INTERFACE_RS690,
 };
 
 #define AVIVO_CRTC1_FB_LOCATION				0x6110
@@ -113,6 +114,16 @@ enum interface_t
 #define RADEON_IGPGART_ENABLE           0x38
 #define RADEON_IGPGART_UNK_39           0x39
 
+#define RADEON_RS690GART_INDEX	        0x78
+#	define RADEON_RS690GART_INDEX_MASK	0x1ff
+#	define RADEON_RS690GART_INDEX_WRITEBIT	(1 << 9)
+#	define RADEON_RS690GART_INDEX_WRITEACK	0x7f 	 /* write ack value */
+#define RADEON_RS690GART_DATA		0x7c
+
+#define RADEON_RS690GART_BASE_ADDR      0x2c
+#define RADEON_RS690GART_LOCATION	0x101
+
 #define R300_TX_SIZE_0                      0x4480
 #       define R300_TX_WIDTHMASK_SHIFT           0
 #       define R300_TX_WIDTHMASK_MASK            0x7ff
diff --git a/src/revenge_memory.c b/src/revenge_memory.c
index fd28e04..9bcd3c1 100644
--- a/src/revenge_memory.c
+++ b/src/revenge_memory.c
@@ -61,6 +61,7 @@ memory_gart_to_phys (unsigned int addr)
 
   switch (option_interface)
     {
+    case INTERFACE_RS690:
     case INTERFACE_IGP:
       phys_addr = pcigart_mem_map[num] & ~0xc;
       break;
@@ -162,6 +163,7 @@ memory_read (unsigned int addr, unsigned int size)
     case INTERFACE_AGP:
       mem_map = memory_read_agp (addr, size);
       break;
+    case INTERFACE_RS690:
     case INTERFACE_IGP:
     case INTERFACE_PCI:
     case INTERFACE_PCI_E:
diff --git a/src/revenge_register.c b/src/revenge_register.c
index 05d1b58..00483c2 100644
--- a/src/revenge_register.c
+++ b/src/revenge_register.c
@@ -65,3 +65,19 @@ register_write_igp (unsigned int key, unsigned int val)
   register_write (RADEON_IGPGART_DATA, val);
   register_write (RADEON_IGPGART_INDEX, 0x7f);
 }
+
+unsigned int
+register_read_rs690 (unsigned int key)
+{
+  register_write (RADEON_RS690GART_INDEX, key & RADEON_RS690GART_INDEX_MASK);
+  return register_read (RADEON_RS690GART_DATA);
+}
+
+
+void
+register_write_rs690 (unsigned int key, unsigned int val)
+{
+    register_write (RADEON_RS690GART_INDEX, (key & RADEON_RS690GART_INDEX_MASK) | RADEON_RS690GART_INDEX_WRITEBIT);
+    register_write (RADEON_RS690GART_DATA, val);
+    register_write (RADEON_RS690GART_INDEX, RADEON_RS690GART_INDEX_WRITEACK);
+}
diff --git a/src/revenge_register.h b/src/revenge_register.h
index 59e624e..77975e3 100644
--- a/src/revenge_register.h
+++ b/src/revenge_register.h
@@ -29,5 +29,7 @@ unsigned int register_read_pcie (unsigned int key);
 void register_write_pcie (unsigned int key, unsigned int val);
 unsigned int register_read_igp (unsigned int key);
 void register_write_igp (unsigned int key, unsigned int val);
+unsigned int register_read_rs690 (unsigned int key);
+void register_write_rs690 (unsigned int key, unsigned int val);
 
 #endif