1,31 → 1,44 |
#include <kernel/kern.h> |
/* FSF Loader |
* |
* Load and run a specific set of tasks/contracts |
* |
* This is the system indipendent part |
* |
* Giacomo Guidi <giacomo@gandalf.sssup.it> |
* Michael Timarchi <trimarchi@gandalf.sssup.it> |
* |
*/ |
|
#include "fsf_contract.h" |
#include "fsf_server.h" |
#include "func.h" |
#include <kernel/kern.h> //Shark dependent header, it's used only for TASK_OUTPUT debug |
|
/* Activate task output */ |
#include "fsf_contract.h" //Framework main header |
#include "func.h" //Generic function definitions |
|
/* Activate task output debug */ |
#define TASK_OUTPUT |
|
int cal_cycles=0; |
struct timespec zero_time; |
extern struct loader_task loader_task_list[]; |
extern int total_loader_task; |
int cal_cycles = 0; //Calibration const, it converts usec in cycles |
struct timespec zero_time; //Zero time of the simulation |
extern struct loader_task loader_task_list[]; //Loader task array |
extern int total_loader_task; //Loader task number |
|
/* oneshot Soft and hard Task */ |
/* OS: Oneshot Task: |
begin |
- execution |
end |
*/ |
void *oneshot_task(void *arg) |
{ |
long long i,exec_cycles = 0; |
int act = 0; |
struct loader_task *l = (struct loader_task *)(arg); |
char tmp[20]; |
|
#ifdef TASK_OUTPUT |
sprintf(tmp,"X[%06d]",act); |
sprintf(tmp,"[ONESHOT]"); |
printf_xy((get_current_exec_task() % 5) * 9 + 34,get_current_exec_task() / 5 + 5, GREEN, tmp); |
#endif |
|
exec_cycles = (long long)(TIMESPEC2USEC(&l->exec[act])) * CALIBRATION_DELTA / cal_cycles; |
exec_cycles = (long long)(TIMESPEC2USEC(&l->exec[l->act_current-1])) * CALIBRATION_DELTA / cal_cycles; |
|
for (i=0;i<exec_cycles;i++) |
__asm__ __volatile__ ("xorl %%eax,%%eax\n\t" |
32,12 → 45,18 |
"cpuid\n\t" |
:::"eax","ebx","ecx","edx"); |
|
generic_task_endcycle(); |
|
return NULL; |
|
} |
|
/* CT: Cyclical Task: |
begin |
while (1) { |
- execution |
- end_cycle |
} |
end (never end) |
*/ |
void * periodic_task(void *arg) |
{ |
long long i,exec_cycles = 0; |
48,11 → 67,11 |
while(1) { |
|
#ifdef TASK_OUTPUT |
sprintf(tmp,"X[%06d]",act); |
sprintf(tmp,"C[%06d]",act); |
printf_xy((get_current_exec_task() % 5) * 9 + 34,get_current_exec_task() / 5 + 5, GREEN, tmp); |
#endif |
|
exec_cycles = (long long)(TIMESPEC2USEC(&l->exec[act])) * CALIBRATION_DELTA / cal_cycles; |
exec_cycles = (long long)(TIMESPEC2USEC(&l->exec[l->act_current-1])) * CALIBRATION_DELTA / cal_cycles; |
|
for (i=0;i<exec_cycles;i++) |
__asm__ __volatile__ ("xorl %%eax,%%eax\n\t" |
64,10 → 83,18 |
act++; |
|
} |
|
return NULL; |
|
} |
|
/* BT: Background Task: |
begin |
while (1) { |
- execution |
} |
end (never end) |
*/ |
void * back_task(void *arg) |
{ |
long long i,exec_cycles = 0; |
78,11 → 105,11 |
while(1) { |
|
#ifdef TASK_OUTPUT |
sprintf(tmp,"X[%06d]",act); |
sprintf(tmp,"B[%06d]",act); |
printf_xy((get_current_exec_task() % 5) * 9 + 34,get_current_exec_task() / 5 + 5, GREEN, tmp); |
#endif |
|
exec_cycles = (long long)(TIMESPEC2USEC(&l->exec[0])) * CALIBRATION_DELTA / cal_cycles; |
exec_cycles = (long long)(TIMESPEC2USEC(&l->exec[l->act_current-1])) * CALIBRATION_DELTA / cal_cycles; |
|
for (i=0;i<exec_cycles;i++) |
__asm__ __volatile__ ("xorl %%eax,%%eax\n\t" |
98,7 → 125,6 |
|
/* Task create */ |
/* this function create the task struct in memory */ |
|
void loader_task_create() |
{ |
|
128,8 → 154,8 |
break; |
} |
if (err) { |
cprintf("Error fsf task creating\n"); |
sys_end(); |
printf("Error fsf task creating\n"); |
generic_end_simulation(); |
} |
|
} |
138,12 → 164,12 |
|
} |
|
cprintf("Created %d loader tasks\n",k); |
printf("Created %d loader tasks\n",k); |
|
|
} |
|
|
/* Main Function */ |
int start_environment() |
{ |
|