dol: initial epiphany code generator (untested)
[jump.git] / dol / src / dol / visitor / epiphany / template / process_Wrapper.c
diff --git a/dol/src/dol/visitor/epiphany/template/process_Wrapper.c b/dol/src/dol/visitor/epiphany/template/process_Wrapper.c
new file mode 100644 (file)
index 0000000..def5887
--- /dev/null
@@ -0,0 +1,65 @@
+/* @@PROCESSNAME@@_Wrapper
+ * ===================================================================== */
+#include <e_lib.h>
+#include <string.h>
+#include "../esrc/@@PROCESSNAME@@.h"
+#include "../shared.h"
+#include "ports.h"
+#include "index.h"
+
+shm_t shm SECTION(".shared_dram");
+
+/* DOL structures
+ * ===================================================================== */
+struct _DOL_wptr @@PROCESSNAME@@_wptr = {
+       1,              /* active   */
+       {0,0,0,0}       /* instance */
+};
+
+@@PROCESSNAME@@_State @@PROCESSNAME@@_local;
+DOLProcess @@PROCESSNAME@@_process = {
+       &@@PROCESSNAME@@_local,
+       &@@PROCESSNAME@@_init,
+       &@@PROCESSNAME@@_fire,
+       &@@PROCESSNAME@@_wptr,
+};
+
+/* Port Read/Write Functions
+ * ===================================================================== */
+@@PORTFUNCTIONS@@
+
+/* Port Mapping
+ * ===================================================================== */
+#define NUM_PORTS @@NUM_PORTS@@
+port_t ports[NUM_PORTS] = {
+@@PORTMAPPING@@
+};
+
+port_t *get_port(void *port)
+{
+       for(int i = 0; i < NUM_PORTS; i++) {
+               if(!strncmp(ports[i].name, port, PORTNAME_MAXLEN)) {
+                       /* found the port */
+                       return(&ports[i]);
+               }
+       }
+       return(NULL);
+}
+
+/* eCore entry point
+ * ===================================================================== */
+int main(void)
+{
+       int index = core_id2lin(e_get_coreid());
+       int state = 0;
+
+       @@PROCESSNAME@@_process.init((struct _DOLProcess_struct*)&@@PROCESSNAME@@_process);
+       while(@@PROCESSNAME@@_process.wptr->active) {
+               shm.states[index] = ++state;
+               @@PROCESSNAME@@_process.fire((struct _DOLProcess_struct*)&@@PROCESSNAME@@_process);
+       }
+
+       shm.states[index] = -1;
+       while(1);
+}
+