Beispiel #1
0
static void f3(struct callout_mgr *cm, struct callout *tim, void *arg)
{
	(void)arg;
	ts_printf("%s START\n", __FUNCTION__);
	wait_ms(600);
	ts_printf("%s END\n", __FUNCTION__);

	callout_reschedule(cm, tim, C3_TIME_MS);
}
Beispiel #2
0
static void supp(struct callout_mgr *cm, struct callout *tim, void *arg)
{
	struct callout *c2 = arg;

	ts_printf("stopping c1\n");
	callout_stop(cm, c2);
}
Beispiel #3
0
static void f2(struct callout_mgr *cm, struct callout *tim, void *arg)
{
	(void)arg;
	ts_printf("%s\n", __FUNCTION__);

	callout_reschedule(cm, tim, C2_TIME_MS);
}
Beispiel #4
0
/**
 * <pre>
 * Description:
 *   Dump cell inventoy data.
 * Arguments:
 *   *tscb - Test script control block
 * </pre>
 *****************************************************************************/
Byte getEnvironmentStatus(TEST_SCRIPT_CONTROL_BLOCK *tscb)
{
  TEST_SCRIPT_ERROR_BLOCK *tseb = &tscb->testScriptErrorBlock;
  Byte rc = 0;

  ts_printf(__FILE__, __LINE__, "getEnvironmentStatus");

  rc = getCurrentTemperature(MY_CELL_NO + 1, &tscb->wCurrentTempInHundredth);
  if (rc) {
    ts_printf(__FILE__, __LINE__, "error %d", rc);
    tseb->isFatalError = 1;
  }

  rc = getCurrentVoltage(MY_CELL_NO + 1, &tscb->wCurrentV5InMilliVolts, &tscb->wCurrentV12InMilliVolts);
  if (rc) {
    ts_printf(__FILE__, __LINE__, "error %d", rc);
    tseb->isFatalError = 1;
  }

  ts_printf(__FILE__, __LINE__, "cell temp = %d, x_volt = %d, y_volt = %d", tscb->wCurrentTempInHundredth, tscb->wCurrentV5InMilliVolts, tscb->wCurrentV12InMilliVolts);

  return 0;
}
Beispiel #5
0
/**
 * <pre>
 * Description:
 *   Wait drive test completed.
 * Arguments:
 *   *tscb - Test script control block
 * </pre>
 *****************************************************************************/
Byte isEnvironmentError(TEST_SCRIPT_CONTROL_BLOCK *tscb)
{
  TEST_SCRIPT_ERROR_BLOCK *tseb = &tscb->testScriptErrorBlock;
  Byte rc = 1;
  Word wErrorStatus = 0xffff;

  rc = isDrivePlugged(MY_CELL_NO + 1);
  if (!rc) {
    if (tscb->isNoPlugCheck) {
      ts_printf(__FILE__, __LINE__, "Warning - Drive Plug Off");
    } else {
      ts_printf(__FILE__, __LINE__, "Error - Drive Plug Off");
      tseb->isDriveUnplugged = 1;
      return 1;
    }
  }

  rc = getVoltageErrorStatus(MY_CELL_NO + 1, &wErrorStatus);
  if (rc) {
    if (tscb->isNoPowerControl) {
      ts_printf(__FILE__, __LINE__, "Warning - Disable poower on");
    } else {
      ts_printf(__FILE__, __LINE__, "Error - Voltatge 0x%04x", wErrorStatus);
      tseb->isDrivePowerFail = 1;
      return rc;
    }
  }

  rc = getTemperatureErrorStatus(MY_CELL_NO + 1, &wErrorStatus);
  if (rc) {
    ts_printf(__FILE__, __LINE__, "Error - Temp Environment 0x%04x", wErrorStatus);
    tseb->isCellTemperatureAbnormal = 1;
    return rc;
  }

  return 0;
}
Beispiel #6
0
/**
 * <pre>
 * Description:
 *   Wait drive test completed.
 * Arguments:
 *   *tscb - Test script control block
 * </pre>
 *****************************************************************************/
