Exemple #1
0
static void errlogInitPvt(void *arg)
{
    struct initArgs *pconfig = (struct initArgs *) arg;
    epicsThreadId tid;

    pvtData.errlogInitFailed = TRUE;
    pvtData.buffersize = pconfig->bufsize;
    pvtData.maxMsgSize = pconfig->maxMsgSize;
    pvtData.msgNeeded = adjustToWorstCaseAlignment(pvtData.maxMsgSize +
        sizeof(msgNode));
    ellInit(&pvtData.listenerList);
    ellInit(&pvtData.msgQueue);
    pvtData.toConsole = TRUE;
    pvtData.console = stderr;
    pvtData.waitForWork = epicsEventMustCreate(epicsEventEmpty);
    pvtData.listenerLock = epicsMutexMustCreate();
    pvtData.msgQueueLock = epicsMutexMustCreate();
    pvtData.waitForFlush = epicsEventMustCreate(epicsEventEmpty);
    pvtData.flush = epicsEventMustCreate(epicsEventEmpty);
    pvtData.flushLock = epicsMutexMustCreate();
    pvtData.waitForExit = epicsEventMustCreate(epicsEventEmpty);
    pvtData.pbuffer = callocMustSucceed(1, pvtData.buffersize,
        "errlogInitPvt");

    errSymBld();    /* Better not to do this lazily... */

    tid = epicsThreadCreate("errlog", epicsThreadPriorityLow,
        epicsThreadGetStackSize(epicsThreadStackSmall),
        (EPICSTHREADFUNC)errlogThread, 0);
    if (tid) {
        pvtData.errlogInitFailed = FALSE;
    }
}
void ell_check(){
	EllCurve ecc;
	BigNum bnA, bnB, bnPrime, bnQ, bnPX, bnPY, bnQX, bnQY, bnD;
	strtodigitn( "0000000000000000000000000000000000000000000000000000000000000007", bnA, MAX_SIZE );
	strtodigitn( "5FBFF498AA938CE739B8E022FBAFEF40563F6E6A3472FC2A514C0CE9DAE23B7E", bnB, MAX_SIZE );
	strtodigitn( "8000000000000000000000000000000000000000000000000000000000000431", bnPrime, MAX_SIZE );
	strtodigitn( "8000000000000000000000000000000150FE8A1892976154C59CFC193ACCF5B3", bnQ, MAX_SIZE );
	strtodigitn( "0000000000000000000000000000000000000000000000000000000000000002", bnPX, MAX_SIZE );
	strtodigitn( "8E2A8A0E65147D4BD6316030E16D19C85C97F0A9CA267122B96ABBCEA7E8FC8", bnPY, MAX_SIZE );
	strtodigitn( "7A929ADE789BB9BE10ED359DD39A72C11B60961F49397EEE1D19CE9891EC3B28", bnD, MAX_SIZE );
	ellCurveInit( ecc, bnA, bnB, bnPrime );


	EllPoint epP, epQ, epRes;
	ellInit( epP, bnPX, bnPY, ecc );
	ellInit( epQ, ecc );

	ellMul( epRes, bnQ, epP, ecc );	
	//std::cout << epRes << std::endl;
	if ( ellIsZero(epRes) )
		std::cout << "Test Valid" << std::endl;
	else
		std::cout << "Test is NOT Valid" << std::endl;

	ellMul( epRes, bnD, epP, ecc );
	strtodigitn( "7F2B49E270DB6D90D8595BEC458B50C58585BA1D4E9B788F6689DBD8E56FD80B", bnQX, MAX_SIZE );
	strtodigitn( "26F1B489D6701DD185C8413A977B3CBBAF64D1C593D26627DFFB101A87FF77DA", bnQY, MAX_SIZE );
	ellInit( epQ, bnQX, bnQY, ecc );
	if ( ellIsEqual( epQ, epRes ) )
		std::cout << "Test Valid" << std::endl;
	else
		std::cout << "Test is NOT Valid" << std::endl;
};
Exemple #3
0
static void generalTime_InitOnce(void *dummy)
{
    ellInit(&gtPvt.timeProviders);
    gtPvt.timeListLock = epicsMutexMustCreate();

    ellInit(&gtPvt.eventProviders);
    gtPvt.eventListLock = epicsMutexMustCreate();
}
static void inputConstruct(void **ppvt)
{
    inputData	*pinputData;

    pinputData = calloc(1,sizeof(inputData));
    ellInit(&pinputData->inputFileList);
    ellInit(&pinputData->pathList);
    *ppvt = pinputData;
}
Exemple #5
0
void dbNotifyAdd(dbCommon *pfrom, dbCommon *pto)
{
    processNotify *ppn = pfrom->ppn;
    notifyPvt *pnotifyPvt;

    if (pto->pact)
        return; /*if active it will not be processed*/
    epicsMutexMustLock(pnotifyGlobal->lock);
    if (!pto->ppnr) {/* make sure record has a processNotifyRecord*/
        pto->ppnr = dbCalloc(1, sizeof(processNotifyRecord));
        pto->ppnr->precord = pto;
        ellInit(&pto->ppnr->restartList);
    }
    assert(ppn);
    pnotifyPvt = (notifyPvt *) ppn->pnotifyPvt;
    if (!pto->ppn &&
        (pnotifyPvt->state == notifyProcessInProgress) &&
        (pto != dbChannelRecord(ppn->chan))) {
        notifyPvt *pnotifyPvt;
        pto->ppn = pfrom->ppn;
        pnotifyPvt = (notifyPvt *) pfrom->ppn->pnotifyPvt;
        ellSafeAdd(&pnotifyPvt->waitList, &pto->ppnr->waitNode);
    }
    epicsMutexUnlock(pnotifyGlobal->lock);
}
Exemple #6
0
void dbProcessNotify(processNotify *ppn)
{
    struct dbChannel *chan = ppn->chan;
    dbCommon *precord = dbChannelRecord(chan);
    short dbfType = dbChannelFieldType(chan);
    notifyPvt *pnotifyPvt;

    /* Must handle DBF_XXXLINKs as special case.
     * Only dbPutField will change link fields.
     * Also the record is not processed as a result
    */
    ppn->status = notifyOK;
    ppn->wasProcessed = 0;
    if (dbfType>=DBF_INLINK && dbfType<=DBF_FWDLINK) {
        if (ppn->requestType == putProcessRequest ||
            ppn->requestType == putProcessGetRequest) {
            /* Check if puts disabled */
            if (precord->disp && (dbChannelField(ppn->chan) != (void *) &precord->disp)) {
                ppn->putCallback(ppn, putDisabledType);
            } else {
                ppn->putCallback(ppn, putFieldType);
            }
        }
        if (ppn->requestType == processGetRequest ||
            ppn->requestType == putProcessGetRequest) {
                ppn->getCallback(ppn, getFieldType);
            
        }
        ppn->doneCallback(ppn);
        return;
    }
    dbScanLock(precord);
    epicsMutexMustLock(pnotifyGlobal->lock);
    pnotifyPvt = (notifyPvt *) ppn->pnotifyPvt;
    if (pnotifyPvt && (pnotifyPvt->magic != MAGIC)) {
        printf("dbPutNotify:pnotifyPvt was not initialized\n");
        pnotifyPvt = 0;
    }
    if (pnotifyPvt) {
        assert(pnotifyPvt->state == notifyUserCallbackActive);
        pnotifyPvt->userCallbackWait = 1;
        epicsMutexUnlock(pnotifyGlobal->lock);
        dbScanUnlock(precord);
        epicsEventWait(pnotifyPvt->userCallbackEvent);
        dbScanLock(precord);
        epicsMutexMustLock(pnotifyGlobal->lock);
        notifyCleanup(ppn);
    }
    pnotifyPvt = (notifyPvt *) ppn->pnotifyPvt;
    assert(!pnotifyPvt);
    notifyInit(ppn);
    pnotifyPvt = (notifyPvt *) ppn->pnotifyPvt;
    if (!precord->ppnr) {
        /* make sure record has a processNotifyRecord*/
        precord->ppnr = dbCalloc(1, sizeof(processNotifyRecord));
        precord->ppnr->precord = precord;
        ellInit(&precord->ppnr->restartList);
    }
    processNotifyCommon(ppn, precord);
}
Exemple #7
0
static void notifyInit(processNotify *ppn)
{
    notifyPvt *pnotifyPvt;

    pnotifyPvt = (notifyPvt *) ellFirst(&pnotifyGlobal->freeList);
    if (pnotifyPvt) {
        ellDelete(&pnotifyGlobal->freeList, &pnotifyPvt->node);
    } else {
        pnotifyPvt = dbCalloc(1,sizeof(notifyPvt));
        pnotifyPvt->cancelEvent = epicsEventCreate(epicsEventEmpty);
        pnotifyPvt->userCallbackEvent = epicsEventCreate(epicsEventEmpty);
        pnotifyPvt->magic = MAGIC;
        pnotifyPvt->state = notifyNotActive;
    }
    pnotifyPvt->state = notifyNotActive;
    callbackSetCallback(notifyCallback,&pnotifyPvt->callback);
    callbackSetUser(ppn,&pnotifyPvt->callback);
    callbackSetPriority(priorityLow,&pnotifyPvt->callback);
    ellInit(&pnotifyPvt->waitList);
    ppn->status = notifyOK;
    ppn->wasProcessed = 0;
    pnotifyPvt->state = notifyNotActive;
    pnotifyPvt->cancelWait = pnotifyPvt->userCallbackWait = 0;
    ppn->pnotifyPvt = pnotifyPvt;
}
Exemple #8
0
static void doInitRecord0(dbRecordType *pdbRecordType, dbCommon *precord,
    void *user)
{
    struct rset *prset = pdbRecordType->prset;
    devSup *pdevSup;

    if (!prset) return;         /* unlikely */

    precord->rset = prset;
    precord->rdes = pdbRecordType;
    precord->mlok = epicsMutexMustCreate();
    ellInit(&precord->mlis);

    /* Reset the process active field */
    precord->pact = FALSE;

    /* Initial UDF severity */
    if (precord->udf && precord->stat == UDF_ALARM)
    	precord->sevr = precord->udfs;

    /* Init DSET NOTE that result may be NULL */
    pdevSup = dbDTYPtoDevSup(pdbRecordType, precord->dtyp);
    precord->dset = pdevSup ? pdevSup->pdset : NULL;

    if (prset->init_record)
        prset->init_record(precord, 0);
}
motorSimController::motorSimController(const char *portName, int numAxes, int priority, int stackSize)
  :  asynMotorController(portName, numAxes, NUM_SIM_CONTROLLER_PARAMS, 
                         asynInt32Mask | asynFloat64Mask, 
                         asynInt32Mask | asynFloat64Mask,
                         ASYN_CANBLOCK | ASYN_MULTIDEVICE, 
                         1, // autoconnect
                         priority, stackSize)
{
  int axis;
  motorSimControllerNode *pNode;
  
  if (!motorSimControllerListInitialized) {
    motorSimControllerListInitialized = 1;
    ellInit(&motorSimControllerList);
  }
  
  // We should make sure this portName is not already in the list */
  pNode = (motorSimControllerNode*) calloc(1, sizeof(motorSimControllerNode));
  pNode->portName = epicsStrDup(portName);
  pNode->pController = this;
  ellAdd(&motorSimControllerList, (ELLNODE *)pNode);

  if (numAxes < 1 ) numAxes = 1;
  numAxes_ = numAxes;
  this->movesDeferred_ = 0;
  for (axis=0; axis<numAxes; axis++) {
    new motorSimAxis(this, axis, DEFAULT_LOW_LIMIT, DEFAULT_HI_LIMIT, DEFAULT_HOME, DEFAULT_START);
    setDoubleParam(axis, this->motorPosition_, DEFAULT_START);
  }

  this->motorThread_ = epicsThreadCreate("motorSimThread", 
                                         epicsThreadPriorityLow,
                                         epicsThreadGetStackSize(epicsThreadStackMedium),
                                         (EPICSTHREADFUNC) motorSimTaskC, (void *) this);
}
Exemple #10
0
static long configMenuList_init(aSubRecord *pasub) {
	ELLLIST *configMenuList;
	configMenuList = calloc(1, sizeof(ELLLIST));
	pasub->dpvt = configMenuList;
	ellInit(configMenuList);
	return(0);
}
Exemple #11
0
 void ecAsynRegistrar(void)
 {
     ellInit(&sampler_configs);
     iocshRegister(&InitFuncDef,InitCallFunc);
     iocshRegister(&SamplerFuncDef,SamplerCallFunc);
     iocshRegister(&showPdoFuncDef,showPdoCallFunc);
 }
