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

📄 nvimw.c

📁 free sources for gsm
💻 C
📖 第 1 页 / 共 5 页
字号:
    }
  }


  /* 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) + sizeof(index),
                                           nv_op_get_size(cmd_ptr->item));
        }

        /* Turn back on permanent file attribute */
        (void) nvim_update_fs_item_file_attrs(nv_op_get_fparams(cmd_ptr->item),
                                       FS_FA_SYS_PERMANENT);
        return status;

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

       case NV_PAP_PASSWORD_I:
         #ifdef NV_FEATURE_PAP
           /* 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;
           }

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

           /* Turn back on permanent file attribute */
           (void) nvim_update_fs_item_file_attrs(
                 nv_op_get_fparams(cmd_ptr->item), FS_FA_SYS_PERMANENT);

         #else
           status = NV_BADPARM_S;
         #endif
           return status;

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

       case NV_UP_KEY_I:
         #ifdef NV_FEATURE_UP
           /* 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;
           }

           index = *((byte *) cmd_ptr->data_ptr);
           if (index >= NV_UP_LINK_INFO_TABLE_SIZE)
           {
             status = NV_BADPARM_S;
           }
           else /* Valid index */
           {
             status = nvimw_write_fixed_array(cmd_ptr->item,
                                              index,
                                              ((byte *)cmd_ptr->data_ptr) + sizeof(index),
                                              nv_op_get_size(cmd_ptr->item));
           }

           /* Turn back on permanent file attribute */
           nvim_update_fs_item_file_attrs(
                 nv_op_get_fparams(cmd_ptr->item), FS_FA_SYS_PERMANENT);

         #else
           status = NV_BADPARM_S;
         #endif


         return status;

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

#ifdef NV_FEATURE_FACTORY_INFO
      case NV_FACTORY_INFO_I:
        /* Write the item */
        status = nvimw_write_factory(cmd_ptr->data_ptr->fact_info,
                                   (word) NV_FACTORY_INFO_SIZ);

        /* Update the local cache used by peek/poke */
        memcpy(fact_data, (void *) cmd_ptr->data_ptr->fact_info,
               (word) NV_FACTORY_INFO_SIZ);
        return status;
#endif

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

/*  Roaming List is handled differently in the item manager (not a generic case) */
#ifdef NV_FEATURE_PRL_ITEMS

  #ifdef NV_FEATURE_IS683A_PRL
      case NV_ROAMING_LIST_683_I:
        status = nvimw_write_roaming_list(cmd_ptr);
        return status;
  #else
      case NV_ROAMING_LIST_I:
        status = nvimw_write_roaming_list(cmd_ptr);
        return status;
  #endif
#endif

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

      case NV_BD_ADDR_I:
        #ifdef FEATURE_BT
          #ifdef _SAMSUNG_MP_CUSTOM_RESET
                 if(Master_Reset) 
                    return NV_READONLY_S; 
                 if(ResetMode>0 && ResetMode<MAX_MODE) 
                 {
                    if(keystr == FALSE)return NV_READONLY_S; //sec_system_selee_051106 : keystring reset 矫 檬扁拳
                 }
          #endif
          status = nvimw_write_bd_addr(cmd_ptr);
        #else
          status = NV_BADPARM_S;
        #endif
          return status;

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

⌨️ 快捷键说明

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