/* Dweet app init */ EXPORTED void APP_DWEET_Init( void ) { boolean bInitSuccess = B_TRUE; /* init ETHMAC */ bInitSuccess &= ETHMAC_Init(); /* init IPv4 */ bInitSuccess &= IPV4_Init(); /* init DHCP */ bInitSuccess &= DHCP_Init(); if(bInitSuccess != B_TRUE) { /* TCP/IP module init fail! */ } else { /* TCP/IP module init success! */ /* allocate TX and RX data buffers */ pui8TXDataBufPtr = (uint8 *)MEM_MALLOC(US_TX_DATA_BUFFER_LENGTH); pui8RXDataBufPtr = (uint8 *)MEM_MALLOC(US_RX_DATA_BUFFER_LENGTH); /* connection status is in IDLE */ enConnStatus = KE_IDLE_STATE; } }
/* * XDR a list_t list of elements * offset - offset of list_node_t in list element * elsize - size of list element * elproc - XDR function for the list element */ bool_t smb_list_xdr(XDR *xdrs, list_t *list, const size_t offset, const size_t elsize, const xdrproc_t elproc) { void *node; uint32_t count = 0; switch (xdrs->x_op) { case XDR_ENCODE: node = list_head(list); while (node) { ++count; node = list_next(list, node); } if (!xdr_uint32_t(xdrs, &count)) return (FALSE); node = list_head(list); while (node) { if (!elproc(xdrs, node)) return (FALSE); node = list_next(list, node); } return (TRUE); case XDR_DECODE: if (!xdr_uint32_t(xdrs, &count)) return (FALSE); list_create(list, elsize, offset); while (count) { node = MEM_MALLOC("xdr", elsize); if (node == NULL) return (FALSE); if (!elproc(xdrs, node)) return (FALSE); list_insert_tail(list, node); --count; } return (TRUE); case XDR_FREE: while ((node = list_head(list)) != NULL) { list_remove(list, node); (void) elproc(xdrs, node); MEM_FREE("xdr", node); } list_destroy(list); return (TRUE); } return (FALSE); }
static void medmAcquisition(short *own_prot, int *devIOFunc, pioDevices *Cells, int *Nbcells, int *rep, int *ReqNo, int *NumberOfLists, int *listError, int tffunc) { int i, k, error; int finished; int ident_number; int nlists; int repetition; int listNo; int lisReqNo; int listDevices; char actFec[7], prvFec[7]; int indFec; int total[MAX_FECS]; static int prvNumcells = 0; int numlist = 0; static pioDevices *SortCells = (pioDevices *)0; static pioDevices *SendCells = (pioDevices *)0; static int *CellTaken = (int *)0; UNUSED(own_prot); repetition = *rep; ident_number = 1; lisReqNo = *ReqNo; nlists = 1; *NumberOfLists = 0; /* allocate memory */ if (*Nbcells != prvNumcells) { if (SortCells != (pioDevices *)0) MEM_FREE(SortCells); if (SendCells != (pioDevices *)0) MEM_FREE(SendCells); if (CellTaken != (int *)0) MEM_FREE(CellTaken); SortCells = (pioDevices *) MEM_MALLOC(*Nbcells *sizeof(pioDevices)); SendCells = (pioDevices *) MEM_MALLOC(*Nbcells *sizeof(pioDevices)); CellTaken = (int *) MEM_MALLOC(*Nbcells *sizeof(int)); prvNumcells = *Nbcells; } /* copy all cells into "sort" cells */ memcpy(SortCells, Cells, *Nbcells *sizeof(pioDevices)); for (i = 0; i < *Nbcells; i++) CellTaken[i] = False; /* qsort the cells according to the ioc */ qsort(SortCells, *Nbcells, sizeof(pioDevices), (int (*)(const void *, const void *))PIOcmpF); strcpy(prvFec, " "); prvFec[6] = '\0'; actFec[6] = '\0'; indFec = 0; total[0] = 0; finished = False; while (!finished) { k = 0; for (i = 0; i < *Nbcells; i++) { if (!CellTaken[i] && total[indFec] < MaxCellsPerFEC - 3) { CellTaken[i] = True; memcpy(&SendCells[k++], &SortCells[i], sizeof(pioDevices)); total[indFec]++; } memcpy(actFec, SortCells[i].fec, 6); if (i > 0 && PtrNull(strstr(prvFec, actFec))) { indFec++; total[indFec] = 0; // 16-2-2009 added if (!CellTaken[i]) { //printf("piosubs -- fec change <%.6s> <%.6s> copy cell %d\n", prvFec, actFec, i); CellTaken[i] = True; memcpy(&SendCells[k++], &SortCells[i], sizeof (pioDevices)); total[indFec]++; } } memcpy(prvFec, SortCells[i].fec, 6); } listDevices = k; listNo = lisReqNo; *listError = 1; if (listDevices > 0) { int maxfecs = MAX_FECS; int maxlists = MAX_LISTS; int repeat = 0; indFec++; /* one more fec when devices present, 20-11-2004 */ pioreq_execute_extended(&maxfecs, &maxlists, devIOFunc, &repeat, &listNo, &listnumber[indFec - 1], &listDevices, (allDevices *) SendCells, &numlist, infolist, &fecNamesD, &error, &ident_number, &tffunc, &nlists); *listError = error; /* fatal list error */ if (*listError < 1) { printf("medmAcquisition device io-error=%d on list=%d\n", *listError, listNo); return; } else { *NumberOfLists = *NumberOfLists + 1; lisReqNo++; } } /* are we through ? */ finished = True; for (i = 0; i < *Nbcells; i++) { if (!CellTaken[i]) { finished = False; break; } } indFec = 0; total[0] = 0; } }
int dat1GetBounds( const HDSLoc * locator, hdsdim lower[DAT__MXDIM], hdsdim upper[DAT__MXDIM], hdsbool_t * issubset, int *actdim, int * status ) { int rank = 0; hssize_t nblocks = 0; hsize_t *blockbuf = NULL; *actdim = 0; *issubset = 0; if (*status != SAI__OK) return *status; /* If the supplied locator has a dataspace, then use the bounds of the data space. This is done even if the object is a structure, since vectorised structure arrays will have a dataspace describing their vectorised extent. */ if( locator->dataspace_id ) { int i; hsize_t h5lower[DAT__MXDIM]; hsize_t h5upper[DAT__MXDIM]; hsize_t h5dims[DAT__MXDIM]; CALLHDFE( int, rank, H5Sget_simple_extent_dims( locator->dataspace_id, h5dims, NULL ), DAT__DIMIN, emsRep("datshape_1", "datShape: Error obtaining shape of object", status) ); /* If we are using datSlice then there should be one (and only one) hyperslab for the dataspace and we need to handle that. Should be same dimensionality as above. Negative number indicates there were no hyperslabs. */ if( H5Sget_select_type( locator->dataspace_id ) == H5S_SEL_HYPERSLABS ) { nblocks = H5Sget_select_hyper_nblocks( locator->dataspace_id ); } else { nblocks = 0; } if (nblocks == 1) { herr_t h5err = 0; *issubset = 1; blockbuf = MEM_MALLOC( nblocks * rank * 2 * sizeof(*blockbuf) ); CALLHDF( h5err, H5Sget_select_hyper_blocklist( locator->dataspace_id, 0, 1, blockbuf ), DAT__DIMIN, emsRep("datShape_2", "datShape: Error obtaining shape of slice", status ) ); /* We only go through one block. The buffer is returned in form: ndim start coordinates, then ndim opposite corner coordinates and repeats for each block (if we had more than one block). */ for (i = 0; i<rank; i++) { hsize_t start; hsize_t opposite; start = blockbuf[i]; opposite = blockbuf[i+rank]; /* So update the shape to account for the slice: HDS is 1-based */ h5lower[i] = start + 1; h5upper[i] = opposite + 1; } } else if (nblocks > 1) { if (*status == SAI__OK) { *status = DAT__WEIRD; emsRepf("datShape_2", "Unexpectedly got %zd hyperblocks from locator. Expected 1." " (possible programming error)", status, (ssize_t)nblocks); goto CLEANUP; } } else { /* No hyperblock */ for (i=0; i<rank; i++) { h5lower[i] = 1; /* HDS value 1-based */ h5upper[i] = h5dims[i]; } } dat1ExportDims( rank, h5lower, lower, status ); dat1ExportDims( rank, h5upper, upper, status ); /* If no dataspace ia available, and the locator is a structure array... */ } else if (dat1IsStructure( locator, status ) ) {