Subversion Repositories shark

Rev

Rev 1538 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1255 giacomo 1
#ifndef __FUNC_H__
2
#define __FUNC_H__
1254 giacomo 3
 
1255 giacomo 4
#include "kernel/kern.h"
1538 trimarchi 5
#include "fsf_basic_types.h"
6
#include "fsf_core.h"
1527 trimarchi 7
#include "fsf_server.h"
1254 giacomo 8
#include "shark.h"
9
 
1262 giacomo 10
#define OS_SHARK
11
 
1527 trimarchi 12
 
1254 giacomo 13
#define get_current_exec_task() exec_shadow
1262 giacomo 14
/* Return the PID/pthread_t of calling task */
15
 
1254 giacomo 16
#define generic_get_server_from_contract get_server_from_contract 
1262 giacomo 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
 
1254 giacomo 22
#define generic_calibrate_cycle calibrate_cycle
1262 giacomo 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
 
1254 giacomo 47
#define generic_set_next_activation set_next_activation
1262 giacomo 48
/* Set the next activation time. It's like fsf_schedule_next_timed_job
49
 * but it don't return nothing
50
 */
51
 
1254 giacomo 52
#define generic_set_simulation_time set_simulation_time
1262 giacomo 53
/* Set the end time of simulation */
54
 
1254 giacomo 55
#define generic_get_task_model get_task_model
1262 giacomo 56
/* Return a pointer to the struct that contains the
57
 * local shceduler parameter */
58
 
1254 giacomo 59
#define generic_start_simulation start_simulation
1262 giacomo 60
/* Start the simulation */
61
 
1254 giacomo 62
#define generic_fsfinit() fsfinit()
1262 giacomo 63
/* Create the fsf_server */
64
 
1254 giacomo 65
#define generic_task_endcycle() task_endcycle()
1262 giacomo 66
/* The job is finished */
67
 
1254 giacomo 68
#define generic_end_simulation() sys_end()
1262 giacomo 69
/* Exit from simulation */
70
 
1254 giacomo 71
#define printf cprintf
1262 giacomo 72
/* Printf standard function */
1254 giacomo 73
 
1304 giacomo 74
/* Mutex */
75
extern __inline__ void generic_lock_mutex(int res) {
1538 trimarchi 76
  extern mutex_t mutex_table[MAX_MUTEX];
1304 giacomo 77
 
1538 trimarchi 78
  mutex_lock(&mutex_table[res]);
1304 giacomo 79
}
80
 
81
extern __inline__ void generic_unlock_mutex(int res) {
1538 trimarchi 82
  extern mutex_t mutex_table[MAX_MUTEX];
1304 giacomo 83
 
1538 trimarchi 84
  mutex_unlock(&mutex_table[res]);
1304 giacomo 85
}
86
 
1264 giacomo 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) {}
1298 giacomo 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
}
1264 giacomo 99
extern __inline__ void end_periodic_task(void) {}
100
 
101
extern __inline__ void start_back_task(void) {}
1298 giacomo 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
}
1264 giacomo 108
extern __inline__ void end_back_task(void) {}
109
 
1254 giacomo 110
#endif
111
 
112