-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimio_r4s5_patch.diff
81 lines (78 loc) · 2.24 KB
/
simio_r4s5_patch.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
diff --git tb/base/semicpu/SemiCPU.cpp tb/base/semicpu/SemiCPU.cpp
old mode 100644
new mode 100755
index 71fc1f5e..5c8258c5
--- tb/base/semicpu/SemiCPU.cpp
+++ tb/base/semicpu/SemiCPU.cpp
@@ -22,7 +22,9 @@ extern "C" void semiCPULeaveCriticalSection(void);
typedef int (*main_func) (int argc, const char *argv[]);
typedef void (*irq_func) (int hartid);
+typedef int (*conn_func) (int);
static char custom_APPPath[4096];
+#ifndef SIMIO
static main_func custom_Main = NULL;
static irq_func custom_IRQHandler= NULL;
@@ -68,3 +70,64 @@ void semiCPURunIRQ ( int intID ){
if(custom_IRQHandler){ custom_IRQHandler(intID); }
}
+#else
+static main_func custom_Main = NULL;
+static irq_func custom_IRQHandler= NULL;
+static conn_func custom_ConnQEMU = NULL;
+
+#define CONN_NONBLOCK (0x1)
+#define CONN_THREADED (0x2)
+
+void semiCPURegisterLocalmemory( unsigned long int address, unsigned int bytes ){
+
+}
+void semiCPULoadHex( const char* hexFileName, unsigned long int entry_point ){
+ strcpy( custom_APPPath, hexFileName );
+ void *plugin = dlopen(hexFileName, RTLD_NOW);
+ if (!plugin)
+ {
+ printf("Cannot load %s: %s", hexFileName, dlerror ());
+ return;
+ }
+ const char* result;
+ custom_Main = (main_func)dlsym (plugin, "main_SimIO");
+ result = dlerror();
+ if (result)
+ {
+ printf("Cannot find query in %s: %s", hexFileName, result);
+ return;
+ }
+
+ custom_IRQHandler = (irq_func)dlsym (plugin, "SimIORaiseIRQ");
+ result = dlerror();
+ if (result)
+ {
+ printf("Cannot find query in %s: %s", hexFileName, result);
+ return;
+ }
+
+ custom_ConnQEMU = (conn_func)dlsym (plugin, "SimIOConnService");
+ result = dlerror();
+ if (result)
+ {
+ printf("Cannot find query in %s: %s", hexFileName, result);
+ return;
+ }
+
+ custom_ConnQEMU(CONN_NONBLOCK);
+}
+
+void semiCPURunHex ( unsigned long int entry_point, int hartid ){
+ if(custom_Main){
+ int argc = 2;
+ const char* UnityFixture_Silent = "-s";
+ const char* argv[2] = { custom_APPPath, UnityFixture_Silent };
+ custom_Main(argc,argv);
+ }
+}
+
+void semiCPURunIRQ ( int intID ){
+ if(custom_IRQHandler){ custom_IRQHandler(intID); }
+}
+#endif
+