5 #include "rtems_process_wrapper.h"
7 #ifdef WORKLOAD_EXTRACT
8 #define DOL_read(port, buf, len, process) \
9 { ((RtemsProcessWrapper*)process->wptr)->end_line = __LINE__; \
10 DOL_read(port, buf, len, process); \
11 ((RtemsProcessWrapper*)process->wptr)->start_line = __LINE__; }
13 #define DOL_write(port, buf, len, process) \
14 { ((RtemsProcessWrapper*)process->wptr)->end_line = __LINE__; \
15 DOL_write(port, buf, len, process); \
16 ((RtemsProcessWrapper*)process->wptr)->start_line = __LINE__; }
19 #ifdef PRINTF_TO_DEBUG
24 sprintf(_buffer, __VA_ARGS__); \
25 SHOW_DEBUG((int)_buffer); \
29 //#include "@PROCESSNAME@.c"
31 //DOL-specific implementation
32 rtems_task @PROCESSNAME@_task(rtems_task_argument argument) {
33 RtemsProcessWrapper* wrapper = (RtemsProcessWrapper*)argument;
36 int number_of_activations = 0;
38 rtems_task_priority old_priority;
40 process = (DOLProcess *)malloc(sizeof(DOLProcess));
41 state = (LocalState)malloc(sizeof(@Processname@_State));
42 process->init = @PROCESSNAME@_init;
43 process->fire = @PROCESSNAME@_fire;
44 process->local = state;
45 process->wptr = wrapper;
47 //initialize the index array
48 wrapper->index = (int *)malloc(4 * sizeof(int));
49 for (i = 0; i < 4; i++) {
50 wrapper->index[i] = getIndex(wrapper->name, "_", i);
53 printf("Start process %s.\n", wrapper->name);
54 process->init(process);
56 //yield process such that other processes can be initialized
59 rtems_task_wake_after(RTEMS_YIELD_PROCESSOR);
60 } while((int)get_cycle() < 1511576);
62 rtems_task_set_priority(RTEMS_SELF, wrapper->priority, &old_priority);
64 while (!wrapper->is_detached) {
66 //placeholder for periodic trigger
68 #ifdef WORKLOAD_EXTRACT
69 wrapper->start_line = 0;
70 SHOW_DEBUG("log start_fire");
71 SHOW_DEBUG_INT((int)get_cycle());
74 process->fire(process);
76 #ifdef WORKLOAD_EXTRACT
77 SHOW_DEBUG("log end_fire");
78 SHOW_DEBUG_INT((int)get_cycle());
79 wrapper->end_line = 0;
81 number_of_activations++;
84 #ifdef MPARM_SCRATCHPAD_QUEUE
85 #ifdef QUEUE_BUFF_SHAPER
89 //below is not necessary if no dynamic switching
90 //printf("Detached @PROCESSNAME@. Cleanup... ");
94 printf("Could not free memory for index of @PROCESSNAME@.\n");
97 if (wrapper->port_id) {
98 free(wrapper->port_id);
100 printf("Could not free memory for port_id of @PROCESSNAME@.\n");
103 if (wrapper->port_queue_id) {
105 printf("Could not free memory for port_queue_id of @PROCESSNAME@.\n");
107 #endif // MPARM_SCRATCHPAD_QUEUE
110 printf("Detach process %s.\n", wrapper->name);
115 rtems_task_delete(RTEMS_SELF);