Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1672 | tullio | 1 | #ifndef __FUNC_H__ |
2 | #define __FUNC_H__ |
||
3 | |||
4 | #include "kernel/kern.h" |
||
5 | #include "fsf_basic_types.h" |
||
6 | #include "fsf_core.h" |
||
7 | #include "fsf_server.h" |
||
8 | #include "shark.h" |
||
9 | |||
10 | #define OS_SHARK |
||
11 | |||
12 | |||
13 | #define get_current_exec_task() exec_shadow |
||
14 | /* Return the PID/pthread_t of calling task */ |
||
15 | |||
16 | #define generic_get_server_from_contract get_server_from_contract |
||
17 | /* Return the server_id from the contract number used |
||
18 | * inside .fsf file to define contract parameters |
||
19 | * |
||
20 | * generic_get_server_from_contract(int contract_number) */ |
||
21 | |||
22 | #define generic_calibrate_cycle calibrate_cycle |
||
23 | /* Set the calibration parameter "cal_cycle" |
||
24 | * only if it's initialized to 0. The calibration routine |
||
25 | * calculates cal_cycle from CALIBRATION_DELTA. |
||
26 | * This step can also be performed outside the demo. |
||
27 | * Inside calibrate.h you can set the calibration parameters |
||
28 | * for calibration step performed outside. |
||
29 | * |
||
30 | * cal_cycle is the number of cycles that are needed to |
||
31 | * make CALIBRATION_DELTA number of iteration. |
||
32 | * |
||
33 | * kern_cli(); |
||
34 | * kern_gettime(&start); |
||
35 | * for (i=0;i<CALIBRATION_DELTA;i++) |
||
36 | * __asm__ __volatile__ ("xorl %%eax,%%eax\n\t" |
||
37 | * "cpuid\n\t" |
||
38 | * :::"eax","ebx","ecx","edx"); |
||
39 | * kern_gettime(&end); |
||
40 | * kern_sti(); |
||
41 | * |
||
42 | * SUBTIMESPEC(&end,&start,&diff); |
||
43 | * cal_cycles = TIMESPEC2USEC(&diff); |
||
44 | * |
||
45 | */ |
||
46 | |||
47 | #define generic_set_next_activation set_next_activation |
||
48 | /* Set the next activation time. It's like fsf_schedule_next_timed_job |
||
49 | * but it don't return nothing |
||
50 | */ |
||
51 | |||
52 | #define generic_set_simulation_time set_simulation_time |
||
53 | /* Set the end time of simulation */ |
||
54 | |||
55 | #define generic_get_task_model get_task_model |
||
56 | /* Return a pointer to the struct that contains the |
||
57 | * local shceduler parameter */ |
||
58 | |||
59 | #define generic_start_simulation start_simulation |
||
60 | /* Start the simulation */ |
||
61 | |||
62 | #define generic_fsfinit() fsfinit() |
||
63 | /* Create the fsf_server */ |
||
64 | |||
65 | #define generic_task_endcycle() task_endcycle() |
||
66 | /* The job is finished */ |
||
67 | |||
68 | #define generic_end_simulation() exit(0) |
||
69 | /* Exit from simulation */ |
||
70 | |||
71 | #define printf cprintf |
||
72 | /* Printf standard function */ |
||
73 | |||
74 | /* Mutex */ |
||
75 | extern __inline__ void generic_lock_mutex(int res) { |
||
76 | extern mutex_t mutex_table[MAX_MUTEX]; |
||
77 | |||
78 | mutex_lock(&mutex_table[res]); |
||
79 | } |
||
80 | |||
81 | extern __inline__ void generic_unlock_mutex(int res) { |
||
82 | extern mutex_t mutex_table[MAX_MUTEX]; |
||
83 | |||
84 | mutex_unlock(&mutex_table[res]); |
||
85 | } |
||
86 | |||
87 | /* TASK RUNTIME FUNCTIONS */ |
||
88 | |||
89 | extern __inline__ void start_oneshot_task(void) {} |
||
90 | extern __inline__ void end_oneshot_task(void) {} |
||
91 | |||
92 | extern __inline__ void start_periodic_task(void) {} |
||
93 | extern __inline__ void start_job_periodic_task(void) { |
||
94 | task_testcancel(); |
||
95 | } |
||
96 | extern __inline__ void end_job_periodic_task(void) { |
||
97 | task_testcancel(); |
||
98 | } |
||
99 | extern __inline__ void end_periodic_task(void) {} |
||
100 | |||
101 | extern __inline__ void start_back_task(void) {} |
||
102 | extern __inline__ void start_job_back_task(void) { |
||
103 | task_testcancel(); |
||
104 | } |
||
105 | extern __inline__ void end_job_back_task(void) { |
||
106 | task_testcancel(); |
||
107 | } |
||
108 | extern __inline__ void end_back_task(void) {} |
||
109 | |||
110 | #endif |
||
111 | |||
112 |