Rev 496 |
Rev 514 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
#include <kernel/int_sem.h>
#include <stdlib.h>
#include <kernel/func.h>
#include <ll/sys/ll/event.h>
PID intr_server
= NIL
;
#define MAX_INT_LIST 50
void *int_arg_table
[16];
void *int_func_table
[16];
int int_list
[MAX_INT_LIST
];
int next_free_int
= 0;
int next_execute_int
= 0;
/* FIFO add job */
int add_interrupt_job
(int no
)
{
int_list
[next_free_int
] = no
;
next_free_int
++;
if (next_free_int
== MAX_INT_LIST
) next_free_int
= 0;
if (next_free_int
== next_execute_int
) {
next_free_int
--;
return -1;
}
return 0;
}
/* FIFO get job */
int get_interrupt_job
()
{
int res
= -1;
if (next_free_int
!= next_execute_int
) {
res
= int_list
[next_execute_int
];
next_execute_int
++;
if (next_execute_int
== MAX_INT_LIST
) next_execute_int
= 0;
}
return res
;
}
extern void linux_intr
(int no
);
TASK Interrupt_Server
(void *arg
)
{
int no
;
while(1) {
no
= get_interrupt_job
();
if (no
!= -1)
linux_intr
(no
);
task_endcycle
();
}
}
int shark_interrupt_server
() {
HARD_TASK_MODEL ht
;
int i
;
for(i
=0;i
<16;i
++) {
int_arg_table
[i
] = NULL
;
int_func_table
[i
] = NULL
;
}
hard_task_default_model
(ht
);
hard_task_def_wcet
(ht
,10000);
hard_task_def_interrupt
(ht
);
intr_server
= task_create
("Interrupt Server",Interrupt_Server
,&ht
,NULL
);
if (intr_server
!= NIL
)
return 0;
else
return -1;
}
void shark_internal_sem_create
(void **sem
, int init
) {
*sem
= (void *)malloc(sizeof(internal_sem_t
));
internal_sem_init
((internal_sem_t
*)(*sem
),init
);
}
void shark_internal_sem_wait
(void *sem
) {
internal_sem_wait
((internal_sem_t
*)(sem
));
}
void shark_internal_sem_post
(void *sem
) {
internal_sem_post
((internal_sem_t
*)(sem
));
}
int shark_event_post
(const struct timespec
*time, void (*handler
)(void *p
), void *par
)
{
return event_post
(*time, handler
, par
);
}
int shark_event_delete
(int index
)
{
return event_delete
(index
);
}
void fast_call
(int no
)
{
int res
;
res
= add_interrupt_job
(no
);
if (intr_server
!= NIL
&& res
== 0)
task_activate
(intr_server
);
}
int shark_handler_set
(int no
, void *fast
, void *arg
){
if (no
>= 1 && no
< 16) {
int_arg_table
[no
] = arg
;
int_func_table
[no
] = fast
;
return handler_set
(no
, fast_call
, NIL
, TRUE
);
} else {
return -1;
}
}
int shark_handler_remove
(int no
){
return handler_remove
(no
);
}