@@ -25,12 +25,17 @@
*
*/
+#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <errno.h>
#include <err.h>
#include <assert.h>
#include <sys/ioctl.h>
+#include <sys/fcntl.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
#include "intel_gpu_tools.h"
#include "i915_drm.h"
#include "intel_batchbuffer.h"
@@ -83,6 +88,28 @@ intel_get_pci_device(void)
}
void
+intel_map_file(char *file)
+{
+ int fd;
+ struct stat st;
+
+ fd = open(file, O_RDWR);
+ if (fd == -1) {
+ fprintf(stderr, "Couldn't open %s: %s\n", file,
+ strerror(errno));
+ exit(1);
+ }
+ fstat(fd, &st);
+ mmio = mmap(NULL, st.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
+ if (mmio == MAP_FAILED) {
+ fprintf(stderr, "Couldn't mmap %s: %s\n", file,
+ strerror(errno));
+ exit(1);
+ }
+ close(fd);
+}
+
+void
intel_get_mmio(void)
{
int mmio_bar;
@@ -56,3 +56,4 @@ void intel_get_drm_devid(int fd);
void intel_copy_bo(struct intel_batchbuffer *batch,
drm_intel_bo *dst_bo, drm_intel_bo *src_bo,
int width, int height);
+void intel_map_file(char *);
@@ -1658,9 +1658,12 @@ intel_dump_regs(void)
int main(int argc, char** argv)
{
- intel_get_mmio();
+ if (argc == 2)
+ intel_map_file(argv[1]);
+ else
+ intel_get_mmio();
- if (HAS_PCH_SPLIT(devid))
+ if (HAS_PCH_SPLIT(devid) || getenv("HAS_PCH_SPLIT"))
ironlake_dump_regs();
else
intel_dump_regs();