1 /*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*
\r
3 N V I T E M M A N A G E R IO S E R V I C E S
\r
6 This module provides the NV I/O services using EFS items.
\r
8 EXTERNALIZED FUNCTIONS
\r
10 This is the function which writes NV items into the EFS.
\r
12 This is the function which reads NV items from the EFS.
\r
14 INITIALIZATION AND SEQUENCING REQUIREMENTS
\r
16 Copyright (c) 2005-2010 by QUALCOMM, Incorporated.
\r
17 All Rights Reserved.
\r
18 Qualcomm Confidential and Proprietary
\r
19 *====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/
\r
20 /*===========================================================================
\r
23 EDIT HISTORY FOR MODULE
\r
25 This section contains comments describing changes made to the module.
\r
26 Notice that changes are listed in reverse chronological order.
\r
28 $Header: //source/qcom/qct/core/pkg/2H09/halcyon_modem/rel/LA2.0/AMSS/products/7x30/core/services/nv/src/nvio.c#1 $
\r
30 when who what, where, why
\r
31 -------- --- ----------------------------------------------------------
\r
32 09/25/09 pc Dual SIM/Dual Standby support for LCU
\r
33 05/27/09 sri included header file nvio.h, modified function prototype
\r
34 nvio_read_prl_item()
\r
35 04/01/09 sri nvio_write_roaming_list modified to avoid write_buf
\r
37 05/04/05 pc Creation of NV2
\r
40 ===========================================================================*/
\r
42 /*===========================================================================
\r
44 INCLUDE FILES FOR MODULE
\r
46 ===========================================================================*/
\r
51 #ifdef FEATURE_NV_ITEM_MGR
\r
60 #include "fs_public.h"
\r
61 #include "nv_items.h"
\r
64 #ifdef FEATURE_NV_RUIM
\r
65 #include "nvruimi.h"
\r
68 #ifdef FEATURE_NV_SUPPORT_FLASH_OTP
\r
69 #include "flash_otp.h"
\r
72 #ifdef FEATURE_NV_SFS_PRIVATE
\r
73 #include "sfs_private.h"
\r
76 /*===========================================================================
\r
78 DEFINITIONS AND DECLARATIONS FOR MODULE
\r
80 This section contains definitions for constants, macros, types, variables
\r
81 and other items needed by this module.
\r
83 ===========================================================================*/
\r
85 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
87 /* DATA DEFINITIONS */
\r
89 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
91 extern nvi_item_type nvi_item;
\r
92 extern boolean nvi_initialized;
\r
94 #ifdef NV_FEATURE_RENTAL_ITEMS
\r
95 #error code not present
\r
98 #ifdef NV_FEATURE_FACTORY_INFO
\r
99 /* Factory data block cache for peek/poke access */
\r
100 extern byte fact_data[NVIM_FACTORY_DATA_SIZE];
\r
103 /* Dynamic pool available in EFS */
\r
104 extern word nvi_memavail_data;
\r
106 extern boolean nv_prl_valid_data[NV_MAX_NAMS];
\r
107 extern word nv_prl_version_data[NV_MAX_NAMS];
\r
109 rex_crit_sect_type nv_crit_sect;
\r
111 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
113 /* REX Timers and Queues */
\r
115 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
117 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
121 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
123 #ifdef NV_FEATURE_DIAG_WINS
\r
124 static boolean write_gate_open = TRUE;
\r
128 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
131 /*===========================================================================
\r
133 FUNCTION NVR_TRANSLATE_TO_EXTERNAL
\r
136 This function translates a digit from internal 4 bit NVM storage
\r
137 to external 8 bit ASCII representation.
\r
143 The 8 bit ASCII digit value.
\r
148 ===========================================================================*/
\r
151 nvr_translate_to_external (
\r
152 byte digit /* Internal digit representation */
\r
155 if (digit <= 0x09) return(digit + '0');
\r
156 else if (digit == 0x0A) return('*');
\r
157 else if (digit == 0x0B) return('#');
\r
158 else if (digit == 0x0C) return('-');
\r
159 else if (digit == 0x0D) return('P');
\r
160 else if (digit == 0x0E) return('T');
\r
163 } /* nvr_translate_to_external */
\r
165 /*===========================================================================
\r
167 FUNCTION NVIO_READ_ITEM
\r
170 This function reads an NV item from NV database.
\r
176 NV_DONE_S if it worked
\r
177 NV_FAIL_S if it did not work.
\r
181 ===========================================================================*/
\r
184 nv_items_enum_type item,
\r
193 nv_stat_enum_type status;
\r
194 struct fs_stat temp_buf;
\r
196 /* Create the name of the item file */
\r
197 /* Check if context is defined while constructing pathname */
\r
198 if (context == 0) { /* No context is defined, use old pathname */
\r
200 (void)snprintf(f_name,sizeof(f_name),"/nvm/num/%d",item);
\r
202 (void)snprintf(f_name,sizeof(f_name),"/nvm/num/%d_%d",item,index);
\r
204 else { /* use context while constructing pathname*/
\r
206 (void)snprintf(f_name,sizeof(f_name),"/nvm/context%d/%d",context,item);
\r
208 (void)snprintf(f_name,sizeof(f_name),"/nvm/context%d/%d_%d",context,item,index);
\r
211 /* Check if the file is present or not. */
\r
212 if(efs_stat(f_name,&temp_buf) == -1) {
\r
213 return NV_NOTACTIVE_S;
\r
216 if((temp_buf.st_size) != (nvim_op_get_size(item)))
\r
218 (void)efs_unlink(f_name);
\r
219 return NV_NOTACTIVE_S;
\r
222 /* Obtain the contents from EFS */
\r
223 return_size = efs_get(f_name, data_ptr, item_size);
\r
225 if (return_size == -1)
\r
226 status = NV_FAIL_S;
\r
228 status = NV_DONE_S;
\r
231 } /* End of nvio_read_item*/
\r
234 /*===========================================================================
\r
236 FUNCTION NVIO_READ_DIAL
\r
239 This procedure processes read requests for speed dial numbers. It reads
\r
240 the NV item and it performs necessary translations and copy from internal
\r
241 format to external format.
\r
247 Status of the read request.
\r
252 ===========================================================================*/
\r
254 LOCAL nv_stat_enum_type
\r
256 nv_items_enum_type item, /* Item to access */
\r
257 byte index_range, /* Maximum allowed range for index */
\r
258 byte index, /* speed dial # */
\r
259 nv_dial_type *dial_ptr, /* Pointer to write source buffer */
\r
260 byte item_context /* Context for NV path */
\r
263 word i; /* Digit index */
\r
264 word ndigits; /* # of digits being processed */
\r
265 nv_stat_enum_type status; /* Status to return to calling procedure */
\r
267 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
269 /* Read the number from NVM into internal buffer. */
\r
271 if (index >= index_range) {
\r
272 return NV_BADPARM_S;
\r
275 status = nvio_read_item(
\r
278 #ifdef NV_FEATURE_EXTENDED_UI
\r
279 (byte*)&nvi_item.dial.status,
\r
281 (byte*)&nvi_item.dial.num_digits,
\r
283 sizeof(nvi_item.dial),
\r
285 if(status == NV_DONE_S)
\r
287 /* Copy the number of dial digits stored, making */
\r
288 /* sure that if there was an NV error only the */
\r
289 /* maximum number of dialed digits will be read. */
\r
291 dial_ptr->num_digits = MIN(nvi_item.dial.num_digits, NV_MAX_DIAL_DIGITS);
\r
293 /* Copy the digits, expanding from two digits per */
\r
294 /* byte into one digits per byte, and translating */
\r
295 /* the digit to external character representation. */
\r
297 ndigits = dial_ptr->num_digits;
\r
298 for (i = 0; i < ndigits; i++) {
\r
300 /* Even digits are copied from least significant digit, */
\r
301 /* odd digits are copied from most significant digit. */
\r
304 dial_ptr->digits[i] =
\r
305 nvr_translate_to_external(
\r
306 (byte)(nvi_item.dial.digits[i/2] & 0x0F));
\r
309 dial_ptr->digits[i] =
\r
310 nvr_translate_to_external(
\r
311 (byte)((nvi_item.dial.digits[i/2] & 0xF0) >> 4));
\r
315 /* Move name into external type. */
\r
316 (void)memcpy((void *) dial_ptr->letters, (void *) nvi_item.dial.letters,
\r
320 #ifdef NV_FEATURE_EXTENDED_UI
\r
321 dial_ptr->status = nvi_item.dial.status;
\r
325 } /* nvio_read_dial */
\r
328 /*===========================================================================
\r
330 FUNCTION NVIO_READ_STDIAL
\r
333 This procedure processes read requests for speed dial numbers. It reads
\r
334 the NV item and it performs necessary translations and copy from internal
\r
335 format to external format.
\r
341 Status of the read request.
\r
346 ===========================================================================*/
\r
348 LOCAL nv_stat_enum_type
\r
350 nv_items_enum_type item, /* Item to access */
\r
351 byte index_range, /* Maximum allowed range for index */
\r
352 byte index, /* speed dial # */
\r
353 nv_stdial_type *dial_ptr, /* Pointer to write source buffer */
\r
354 byte item_context /* Context for NV path */
\r
357 word i; /* Digit index */
\r
358 nv_stat_enum_type status; /* Status to return to calling procedure */
\r
360 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
362 /* Read the number from NV into internal buffer. */
\r
364 if (index >= index_range) return NV_BADPARM_S;
\r
366 status = nvio_read_item(
\r
369 #ifdef NV_FEATURE_EXTENDED_UI
\r
370 (byte*)&nvi_item.stack.status,
\r
372 (byte*)&nvi_item.stack.num_digits,
\r
374 sizeof(nvi_item.stack),
\r
377 if(status == NV_DONE_S)
\r
379 /* Copy the number of dial digits stored, making */
\r
380 /* sure that if there was an NVM error only the */
\r
381 /* maximum number of dialed digits will be read. */
\r
383 dial_ptr->num_digits = MIN(nvi_item.stack.num_digits, NV_MAX_DIAL_DIGITS);
\r
385 /* Copy the digits, expanding from two digits per */
\r
386 /* byte into one digits per byte, and translating */
\r
387 /* the digit to external character representation. */
\r
389 for (i = 0; i < dial_ptr->num_digits; i++) {
\r
391 /* Even digits are copied from least significant digit, */
\r
392 /* odd digits are copied from most significant digit. */
\r
395 dial_ptr->digits[i] = nvr_translate_to_external((byte)(nvi_item.stack.digits[i/2] & 0x0F));
\r
397 dial_ptr->digits[i] = nvr_translate_to_external((byte)((nvi_item.stack.digits[i/2] & 0xF0) >> 4));
\r
400 /* Move name into external type. */
\r
401 (void)memcpy((void *) dial_ptr->letters, (void *) nvi_item.stack.letters,
\r
405 #ifdef NV_FEATURE_EXTENDED_UI
\r
406 dial_ptr->status = nvi_item.stack.status;
\r
407 dial_ptr->time_stamp = nvi_item.stack.time_stamp;
\r
408 dial_ptr->duration = nvi_item.stack.duration;
\r
412 } /* nvio_read_stdial */
\r
415 /*===========================================================================
\r
417 FUNCTION NVIO_READ_SMS
\r
420 This function reads an sms depending upon the address (index) of sms
\r
421 passed into it via the cmd_ptr.
\r
427 NV_DONE_S if it worked
\r
428 NV_BADPARM_S if requested bytes are out of range for NVM
\r
433 ===========================================================================*/
\r
435 LOCAL nv_stat_enum_type
\r
437 nv_cmd_ext_type *cmd_ext_ptr /* Command block */
\r
441 /* Increase size of sms name from 20 to 28 to accomodate
\r
442 the 8 characters for context */
\r
444 nv_stat_enum_type status = NV_DONE_S;
\r
445 struct fs_stat temp_buf;
\r
447 /* only sms supported at this time */
\r
448 if(((cmd_ext_ptr->nvcmd->item != NV_SMS_I) && (cmd_ext_ptr->nvcmd->item != NV_SMS_DM_I))
\r
449 || (cmd_ext_ptr->nvcmd->data_ptr->sms.address >= NVI_MAX_SMS_ADDR)) {
\r
450 status = NV_BADPARM_S;
\r
454 /* Reset the watchdog timer */
\r
457 /* Create the name of the file to be read */
\r
458 /* Check if context is defined*/
\r
459 if (cmd_ext_ptr->context == 0) /* Context is not defined*/
\r
460 (void) snprintf(sms_name, sizeof(sms_name), "/nvm/sms_%05d",
\r
461 cmd_ext_ptr->nvcmd->data_ptr->sms.address);
\r
462 else /* Context is defined */
\r
463 (void) snprintf(sms_name, sizeof(sms_name), "/nvm/context%d/sms_%05d",
\r
464 cmd_ext_ptr->context,
\r
465 cmd_ext_ptr->nvcmd->data_ptr->sms.address);
\r
467 /* Check if the file present or not. */
\r
468 if(efs_stat(sms_name,&temp_buf) == -1) {
\r
469 status = NV_NOTACTIVE_S;
\r
473 if(((cmd_ext_ptr->nvcmd->item == NV_SMS_I)&&
\r
474 (temp_buf.st_size > (NV_SMS_DATA_SIZ + sizeof(nvi_sms_type))))
\r
475 ||((cmd_ext_ptr->nvcmd->item == NV_SMS_DM_I)&&
\r
476 (temp_buf.st_size > (NV_SMS_DATA_SIZ + sizeof(nvi_sms_type))))){
\r
477 QSR_MSG_HIGH ( 305830160ULL, "SMS Buffer not big enough for slot %d",
\r
478 cmd_ext_ptr->nvcmd->data_ptr->sms.address, 0, 0);//auto-gen, to change remove 'QSR_' and first param
\r
479 status = NV_FAIL_S;
\r
483 /* Read the contents from EFS */
\r
484 return_size = efs_get( sms_name,
\r
485 (byte *)&(cmd_ext_ptr->nvcmd->data_ptr->sms.address),
\r
486 (int)temp_buf.st_size);
\r
487 if(return_size == -1) {
\r
488 status = NV_FAIL_S;
\r
494 } /* nvio_read_sms */
\r
497 #ifdef FEATURE_GWSMS
\r
498 /*===========================================================================
\r
500 FUNCTION NVIO_READ_SMS_GW
\r
503 This function reads from an sms_gw location
\r
509 NV_DONE_S if it worked
\r
510 NV_BADPARM_S if requested bytes are out of range for NVM
\r
515 ===========================================================================*/
\r
517 LOCAL nv_stat_enum_type
\r
519 nv_cmd_ext_type *cmd_ext_ptr /* Command block */
\r
523 char sms_name[28];/* Incrementing size from 20 to 28 for context*/
\r
524 nv_stat_enum_type status = NV_DONE_S;
\r
525 struct fs_stat temp_buf;
\r
527 if ((cmd_ext_ptr->nvcmd->item != NV_SMS_GW_I)||
\r
528 (cmd_ext_ptr->nvcmd->data_ptr->sms_gw.address >= NVI_MAX_SMS_ADDR)) {
\r
529 status = NV_BADPARM_S;
\r
533 /* Reset the watchdog timer */
\r
536 /* Create the name of the file being read.*/
\r
537 if (cmd_ext_ptr->context == 0) /* No context defined */
\r
538 (void)snprintf(sms_name, sizeof(sms_name), "/nvm/sms_gw_%05d",
\r
539 cmd_ext_ptr->nvcmd->data_ptr->sms_gw.address);
\r
540 else /* Context defined */
\r
541 (void)snprintf(sms_name, sizeof(sms_name), "/nvm/context%d/sms_gw_%05d",
\r
542 cmd_ext_ptr->context,
\r
543 cmd_ext_ptr->nvcmd->data_ptr->sms_gw.address);
\r
544 /* Check if the file is present or not. */
\r
545 if(efs_stat(sms_name,&temp_buf) == -1){
\r
546 status = NV_NOTACTIVE_S;
\r
549 if (temp_buf.st_size > (NV_SMS_GW_DATA_SIZ + sizeof(nvi_sms_gw_type))) {
\r
550 /* Buffer not big enough to hold the message */
\r
551 QSR_MSG_HIGH ( 305830160ULL, "SMS Buffer not big enough for slot %d",
\r
552 cmd_ext_ptr->nvcmd->data_ptr->sms_gw.address, 0, 0);//auto-gen, to change remove 'QSR_' and first param
\r
553 status = NV_FAIL_S;
\r
556 /* Extract the data from EFS */
\r
557 return_size = efs_get( sms_name,
\r
558 (byte *)&(cmd_ext_ptr->nvcmd->data_ptr->sms_gw.address),
\r
559 (int)temp_buf.st_size);
\r
560 if(return_size == -1) {
\r
561 status = NV_FAIL_S;
\r
567 } /* nvio_read_sms_gw */
\r
571 /*===========================================================================
\r
573 FUNCTION NVIO_READ_PRL_ITEM
\r
576 This function reads a PRL item from NVM directory
\r
582 NV_DONE_S if it worked
\r
583 NV_FAIL_S if it did not work.
\r
587 ===========================================================================*/
\r
589 nvio_read_prl_item (
\r
595 nv_stat_enum_type status; /* Function return value */
\r
598 struct fs_stat temp_buf;
\r
600 fs_ssize_t result = 0;
\r
602 fs_size_t bytes_read;
\r
604 QSR_MSG_MED( 2779538831ULL, "size: %d", item_size, 0, 0);//auto-gen, to change remove 'QSR_' and first param
\r
606 snprintf(f_name,sizeof(f_name),"/nvm/prl_%d",num);
\r
608 /* Check if the file is present or not. */
\r
609 if(efs_stat(f_name,&temp_buf) == -1) {
\r
610 return NV_NOTACTIVE_S;
\r
613 fd = efs_open(f_name, O_RDWR, 0777 );
\r
615 nbytes = item_size;
\r
616 read_buf = data_ptr;
\r
619 (void *) (read_buf),
\r
622 efs_lseek(fd,sizeof(boolean),SEEK_CUR);
\r
626 while (bytes_read < nbytes)
\r
628 result = efs_read (fd,
\r
629 (void *) (read_buf + bytes_read),
\r
630 nbytes - bytes_read);
\r
633 bytes_read += (fs_size_t) result;
\r
638 if (result == -1) {
\r
639 status = NV_FAIL_S;
\r
641 else status = NV_DONE_S;
\r
643 if (status == NV_DONE_S) {
\r
644 nv_prl_version_data[num] = ((nv_roaming_list_header_type *)read_buf)->prl_version;
\r
645 nv_prl_valid_data[num] = ((nv_roaming_list_header_type *)read_buf)->valid;
\r
648 nv_prl_version_data[num] = NV_PRL_VERSION_INVALID;
\r
649 nv_prl_valid_data[num] = FALSE;
\r
656 /*===========================================================================
\r
658 FUNCTION NVIO_READ_RENTAL_TIMER
\r
661 This function returns the current value of the rental timer item. Since
\r
662 this item is expected to be updated with very high frequency, it is stored
\r
663 in a way that minimizes EEPROM cell wear. This unusual storage format
\r
664 calls for a special routine to compute and return the value for reads.
\r
670 NV_DONE_S if it worked
\r
671 NV_NOTACTIVE_S if the item is uninitialized
\r
676 ===========================================================================*/
\r
677 #ifdef NV_FEATURE_RENTAL_ITEMS
\r
678 #error code not present
\r
682 /*===========================================================================
\r
684 FUNCTION NVIO_READ_RENTAL_CNT
\r
687 This function returns the current value of the rental count item. Since
\r
688 this item is a fixed-pool double-buffered item, it needs a special read
\r
695 NV_DONE_S if it worked
\r
696 NV_NOTACTIVE_S if the item is uninitialized
\r
701 ===========================================================================*/
\r
702 #ifdef NV_FEATURE_RENTAL_ITEMS
\r
703 #error code not present
\r
707 #ifdef NV_FEATURE_PRL_ITEMS
\r
708 /*===========================================================================
\r
710 FUNCTION NVIO_READ_ROAMING_LIST
\r
713 This function reads the roaming list.
\r
719 NV_DONE_S if it worked
\r
720 NV_BADPARM_S if requested bytes are out of range for NVM
\r
725 ===========================================================================*/
\r
727 LOCAL nv_stat_enum_type
\r
728 nvio_read_roaming_list (
\r
729 nv_cmd_ext_type *cmd_ext_ptr
\r
732 word item_size; /* Size of item (in bytes) */
\r
733 nv_stat_enum_type status; /* Function return value */
\r
735 char f_name[128]; /* Increase size from 120 to 128 for context*/
\r
736 struct fs_stat temp_buf;
\r
738 fs_ssize_t result = 0;
\r
740 fs_size_t bytes_read;
\r
743 /* Check for illegal NAM */
\r
744 if(cmd_ext_ptr->nvcmd->data_ptr->roaming_list.nam >= NV_MAX_NAMS) {
\r
745 return NV_BADPARM_S;
\r
749 item_size = NV_ROAMING_LIST_HEADER_SIZE +
\r
750 nv_max_size_of_roaming_list();
\r
753 QSR_MSG_MED( 2779538831ULL, "size: %d", item_size, 0, 0);//auto-gen, to change remove 'QSR_' and first param
\r
755 if (cmd_ext_ptr->context == 0) /* No context is defined*/
\r
756 snprintf(f_name,sizeof(f_name),"/nvm/prl_%d",
\r
757 cmd_ext_ptr->nvcmd->data_ptr->roaming_list.nam);
\r
758 else /* Context is defined */
\r
759 snprintf(f_name,sizeof(f_name),"/nvm/context%d/prl_%d",
\r
760 cmd_ext_ptr->context,cmd_ext_ptr->nvcmd->data_ptr->roaming_list.nam);
\r
762 /* Check if the file is present or not. */
\r
763 if(efs_stat(f_name,&temp_buf) == -1) {
\r
764 return NV_NOTACTIVE_S;
\r
767 fd = efs_open(f_name, O_RDWR, 0777 );
\r
769 nbytes = item_size;
\r
771 read_buf = (void *) &(cmd_ext_ptr->nvcmd->data_ptr->roaming_list.prl_version);
\r
774 sizeof(nam_flag) + sizeof(cmd_ext_ptr->nvcmd->data_ptr->roaming_list.nam),
\r
777 while (bytes_read < nbytes)
\r
779 result = efs_read (fd,
\r
780 (void *) (read_buf + bytes_read),
\r
781 nbytes - bytes_read);
\r
784 bytes_read += (fs_size_t) result;
\r
789 if (result == -1) {
\r
790 status = NV_FAIL_S;
\r
792 else status = NV_DONE_S;
\r
794 if (status == NV_DONE_S) {
\r
795 nv_prl_version_data[cmd_ext_ptr->nvcmd->data_ptr->roaming_list.nam] = cmd_ext_ptr->nvcmd->data_ptr->roaming_list.prl_version;
\r
796 nv_prl_valid_data[cmd_ext_ptr->nvcmd->data_ptr->roaming_list.nam] = cmd_ext_ptr->nvcmd->data_ptr->roaming_list.valid;
\r
799 nv_prl_version_data[cmd_ext_ptr->nvcmd->data_ptr->roaming_list.nam] = NV_PRL_VERSION_INVALID;
\r
800 nv_prl_valid_data[cmd_ext_ptr->nvcmd->data_ptr->roaming_list.nam] = FALSE;
\r
804 } /* nvio_read_roaming_list */
\r
809 /*===========================================================================
\r
814 This procedure processes NVM read requests. It checks to make sure
\r
815 that a valid item has been requested, it reads the NVM item using EFS
\r
816 services and it performs the translation from internal NVM format to
\r
817 external format. If the item being read requires no special processing,
\r
818 it is passed on to nvimio_io().
\r
824 Status of read operation.
\r
829 ===========================================================================*/
\r
833 nv_cmd_ext_type *cmd_ext_ptr /* Pointer to Command block */
\r
836 nv_stat_enum_type status; /* Status to return to calling procedure */
\r
837 dword local_esn_chksum; /* buffer for esn chksum */
\r
840 byte index; /* Specific index of an array */
\r
841 #ifdef FEATURE_NV_SFS_PRIVATE
\r
842 sfs_priv_errno_enum_type sfs_ret = 0;
\r
845 #ifdef FEATURE_NV_SUPPORT_FLASH_OTP
\r
846 FlashOTP_ReturnType otp_ret_val;
\r
847 FlashOTP_ProtectOp_ReturnType otp_prot_ret_val;
\r
848 byte local_imei[NV_UE_IMEI_SIZE];
\r
852 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
854 /* If item code is out of range return with bad parameter status. */
\r
856 if (cmd_ext_ptr->nvcmd->item >= NV_MAX_I) {
\r
857 return NV_BADPARM_S;
\r
861 #ifdef FEATURE_NV_RUIM
\r
863 /* If the R-UIM supports the item,
\r
864 * return the status else use "regular" NVM.
\r
866 if (cmd_ext_ptr->context == 0) {
\r
867 if ( nvruim_read(cmd_ext_ptr->nvcmd, &status) == NV_RUIM_SUPPORTS_ITEM ){
\r
868 if (cmd_ext_ptr->nvcmd->item == NV_ROAMING_LIST_683_I)
\r
870 if (status == NV_DONE_S) {
\r
871 nv_prl_version_data[cmd_ext_ptr->nvcmd->data_ptr->roaming_list.nam] = cmd_ext_ptr->nvcmd->data_ptr->roaming_list.prl_version;
\r
872 nv_prl_valid_data[cmd_ext_ptr->nvcmd->data_ptr->roaming_list.nam] = cmd_ext_ptr->nvcmd->data_ptr->roaming_list.valid;
\r
875 nv_prl_version_data[cmd_ext_ptr->nvcmd->data_ptr->roaming_list.nam] = NV_PRL_VERSION_INVALID;
\r
876 nv_prl_valid_data[cmd_ext_ptr->nvcmd->data_ptr->roaming_list.nam] = FALSE;
\r
882 #ifdef FEATURE_DUAL_STANDBY
\r
884 if ( nvruim_read_ext(cmd_ext_ptr, &status) == NV_RUIM_SUPPORTS_ITEM ){
\r
885 if (cmd_ext_ptr->nvcmd->item == NV_ROAMING_LIST_683_I)
\r
887 if (status == NV_DONE_S) {
\r
888 nv_prl_version_data[cmd_ext_ptr->nvcmd->data_ptr->roaming_list.nam] = cmd_ext_ptr->nvcmd->data_ptr->roaming_list.prl_version;
\r
889 nv_prl_valid_data[cmd_ext_ptr->nvcmd->data_ptr->roaming_list.nam] = cmd_ext_ptr->nvcmd->data_ptr->roaming_list.valid;
\r
892 nv_prl_version_data[cmd_ext_ptr->nvcmd->data_ptr->roaming_list.nam] = NV_PRL_VERSION_INVALID;
\r
893 nv_prl_valid_data[cmd_ext_ptr->nvcmd->data_ptr->roaming_list.nam] = FALSE;
\r
902 switch (cmd_ext_ptr->nvcmd->item) {
\r
904 /* read up data item, do special processing if required */
\r
906 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
907 /* This item is a special case for writes, so it has no generic path in
\r
908 * nvimio_io(). Thus we have to handle the read of this item specially.
\r
912 status = nvio_read_item(NV_ESN_I,/* file handle */
\r
914 (byte *)&cmd_ext_ptr->nvcmd->data_ptr->esn, /* data ptr */
\r
915 sizeof(nvi_item.esn),/* data count */
\r
916 cmd_ext_ptr->context); /* SIM context */
\r
918 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
920 /* Since NV_ESN_ME is a shadow variable for ESN in EFS, return the value
\r
926 status = nvio_read_item(NV_ESN_I,/* file handle */
\r
928 (byte *)&cmd_ext_ptr->nvcmd->data_ptr->esn_me, /* data ptr */
\r
929 sizeof(nvi_item.esn), /* data count */
\r
930 cmd_ext_ptr->context); /* SIM context */
\r
933 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
935 /* ESN checksum read returns the status of */
\r
936 /* the checksum, NOT the checksum itself. */
\r
938 case NV_ESN_CHKSUM_I:
\r
940 /* First read the ESN itself into a local buffer. */
\r
941 status = nvio_read_item(NV_ESN_I,/* file handle */
\r
943 (byte*)&local_esn, /* data ptr */
\r
944 sizeof(local_esn), /* data count */
\r
945 cmd_ext_ptr->context); /* SIM context */
\r
947 if(status != NV_DONE_S)
\r
950 /* Next read the ESN checksum into a local buffer. */
\r
951 status = nvio_read_item(NV_ESN_CHKSUM_I, /* file handle */
\r
953 &local_esn_chksum, /* data ptr */
\r
954 sizeof(local_esn_chksum), /* data count */
\r
955 cmd_ext_ptr->context); /* SIM context */
\r
957 if(status != NV_DONE_S)
\r
959 /* Next compute the ESN checksum and compare against */
\r
960 /* the stored checksum. Return its status to caller. */
\r
962 if (crc_30_calc((byte *)&local_esn,
\r
963 sizeof(local_esn) * 8) == local_esn_chksum) {
\r
964 cmd_ext_ptr->nvcmd->data_ptr->esn_chksum.chksum = NV_VALID_ESN_CHKSUM;
\r
967 cmd_ext_ptr->nvcmd->data_ptr->esn_chksum.chksum = ~NV_VALID_ESN_CHKSUM;
\r
969 status = NV_DONE_S;
\r
972 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
974 /* Since NV_MEID_ME is a shadow variable for MEID in EFS, return the value
\r
980 status = nvio_read_item(NV_MEID_I,/* file handle */
\r
982 (byte *)cmd_ext_ptr->nvcmd->data_ptr, /* data ptr */
\r
983 nvim_op_get_size(cmd_ext_ptr->nvcmd->item),/* data count */
\r
984 cmd_ext_ptr->context); /* SIM context */
\r
986 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
988 #ifdef FEATURE_NV_SUPPORT_FLASH_OTP
\r
992 /* Check whether OTP area is programmed */
\r
993 otp_prot_ret_val = flash_otp_status();
\r
995 /* If the protection is not active, then return NV data */
\r
996 if ((otp_prot_ret_val == FLASH_OTP_PROTECTION_INACTIVE) ||
\r
997 (otp_prot_ret_val == FLASH_OTP_NOT_SUPPORTED)) {
\r
999 status = nvio_read_item(cmd_ext_ptr->nvcmd->item,
\r
1001 (byte *)cmd_ext_ptr->nvcmd->data_ptr,
\r
1002 nvim_op_get_size(cmd_ext_ptr->nvcmd->item),
\r
1003 cmd_ext_ptr->context); /* SIM context */
\r
1007 /* Read from OTP Area */
\r
1008 otp_ret_val = flash_otp_operation(FLASH_OTP_OP_IMEI_READ,
\r
1009 (uint8 *)local_imei);
\r
1011 if (otp_ret_val != FLASH_OTP_IO_SUCCESS) {
\r
1012 QSR_MSG_HIGH ( 2233670895ULL, "OTP Read failure",0,0,0);//auto-gen, to change remove 'QSR_' and first param
\r
1013 status = NV_FAIL_S;
\r
1016 /* Read from NV */
\r
1017 status = nvio_read_item(cmd_ext_ptr->nvcmd->item,
\r
1019 (byte *)cmd_ext_ptr->nvcmd->data_ptr,
\r
1020 nvim_op_get_size(cmd_ext_ptr->nvcmd->item),
\r
1021 cmd_ext_ptr->context); /* SIM context */
\r
1023 if ( (status != NV_DONE_S) && (status != NV_NOTACTIVE_S) ) {
\r
1024 QSR_MSG_HIGH ( 3750100468ULL, "NV Read failure for IMEI",0,0,0);//auto-gen, to change remove 'QSR_' and first param
\r
1028 /* If the IMEI got wiped out, then set it from OTP area */
\r
1029 if ( status == NV_NOTACTIVE_S )
\r
1031 for (i=0; i<NV_UE_IMEI_SIZE; i++)
\r
1032 cmd_ext_ptr->nvcmd->data_ptr->ue_imei.ue_imei[i] = local_imei[i];
\r
1034 status = nvio_write(cmd_ext_ptr);
\r
1036 /* Turn back on permanent file attribute */
\r
1037 if (status == NV_DONE_S) {
\r
1038 QSR_MSG_HIGH ( 2227689700ULL, "IMEI successfully propagated from OTP to NV.",0,0,0);//auto-gen, to change remove 'QSR_' and first param
\r
1042 QSR_MSG_HIGH ( 2226192909ULL, "IMEI could not propagate from OTP to NV.",0,0,0);//auto-gen, to change remove 'QSR_' and first param
\r
1043 return (NV_FAIL_S);
\r
1046 /* Compare the contents of OTP and NV */
\r
1047 if (memcmp(local_imei, (byte *)cmd_ext_ptr->nvcmd->data_ptr->ue_imei.ue_imei,
\r
1048 sizeof(local_imei))==0)
\r
1051 QSR_MSG_HIGH ( 847005925ULL, "OTP and NV contents are same.",0,0,0);//auto-gen, to change remove 'QSR_' and first param
\r
1056 /* Return Failure */
\r
1057 QSR_MSG_HIGH ( 3216026684ULL, "IMEI does not match between OTP and NV",0,0,0);//auto-gen, to change remove 'QSR_' and first param
\r
1058 return (NV_FAIL_S);
\r
1063 #elif defined (FEATURE_NV_SFS_PRIVATE)
\r
1065 case NV_UE_IMEI_I:
\r
1066 sfs_ret = sfs_priv_imei_read((uint8 *)cmd_ext_ptr->nvcmd->data_ptr,
\r
1067 nvim_op_get_size(cmd_ext_ptr->nvcmd->item));
\r
1068 if(sfs_ret == SFS_PRIV_INACTIVE)
\r
1070 return NV_NOTACTIVE_S;
\r
1072 else if(sfs_ret == SFS_PRIV_SUCCESS)
\r
1082 case NV_UE_IMEI_I:
\r
1083 status = nvio_read_item(cmd_ext_ptr->nvcmd->item,
\r
1085 (byte *)cmd_ext_ptr->nvcmd->data_ptr,
\r
1086 nvim_op_get_size(cmd_ext_ptr->nvcmd->item),
\r
1087 cmd_ext_ptr->context);
\r
1090 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
1092 /* This item is a special case for writes, so it has no generic path in
\r
1093 * nvimio_io(). Thus we have to handle the read of this item here
\r
1094 * rather than in nvimio_io().
\r
1096 case NV_VERNO_MAJ_I:
\r
1097 status = nvio_read_item(cmd_ext_ptr->nvcmd->item, /* item ID */
\r
1099 (byte*)&cmd_ext_ptr->nvcmd->data_ptr->verno_maj, /* data ptr */
\r
1100 sizeof(nvi_item.verno_maj), /* data count */
\r
1101 cmd_ext_ptr->context); /* context */
\r
1103 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
1105 /* This item is a special case for writes, so it has no generic path in
\r
1106 * nvimio_io(). Thus we have to handle the read of this item here
\r
1107 * rather than in nvimio_io().
\r
1109 case NV_VERNO_MIN_I:
\r
1110 status = nvio_read_item(NV_VERNO_MIN_I, /* item ID */
\r
1112 (byte*)&cmd_ext_ptr->nvcmd->data_ptr->verno_min, /* data ptr */
\r
1113 sizeof(nvi_item.verno_min), /* data count */
\r
1114 cmd_ext_ptr->context); /* context */
\r
1116 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
1117 /* Some invariant offset items are handled as a special case,
\r
1118 because they will always have a valid entry, but if their
\r
1119 feature is not turned on, then you can't read, write or build
\r
1121 case NV_PAP_PASSWORD_I:
\r
1122 #ifdef NV_FEATURE_PAP
\r
1123 status = nvio_read_item(cmd_ext_ptr->nvcmd->item,
\r
1125 (byte *)cmd_ext_ptr->nvcmd->data_ptr,
\r
1126 nvim_op_get_size(cmd_ext_ptr->nvcmd->item),
\r
1127 cmd_ext_ptr->context);
\r
1129 status = NV_BADPARM_S;
\r
1132 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
1134 #ifdef NV_FEATURE_UP
\r
1135 index = *((byte *)cmd_ext_ptr->nvcmd->data_ptr);
\r
1136 if (index >= NV_UP_LINK_INFO_TABLE_SIZE)
\r
1137 status = NV_BADPARM_S;
\r
1139 status = nvio_read_item(cmd_ext_ptr->nvcmd->item,
\r
1141 ((byte *)cmd_ext_ptr->nvcmd->data_ptr)+sizeof(index),
\r
1142 nvim_op_get_size(cmd_ext_ptr->nvcmd->item),
\r
1143 cmd_ext_ptr->context);
\r
1145 status = NV_BADPARM_S;
\r
1148 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
1149 case NV_BD_ADDR_I:
\r
1150 #if (defined(FEATURE_BT) || defined(FEATURE_BT_QSOC))
\r
1151 status = nvio_read_item(cmd_ext_ptr->nvcmd->item,
\r
1153 (byte *)cmd_ext_ptr->nvcmd->data_ptr,
\r
1154 nvim_op_get_size(cmd_ext_ptr->nvcmd->item),
\r
1155 cmd_ext_ptr->context);
\r
1157 status = NV_BADPARM_S;
\r
1160 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
1163 status = nvio_read_dial(NV_DIAL_I,
\r
1164 NV_MAX_SPEED_DIALS,
\r
1165 cmd_ext_ptr->nvcmd->data_ptr->dial.address,
\r
1166 &cmd_ext_ptr->nvcmd->data_ptr->dial,
\r
1167 cmd_ext_ptr->context);
\r
1169 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
1172 status = nvio_read_stdial(NV_STACK_I,
\r
1173 NV_MAX_STACK_DIALS,
\r
1174 cmd_ext_ptr->nvcmd->data_ptr->stack.address,
\r
1175 &cmd_ext_ptr->nvcmd->data_ptr->stack,
\r
1176 cmd_ext_ptr->context);
\r
1178 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
1180 #ifdef NV_FEATURE_REDIAL
\r
1182 status = nvio_read_dial(NV_DIAL_I,
\r
1183 NV_MAX_SPEED_DIALS + NVI_REDIAL_EXTENSIONS,
\r
1184 NV_MAX_SPEED_DIALS,
\r
1185 &cmd_ext_ptr->nvcmd->data_ptr->dial,
\r
1186 cmd_ext_ptr->context);
\r
1190 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
1194 status = nvio_read_sms(cmd_ext_ptr);
\r
1196 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
1198 #ifdef NV_FEATURE_RENTAL_ITEMS
\r
1199 #error code not present
\r
1202 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
1204 #ifdef NV_FEATURE_RENTAL_ITEMS
\r
1205 #error code not present
\r
1208 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
1210 #ifdef NV_FEATURE_FACTORY_INFO
\r
1211 case NV_FACTORY_INFO_I:
\r
1212 /* Copy from the static block, latest factory data */
\r
1213 memcpy((void *) cmd_ext_ptr->nvcmd->data_ptr->fact_info,
\r
1215 (word) NV_FACTORY_INFO_SIZ);
\r
1216 status = NV_DONE_S;
\r
1220 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
1222 #ifdef NV_FEATURE_PRL_ITEMS
\r
1223 #ifdef NV_FEATURE_IS683A_PRL
\r
1224 case NV_ROAMING_LIST_683_I:
\r
1226 case NV_ROAMING_LIST_I:
\r
1228 status = nvio_read_roaming_list(cmd_ext_ptr);
\r
1232 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
1234 #ifdef FEATURE_NV_SUPPORT_FLASH_OTP
\r
1235 case NV_DEVICE_SERIAL_NO_I:
\r
1236 if (flash_otp_operation(FLASH_OTP_OP_SERIALNO_READ,
\r
1237 (byte *)cmd_ext_ptr->nvcmd->data_ptr) != FLASH_OTP_IO_SUCCESS) {
\r
1245 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
1247 #ifdef FEATURE_GWSMS
\r
1249 status = nvio_read_sms_gw(cmd_ext_ptr);
\r
1255 /* Check if there's an actual entry */
\r
1256 if (nvim_op_get_presence(cmd_ext_ptr->nvcmd->item)) {
\r
1257 array_size = nvim_op_get_array_size(cmd_ext_ptr->nvcmd->item);
\r
1258 if (array_size == 0) /* If not an array, 1 means an array of 1 */
\r
1259 status = nvio_read_item(cmd_ext_ptr->nvcmd->item,
\r
1261 (byte *)cmd_ext_ptr->nvcmd->data_ptr,
\r
1262 nvim_op_get_size(cmd_ext_ptr->nvcmd->item),
\r
1263 cmd_ext_ptr->context);
\r
1264 else /* More than one item */ {
\r
1265 index = *((byte *) cmd_ext_ptr->nvcmd->data_ptr);
\r
1266 if (index >= array_size) {
\r
1267 status = NV_BADPARM_S;
\r
1270 status = nvio_read_item(cmd_ext_ptr->nvcmd->item,
\r
1272 ((byte *)cmd_ext_ptr->nvcmd->data_ptr)+sizeof(index),
\r
1273 nvim_op_get_size(cmd_ext_ptr->nvcmd->item),
\r
1274 cmd_ext_ptr->context);
\r
1278 else /* Not a valid entry */ {
\r
1279 QSR_MSG_HIGH( 253627890ULL, "nvio_read item %d not for this target", cmd_ext_ptr->nvcmd->item, 0, 0);//auto-gen, to change remove 'QSR_' and first param
\r
1280 status = NV_BADPARM_S;
\r
1282 /* End read switch and return status. */
\r
1290 /*===========================================================================
\r
1292 FUNCTION NVIO_TRANSLATE_TO_INTERNAL
\r
1295 This function translates a digit frome external representation to
\r
1296 internal 4 bit NVM storage representation.
\r
1302 The 4 bit digit value.
\r
1307 ===========================================================================*/
\r
1310 nvio_translate_to_internal (
\r
1311 byte digit /* External digit representation */
\r
1314 if ((digit >= '0') && (digit <= '9')) return(digit - '0');
\r
1315 else if (digit == '*' ) return(0x0A);
\r
1316 else if (digit == '#' ) return(0x0B);
\r
1317 else if (digit == '-' ) return(0x0C);
\r
1318 else if (digit == 'P' ) return(0x0D);
\r
1319 else if (digit == 'T' ) return(0x0E);
\r
1320 else if (digit == 'L' ) return(0x0F);
\r
1322 ERR("Illegal dial digit",0,0,0);
\r
1326 } /* nvio_translate_to_internal */
\r
1329 /********************** TEMPORARY ******************************************/
\r
1330 /************* Remove this function after cross-update is removed **********/
\r
1331 /*===========================================================================
\r
1333 FUNCTION NVT_TRANSLATE_TO_EXTERNAL
\r
1336 This function translates a digit frome internal 4 bit NVM storage
\r
1337 to external 8 bit ASCII representation.
\r
1343 The 8 bit ASCII digit value.
\r
1348 ===========================================================================*/
\r
1350 static byte nvt_translate_to_external
\r
1352 byte digit /* Internal digit representation */
\r
1355 if ((digit > 0) && (digit <= 0x09)) return(digit + '0');
\r
1356 else if (digit == 0x0A) return('0');
\r
1357 else if (digit == 0x0B) return('*');
\r
1358 else if (digit == 0x0C) return('#');
\r
1361 } /* nvt_translate_to_external */
\r
1362 /********************** TEMPORARY ******************************************/
\r
1365 /*===========================================================================
\r
1367 FUNCTION NVT_TRANSLATE_TO_INTERNAL
\r
1370 This function translates a digit frome external representation to
\r
1371 internal 4 bit NVM storage representation.
\r
1377 The 4 bit digit value.
\r
1382 ===========================================================================*/
\r
1385 nvt_translate_to_internal (
\r
1386 byte digit /* External digit representation */
\r
1389 if ((digit > '0') && (digit <= '9')) return(digit - '0');
\r
1390 else if (digit == '0') return(0x0A);
\r
1391 else if (digit == '*') return(0x0B);
\r
1392 else if (digit == '#') return(0x0C);
\r
1393 else return(0x0F);
\r
1395 } /* nvt_translate_to_internal */
\r
1397 /*===========================================================================
\r
1399 FUNCTION NVIO_WRITE_ITEM
\r
1402 This function writes an NV item to NV database.
\r
1408 NV_DONE_S if it worked
\r
1409 Or the failure status from the lower levels.
\r
1413 ===========================================================================*/
\r
1414 nv_stat_enum_type
\r
1415 nvio_write_item (
\r
1416 nv_items_enum_type item,
\r
1424 boolean item_present;
\r
1426 nv_stat_enum_type status;
\r
1427 struct fs_stat temp_buf;
\r
1430 item_present = nvim_op_get_presence(item);
\r
1432 if(item_present) {
\r
1433 /* Creating file name for array item*/
\r
1434 /* Check if context is defined*/
\r
1435 if (context == 0) { /* Context is not defined, use old pathnames*/
\r
1437 (void)snprintf(f_name,sizeof(f_name),"/nvm/num/%d",item);
\r
1439 (void)snprintf(f_name,sizeof(f_name),"/nvm/num/%d_%d",item,index);
\r
1442 else { /* Context is defined. Use context for creating pathname*/
\r
1444 (void)snprintf(f_name,sizeof(f_name),"/nvm/context%d/%d",context,item);
\r
1446 (void)snprintf(f_name,sizeof(f_name),"/nvm/context%d/%d_%d",context,item,index);
\r
1448 /* Check if the file is present or not. */
\r
1449 if(efs_stat(f_name,&temp_buf) != -1) {
\r
1450 if((temp_buf.st_size) != (nvim_op_get_size(item))) {
\r
1451 (void)efs_unlink(f_name);
\r
1455 return_size = efs_put(f_name, data_ptr, item_size,
\r
1456 O_CREAT|O_AUTODIR, 0777);
\r
1457 if(return_size >= 0)
\r
1458 status = NV_DONE_S;
\r
1460 status = NV_FAIL_S;
\r
1463 ERR("nvio_write %d not for this target", (int)item, 0, 0);
\r
1464 status = NV_BADPARM_S;
\r
1467 } /* End of nvio_write_item*/
\r
1470 /*===========================================================================
\r
1472 FUNCTION NVIO_WRITE_ESN
\r
1475 This function processed a write command to the NV_ESN_I item.
\r
1481 NV_DONE_S if it worked error status code if it failed.
\r
1486 ===========================================================================*/
\r
1488 LOCAL nv_stat_enum_type
\r
1490 nv_cmd_ext_type *cmd_ext_ptr /* Command block */
\r
1493 nv_stat_enum_type status; /* Function return value */
\r
1494 dword local_esn; /* tmp buffer for esn */
\r
1495 dword local_esn_chksum; /**/
\r
1496 /* Read the current ESN value */
\r
1497 status = nvio_read_item(NV_ESN_I,/* file handle */
\r
1499 &local_esn, /* data ptr */
\r
1500 sizeof(local_esn), /* data count */
\r
1501 cmd_ext_ptr->context ); /* Context */
\r
1503 if (status == NV_FAIL_S){
\r
1507 /* The ESN may only be written once */
\r
1508 if ((local_esn != 0) &&
\r
1509 (local_esn != 0xFFFFFFFF) && (status != NV_NOTACTIVE_S)){
\r
1510 /* The file is now considered read-only */
\r
1511 return NV_READONLY_S;
\r
1514 /* Write the ESN, the ESN checksum, and the ESN valid flag. */
\r
1515 status = nvio_write_item(NV_ESN_I, /* Item name */
\r
1517 (byte*)&cmd_ext_ptr->nvcmd->data_ptr->esn, /* data ptr */
\r
1518 sizeof(nvi_item.esn), /* data count */
\r
1519 cmd_ext_ptr->context); /* context */
\r
1521 if (status == NV_DONE_S)
\r
1523 local_esn_chksum = crc_30_calc((byte *)&cmd_ext_ptr->nvcmd->data_ptr->esn,
\r
1524 sizeof(nvi_item.esn) * 8);
\r
1526 status = nvio_write_item(NV_ESN_CHKSUM_I, /* file handle */
\r
1527 0, /* file position */
\r
1528 (byte*)&local_esn_chksum, /* data ptr */
\r
1529 sizeof(local_esn_chksum), /* data count */
\r
1530 cmd_ext_ptr->context); /* context */
\r
1534 } /* nvio_write_esn */
\r
1537 /*===========================================================================
\r
1539 FUNCTION NVIO_WRITE_ROAMING_LIST
\r
1542 This function writes the roaming list. Handled as a special case in the
\r
1549 NV_DONE_S if it worked
\r
1550 NV_BADPARM_S if requested bytes are out of range for NVM
\r
1555 ===========================================================================*/
\r
1557 LOCAL nv_stat_enum_type
\r
1558 nvio_write_roaming_list (
\r
1559 nv_cmd_ext_type *cmd_ext_ptr
\r
1562 word item_size; /* Size of item (in bytes) */
\r
1563 nv_stat_enum_type status; /* Function return value */
\r
1566 fs_ssize_t result = 0;
\r
1568 fs_size_t bytes_written;
\r
1570 boolean true_flag = TRUE;
\r
1572 /* Check for illegal NAM */
\r
1573 if(cmd_ext_ptr->nvcmd->data_ptr->roaming_list.nam >= NV_MAX_NAMS)
\r
1575 return NV_BADPARM_S;
\r
1579 /* Get its size */
\r
1580 item_size = NV_ROAMING_LIST_HEADER_SIZE +
\r
1581 nv_max_size_of_roaming_list();
\r
1583 QSR_MSG_MED( 2779538831ULL, "size: %d", item_size, 0, 0);//auto-gen, to change remove 'QSR_' and first param
\r
1585 /* Construct pathname*/
\r
1586 if (cmd_ext_ptr->context == 0) /* No context defined */
\r
1587 snprintf(f_name,sizeof(f_name),"/nvm/prl_%d",
\r
1588 cmd_ext_ptr->nvcmd->data_ptr->roaming_list.nam);
\r
1590 snprintf(f_name,sizeof(f_name),"/nvm/context%d/prl_%d",
\r
1591 cmd_ext_ptr->context,cmd_ext_ptr->nvcmd->data_ptr->roaming_list.nam);
\r
1593 fd = efs_open(f_name, O_RDWR | O_CREAT , 0777 );
\r
1595 /* nbytes should be one less than item_size as the write_buf is pointing to
\r
1596 * prl_version which is second element of the prl data structure and NAM
\r
1597 * is not supposed to be updated */
\r
1598 nbytes = item_size - 1;
\r
1599 bytes_written = 0;
\r
1602 memcpy(((byte*)write_buf), &true_flag, sizeof(true_flag));
\r
1603 memcpy(((byte*)write_buf)+sizeof(true_flag),
\r
1604 (byte*)&(cmd_ext_ptr->data_ptr->roaming_list.prl_version),
\r
1605 item_size-sizeof(true_flag));
\r
1608 write_buf = (void *)&(cmd_ext_ptr->nvcmd->data_ptr->roaming_list.prl_version);
\r
1611 (const void *) &(true_flag),
\r
1612 sizeof(true_flag));
\r
1614 efs_lseek(fd, sizeof(true_flag), SEEK_CUR);
\r
1616 while (bytes_written < nbytes) {
\r
1617 result = efs_write (fd,
\r
1618 (const void *) (write_buf + bytes_written),
\r
1619 nbytes - bytes_written);
\r
1622 bytes_written += (fs_size_t) result;
\r
1625 if (result == -1) {
\r
1626 status = NV_FAIL_S;
\r
1629 status = NV_DONE_S;
\r
1631 nv_prl_version_data[cmd_ext_ptr->nvcmd->data_ptr->roaming_list.nam] =
\r
1632 cmd_ext_ptr->nvcmd->data_ptr->roaming_list.prl_version;
\r
1633 nv_prl_valid_data[cmd_ext_ptr->nvcmd->data_ptr->roaming_list.nam] =
\r
1634 cmd_ext_ptr->nvcmd->data_ptr->roaming_list.valid;
\r
1638 } /* nvio_write_roaming_list */
\r
1642 /*===========================================================================
\r
1644 FUNCTION NVIO_WRITE_DIAL
\r
1647 This function processes write requests for speed dial number. It performs
\r
1648 translations necessary from external to internal format and then attempts
\r
1649 to write the NVM item using EFS services.
\r
1655 Status of write operation.
\r
1660 ===========================================================================*/
\r
1662 LOCAL nv_stat_enum_type
\r
1664 nv_items_enum_type item, /* Item to access */
\r
1665 byte index_range, /* Maximum allowed range for index */
\r
1666 byte index, /* speed dial # */
\r
1667 nv_dial_type *dial_ptr, /* Pointer to write source buffer */
\r
1668 byte item_context /* Context of item in NV */
\r
1671 word i; /* Index through speed dial numbers */
\r
1672 byte ndigits; /* # of digits to process */
\r
1674 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
1676 /* Check for illegal offset into the array */
\r
1677 if (index >= index_range) return NV_BADPARM_S;
\r
1679 /* First copy the digits count from external buffer to internal */
\r
1680 /* buffer, making sure that only the maximum number allowed can */
\r
1681 /* be stored. When copying translate digits to internal type. */
\r
1683 nvi_item.dial.num_digits = MIN(dial_ptr->num_digits, NV_MAX_DIAL_DIGITS);
\r
1684 ndigits = nvi_item.dial.num_digits;
\r
1685 for (i = 0; i < ndigits; i++) {
\r
1687 /* Copy the digits, compressing from one digit per byte into two */
\r
1688 /* digits per byte. Even bytes are stored in least significant */
\r
1689 /* digit, odd bytes in most significant digit. */
\r
1692 nvi_item.dial.digits[i/2] =
\r
1693 nvio_translate_to_internal(dial_ptr->digits[i]);
\r
1695 nvi_item.dial.digits[i/2] |=
\r
1696 (byte)(nvio_translate_to_internal(dial_ptr->digits[i]) << 4);
\r
1700 /* Copy the name to internal type. */
\r
1701 (void)memcpy((void *) nvi_item.dial.letters, (void *) dial_ptr->letters,
\r
1704 #ifdef NV_FEATURE_EXTENDED_UI
\r
1705 nvi_item.dial.status = dial_ptr->status;
\r
1708 /* Write out item. */
\r
1709 return nvio_write_item(
\r
1712 #ifdef NV_FEATURE_EXTENDED_UI
\r
1713 (byte*)&nvi_item.dial.status,
\r
1715 (byte*)&nvi_item.dial.num_digits,
\r
1717 sizeof(nvi_item.dial),
\r
1720 } /* nvio_write_dial */
\r
1723 /*===========================================================================
\r
1725 FUNCTION NVIO_WRITE_STDIAL
\r
1728 This function processes write requests for stack dial number. It performs
\r
1729 translations necessary from external to internal format and then attempts
\r
1730 to write the NV item using EFS services.
\r
1736 Status of write operation.
\r
1741 ===========================================================================*/
\r
1743 LOCAL nv_stat_enum_type
\r
1744 nvio_write_stdial (
\r
1745 nv_items_enum_type item, /* Item to access */
\r
1746 byte index_range, /* Maximum allowed range for index */
\r
1747 byte index, /* speed dial # */
\r
1748 nv_stdial_type *dial_ptr, /* Pointer to external write source buffer */
\r
1749 byte item_context /* Context of item in NV */
\r
1752 word i; /* Index through stack dial numbers */
\r
1754 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
1756 /* Check if the index is within the range */
\r
1757 if (index >= index_range) return NV_BADPARM_S;
\r
1759 /* First copy the digits count from external buffer to internal */
\r
1760 /* buffer, making sure that only the maximum number allowed can */
\r
1761 /* be stored. When copying translate digits to internal type. */
\r
1763 nvi_item.stack.num_digits = MIN(dial_ptr->num_digits, NV_MAX_DIAL_DIGITS);
\r
1764 for (i = 0; i < nvi_item.stack.num_digits; i++) {
\r
1766 /* Copy the digits, compressing from one digit per byte into two */
\r
1767 /* digits per byte. Even bytes are stored in least significant */
\r
1768 /* digit, odd bytes in most significant digit. */
\r
1771 nvi_item.stack.digits[i/2] = nvio_translate_to_internal(dial_ptr->digits[i]);
\r
1773 nvi_item.stack.digits[i/2] |= (byte)(nvio_translate_to_internal(dial_ptr->digits[i]) << 4);
\r
1777 /* Copy the name to internal type. */
\r
1778 (void)memcpy((void *) nvi_item.stack.letters, (void *) dial_ptr->letters,
\r
1781 #ifdef NV_FEATURE_EXTENDED_UI
\r
1782 nvi_item.stack.status = dial_ptr->status;
\r
1783 nvi_item.stack.time_stamp = dial_ptr->time_stamp;
\r
1784 nvi_item.stack.duration = dial_ptr->duration;
\r
1787 /* Write out item. */
\r
1788 return nvio_write_item(
\r
1791 #ifdef NV_FEATURE_EXTENDED_UI
\r
1792 (byte*)&nvi_item.stack.status,
\r
1794 (byte*)&nvi_item.stack.num_digits,
\r
1796 sizeof(nvi_item.stack),
\r
1798 } /* nvio_write_stdial */
\r
1801 /*===========================================================================
\r
1803 FUNCTION NVIO_WRITE_SMS
\r
1806 This function writes to an sms EFS file.
\r
1812 NV_DONE_S if it worked
\r
1813 NV_BADPARM_S if requested bytes are out of range for NVM
\r
1818 ===========================================================================*/
\r
1820 LOCAL nv_stat_enum_type
\r
1822 nv_cmd_ext_type *cmd_ext_ptr /* Command block */
\r
1826 char sms_name[28]; /* Increasing size from 20 to 28 for context*/
\r
1827 nv_stat_enum_type status = NV_DONE_S;
\r
1829 /* only sms supported at this time */
\r
1830 if(((cmd_ext_ptr->nvcmd->item != NV_SMS_I) && (cmd_ext_ptr->nvcmd->item != NV_SMS_DM_I)) ||
\r
1831 (cmd_ext_ptr->nvcmd->data_ptr->sms.address >= NVI_MAX_SMS_ADDR) ||
\r
1832 (cmd_ext_ptr->nvcmd->data_ptr->sms.length > NV_SMS_DATA_SIZ)) {
\r
1833 status = NV_BADPARM_S;
\r
1836 /* Reset the watchdog timer */
\r
1839 if (cmd_ext_ptr->context == 0) /* No context defined */
\r
1840 (void)snprintf(sms_name, sizeof(sms_name), "/nvm/sms_%05d",
\r
1841 cmd_ext_ptr->nvcmd->data_ptr->sms.address);
\r
1842 else /* Context defined */
\r
1843 (void)snprintf(sms_name, sizeof(sms_name), "/nvm/context%d/sms_%05d",
\r
1844 cmd_ext_ptr->context,
\r
1845 cmd_ext_ptr->nvcmd->data_ptr->sms.address);
\r
1847 /* Unlink the file before writing to it as the size may be different */
\r
1848 if (cmd_ext_ptr->nvcmd->cmd == NV_REPLACE_F)
\r
1849 (void)efs_unlink(sms_name);
\r
1851 return_size = efs_put( sms_name,
\r
1852 (byte*)&(cmd_ext_ptr->nvcmd->data_ptr->sms.address),
\r
1853 (sizeof(nvi_sms_type) + cmd_ext_ptr->nvcmd->data_ptr->sms.length),
\r
1856 if(return_size == -1) {
\r
1857 QSR_MSG_HIGH( 2025558454ULL, "Write failed for SMS item address %d",
\r
1858 cmd_ext_ptr->nvcmd->data_ptr->sms.address, 0, 0);//auto-gen, to change remove 'QSR_' and first param
\r
1859 status = NV_FAIL_S;
\r
1863 } /* nvio_write_sms */
\r
1866 #ifdef FEATURE_GWSMS
\r
1867 /*===========================================================================
\r
1869 FUNCTION NVIO_WRITE_SMS_GW
\r
1872 This function writes to an sms_gw EFS file.
\r
1878 NV_DONE_S if it worked
\r
1879 NV_BADPARM_S if requested bytes are out of range for NVM
\r
1884 ===========================================================================*/
\r
1886 LOCAL nv_stat_enum_type
\r
1887 nvio_write_sms_gw (
\r
1888 nv_cmd_ext_type *cmd_ext_ptr /* Command block */
\r
1892 char sms_name[28]; /* Increasing size from 20 to 28*/
\r
1893 nv_stat_enum_type status = NV_DONE_S;
\r
1895 /* only sms supported at this time */
\r
1896 if ((cmd_ext_ptr->nvcmd->item != NV_SMS_GW_I) ||
\r
1897 (cmd_ext_ptr->nvcmd->data_ptr->sms_gw.address >= NVI_MAX_SMS_ADDR) ||
\r
1898 (cmd_ext_ptr->nvcmd->data_ptr->sms_gw.length > NV_SMS_GW_DATA_SIZ)) {
\r
1899 status = NV_BADPARM_S;
\r
1902 /* Reset the watchdog timer */
\r
1905 /* Get the pathname */
\r
1906 if (cmd_ext_ptr->context == 0) /* No context is defined */
\r
1907 (void) snprintf(sms_name, sizeof(sms_name), "/nvm/sms_gw_%05d",
\r
1908 cmd_ext_ptr->nvcmd->data_ptr->sms_gw.address);
\r
1910 (void) snprintf(sms_name, sizeof(sms_name), "/nvm/context%d/sms_gw_%05d",
\r
1911 cmd_ext_ptr->context,
\r
1912 cmd_ext_ptr->nvcmd->data_ptr->sms_gw.address);
\r
1914 /* Unlink the file before writing to it as the size may be different */
\r
1915 if (cmd_ext_ptr->nvcmd->cmd == NV_REPLACE_F)
\r
1916 (void)efs_unlink(sms_name);
\r
1918 return_size = efs_put( sms_name,
\r
1919 (byte*)&(cmd_ext_ptr->nvcmd->data_ptr->sms_gw.address),
\r
1920 (sizeof(nvi_sms_gw_type) + cmd_ext_ptr->nvcmd->data_ptr->sms_gw.length),
\r
1923 if(return_size == -1) {
\r
1924 QSR_MSG_HIGH( 2025558454ULL, "Write failed for SMS item address %d",
\r
1925 cmd_ext_ptr->nvcmd->data_ptr->sms_gw.address, 0, 0);//auto-gen, to change remove 'QSR_' and first param
\r
1926 status = NV_FAIL_S;
\r
1930 } /* nvio_write_sms_gw */
\r
1934 /*===========================================================================
\r
1936 FUNCTION NVIO_WRITE_DIR_NUMBER
\r
1939 This function performs the "cross-update" between NV_DIR_NUMBER_I and
\r
1940 NV_DIR_NUMBER_PCS_I. That is, a write to either item is translated
\r
1941 and copied to the other item as well. THIS IS A TEMPORARY FUNCTION
\r
1942 ONLY USED TO EASE THE TRANSITION FROM THE OLD STRUCTURE TO THE NEW.
\r
1948 NV_DONE_S if it worked
\r
1949 other if a called function returns a failure status
\r
1954 ===========================================================================*/
\r
1956 LOCAL nv_stat_enum_type
\r
1957 nvio_write_dir_number (
\r
1958 nv_cmd_ext_type *cmd_ext_ptr /* Command block */
\r
1961 nv_stat_enum_type status; /* Status to return to calling procedure */
\r
1962 nv_cmd_type local_cmd;
\r
1963 static nv_item_type local_item;
\r
1965 byte pcs_index, gem_index;
\r
1968 /* First, update the specified nv item */
\r
1969 index = *((byte *)cmd_ext_ptr->nvcmd->data_ptr);
\r
1971 if (index >= NV_MAX_NAMS)
\r
1973 status = NV_BADPARM_S;
\r
1977 status = nvio_write_item(cmd_ext_ptr->nvcmd->item,
\r
1979 ((byte *)cmd_ext_ptr->nvcmd->data_ptr) + sizeof(index),
\r
1980 nvim_op_get_size(cmd_ext_ptr->nvcmd->item),
\r
1981 cmd_ext_ptr->context);
\r
1984 if (status != NV_DONE_S) return status;
\r
1986 /* Set up generic command buffer parameters */
\r
1987 local_cmd.cmd = NV_WRITE_F;
\r
1988 local_cmd.tcb_ptr = NULL;
\r
1989 local_cmd.sigs = 0;
\r
1990 local_cmd.done_q_ptr = NULL;
\r
1991 local_cmd.data_ptr = &local_item;
\r
1992 local_cmd.status = NV_DONE_S;
\r
1994 /* Now do the cross update */
\r
1995 if (cmd_ext_ptr->nvcmd->item == NV_DIR_NUMBER_I) {
\r
1996 local_cmd.item = NV_DIR_NUMBER_PCS_I;
\r
1997 local_item.mob_dir_number.nam = cmd_ext_ptr->nvcmd->data_ptr->dir_number.nam;
\r
1998 for (i=0; i<NV_DIR_NUMB_SIZ; ++i) {
\r
1999 local_item.mob_dir_number.digitn[i] =
\r
2000 nvt_translate_to_internal
\r
2001 (cmd_ext_ptr->nvcmd->data_ptr->dir_number.dir_number[i]);
\r
2003 local_item.mob_dir_number.n_digits = NV_DIR_NUMB_SIZ;
\r
2006 if (cmd_ext_ptr->nvcmd->data_ptr->mob_dir_number.n_digits > 15) {
\r
2007 return NV_BADPARM_S;
\r
2009 local_cmd.item = NV_DIR_NUMBER_I;
\r
2010 local_item.dir_number.nam = cmd_ext_ptr->nvcmd->data_ptr->mob_dir_number.nam;
\r
2011 for (i=0; i<NV_DIR_NUMB_SIZ; ++i) {
\r
2012 local_item.dir_number.dir_number[i] = 0x20; /* ASCII blank */
\r
2015 /* If n_digits is nonzero, translate and copy the digits; otherwise */
\r
2016 /* we've already blanked out all the digits */
\r
2017 if (cmd_ext_ptr->nvcmd->data_ptr->mob_dir_number.n_digits != 0) {
\r
2018 pcs_index = MAX(0,(cmd_ext_ptr->nvcmd->data_ptr->mob_dir_number.n_digits-10));
\r
2019 gem_index = MAX(0, (10-cmd_ext_ptr->nvcmd->data_ptr->mob_dir_number.n_digits));
\r
2020 while ((gem_index < NV_DIR_NUMB_SIZ)&&(pcs_index < NV_DIR_NUMB_PCS_SIZ)) {
\r
2021 local_item.dir_number.dir_number[gem_index++] =
\r
2022 nvt_translate_to_external
\r
2023 (cmd_ext_ptr->nvcmd->data_ptr->mob_dir_number.digitn[pcs_index++]);
\r
2028 /* Finally, update the "other" nv item */
\r
2029 index = *(byte *)(local_cmd.data_ptr);
\r
2030 if (index >= NV_MAX_NAMS)
\r
2032 status = NV_BADPARM_S;
\r
2036 status = nvio_write_item(local_cmd.item,
\r
2038 ((byte *)(local_cmd.data_ptr) + sizeof(index)),
\r
2039 nvim_op_get_size(local_cmd.item),
\r
2040 cmd_ext_ptr->context);
\r
2045 } /* nvio_write_dir_number */
\r
2048 /*===========================================================================
\r
2050 FUNCTION NVIO_WRITE_RENTAL_TIMER
\r
2053 This function writes an arbitrary value to the rental timer item.
\r
2054 Since this item is expected to be updated with very high frequency,
\r
2055 it is stored in a way that minimizes EEPROM cell wear. This unusual
\r
2056 storage format calls for a special routine to write and read the
\r
2059 The NV "increment" command would normally be used to update this item;
\r
2060 this routine should only be used to initialize the item to some desired
\r
2067 NV_DONE_S if it worked
\r
2068 other if a called function returns a failure status
\r
2073 ===========================================================================*/
\r
2074 #ifdef NV_FEATURE_RENTAL_ITEMS
\r
2075 #error code not present
\r
2079 /*===========================================================================
\r
2081 FUNCTION NVIM_INCREMENT
\r
2084 This function processes NVM item "increment" requests. Currently, only
\r
2085 the rental timer item can use this operation. This special processing
\r
2086 is needed because the rental timer item is an unusually high wear item,
\r
2087 expected to be written very frequently.
\r
2093 Status of the increment operation.
\r
2098 ===========================================================================*/
\r
2100 nv_stat_enum_type
\r
2102 nv_cmd_ext_type *cmd_ext_ptr /* Command block */
\r
2106 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
2108 #ifndef NV_FEATURE_RENTAL_ITEMS
\r
2109 return NV_BADPARM_S;
\r
2111 #error code not present
\r
2113 } /* nvim_increment */
\r
2116 /*===========================================================================
\r
2118 FUNCTION NVIO_WRITE_RENTAL_CNT
\r
2121 This function writes a value to the rental count item. This special
\r
2122 function is needed because this item is a fixed-pool double-buffered
\r
2129 NV_DONE_S if it worked
\r
2130 other if a called function returns a failure status
\r
2135 ===========================================================================*/
\r
2136 #ifdef NV_FEATURE_RENTAL_ITEMS
\r
2137 #error code not present
\r
2142 /*===========================================================================
\r
2144 FUNCTION NVIO_WRITE_PRL_ITEM
\r
2147 This function writes a PRL item into NVM directory
\r
2153 NV_DONE_S if it worked
\r
2154 NV_FAIL_S if it did not work.
\r
2158 ===========================================================================*/
\r
2159 nv_stat_enum_type
\r
2160 nvio_write_prl_item (
\r
2166 nv_stat_enum_type status; /* Function return value */
\r
2169 fs_ssize_t result = 0;
\r
2171 fs_size_t bytes_written;
\r
2175 QSR_MSG_MED( 2779538831ULL, "size: %d", item_size, 0, 0);//auto-gen, to change remove 'QSR_' and first param
\r
2177 snprintf(f_name,sizeof(f_name),"/nvm/prl_%d",num);
\r
2179 fd = efs_open(f_name, O_RDWR | O_CREAT, 0777 );
\r
2181 nbytes = item_size;
\r
2182 bytes_written = 0;
\r
2183 write_buf = data_ptr;
\r
2185 while (bytes_written < nbytes) {
\r
2186 result = efs_write (fd,
\r
2187 (const void *) (write_buf + bytes_written),
\r
2188 nbytes - bytes_written);
\r
2191 bytes_written += (fs_size_t) result;
\r
2194 if (result == -1) {
\r
2195 status = NV_FAIL_S;
\r
2198 status = NV_DONE_S;
\r
2206 #if (defined(FEATURE_BT) || defined(FEATURE_BT_QSOC))
\r
2207 /*===========================================================================
\r
2209 FUNCTION NVIO_WRITE_BD_ADDR
\r
2212 This function processed a write command to the NV_BD_ADDR_I item.
\r
2218 NV_DONE_S if it worked error status code if it failed.
\r
2223 ===========================================================================*/
\r
2225 LOCAL nv_stat_enum_type
\r
2226 nvio_write_bd_addr (
\r
2227 nv_cmd_ext_type *cmd_ext_ptr /* Command block */
\r
2231 nv_stat_enum_type status;
\r
2232 nv_bd_addr_type local_bd_addr; /* tmp buffer for bd_addr */
\r
2233 boolean all_zero_write_value;
\r
2234 boolean bd_addr_empty = TRUE;
\r
2236 /* Read the current Bluetooth addr. value */
\r
2237 status = nvio_read_item(cmd_ext_ptr->nvcmd->item,
\r
2239 (byte*)&local_bd_addr, /* data ptr */
\r
2240 nvim_op_get_size(cmd_ext_ptr->nvcmd->item),
\r
2241 cmd_ext_ptr->context);
\r
2243 if ((status != NV_DONE_S) && (status != NV_NOTACTIVE_S))
\r
2249 /* Bluetooth addr can only be written once */
\r
2250 if (status == NV_DONE_S) {
\r
2251 for (i=0; i<NV_BD_ADDR_SIZE; i++) {
\r
2252 if (local_bd_addr.bd_addr[i] != 0) {
\r
2253 bd_addr_empty = FALSE;
\r
2256 if (!bd_addr_empty)
\r
2258 /* The file is now considered read-only */
\r
2259 return NV_READONLY_S;
\r
2262 /* The PST may try to write a value of 0 one or more times,
\r
2263 simply return success if the current BD_ADDR value is 0 */
\r
2264 all_zero_write_value = TRUE;
\r
2265 for (i=0; i<NV_BD_ADDR_SIZE; i++) {
\r
2266 if (cmd_ext_ptr->nvcmd->data_ptr->bd_addr.bd_addr[i] != 0) {
\r
2267 all_zero_write_value = FALSE;
\r
2271 if (all_zero_write_value)
\r
2278 status = nvio_write_item(cmd_ext_ptr->nvcmd->item,
\r
2280 (byte*)cmd_ext_ptr->nvcmd->data_ptr,
\r
2281 nvim_op_get_size(cmd_ext_ptr->nvcmd->item),
\r
2282 cmd_ext_ptr->context);
\r
2288 #ifdef FEATURE_RFCAL_VERSION
\r
2289 /*===========================================================================
\r
2291 FUNCTION NVIO_WRITE_RF_CAL_DATE
\r
2294 This function processed a write command to the NV_RF_CAL_DATE_I item.
\r
2300 NV_DONE_S if it worked error status code if it failed.
\r
2305 ===========================================================================*/
\r
2307 LOCAL nv_stat_enum_type
\r
2308 nvio_write_rf_cal_date (
\r
2309 nv_cmd_ext_type *cmd_ext_ptr /* Command block */
\r
2312 nv_stat_enum_type status;
\r
2313 dword local_rf_cal_date; /* tmp buffer for rf_cal_date */
\r
2315 /* Read the current rf_cal_date */
\r
2316 status = nvio_read_item(cmd_ext_ptr->nvcmd->item,
\r
2318 &local_rf_cal_date, /* data ptr */
\r
2319 nvim_op_get_size(cmd_ext_ptr->nvcmd->item),
\r
2320 cmd_ext_ptr->context);
\r
2322 if ((status != NV_DONE_S) && (status != NV_NOTACTIVE_S))
\r
2327 /* rf_cal_date can only be written once */
\r
2328 if (status == NV_DONE_S) {
\r
2329 if (local_rf_cal_date != 0) {
\r
2330 /* The file is now considered read-only */
\r
2331 return NV_READONLY_S;
\r
2334 /* The PST may try to write a value of 0 one or more times,
\r
2335 simply return success if the current rf_cal_date value is 0 */
\r
2336 if (cmd_ext_ptr->nvcmd->data_ptr->rf_cal_date == 0) {
\r
2342 status = nvio_write_item(cmd_ext_ptr->nvcmd->item,
\r
2344 (byte*)cmd_ext_ptr->nvcmd->data_ptr,
\r
2345 nvim_op_get_size(cmd_ext_ptr->nvcmd->item),
\r
2346 cmd_ext_ptr->context);
\r
2352 #ifdef FEATURE_RFCAL_VERSION
\r
2353 /*===========================================================================
\r
2355 FUNCTION NVIO_WRITE_RF_CAL_DAT_FILE
\r
2358 This function processed a write command to the NV_RF_CAL_DAT_FILE_I item.
\r
2364 NV_DONE_S if it worked error status code if it failed.
\r
2369 ===========================================================================*/
\r
2371 LOCAL nv_stat_enum_type
\r
2372 nvio_write_rf_cal_dat_file (
\r
2373 nv_cmd_ext_type *cmd_ext_ptr /* Command block */
\r
2377 nv_stat_enum_type status;
\r
2378 byte local_rf_cal_dat_file[NV_QC_SERIAL_NUM_LEN]; /* tmp buffer for rf_cal_dat_file */
\r
2379 boolean all_zero_write_value;
\r
2380 boolean empty_value = TRUE;
\r
2382 /* Read the current rf_cal_dat_file. value */
\r
2383 status = nvio_read_item(cmd_ext_ptr->nvcmd->item,
\r
2385 &local_rf_cal_dat_file, /* data ptr */
\r
2386 nvim_op_get_size(cmd_ext_ptr->nvcmd->item),
\r
2387 cmd_ext_ptr->context);
\r
2389 if ((status != NV_DONE_S) && (status != NV_NOTACTIVE_S))
\r
2394 /* rf_cal_dat_file can only be written once */
\r
2395 if (status == NV_DONE_S) {
\r
2396 for (i=0; i<NV_QC_SERIAL_NUM_LEN; i++) {
\r
2397 if (local_rf_cal_dat_file[i] != 0) {
\r
2398 empty_value = FALSE;
\r
2403 /* The file is now considered read-only */
\r
2404 return NV_READONLY_S;
\r
2407 /* The PST may try to write a value of 0 one or more times,
\r
2408 simply return success if the current rf_cal_dat_file value is 0 */
\r
2409 all_zero_write_value = TRUE;
\r
2410 for (i=0; i<NV_QC_SERIAL_NUM_LEN; i++) {
\r
2411 if (cmd_ext_ptr->nvcmd->data_ptr->rf_cal_dat_file[i] != 0) {
\r
2412 all_zero_write_value = FALSE;
\r
2416 if (all_zero_write_value)
\r
2423 status = nvio_write_item(cmd_ext_ptr->nvcmd->item,
\r
2425 (byte*)cmd_ext_ptr->nvcmd->data_ptr,
\r
2426 nvim_op_get_size(cmd_ext_ptr->nvcmd->item),
\r
2427 cmd_ext_ptr->context);
\r
2430 } /* nvio_write_rf_cal_dat_file */
\r
2434 /*===========================================================================
\r
2436 FUNCTION NVIO_WRITE_MEID
\r
2439 This function processed a write command to the NV_MEID_I item.
\r
2445 NV_DONE_S if it worked error status code if it failed.
\r
2450 ===========================================================================*/
\r
2452 LOCAL nv_stat_enum_type
\r
2454 nv_cmd_ext_type *cmd_ext_ptr /* Command block */
\r
2457 nv_stat_enum_type status;
\r
2458 qword local_meid; /* temporary buffer for meid */
\r
2459 local_meid[0] = 0;
\r
2460 local_meid[1] = 0;
\r
2462 /* Read the current MEID value */
\r
2463 status = nvio_read_item(cmd_ext_ptr->nvcmd->item,
\r
2465 &local_meid, /* data ptr */
\r
2466 nvim_op_get_size(cmd_ext_ptr->nvcmd->item),
\r
2467 cmd_ext_ptr->context);
\r
2469 if((status != NV_DONE_S)&&(status != NV_NOTACTIVE_S)) {
\r
2470 QSR_MSG_HIGH ( 302884211ULL, " MEID Read was successful. ",0,0,0);//auto-gen, to change remove 'QSR_' and first param
\r
2474 if (!(((local_meid[0] == 0) && (local_meid[1] == 0)) ||
\r
2475 ((local_meid[0] == 0xFFFFFFFF)
\r
2476 && (local_meid[1] == 0x00FFFFFF)))) {
\r
2477 /* The file is now considered read-only */
\r
2478 QSR_MSG_HIGH ( 911419585ULL, " MEID is neither all 0s nor all Fs. ",0,0,0);//auto-gen, to change remove 'QSR_' and first param
\r
2479 return NV_READONLY_S;
\r
2481 status = nvio_write_item(cmd_ext_ptr->nvcmd->item,
\r
2483 (byte*)cmd_ext_ptr->nvcmd->data_ptr,
\r
2484 nvim_op_get_size(cmd_ext_ptr->nvcmd->item),
\r
2485 cmd_ext_ptr->context);
\r
2488 } /* nvio_write_meid */
\r
2491 /*===========================================================================
\r
2493 FUNCTION NVIO_WRITE_IMEI
\r
2496 This function processed a write command to the NV_UE_IMEI_I item.
\r
2502 NV_DONE_S if it worked error status code if it failed.
\r
2507 ===========================================================================*/
\r
2509 LOCAL nv_stat_enum_type
\r
2512 nv_cmd_ext_type *cmd_ext_ptr /* Command block */
\r
2516 nv_stat_enum_type status = NV_FAIL_S;
\r
2517 nv_ue_imei_type local_ue_imei; /* tmp buffer for ue_imei */
\r
2518 boolean all_zero_write_value;
\r
2519 boolean ue_imei_empty = TRUE;
\r
2520 #ifdef FEATURE_NV_SFS_PRIVATE
\r
2521 sfs_priv_errno_enum_type sfs_ret = 0;
\r
2524 #if defined (FEATURE_NV_SFS_PRIVATE)
\r
2525 /* If IMEI can't be read, call it "not active" */
\r
2526 sfs_ret = sfs_priv_imei_read((uint8 *) &local_ue_imei,
\r
2527 nvim_op_get_size(cmd_ext_ptr->nvcmd->item));
\r
2528 if ( sfs_ret == SFS_PRIV_INACTIVE )
\r
2530 status = NV_NOTACTIVE_S;
\r
2532 else if( sfs_ret == SFS_PRIV_SUCCESS)
\r
2534 status = NV_DONE_S;
\r
2538 status = NV_FAIL_S;
\r
2541 /* Read the current IMEI value */
\r
2542 status = nvio_read_item(cmd_ext_ptr->nvcmd->item,
\r
2544 (byte*)&local_ue_imei, /* data ptr */
\r
2545 nvim_op_get_size(cmd_ext_ptr->nvcmd->item),
\r
2546 cmd_ext_ptr->context);
\r
2549 if ((status != NV_DONE_S) && (status != NV_NOTACTIVE_S))
\r
2554 /* IMEI has been written once */
\r
2555 if (status == NV_DONE_S)
\r
2557 for (i=0; i<NV_UE_IMEI_SIZE; i++)
\r
2559 if (local_ue_imei.ue_imei[i] != 0)
\r
2561 ue_imei_empty = FALSE;
\r
2564 if (!ue_imei_empty)
\r
2566 /* The file is now considered read-only */
\r
2567 status = NV_READONLY_S;
\r
2571 /* The PST may try to write a value of 0 one or more times,
\r
2572 simply return success if the current IMEI value is 0 */
\r
2573 all_zero_write_value = TRUE;
\r
2574 for (i=0; i<NV_UE_IMEI_SIZE; i++)
\r
2576 if (cmd_ext_ptr->nvcmd->data_ptr->ue_imei.ue_imei[i] != 0)
\r
2578 all_zero_write_value = FALSE;
\r
2582 if (all_zero_write_value)
\r
2584 status = NV_DONE_S;
\r
2587 } /* IMEI has been written once */
\r
2589 #ifdef FEATURE_NV_SFS_PRIVATE
\r
2590 sfs_ret = sfs_priv_imei_write((uint8 *)cmd_ext_ptr->nvcmd->data_ptr,
\r
2591 nvim_op_get_size(cmd_ext_ptr->nvcmd->item));
\r
2592 /* If IMEI can't be written, call it "read-only" */
\r
2593 if ( sfs_ret == SFS_PRIV_READONLY )
\r
2595 /* SFS sees that Qfuse is blown so readonly */
\r
2596 status = NV_READONLY_S;
\r
2598 else if( sfs_ret == SFS_PRIV_SUCCESS)
\r
2600 /* SFS write succeeded */
\r
2601 status = NV_DONE_S;
\r
2605 /* There is a failure to write at the SFS layer*/
\r
2606 status = NV_FAIL_S;
\r
2609 /* IMEI has not been written yet */
\r
2612 status = nvio_write_item(cmd_ext_ptr->nvcmd->item,
\r
2614 (byte*)cmd_ext_ptr->nvcmd->data_ptr,
\r
2615 nvim_op_get_size(cmd_ext_ptr->nvcmd->item),
\r
2616 cmd_ext_ptr->context);
\r
2617 } /* IMEI has not been written yet */
\r
2621 } /* nvio_write_imei */
\r
2624 /*===========================================================================
\r
2626 FUNCTION NVIO_WRITE
\r
2629 This function processes NVM write requests. The function checks
\r
2630 to make sure that a valid item has been requested, it performs any
\r
2631 translations necessary from external format to internal NVM format
\r
2632 and writes the item using EFS write services.
\r
2638 Status of write operation.
\r
2643 ===========================================================================*/
\r
2645 nv_stat_enum_type
\r
2647 nv_cmd_ext_type *cmd_ext_ptr /* Command block */
\r
2650 nv_stat_enum_type status; /* Status to return to calling procedure */
\r
2651 uint16 array_size; /* Array size of the item */
\r
2652 byte index; /* Specific index of an array */
\r
2654 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
2656 /* Check that the item code is within range. If it is not */
\r
2657 /* then exit with fail status, else switch on item type. */
\r
2659 if (cmd_ext_ptr->nvcmd->item >= NV_MAX_I) {
\r
2660 return NV_BADPARM_S;
\r
2665 #ifdef NV_FEATURE_DIAG_WINS
\r
2666 /* If write request is from diag, close gate to all other writers */
\r
2667 if ((write_gate_open) || (cmd_ext_ptr->nvcmd->tcb_ptr == &diag_tcb))
\r
2669 if (cmd_ext_ptr->nvcmd->tcb_ptr == &diag_tcb)
\r
2671 write_gate_open = FALSE;
\r
2675 #ifdef FEATURE_NV_RUIM
\r
2677 /* If the R-UIM supports the item,
\r
2678 * return the status else use "regular" NVM.
\r
2680 if (cmd_ext_ptr->context == 0) {
\r
2681 if ( nvruim_write(cmd_ext_ptr->nvcmd, &status) == NV_RUIM_SUPPORTS_ITEM ) {
\r
2685 #ifdef FEATURE_DUAL_STANDBY
\r
2687 if ( nvruim_write_ext(cmd_ext_ptr, &status) == NV_RUIM_SUPPORTS_ITEM ) {
\r
2694 switch (cmd_ext_ptr->nvcmd->item)
\r
2697 /* For each requested parameter if the parameter is fixed then */
\r
2698 /* write it via its pointer from the external requestor's data */
\r
2699 /* buffer to an EFS file. Any required */
\r
2700 /* translation from external to internal format is performed */
\r
2701 /* as part of this write. */
\r
2703 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
2706 status = nvio_write_esn(cmd_ext_ptr);
\r
2709 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
2712 status = NV_READONLY_S;
\r
2715 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
2717 case NV_ESN_CHKSUM_I:
\r
2719 /* The ESN checksum cannot be written from external */
\r
2720 /* request. This request is denied and the NV task */
\r
2721 /* initiates transition of the DMSS to offline state */
\r
2722 /* (not yet implemented). */
\r
2723 status = NV_READONLY_S;
\r
2726 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
2728 case NV_VERNO_MAJ_I:
\r
2730 /* Major version can be written only internally, directly */
\r
2731 /* from nv_init. So we do not allow writing it here. */
\r
2733 status = NV_READONLY_S;
\r
2736 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
2738 case NV_VERNO_MIN_I:
\r
2740 /* Minor version can be written only internally, directly */
\r
2741 /* from nv_init. So we do not allow writing it here. */
\r
2743 status = NV_READONLY_S;
\r
2746 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
2749 status = nvio_write_dial(NV_DIAL_I,
\r
2750 NV_MAX_SPEED_DIALS,
\r
2751 cmd_ext_ptr->nvcmd->data_ptr->dial.address,
\r
2752 &cmd_ext_ptr->nvcmd->data_ptr->dial,
\r
2753 cmd_ext_ptr->context);
\r
2756 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
2759 status = nvio_write_stdial(NV_STACK_I,
\r
2760 NV_MAX_STACK_DIALS,
\r
2761 cmd_ext_ptr->nvcmd->data_ptr->stack.address,
\r
2762 &cmd_ext_ptr->nvcmd->data_ptr->stack,
\r
2763 cmd_ext_ptr->context);
\r
2766 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
2768 #ifdef FEATURE_NV_REDIAL_ITEM
\r
2770 status = nvio_write_dial(NV_DIAL_I,
\r
2771 NV_MAX_SPEED_DIALS + NVI_REDIAL_EXTENSIONS,
\r
2772 NV_MAX_SPEED_DIALS,
\r
2773 &cmd_ext_ptr->nvcmd->data_ptr->dial,
\r
2774 cmd_ext_ptr->context);
\r
2778 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
2782 status = nvio_write_sms(cmd_ext_ptr);
\r
2785 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
2787 case NV_DIR_NUMBER_I:
\r
2788 case NV_DIR_NUMBER_PCS_I :
\r
2789 status = nvio_write_dir_number(cmd_ext_ptr);
\r
2792 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
2794 #ifdef NV_FEATURE_RENTAL_ITEMS
\r
2795 #error code not present
\r
2798 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
2800 #ifdef NV_FEATURE_RENTAL_ITEMS
\r
2801 #error code not present
\r
2804 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
2809 /* Write the item */
\r
2810 index = *((byte *)cmd_ext_ptr->nvcmd->data_ptr);
\r
2811 if (index >= NV_MAX_NAMS) {
\r
2812 status = NV_BADPARM_S;
\r
2814 else /* Valid index */ {
\r
2815 status = nvio_write_item(cmd_ext_ptr->nvcmd->item,
\r
2817 ((byte *)cmd_ext_ptr->nvcmd->data_ptr) + sizeof(index),
\r
2818 nvim_op_get_size(cmd_ext_ptr->nvcmd->item),
\r
2819 cmd_ext_ptr->context);
\r
2824 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
2826 case NV_PAP_PASSWORD_I:
\r
2827 #ifdef NV_FEATURE_PAP
\r
2828 status = nvio_write_item(cmd_ext_ptr->nvcmd->item,
\r
2830 (byte *)cmd_ext_ptr->nvcmd->data_ptr,
\r
2831 nvim_op_get_size(cmd_ext_ptr->nvcmd->item),
\r
2832 cmd_ext_ptr->context);
\r
2834 status = NV_BADPARM_S;
\r
2838 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
2841 #ifdef NV_FEATURE_UP
\r
2843 index = *((byte *) cmd_ext_ptr->nvcmd->data_ptr);
\r
2844 if (index >= NV_UP_LINK_INFO_TABLE_SIZE) {
\r
2845 status = NV_BADPARM_S;
\r
2847 else /* Valid index */ {
\r
2848 status = nvio_write_item(cmd_ext_ptr->nvcmd->item,
\r
2850 ((byte *)cmd_ext_ptr->nvcmd->data_ptr) + sizeof(index),
\r
2851 nvim_op_get_size(cmd_ext_ptr->nvcmd->item),
\r
2852 cmd_ext_ptr->context);
\r
2856 status = NV_BADPARM_S;
\r
2860 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
2862 /* Roaming List is handled differently in the item manager (not a generic case) */
\r
2863 #ifdef NV_FEATURE_PRL_ITEMS
\r
2865 #ifdef NV_FEATURE_IS683A_PRL
\r
2866 case NV_ROAMING_LIST_683_I:
\r
2867 status = nvio_write_roaming_list(cmd_ext_ptr);
\r
2870 case NV_ROAMING_LIST_I:
\r
2871 status = nvio_write_roaming_list(cmd_ext_ptr);
\r
2876 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
2878 case NV_BD_ADDR_I:
\r
2879 #if (defined(FEATURE_BT) || defined(FEATURE_BT_QSOC))
\r
2880 status = nvio_write_bd_addr(cmd_ext_ptr);
\r
2882 status = NV_BADPARM_S;
\r
2886 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
2888 case NV_UE_IMEI_I:
\r
2889 status = nvio_write_imei(cmd_ext_ptr);
\r
2892 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
2894 #ifdef FEATURE_GWSMS
\r
2896 status = nvio_write_sms_gw(cmd_ext_ptr);
\r
2900 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
2902 case NV_RF_CAL_DATE_I:
\r
2903 #ifdef FEATURE_RFCAL_VERSION
\r
2904 status = nvio_write_rf_cal_date(cmd_ext_ptr);
\r
2906 status = NV_BADPARM_S;
\r
2910 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
2912 case NV_RF_CAL_DAT_FILE_I:
\r
2913 #ifdef FEATURE_RFCAL_VERSION
\r
2914 status = nvio_write_rf_cal_dat_file(cmd_ext_ptr);
\r
2916 status = NV_BADPARM_S;
\r
2919 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
2921 #ifdef FEATURE_NV_SUPPORT_FLASH_OTP
\r
2923 case NV_DEVICE_SERIAL_NO_I:
\r
2924 if (flash_otp_operation(FLASH_OTP_OP_SERIALNO_WRITE,
\r
2925 (byte *)cmd_ext_ptr->nvcmd->data_ptr) != FLASH_OTP_IO_SUCCESS) {
\r
2933 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
2936 status = nvio_write_meid(cmd_ext_ptr);
\r
2939 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
2941 case NV_MEID_ME_I:
\r
2942 status = NV_READONLY_S;
\r
2945 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
2947 case NV_MS_SMS_AUTOSAVE_I:
\r
2948 status = nvio_write_item(cmd_ext_ptr->nvcmd->item,
\r
2950 (byte *)cmd_ext_ptr->nvcmd->data_ptr,
\r
2951 nvim_op_get_size(cmd_ext_ptr->nvcmd->item),
\r
2952 cmd_ext_ptr->context);
\r
2954 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
2957 /* All other items get generic treatment, if they have
\r
2959 if (nvim_op_get_presence(cmd_ext_ptr->nvcmd->item)) {
\r
2960 array_size = nvim_op_get_array_size(cmd_ext_ptr->nvcmd->item);
\r
2962 if (array_size == 0) {
\r
2963 status = nvio_write_item(cmd_ext_ptr->nvcmd->item,
\r
2965 (void *) cmd_ext_ptr->nvcmd->data_ptr,
\r
2966 nvim_op_get_size(cmd_ext_ptr->nvcmd->item),
\r
2967 cmd_ext_ptr->context);
\r
2969 else /* More than one item */ {
\r
2970 index = *((byte *) cmd_ext_ptr->nvcmd->data_ptr);
\r
2971 if (index >= array_size) {
\r
2972 status = NV_BADPARM_S;
\r
2975 //QSR_MSG_MED( 3068207423ULL, "Data after: %.4x", *(((byte *) cmd_ext_ptr->data_ptr) + sizeof(index)), 0, 0);//auto-gen, to change remove 'QSR_' and first param
\r
2976 status = nvio_write_item(cmd_ext_ptr->nvcmd->item,
\r
2978 ((byte *)cmd_ext_ptr->nvcmd->data_ptr)+sizeof(index),
\r
2979 nvim_op_get_size(cmd_ext_ptr->nvcmd->item),
\r
2980 cmd_ext_ptr->context);
\r
2984 else /* Not a valid entry */ {
\r
2985 ERR("nvw_write %d not for this target", cmd_ext_ptr->nvcmd->item, 0, 0);
\r
2986 status = NV_BADPARM_S;
\r
2988 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
\r
2993 #ifdef NV_FEATURE_DIAG_WINS
\r
2997 /* If write gate is closed, tell callers write succeeded even though */
\r
2998 /* it didn't really (avoids recovery processing in client code) */
\r
3004 } /* nvio_write */
\r
3006 #endif /* FEATURE_NV_ITEM_MGR */
\r