Exemple #12
0
/*
 * Driver initialisation at IOC startup (ecAsynInit)
 *
 * path - location of Unix Domain Socket, must match the scanner's
 * max_message - maximum size of messages between scanner and ioc
 *               This must be able to accommodate the configuration
 *               of the chain that is transferred from the scanner to
 *               the ioc.
 */
static void makePorts(char * path, int max_message)
{
    ENGINE_USER * usr = (ENGINE_USER *)callocMustSucceed
        (1, sizeof(ENGINE_USER), "can't allocate socket engine private data");
    ellInit(&usr->ports);
    usr->master = new ecMaster((char *)"MASTER0");
    ellAdd(&usr->ports, &usr->master->node);
    usr->config_ready = rtMessageQueueCreate(1, sizeof(int));
    // TODO - no assert for runtime errors, so what should we use to throw?
    assert(usr->config_ready != NULL);
    usr->config = (EC_CONFIG *)callocMustSucceed
        (1, sizeof(EC_CONFIG), "can't allocate chain config lists");
    usr->writeq = rtMessageQueueCreate(1, max_message);
    assert(usr->writeq != NULL);
    ENGINE * engine = new_engine(max_message);
    engine->path = strdup(path);
    engine->connect = client_connect;
    engine->on_connect = receive_config_on_connect;
    engine->send_message = ioc_send;
    engine->receive_message = ioc_receive;
    engine->usr = usr;
    engine_start(engine);

    new_timer(1000000000, usr->writeq, 0, MSG_HEARTBEAT);

    int ack;
    rtMessageQueueReceive(usr->config_ready, &ack, sizeof(int));

}
/* epicsShareFunc int drvSNMPConnInit(const char *version, const char *hostaddr, const char *username, const char *authpass, const char*privpass) */
epicsShareFunc int drvSNMPConnInit(char *version, char *hostaddr, char *username, char *authpass, char*privpass)
{
  printf("------------------------------------------------\n");
  printf("degug line\n");
  printf("------------------------------------------------\n");
  printf("version: %s, hostaddr: %s, username: %s, authpass: %s, privpass: %s\n", 
	 version, hostaddr, username, authpass, privpass);
  printf("------------------------------------------------\n");

  
  snmpinfo = (SNMP_INFO *)malloc(sizeof(SNMP_INFO));

  strcpy(&snmpinfo->version, version);
  strcpy(&snmpinfo->hostaddr, hostaddr);
  strcpy(&snmpinfo->username, username);
  strcpy(&snmpinfo->authpass, authpass);
  strcpy(&snmpinfo->privpass, privpass);
  strcpy(&snmpinfo->msg,"Test Message");

  gsnmpInfo = snmpinfo;
  memcpy(gsnmpInfo, snmpinfo, sizeof(SNMP_INFO));

  printf("version: %s, hostaddr: %s, username: %s, authpass: %s, privpass: %s\n",
  	 snmpinfo->version, snmpinfo->hostaddr, snmpinfo->username, snmpinfo->authpass, snmpinfo->privpass);

  ellInit(&devSNMPList);
  epicsThreadCreate("drvSNMPConnInit", epicsThreadPriorityHigh, epicsThreadGetStackSize(epicsThreadStackSmall),
		    (EPICSTHREADFUNC)devSNMPScanThread,NULL);

  return 0;
};
Exemple #14
0
void epicsShareAPI dbPutNotifyInit(void)
{
    if(pnotifyGlobal) return;
    pnotifyGlobal = dbCalloc(1,sizeof(notifyGlobal));
    pnotifyGlobal->lock = epicsMutexMustCreate();
    ellInit(&pnotifyGlobal->freeList);
}
Exemple #15
0
static void initPeriodic(void)
{
    dbMenu *pmenu = dbFindMenu(pdbbase, "menuScan");
    double quantum = epicsThreadSleepQuantum();
    int i;

    if (!pmenu) {
        errlogPrintf("initPeriodic: menuScan not present\n");
        return;
    }
    nPeriodic = pmenu->nChoice - SCAN_1ST_PERIODIC;
    papPeriodic = dbCalloc(nPeriodic, sizeof(periodic_scan_list*));
    periodicTaskId = dbCalloc(nPeriodic, sizeof(void *));
    for (i = 0; i < nPeriodic; i++) {
        periodic_scan_list *ppsl = dbCalloc(1, sizeof(periodic_scan_list));
        const char *choice = pmenu->papChoiceValue[i + SCAN_1ST_PERIODIC];
        double number;
        char *unit;
        int status = epicsParseDouble(choice, &number, &unit);

        ppsl->scan_list.lock = epicsMutexMustCreate();
        ellInit(&ppsl->scan_list.list);
        ppsl->name = choice;
        if (status || number == 0) {
            errlogPrintf("initPeriodic: Bad menuScan choice '%s'\n", choice);
            ppsl->period = i;
        }
        else if (!*unit ||
                 !epicsStrCaseCmp(unit, "second") ||
                 !epicsStrCaseCmp(unit, "seconds")) {
            ppsl->period = number;
        }
        else if (!epicsStrCaseCmp(unit, "minute") ||
                 !epicsStrCaseCmp(unit, "minutes")) {
            ppsl->period = number * 60;
        }
        else if (!epicsStrCaseCmp(unit, "hour") ||
                 !epicsStrCaseCmp(unit, "hours")) {
            ppsl->period = number * 60 * 60;
        }
        else if (!epicsStrCaseCmp(unit, "Hz") ||
                 !epicsStrCaseCmp(unit, "Hertz")) {
            ppsl->period = 1 / number;
        }
        else {
            errlogPrintf("initPeriodic: Bad menuScan choice '%s'\n", choice);
            ppsl->period = i;
        }
        number = ppsl->period / quantum;
        if ((ppsl->period < 2 * quantum) ||
            (number / floor(number) > 1.1)) {
            errlogPrintf("initPeriodic: Scan rate '%s' is not achievable.\n",
                choice);
        }
        ppsl->scanCtl = ctlPause;
        ppsl->loopEvent = epicsEventMustCreate(epicsEventEmpty);

        papPeriodic[i] = ppsl;
    }
}
Exemple #16
0
static exitPvt * createExitPvt(void)
{
    exitPvt * pep = calloc ( 1, sizeof ( * pep ) );
    if ( pep ) {
        ellInit ( &pep->list );
    }
    return pep;
}
Exemple #17
0
/*internal methods */
static void gpibInit(void)
{
    if(pgpibBase) return;
    pgpibBase = callocMustSucceed(1,sizeof(gpibPvt),"gpibInit");
    ellInit(&pgpibBase->gpibPvtList);
    pgpibBase->timerQueue = epicsTimerQueueAllocate(
        1,epicsThreadPriorityScanLow);
}
Exemple #18
0
static drvM6802_taskConfig* make_taskConfig(char *taskName, uint16 vme_addr)
{
	static uint16 boardcnt = 1;
	drvM6802_taskConfig *ptaskConfig = NULL;
	char task_name[60];
	int i;

	strcpy(task_name, taskName);

	ptaskConfig = (drvM6802_taskConfig*) malloc(sizeof(drvM6802_taskConfig));
	if(!ptaskConfig) return ptaskConfig;


	ptaskConfig->BoardID = boardcnt;
	ptaskConfig->vme_addr = vme_addr;
	strcpy(ptaskConfig->taskName, task_name);
	ptaskConfig->taskLock = epicsMutexCreate();
	ptaskConfig->bufferLock = epicsMutexCreate();
	scanIoInit(&ptaskConfig->ioScanPvt);
/*	ptaskConfig->masterMode = 0; */
	ptaskConfig->masterMode = ( ptaskConfig->BoardID == 1 ) ? 1 : 0;
	ptaskConfig->samplingRate = INIT_SAMPLING;
	ptaskConfig->appSampleRate = INIT_SAMPLING;
	ptaskConfig->channelMask = INIT_CH_MASK;
	ptaskConfig->clockSource = (ptaskConfig->BoardID == 1) ? 0 : 1; /* default 0 : internal clock ,  1: external*/
/*	ptaskConfig->msgFPDP	=	0; */
	ptaskConfig->cnt_DMAcallback = 0;
	ptaskConfig->nTrigPolarity = INIT_TRIG_POLARITY;
/*	ptaskConfig->pcallback = (CALLBACK*) taskCallback; */
	ptaskConfig->fT0 = 1.;
	ptaskConfig->fT1 = 2.;

	boardcnt++;

	ptaskConfig->pcontrolThreadConfig = NULL;
	ptaskConfig->pfpdpThreadConfig = NULL;


	for( i=0; i< 16 ; i++) 
		ptaskConfig->register_m6802[i] = DUMMY_DATA;

	ptaskConfig->adjTime_smplRate_Usec = 0.;
	ptaskConfig->adjTime_Gain_Usec = 0.;

	ptaskConfig->adjCount_smplRate = 0;
	ptaskConfig->adjCount_Gain = 0;


	ptaskConfig->pchannelConfig = (ELLLIST*) malloc(sizeof(ELLLIST));
	if(!ptaskConfig->pchannelConfig) return NULL;
	else ellInit(ptaskConfig->pchannelConfig);

	ptaskConfig->taskStatus = TASK_NOT_INIT;

	return ptaskConfig;

}
void testHarness(void) {
    epicsThreadOnce(&onceFlag, testOnce, NULL);
    epicsAtExit(harnessExit, NULL);
    Harness = 1;
    Programs = 0;
    Tests = 0;
    ellInit(&faults);
    epicsTimeGetCurrent(&started);
}
Exemple #20
0
bufRxManager::bufRxManager(const std::string& n, unsigned int qdepth, unsigned int bsize)
  :dataBufRx(n)
  ,guard()
  ,onerror(defaulterr)
  ,onerror_arg(NULL)
  ,m_bsize(bsize ? bsize : 2048)
{
    ellInit(&dispatch);
    ellInit(&freebufs);
    ellInit(&usedbufs);

    CBINIT(&received_cb, priorityMedium, &bufRxManager::received, this);

    for(unsigned int i=0; i<qdepth; i++) {
        buffer *t=(buffer*)callocMustSucceed(1, sizeof(buffer)-1+m_bsize, "bufRxManager buffer");
        ellAdd(&freebufs, &t->node);
    }
}
Exemple #21
0
void epicsShareAPI dbPutNotify(putNotify *ppn)
{
    dbCommon	*precord = ppn->paddr->precord;
    short	dbfType = ppn->paddr->field_type;
    long	status=0;
    putNotifyPvt *pputNotifyPvt;

    assert(precord);
    /*check for putField disabled*/
    if(precord->disp) {
        if((void *)(&precord->disp) != ppn->paddr->pfield) {
           ppn->status = putNotifyPutDisabled;
           (*ppn->userCallback)(ppn);
           return;
        }
    }
    /* Must handle DBF_XXXLINKs as special case.
     * Only dbPutField will change link fields. 
     * Also the record is not processed as a result
    */
    if(dbfType>=DBF_INLINK && dbfType<=DBF_FWDLINK) {
	status=dbPutField(ppn->paddr,ppn->dbrType,ppn->pbuffer,ppn->nRequest);
        ppn->status = (status==0) ? putNotifyOK : putNotifyError;
        (*ppn->userCallback)(ppn);
        return;
    }
    dbScanLock(precord);
    epicsMutexMustLock(pnotifyGlobal->lock);
    pputNotifyPvt = (putNotifyPvt *)ppn->pputNotifyPvt;
    if(pputNotifyPvt && (pputNotifyPvt->magic!=MAGIC)) {
        printf("dbPutNotify:pputNotifyPvt was not initialized\n");
        pputNotifyPvt = 0;
    }
    if(pputNotifyPvt) {
        assert(pputNotifyPvt->state==putNotifyUserCallbackActive);
        pputNotifyPvt->userCallbackWait = 1;
        epicsMutexUnlock(pnotifyGlobal->lock);
        dbScanUnlock(precord);
        epicsEventWait(pputNotifyPvt->userCallbackEvent);
        dbScanLock(precord);
        epicsMutexMustLock(pnotifyGlobal->lock);
        putNotifyCleanup(ppn);
    }
    pputNotifyPvt = (putNotifyPvt *)ppn->pputNotifyPvt;
    assert(!pputNotifyPvt);
    putNotifyInit(ppn);
    pputNotifyPvt = (putNotifyPvt *)ppn->pputNotifyPvt;
    if(!precord->ppnr) {/* make sure record has a putNotifyRecord*/
        precord->ppnr = dbCalloc(1,sizeof(putNotifyRecord));
        precord->ppnr->precord = precord;
        ellInit(&precord->ppnr->restartList);
    }
    putNotifyCommon(ppn,precord);
}
Exemple #22
0
/*
 *  devLibInit()
 */