Byte turnDrivePowerSupplyOff(TEST_SCRIPT_CONTROL_BLOCK *tscb)
{
  TEST_SCRIPT_ERROR_BLOCK *tseb = &tscb->testScriptErrorBlock;
  Byte rc = 1;

  ts_printf(__FILE__, __LINE__, "turnDrivePowerSupplyOff");

  /* turn off voltage supply */
  if (tscb->isNoPowerControl || tscb->isNoPowerOffAfterTest) {
    ts_printf(__FILE__, __LINE__, "Warning - Disable poower off");
  } else {
    rc = setUartPullupVoltage(MY_CELL_NO + 1, 0);
    if (rc) {
      ts_printf(__FILE__, __LINE__, "error %d", rc);
      tseb->isFatalError = 1;
      return rc;
    }
    ts_sleep_slumber(1);
    rc = setTargetVoltage(MY_CELL_NO + 1, 0, 0);
    if (rc) {
      ts_printf(__FILE__, __LINE__, "error %d", rc);
      tseb->isFatalError = 1;
      return rc;
    }
  }
  ts_sleep_slumber(tscb->dwDrivePowerOffWaitTime);

  /* check enviroment error */
  rc = isEnvironmentError(tscb);
  if (rc) {
    ts_printf(__FILE__, __LINE__, "error %d", rc);
    return rc;
  }

  return rc;
}
Beispiel #7
0
/**
 * <pre>
 * Description:
 *   Dump cell inventoy data.
 * Arguments:
 *   *tscb - Test script control block
 * </pre>
 *****************************************************************************/
Byte dumpCellInventoryData(TEST_SCRIPT_CONTROL_BLOCK *tscb)
{
  TEST_SCRIPT_ERROR_BLOCK *tseb = &tscb->testScriptErrorBlock;
  CELL_CARD_INVENTORY_BLOCK *ccib = &tscb->cellCardInventoryblock;
  CELL_CARD_INVENTORY_BLOCK *p = NULL;
  Byte rc = 0;

  ts_printf(__FILE__, __LINE__, "dumpCellInventoryData");

  rc = getCellInventory(MY_CELL_NO + 1, &p);
  if (rc) {
    ts_printf(__FILE__, __LINE__, "error - getCellInventory %d", rc);
    tseb->isFatalError = 1;
    return 1;
  }
  memcpy(ccib, p, sizeof(*ccib));
  ts_printf(__FILE__, __LINE__, "sizeof(*ccib) = %d", sizeof(*ccib));

  ts_printf(__FILE__, __LINE__, "bPartsNumber");
  putBinaryDataDump(ccib->bPartsNumber, 0, sizeof(ccib->bPartsNumber));

  ts_printf(__FILE__, __LINE__, "bCardRev");
  putBinaryDataDump(ccib->bCardRev, 0, sizeof(ccib->bCardRev));

  ts_printf(__FILE__, __LINE__, "bCardType");
  putBinaryDataDump(ccib->bCardType, 0, sizeof(ccib->bCardType));

  ts_printf(__FILE__, __LINE__, "bHddType");
  putBinaryDataDump(ccib->bHddType, 0, sizeof(ccib->bHddType));

  ts_printf(__FILE__, __LINE__, "bSerialNumber");
  putBinaryDataDump(ccib->bSerialNumber, 0, sizeof(ccib->bSerialNumber));

  ts_printf(__FILE__, __LINE__, "bConnectorLifeCount");
  putBinaryDataDump(ccib->bConnectorLifeCount, 0, sizeof(ccib->bConnectorLifeCount));

  return 0;
}
Beispiel #8
0
/**
 * <pre>
 * Description:
 *   Wait drive test completed.
 * Arguments:
 *   *tscb - Test script control block
 * </pre>
 *****************************************************************************/
Byte turnDrivePowerSupplyOn(TEST_SCRIPT_CONTROL_BLOCK *tscb)
{
  TEST_SCRIPT_ERROR_BLOCK *tseb = &tscb->testScriptErrorBlock;
  Byte rc = 0;

  ts_printf(__FILE__, __LINE__, "turnDrivePowerSupplyOn");

  rc = isEnvironmentError(tscb);
  if (rc) {
    ts_printf(__FILE__, __LINE__, "error %d", rc);
    return rc;
  }

  if (tscb->isNoPowerControl) {
    ts_printf(__FILE__, __LINE__, "warning - disable power on");

  } else {
    /* range check */
    if (0 == tscb->dwDriveUartPullup) {
      /* in case of power off */
    } else if ((tscb->dwDriveUartPullup < VOLTAGE_LIMIT_UART_LOW_MV) ||
               (VOLTAGE_LIMIT_UART_HIGH_MV < tscb->dwDriveUartPullup)) {
      ts_printf(__FILE__, __LINE__, "dwDriveUartPullup out of range %d", tscb->dwDriveUartPullup);
      return 1;
    }
    if (0 == tscb->dwDrivePowerSupply5V) {
      /* in case of power off */
    } else if ((tscb->dwDrivePowerSupply5V < VOLTAGE_LIMIT_5V_LOW_MV) ||
               (VOLTAGE_LIMIT_5V_HIGH_MV < tscb->dwDrivePowerSupply5V)) {
      ts_printf(__FILE__, __LINE__, "dwDrivePowerSupply5V out of range %d", tscb->dwDrivePowerSupply5V);
      return 1;
    }
    if (0 == tscb->dwDrivePowerSupply12V) {
      /* in case of power off */
    } else if ((tscb->dwDrivePowerSupply12V < VOLTAGE_LIMIT_12V_LOW_MV) ||
               (VOLTAGE_LIMIT_12V_HIGH_MV < tscb->dwDrivePowerSupply12V)) {
      ts_printf(__FILE__, __LINE__, "dwDrivePowerSupply12V out of range %d", tscb->dwDrivePowerSupply12V);
      return 1;
    }

    if (tscb->dwTestUartBaudrate > 0) {
      rc = siSetUartBaudrate(MY_CELL_NO + 1, tscb->dwTestUartBaudrate);
      if (rc) {
        ts_printf(__FILE__, __LINE__, "error %d", rc);
        tseb->isFatalError = 1;
        return rc;
      }
    }

    rc = siSetUartProtocol(MY_CELL_NO + 1, tscb->bTestUartProtocol);
    if (rc) {
      ts_printf(__FILE__, __LINE__, "error %d", rc);
      tseb->isFatalError = 1;
      return rc;
    }

    rc = setVoltageRiseTime(MY_CELL_NO + 1, tscb->dwDrivePowerRiseTime5V, tscb->dwDrivePowerRiseTime12V);
    if (rc) {
      ts_printf(__FILE__, __LINE__, "error %d", rc);
      tseb->isFatalError = 1;
      return rc;
    }

    rc = setVoltageInterval(MY_CELL_NO + 1, tscb->dwDrivePowerIntervalFrom5VTo12V);
    if (rc) {
      ts_printf(__FILE__, __LINE__, "error %d", rc);
      tseb->isFatalError = 1;
      return rc;
    }

    rc = setTargetVoltage(MY_CELL_NO + 1, tscb->dwDrivePowerSupply5V, tscb->dwDrivePowerSupply12V);
    if (rc) {
      ts_printf(__FILE__, __LINE__, "error %d", rc);
      tseb->isFatalError = 1;
      return rc;
    }
    ts_sleep_slumber(1);

    rc = setUartPullupVoltage(MY_CELL_NO + 1, tscb->dwDriveUartPullup);
    if (rc) {
      ts_printf(__FILE__, __LINE__, "error %d", rc);
      tseb->isFatalError = 1;
      return rc;
    }
  }

  ts_sleep_slumber(tscb->dwDrivePowerOnWaitTime);

  rc = clearFPGABuffers( MY_CELL_NO + 1 , RECEIVE_BUFFER_ID );
  if (rc) {
      ts_printf(__FILE__, __LINE__, "error %d", rc);
      tseb->isFatalError = 1;
      return rc;
  }
  ts_sleep_slumber(10);

  rc = isEnvironmentError(tscb);
  if (rc) {
    ts_printf(__FILE__, __LINE__, "error %d", rc);
    return rc;
  }

  return rc;
}
Beispiel #9
0
void op_fileinfo()
{
 /* Stack:

     |================================|=============================|
     |            BEFORE              |           AFTER             |
     |================================|=============================|
 top |  Key                           | Information                 |
     |--------------------------------|-----------------------------| 
     |  ADDR to file variable         |                             |
     |================================|=============================|

 Key values:           Action                         Returns
     0 FL_OPEN         Test if is open file variable  True/False
     1 FL_VOCNAME      Get VOC name of file           VOC name
     2 FL_PATH         Get file pathname              Pathname
     3 FL_TYPE         Check file type                DH:         FL_TYPE_DH  (3)
                                                      Directory:  FL_TYPE_DIR (4)
                                                      Sequential: FL_TYPE_SEQ (5)
     5 FL_MODULUS      File modulus                   Modulus value
     6 FL_MINMOD       Minimum modulus                Minimum modulus value
     7 FL_GRPSIZE      Group size                     Group size
     8 FL_LARGEREC     Large record size              Large record size
     9 FL_MERGE        Merge load percentage          Merge load
    10 FL_SPLIT        Split load percentage          Split load
    11 FL_LOAD         Current load percentage        Current load
    13 FL_AK           File has AK indices?           Boolean
    14 FL_LINE         Number of next line            Line number
  1000 FL_LOADBYTES    Current load in bytes          Current load bytes
  1001 FL_READONLY     Read only file?                Boolean
  1002 FL_TRIGGER      Get trigger function name      Call name
  1003 FL_PHYSBYTES    Physical file size             Size in bytes, excl indices
  1004 FL_VERSION      File version
  1005 FL_STATS_QUERY  Query file stats status        Boolean
  1006 FL_SEQPOS       File position                  File offset
  1007 FL_TRG_MODES    Get trigger modes              Mode mask
  1008 FL_NOCASE       File uses case insensitive ids?  Boolean
  1009 FL_FILENO       Return internal file number    File number
  1010 FL_JNL_FNO      Return journalling file no     File no, zero if not journalling
  1011 FL_AKPATH       Returns AK subfile location    Pathname of directory
  1012 FL_ID           Id of last record read         Id
  1013 FL_STATUS       As STATUS statement            Dynamic array
  1014 FL_MARK_MAPPING Is mark mapping enabled?       Boolean
  1015 FL_RECORD_COUNT Approximate record count
  1016 FL_PRI_BYTES    Primary subfile size in bytes
  1017 FL_OVF_BYTES    Overflow subfile size in bytes
  1018 FL_NO_RESIZE    Resizing inhibited?
  1019 FL_UPDATE       Update counter
  1020 FL_ENCRYPTED    File uses encryption?          Boolean
 10000 FL_EXCLUSIVE    Set exclusive access           Successful?
 10001 FL_FLAGS        Fetch file flags               File flags
 10002 FL_STATS_ON     Turn on file statistics
 10003 FL_STATS_OFF    Turn off file statistics
 10004 FL_STATS        Return file statistics
 10005 FL_SETRDONLY    Set file as read only
 */

 short int key;
 DESCRIPTOR * descr;
 FILE_VAR * fvar;
 DH_FILE * dh_file;
 char * p = NULL;
 long int n = 0;
 FILE_ENTRY * fptr;
 OSFILE fu;
 bool dynamic;
 bool internal;
 long int * q;
 STRING_CHUNK * str;
 short int i;
 double floatnum;
 u_char ftype;
 int64 n64;


 /* Get action key */

 descr = e_stack - 1;
 GetInt(descr);
 key = (short int)(descr->data.value);
 k_pop(1);

 /* Get file variable */

 descr = e_stack - 1;
 while(descr->type == ADDR) {descr = descr->data.d_addr;}


 if (key == FL_OPEN)    /* Test if file is open */
  {
   n = (descr->type == FILE_REF);
  }
 else
  {
   if (descr->type != FILE_REF) k_error(sysmsg(1200));

   fvar = descr->data.fvar;
   ftype = fvar->type;
   if (ftype == NET_FILE)  /* Network file */
    {
     str = net_fileinfo(fvar, key);
     k_dismiss();
     InitDescr(e_stack, STRING);
     (e_stack++)->data.str.saddr = str;
     return;
    }


   fptr = FPtr(fvar->file_id);

   dynamic = (ftype == DYNAMIC_FILE);
   if (dynamic) dh_file = fvar->access.dh.dh_file;

   internal = ((process.program.flags & HDR_INTERNAL) != 0);
   switch(key)
    {
     case FL_VOCNAME:     /* 1  VOC name of file */
        if (fvar->voc_name != NULL) p = fvar->voc_name;
        else p = "";
        goto set_string;

     case FL_PATH:        /* 2  File pathname */
        p = (char *)(fptr->pathname);
        goto set_string;

     case FL_TYPE:        /* 3  File type */
        /* !!FVAR_TYPES!! */
        switch(ftype)
         {
          case DYNAMIC_FILE:
             n = FL_TYPE_DH;
             break;
          case DIRECTORY_FILE:
             n = FL_TYPE_DIR;
             break;
          case SEQ_FILE:
             n = FL_TYPE_SEQ;
             break;
         }
        break;

     case FL_MODULUS:     /* 5  Modulus of file */
        if (dynamic) n = fptr->params.modulus;
        break;

     case FL_MINMOD:      /* 6  Minimum modulus of file */
        if (dynamic) n = fptr->params.min_modulus;
        break;

     case FL_GRPSIZE:     /* 7  Group size of file */
        if (dynamic) n = dh_file->group_size / DH_GROUP_MULTIPLIER;
        break;

     case FL_LARGEREC:    /* 8  Large record size */
        if (dynamic) n = fptr->params.big_rec_size;
        break;

     case FL_MERGE:       /* 9  Merge load percentage */
        if (dynamic) n = fptr->params.merge_load;
        break;

     case FL_SPLIT:       /* 10  Split load percentage */
        if (dynamic) n = fptr->params.split_load;
        break;

     case FL_LOAD:        /* 11  Load percentage */
        if (dynamic)
         {
          n = DHLoad(fptr->params.load_bytes, dh_file->group_size, fptr->params.modulus);
         }
        break;

     case FL_AK:          /* 13  File has AKs? */
        if (dynamic) n = (dh_file->ak_map != 0);
        break;

     case FL_LINE:        /* 14  Sequential file line position */
        if (ftype == SEQ_FILE)
         {
          n64 = fvar->access.seq.sq_file->line;
          if (n64 > LONG_MAX)
           {
            floatnum = (double)n64;
            goto set_float;
           }
          n = (long)n64;
         }
        break;

     case FL_LOADBYTES:   /* 1000  Load bytes */
        if (dynamic)
         {
          floatnum = (double)(fptr->params.load_bytes);
          goto set_float;
         }
        break;

     case FL_READONLY:    /* 1001  Read-only? */
        n = ((fvar->flags & FV_RDONLY) != 0);
        break;

     case FL_TRIGGER:     /* 1002  Trigger function name */
        if (dynamic)
         {
          p = dh_file->trigger_name;
          goto set_string;
         }
        break;

     case FL_PHYSBYTES:   /* 1003  Physical file size */
        switch(ftype)
         {
          case DIRECTORY_FILE:
             floatnum = (double)dir_filesize(fvar);
             break;
          case DYNAMIC_FILE:
             floatnum = (double)dh_filesize(dh_file, PRIMARY_SUBFILE) + dh_filesize(dh_file, OVERFLOW_SUBFILE);
             break;
          case SEQ_FILE:
             fu = fvar->access.seq.sq_file->fu;
             floatnum = (double)(ValidFileHandle(fu)?filelength64(fu):-1);
             break;
         }
        goto set_float;

     case FL_VERSION:     /* 1004  File version */
        if (dynamic) n = dh_file->file_version;
        break;

     case FL_STATS_QUERY: /* 1005  File statistics enabled? */
        if (dynamic) n = (fptr->stats.reset != 0);
        break;

     case FL_SEQPOS:      /* 1006  Sequential file offset */
        if (ftype == SEQ_FILE)
         {
          n64 = fvar->access.seq.sq_file->posn;
          if (n64 > LONG_MAX)
           {
            floatnum = (double)n64;
            goto set_float;
           }
          n = (long)n64;
         }
        break;

     case FL_TRG_MODES:   /* 1007  Trigger modes */
        if (dynamic) n = dh_file->trigger_modes;
        break;

     case FL_NOCASE:      /* 1008  Case insensitive ids? */
        switch(ftype)
         {
          case DIRECTORY_FILE:
          case DYNAMIC_FILE:
             n = (fptr->flags & DHF_NOCASE) != 0;
             break;
         }
        break;

     case FL_FILENO:      /* 1009  Internal file number */
        n = fvar->file_id;
        break;

     case FL_JNL_FNO:     /* 1010  Journalling file number */
        break;

     case FL_AKPATH:      /* 1011  AK subfile pathname */
        if (dynamic)
         {
          p = dh_file->akpath;
          goto set_string;
         }
        break;

     case FL_ID:          /* 1012  Id of last record read */
        k_dismiss();
        k_put_string(fvar->id, fvar->id_len, e_stack);
        e_stack++;
        return;

     case FL_STATUS:      /* 1013  STATUS array */
        str = get_file_status(fvar);
        k_dismiss();
        InitDescr(e_stack, STRING);
        (e_stack++)->data.str.saddr = str;
        return;

     case FL_MARK_MAPPING: /* 1014  Mark mapping enabled? */
        if (ftype == DIRECTORY_FILE) n = fvar->access.dir.mark_mapping;
        break;

     case FL_RECORD_COUNT: /* 1015  Approximate record count */
        if (dynamic)
         {
          floatnum = (double)(fptr->record_count);
          goto set_float;
         }
        else n = -1;

     case FL_PRI_BYTES:   /* 1016  Physical size of primary subfile */
        if (dynamic)
         {
          floatnum = (double)dh_filesize(dh_file, PRIMARY_SUBFILE);
          goto set_float;
         }
        break;

     case FL_OVF_BYTES:   /* 1017  Physical size of overflow subfile */
        if (dynamic)
         {
          floatnum = (double)dh_filesize(dh_file, OVERFLOW_SUBFILE);
          goto set_float;
         }
        break;

     case FL_NO_RESIZE:   /* 1018  Resizing inhibited? */
        if (dynamic) n = ((fptr->flags & DHF_NO_RESIZE) != 0);
        break;

     case FL_UPDATE:      /* 1019  File update counter */
        n = (long)(fptr->upd_ct);
        break;

     case FL_ENCRYPTED:   /* 1020  File uses encryption? */
        /* Recognised but returns default zero */
        break;

     case FL_EXCLUSIVE:   /* 10000  Set exclusive access mode */
        if (internal)
         {
          /* To gain exclusive access to a file it must be open only to this
             process (fptr->ref_ct = 1) and must not be open more than once
             in this process.  The latter condition only affects dynamic files
             as other types produce multiply referenced file table entries.
             We need to ensure a dynamic file is only open once so that when
             we close the file we really are going to kill off the DH_FILE
             structure. This is essential, for example, in AK creation where
             the DH_FILE structure has to change its size.                   */

          flush_dh_cache();    /* Ensure we are not stopped by a cached
                                  reference from our own process.       */
          n = FALSE;
          for (i = 0; i < 6; i++)
           {
            StartExclusive(FILE_TABLE_LOCK, 37);
            if ((fptr->ref_ct == 1)
               && ((ftype != DYNAMIC_FILE) || (dh_file->open_count == 1)))
             {
              fptr->ref_ct = -1;
              fptr->fvar_index = fvar->index;
              n = TRUE;
             }
            EndExclusive(FILE_TABLE_LOCK);

            if (n) break;

            if (i == 0)  /* First attempt */
             {
              /* Cannot gain exclusive access. Maybe some other process has
                 the file in its DH cache. Fire an EVT_FLUSH_CACHE event to
                 all processes to see if this clears the problem. We then
                 continue trying for a short time until either we get the
                 required access or we reach our retry count.              */
              raise_event(EVT_FLUSH_CACHE, -1);
             }

            Sleep(500);   /* Pause for something to happen */
           }
         }
        break;

     case FL_FLAGS:       /* 10001  File flags */
        if (dynamic && internal) n = (long int)(dh_file->flags);
        break;

     case FL_STATS_ON:    /* 10002  Enable file statistics */
        if (dynamic && internal)
         {
          memset((char *)&(fptr->stats), 0, sizeof(struct FILESTATS));
          fptr->stats.reset = qmtime();
         }
        break;

     case FL_STATS_OFF:   /* 10003  Disable file statistics */
        if (dynamic && internal) fptr->stats.reset = 0;
        break;

     case FL_STATS:       /* 10004  Return file statistics data */
        if (dynamic && internal)
         {
          str = NULL;
          ts_init(&str, 5 * FILESTATS_COUNTERS);
          for (i = 0, q = (long int *)&(fptr->stats.reset); i < FILESTATS_COUNTERS; i++, q++)
           {
            ts_printf("%ld\xfe", *q);
           }
          (void)ts_terminate();
          k_dismiss();    /* 0363 */
          InitDescr(e_stack, STRING);
          (e_stack++)->data.str.saddr = str;
          return;
         }
        break;

     case FL_SETRDONLY:   /* 10005  Set read-only */
        if (internal)
         {
          fvar->flags |= FV_RDONLY;
          if (dynamic) dh_file->flags |= DHF_RDONLY;
         }
        break;

     default:
        k_error(sysmsg(1010));
    }
  }

 /* Set integer return value on stack */

set_integer:
 k_dismiss();
 InitDescr(e_stack, INTEGER);
 (e_stack++)->data.value = n;
 return;

/* Set string return value on stack */

set_string:
 k_dismiss();
 k_put_c_string(p, e_stack);
 e_stack++;
 return;

set_float:
 if (floatnum <= (double)LONG_MAX)
  {
   n = (long)floatnum;
   goto set_integer;
  }

 k_dismiss();
 InitDescr(e_stack, FLOATNUM);
 (e_stack++)->data.float_value = floatnum;
 return;
}
Beispiel #10
0
Private STRING_CHUNK * get_file_status(FILE_VAR * fvar)
{
 STRING_CHUNK * str = NULL;
 u_char ftype;
 DH_FILE * dh_file;
 SQ_FILE * sq_file;
 int64 file_size = 0;
 int file_type_num = 0;
 bool is_seq = FALSE;
 char * path;
 int64 n64;
 struct stat statbuf;

 memset(&statbuf, 0, sizeof(statbuf));

 ftype = fvar->type;
 path = (char *)(FPtr(fvar->file_id)->pathname);

 /* !!FVAR_TYPES!! */
 switch(ftype)
  {
   case DYNAMIC_FILE:
      file_type_num = FL_TYPE_DH;
      dh_file = fvar->access.dh.dh_file;
      FDS_open(dh_file, PRIMARY_SUBFILE);
      fstat(dh_file->sf[PRIMARY_SUBFILE].fu, &statbuf);
      file_size = dh_filesize(dh_file, PRIMARY_SUBFILE) + dh_filesize(dh_file, OVERFLOW_SUBFILE);
      break;

   case DIRECTORY_FILE:
      file_type_num = FL_TYPE_DIR;
      stat((char *)(FPtr(fvar->file_id)->pathname), &statbuf);
      file_size = dir_filesize(fvar);
      break;

   case SEQ_FILE:
      file_type_num = FL_TYPE_SEQ;
      is_seq = TRUE;
      sq_file = fvar->access.seq.sq_file;
      if (!(sq_file->flags & SQ_NOTFL)) fstat(sq_file->fu, &statbuf);
      file_size = statbuf.st_size;
      path = sq_file->pathname;
      break;

  }

 ts_init(&str, 128);

 /* 1  File position */
 n64 = (is_seq)?sq_file->posn:0;
 ts_printf("%lld\xfe", n64);

 /* 2  At EOF? */
 ts_printf("%d\xfe", (is_seq)?sq_file->posn == file_size:0);

 /* 3  Not used */
 ts_printf("\xfe");

 /* 4  Bytes available to read */
 n64 = (is_seq)?(file_size - sq_file->posn):0;
 ts_printf("%lld\xfe", n64);

 /* 5  File mode */
 ts_printf("%u\xfe", statbuf.st_mode & 0777);

 /* 6  File size */
 ts_printf("%lld\xfe", file_size);

 /*  7  Hard links */
 ts_printf("%d\xfe", statbuf.st_nlink);

 /*  8  UID of owner */
 ts_printf("%d\xfe", statbuf.st_uid);

 /*  9  GID of owner */
 ts_printf("%d\xfe", statbuf.st_gid);

 /* 10  Inode number */
 ts_printf("%d\xfe", statbuf.st_ino);

 /* 11  Device number */
 ts_printf("%d\xfe", statbuf.st_dev);

 /* 12  Not used */
 ts_printf("\xfe");

 /* 13  Time of last access */
 ts_printf("%d\xfe", statbuf.st_atime % 86400);

 /* 14  Date of last access */
 ts_printf("%d\xfe", (statbuf.st_atime / 86400) + 732);

 /* 15  Time of last modification */
 ts_printf("%d\xfe", statbuf.st_mtime % 86400);

 /* 16  Date of last modification */
 ts_printf("%d\xfe", (statbuf.st_mtime / 86400) + 732);

 /* 17 - 19 unused */
 ts_printf("\xfe\xfe\xfe");

 /* 20  Operating system file name */
 ts_printf("%s\xfe", path);

 /* 21  File type */
 ts_printf("%d", file_type_num);

 (void)ts_terminate();

 return str;
}
Beispiel #11
0
int main(void)
{
	struct callout c1, c2, c3, c4;
	uint8_t old_prio;

#ifdef HOST_VERSION
	hostsim_uart_init();
	hostsim_ittimer_add(timer_interrupt, 1 * 1000 * 1000); /* 1ms period */
	hostsim_ittimer_enable(100); /* 100 us */
#else
	uart_init();
	fdevopen(uart0_dev_send, uart0_dev_recv);
	timer_init();
	timer0_register_OV_intr(timer_interrupt);
#endif
	uart_register_rx_event(0, dump_stats);

	callout_mgr_init(&global_cm, get_time_ms);
	sei();

	printf("f1 every %d ms, high prio (200)\n", C1_TIME_MS);
	printf("f2 every %d ms, low prio (50)\n", C2_TIME_MS);
	printf("f3 every %d ms, med prio (100), the function lasts 600ms\n",
		C3_TIME_MS);
	printf("f4 only once after %d ms, very high prio (250), "
		"stop task f2\n", C4_TIME_MS);
	printf("type s to dump stats\n");

	callout_init(&c1, f1, NULL, 200);
	callout_init(&c2, f2, NULL, 50);
	callout_init(&c3, f3, NULL, 100);
	callout_init(&c4, supp, &c2, 250);

	callout_schedule(&global_cm, &c1, C1_TIME_MS);
	callout_schedule(&global_cm, &c2, C2_TIME_MS);
	callout_schedule(&global_cm, &c3, C3_TIME_MS);
	callout_schedule(&global_cm, &c4, C4_TIME_MS);

	while (get_time_ms() < 2900)
		;

	old_prio = callout_mgr_set_prio(&global_cm, 150);
	ts_printf("set prio 150\n");

	while (get_time_ms() < 3100)
		;

	ts_printf("set prio 0\n");
	callout_mgr_restore_prio(&global_cm, old_prio);

	while (get_time_ms() < 5000)
		;

	callout_stop(&global_cm, &c1);
	callout_stop(&global_cm, &c3);
	callout_stop(&global_cm, &c4);

	callout_dump_stats(&global_cm);
	wait_ms(10);

#ifdef HOST_VERSION
	hostsim_uart_exit();
#endif

	return 0;
}