changes for iocCore port

This commit is contained in:
Marty Kraimer
1999-11-18 15:17:51 +00:00
parent f62b50da17
commit 76f7caa362
8 changed files with 103 additions and 98 deletions

View File

@@ -59,7 +59,7 @@ typedef void (*CALLBACKFUNC)();
#define callbackSetPriority(PRIORITY,PCALLBACK)\
( (PCALLBACK)->priority = (PRIORITY) )
#define callbackSetUser(USER,PCALLBACK)\
( (PCALLBACK)->user = (VOID *)(USER) )
( (PCALLBACK)->user = (void *)(USER) )
#define callbackGetUser(USER,PCALLBACK)\
( (USER) = (void *)((CALLBACK *)(PCALLBACK))->user )

View File

@@ -136,7 +136,7 @@ int db_event_list(char *name)
struct dbCommon *precord;
status = dbNameToAddr(name, &addr);
if(status==ERROR)
if(status!=0)
return ERROR;
precord = addr.precord;
@@ -715,8 +715,8 @@ LOCAL int db_post_single_event_private(struct event_block *event)
int db_start_events(
struct event_user *evUser,
char *taskname, /* defaulted if NULL */
int (*init_func)(),
int init_func_arg,
int (*init_func)(threadId),
threadId init_func_arg,
int priority_offset
)
{
@@ -734,7 +734,7 @@ int priority_offset
threadUnlockContextSwitch();
if(!firstTry) return ERROR;
taskpri = threadGetPriority(threadGetIdSelf());
taskpri += priority_offset;
taskpri -= priority_offset;
evUser->pendexit = FALSE;
evUser->init_func = init_func;
evUser->init_func_arg = init_func_arg;

View File

@@ -42,128 +42,126 @@
#include <db_field_log.h>
#include <osiThread.h>
typedef void EVENTFUNC (void *user_arg, struct dbAddr *paddr,
int eventsRemaining, db_field_log *pfl);
int eventsRemaining, db_field_log *pfl);
struct event_block {
ELLNODE node;
struct dbAddr *paddr;
EVENTFUNC *user_sub;
void *user_arg;
struct event_que *ev_que;
db_field_log *pLastLog;
unsigned long npend; /* n times this event is on the que */
unsigned char select;
char valque;
char callBackInProgress;
struct event_block{
ELLNODE node;
struct dbAddr *paddr;
EVENTFUNC *user_sub;
void *user_arg;
struct event_que *ev_que;
db_field_log *pLastLog;
unsigned long npend; /* n times this event is on the que */
unsigned char select;
char valque;
char callBackInProgress;
};
#define EVENTSPERQUE 32
#define EVENTSPERQUE 32
#define EVENTQUESIZE (EVENTENTRIES * EVENTSPERQUE)
#define EVENTENTRIES 4 /* the number of que entries for each event */
#define EVENTQEMPTY ((struct event_block *)NULL)
/*
* really a ring buffer
*/
struct event_que {
struct event_que{
/* lock writers to the ring buffer only */
/* readers must never slow up writers */
semId writelock;
db_field_log valque[EVENTQUESIZE];
struct event_block *evque[EVENTQUESIZE];
struct event_que *nextque; /* in case que quota exceeded */
struct event_user *evUser; /* event user parent struct */
unsigned short putix;
unsigned short getix;
unsigned short quota; /* the number of assigned entries*/
semId writelock;
db_field_log valque[EVENTQUESIZE];
struct event_block *evque[EVENTQUESIZE];
struct event_que *nextque; /* in case que quota exceeded */
struct event_user *evUser; /* event user parent struct */
unsigned short putix;
unsigned short getix;
unsigned short quota; /* the number of assigned entries*/
};
typedef void OVRFFUNC (void *overflow_arg, unsigned count);
typedef void EXTRALABORFUNC (void *extralabor_arg);
struct event_user {
struct event_que firstque; /* the first event que */
semId ppendsem; /* Wait while empty */
semId pflush_sem; /* wait for flush */
OVRFFUNC *overflow_sub; /* called when overflow detect */
void *overflow_arg; /* parameter to above */
EXTRALABORFUNC *extralabor_sub;/* off load to event task */
void *extralabor_arg;/* parameter to above */
threadId taskid; /* event handler task id */
unsigned queovr; /* event que overflow count */
unsigned nDuplicates; /* events duplicated on q */
char pendlck; /* Only one task can pend */
unsigned char pendexit; /* exit pend task */
unsigned char extra_labor; /* if set call extra labor func */
unsigned char flowCtrlMode; /* replace existing monitor */
int (*init_func)();
int init_func_arg;
struct event_user{
struct event_que firstque; /* the first event que */
semId ppendsem; /* Wait while empty */
semId pflush_sem; /* wait for flush */
OVRFFUNC *overflow_sub; /* called when overflow detect */
void *overflow_arg; /* parameter to above */
EXTRALABORFUNC *extralabor_sub;/* off load to event task */
void *extralabor_arg;/* parameter to above */
threadId taskid; /* event handler task id */
unsigned queovr; /* event que overflow count */
unsigned nDuplicates; /* events duplicated on q */
char pendlck; /* Only one task can pend */
unsigned char pendexit; /* exit pend task */
unsigned char extra_labor; /* if set call extra labor func */
unsigned char flowCtrlMode; /* replace existing monitor */
int (*init_func)();
threadId init_func_arg;
};
int db_event_list (char *name);
struct event_user *db_init_events (void);
int db_close_events (struct event_user *evUser);
unsigned db_sizeof_event_block (void);
int db_event_list(char *name);
struct event_user *db_init_events(void);
int db_close_events(struct event_user *evUser);
unsigned db_sizeof_event_block(void);
int db_add_event (
int db_add_event(
struct event_user *evUser,
struct dbAddr *paddr,
EVENTFUNC *user_sub,
EVENTFUNC *user_sub,
void *user_arg,
unsigned int select,
struct event_block *pevent /* ptr to event blk (not required) */
);
int db_cancel_event (struct event_block *pevent);
int db_cancel_event(struct event_block *pevent);
int db_add_overflow_event (
int db_add_overflow_event(
struct event_user *evUser,
OVRFFUNC *overflow_sub,
OVRFFUNC *overflow_sub,
void *overflow_arg
);
int db_add_extra_labor_event (
struct event_user *evUser,
EXTRALABORFUNC *func,
void *arg
int db_add_extra_labor_event(
struct event_user *evUser,
EXTRALABORFUNC *func,
void *arg
);
int db_flush_extra_labor_event (
struct event_user *evUser
int db_flush_extra_labor_event(struct event_user *evUser);
int db_post_single_event(struct event_block *pevent);
int db_post_extra_labor(struct event_user *evUser);
int db_post_events(
void *precord,
void *pvalue,
unsigned int select
);
int db_post_single_event (struct event_block *pevent);
int db_post_extra_labor (struct event_user *evUser);
int db_post_events (
void *precord,
void *pvalue,
unsigned int select
);
int db_start_events (
int db_start_events(
struct event_user *evUser,
char *taskname, /* defaulted if NULL */
int (*init_func)(int),
int init_func_arg,
int (*init_func)(threadId),
threadId init_func_arg,
int priority_offset
);
void event_task (struct event_user *evUser);
void event_task(struct event_user *evUser);
int db_event_enable (struct event_block *pevent);
int db_event_disable (struct event_block *pevent);
int db_event_enable(struct event_block *pevent);
int db_event_disable(struct event_block *pevent);
void db_event_flow_ctrl_mode_on (struct event_user *evUser);
void db_event_flow_ctrl_mode_off (struct event_user *evUser);
void db_event_flow_ctrl_mode_on(struct event_user *evUser);
void db_event_flow_ctrl_mode_off(struct event_user *evUser);
#endif /*INCLdbEventh*/

View File

@@ -180,6 +180,7 @@ void scanAdd(struct dbCommon *precord)
if(!pevent_scan_list ) {
pevent_scan_list = dbCalloc(1,sizeof(event_scan_list));
pevent_list[priority][evnt] = pevent_scan_list;
pevent_scan_list->scan_list.lock = semMutexCreate();
callbackSetCallback(eventCallback,&pevent_scan_list->callback);
callbackSetPriority(priority,&pevent_scan_list->callback);
callbackSetUser(pevent_scan_list,&pevent_scan_list->callback);
@@ -236,8 +237,8 @@ void scanAdd(struct dbCommon *precord)
void scanDelete(struct dbCommon *precord)
{
short scan;
scan_list *psl;
short scan;
scan_list *psl = 0;
/* get the list on which this record belongs */
scan = precord->scan;
@@ -511,8 +512,7 @@ static void periodicTask(void *arg)
if(end_time>=start_time) {
diff = end_time - start_time;
} else {
/*unsigned long overflow*/
diff = (UINT_MAX - start_time) + end_time;
diff = 1 + end_time + (ULONG_MAX - start_time);
}
delay = psl->ticks - diff;
delay = (delay<=0.0) ? .1 : delay/clockGetRate();

View File

@@ -49,7 +49,6 @@
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <types.h>
#include "dbDefs.h"
#include "errlog.h"

View File

@@ -40,6 +40,8 @@
#include <stddef.h>
#include <stdio.h>
#include <dbDefs.h>
#include "ellLib.h"
#include "initHooks.h"
@@ -69,11 +71,11 @@ int initHookRegister(initHookFunction func)
if (newHook == NULL)
{
printf("Cannot malloc a new initHookLink\n");
return ERROR;
return -1;
}
newHook->func = func;
ellAdd(&functionList,&newHook->node);
return OK;
return 0;
}
/*

View File

@@ -44,9 +44,11 @@
#include "errMdef.h"
#include "taskwd.h"
typedef void (*MYFUNCPTR)();
struct task_list {
ELLNODE node;
VOIDFUNCPTR callback;
MYFUNCPTR callback;
void *arg;
union {
threadId tid;
@@ -87,7 +89,7 @@ void taskwdInit()
(THREADFUNC)taskwdTask,0);
}
void taskwdInsert(threadId tid,VOIDFUNCPTR callback,void *arg)
void taskwdInsert(threadId tid,TASKWDFUNCPRR callback,void *arg)
{
struct task_list *pt;
@@ -101,7 +103,7 @@ void taskwdInsert(threadId tid,VOIDFUNCPTR callback,void *arg)
semMutexGive(lock);
}
void taskwdAnyInsert(void *userpvt,VOIDFUNCPTR callback,void *arg)
void taskwdAnyInsert(void *userpvt,TASKWDANYFUNCPRR callback,void *arg)
{
struct task_list *pt;
@@ -175,11 +177,14 @@ static void taskwdTask(void)
errMessage(-1,message);
ptany = (struct task_list *)ellFirst(&anylist);
while(ptany) {
if(ptany->callback) (ptany->callback)(ptany->arg,pt->id.tid);
if(ptany->callback) {
TASKWDANYFUNCPRR pcallback = pt->callback;
(pcallback)(ptany->arg,pt->id.tid);
}
ptany = (struct task_list *)ellNext((ELLNODE *)ptany);
}
if(pt->callback) {
VOIDFUNCPTR pcallback = pt->callback;
TASKWDFUNCPRR pcallback = pt->callback;
void *arg = pt->arg;
/*Must allow callback to call taskwdRemove*/
@@ -199,8 +204,7 @@ static void taskwdTask(void)
threadSleep(TASKWD_DELAY);
}
}
static struct task_list *allocList(void)
{
struct task_list *pt;

View File

@@ -37,10 +37,12 @@
#include "osiThread.h"
typedef void (*TASKWDFUNCPRR)(void *parm);
typedef void (*TASKWDANYFUNCPRR)(void *parm,threadId tid);
#ifdef __STDC__
void taskwdInit();
void taskwdInsert(threadId tid, VOIDFUNCPTR callback,void *arg);
void taskwdAnyInsert(void *userpvt, VOIDFUNCPTR callback,void *arg);
void taskwdInsert(threadId tid, TASKWDFUNCPRR callback,void *arg);
void taskwdAnyInsert(void *userpvt, TASKWDANYFUNCPRR callback,void *arg);
void taskwdRemove(threadId tid);
void taskwdAnyRemove(void *userpvt);
#else