⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nvimw.c

📁 free sources for gsm
💻 C
📖 第 1 页 / 共 5 页
字号:
                           FS_FA_UNRESTRICTED)) != NV_DONE_S)
    {
       return status;
    }

    status = nvimw_write_fixed(cmd_ptr->item,
                               cmd_ptr->data_ptr,
                               nv_op_get_size(cmd_ptr->item));

    /* Turn back on permanent file attribute */
    if (status == NV_DONE_S)
    {
       status = nvim_update_fs_item_file_attrs(
                nv_op_get_fparams(cmd_ptr->item),
                                               FS_FA_SYS_PERMANENT);
    }

    return status;
}

/*===========================================================================

FUNCTION NVIMW_WRITE_FIXED_ARRAY

DESCRIPTION
  This function writes a fixed array item.

DEPENDENCIES
  None

RETURN VALUE
  NV_DONE_S if it worked
  NV_FAIL_S if it couldn't be writen.

SIDE EFFECTS
  None

===========================================================================*/
nv_stat_enum_type nvimw_write_fixed_array
(
  nv_items_enum_type   item,          /* NV index of the item */
  byte                 item_index,    /* index into array of array members */
  PACKED void          *data_ptr,      /* Data to write for variable */
  word                 size            /* Size of a member of the array */
)
{
  boolean true_flag   = TRUE;    /* Flag used to set active flag to TRUE  */
  boolean false_flag   = FALSE;    /* Flag used to set active flag to FALSE  */
  boolean close_file  = FALSE;   /* Flag used to indicate if close required */
  nv_stat_enum_type status = NV_DONE_S;  /* Assume good status */
  nvim_efs_params *fparams;
  fs_file_position_type fpos;

  /* Roaming list requires special processing */
#ifdef NV_FEATURE_IS683A_PRL
  if (item == NV_ROAMING_LIST_683_I)
#else
  if (item == NV_ROAMING_LIST_I)
#endif
  {
    /* Setup file info */
    fparams = nvim_prl_fs_params(item_index);
    fpos = 0;
  }
  else
  {
    fparams = nv_op_get_fparams(item);
    fpos = nv_op_get_file_pos(item) + (item_index*size);
  }

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

  /* Open for write access if necessary */
  if (fparams->wr_handle == FS_NULL_HANDLE)
  {
     (void) nvim_open_write(fparams);
     close_file = TRUE;
  }

  /* Reset the watchdog timer */
  KICK_WATCHDOG();

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

  /* Attempt to write active flag to false, then write the data,
   * then write the flag to true. In event of a write failure the
   * item ends up "inactive"
   */

  memcpy(((byte*)&nvi_item), &true_flag, sizeof(true_flag));
  /*lint -save -e{419,420} */
  memcpy(((byte*)&nvi_item)+sizeof(true_flag), (byte*)data_ptr, size-sizeof(true_flag));
  /*lint -restore */

  status = nvim_write_efs(fparams->wr_handle,
                          fpos,
                          &false_flag,
                          sizeof(false_flag));

  /* Write the new data into the item */
  if(status == NV_DONE_S) {

    status = nvim_write_efs(fparams->wr_handle,
                            fpos + sizeof(true_flag),
                            data_ptr,
                            size-sizeof(true_flag));
  }

  /* Write the active flag to true for this member of the array */
  if(status == NV_DONE_S)
  {
    status = nvim_write_efs(fparams->wr_handle,
                            fpos,
                            &true_flag,
                            sizeof(true_flag));
    if (status != NV_DONE_S)
    {
      ERR("Couldn't update array: pos 0x%x, status %d",
           fpos,status,0);
    }
  }


  /* Close for write access if necessary */
  if (close_file)
  {
     (void) nvim_close_write(fparams);
  }

  return status;

} /* nvimw_write_fixed_array */


/*===========================================================================

FUNCTION NVIMW_WRITE_FIXED

DESCRIPTION
  This function writes an fixed item type.  If the item is already
  active, it is first set to not active, then the item is written,
  and finally the item is set to active again.  If the item could
  not be written we do nothing at this level all retries and reallocations
  take place at a lower level.

DEPENDENCIES
  None.

RETURN VALUE
  NV_DONE_S if it worked
  Or the failure status from the lower levels.

SIDE EFFECTS
  None

===========================================================================*/

LOCAL nv_stat_enum_type nvimw_write_fixed
(
  nv_items_enum_type item, /* index in NV of the item */
  PACKED void        *data_ptr,  /* Pointer to write data */
  word               size  /* Size of data inside active item */
)
{
  boolean true_flag   = TRUE;   /* Flag used to set active flag to TRUE */
  boolean false_flag  = FALSE;   /* Flag used to set active flag to FALSE */
  boolean close_file  = FALSE;   /* Flag used to indicate if close required */
  nv_stat_enum_type status = NV_DONE_S;  /* Assume good status */
  fs_file_position_type fpos = nv_op_get_file_pos(item);
  nvim_efs_params *fparams = nv_op_get_fparams(item);

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

  /* Open for write access if necessary */
  if (fparams->wr_handle == FS_NULL_HANDLE)
  {
     (void) nvim_open_write(fparams);
     close_file = TRUE;
  }

  /* reset the watchdog timer */
  KICK_WATCHDOG();
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

  /* Attempt to write active flag to false, then
   * write the data, then write the flag to true. In event of a write
   * failure the item ends up "inactive"
   */
  status = nvim_write_efs(fparams->wr_handle,
                          fpos,
                          &false_flag,
                          sizeof(false_flag));

  /* Write the new data into the item */
  if(status == NV_DONE_S)
  {
    status = nvim_write_efs(fparams->wr_handle,
                            fpos+sizeof(true_flag),
                            data_ptr,
                            size-sizeof(true_flag));
  }

  /* Update the 'active' flag to 'true'. */
  if(status == NV_DONE_S)
  {
    status = nvim_write_efs(fparams->wr_handle,
                            fpos,
                            &true_flag,
                            sizeof(true_flag));
  }


  /* Close for write access if necessary */
  if (close_file)
  {
     (void) nvim_close_write(fparams);
  }

  return status;

} /* nvimw_write_fixed */


