X-Git-Url: http://sraa.de/git/?a=blobdiff_plain;f=dol%2Fsrc%2Fdol%2Fvisitor%2Frtems%2Flib%2Fprocess_wrapper_template.c;fp=dol%2Fsrc%2Fdol%2Fvisitor%2Frtems%2Flib%2Fprocess_wrapper_template.c;h=15c262b5293497bf2adcd1cbd4aeb7bbd547999f;hb=8c411cf24ed0eb889191aaeafd8fa1e69081df42;hp=0000000000000000000000000000000000000000;hpb=dea7a4fb1ed110d3ce6e6d9255103d724bd66c0e;p=jump.git diff --git a/dol/src/dol/visitor/rtems/lib/process_wrapper_template.c b/dol/src/dol/visitor/rtems/lib/process_wrapper_template.c new file mode 100644 index 0000000..15c262b --- /dev/null +++ b/dol/src/dol/visitor/rtems/lib/process_wrapper_template.c @@ -0,0 +1,116 @@ +#include +#include +#include + +#include "rtems_process_wrapper.h" + +#ifdef WORKLOAD_EXTRACT +#define DOL_read(port, buf, len, process) \ +{ ((RtemsProcessWrapper*)process->wptr)->end_line = __LINE__; \ + DOL_read(port, buf, len, process); \ + ((RtemsProcessWrapper*)process->wptr)->start_line = __LINE__; } + +#define DOL_write(port, buf, len, process) \ +{ ((RtemsProcessWrapper*)process->wptr)->end_line = __LINE__; \ + DOL_write(port, buf, len, process); \ + ((RtemsProcessWrapper*)process->wptr)->start_line = __LINE__; } +#endif + +#ifdef PRINTF_TO_DEBUG +#undef printf +#define printf(...) \ + do { \ + char _buffer[128]; \ + sprintf(_buffer, __VA_ARGS__); \ + SHOW_DEBUG((int)_buffer); \ + } while (0) +#endif + +//#include "@PROCESSNAME@.c" + +//DOL-specific implementation +rtems_task @PROCESSNAME@_task(rtems_task_argument argument) { + RtemsProcessWrapper* wrapper = (RtemsProcessWrapper*)argument; + DOLProcess* process; + LocalState state; + int number_of_activations = 0; + int i; + rtems_task_priority old_priority; + + process = (DOLProcess *)malloc(sizeof(DOLProcess)); + state = (LocalState)malloc(sizeof(@Processname@_State)); + process->init = @PROCESSNAME@_init; + process->fire = @PROCESSNAME@_fire; + process->local = state; + process->wptr = wrapper; + + //initialize the index array + wrapper->index = (int *)malloc(4 * sizeof(int)); + for (i = 0; i < 4; i++) { + wrapper->index[i] = getIndex(wrapper->name, "_", i); + } + + printf("Start process %s.\n", wrapper->name); + process->init(process); + + //yield process such that other processes can be initialized +#ifdef MPARM + do { + rtems_task_wake_after(RTEMS_YIELD_PROCESSOR); + } while((int)get_cycle() < 1511576); +#endif + rtems_task_set_priority(RTEMS_SELF, wrapper->priority, &old_priority); + + while (!wrapper->is_detached) { + + //placeholder for periodic trigger + +#ifdef WORKLOAD_EXTRACT + wrapper->start_line = 0; + SHOW_DEBUG("log start_fire"); + SHOW_DEBUG_INT((int)get_cycle()); +#endif + + process->fire(process); + +#ifdef WORKLOAD_EXTRACT + SHOW_DEBUG("log end_fire"); + SHOW_DEBUG_INT((int)get_cycle()); + wrapper->end_line = 0; +#endif + number_of_activations++; + } + +#ifdef MPARM_SCRATCHPAD_QUEUE + #ifdef QUEUE_BUFF_SHAPER + @ENDING_SHAPER@ + #endif +#else // pc386 + //below is not necessary if no dynamic switching + //printf("Detached @PROCESSNAME@. Cleanup... "); + if (wrapper->index) { + free(wrapper->index); + } else { + printf("Could not free memory for index of @PROCESSNAME@.\n"); + } + + if (wrapper->port_id) { + free(wrapper->port_id); + } else { + printf("Could not free memory for port_id of @PROCESSNAME@.\n"); + } + + if (wrapper->port_queue_id) { + } else { + printf("Could not free memory for port_queue_id of @PROCESSNAME@.\n"); + } +#endif // MPARM_SCRATCHPAD_QUEUE + //printf("Done.\n"); + + printf("Detach process %s.\n", wrapper->name); +#ifdef MPARM + Cleanup(); +#endif + + rtems_task_delete(RTEMS_SELF); +}