Subversion Repositories shark

Rev

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