/*===========================================================================

FUNCTION NVIMW_WRITE

DESCRIPTION
  This function processes NVM write requests.  The function checks
  to make sure that a valid item has been requested, it performs any
  translations necessary from external format to internal NVM format
  and writes the item using EFS write services.

DEPENDENCIES
  None.

RETURN VALUE
  Status of write operation.

SIDE EFFECTS
  None.

===========================================================================*/

nv_stat_enum_type nvimw_write
(
  nv_cmd_type  *cmd_ptr          /* Command block */
)
{
  nv_stat_enum_type status;     /* Status to return to calling procedure */
  word array_size; /* Array size of the item */
  byte index; /* Specific index of an array */

#ifdef FEATURE_NV_SFS_PRIVATE
  int num_imei_bytes;
#endif

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

  /* Check that the item code is within range. If it is not */
  /* then exit with fail status, else switch on item type.  */

  if (cmd_ptr->item >= NV_MAX_I) {
    return NV_BADPARM_S;
  }
  else
  {

#ifdef NV_FEATURE_DIAG_WINS
    /* If write request is from diag, close gate to all other writers */
    if ((write_gate_open) || (cmd_ptr->tcb_ptr == &diag_tcb))
    {
      if (cmd_ptr->tcb_ptr == &diag_tcb)
      {
         write_gate_open = FALSE;
      }
#endif

#ifdef FEATURE_NV_RUIM

      /* If the R-UIM supports the item,
       * return the status else use "regular" NVM.
       */
      if ( nvruim_write(cmd_ptr, &status) == NV_RUIM_SUPPORTS_ITEM )
        return status;

#endif

      switch (cmd_ptr->item)
      {

      /* For each requested parameter if the parameter is fixed then */
      /* write it via its pointer from the external requestor's data */
      /* buffer to an EFS file. Any required                         */
      /* translation from external to internal format is performed   */
      /* as part of this write.                                      */

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

      case NV_ESN_I:
        status = nvimw_write_esn(cmd_ptr);
        return status;

  /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

      case NV_ESN_CHKSUM_I:

        /* The ESN checksum cannot be written from external   */
        /* request.  This request is denied and the NV task   */
        /* initiates transition of the DMSS to offline state  */
        /* (not yet implemented).                             */

        return NV_READONLY_S;

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

      case NV_VERNO_MAJ_I:

        /* Major version can be written only internally, directly */
        /* from nv_init.  So we do not allow writing it here.     */

        return NV_READONLY_S;

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

      case NV_VERNO_MIN_I:

        /* Minor version can be written only internally, directly */
        /* from nv_init.  So we do not allow writing it here.     */

        return NV_READONLY_S;

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

      case NV_DIAL_I:
          status = nvimw_write_dial(NV_DIAL_I,
                                 NV_MAX_SPEED_DIALS,
                                 cmd_ptr->data_ptr->dial.address,
                                 &cmd_ptr->data_ptr->dial);
        return status;

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

      case NV_STACK_I:
          status = nvimw_write_stdial(NV_STACK_I,
                                 NV_MAX_STACK_DIALS,
                                 cmd_ptr->data_ptr->stack.address,
                                 &cmd_ptr->data_ptr->stack);
        return status;

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

#ifdef FEATURE_NV_REDIAL_ITEM
      case NV_REDIAL_I:
          status = nvimw_write_dial(NV_DIAL_I,
                       NV_MAX_SPEED_DIALS + NVI_REDIAL_EXTENSIONS,
                       NV_MAX_SPEED_DIALS,
                       &cmd_ptr->data_ptr->dial);
        return status;
#endif

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

      case NV_SMS_I:
      case NV_SMS_DM_I:
        status = nvimw_write_sms(cmd_ptr);
        return status;

/*- - - - - - - - - -  - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

      case NV_DIR_NUMBER_I:
      case NV_DIR_NUMBER_PCS_I :
        status = nvimw_write_dir_number(cmd_ptr);
        return status;

/*- - - - - - - - - -  - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

#ifdef NV_FEATURE_RENTAL_ITEMS
#error code not present
#endif

/*- - - - - - - - - -  - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

#ifdef NV_FEATURE_RENTAL_ITEMS
#error code not present
#endif

/*- - - - - - - - - -  - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
      case NV_A_KEY_I:
      case NV_SSD_A_I:
      case NV_SSD_B_I:

        /* Turn off permanent file attribute in order to write */
        if ((status = nvim_update_fs_item_file_attrs(nv_op_get_fparams(cmd_ptr->item),
                                     FS_FA_UNRESTRICTED)) != NV_DONE_S)
        {
           return status;
        }

        /* Write the item */
        index = *((byte *)cmd_ptr->data_ptr);
        if (index >= NV_MAX_NAMS)
        {
          status = NV_BADPARM_S;
        }
        else   /* Valid index */
        {
          status = nvimw_write_fixed_array(cmd_ptr->item,
                                           index,
                                           ((byte *)cmd_ptr->data_ptr) + s

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -