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

📄 nvimr.c

📁 free sources for gsm
💻 C
📖 第 1 页 / 共 4 页
字号:
/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*

          N V  I T E M    M A N A G E R    R E A D   S E R V I C E S

GENERAL DESCRIPTION
  This module provides the NV read services using EFS.  The module reads the
  requested item based on the item attributes.

EXTERNALIZED FUNCTIONS
  nvimr_read
    This is the function which reads NV items with EFS simulation.

INITIALIZATION AND SEQUENCING REQUIREMENTS

Copyright (c) 1999, 2000 by QUALCOMM Incorporated.  All Rights Reserved.
Copyright (c) 2001 by QUALCOMM Incorporated.  All Rights Reserved.
*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/

/*===========================================================================

                        EDIT HISTORY FOR MODULE

$PVCSPath:  L:/src/asw/MSM5200/drivers/vcs/nvimr.c_v   1.6   27 Sep 2001 10:14:40   pingguan  $
$Header: //depot/asic/msmshared/services/meta_nv/nvimr.c#11 $ $DateTime: 2005/11/11 20:18:29 $ $Author: pratapc $

when       who     what, where, why
--------   ---     ----------------------------------------------------------
10/21/05   ck      Switched the SMS NV items to item files to support
                   more than 255 messages.
05/27/05   sl      Changed NV_DEVICE_SERIAL_NO_I from W only to R/W
03/22/05   sl      Added support for IMEI restore from OTP to NV
02/26/05   pc      Added support for SFS_ACCESSOR function based read
                   operation on IMEI.
02/20/05   pc      Added support for special treatment for read operations on
                   IMEI and DEVICE_SERIAL_NO. Featurised the same under
                   FEATURE_NV_SUPPORT_FLASH_OTP.
12/16/03   pg      Changed some ERR msg to flag item # instead of file & fpos.
04/14/03   pg      Changed some ERR msg to MSG_HIGH.
01/28/03   pg      Made NV_PPP_PASSWORD_I a non-invariant.
01/21/03   pg      Fixed read location for roaming list in
                   nvimr_read_fixed_array().
09/27/01   pg      Added support for dynamic item NV_SMS_GW_I under
                   FEATURE_GWSMS.
09/24/01   pg      Removed support for NV_IMEI_I and NV_IMEI_CHKSUM_I.
                   These items are no longer used.
                   Added support for special item NV_UE_IMEI_I.
05/15/01   pg      Featurelized function NVIMR_READ_ROAMING_LIST under
                   NV_FEATURE_PRL_ITEMS.
04/13/01   pg      Added support for special items NV_IMEI_I and
                   NV_IMEI_CHKSUM_I.
04/04/01   pg      Added special case to read item NV_BD_ADDR_I.
04/02/01   pg      Deleted some unused variables.
03/30/01   pg      Made changes to make use of the files generated by NVC.
                   Ported to simba MSM5200.
10/24/00   ts      Added NV item access to the RUIM driver when defined.
09/21/00   rp      Moved includes of target.h and comdef.h before
                   #ifdef FEATURE_NV_ITEM_MGR which is around all code.
09/20/00   pg      Added #ifdef FEATURE_NV_ITEM_MGR to whole file.
11-11-99   rp      In nvimr_read_sms now calling fs_test to check for
                   existance of SMS file.
10-08-99   pg      Simplified nvimr_read_rental_cnt() and
                   nvimr_read_rental_timer() because wearing out of eeprom
                   bits is no longer a concern and reading NV_RENTAL_TIMER_I
                   and NV_RENTAL_CNT_I can (almost) be treated as regular
                   item reads.
08-13-99   rp      Initial ASW version.
07-27-99   rp      Cleaned up compiler warnings for fact_data.
07-26-99   rp      Updated NV_FACTORY_INFO_I support to copy from the
                   fact_data cache the latest factory data.
07-06-99   rp      Added support for NV_FACTORY_INFO_I including function
                   nvimr_read_factory() which also supports peek command.
06-23-99   rp      Cleaned up compiler warnings
04-30-99   rp      Initial version.


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

                     INCLUDE FILES FOR MODULE

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

#include "target.h"
#include "comdef.h"

#ifdef FEATURE_NV_SUPPORT_FLASH_OTP
#include "nvimw.h"
#include "flash_otp.h"
#endif

#ifdef FEATURE_NV_ITEM_MGR


#include "nvimr.h"
#include "nvim.h"
#include "msg.h"
#include "crc.h"
#include "err.h"
#include "memory.h"
#include "dog.h"
#include "nv_op.h"

#ifdef FEATURE_NV_RUIM
#include "nvruimi.h"
#endif

#include <stdio.h>
#include "fs_public.h"

/*===========================================================================

                DEFINITIONS AND DECLARATIONS FOR MODULE

This section contains definitions for constants, macros, types, variables
and other items needed by this module.

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

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/*                                                                         */
/*                         DATA DEFINITIONS                                */
/*                                                                         */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

