summaryrefslogtreecommitdiffstats
path: root/simulator/HAL.cpp
diff options
context:
space:
mode:
authorEvan Lojewski <github@meklort.com>2019-02-15 17:51:36 -0700
committerEvan Lojewski <github@meklort.com>2019-02-15 17:51:36 -0700
commit9c494f21a7e9abad1526dcd845dbdd2aebb5dd7a (patch)
tree18e32785a3150a36b6eb3a7b222e3089ecdb277f /simulator/HAL.cpp
parent5318e6a8a1a38f6b70b2bd767cdf449a65456b3e (diff)
downloadbcm5719-ortega-9c494f21a7e9abad1526dcd845dbdd2aebb5dd7a.tar.gz
bcm5719-ortega-9c494f21a7e9abad1526dcd845dbdd2aebb5dd7a.zip
Ensure we don't accidentaly mmap pci registers under valgrind. It causes the device to lock up.
Diffstat (limited to 'simulator/HAL.cpp')
-rw-r--r--simulator/HAL.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/simulator/HAL.cpp b/simulator/HAL.cpp
index a77d798..5a91f56 100644
--- a/simulator/HAL.cpp
+++ b/simulator/HAL.cpp
@@ -18,6 +18,13 @@
#include <unistd.h>
#include <string>
+#include <iostream>
+
+#if __has_include("valgrind/valgrind.h")
+#include <valgrind/valgrind.h>
+#else
+#define RUNNING_ON_VALGRIND 0
+#endif
using namespace std;
@@ -80,6 +87,12 @@ void initHAL(const char *pci_path)
struct stat st;
int memfd;
+ if(RUNNING_ON_VALGRIND)
+ {
+ cerr << "Running on valgrind is not supported when mmaping device registers." << endl;
+ exit(-1);
+ }
+
string configPath = string(pci_path) + string("/") + string(DEVICE_CONFIG);
const char* pConfigPath = configPath.c_str();
OpenPOWER on IntegriCloud