static long devLibInit (void)
{
    rangeItem   *pRange;
    int 	i;


    if(devLibInitFlag) return(SUCCESS);
    if(!pdevLibVME) {
        epicsPrintf ("pdevLibVME is NULL\n");
        return S_dev_internal;
    }

    if (NELEMENTS(addrAlloc) != NELEMENTS(addrFree)) {
        return S_dev_internal;
    }

    addrListLock = epicsMutexMustCreate();

    epicsMutexMustLock(addrListLock);
    for (i=0; i<NELEMENTS(addrAlloc); i++) {
        ellInit (&addrAlloc[i]);
        ellInit (&addrFree[i]);
    }

    for (i=0; i<NELEMENTS(addrAlloc); i++) {
        pRange = (rangeItem *) malloc (sizeof(*pRange));
        if (!pRange) {
            return S_dev_noMemory;
        }
        pRange->pOwnerName = "<Vacant>";
        pRange->pPhysical = NULL;
        pRange->begin = 0;
        pRange->end = addrLast[i];
        ellAdd (&addrFree[i], &pRange->node);
    }
    epicsMutexUnlock(addrListLock);
    devLibInitFlag = TRUE;
    return pdevLibVME->pDevInit();
}
Exemple #23
0
static int make_drvConfig(uint16 vme_addr)
{
/*	static int cnt = 0;
	epicsPrintf(">>>>> call make_drvConfig cnt : %d\n", cnt);
	cnt++;
*/
/* just call only once */

	if(pdrvM6802Config) return 0;

/*	epicsPrintf(">>>>> %d\n", cnt);	*/
	

	pdrvM6802Config = (drvM6802Config*) malloc(sizeof(drvM6802Config));
	if(!pdrvM6802Config) return 1;

	pdrvBufferConfig = (drvBufferConfig*) malloc(sizeof(drvBufferConfig));
	if(!pdrvBufferConfig) return 1;

	pdrvM6802Config->openBus = 0;
	if( ozInitDevice( vme_addr ) == ERROR ) return 0;
	else epicsPrintf("\n>>> make_drvConfig(0x%04X) : ozInitDevice .... OK\n", vme_addr);
	pdrvM6802Config->openBus = 1;


	pdrvM6802Config->ptaskList = (ELLLIST*) malloc(sizeof(ELLLIST));
	if(!pdrvM6802Config->ptaskList) return 1;
	else ellInit(pdrvM6802Config->ptaskList);


	pdrvBufferConfig->pbufferList = (ELLLIST*) malloc(sizeof(ELLLIST));
	if(!pdrvBufferConfig->pbufferList) return 1;
	else ellInit(pdrvBufferConfig->pbufferList);



	return 0;
}
Exemple #24
0
bool addToList(const char *portName, PMCVController *drv) {
    if (!PMCVListInitialized) {
        PMCVListInitialized = 1;
        ellInit(&PMCVList);
    } else if (findByPortName(portName) != NULL) {
        fprintf(stderr, "ERROR: Re-using portName=%s\n", portName);
        return false;
    }

    PMCVNode *pNode = (PMCVNode*)calloc(1, sizeof(PMCVNode));
    pNode->portName = epicsStrDup(portName);
    pNode->pController = drv;
    ellAdd(&PMCVList, (ELLNODE*)pNode);
    return true;
}
epicsShareFunc epicsMessageQueueId epicsShareAPI epicsMessageQueueCreate(
    unsigned int capacity,
    unsigned int maxMessageSize)
{
    epicsMessageQueueId pmsg;
    unsigned int slotBytes, slotLongs;

    assert(capacity != 0);
    pmsg = (epicsMessageQueueId)callocMustSucceed(1, sizeof(*pmsg), "epicsMessageQueueCreate");
    pmsg->capacity = capacity;
    pmsg->maxMessageSize = maxMessageSize;
    slotLongs = 1 + ((maxMessageSize + sizeof(unsigned long) - 1) / sizeof(unsigned long));
    slotBytes = slotLongs * sizeof(unsigned long);
    pmsg->buf = (unsigned long *)callocMustSucceed(pmsg->capacity, slotBytes, "epicsMessageQueueCreate");
    pmsg->inPtr = pmsg->outPtr = pmsg->firstMessageSlot = (char *)&pmsg->buf[0];
    pmsg->lastMessageSlot = (char *)&pmsg->buf[(capacity - 1) * slotLongs];
    pmsg->full = false;
    pmsg->slotSize = slotBytes;
    pmsg->mutex = epicsMutexMustCreate();
    ellInit(&pmsg->sendQueue);
    ellInit(&pmsg->receiveQueue);
    ellInit(&pmsg->eventFreeList);
    return pmsg;
}
Exemple #26
0
static void dbRecordtypeHead(char *name)
{
    dbRecordType		*pdbRecordType;
    GPHENTRY		*pgphentry;

    pgphentry = gphFind(pdbbase->pgpHash,name,&pdbbase->recordTypeList);
    if(pgphentry) {
	duplicate = TRUE;
	return;
    }
    pdbRecordType = dbCalloc(1,sizeof(dbRecordType));
    pdbRecordType->name = epicsStrDup(name);
    if (pdbbase->loadCdefs) ellInit(&pdbRecordType->cdefList);
    if(ellCount(&tempList))
	yyerrorAbort("dbRecordtypeHead tempList not empty");
    allocTemp(pdbRecordType);
}
Exemple #27
0
void scanIoInit(IOSCANPVT *pioscanpvt)
{
    ioscan_head *piosh = dbCalloc(1, sizeof(ioscan_head));
    int prio;

    ioscanInit();
    for (prio = 0; prio < NUM_CALLBACK_PRIORITIES; prio++) {
        io_scan_list *piosl = &piosh->iosl[prio];

        callbackSetCallback(ioscanCallback, &piosl->callback);
        callbackSetPriority(prio, &piosl->callback);
        callbackSetUser(piosh, &piosl->callback);
        ellInit(&piosl->scan_list.list);
        piosl->scan_list.lock = epicsMutexMustCreate();
    }
    epicsMutexMustLock(ioscan_lock);
    piosh->next = pioscan_list;
    pioscan_list = piosh;
    epicsMutexUnlock(ioscan_lock);
    *pioscanpvt = piosh;
}
Exemple #28
0
static void twdInitOnce(void *arg)
{
    epicsThreadId tid;

    tLock = epicsMutexMustCreate();
    mLock = epicsMutexMustCreate();
    fLock = epicsMutexMustCreate();
    ellInit(&fList);
    VALGRIND_CREATE_MEMPOOL(&fList, 0, 0);

    twdCtl = twdctlRun;
    loopEvent = epicsEventMustCreate(epicsEventEmpty);
    exitEvent = epicsEventMustCreate(epicsEventEmpty);

    tid = epicsThreadCreate("taskwd", epicsThreadPriorityLow,
         epicsThreadGetStackSize(epicsThreadStackSmall),
         twdTask, NULL);
    if (tid == 0)
        cantProceed("Failed to spawn task watchdog thread\n");

    epicsAtExit(twdShutdown, NULL);
}
Exemple #29
0
GPHENTRY * epicsShareAPI gphAdd(gphPvt *pgphPvt, const char *name, void *pvtid)
{
    ELLLIST **paplist;
    ELLLIST *plist;
    GPHENTRY *pgphNode;
    int hash;

    if (pgphPvt == NULL) return NULL;
    paplist = pgphPvt->paplist;
    hash = epicsMemHash((char *)&pvtid, sizeof(void *), 0);
    hash = epicsStrHash(name, hash) & pgphPvt->mask;

    epicsMutexMustLock(pgphPvt->lock);
    plist = paplist[hash];
    if (plist == NULL) {
        plist = callocMustSucceed(1, sizeof(ELLLIST), "gphAdd");
        ellInit(plist);
        paplist[hash] = plist;
    }

    pgphNode = (GPHENTRY *) ellFirst(plist);
    while (pgphNode) {
        if (pvtid == pgphNode->pvtid &&
                strcmp(name, pgphNode->name) == 0) {
            epicsMutexUnlock(pgphPvt->lock);
            return NULL;
        }
        pgphNode = (GPHENTRY *) ellNext((ELLNODE *)pgphNode);
    }

    pgphNode = callocMustSucceed(1, sizeof(GPHENTRY), "gphAdd");
    pgphNode->name = name;
    pgphNode->pvtid = pvtid;
    ellAdd(plist, (ELLNODE *)pgphNode);

    epicsMutexUnlock(pgphPvt->lock);
    return (pgphNode);
}
static void substituteOpen(void **ppvt,char *substitutionName)
{
    subInfo	*psubInfo;
    subFile	*psubFile;
    FILE	*fp;

    psubInfo = calloc(1,sizeof(subInfo));
    *ppvt = (void *)psubInfo;
    psubFile = calloc(1,sizeof(subFile));
    psubInfo->psubFile = psubFile;
    ellInit(&psubInfo->patternList);
    fp = fopen(substitutionName,"r");
    if(!fp) {
	fprintf(stderr,"Could not open %s\n",substitutionName);
        exit(1);
    }
    psubFile->substitutionName = substitutionName;
    psubFile->fp = fp;
    psubFile->lineNum = 0;
    psubFile->inputBuffer[0] = 0;
    psubFile->pnextChar = &psubFile->inputBuffer[0];
    subGetNextToken(psubFile);
    return;
}