Modify aai to support pass-1 device initialization

The Soft Channel device support requests pass-1 initialization.
It no longer needs to initialize the INP link or allocate the
array buffer itself, these are taken care of elsewhere.

The record code uses PACT to remember that the device must be
initialized again in pass 1.
This commit is contained in:
Andrew Johnson
2021-02-27 22:08:50 -06:00
parent 4a0f488657
commit 1c566e2110
2 changed files with 21 additions and 15 deletions

View File

@@ -47,19 +47,15 @@ static long init_record(dbCommon *pcommon)
aaiRecord *prec = (aaiRecord *)pcommon;
DBLINK *plink = &prec->inp;
/* This is pass 0, link hasn't been initialized yet */
dbInitLink(plink, DBF_INLINK);
/* Ask record to call us in pass 1 instead */
if (prec->pact != 2) {
return 2;
}
if (dbLinkIsConstant(plink)) {
long nRequest = prec->nelm;
long status;
/* Allocate a buffer, record support hasn't done that yet */
if (!prec->bptr) {
prec->bptr = callocMustSucceed(nRequest, dbValueSize(prec->ftvl),
"devAaiSoft: buffer calloc failed");
}
status = dbLoadLinkArray(plink, prec->ftvl, prec->bptr, &nRequest);
if (!status) {
prec->nord = nRequest;

View File

@@ -112,16 +112,18 @@ static long init_record(struct dbCommon *pcommon, int pass)
prec->ftvl = DBF_UCHAR;
prec->nord = (prec->nelm == 1);
/* we must call pdset->init_record in pass 0
because it may set prec->bptr which must
not change after links are established before pass 1
*/
/* call pdset->init_record() in pass 0 so it can do its own
* memory allocation and set prec->bptr, which must be set by
* the end of pass 0.
*/
if (pdset->common.init_record) {
long status = pdset->common.init_record(pcommon);
/* init_record may set the bptr to point to the data */
if (status)
if (status == 2) {
/* requesting pass 1 callback, remember to do that */
prec->pact = 2;
}
else if (status)
return status;
}
if (!prec->bptr) {
@@ -132,6 +134,14 @@ static long init_record(struct dbCommon *pcommon, int pass)
return 0;
}
if (prec->pact == 2) {
/* device support asked for an init_record() callback in pass 1 */
long status = pdset->common.init_record(pcommon);
if (status)
return status;
prec->pact = FALSE;
}
recGblInitSimm(pcommon, &prec->sscn, &prec->oldsimm, &prec->simm, &prec->siml);
/* must have read_aai function defined */