Subversion Repositories shark

Rev

Rev 1527 | Rev 1543 | Go to most recent revision | 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_create_thread fsf_create_thread
1262 giacomo 23
/* Create a task/thread inside a specific server.
24
 * it's very similar to fsf_create_thread, but we need a parameter
25
 * to set the local scheduler task and actually it's outside
26
 * the framework
27
 *
28
 * generic_task_create(
29
 *           server number,
30
 *           pthread_t of created task (-1 if failed),
31
 *           pthread_attr_t,
32
 *           task_body,
33
 *           arg of the body (must be "(void *)current"),
34
 *           arg for real-time task specification)
35
 */
36
 
1254 giacomo 37
#define generic_calibrate_cycle calibrate_cycle
1262 giacomo 38
/* Set the calibration parameter "cal_cycle"
39
 * only if it's initialized to 0. The calibration routine
40
 * calculates cal_cycle from CALIBRATION_DELTA.
41
 * This step can also be performed outside the demo.
42
 * Inside calibrate.h you can set the calibration parameters
43
 * for calibration step performed outside.
44
 *
45
 * cal_cycle is the number of cycles that are needed to
46
 * make CALIBRATION_DELTA number of iteration.
47
 *
48
 * kern_cli();
49
 * kern_gettime(&start);
50
 * for (i=0;i<CALIBRATION_DELTA;i++)
51
 *   __asm__ __volatile__ ("xorl %%eax,%%eax\n\t"
52
 *                         "cpuid\n\t"
53
 *                         :::"eax","ebx","ecx","edx");
54
 * kern_gettime(&end);
55
 * kern_sti();
56
 *
57
 * SUBTIMESPEC(&end,&start,&diff);
58
 * cal_cycles = TIMESPEC2USEC(&diff);
59
 *
60
 */
61
 
1254 giacomo 62
#define generic_set_next_activation set_next_activation
1262 giacomo 63
/* Set the next activation time. It's like fsf_schedule_next_timed_job
64
 * but it don't return nothing
65
 */
66
 
1254 giacomo 67
#define generic_set_simulation_time set_simulation_time
1262 giacomo 68
/* Set the end time of simulation */
69
 
1254 giacomo 70
#define generic_get_task_model get_task_model
1262 giacomo 71
/* Return a pointer to the struct that contains the
72
 * local shceduler parameter */
73
 
1254 giacomo 74
#define generic_start_simulation start_simulation
1262 giacomo 75
/* Start the simulation */
76
 
1254 giacomo 77
#define generic_fsfinit() fsfinit()
1262 giacomo 78
/* Create the fsf_server */
79
 
1254 giacomo 80
#define generic_task_endcycle() task_endcycle()
1262 giacomo 81
/* The job is finished */
82
 
1254 giacomo 83
#define generic_end_simulation() sys_end()
1262 giacomo 84
/* Exit from simulation */
85
 
1254 giacomo 86
#define printf cprintf
1262 giacomo 87
/* Printf standard function */
1254 giacomo 88
 
1304 giacomo 89
/* Mutex */
90
extern __inline__ void generic_lock_mutex(int res) {
1538 trimarchi 91
  extern mutex_t mutex_table[MAX_MUTEX];
1304 giacomo 92
 
1538 trimarchi 93
  mutex_lock(&mutex_table[res]);
1304 giacomo 94
}
95
 
96
extern __inline__ void generic_unlock_mutex(int res) {
1538 trimarchi 97
  extern mutex_t mutex_table[MAX_MUTEX];
1304 giacomo 98
 
1538 trimarchi 99
  mutex_unlock(&mutex_table[res]);
1304 giacomo 100
}
101
 
1264 giacomo 102
/* TASK RUNTIME FUNCTIONS */
103
 
104
extern __inline__ void start_oneshot_task(void) {}
105
extern __inline__ void end_oneshot_task(void) {}
106
 
107
extern __inline__ void start_periodic_task(void) {}
1298 giacomo 108
extern __inline__ void start_job_periodic_task(void) {
109
   task_testcancel();
110
}
111
extern __inline__ void end_job_periodic_task(void) {
112
   task_testcancel();
113
}
1264 giacomo 114
extern __inline__ void end_periodic_task(void) {}
115
 
116
extern __inline__ void start_back_task(void) {}
1298 giacomo 117
extern __inline__ void start_job_back_task(void) {
118
  task_testcancel();
119
}
120
extern __inline__ void end_job_back_task(void) {
121
  task_testcancel();
122
}
1264 giacomo 123
extern __inline__ void end_back_task(void) {}
124
 
1254 giacomo 125
#endif
126
 
127