extern nvi_item_type     nvi_item;

//whlee. DRX Toggle mode 备泅阑 困秦 眠啊. ----------
#ifdef _SAMSUNG_PROT_DRX_OFF
boolean is_drx_mode;
#endif

#ifdef FEATURE_SAMSUNG_DUALMODE_IMPROVEMENT
extern boolean dualModePerfImprove_enabled_nv;
#endif

#ifdef _SAMSUNG_HW_USB_SELECT
extern byte usb_driver;
#endif /* _SAMSUNG_HW_USB_SELECT */

#ifdef NV_FEATURE_RENTAL_ITEMS
#error code not present
#endif

#ifdef NV_FEATURE_FACTORY_INFO
  /* Factory data block cache for peek/poke access */
  extern byte fact_data[NVIM_FACTORY_DATA_SIZE];
#endif

#ifdef _SAMSUNG_PROT_GCF_VERSION
boolean samsung_gcf_test_nv;                   //whlee. 2004_1112. To mode change for GCF Version
#endif

#ifdef _SAMSUNG_PROT_ADJUST_C1_THRESHOLD
int C1_threshold;                            //whlee. 2004_1206. To adjust C1 threshold. Variable for threshold correspond to NV item value.
#endif //_SAMSUNG_PROT_ADJUST_C1_THRESHOLD
//ccy_pwron_attach_mode_realization(
#ifdef _SAMSUNG_PROT_PWR_ON_ATT
boolean pwron_att_manualmode_on;
#endif
//)
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/*                                                                         */
/*                      REX Timers and Queues                              */
/*                                                                         */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/*                                                                         */
/*                            Local Data                                   */
/*                                                                         */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/*                                                                         */
/*                            Debug Data                                   */
/*                                                                         */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/*                                                                         */
/*                               Macros                                    */
/*                                                                         */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

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

FUNCTION NVR_TRANSLATE_TO_EXTERNAL

DESCRIPTION
  This function translates a digit from internal 4 bit NVM storage
  to external 8 bit ASCII representation.

DEPENDENCIES
  None.

RETURN VALUE
  The 8 bit ASCII digit value.

SIDE EFFECTS
  None.

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

LOCAL byte nvr_translate_to_external
(
  byte   digit    /* Internal digit representation */
)
{
  if (digit <= 0x09) return(digit + '0');
  else if (digit == 0x0A) return('*');
  else if (digit == 0x0B) return('#');
  else if (digit == 0x0C) return('-');
  else if (digit == 0x0D) return('P');
  else if (digit == 0x0E) return('T');
  else return('L');

} /* nvr_translate_to_external */

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

FUNCTION NVIMR_READ_FACTORY

DESCRIPTION
  This function reads data from the factory data block ($SYS.FACTORY file).

DEPENDENCIES
  None.

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

SIDE EFFECTS
  None

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

nv_stat_enum_type nvimr_read_factory
(
  PACKED void *data_ptr,  /* Pointer to read data */
  word offset,            /* Start offset into factory data area for read */
  word size               /* Size of data to read */
)
{
   word              start_addr;       /* Start address of read */
   nv_stat_enum_type status;           /* Status to return */
   fs_rsp_msg_type   rsp_msg;          /* EFS response status */
   fs_handle_type    fhandle;          /* Handle of file to write to */
   dword             bytes_read;

   /* Read from the factory data file */
   /* Get the actual offset into the file */
   start_addr = offset + FACTORY_FILE_RESERVED;

   /* Open the factory data file */
   fs_open(nvim_factory_file(), /* Name of file to open */
           FS_OA_READONLY,   /* Open mode */
           NULL,             /* No optional parameters */
           NULL,             /* Callback function ptr */
           &rsp_msg);        /* Response message ptr */

   if (rsp_msg.open.handle != FS_NULL_HANDLE)
   {
      fhandle = rsp_msg.open.handle;  /* save file handle */
      /* Seek to offset in the file */
      fs_seek( fhandle,  /* file handle */
               FS_SEEK_SET, /* file origin */
               start_addr,  /* file position */
               NULL,    /* callback_function */
               &rsp_msg); /* message ptr */

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

      /* Read factory data from this file */
      if (rsp_msg.seek.status == FS_OKAY_S)
      {
         fs_read( fhandle,    /* file handle */
                  data_ptr,   /* source to store bytes */
                  size,       /* # bytes to read */
                  NULL,       /* callback_function */
                  &rsp_msg);  /* message ptr */
         bytes_read = rsp_msg.read.count;
      }
      else
      {
         bytes_read = 0;
      }

      /* FF fill if necessary due to file read not satisfying peek */
      while (bytes_read < size)
      {
         *((byte *) (((byte *)(data_ptr)) + bytes_read++)) = 0xFF;
      }

      /* Close this file */
      fs_close(fhandle,         /* Handle of file to close */
               NULL,            /* Callback function ptr */
               &rsp_msg);       /* Response message ptr */

      status = NV_DONE_S;
   }
   else
   {
      ERR("Unable to open factory data file %s",
           nvim_factory_file(), 0, 0);
      status = NV_FAIL_S;
   }

   return status;
}

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

FUNCTION NVIMR_READ_DIAL

DESCRIPTION
  This procedure processes read requests for speed dial numbers.  It reads
  the NVM item using EFS services and it performs necessary translations
  and copy from internal format to external format.

DEPENDENCIES
  None.

RETURN VALUE
  Status of the read request.

SIDE EFFECTS
  None.

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

LOCAL nv_stat_enum_type nvimr_read_dial
(
  nv_items_enum_type    item,         /* Item to access */
  byte                  index_range,  /* Maximum allowed range for index */
  byte                  index,        /* speed dial # */
  nv_dial_type          *dial_ptr     /* Pointer to write source buffer */
)
{
  word   i;                           /* Digit index */
  word ndigits;                       /* # of digits being processed */
  nv_stat_enum_type status; /* Status to return to calling procedure */

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

  /* Read the number from NVM into internal buffer. */
  /* Note that this data structure has a target specific member,
   * which dictates the member name we start the read into, in order
   * to skip the 'active' byte.
   */

  if (index >= index_range)
  {
    return NV_BADPARM_S;
  }

  status = nvimr_read_fixed_array(
                                  item,
                                  index,
#ifdef NV_FEATURE_EXTENDED_UI
                                  &nvi_item.dial.status,     /* skip "active" item */
#else
                                  &nvi_item.dial.num_digits, /* skip "active" item */
#endif
                                  sizeof(nvi_item.dial));
  if(status == NV_DONE_S)
  {
    /* Copy the number of dial digits stored, making  */
    /* sure that if there was an NVM error only the   */
    /* maximum number of dialed digits will be read.  */

    dial_ptr->num_digits = MIN(nvi_item.dial.num_digits, NV_MAX_DIAL_DIGITS);

    /* Copy the digits, expanding from two digits per  */
    /* byte into one digits per byte, and translating  */
    /* the digit to external character representation. */

⌨️ 快捷键说明

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