summaryrefslogtreecommitdiff
path: root/util/m5/m5.c
diff options
context:
space:
mode:
authorAndreas Sandberg <andreas@sandberg.pp.se>2013-09-30 12:20:53 +0200
committerAndreas Sandberg <andreas@sandberg.pp.se>2013-09-30 12:20:53 +0200
commitfec2dea5c35d830ab4f4dc5295e6dba0e152f18e (patch)
treed3304bcc3a5d3d7684df0107982077714200535f /util/m5/m5.c
parentd9856f33a455b9c86b90f5857df866fba3aa5bfb (diff)
downloadgem5-fec2dea5c35d830ab4f4dc5295e6dba0e152f18e.tar.xz
x86: Add support for m5ops through a memory mapped interface
In order to support m5ops in virtualized environments, we need to use a memory mapped interface. This changeset adds support for that by reserving 0xFFFF0000-0xFFFFFFFF and mapping those to the generic IPR interface for m5ops. The mapping is done in the X86ISA::TLB::finalizePhysical() which means that it just works for all of the CPU models, including virtualized ones.
Diffstat (limited to 'util/m5/m5.c')
-rw-r--r--util/m5/m5.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/util/m5/m5.c b/util/m5/m5.c
index 021816ce3..1ddaaf66d 100644
--- a/util/m5/m5.c
+++ b/util/m5/m5.c
@@ -51,10 +51,15 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
#include "m5op.h"
+void *m5_mem = NULL;
+
char *progname;
char *command = "unspecified";
void usage();
@@ -315,6 +320,26 @@ usage()
exit(1);
}
+static void
+map_m5_mem()
+{
+#ifdef M5OP_ADDR
+ int fd;
+
+ fd = open("/dev/mem", O_RDWR | O_SYNC);
+ if (fd == -1) {
+ perror("Can't open /dev/mem");
+ exit(1);
+ }
+
+ m5_mem = mmap(NULL, 0x10000, PROT_READ | PROT_WRITE, MAP_SHARED, fd, M5OP_ADDR);
+ if (!m5_mem) {
+ perror("Can't mmap /dev/mem");
+ exit(1);
+ }
+#endif
+}
+
int
main(int argc, char *argv[])
{
@@ -322,6 +347,8 @@ main(int argc, char *argv[])
if (argc < 2)
usage(1);
+ map_m5_mem();
+
command = argv[1];
argv += 2;