Exemplo n.º 1
0
int do_frd (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
{
	unsigned int fslnum;
	unsigned int num;
	unsigned int blocking;

	if (argc < 2) {
		cmd_usage(cmdtp);
		return 1;
	}

	fslnum = (unsigned int)simple_strtoul (argv[1], NULL, 16);
	blocking = (unsigned int)simple_strtoul (argv[2], NULL, 16);
	if (fslnum < 0 || fslnum >= XILINX_FSL_NUMBER) {
		puts ("Bad number of FSL\n");
		cmd_usage(cmdtp);
		return 1;
	}

	switch (fslnum) {
#if (XILINX_FSL_NUMBER > 0)
	case 0:
		switch (blocking) {
		case 0:	NGET (num, 0);
			break;
		case 1:	NCGET (num, 0);
			break;
		case 2:	GET (num, 0);
			break;
		case 3:	CGET (num, 0);
			break;
		default:
			return 2;
		}
		break;
#endif
#if (XILINX_FSL_NUMBER > 1)
	case 1:
		switch (blocking) {
		case 0:	NGET (num, 1);
			break;
		case 1:	NCGET (num, 1);
			break;
		case 2:	GET (num, 1);
			break;
		case 3:	CGET (num, 1);
			break;
		default:
			return 2;
		}
		break;
#endif
#if (XILINX_FSL_NUMBER > 2)
	case 2:
		switch (blocking) {
		case 0:	NGET (num, 2);
			break;
		case 1:	NCGET (num, 2);
			break;
		case 2:	GET (num, 2);
			break;
		case 3:	CGET (num, 2);
			break;
		default:
			return 2;
		}
		break;
#endif
#if (XILINX_FSL_NUMBER > 3)
	case 3:
		switch (blocking) {
		case 0:	NGET (num, 3);
			break;
		case 1:	NCGET (num, 3);
			break;
		case 2:	GET (num, 3);
			break;
		case 3:	CGET (num, 3);
			break;
		default:
			return 2;
		}
		break;
#endif
#if (XILINX_FSL_NUMBER > 4)
	case 4:
		switch (blocking) {
		case 0:	NGET (num, 4);
			break;
		case 1:	NCGET (num, 4);
			break;
		case 2:	GET (num, 4);
			break;
		case 3:	CGET (num, 4);
			break;
		default:
			return 2;
		}
		break;
#endif
#if (XILINX_FSL_NUMBER > 5)
	case 5:
		switch (blocking) {
		case 0:	NGET (num, 5);
			break;
		case 1:	NCGET (num, 5);
			break;
		case 2:	GET (num, 5);
			break;
		case 3:	CGET (num, 5);
			break;
		default:
			return 2;
		}
		break;
#endif
#if (XILINX_FSL_NUMBER > 6)
	case 6:
		switch (blocking) {
		case 0:	NGET (num, 6);
			break;
		case 1:	NCGET (num, 6);
			break;
		case 2:	GET (num, 6);
			break;
		case 3:	CGET (num, 6);
			break;
		default:
			return 2;
		}
		break;
#endif
#if (XILINX_FSL_NUMBER > 7)
	case 7:
		switch (blocking) {
		case 0:	NGET (num, 7);
			break;
		case 1:	NCGET (num, 7);
			break;
		case 2:	GET (num, 7);
			break;
		case 3:	CGET (num, 7);
			break;
		default:
			return 2;
		}
		break;
#endif
	default:
		return 1;
	}

	printf ("%01x: 0x%08x - %s %s read\n", fslnum, num,
		blocking < 2  ? "non blocking" : "blocking",
		((blocking == 1) || (blocking == 3)) ? "control" : "data" );
	return 0;
}
Exemplo n.º 2
0
int ReadVarFromCDF(int cdfid, int vid, VarDesc *v, size_t **d, size_t *coords, BOOL bigdim)
{
  int lnx, lny, offs, startloop;
  int startoff = ((v->option & STARTING_WITH_ZERO) != 0);
  double tmp;
  nc_type vartype;
  nc_inq_vartype(cdfid, vid, &vartype);
  lnx = nxm + bigdim + startoff; lny = nym + bigdim + startoff;
  offs = !startoff && !bigdim;
  startloop = !startoff && bigdim;
  switch (v->storetype)  {
  case GRID_VAL :
    if (!g[v->v.et])  g[v->v.et] = (double *)calloc(mesh, sizeof(double));
    for (*d[2] = 0; *d[2] < nz; (*d[2])++)
      for (*d[0] = startloop; *d[0] < lnx; (*d[0])++)
	for (*d[1] = startloop; *d[1] < lny; (*d[1])++)
	  NCGET(g[v->v.et][F(*d[2],*d[0]+offs,*d[1]+offs)]);
    break;
  case DOUBLE_PTR :
    switch (v->dims)  {
    case (ALL_DIM) :
      for (*d[2] = 0; *d[2] < nz; (*d[2])++)
	for (*d[0] = startloop; *d[0] < lnx; (*d[0])++)
	  for (*d[1] = startloop; *d[1] < lny; (*d[1])++)
	    NCGET(v->v.d[F(*d[2],*d[0]+offs,*d[1]+offs)]);
      break;
    case (X_DIM | Y_DIM) :
      for (*d[0] = startloop; *d[0] < lnx; (*d[0])++)
	for (*d[1] = 0; *d[1] < lny; (*d[1])++)
	  NCGET(v->v.d[FH(*d[0]+offs,*d[1]+offs)]);
      break;
    case (Y_DIM | Z_DIM) :
      for (*d[2] = 0; *d[2] < nz; (*d[2])++)
	for (*d[1] = startloop; *d[1] < lny; (*d[1])++)
	  NCGET(v->v.d[FH(*d[2],*d[1]+offs)]);
      break;
    case (X_DIM | Z_DIM) :
      for (*d[2] = 0; *d[2] < nz; (*d[2])++)
	for (*d[0] = startloop; *d[0] < lnx; (*d[0])++)
	  NCGET(v->v.d[*d[2] * xrow + *d[0]+offs]);
      break;
    case X_DIM : for (*d[0] = startloop; *d[0] < lnx; (*d[0])++)
      NCGET(v->v.d[*d[0]+offs]);
    break;
    case Y_DIM : for (*d[1] = startloop; *d[1] < lny; (*d[1])++)
      NCGET(v->v.d[*d[1]+offs]);
    break;
    case Z_DIM : for (*d[2] = 0; *d[2] < nz; (*d[2])++)
      NCGET(v->v.d[*d[2]]);
    break;
    case COUNT_DIM :
      for (*d[4] = 0; *d[4] < v->ncoord; (*d[4])++)
	NCGET(v->v.d[*d[4]]);
      break;
    case 0     : NCGET(*v->v.d); break;
    default : InputError(ERROR, "Internal implementation error (2)");
      break;
    }
    break;
  case GROUND_PARAM :
    for (*d[0] = startloop; *d[0] < lnx; (*d[0])++)
      for (*d[1] = startloop; *d[1] < lny; (*d[1])++)
	NCGET(v->v.g[(*d[0]+offs)*row+*d[1]+offs].Tg[0]);
    break;
  default :
    InputError(ERROR, "Variable %s cannot be set via CDF-File. (Wrong-Type)", v->name);
    return (1);
  }
  return (0);
}