static long init_record(mbbiDirectRecord *pmbbiDirect) { struct link *plink = &pmbbiDirect->inp; int size; char *buf; char *pC; F3RP61_MBBIDIRECT_DPVT *dpvt; M3IO_ACCESS_COM *pacom; M3IO_ACCESS_REG *pdrly; int unitno, slotno, cpuno, start; char device; if (pmbbiDirect->inp.type != INST_IO) { recGblRecordError(S_db_badField,(void *)pmbbiDirect, "devMbbiDirectF3RP61 (init_record) Illegal INP field"); pmbbiDirect->pact = 1; return(S_db_badField); } size = strlen(plink->value.instio.string) + 1; buf = (char *) callocMustSucceed(size, sizeof(char), "calloc failed"); strncpy(buf, plink->value.instio.string, size); buf[size - 1] = '\0'; pC = strchr(buf, ':'); if (pC) { *pC++ = '\0'; if (sscanf(pC, "U%d,S%d,X%d", &unitno, &slotno, &start) < 3) { errlogPrintf("devMbbiDirectF3RP61: can't get interrupt source address for %s\n", pmbbiDirect->name); pmbbiDirect->pact = 1; return (-1); } if (f3rp61_register_io_interrupt((dbCommon *) pmbbiDirect, unitno, slotno, start) < 0) { errlogPrintf("devMbbiDirectF3RP61: can't register I/O interrupt for %s\n", pmbbiDirect->name); pmbbiDirect->pact = 1; return (-1); } } if (sscanf(buf, "U%d,S%d,%c%d", &unitno, &slotno, &device, &start) < 4) { if (sscanf(buf, "CPU%d,R%d", &cpuno, &start) < 2) { if (sscanf(buf, "%c%d", &device, &start) < 2) { errlogPrintf("devMbbiDirectF3RP61: can't get I/O address for %s\n", pmbbiDirect->name); pmbbiDirect->pact = 1; return (-1); } else if (device != 'W' && device != 'L' && device != 'R' && device != 'E') { errlogPrintf("devMbbiDirectF3RP61: unsupported device \'%c\' for %s\n", device, pmbbiDirect->name); pmbbiDirect->pact = 1; return (-1); } } else { device = 'r'; } } if (!(device == 'X' || device == 'Y' || device == 'A' || device == 'r' || device == 'W' || device == 'L' || device == 'M' || device == 'R' || device == 'E')) { errlogPrintf("devMbbiDirectF3RP61: illegal I/O address for %s\n", pmbbiDirect->name); pmbbiDirect->pact = 1; return (-1); } dpvt = (F3RP61_MBBIDIRECT_DPVT *) callocMustSucceed(1, sizeof(F3RP61_MBBIDIRECT_DPVT), "calloc failed"); dpvt->device = device; if (device == 'r') { pacom = &dpvt->u.acom; pacom->cpuno = (unsigned short) cpuno; pacom->start = (unsigned short) start; pacom->count = (unsigned short) 1; } else if (device == 'W' || device == 'L' || device == 'R' || device == 'E') { pacom = &dpvt->u.acom; pacom->start = (unsigned short) start; } else { pdrly = &dpvt->u.drly; pdrly->unitno = (unsigned short) unitno; pdrly->slotno = (unsigned short) slotno; pdrly->start = (unsigned short) start; pdrly->count = (unsigned short) 1; } pmbbiDirect->dpvt = dpvt; return(0); }
static long init_record(longinRecord *plongin) { struct link *plink = &plongin->inp; int size; char *buf; char *pC; F3RP61_LI_DPVT *dpvt; M3IO_ACCESS_COM *pacom; M3IO_ACCESS_REG *pdrly; int unitno, slotno, cpuno, start; char device; char option = 'W'; int uword = 0; int lng = 0; int BCD = 0; if (plongin->inp.type != INST_IO) { recGblRecordError(S_db_badField,(void *)plongin, "devLiF3RP61 (init_record) Illegal INP field"); plongin->pact = 1; return(S_db_badField); } size = strlen(plink->value.instio.string) + 1; buf = (char *) callocMustSucceed(size, sizeof(char), "calloc failed"); strncpy(buf, plink->value.instio.string, size); buf[size - 1] = '\0'; /* Parse option*/ pC = strchr(buf, '&'); if (pC) { *pC++ = '\0'; if (sscanf(pC, "%c", &option) < 1) { errlogPrintf("devLiF3RP61: can't get option for %s\n", plongin->name); plongin->pact = 1; return (-1); } if (option == 'U') { uword = 1; /* uword flag is used for the possible double option case */ } else if (option == 'L') { lng = 1; } else if (option == 'B') { BCD = 1; /* flag is used for the possible double/triple option case */ } else { /* Option not recognized*/ errlogPrintf("devLiF3RP61: illegal option for %s\n", plongin->name); plongin->pact = 1; return (-1); } } /* Parse for possible interrupt source*/ pC = strchr(buf, ':'); if (pC) { *pC++ = '\0'; if (sscanf(pC, "U%d,S%d,X%d", &unitno, &slotno, &start) < 3) { errlogPrintf("devLiF3RP61: can't get interrupt source address for %s\n", plongin->name); plongin->pact = 1; return (-1); } if (f3rp61_register_io_interrupt((dbCommon *) plongin, unitno, slotno, start) < 0) { errlogPrintf("devLiF3RP61: can't register I/O interrupt for %s\n", plongin->name); plongin->pact = 1; return (-1); } } /* Parse device*/ if (sscanf(buf, "U%d,S%d,%c%d", &unitno, &slotno, &device, &start) < 4) { if (sscanf(buf, "CPU%d,R%d", &cpuno, &start) < 2) { if (sscanf(buf, "%c%d", &device, &start) < 2) { errlogPrintf("devLiF3RP61: can't get I/O address for %s\n", plongin->name); plongin->pact = 1; return (-1); } else if (device != 'W' && device != 'R') { errlogPrintf("devLiF3RP61: unsupported device \'%c\' for %s\n", device, plongin->name); plongin->pact = 1; } } else { device = 'r'; /* Corresponds to accessing shared memory using 'Old Interface'*/ } } /* Check device validity*/ if (!(device == 'X' || device == 'Y' || device == 'A' || device == 'r' || device == 'W' || device == 'R')) { errlogPrintf("devLiF3RP61: illegal I/O address for %s\n", plongin->name); plongin->pact = 1; return (-1); } /* Create private data storage area*/ dpvt = (F3RP61_LI_DPVT *) callocMustSucceed(1, sizeof(F3RP61_LI_DPVT), "calloc failed"); dpvt->device = device; dpvt->option = option; dpvt->uword = uword; dpvt->lng = lng; dpvt->BCD = BCD; if (device == 'r') { /* Shared registers - Using 'Old' interface*/ pacom = &dpvt->u.acom; pacom->cpuno = (unsigned short) cpuno; pacom->start = (unsigned short) start; pacom->count = (unsigned short) 1; } else if (device == 'W' || device == 'R') { /* Shared registers - Using 'New' interface*/ pacom = &dpvt->u.acom; pacom->start = (unsigned short) start; switch (option) { case 'L': pacom->count = 2; break; default: pacom->count = 1; } } else { /* Registers and I/Os of specific modules (X, Y and A)*/ pdrly = &dpvt->u.drly; pdrly->unitno = (unsigned short) unitno; pdrly->slotno = (unsigned short) slotno; pdrly->start = (unsigned short) start; pdrly->count = (unsigned short) 1; } plongin->dpvt = dpvt; return(0); }
static long init_record(longinRecord *plongin) { struct link *plink = &plongin->inp; int size; char *buf; char *pC; F3RP61_LI_DPVT *dpvt; M3IO_ACCESS_COM *pacom; M3IO_ACCESS_REG *pdrly; int unitno, slotno, cpuno, start; char device; char option = 'W'; int uword = 0; if (plongin->inp.type != INST_IO) { recGblRecordError(S_db_badField,(void *)plongin, "devLiF3RP61 (init_record) Illegal INP field"); plongin->pact = 1; return(S_db_badField); } size = strlen(plink->value.instio.string) + 1; buf = (char *) callocMustSucceed(size, sizeof(char), "calloc failed"); strncpy(buf, plink->value.instio.string, size); buf[size - 1] = '\0'; pC = strchr(buf, '&'); if (pC) { *pC++ = '\0'; if (sscanf(pC, "%c", &option) < 1) { errlogPrintf("devLiF3RP61: can't get option for %s\n", plongin->name); plongin->pact = 1; return (-1); } if (option == 'U') { uword = 1; /* uword flag is used for the possible double option case */ } } pC = strchr(buf, ':'); if (pC) { *pC++ = '\0'; if (sscanf(pC, "U%d,S%d,X%d", &unitno, &slotno, &start) < 3) { errlogPrintf("devLiF3RP61: can't get interrupt source address for %s\n", plongin->name); plongin->pact = 1; return (-1); } if (f3rp61_register_io_interrupt((dbCommon *) plongin, unitno, slotno, start) < 0) { errlogPrintf("devLiF3RP61: can't register I/O interrupt for %s\n", plongin->name); plongin->pact = 1; return (-1); } } if (sscanf(buf, "U%d,S%d,%c%d", &unitno, &slotno, &device, &start) < 4) { if (sscanf(buf, "CPU%d,R%d", &cpuno, &start) < 2) { if (sscanf(buf, "%c%d", &device, &start) < 2) { errlogPrintf("devLiF3RP61: can't get I/O address for %s\n", plongin->name); plongin->pact = 1; return (-1); } else if (device != 'W' && device != 'R') { errlogPrintf("devLiF3RP61: unsupported device \'%c\' for %s\n", device, plongin->name); plongin->pact = 1; } } else { device = 'r'; } } if (!(device == 'X' || device == 'Y' || device == 'A' || device == 'r' || device == 'W' || device == 'R')) { errlogPrintf("devLiF3RP61: illegal I/O address for %s\n", plongin->name); plongin->pact = 1; return (-1); } if (!(option == 'W' || option == 'L' || option == 'U')) { errlogPrintf("devLiF3RP61: illegal option for %s\n", plongin->name); plongin->pact = 1; return (-1); } dpvt = (F3RP61_LI_DPVT *) callocMustSucceed(1, sizeof(F3RP61_LI_DPVT), "calloc failed"); dpvt->device = device; dpvt->option = option; dpvt->uword = uword; if (device == 'r') { pacom = &dpvt->u.acom; pacom->cpuno = (unsigned short) cpuno; pacom->start = (unsigned short) start; pacom->count = (unsigned short) 1; } else if (device == 'W' || device == 'R') { pacom = &dpvt->u.acom; pacom->start = (unsigned short) start; switch (option) { case 'L': pacom->count = 2; break; default: pacom->count = 1; } } else { pdrly = &dpvt->u.drly; pdrly->unitno = (unsigned short) unitno; pdrly->slotno = (unsigned short) slotno; pdrly->start = (unsigned short) start; pdrly->count = (unsigned short) 1; } plongin->dpvt = dpvt; return(0); }
static long init_record(stringinRecord *psi) { struct link *plink = &psi->inp; int size; char *buf; char *pC; F3RP61_SI_DPVT *dpvt; M3IO_ACCESS_REG *pdrly; int unitno, slotno, start; char device; /* si.inp must be an INST_IO */ if (psi->inp.type != INST_IO) { recGblRecordError(S_db_badField,(void *)psi, "devSiF3RP61 (init_record) Illegal INP field"); psi->pact = 1; return(S_db_badField); } size = strlen(plink->value.instio.string) + 1; buf = (char *) callocMustSucceed(size, sizeof(char), "calloc failed"); strncpy(buf, plink->value.instio.string, size); buf[size - 1] = '\0'; pC = strchr(buf, ':'); if (pC) { *pC++ = '\0'; if (sscanf(pC, "U%d,S%d,X%d", &unitno, &slotno, &start) < 3) { errlogPrintf("devSiF3RP61: can't get interrupt source address for %s\n", psi->name); psi->pact = 1; return (-1); } if (f3rp61_register_io_interrupt((dbCommon *) psi, unitno, slotno, start) < 0) { errlogPrintf("devSiF3RP61: can't register I/O interrupt for %s\n", psi->name); psi->pact = 1; return (-1); } } if (sscanf(buf, "U%d,S%d,%c%d", &unitno, &slotno, &device, &start) < 4) { errlogPrintf("devSiF3RP61: can't get I/O address for %s\n", psi->name); psi->pact = 1; return (-1); } if (!(device == 'A')) { errlogPrintf("devSiF3RP61: illegal I/O address for %s\n", psi->name); psi->pact = 1; return (-1); } dpvt = (F3RP61_SI_DPVT *) callocMustSucceed(1, sizeof(F3RP61_SI_DPVT), "calloc failed"); pdrly = &dpvt->drly; pdrly->unitno = (unsigned short) unitno; pdrly->slotno = (unsigned short) slotno; pdrly->start = (unsigned short) start; /* pdrly->u.pbdata = (unsigned char *) callocMustSucceed(40, sizeof(unsigned char), "calloc failed"); */ pdrly->u.pwdata = (unsigned short *) callocMustSucceed(40, sizeof(unsigned char), "calloc failed"); /* pdrly->count = (unsigned short) 40; */ pdrly->count = (unsigned short) 20; psi->dpvt = dpvt; return(0); }
/* Function init_record initializes record - parses INP/OUT field string, * allocates private data storage area and sets initial configure values */ static long init_record(mbboRecord *pmbbo) { struct link *plink = &pmbbo->out; int size; char *buf; char *pC; F3RP61_LO_DPVT *dpvt; M3IO_ACCESS_COM *pacom; M3IO_ACCESS_REG *pdrly; int unitno, slotno, cpuno, start; char device; /* bi.out link type must be an INST_IO */ if (pmbbo->out.type != INST_IO) { recGblRecordError(S_db_badField,(void *)pmbbo, "devMbboF3RP61 (init_record) Illegal OUT field"); pmbbo->pact = 1; return(S_db_badField); } size = strlen(plink->value.instio.string) + 1; buf = (char *) callocMustSucceed(size, sizeof(char), "calloc failed"); strncpy(buf, plink->value.instio.string, size); buf[size - 1] = '\0'; /* Parse for possible interrupt source*/ pC = strchr(buf, ':'); /* check if it is interrupt based (example: @U0,S3,Y1:U0,S4,X1)*/ if (pC) { *pC++ = '\0'; if (sscanf(pC, "U%d,S%d,X%d", &unitno, &slotno, &start) < 3) { errlogPrintf("devMbboF3RP61: can't get interrupt source address for %s\n", pmbbo->name); pmbbo->pact = 1; return (-1); } if (f3rp61_register_io_interrupt((dbCommon *) pmbbo, unitno, slotno, start) < 0) { errlogPrintf("devMbboF3RP61: can't register I/O interrupt for %s\n", pmbbo->name); pmbbo->pact = 1; return (-1); } } /* Parse device*/ if (sscanf(buf, "U%d,S%d,%c%d", &unitno, &slotno, &device, &start) < 4) { if (sscanf(buf, "CPU%d,R%d", &cpuno, &start) < 2) { if (sscanf(buf, "%c%d", &device, &start) < 2) { errlogPrintf("devMbboF3RP61: can't get I/O address for %s\n", pmbbo->name); pmbbo->pact = 1; return (-1); } else if (device != 'W' && device != 'L' && device != 'R' && device != 'E') { errlogPrintf("devMbboF3RP61: unsupported device \'%c\' for %s\n", device, pmbbo->name); pmbbo->pact = 1; return (-1); } } else { device = 'r'; } } /* Check device validity*/ if (!(device == 'Y' || device == 'A' || device == 'r' || device == 'W' || device == 'L' || device == 'M' || device == 'R' || device == 'E')) { errlogPrintf("devMbboF3RP61: illegal I/O address for %s\n", pmbbo->name); pmbbo->pact = 1; return (-1); } dpvt = (F3RP61_LO_DPVT *) callocMustSucceed(1, sizeof(F3RP61_LO_DPVT), "calloc failed"); dpvt->device = device; if (device == 'r') { pacom = &dpvt->u.acom; pacom->cpuno = (unsigned short) cpuno; pacom->start = (unsigned short) start; pacom->count = (unsigned short) 1; } else if (device == 'W' || device == 'L' || device == 'R' || device == 'E') { pacom = &dpvt->u.acom; pacom->start = (unsigned short) start; } else { pdrly = &dpvt->u.drly; pdrly->unitno = (unsigned short) unitno; pdrly->slotno = (unsigned short) slotno; pdrly->start = (unsigned short) start; pdrly->count = (unsigned short) 1; } pmbbo->dpvt = dpvt; return(0); }