21,11 → 21,11 |
|
/** |
------------ |
CVS : $Id: func.h,v 1.1.1.1 2002-03-29 14:12:51 pj Exp $ |
CVS : $Id: func.h,v 1.6 2003-03-17 09:18:55 pj Exp $ |
|
File: $File$ |
Revision: $Revision: 1.1.1.1 $ |
Last update: $Date: 2002-03-29 14:12:51 $ |
Revision: $Revision: 1.6 $ |
Last update: $Date: 2003-03-17 09:18:55 $ |
------------ |
|
Kernel functions: |
89,15 → 89,10 |
/* if a source use printk() it should include log.h not func.h */ |
#include <kernel/log.h> |
|
#if 0 |
#ifdef __DEBUG_ON__ |
#define printk(fmt,args...) \ |
VM_printf(fmt,##args) |
#else |
#define printk(fmt,args...) |
#endif |
#endif |
#include "ll/sys/cdefs.h" |
|
__BEGIN_DECLS |
|
/*---------------------------------------------------------------------*/ |
/* Kernel global functions: initialization & termination... */ |
/*---------------------------------------------------------------------*/ |
107,11 → 102,39 |
TIME __kernel_register_levels__(void *arg); |
|
/*+ This function returns a level_des **. the value returned shall be |
used to register a level module. The function shall be called only at |
module registration time. It assume that the system is not yet |
initialized, so we shall not call sys_abort... +*/ |
LEVEL level_alloc_descriptor(); |
used to register a level module. |
|
The function is usually called at module registration time. The |
function can also be called when the system is already started, to |
allow the implementation of dynamic module registration. |
|
The argument must be the size of the data block that have to be allocated |
|
The function returns the number of the descriptor allocated for the module |
or -1 in case there are no free descriptors. |
|
The function also reserves a descriptor with size s, initialized |
with default function pointers. |
|
+*/ |
LEVEL level_alloc_descriptor(size_t s); |
|
/*+ This function release a level descriptor previously allocated using |
level_alloc_descriptor(). |
|
The function returns 0 if the level has been freed, or -1 if someone is |
using it, -2 if the level has never been registered. |
|
+*/ |
int level_free_descriptor(LEVEL l); |
|
/* Call this if you want to say that your module is using module l |
(e.g., for calling its private functions) */ |
int level_use_descriptor(LEVEL l); |
|
/* Call this when you no more need the module l */ |
int level_unuse_descriptor(LEVEL l); |
|
/*+ This function returns a resource_des **. the value returned shall be |
used to register a resource module. The function shall be called only at |
module registration time. It assume that the system is not yet |
137,15 → 160,8 |
(when uses some defines contained in const.h) +*/ |
int sys_atrunlevel(void (*func_code)(void *),void *parm, BYTE when); |
|
/*+ These functions can be used to set a nice (I hope) default |
signal handler. If not used, they are not linked. |
They returns -1 if an error occurred, as done by the |
sigaction primitive. +*/ |
int set_exchandler_grx(); |
int set_exchandler_text(); |
|
/*---------------------------------------------------------------------*/ |
/* Kernel global functions: scheduler, queues */ |
/* Kernel global functions: scheduler, */ |
/*---------------------------------------------------------------------*/ |
|
/*+ This is the generic scheduler. |
157,31 → 173,13 |
the end of an event list +*/ |
void event_need_reschedule(); |
|
/* Simple QUEUE management functions */ |
void q_insert (PID p, QUEUE *q); |
void q_timespec_insert (PID p, QUEUE *q); |
void q_extract (PID p, QUEUE *q); |
PID q_getfirst ( QUEUE *q); |
void q_insertfirst (PID p, QUEUE *q); |
|
|
/* QQUEUE management functions */ |
void qq_init ( QQUEUE *q); |
void qq_insert (PID p, QQUEUE *q); |
void qq_timespec_insert (PID p, QQUEUE *q); |
void qq_extract (PID p, QQUEUE *q); |
PID qq_getfirst ( QQUEUE *q); |
void qq_insertfirst (PID p, QQUEUE *q); |
void qq_insertlast (PID p, QQUEUE *q); |
PID qq_queryfirst ( QQUEUE *q); |
PID qq_querylast ( QQUEUE *q); |
|
|
void task_makefree(void *ret); |
void check_killed_async(void); |
|
int guarantee(); |
|
void levels_init(void); /* see init.c */ |
|
void runlevel_init(); |
void call_runlevel_func(int runlevel, int aborting); |
|
221,15 → 219,6 |
return ll_context_from(); |
} |
|
|
|
#ifdef __TEST1__ |
extern int useds; |
extern int testactive; |
extern struct timespec s_send[]; |
#endif |
|
|
/*+ this functions are called every time a context is changed +*/ |
void kern_after_dispatch(void); |
|
239,14 → 228,10 |
- cond_timedwait |
- internal_sem_wait |
*/ |
extern __inline__ void kern_context_load(c) |
extern __inline__ void kern_context_load(CONTEXT c) |
{ |
ll_context_to(c); |
kern_after_dispatch(); |
|
#ifdef __TEST1__ |
if (testactive) ll_gettime(TIME_EXACT,&s_send[useds-1] ); |
#endif |
sti(); |
} |
|
276,6 → 261,8 |
return e; |
} |
|
#define kern_event_delete event_delete |
|
/*+ the default capacity timer used by the kernel... +*/ |
void capacity_timer(void *arg); |
|
282,17 → 269,17 |
|
#define kern_printf message |
|
extern __inline__ TIME kern_gettime(struct timespec *t) |
{ |
return ll_gettime(TIME_NEW, t); |
} |
|
|
|
/*---------------------------------------------------------------------*/ |
/* Kernel global functions: IRQ, errors and exception handling */ |
/* Kernel global functions: IRQ handling */ |
/*---------------------------------------------------------------------*/ |
|
/*+ Generic exception trapping routine +*/ |
void act_exc(int code); |
|
/* |
* User level interrupt/exception primitives |
*/ |
|
/*+ Interrupt handler installation +*/ |
int handler_set(int no, void (*fast)(int), PID pi); |
|
330,18 → 317,6 |
/*+ prints an error message (see perror.c) +*/ |
void perror (const char *s); |
|
/*+ Convert a status in a string. Useful for sys_status and level_status +*/ |
char *status_to_a(WORD status); |
|
/*+ this primitive prints the status of the system. cw contains a set of |
the statuses to be prompted... see const.h +*/ |
void sys_status(DWORD cw); |
|
/*+ sys_status flags +*/ |
#define CLOCK_STATUS 1 |
#define SCHED_STATUS 2 |
#define MEM_STATUS 4 |
|
/*+ this primitive returns the time read from the system timer +*/ |
TIME sys_gettime(struct timespec *t); |
|
387,6 → 362,34 |
void jet_update_endcycle(); |
|
/*---------------------------------------------------------------------*/ |
/* Internal Macros */ |
/*---------------------------------------------------------------------*/ |
|
extern __inline__ void kern_epilogue_macro(void) |
{ |
TIME tx; /* a dummy used for time computation */ |
struct timespec ty; /* a dummy used for time computation */ |
|
kern_gettime(&schedule_time); |
|
/* manage the capacity event */ |
SUBTIMESPEC(&schedule_time, &cap_lasttime, &ty); |
tx = TIMESPEC2USEC(&ty); |
proc_table[exec_shadow].avail_time -= tx; |
jet_update_slice(tx); |
|
/* if the event didn't fire before, we delete it. */ |
if (cap_timer != NIL) { |
kern_event_delete(cap_timer); |
cap_timer = NIL; |
} |
} |
|
/* This function is called by the kernel into kern.c to register a default |
exception handler */ |
int set_default_exception_handler(void); |
|
/*---------------------------------------------------------------------*/ |
/* Task management primitives */ |
/*---------------------------------------------------------------------*/ |
|
529,19 → 532,18 |
/*+ Enable the preemption mechanism on the task. +*/ |
void task_preempt(void); |
|
/*+ sends a message to the scheduling module that is handling the task +*/ |
int task_message(void *m, int reschedule); |
|
/*+ This function signals to the kernel that the current istance of |
the task (periodic or aperiodic) is ended; so the task can be |
suspended until it is activated again. Pending activations may be saved |
depending on the task model +*/ |
void task_endcycle(void); |
extern __inline__ void task_endcycle(void) |
{ |
task_message(NULL, 1); |
} |
|
/*+ This function suspend the actual task until an explicit activation |
Pending activations are discarded +*/ |
void task_sleep(void); |
|
/*+ This function suspend the actual task for a minimum delay time +*/ |
void task_delay(DWORD delay); |
|
/*+ This primitives refers the group id which is supplied |
by the application, not by the kernel +*/ |
int group_activate(WORD g); |
629,4 → 631,5 |
if (ex) (*__cleanup_handler.f) (__cleanup_handler.a); \ |
} |
|
__END_DECLS |
#endif /* __FUNC_H__ */ |