diff options
author | ToshikazuOhiwa <toshikazu_ohiwa@mail.toyota.co.jp> | 2020-03-30 09:31:31 +0900 |
---|---|---|
committer | ToshikazuOhiwa <toshikazu_ohiwa@mail.toyota.co.jp> | 2020-03-30 09:31:31 +0900 |
commit | fe2caefcaa1ece2e7b163741184c3fc834440a48 (patch) | |
tree | 5c4036069388c0928214db076e779d2e24d0e84c /backup_manager | |
parent | 706ad73eb02caf8532deaf5d38995bd258725cb8 (diff) |
ns-backupmanager branch
Diffstat (limited to 'backup_manager')
27 files changed, 6512 insertions, 0 deletions
diff --git a/backup_manager/LICENSE b/backup_manager/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/backup_manager/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/backup_manager/Makefile.client b/backup_manager/Makefile.client new file mode 100644 index 00000000..08700bd1 --- /dev/null +++ b/backup_manager/Makefile.client @@ -0,0 +1,19 @@ +# +# @copyright Copyright (c) 2017-2019 TOYOTA MOTOR CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +SUBDIRS := config client + +include ../native_service.mk diff --git a/backup_manager/Makefile.server b/backup_manager/Makefile.server new file mode 100644 index 00000000..6129c277 --- /dev/null +++ b/backup_manager/Makefile.server @@ -0,0 +1,19 @@ +# +# @copyright Copyright (c) 2017-2019 TOYOTA MOTOR CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +SUBDIRS := server + +include ../native_service.mk diff --git a/backup_manager/client/Makefile b/backup_manager/client/Makefile new file mode 100644 index 00000000..66a2a67c --- /dev/null +++ b/backup_manager/client/Makefile @@ -0,0 +1,53 @@ +# +# @copyright Copyright (c) 2017-2019 TOYOTA MOTOR CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +######### libraries to be installed(*.so)############# +INST_SHLIBS := libns_backup + +######### headers to be installed(*.h) ############# +INST_HEADERS := backup_manager.h ns_backup.h + +######### sources to be compiled ############# +libns_backup_SRCS := bkup_api.cpp + +######### search paths ############# +VPATH += ./src ./include/$(COMPONENT_NAME) ../server/include + +######### include paths ############# +CPPFLAGS += -I./include +CPPFLAGS += -I../server/include + +######### frameworkunifiedlog options ############# +CPPFLAGS += -DFRAMEWORKUNIFIEDLOGOPTIONS=0x08 -DFRAMEWORKUNIFIEDLOGAPPZONES=31,30,29,28,27,26,9,8,3 + +LDFLAGS += -Wl,--no-as-needed +LDFLAGS += -Wl,--no-undefined + +######### libraries to be linked(dynamic)############# +LDLIBS += -Wl,-Bdynamic -lNS_FrameworkUnified + +######### other unit specific options ############# +LINK_CXX=Y + +CPPFLAGS += -Werror=implicit-function-declaration +CPPFLAGS += -Werror=format-security + +CPPFLAGS += -Wconversion +CPPFLAGS += -Wint-to-pointer-cast +CPPFLAGS += -Wpointer-arith +CPPFLAGS += -Wformat + +include ../../native_service.mk diff --git a/backup_manager/client/include/bkup_api.h b/backup_manager/client/include/bkup_api.h new file mode 100644 index 00000000..b372dd49 --- /dev/null +++ b/backup_manager/client/include/bkup_api.h @@ -0,0 +1,60 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef BACKUP_MANAGER_CLIENT_INCLUDE_BKUP_API_H_ +#define BACKUP_MANAGER_CLIENT_INCLUDE_BKUP_API_H_ + +#define BACKUP_CID 0xBACC1D00 + +#define BKUP_MAX_ITEM_NAME 64 + +/** + * media + */ +//#include <nv_hal.h> + +/** + * command + */ +typedef enum { + BKUP_CMD_READ = 0, + BKUP_CMD_WRITE, + BKUP_CMD_FILL, + BKUP_CMD_SIZE, + BKUP_CMD_READ_NUM, + BKUP_CMD_SIZE_NUM, + BKUP_CMD_CHECK, + BKUP_CMD_DELETE, + BKUP_CMD_COPY_INNER, + BKUP_CMD_MAX, +} bkup_protocol_command_t; + +/** + * api/process protocol + */ +typedef struct { + bkup_protocol_command_t command; + char item_name[64]; + uint32_t num_id; + uint32_t offset; + uint32_t size; + char fill_patern; +// enum NvHalMedia src_media; +} bkup_protocol_header_t; + +#define SERVICE_BACKUP_MANAGER_MSG_HANDLE_THREAD "bkupmanagerthr" + +#endif // BACKUP_MANAGER_CLIENT_INCLUDE_BKUP_API_H_ diff --git a/backup_manager/client/include/native_service/backup_manager.h b/backup_manager/client/include/native_service/backup_manager.h new file mode 100644 index 00000000..abd670b0 --- /dev/null +++ b/backup_manager/client/include/native_service/backup_manager.h @@ -0,0 +1,42 @@ +/* + * @copyright Copyright (c) 2017-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file backup_manager.h + * @brief backup_manager unit common header file. + */ + +#ifndef NATIVESERVICE_BACKUPMANAGER_H_ // NOLINT(build/header_guard) +#define NATIVESERVICE_BACKUPMANAGER_H_ + +/** @addtogroup BaseSystem + * @{ + */ +/** @addtogroup native_service + * @ingroup BaseSystem + * @{ + */ +/** @addtogroup backup_manager + * @ingroup native_service + * @{ + */ + +#include <native_service/ns_backup.h> + +/**@}*/ // end of backup_manager +/**@}*/ // end of native_service +/**@}*/ // end of BaseSystem + +#endif // NATIVESERVICE_BACKUPMANAGER_H_ diff --git a/backup_manager/client/include/native_service/ns_backup.h b/backup_manager/client/include/native_service/ns_backup.h new file mode 100644 index 00000000..b007a23d --- /dev/null +++ b/backup_manager/client/include/native_service/ns_backup.h @@ -0,0 +1,497 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file ns_backup.h + * @brief backup_manager function header file + */ + +#ifndef BACKUP_MANAGER_CLIENT_INCLUDE_NATIVE_SERVICE_NS_BACKUP_H_ +#define BACKUP_MANAGER_CLIENT_INCLUDE_NATIVE_SERVICE_NS_BACKUP_H_ + +#include <native_service/frameworkunified_types.h> + +/** @addtogroup BaseSystem + * @{ + */ +/** @addtogroup native_service + * @ingroup BaseSystem + * @{ + */ +/** @addtogroup backup_manager + * @ingroup native_service + * @{ + */ + +/** + * \~english Service availability notify + */ +#define NTFY_BackupMgr_Availability "NS_BackupMgr/Availability" + +/** + * \~english Return value: terminated normally + */ +#define BKUP_RET_NORMAL 0 + +/** + * \~english Return value: abnormal termination(content not specified) + */ +#define BKUP_RET_ERROR -1 + +/** + * \~english Return value: parameter error + */ +#define BKUP_RET_ERRPARAM -2 + +/** + * \~english Return value: initializing + */ +#define BKUP_RET_ERRINIT -3 + +/** + * \~english Return value: terminating + */ +#define BKUP_RET_ERRTERM -4 + +/** + * \~english Return value: data does not exist + */ +#define BKUP_RET_ERRNOENT -5 + +/** + * \~english Return value: data size error + */ +#define BKUP_RET_ERRSIZE -6 + + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \ingroup Backup_DataRd + * \~english @par Brief + * Read data from backup area + * \~english @param [in] tagID + * PCSTR - Area ID(character string of less than 64 bytes) + * \~english @param [in] uiOffset + * uint32_t - Offset from the beginning of the area(0~size of backup area identified by area ID) + * \~english @param [out] pvBuf + * void * - A pointer which point to buffer used to storage read data + * \~english @param [in] uiSize + * uint32_t - Read data size(0~size of backup area identified by area ID) + * \~english @retval BKUP_RET_NORMAL Terminated normally + * \~english @retval BKUP_RET_ERRPARAM Parameter error(Sync message transmission or reception(@ref McInvokeSync) error[eFrameworkunifiedStatusInvldParam]) + * \~english @retval BKUP_RET_ERRINIT Initializing(Sync message send or receive(@ref McInvokeSync) error [eFrameworkunifiedStatusErrOther]) + * \~english @retval BKUP_RET_ERRTERM Terminating(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusExit]) + * \~english @retval BKUP_RET_ERRNOENT Data dose not exist(Sync message transmission or reception(@ref McInvokeSync) fails [eFrameworkunifiedStatusFileLoadError]) + * \~english @retval BKUP_RET_ERRSIZE Data size error(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusAccessError]) + * \~english @retval BKUP_RET_ERROR Abnormal termination(@ref McOpenSender failed, or sync message transmission or reception(@ref McInvokeSync) error other than the above) + * \~english @par Prerequisite + * - None. + * \~english @par Change of internal state + * - Change of internal state according to the API does not occur. + * \~english @par Conditions of processing failure + * - If the area ID(tagID) specified by the argument is NULL [BKUP_RET_ERRPARAM] + * - If the area ID(tagID) specified by the argument is 64 bytes or more than 64 bytes [BKUP_RET_ERRPARAM] + * - If the buffer point(pvBuf) specified by the argument is NULL [BKUP_RET_ERRPARAM] + * - If system call(pctrl(PR_GET_NAME)) is error [BKUP_RET_ERROR] + * - If failed to open the message queue for transmission [BKUP_RET_ERROR] + * - If failed to genarate message queue name for synchronous communication [BKUP_RET_ERROR] + * - If failed to open the reception message queue for synchronous communication [BKUP_RET_ERROR] + * - Sync message transmission or reception(@ref McInvokeSync) error + * - If the return value is eFrameworkunifiedStatusInvldParam [BKUP_RET_ERRPARAM] + * - If the return value is eFrameworkunifiedStatusErrOther [BKUP_RET_ERRINIT] + * - If the return value is eFrameworkunifiedStatusExit [BKUP_RET_ERRTERM] + * - If the return value is eFrameworkunifiedStatusFileLoadError [BKUP_RET_ERRNOENT] + * - If the return value is eFrameworkunifiedStatusAccessError [BKUP_RET_ERRSIZE] + * - If the return value is eFrameworkunifiedStatusFail, it call will synchronization message transmission(@ref McInvokeSync) again after 100 milliseconds later + * If the return value is eFrameworkunifiedStatusFail, it will retry BKUP_RETRY_MAX(10) times + * - If the return value is other value [BKUP_RET_ERROR] + * - If the size specified by the argument does not match the actual read size [BKUP_RET_ERROR] + * \~english @par Detail + - Judge the type and access destination according to specified area ID and then read data. + * + * \~english @par Classification + * Public + * \~english @par Type + * Sync + * \~english @see + * Backup_DataWt + */ +int32_t Backup_DataRd(PCSTR tag_id, uint32_t ui_offset, void *pv_buf, uint32_t ui_size); +/** + * \ingroup Backup_DataWt + * \~english @par Brief + * Write data to backup area + * \~english @param [in] tagID + * PCSTR - Area ID(character string of less than 64 bytes) + * \~english @param [in] pvBuf + * void * - A pointer which point to buffer used to storage write data + * \~english @param [in] uiOffset + * uint32_t - Offset from the beginning of the area(0~size of backup area identified by area ID) + * \~english @param [in] uiSize + * uint32_t - Write data size(0~size of backup area identified by area ID) + * \~english @retval BKUP_RET_NORMAL Terminated normally + * \~english @retval BKUP_RET_ERRPARAM Parameter error(Sync message transmission or reception(@ref McInvokeSync) error[eFrameworkunifiedStatusInvldParam]) + * \~english @retval BKUP_RET_ERRINIT Initializing(Sync message send or receive(@ref McInvokeSync) error [eFrameworkunifiedStatusErrOther]) + * \~english @retval BKUP_RET_ERRTERM Terminating(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusExit]) + * \~english @retval BKUP_RET_ERRNOENT Data dose not exist(Sync message transmission or reception(@ref McInvokeSync) fails [eFrameworkunifiedStatusFileLoadError]) + * \~english @retval BKUP_RET_ERRSIZE Data size error(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusAccessError]) + * \~english @retval BKUP_RET_ERROR Abnormal termination(@ref McOpenSender failed, or sync message transmission or reception(@ref McInvokeSync) error other than the above) + * \~english @par Prerequisite + * - None. + * \~english @par Change of internal state + * - Change of internal state according to the API does not occur. + * \~english @par Conditions of processing failure + * - If the area ID(tagID) specified by the argument is NULL [BKUP_RET_ERRPARAM] + * - If the area ID(tagID) specified by the argument is 64 bytes or more than 64 bytes [BKUP_RET_ERRPARAM] + * - If the buffer point(pvBuf) specified by the argument is NULL [BKUP_RET_ERRPARAM] + * - If system call(mmap()) is error [BKUP_RET_ERROR] + * - If system call(pctrl(PR_GET_NAME)) is error [BKUP_RET_ERROR] + * - If failed to open the message queue for transmission [BKUP_RET_ERROR] + * - If failed to genarate message queue name for synchronous communication [BKUP_RET_ERROR] + * - If failed to open the reception message queue for synchronous communication [BKUP_RET_ERROR] + * - Sync message transmission or reception(@ref McInvokeSync) error + * - If the return value is eFrameworkunifiedStatusInvldParam [BKUP_RET_ERRPARAM] + * - If the return value is eFrameworkunifiedStatusErrOther [BKUP_RET_ERRINIT] + * - If the return value is eFrameworkunifiedStatusExit [BKUP_RET_ERRTERM] + * - If the return value is eFrameworkunifiedStatusFileLoadError [BKUP_RET_ERRNOENT] + * - If the return value is eFrameworkunifiedStatusAccessError [BKUP_RET_ERRSIZE] + * - If the return value is eFrameworkunifiedStatusFail, it call will synchronization message transmission(@ref McInvokeSync) again after 100 milliseconds later + * If the return value is eFrameworkunifiedStatusFail, it will retry BKUP_RETRY_MAX(10) times + * - If the return value is other value [BKUP_RET_ERROR] + * - If the size specified by the argument does not match the actual read size [BKUP_RET_ERROR] + * \~english @par Detail + * Judge the storage media type and access destination according to specified area ID and then write data. + * Calling @ref Backup_DataWt more than once for the same ID when writing data separately. + * Data integrity can not be guaranteed at power interruption. + * Data should be written at one time to guarantee data consistency. + * The work life of writing times depends on how the user writes,NS_BackupMgr doesn't guaranteed. + * \~english @par Classification + * Public + * \~english @par Type + * Sync + * \~english @see + * Backup_DataRd + */ +int32_t Backup_DataWt(PCSTR tag_id, void *pv_buf, uint32_t ui_offset, uint32_t ui_size); + + +/** + * \ingroup Backup_DataFil + * \~english @par Brief + * Write data to backup area with the specified pattern + * \~english @param [in] tagID + * PCSTR - Area ID(character string of less than 64 bytes) + * \~english @param [in] uiOffset + * uint32_t - Offset from the beginning of the area(0~size of backup area identified by area ID) + * \~english @param [in] ucPat + * uint8_t - Write pattern data(0x00~0xff) + * \~english @param [in] uiSize + * uint32_t - Write data size(0~size of backup area identified by area ID) + * \~english @retval BKUP_RET_NORMAL Terminated normally + * \~english @retval BKUP_RET_ERRPARAM Parameter error(Sync message transmission or reception(@ref McInvokeSync) error[eFrameworkunifiedStatusInvldParam]) + * \~english @retval BKUP_RET_ERRINIT Initializing(Sync message send or receive(@ref McInvokeSync) error [eFrameworkunifiedStatusErrOther]) + * \~english @retval BKUP_RET_ERRTERM Terminating(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusExit]) + * \~english @retval BKUP_RET_ERRNOENT Data dose not exist(Sync message transmission or reception(@ref McInvokeSync) fails [eFrameworkunifiedStatusFileLoadError]) + * \~english @retval BKUP_RET_ERRSIZE Data size error(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusAccessError]) + * \~english @retval BKUP_RET_ERROR Abnormal termination(@ref McOpenSender failed, or sync message transmission or reception(@ref McInvokeSync) error other than the above) + * \~english @par Prerequisite + * - None. + * \~english @par Change of internal state + * - Change of internal state according to the API does not occur. + * \~english @par Conditions of processing failure + * - If the area ID(tagID) specified by the argument is NULL [BKUP_RET_ERRPARAM] + * - If the area ID(tagID) specified by the argument is 64 bytes or more than 64 bytes [BKUP_RET_ERRPARAM] + * - If system call(pctrl(PR_GET_NAME)) is error [BKUP_RET_ERROR] + * - If failed to open the message queue for transmission [BKUP_RET_ERROR] + * - If failed to genarate message queue name for synchronous communication [BKUP_RET_ERROR] + * - If failed to open the reception message queue for synchronous communication [BKUP_RET_ERROR] + * - Sync message transmission or reception(@ref McInvokeSync) error + * - If the return value is eFrameworkunifiedStatusInvldParam [BKUP_RET_ERRPARAM] + * - If the return value is eFrameworkunifiedStatusErrOther [BKUP_RET_ERRINIT] + * - If the return value is eFrameworkunifiedStatusExit [BKUP_RET_ERRTERM] + * - If the return value is eFrameworkunifiedStatusFileLoadError [BKUP_RET_ERRNOENT] + * - If the return value is eFrameworkunifiedStatusAccessError [BKUP_RET_ERRSIZE] + * - If the return value is eFrameworkunifiedStatusFail, it call will synchronization message transmission(@ref McInvokeSync) again after 100 milliseconds later + * If the return value is eFrameworkunifiedStatusFail, it will retry BKUP_RETRY_MAX(10) times + * - If the return value is other value [BKUP_RET_ERROR] + * - If the size specified by the argument does not match the actual read size [BKUP_RET_ERROR] + * \~english @par Detail + * Judge the type and access destination according to specified area ID and then fill it with the specified pattern. + * The work life of writing times depends on how the usrs writes,NS_BackupMgr doesn't guaranteed. + * \~english @par Classification + * Public + * \~english @par Type + * Sync + * \~english @see + * none + */ +int32_t Backup_DataFil(PCSTR tag_id, uint32_t ui_offset, uint8_t uc_pat, uint32_t ui_size); + + +/** + * \ingroup Backup_DataSz + * \~english @par Brief + * Get the size of the backup area. + * \~english @param [in] tagID + * PCSTR - Area ID(character string of less than 64 bytes) + * \~english @param [out] puiSize + * uint32_t * - A pointer which point to storage size + * \~english @retval BKUP_RET_NORMAL Terminated normally + * \~english @retval BKUP_RET_ERRPARAM Parameter error(Sync message transmission or reception(@ref McInvokeSync) error[eFrameworkunifiedStatusInvldParam]) + * \~english @retval BKUP_RET_ERRINIT Initializing(Sync message send or receive(@ref McInvokeSync) error [eFrameworkunifiedStatusErrOther]) + * \~english @retval BKUP_RET_ERRTERM Terminating(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusExit]) + * \~english @retval BKUP_RET_ERRNOENT Data dose not exist(Sync message transmission or reception(@ref McInvokeSync) fails [eFrameworkunifiedStatusFileLoadError]) + * \~english @retval BKUP_RET_ERRSIZE Data size error(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusAccessError]) + * \~english @retval BKUP_RET_ERROR Abnormal termination(@ref McOpenSender failed, or sync message transmission or reception(@ref McInvokeSync) error other than the above) + * \~english @par Prerequisite + * - None. + * \~english @par Change of internal state + * - Change of internal state according to the API does not occur. + * \~english @par Conditions of processing failure + * - If the area ID(tagID) specified by the argument is NULL [BKUP_RET_ERRPARAM] + * - If the area ID(tagID) specified by the argument is 64 bytes or more than 64 bytes [BKUP_RET_ERRPARAM] + * - If the pointer(puiSize) that stores the size specified by the argument is NULL [BKUP_RET_ERRPARAM] + * - If system call(pctrl(PR_GET_NAME)) is error [BKUP_RET_ERROR] + * - If failed to open the message queue for transmission [BKUP_RET_ERROR] + * - If failed to genarate message queue name for synchronous communication [BKUP_RET_ERROR] + * - If failed to open the reception message queue for synchronous communication [BKUP_RET_ERROR] + * - Sync message transmission or reception(@ref McInvokeSync) error + * - If the return value is eFrameworkunifiedStatusInvldParam [BKUP_RET_ERRPARAM] + * - If the return value is eFrameworkunifiedStatusErrOther [BKUP_RET_ERRINIT] + * - If the return value is eFrameworkunifiedStatusExit [BKUP_RET_ERRTERM] + * - If the return value is eFrameworkunifiedStatusFileLoadError [BKUP_RET_ERRNOENT] + * - If the return value is eFrameworkunifiedStatusAccessError [BKUP_RET_ERRSIZE] + * - If the return value is eFrameworkunifiedStatusFail, it call will synchronization message transmission(@ref McInvokeSync) again after 100 milliseconds later + * If the return value is eFrameworkunifiedStatusFail, it will retry BKUP_RETRY_MAX(10) times + * - If the return value is other value [BKUP_RET_ERROR] + * - If the size specified by the argument does not match the actual size [BKUP_RET_ERROR] + * \~english @par Detail + * Judge the type and access destination according to specified area ID and acquire the size of the target data. + * \~english @par Classification + * Public + * \~english @par Type + * Sync + * \~english @see + * none + */ +int32_t Backup_DataSz(PCSTR tag_id, uint32_t *pui_size); + +/** + * \ingroup Backup_DataRdByNumID + * \~english @par Brief + * Read data from backup area + * \~english @param [in] numID + * uint32_t - Area ID specified by number + * \~english @param [in] uiOffset + * uint32_t - Offset from the beginning of the area(0~size of backup area identified by area ID) + * \~english @param [out] pvBuf + * void * - A pointer which point to buffer used to storage read data + * \~english @param [in] uiSize + * uint32_t - Read data size(0~size of backup area identified by area ID) + * \~english @retval BKUP_RET_NORMAL Terminated normally + * \~english @retval BKUP_RET_ERRPARAM Parameter error(Sync message transmission or reception(@ref McInvokeSync) error[eFrameworkunifiedStatusInvldParam]) + * \~english @retval BKUP_RET_ERRINIT Initializing(Sync message send or receive(@ref McInvokeSync) error [eFrameworkunifiedStatusErrOther]) + * \~english @retval BKUP_RET_ERRTERM Terminating(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusExit]) + * \~english @retval BKUP_RET_ERRNOENT Data dose not exist(Sync message transmission or reception(@ref McInvokeSync) fails [eFrameworkunifiedStatusFileLoadError]) + * \~english @retval BKUP_RET_ERRSIZE Data size error(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusAccessError]) + * \~english @retval BKUP_RET_ERROR Abnormal termination(@ref McOpenSender failed, or sync message transmission or reception(@ref McInvokeSync) error other than the above) + * \~english @par Prerequisite + * - None. + * \~english @par Change of internal state + * - Change of internal state according to the API does not occur. + * \~english @par Conditions of processing failure + * - If the area ID(tagID) specified by the argument is NULL [BKUP_RET_ERRPARAM] + * - If the area ID(tagID) specified by the argument is 64 bytes or more than 64 bytes [BKUP_RET_ERRPARAM] + * - If the buffer point(pvBuf) specified by the argument is NULL [BKUP_RET_ERRPARAM] + * - If system call(pctrl(PR_GET_NAME)) is error [BKUP_RET_ERROR] + * - If failed to open the message queue for transmission [BKUP_RET_ERROR] + * - If failed to genarate message queue name for synchronous communication [BKUP_RET_ERROR] + * - If failed to open the reception message queue for synchronous communication [BKUP_RET_ERROR] + * - Sync message transmission or reception(@ref McInvokeSync) error + * - If the return value is eFrameworkunifiedStatusInvldParam [BKUP_RET_ERRPARAM] + * - If the return value is eFrameworkunifiedStatusErrOther [BKUP_RET_ERRINIT] + * - If the return value is eFrameworkunifiedStatusExit [BKUP_RET_ERRTERM] + * - If the return value is eFrameworkunifiedStatusFileLoadError [BKUP_RET_ERRNOENT] + * - If the return value is eFrameworkunifiedStatusAccessError [BKUP_RET_ERRSIZE] + * - If the return value is eFrameworkunifiedStatusFail, it call will synchronization message transmission(@ref McInvokeSync) again after 100 milliseconds later + * If the return value is eFrameworkunifiedStatusFail, it will retry BKUP_RETRY_MAX(10) times + * - If the return value is other value [BKUP_RET_ERROR] + * - If the size specified by the argument does not match the actual read size [BKUP_RET_ERROR] + * \~english @par Detail + * Judge the type and access destination according to specified area ID and then read data. + * Backup Non-volatile Data Read API for DIAG + * Use from the module other than DIAG is prohibited. + * + * \~english @par Classification + * Public + * \~english @par Type + * Sync + * \~english @see + * Backup_DataRd + */ +int32_t Backup_DataRdByNumID(uint32_t num_id, uint32_t ui_offset, void *pv_buf, uint32_t ui_size); + + +/** + * \ingroup Backup_DataSzByNumID + * \~english @par Brief + * Get the size of the backup area. + * \~english @param [in] numID + * uint32_t - Area ID specified by number + * \~english @param [out] puiSize + * uint32_t * - A pointer which point to storage size + * \~english @retval BKUP_RET_NORMAL Terminated normally + * \~english @retval BKUP_RET_ERRPARAM Parameter error(Sync message transmission or reception(@ref McInvokeSync) error[eFrameworkunifiedStatusInvldParam]) + * \~english @retval BKUP_RET_ERRINIT Initializing(Sync message send or receive(@ref McInvokeSync) error [eFrameworkunifiedStatusErrOther]) + * \~english @retval BKUP_RET_ERRTERM Terminating(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusExit]) + * \~english @retval BKUP_RET_ERRNOENT Data dose not exist(Sync message transmission or reception(@ref McInvokeSync) fails [eFrameworkunifiedStatusFileLoadError]) + * \~english @retval BKUP_RET_ERRSIZE Data size error(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusAccessError]) + * \~english @retval BKUP_RET_ERROR Abnormal termination(@ref McOpenSender failed, or sync message transmission or reception(@ref McInvokeSync) error other than the above) + * \~english @par Prerequisite + * - None. + * \~english @par Change of internal state + * - Change of internal state according to the API does not occur. + * \~english @par Conditions of processing failure + * - If the area ID(tagID) specified by the argument is NULL [BKUP_RET_ERRPARAM] + * - If the area ID(tagID) specified by the argument is 64 bytes or more than 64 bytes [BKUP_RET_ERRPARAM] + * - If the pointer(puiSize) that stores the size specified by the argument is NULL [BKUP_RET_ERRPARAM] + * - If system call(pctrl(PR_GET_NAME)) is error [BKUP_RET_ERROR] + * - If failed to open the message queue for transmission [BKUP_RET_ERROR] + * - If failed to genarate message queue name for synchronous communication [BKUP_RET_ERROR] + * - If failed to open the reception message queue for synchronous communication [BKUP_RET_ERROR] + * - Sync message transmission or reception(@ref McInvokeSync) error + * - If the return value is eFrameworkunifiedStatusInvldParam [BKUP_RET_ERRPARAM] + * - If the return value is eFrameworkunifiedStatusErrOther [BKUP_RET_ERRINIT] + * - If the return value is eFrameworkunifiedStatusExit [BKUP_RET_ERRTERM] + * - If the return value is eFrameworkunifiedStatusFileLoadError [BKUP_RET_ERRNOENT] + * - If the return value is eFrameworkunifiedStatusAccessError [BKUP_RET_ERRSIZE] + * - If the return value is eFrameworkunifiedStatusFail, it call will synchronization message transmission(@ref McInvokeSync) again after 100 milliseconds later + * If the return value is eFrameworkunifiedStatusFail, it will retry BKUP_RETRY_MAX(10) times + * - If the return value is other value [BKUP_RET_ERROR] + * - If the size specified by the argument does not match the actual size [BKUP_RET_ERROR] + * \~english @par Detail + * Judge the type and access destination according to specified area ID and acquire the size of the target data. + * Get Non-volatile backup data size API for DIAG + * Use from the module other than DIAG is prohibited. + * \~english @par Classification + * Public + * \~english @par Type + * Sync + * \~english @see + * Backup_DataSz + */ +int32_t Backup_DataSzByNumID(uint32_t num_id, uint32_t *pui_size); + +/** + * \ingroup Backup_DataChk + * \~english @par Brief + * Check backup data. + * \~english @param [in] tagID + * PCSTR - Area ID(character string of less than 64 bytes) + * \~english @retval BKUP_RET_NORMAL Terminated normally + * \~english @retval BKUP_RET_ERRPARAM Parameter error(Sync message transmission or reception(@ref McInvokeSync) error[eFrameworkunifiedStatusInvldParam]) + * \~english @retval BKUP_RET_ERRINIT Initializing(Sync message send or receive(@ref McInvokeSync) error [eFrameworkunifiedStatusErrOther]) + * \~english @retval BKUP_RET_ERRTERM Terminating(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusExit]) + * \~english @retval BKUP_RET_ERRNOENT Data dose not exist(Sync message transmission or reception(@ref McInvokeSync) fails [eFrameworkunifiedStatusFileLoadError]) + * \~english @retval BKUP_RET_ERRSIZE Data size error(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusAccessError]) + * \~english @retval BKUP_RET_ERROR Abnormal termination(@ref McOpenSender failed, or sync message transmission or reception(@ref McInvokeSync) error other than the above) + * \~english @par Prerequisite + * - None. + * \~english @par Change of internal state + * - Change of internal state according to the API does not occur. + * \~english @par Conditions of processing failure + * - If the area ID(tagID) specified by the argument is NULL [BKUP_RET_ERRPARAM] + * - If the area ID(tagID) specified by the argument is 64 bytes or more than 64 bytes [BKUP_RET_ERRPARAM] + * - If system call(pctrl(PR_GET_NAME)) is error [BKUP_RET_ERROR] + * - If failed to open the message queue for transmission [BKUP_RET_ERROR] + * - If failed to genarate message queue name for synchronous communication [BKUP_RET_ERROR] + * - If failed to open the reception message queue for synchronous communication [BKUP_RET_ERROR] + * - Sync message transmission or reception(@ref McInvokeSync) error + * - If the return value is eFrameworkunifiedStatusInvldParam [BKUP_RET_ERRPARAM] + * - If the return value is eFrameworkunifiedStatusErrOther [BKUP_RET_ERRINIT] + * - If the return value is eFrameworkunifiedStatusExit [BKUP_RET_ERRTERM] + * - If the return value is eFrameworkunifiedStatusFileLoadError [BKUP_RET_ERRNOENT] + * - If the return value is eFrameworkunifiedStatusAccessError [BKUP_RET_ERRSIZE] + * - If the return value is eFrameworkunifiedStatusFail, it call will synchronization message transmission(@ref McInvokeSync) again after 100 milliseconds later + * If the return value is eFrameworkunifiedStatusFail, it will retry BKUP_RETRY_MAX(10) times + * - If the return value is other value [BKUP_RET_ERROR] + * - If the size specified by the argument does not match the actual read size [BKUP_RET_ERROR] + * \~english @par Detail + * Judge the type and access destination according to specified area ID and check the target data. + * \~english @par Classification + * Public + * \~english @par Type + * Sync + * \~english @see + * none + */ +int32_t Backup_DataChk(PCSTR tag_id); + +/** + * \ingroup Backup_DataDel + * \~english @par Brief + * Delete backup data. + * \~english @param [in] tag_id + * PCSTR - Area ID(character string of less than 64 bytes) + * \~english @retval BKUP_RET_NORMAL Terminated normally + * \~english @retval BKUP_RET_ERRPARAM Parameter error(Sync message transmission or reception(@ref McInvokeSync) error[eFrameworkunifiedStatusInvldParam]) + * \~english @retval BKUP_RET_ERRINIT Initializing(Sync message send or receive(@ref McInvokeSync) error [eFrameworkunifiedStatusErrOther]) + * \~english @retval BKUP_RET_ERRTERM Terminating(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusExit]) + * \~english @retval BKUP_RET_ERRNOENT Data dose not exist(Sync message transmission or reception(@ref McInvokeSync) fails [eFrameworkunifiedStatusFileLoadError]) + * \~english @retval BKUP_RET_ERRSIZE Data size error(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusAccessError]) + * \~english @retval BKUP_RET_ERROR Abnormal termination(@ref McOpenSender failed, or sync message transmission or reception(@ref McInvokeSync) error other than the above) + * \~english @par Prerequisite + * - None. + * \~english @par Change of internal state + * - Change of internal state according to the API does not occur. + * \~english @par Conditions of processing failure + * - If the area ID(tagID) specified by the argument is NULL [BKUP_RET_ERRPARAM] + * - If the area ID(tagID) specified by the argument is 64 bytes or more than 64 bytes [BKUP_RET_ERRPARAM] + * - If system call(pctrl(PR_GET_NAME)) is error [BKUP_RET_ERROR] + * - If failed to open the message queue for transmission [BKUP_RET_ERROR] + * - If failed to genarate message queue name for synchronous communication [BKUP_RET_ERROR] + * - If failed to open the reception message queue for synchronous communication [BKUP_RET_ERROR] + * - Sync message transmission or reception(@ref McInvokeSync) error + * - If the return value is eFrameworkunifiedStatusInvldParam [BKUP_RET_ERRPARAM] + * - If the return value is eFrameworkunifiedStatusErrOther [BKUP_RET_ERRINIT] + * - If the return value is eFrameworkunifiedStatusExit [BKUP_RET_ERRTERM] + * - If the return value is eFrameworkunifiedStatusFileLoadError [BKUP_RET_ERRNOENT] + * - If the return value is eFrameworkunifiedStatusAccessError [BKUP_RET_ERRSIZE] + * - If the return value is eFrameworkunifiedStatusFail, it call will synchronization message transmission(@ref McInvokeSync) again after 100 milliseconds later + * If the return value is eFrameworkunifiedStatusFail, it will retry BKUP_RETRY_MAX(10) times + * - If the return value is other value [BKUP_RET_ERROR] + * \~english @par Detail + * Judge the type and access destination according to specified area ID and delete the target data. + * \~english @par Classification + * Public + * \~english @par Type + * Sync + * \~english @see + * none + */ +int32_t Backup_DataDel(PCSTR tag_id); + +#ifdef __cplusplus +} +#endif /*__cplusplus */ + +/**@}*/ // end of backup_manager +/**@}*/ // end of native_service +/**@}*/ // end of BaseSystem + +#endif // BACKUP_MANAGER_CLIENT_INCLUDE_NATIVE_SERVICE_NS_BACKUP_H_ diff --git a/backup_manager/client/libns_backup.ver b/backup_manager/client/libns_backup.ver new file mode 100644 index 00000000..4ad02dfb --- /dev/null +++ b/backup_manager/client/libns_backup.ver @@ -0,0 +1,34 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +# +# backup version script +# +{ + global: + ### .text section ### + Backup_DataRd; + Backup_DataWt; + Backup_DataFil; + Backup_DataSz; + Backup_DataRdByNumID; + Backup_DataSzByNumID; + Backup_DataChk; + Backup_DataDel; + ### .data section ### + local: + *; +}; diff --git a/backup_manager/client/src/bkup_api.cpp b/backup_manager/client/src/bkup_api.cpp new file mode 100644 index 00000000..1372ba8d --- /dev/null +++ b/backup_manager/client/src/bkup_api.cpp @@ -0,0 +1,343 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <fcntl.h> +#include <sys/mman.h> +#include <sys/prctl.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <unistd.h> +#include <native_service/ns_backup.h> +#include <native_service/ns_message_center_if.h> +#include <agl_thread.h> +#include <cerrno> +#include <cstdio> +#include <cstdlib> +#include <cstring> +#include "bkup_api.h" +#include "bkup_backupmanagerlog.h" +#include "bkup_util.h" + +#define BKUP_RETRY_MAX (10) +#define BKUP_RETRY_TIMER (100 * 1000) + +static __thread HANDLE g_bkup_msg_handle; +static __thread HANDLE g_bkup_response_handle; + +static int32_t BkupApiCheckTagid(PCSTR tag_id) { + if (tag_id == NULL) { + // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "tag_id is NULL"); + // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h" + return BKUP_RET_ERRPARAM; + } + if (strlen(tag_id) >= BKUP_MAX_ITEM_NAME) { + // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "tag_id is long:%zd", strlen(tag_id)); + // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h" + return BKUP_RET_ERRPARAM; + } + return BKUP_RET_NORMAL; +} + +static int32_t BkupApiCall(void *snd_buf, size_t snd_size, void *rcv_buf, uint32_t rcv_size) { + int32_t ret = BKUP_RET_ERROR; + EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusFail; + uint32_t real_rcvlen = 0; + static __thread char thread_name[16]; + + if (g_bkup_msg_handle == NULL) { + char invoker_name[24]; + + if (prctl(PR_GET_NAME, thread_name) < 0) { // LCOV_EXCL_BR_LINE 5:prctl's error case. + // LCOV_EXCL_START 5:prctl's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "prctl(PR_GET_NAME):%s", strerror(errno)); + goto exit; + // LCOV_EXCL_STOP 5:prctl's error case. + } + + g_bkup_msg_handle = McOpenSender(SERVICE_BACKUP_MANAGER_MSG_HANDLE_THREAD); + if (g_bkup_msg_handle == NULL) { // LCOV_EXCL_BR_LINE 4: NSFW error case + // LCOV_EXCL_START 4: NSFW error case + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "McOpenSender"); + goto exit; + // LCOV_EXCL_STOP 4: NSFW error case + } + + // LCOV_EXCL_BR_START 4: NSFW error case + if ((e_status = McCreateInvokerName(thread_name, 0, invoker_name, sizeof(invoker_name))) != eFrameworkunifiedStatusOK) { + // LCOV_EXCL_BR_STOP 4: NSFW error case + // LCOV_EXCL_START 4: NSFW error case + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "McCreateInvokerName:%d", e_status); + McClose(g_bkup_msg_handle); + g_bkup_msg_handle = NULL; + goto exit; + // LCOV_EXCL_STOP 4: NSFW error case + } + + g_bkup_response_handle = McOpenSyncReceiver(invoker_name); + if (g_bkup_response_handle == NULL) { // LCOV_EXCL_BR_LINE 4: NSFW error case + // LCOV_EXCL_START 4: NSFW error case + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "McOpenSyncReceiver"); + McClose(g_bkup_msg_handle); + g_bkup_msg_handle = NULL; + goto exit; + // LCOV_EXCL_STOP 4: NSFW error case + } + } + + for (int retry_cnt = 0; retry_cnt < BKUP_RETRY_MAX; retry_cnt++) { // LCOV_EXCL_BR_LINE 4: NSFW error case + e_status = McInvokeSync(g_bkup_msg_handle, thread_name, BACKUP_CID, static_cast<UI_32>(snd_size), snd_buf, 0, + g_bkup_response_handle, rcv_size, rcv_buf, &real_rcvlen); + if (e_status != eFrameworkunifiedStatusFail) { // LCOV_EXCL_BR_LINE 4: NSFW error case + break; + } + usleep(BKUP_RETRY_TIMER); + } + + if (e_status != eFrameworkunifiedStatusOK) { + // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "McInvokeSync:%d", e_status); + // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h" + if (e_status == eFrameworkunifiedStatusInvldParam) { + ret = BKUP_RET_ERRPARAM; + } else if (e_status == eFrameworkunifiedStatusErrOther) { + ret = BKUP_RET_ERRINIT; + } else if (e_status == eFrameworkunifiedStatusExit) { + ret = BKUP_RET_ERRTERM; + } else if (e_status == eFrameworkunifiedStatusFileLoadError) { + ret = BKUP_RET_ERRNOENT; + } else if (e_status == eFrameworkunifiedStatusAccessError) { + ret = BKUP_RET_ERRSIZE; + } else { + ret = BKUP_RET_ERROR; + } + goto exit; + } + if (rcv_size != real_rcvlen) { + goto exit; + } + ret = BKUP_RET_NORMAL; + +exit: + return ret; +} + +int32_t Backup_DataRd(PCSTR tag_id, uint32_t ui_offset, void *pv_buf, uint32_t ui_size) { + int32_t ret = BKUP_RET_NORMAL; + bkup_protocol_header_t hdr; + + if ((ret = BkupApiCheckTagid(tag_id)) != BKUP_RET_NORMAL) { + goto exit; + } + if (pv_buf == NULL) { + // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Buf is NULL"); + // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h" + ret = BKUP_RET_ERRPARAM; + goto exit; + } + + memset(&hdr, 0, sizeof(hdr)); + hdr.command = BKUP_CMD_READ; + BkupStrlcpy(hdr.item_name, tag_id, sizeof(hdr.item_name)); + hdr.offset = ui_offset; + hdr.size = ui_size; + + ret = BkupApiCall(&hdr, sizeof(hdr), pv_buf, ui_size); + +exit: + return ret; +} + +int32_t Backup_DataWt(PCSTR tag_id, void *pv_buf, uint32_t ui_offset, uint32_t ui_size) { + int32_t ret; + char *snd_buf = NULL; + size_t snd_buf_size = 0; + bkup_protocol_header_t *hdr; + + if ((ret = BkupApiCheckTagid(tag_id)) != BKUP_RET_NORMAL) { + goto exit; + } + if (pv_buf == NULL) { + // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Buf is NULL"); + // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h" + ret = BKUP_RET_ERRPARAM; + goto exit; + } + + // LCOV_EXCL_BR_START 5:mmap's error case. + if ((snd_buf = BkupAnonMmap(sizeof(bkup_protocol_header_t) + ui_size)) == MAP_FAILED) { + // LCOV_EXCL_BR_STOP 5:mmap's error case. + // LCOV_EXCL_START 5:mmap's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mmap:%s", strerror(errno)); + ret = BKUP_RET_ERROR; + goto exit; + // LCOV_EXCL_STOP 5:mmap's error case. + } + snd_buf_size = sizeof(bkup_protocol_header_t) + ui_size; + + hdr = reinterpret_cast<bkup_protocol_header_t *>(snd_buf); + hdr->command = BKUP_CMD_WRITE; + BkupStrlcpy(hdr->item_name, tag_id, sizeof(hdr->item_name)); + hdr->offset = ui_offset; + hdr->size = ui_size; + memcpy(snd_buf + sizeof(bkup_protocol_header_t), pv_buf, ui_size); + + ret = BkupApiCall(snd_buf, snd_buf_size, NULL, 0); + +exit: + if (snd_buf) { + munmap(snd_buf, snd_buf_size); + } + return ret; +} + +int32_t Backup_DataFil(PCSTR tag_id, uint32_t ui_offset, uint8_t uc_pat, uint32_t ui_size) { + int32_t ret; + bkup_protocol_header_t hdr; + + if ((ret = BkupApiCheckTagid(tag_id)) != BKUP_RET_NORMAL) { + goto exit; + } + + memset(&hdr, 0, sizeof(hdr)); + hdr.command = BKUP_CMD_FILL; + BkupStrlcpy(hdr.item_name, tag_id, sizeof(hdr.item_name)); + hdr.offset = ui_offset; + hdr.size = ui_size; + hdr.fill_patern = uc_pat; + + ret = BkupApiCall(&hdr, sizeof(hdr), NULL, 0); + +exit: + return ret; +} + +int32_t Backup_DataSz(PCSTR tag_id, uint32_t *pui_size) { + int32_t ret; + bkup_protocol_header_t hdr; + + if ((ret = BkupApiCheckTagid(tag_id)) != BKUP_RET_NORMAL) { + goto exit; + } + if (pui_size == NULL) { + // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Buf is NULL"); + // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h" + ret = BKUP_RET_ERRPARAM; + goto exit; + } + + memset(&hdr, 0, sizeof(hdr)); + hdr.command = BKUP_CMD_SIZE; + BkupStrlcpy(hdr.item_name, tag_id, sizeof(hdr.item_name)); + + ret = BkupApiCall(&hdr, sizeof(hdr), pui_size, sizeof(uint32_t)); + +exit: + return ret; +} + +int32_t Backup_DataRdByNumID(uint32_t num_id, uint32_t ui_offset, void *pv_buf, uint32_t ui_size) { + int32_t ret = BKUP_RET_NORMAL; + bkup_protocol_header_t hdr; + + if (pv_buf == NULL) { + // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Buf is NULL"); + // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h" + ret = BKUP_RET_ERRPARAM; + goto exit; + } + + memset(&hdr, 0, sizeof(hdr)); + hdr.command = BKUP_CMD_READ_NUM; + hdr.num_id = num_id; + hdr.offset = ui_offset; + hdr.size = ui_size; + + ret = BkupApiCall(&hdr, sizeof(hdr), pv_buf, ui_size); + +exit: + return ret; +} + +int32_t Backup_DataSzByNumID(uint32_t num_id, uint32_t *pui_size) { + int32_t ret; + bkup_protocol_header_t hdr; + + if (pui_size == NULL) { + // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Buf is NULL"); + // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h" + ret = BKUP_RET_ERRPARAM; + goto exit; + } + + memset(&hdr, 0, sizeof(hdr)); + hdr.command = BKUP_CMD_SIZE_NUM; + hdr.num_id = num_id; + + ret = BkupApiCall(&hdr, sizeof(hdr), pui_size, sizeof(uint32_t)); + +exit: + return ret; +} + +int32_t Backup_DataChk(PCSTR tag_id) { + int32_t ret; + bkup_protocol_header_t hdr; + + if ((ret = BkupApiCheckTagid(tag_id)) != BKUP_RET_NORMAL) { + goto exit; + } + + memset(&hdr, 0, sizeof(hdr)); + hdr.command = BKUP_CMD_CHECK; + BkupStrlcpy(hdr.item_name, tag_id, sizeof(hdr.item_name)); + + ret = BkupApiCall(&hdr, sizeof(hdr), NULL, 0); + +exit: + return ret; +} + +int32_t Backup_DataDel(PCSTR tag_id) { + int32_t ret; + bkup_protocol_header_t hdr; + + ret = BkupApiCheckTagid(tag_id); + if (ret != BKUP_RET_NORMAL) { + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "tag_id is invalid"); + goto exit; + } + + memset(&hdr, 0, sizeof(hdr)); + hdr.command = BKUP_CMD_DELETE; + BkupStrlcpy(hdr.item_name, tag_id, sizeof(hdr.item_name)); + + ret = BkupApiCall(&hdr, sizeof(hdr), NULL, 0); + +exit: + return ret; +} diff --git a/backup_manager/config/Makefile b/backup_manager/config/Makefile new file mode 100644 index 00000000..e669699a --- /dev/null +++ b/backup_manager/config/Makefile @@ -0,0 +1,43 @@ +# +# @copyright Copyright (c) 2017-2019 TOYOTA MOTOR CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +XML_PATH := ./conf/backup +RNG_FILE := backup.rng +ALL_XML := ALL_.xml +ID_HEADER := ns_backup_id.h +BACKUP_XML := backup.xml + +######### headers to be installed(*.h) ############# +INST_HEADERS := $(ID_HEADER) + +######### make rule ############# +all: $(ID_HEADER) + +$(ID_HEADER): $(XML_PATH)/$(ALL_XML) + @set -e; \ + for xml_file in `find $(XML_PATH) -name \*.xml | grep -v $(ALL_XML)`; do \ + xmllint --noout --relaxng $(RNG_FILE) $$xml_file; \ + ./uniqcheck.pl $$xml_file; \ + done + ./createhdr.pl $(XML_PATH)/$(ALL_XML) > $(ID_HEADER) + +CLEAN_FILES := $(ID_HEADER) + +install: $(XML_PATH)/$(BACKUP_XML) + install -m 0755 -d $(DESTDIR)/usr/agl/conf/backup_manager + install -m 0644 $(XML_PATH)/$(BACKUP_XML) $(DESTDIR)/usr/agl/conf/backup_manager/$(BACKUP_XML) + +include ../../native_service.mk diff --git a/backup_manager/config/backup.rng b/backup_manager/config/backup.rng new file mode 100644 index 00000000..6c9822b3 --- /dev/null +++ b/backup_manager/config/backup.rng @@ -0,0 +1,123 @@ +<element name="backup" xmlns="http://relaxng.org/ns/structure/1.0"> + <zeroOrMore> + <element name="category" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> + <attribute name="name"> + <data type="Name"> + <param name="maxLength">64</param> + </data> + </attribute> + <choice> + <!-- NAND --> + <group> + <attribute name="nand"> + <choice> + <value type="boolean">true</value> + </choice> + </attribute> + <optional> + <attribute name="cacheDram"> + <data type="boolean"/> + </attribute> + </optional> + <optional> + <attribute name="backupDram"> + <data type="boolean"/> + </attribute> + </optional> + <attribute name="sync"> + <data type="boolean"/> + </attribute> + <optional> + <attribute name="backupCycle"> + <data type="positiveInteger"/> + </attribute> + </optional> + <attribute name="encrypt"> + <data type="boolean"/> + </attribute> + </group> + <!-- CacheDRAM --> + <group> + <attribute name="cacheDram"> + <choice> + <value type="boolean">true</value> + </choice> + </attribute> + <optional> + <attribute name="nand"> + <choice> + <value type="boolean">false</value> + </choice> + </attribute> + </optional> + <optional> + <attribute name="backupDram"> + <choice> + <value type="boolean">false</value> + </choice> + </attribute> + </optional> + <optional> + <attribute name="sync"> + <choice> + <value type="boolean">false</value> + </choice> + </attribute> + </optional> + <attribute name="encrypt"> + <data type="boolean"/> + </attribute> + </group> + <!-- BackupDRAM --> + <group> + <attribute name="backupDram"> + <choice> + <value type="boolean">true</value> + </choice> + </attribute> + <optional> + <attribute name="nand"> + <choice> + <value type="boolean">false</value> + </choice> + </attribute> + </optional> + <optional> + <attribute name="cacheDram"> + <choice> + <value type="boolean">false</value> + </choice> + </attribute> + </optional> + <optional> + <attribute name="sync"> + <choice> + <value type="boolean">false</value> + </choice> + </attribute> + </optional> + <attribute name="encrypt"> + <data type="boolean"/> + </attribute> + </group> + </choice> + <zeroOrMore> + <element name="item"> + <attribute name="name"> + <data type="Name"> + <param name="maxLength">64</param> + </data> + </attribute> + <attribute name="id"> + <data type="positiveInteger"> + <param name="maxInclusive">32767</param> + </data> + </attribute> + <attribute name="size"> + <data type="positiveInteger"/> + </attribute> + </element> + </zeroOrMore> + </element> + </zeroOrMore> +</element> diff --git a/backup_manager/config/conf/backup/ALL_.xml b/backup_manager/config/conf/backup/ALL_.xml new file mode 100644 index 00000000..7149b795 --- /dev/null +++ b/backup_manager/config/conf/backup/ALL_.xml @@ -0,0 +1,1201 @@ +<?xml version="1.0" encoding="UTF-8"?> +<backup> + <category name="D_BK_CA_GID_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_GID_D" id="0001" size="1"/> + </category> + <category name="D_BK_CA_MPT_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_MPT_D" id="0002" size="1"/> + </category> + <category name="D_BK_CA_LPT_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LPT_D" id="0003" size="1"/> + </category> + <category name="D_BK_CA_LSDBKUP" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LSDBKUP" id="0004" size="1"/> + </category> + <category name="D_BK_CA_GPSINFO" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_GPSINFO" id="0005" size="1"/> + </category> + <category name="D_BK_CA_MADTIME" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_MADTIME" id="0006" size="1"/> + </category> + <category name="D_BK_CA_DTI_TEC" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_DTI_TEC" id="0007" size="1"/> + </category> + <category name="D_BK_CA_HDW_SCL" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_HDW_SCL" id="0008" size="1"/> + </category> + <category name="D_BK_CA_LOC_POS" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_POS" id="0009" size="1"/> + </category> + <category name="D_BK_CA_LOC_GYRO" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_GYRO" id="0010" size="1"/> + </category> + <category name="D_BK_CA_LOC_DIST" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_DIST" id="0011" size="1"/> + </category> + <category name="D_BK_CA_LOC_HELP" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_HELP" id="0012" size="1"/> + </category> + <category name="D_BK_CA_LOC_TDST" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_TDST" id="0013" size="1"/> + </category> + <category name="D_BK_CA_LOC_PSSR" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_PSSR" id="0014" size="1"/> + </category> + <category name="D_BK_CA_LOC_GSRV" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_GSRV" id="0015" size="1"/> + </category> + <category name="D_BK_CA_LOC_TTBL" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_TTBL" id="0016" size="1"/> + </category> + <category name="D_BK_CA_LOC_PLGN" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_PLGN" id="0017" size="1"/> + </category> + <category name="D_BK_CA_LOC_CAM" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_CAM" id="0018" size="1"/> + </category> + <category name="D_BK_CA_LOC_DIAG" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_DIAG" id="0019" size="1"/> + </category> + <category name="D_BK_CA_LOC_SLRN" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_SLRN" id="0020" size="1"/> + </category> + <category name="D_BK_CA_LOC_MCKH" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_MCKH" id="0021" size="1"/> + </category> + <category name="D_BK_CA_LOC_GSBK" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_GSBK" id="0022" size="1"/> + </category> + <category name="D_BK_CA_LOC_RLRN" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_RLRN" id="0023" size="1"/> + </category> + <category name="D_BK_CA_LOC_PARK" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_PARK" id="0024" size="1"/> + </category> + <category name="D_BK_CA_LOC_SAPA" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_SAPA" id="0025" size="1"/> + </category> + <category name="D_BK_CA_LOC_TTJD" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_TTJD" id="0026" size="1"/> + </category> + <category name="D_BK_CA_LOC_UPLD" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_UPLD" id="0027" size="1"/> + </category> + <category name="D_BK_CA_LOC_TTKH" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_TTKH" id="0028" size="1"/> + </category> + <category name="D_BK_CA_LOC_UPNR" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_UPNR" id="0029" size="1"/> + </category> + <category name="D_BK_CA_LOC_OFRD" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_OFRD" id="0030" size="1"/> + </category> + <category name="D_BK_CA_LOC_OSRS" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_OSRS" id="0031" size="1"/> + </category> + <category name="D_BK_CA_LOC_MCIN" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_MCIN" id="0032" size="1"/> + </category> + <category name="D_BK_CA_LOC_LCSM" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_LCSM" id="0033" size="1"/> + </category> + <category name="D_BK_CA_LOC_LCSR" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_LCSR" id="0034" size="1"/> + </category> + <category name="D_BK_CA_LOC_LCS1" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_LCS1" id="0035" size="1"/> + </category> + <category name="D_BK_CA_LOC_LCS2" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_LCS2" id="0036" size="1"/> + </category> + <category name="D_BK_CA_LOC_LCS3" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_LCS3" id="0037" size="1"/> + </category> + <category name="D_BK_CA_LOC_LCS4" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_LCS4" id="0038" size="1"/> + </category> + <category name="D_BK_CA_LOC_LCS5" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_LCS5" id="0039" size="1"/> + </category> + <category name="D_BK_CA_LOC_LCS6" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_LCS6" id="0040" size="1"/> + </category> + <category name="D_BK_CA_LOC_LCS7" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_LCS7" id="0041" size="1"/> + </category> + <category name="D_BK_CA_LOC_LCS8" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_LCS8" id="0042" size="1"/> + </category> + <category name="D_BK_CA_MNT_BK1" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_MNT_BK1" id="0043" size="1"/> + </category> + <category name="D_BK_CA_MNT_BK2" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_MNT_BK2" id="0044" size="1"/> + </category> + <category name="D_BK_CA_LOC_GLCM" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_GLCM" id="0045" size="1"/> + </category> + <category name="D_BK_CA_LOC_GLCR" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_GLCR" id="0046" size="1"/> + </category> + <category name="D_BK_CA_LOC_GLC1" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_GLC1" id="0047" size="1"/> + </category> + <category name="D_BK_CA_LOC_GLC2" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_GLC2" id="0048" size="1"/> + </category> + <category name="D_BK_CA_LOC_GLC3" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_GLC3" id="0049" size="1"/> + </category> + <category name="D_BK_CA_LOC_GLC4" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_GLC4" id="0050" size="1"/> + </category> + <category name="D_BK_CA_LOC_GLC5" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_GLC5" id="0051" size="1"/> + </category> + <category name="D_BK_CA_LOC_GLC6" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_GLC6" id="0052" size="1"/> + </category> + <category name="D_BK_CA_LOC_GLC7" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_GLC7" id="0053" size="1"/> + </category> + <category name="D_BK_CA_LOC_GLC8" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_GLC8" id="0054" size="1"/> + </category> + <category name="D_BK_CA_GPSCNT" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_GPSCNT" id="0055" size="1"/> + </category> + <category name="D_BK_CA_MYRT_MNG" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_MYRT_MNG" id="0056" size="1"/> + </category> + <category name="D_BK_CA_MYRT_RT1" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_MYRT_RT1" id="0057" size="1"/> + </category> + <category name="D_BK_CA_MYRT_RT2" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_MYRT_RT2" id="0058" size="1"/> + </category> + <category name="D_BK_CA_MYRT_RT3" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_MYRT_RT3" id="0059" size="1"/> + </category> + <category name="D_BK_CA_MYRT_RT4" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_MYRT_RT4" id="0060" size="1"/> + </category> + <category name="D_BK_CA_MYRT_RT5" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_MYRT_RT5" id="0061" size="1"/> + </category> + <category name="D_BK_CA_HMI_NS1" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_HMI_NS1" id="0062" size="1"/> + </category> + <category name="D_BK_CA_HMI_NS2" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_HMI_NS2" id="0063" size="1"/> + </category> + <category name="D_BK_CA_HMI_NS3" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_HMI_NS3" id="0064" size="1"/> + </category> + <category name="D_BK_CA_AVD_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_AVD_D" id="0065" size="1"/> + </category> + <category name="D_BK_CA_GPT_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_GPT_D" id="0066" size="1"/> + </category> + <category name="D_BK_CA_RTINF_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_RTINF_D" id="0067" size="1"/> + </category> + <category name="D_BK_CA_RDT_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_RDT_D" id="0068" size="1"/> + </category> + <category name="D_BK_CA_ETA_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_ETA_D" id="0069" size="1"/> + </category> + <category name="D_BK_CA_LOC_GYTP" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_GYTP" id="0070" size="1"/> + </category> + <category name="D_BK_CA_GID_F" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_GID_F" id="0071" size="1"/> + </category> + <category name="D_BK_CA_MPT_F" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_MPT_F" id="0072" size="1"/> + </category> + <category name="D_BK_CA_AVD_F" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_AVD_F" id="0073" size="1"/> + </category> + <category name="D_BK_CA_LPT_F" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_LPT_F" id="0074" size="1"/> + </category> + <category name="D_BK_CA_VR_POI" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_VR_POI" id="0075" size="1"/> + </category> + <category name="D_BK_CA_BKWNRO" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_BKWNRO" id="0076" size="1"/> + </category> + <category name="D_BK_CA_MPTGRP_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_MPTGRP_D" id="0077" size="1"/> + </category> + <category name="D_BK_CA_MPTGRP_F" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_MPTGRP_F" id="0078" size="1"/> + </category> + <category name="D_BK_CA_DTI_TFPMMC" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_DTI_TFPMMC" id="0079" size="1"/> + </category> + <category name="D_BK_CA_DTI_TFPDATA" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_DTI_TFPDATA" id="0080" size="1"/> + </category> + <category name="D_BK_CA_DTI_BCN" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_DTI_BCN" id="0081" size="1"/> + </category> + <category name="D_BK_CA_DTI_FM" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_DTI_FM" id="0082" size="1"/> + </category> + <category name="D_BK_CA_DTI_DSRC" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_DTI_DSRC" id="0083" size="1"/> + </category> + <category name="D_BK_CA_DTI_DRG" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_DTI_DRG" id="0084" size="1"/> + </category> + <category name="D_BK_CA_DTI_BRD" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_DTI_BRD" id="0085" size="1"/> + </category> + <category name="D_BK_CA_MADMNG_RCVINFO" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_MADMNG_RCVINFO" id="0086" size="1"/> + </category> + <category name="D_BK_CA_MAD_UPDATEINFO" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_MAD_UPDATEINFO" id="0087" size="1"/> + </category> + <category name="D_BK_CA_NM_NWINF01" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_NM_NWINF01" id="0088" size="1"/> + </category> + <category name="D_BK_CA_NM_NWINF02" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_NM_NWINF02" id="0089" size="1"/> + </category> + <category name="D_BK_CA_ND2_SAPA" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_ND2_SAPA" id="0090" size="1"/> + </category> + <category name="D_BK_CA_SMS_RVS" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_SMS_RVS" id="0091" size="1"/> + </category> + <category name="D_BK_CA_SMS_VSC" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_SMS_VSC" id="0092" size="1"/> + </category> + <category name="D_BK_CA_VCJ_CTL1" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_VCJ_CTL1" id="0093" size="1"/> + </category> + <category name="D_BK_CA_VCJ_MNT1" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_VCJ_MNT1" id="0094" size="1"/> + </category> + <category name="D_BK_CA_VCJ_CTL2" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_VCJ_CTL2" id="0095" size="1"/> + </category> + <category name="D_BK_CA_VCJ_MNT2" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_VCJ_MNT2" id="0096" size="1"/> + </category> + <category name="D_BK_CA_DIC_SDAT" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_DIC_SDAT" id="0097" size="1"/> + </category> + <category name="D_BK_CA_DIC_UDAT" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_DIC_UDAT" id="0098" size="1"/> + </category> + <category name="D_BK_CA_DIC_MDAT" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_DIC_MDAT" id="0099" size="1"/> + </category> + <category name="D_BK_CA_NPMNG_PB" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_NPMNG_PB" id="0100" size="1"/> + </category> + <category name="D_BK_CA_NPMNG_UP" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_NPMNG_UP" id="0101" size="1"/> + </category> + <category name="D_BK_CA_NPMNG_CT" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_NPMNG_CT" id="0102" size="1"/> + </category> + <category name="D_BK_CA_LOC_EA" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_EA" id="0103" size="1"/> + </category> + <category name="D_BK_CA_LOC_ER" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_ER" id="0104" size="1"/> + </category> + <category name="D_BK_CA_LOC_EBA" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_EBA" id="0105" size="1"/> + </category> + <category name="D_BK_CA_LOC_EBD" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LOC_EBD" id="0106" size="1"/> + </category> + <category name="D_BK_CA_AWYMNG_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_AWYMNG_D" id="0107" size="1"/> + </category> + <category name="D_BK_CA_AWYDT_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_AWYDT_D" id="0108" size="1"/> + </category> + <category name="D_BK_CA_AWYCD_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_AWYCD_D" id="0109" size="1"/> + </category> + <category name="D_BK_CA_PWMPT_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_PWMPT_D" id="0110" size="1"/> + </category> + <category name="D_BK_CA_GPOI_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_GPOI_D" id="0111" size="1"/> + </category> + <category name="D_BK_CA_LFM_REC" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LFM_REC" id="0112" size="1"/> + </category> + <category name="D_BK_CA_LFM_RUN1" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LFM_RUN1" id="0113" size="1"/> + </category> + <category name="D_BK_CA_LFM_RUN2" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LFM_RUN2" id="0114" size="1"/> + </category> + <category name="D_BK_CA_LFM_INIT" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LFM_INIT" id="0115" size="1"/> + </category> + <category name="D_BK_CA_PWMPT_F" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_PWMPT_F" id="0116" size="1"/> + </category> + <category name="D_BK_CA_BDMPT_F" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_BDMPT_F" id="0117" size="1"/> + </category> + <category name="D_BK_CA_GPOI_F" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_GPOI_F" id="0118" size="1"/> + </category> + <category name="D_BK_CA_ECOLRNJP" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_ECOLRNJP" id="0119" size="1"/> + </category> + <category name="D_BK_CA_RDTECOJP" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_RDTECOJP" id="0120" size="1"/> + </category> + <category name="D_BK_CA_NPH_CONF" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_NPH_CONF" id="0121" size="1"/> + </category> + <category name="D_BK_CA_NPH_ONDATA" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_NPH_ONDATA" id="0122" size="1"/> + </category> + <category name="D_BK_CA_NPH_CODATA" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_NPH_CODATA" id="0123" size="1"/> + </category> + <category name="D_BK_CA_NPFU_CND" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_NPFU_CND" id="0124" size="1"/> + </category> + <category name="D_BK_CA_NPFU_COL" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_NPFU_COL" id="0125" size="1"/> + </category> + <category name="D_BK_CA_NPFU_STR" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_NPFU_STR" id="0126" size="1"/> + </category> + <category name="D_BK_CA__CWORD67__ITS" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID__CWORD67__ITS" id="0127" size="1"/> + </category> + <category name="D_BK_CA_HMI_MS1" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_HMI_MS1" id="0128" size="1"/> + </category> + <category name="D_BK_CA_HMI_MS2" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_HMI_MS2" id="0129" size="1"/> + </category> + <category name="D_BK_CA_SKN_BTN" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_BTN" id="0134" size="1"/> + </category> + <category name="D_BK_CA_G_PER_CA" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_G_PER_CA" id="0135" size="1"/> + </category> + <category name="D_BK_CA_G_BR_HIS" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_G_BR_HIS" id="0136" size="1"/> + </category> + <category name="D_BK_CA_CAR_CDF" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_CAR_CDF" id="0137" size="1"/> + </category> + <category name="D_BK_CA_ACC_CDF" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_ACC_CDF" id="0138" size="1"/> + </category> + <category name="D_BK_CA_CEL_CDF" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_CEL_CDF" id="0139" size="1"/> + </category> + <category name="D_BK_CA_CDF_ONS" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_CDF_ONS" id="0140" size="1"/> + </category> + <category name="D_BK_CA_CON_CDF1" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_CON_CDF1" id="0141" size="1"/> + </category> + <category name="D_BK_CA_CON_CDF2" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_CON_CDF2" id="0142" size="1"/> + </category> + <category name="D_BK_CA_SPFC_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_SPFC_D" id="0143" size="1"/> + </category> + <category name="D_BK_CA_ECORT_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_ECORT_D" id="0144" size="1"/> + </category> + <category name="D_BK_CA_SPFC_F" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_SPFC_F" id="0145" size="1"/> + </category> + <category name="D_BK_CA_ECORT_F" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_ECORT_F" id="0146" size="1"/> + </category> + <category name="D_BK_CA_G_BM_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_G_BM_D" id="0149" size="1"/> + </category> + <category name="D_BK_CA_SKN_J09" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J09" id="0150" size="1"/> + </category> + <category name="D_BK_CA_SKN_J10" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J10" id="0151" size="1"/> + </category> + <category name="D_BK_CA_SKN_J11" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J11" id="0152" size="1"/> + </category> + <category name="D_BK_CA_SKN_J12" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J12" id="0153" size="1"/> + </category> + <category name="D_BK_CA_SKN_J13" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J13" id="0154" size="1"/> + </category> + <category name="D_BK_CA_SKN_J14" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J14" id="0155" size="1"/> + </category> + <category name="D_BK_CA_SKN_J15" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J15" id="0156" size="1"/> + </category> + <category name="D_BK_CA_SKN_J16" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J16" id="0157" size="1"/> + </category> + <category name="D_BK_CA_SKN_J17" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J17" id="0158" size="1"/> + </category> + <category name="D_BK_CA_SKN_J18" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J18" id="0159" size="1"/> + </category> + <category name="D_BK_CA_SKN_J19" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J19" id="0160" size="1"/> + </category> + <category name="D_BK_CA_SKN_J20" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J20" id="0161" size="1"/> + </category> + <category name="D_BK_CA_SKN_J21" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J21" id="0162" size="1"/> + </category> + <category name="D_BK_CA_SKN_J22" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J22" id="0163" size="1"/> + </category> + <category name="D_BK_CA_SKN_J23" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J23" id="0164" size="1"/> + </category> + <category name="D_BK_CA_SKN_J24" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J24" id="0165" size="1"/> + </category> + <category name="D_BK_CA_SKN_J25" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J25" id="0166" size="1"/> + </category> + <category name="D_BK_CA_SKN_J26" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J26" id="0167" size="1"/> + </category> + <category name="D_BK_CA_SKN_J27" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J27" id="0168" size="1"/> + </category> + <category name="D_BK_CA_SKN_J28" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J28" id="0169" size="1"/> + </category> + <category name="D_BK_CA_SKN_J29" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J29" id="0170" size="1"/> + </category> + <category name="D_BK_CA_SKN_J30" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J30" id="0171" size="1"/> + </category> + <category name="D_BK_CA_SKN_J31" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J31" id="0172" size="1"/> + </category> + <category name="D_BK_CA_SKN_J32" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J32" id="0173" size="1"/> + </category> + <category name="D_BK_CA_SKN_J33" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J33" id="0174" size="1"/> + </category> + <category name="D_BK_CA_SKN_J34" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J34" id="0175" size="1"/> + </category> + <category name="D_BK_CA_SKN_J35" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J35" id="0176" size="1"/> + </category> + <category name="D_BK_CA_SKN_J36" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J36" id="0177" size="1"/> + </category> + <category name="D_BK_CA_SKN_J37" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J37" id="0178" size="1"/> + </category> + <category name="D_BK_CA_SKN_J38" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J38" id="0179" size="1"/> + </category> + <category name="D_BK_CA_SKN_E01" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E01" id="0180" size="1"/> + </category> + <category name="D_BK_CA_SKN_E02" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E02" id="0181" size="1"/> + </category> + <category name="D_BK_CA_SKN_E03" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E03" id="0182" size="1"/> + </category> + <category name="D_BK_CA_SKN_E04" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E04" id="0183" size="1"/> + </category> + <category name="D_BK_CA_SKN_E05" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E05" id="0184" size="1"/> + </category> + <category name="D_BK_CA_SKN_E06" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E06" id="0185" size="1"/> + </category> + <category name="D_BK_CA_SKN_E07" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E07" id="0186" size="1"/> + </category> + <category name="D_BK_CA_SKN_E08" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E08" id="0187" size="1"/> + </category> + <category name="D_BK_CA_SKN_E09" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E09" id="0188" size="1"/> + </category> + <category name="D_BK_CA_SKN_E10" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E10" id="0189" size="1"/> + </category> + <category name="D_BK_CA_SKN_E11" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E11" id="0190" size="1"/> + </category> + <category name="D_BK_CA_SKN_E12" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E12" id="0191" size="1"/> + </category> + <category name="D_BK_CA_SKN_E13" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E13" id="0192" size="1"/> + </category> + <category name="D_BK_CA_SKN_E14" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E14" id="0193" size="1"/> + </category> + <category name="D_BK_CA_SKN_E15" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E15" id="0194" size="1"/> + </category> + <category name="D_BK_CA_SKN_E16" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E16" id="0195" size="1"/> + </category> + <category name="D_BK_CA_SKN_E17" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E17" id="0196" size="1"/> + </category> + <category name="D_BK_CA_SKN_E18" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E18" id="0197" size="1"/> + </category> + <category name="D_BK_CA_SKN_E19" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E19" id="0198" size="1"/> + </category> + <category name="D_BK_CA_SKN_E20" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E20" id="0199" size="1"/> + </category> + <category name="D_BK_CA_SKN_E21" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E21" id="0200" size="1"/> + </category> + <category name="D_BK_CA_SKN_E22" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E22" id="0201" size="1"/> + </category> + <category name="D_BK_CA_SKN_E23" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E23" id="0202" size="1"/> + </category> + <category name="D_BK_CA_SKN_E24" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E24" id="0203" size="1"/> + </category> + <category name="D_BK_CA_SKN_E25" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E25" id="0204" size="1"/> + </category> + <category name="D_BK_CA_SKN_E26" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E26" id="0205" size="1"/> + </category> + <category name="D_BK_CA_SKN_E27" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E27" id="0206" size="1"/> + </category> + <category name="D_BK_CA_SKN_E28" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E28" id="0207" size="1"/> + </category> + <category name="D_BK_CA_SKN_E29" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E29" id="0208" size="1"/> + </category> + <category name="D_BK_CA_SKN_E30" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E30" id="0209" size="1"/> + </category> + <category name="D_BK_CA_SKN_E31" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E31" id="0210" size="1"/> + </category> + <category name="D_BK_CA_SKN_E32" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E32" id="0211" size="1"/> + </category> + <category name="D_BK_CA_SKN_E33" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E33" id="0212" size="1"/> + </category> + <category name="D_BK_CA_SKN_E34" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E34" id="0213" size="1"/> + </category> + <category name="D_BK_CA_SKN_E35" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E35" id="0214" size="1"/> + </category> + <category name="D_BK_CA_SKN_E36" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E36" id="0215" size="1"/> + </category> + <category name="D_BK_CA_SKN_E37" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E37" id="0216" size="1"/> + </category> + <category name="D_BK_CA_SKN_E38" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_E38" id="0217" size="1"/> + </category> + <category name="D_BK_CA_DAPL_ICN" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_DAPL_ICN" id="0218" size="1"/> + </category> + <category name="D_BK_CA_MADMNG_MEMCLEAR" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_MADMNG_MEMCLEAR" id="0219" size="1"/> + </category> + <category name="D_BK_CA_VEHICLE_NAND" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_VEHICLE_STABLE_DATA" id="0227" size="1"/> + </category> + <category name="D_BK_CA_VEHICLE_DRAM" nand="false" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_VEHICLE_DRAMBKUP_DATA" id="0228" size="1"/> + </category> + <category name="D_BK_CA_DUMMYREAD_OFFSET" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_DUMMYREAD_OFFSET" id="0229" size="1"/> + </category> + <category name="D_BK_CA_DPSSERVICE_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_DPSSERVICE_PARAMETER" id="0230" size="1"/> + </category> + <category name="D_BK_CA_MEDSRV_RESUME" nand="false" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_MEDSRV_MMCOM_RESUME" id="0231" size="1"/> + <item name="D_BK_ID_MEDSRV_ITGP_RESUME" id="0274" size="1"/> + <item name="D_BK_ID_MEDSRV_DISC_RESUME" id="0275" size="1"/> + <item name="D_BK_ID_MEDSRV__CWORD57__RESUME" id="0276" size="1"/> + <item name="D_BK_ID_MEDSRV_BTA_RESUME" id="0277" size="1"/> + <item name="D_BK_ID_MEDSRV_CDRIP_RESUME" id="0278" size="1"/> + <item name="D_BK_ID_MEDSRV_SDVCOM_RESUME" id="0444" size="1"/> + </category> + <category name="D_BK_CA_REPROS_UPDATEPARAM" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_REPROS_UPDATEPARAM" id="0232" size="1"/> + <item name="D_BK_ID_REPROS_SERVICEFLG" id="0371" size="1"/> + <item name="D_BK_ID_REPROS_AUTO_UPDATE_CHECK" id="0372" size="1"/> + <item name="D_BK_ID_REPROS_NA03OUT_DLID" id="0373" size="1"/> + <item name="D_BK_ID_REPROS_NA03OUT_RESULT" id="0374" size="1"/> + <item name="D_BK_ID_REPROS_RESUME_TIME" id="0375" size="1"/> + <item name="D_BK_ID_REPROS_NA03OUT_PCGVER" id="0376" size="1"/> + <item name="D_BK_ID_REPROS_NA03OUT_UPDATE_TIMING" id="0377" size="1"/> + <item name="D_BK_ID_REPROS_NA03OUT_UPDATE_TIMEOUT" id="0378" size="1"/> + <item name="D_BK_ID_REPROS_NA05OUT_RESULT" id="0379" size="1"/> + <item name="D_BK_ID_REPROS_NA03OUT_DLURL" id="0380" size="1"/> + <item name="D_BK_ID_REPROS_NA03OUT_UPDATE_INFO" id="0381" size="1"/> + <item name="D_BK_ID_REPROS_CENTERCOMM_STATE" id="0382" size="1"/> + <item name="D_BK_ID_REPROS_MAP_VER" id="0383" size="1"/> + <item name="D_BK_ID_REPROS_NA07_HISTORY_INFO" id="0385" size="1"/> + <item name="D_BK_ID_REPROS_UPDATE_INFO" id="0386" size="1"/> + <item name="D_BK_ID_REPROS_NA05_DOWNLOAD_SIZE" id="0387" size="1"/> + <item name="D_BK_ID_REPROS_FILE_PATH_INFO" id="0399" size="1"/> + <item name="D_BK_ID_REPROS_UPDATE_FILE_EXIST" id="0401" size="1"/> + <item name="D_BK_ID_REPROS_START_STATE_INFO" id="0403" size="1"/> + <item name="D_BK_ID_REPROS_CHECKFORUPDATE_TIME" id="0404" size="1"/> + </category> + <category name="D_BK_CA_REPROS_UPDATEHISTORY" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_REPROS_UPDATEHISTORY" id="0233" size="1"/> + </category> + <category name="D_BK_CA_REPROS_UPDATEINFO" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_REPROS_UPDATEINFO" id="0234" size="1"/> + </category> + <category name="D_BK_CA_SKB_N" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKB_N" id="0235" size="1"/> + </category> + <category name="D_BK_CA_SKB_M" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKB_M" id="0236" size="1"/> + </category> + <category name="D_BK_CA_SKB_G" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKB_G" id="0237" size="1"/> + </category> + <category name="D_BK_CA_SKB_B" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKB_B" id="0238" size="1"/> + </category> + <category name="D_BK_CA_SKB_T" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKB_T" id="0239" size="1"/> + </category> + <category name="D_BK_CA_CLOCK" nand="false" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_CLOCK_OFFSET" id="0240" size="1"/> + <item name="D_BK_ID_CLOCK_STATE" id="0241" size="1"/> + </category> + <category name="D_BK_CA__CWORD76__INFO_SYNC" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID__CWORD76__INFO_SYNC_OFFSET" id="0242" size="1"/> + </category> + <category name="D_BK_CA__CWORD76__INFO_ASYNC" nand="true" cacheDram="true" sync="false" backupCycle="15" encrypt="false"> + <item name="D_BK_ID__CWORD76__INFO_ASYNC_OFFSET" id="0243" size="1"/> + </category> + <category name="D_BK_CA_DIAG_INFORMATION" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_DIAG_INFORMATION" id="0244" size="1"/> + </category> + <category name="D_BK_CA_DIAG_UTILIZATION" nand="true" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_DIAG_UTILIZATION" id="0245" size="1"/> + </category> + <category name="D_BK_CA_VS_VSDSRV_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_VS_VSDSRV_PARAMETER" id="0246" size="1"/> + </category> + <category name="D_BK_CA_VS_ACNSRV_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_VS_ACNSRV_PARAMETER" id="0247" size="1"/> + </category> + <category name="D_BK_CA_VS_FUCSRV_ASYNC" nand="true" backupDram="true" sync="false" backupCycle="15" encrypt="false"> + <item name="D_BK_ID_VS_FUCSRV_ASYNC_GRP" id="0248" size="1"/> + </category> + <category name="D_BK_CA_VS_FUCSRV_SYNC" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_VS_FUCSRV_SYNC_GRP" id="0249" size="1"/> + </category> + <category name="D_BK_CA_VINFOSRV_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_VINFOSRV_PARAMETER" id="0250" size="1"/> + </category> + <category name="D_BK_CA_POS_GPS_FIX_CNT" nand="true" cacheDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_POS_GPS_FIX_CNT" id="0251" size="1"/> + </category> + <category name="D_BK_CA_POS_GPS_TD_STS" nand="false" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_POS_GPS_TD_STS" id="0252" size="1"/> + </category> + <category name="D_BK_CA_POS_GPS_ROLLOVER_CNT" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_POS_GPS_ROLLOVER_CNT" id="0253" size="1"/> + </category> + <category name="D_BK_CA_WLANM_INFO" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_WLANM_INFO" id="0254" size="1"/> + </category> + <category name="D_BK_CA_BTSTK_LINKKEY" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_BTSTK_LINKKEY" id="0255" size="1"/> + </category> + <category name="D_BK_CA_EOM_CONTENTS_STATUS" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_EOM_CONTENTS_STATUS" id="0256" size="1"/> + </category> + <category name="D_BK_CA_UPDSERVICE_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_UPDSERVICE_PARAMETER" id="0257" size="1"/> + </category> + <category name="D_BK_CA_RS_WNG_RCV" nand="false" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_RS_WNG_RCV" id="0259" size="1"/> + </category> + <category name="D_BK_CA_INFS_GENERAL_GRP" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_INFS_GENERAL_GRP" id="0260" size="1"/> + </category> + <category name="D_BK_CA_INFS_GENERAL_STARTUPBGM" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_INFS_GENERAL_STARTUPBGM" id="0261" size="1"/> + </category> + <category name="D_BK_CA_INFS_CLOCK_GRP" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_INFS_CLOCK_GRP" id="0262" size="1"/> + </category> + <category name="D_BK_CA_INFS_HOME_GRP" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_INFS_HOME_GRP" id="0263" size="1"/> + </category> + <category name="D_BK_CA_INFS_VOICE_GRP" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_INFS_VOICE_GRP" id="0264" size="1"/> + </category> + <category name="D_BK_CA_INFS_VOICE_INTERRUPT_VOL" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_INFS_VOICE_INTERRUPT_VOL" id="0265" size="1"/> + </category> + <category name="D_BK_CA_INFS_MENU_GRP" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_INFS_MENU_GRP" id="0266" size="1"/> + </category> + <category name="D_BK_CA_INFS_MENU_UIC_TAB" nand="true" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_INFS_MENU_UIC_TAB" id="0268" size="1"/> + </category> + <category name="D_BK_CA_INFS_METERCOOP_GRP" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_INFS_METERCOOP_GRP" id="0269" size="1"/> + </category> + <category name="D_BK_CA_INFS_METERCOOP_MET" nand="true" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_INFS_METERCOOP_MET" id="0270" size="1"/> + </category> + <category name="D_BK_CA_INFS_UIC_GRP" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_INFS_UIC_GRP" id="0271" size="1"/> + </category> + <category name="D_BK_CA_INFS_UIC_FILENAME" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_INFS_UIC_FILENAME" id="0272" size="1"/> + </category> + <category name="D_BK_CA_INFS_SMARTAGENT_GRP" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_INFS_SMARTAGENT_GRP" id="0273" size="1"/> + </category> + <category name="D_BK_CA_MEDSRV_SETTING" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_MEDSRV_DISC_SETTING" id="0279" size="1"/> + <item name="D_BK_ID_MEDSRV_CDRIP_SETTING" id="0280" size="1"/> + <item name="D_BK_ID_MEDSRV_COM_SETTING" id="420" size="1"/> + </category> + <category name="D_BK_CA_GNDB_UPDATE_HISTORY" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_GNDB_UPDATE_HISTORY" id="0281" size="1"/> + </category> + <category name="D_BK_CA_DIAGCODE_MEM" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_DIAGCODE_MEM" id="0282" size="1"/> + </category> + <category name="D_BK_CA_DIAGCODE_EXTINFO" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_DIAGCODE_EXTINFO" id="0283" size="1"/> + </category> + <category name="D_BK_CA_DIAGCODE_TRIPCNT" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_DIAGCODE_TRIPCNT" id="0284" size="1"/> + </category> + <category name="D_BK_CA_PFDREC_FUNC" nand="false" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_PFDREC_FUNC" id="0285" size="1"/> + </category> + <category name="D_BK_CA_DIAGCODE_WORK_BUF" nand="false" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_DIAGCODE_WORK_BUF" id="0286" size="1"/> + </category> + <category name="D_BK_CA_AS__CWORD76_VOLUME" nand="true" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_AS__CWORD76_VOLUME" id="0287" size="1"/> + </category> + <category name="D_BK_CA_G_INFO" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_G_INFO" id="0288" size="1"/> + </category> + <category name="D_BK_CA_G_BM_S" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_G_BM_S" id="0289" size="1"/> + </category> + <category name="D_BK_CA_F_BR_HIS" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_F_BR_HIS" id="0290" size="1"/> + </category> + <category name="D_BK_CA_F_COOKIE" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_F_COOKIE" id="0291" size="1"/> + </category> + <category name="D_BK_CA_F_INFO" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_F_INFO" id="0292" size="1"/> + </category> + <category name="D_BK_CA_F_USE_INF" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_F_USE_INF" id="0293" size="1"/> + </category> + <category name="D_BK_CA_F_BM_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_F_BM_D" id="0294" size="1"/> + </category> + <category name="D_BK_CA_F_BM_S" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_F_BM_S" id="0295" size="1"/> + </category> + <category name="D_BK_CA_KEYBOARD_PARAMETER" nand="true" cacheDram="true" sync="false" backupCycle="60" encrypt="false"> + <item name="D_BK_ID_KEYBOARD_PARAMETER" id="0296" size="1"/> + </category> + <category name="D_BK_CA_AUDIOSETTING_PARAMETER" nand="true" cacheDram="true" sync="false" backupCycle="60" encrypt="false"> + <item name="D_BK_ID_AUDIOSETTING_PARAMETER" id="0297" size="1"/> + </category> + <category name="D_BK_CA_CONNECTIVITY_LASTAPP" nand="true" cacheDram="true" sync="false" backupCycle="60" encrypt="false"> + <item name="D_BK_ID_CONNECTIVITY_LASTAPP" id="0298" size="1"/> + </category> + <category name="D_BK_CA_RADIOAPP_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_RADIOAPP_PARAMETER" id="0299" size="1"/> + </category> + <category name="D_BK_CA_TOUCH" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_TOUCH_CONFIG" id="0300" size="1"/> + <item name="D_BK_ID_TOUCH_PARAMETER" id="0301" size="1"/> + </category> + <category name="D_BK_CA_CUSERVICE_DCMFLAG" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_CUSERVICE_DCMFLAG" id="0302" size="1"/> + </category> + <category name="D_BK_CA_CUSERVICE_SRVFLAG" nand="true" cacheDram="true" sync="false" backupCycle="60" encrypt="false"> + <item name="D_BK_ID_CUSERVICE_SRVFLAG" id="0303" size="1"/> + </category> + <category name="D_BK_CA_CUSERVICE_ACCON_CDF" nand="true" cacheDram="true" sync="false" backupCycle="60" encrypt="false"> + <item name="D_BK_ID_CUSERVICE_ACCON_CDF" id="0304" size="1"/> + </category> + <category name="D_BK_CA_CUSERVICE_SRVFLAG_CDF" nand="true" cacheDram="true" sync="false" backupCycle="60" encrypt="false"> + <item name="D_BK_ID_CUSERVICE_SRVFLAG_CDF" id="0305" size="1"/> + </category> + <category name="D_BK_CA_GRA_AMFMHD_CTRL" nand="false" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_NVM_ID_GRA_AMFMHD_STATION_LIST" id="0321" size="1"/> + <item name="D_BK_ID_NVM_ID_GRA_AMFMHD_STATION_LOGO" id="0322" size="1"/> + </category> + <category name="D_BK_CA_GRA_MSTR_CTRL" nand="true" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_NVM_ID_GRA_MSTR_LSM_DATA" id="0323" size="1"/> + <item name="D_BK_ID_NVM_ID_GRA_MSTR_SC_CONFIG_PARAMS" id="0324" size="1"/> + </category> + <category name="D_BK_CA_GRA_SDARS_CTRL" nand="true" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_NVM_ID_GRA_SDARS_STATION_LIST" id="0326" size="1"/> + <item name="D_BK_ID_NVM_ID_GRA_SDARS_CATEGORY_LIST" id="0327" size="1"/> + <item name="D_BK_ID_NVM_ID_GRA_SDARS_IMDB_URL_CHN_LOGO" id="0328" size="1"/> + <item name="D_BK_ID_NVM_ID_GRA_SDARS_SMS_CFG" id="0365" size="1"/> + <item name="D_BK_ID_NVM_ID_GRA_SDARS_RADIO_ID" id="0405" size="1"/> + <item name="D_BK_ID_NVM_ID_GRA_SDARS_SUBSCRIPTION_STATUS" id="0439" size="1"/> + </category> + <category name="D_BK_CA_DAB_TUN" nand="true" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_NVM_ID_DAB_LM_ENS" id="0329" size="1"/> + <item name="D_BK_ID_NVM_ID_DAB_LM_ENS_ORDER" id="0330" size="1"/> + <item name="D_BK_ID_NVM_ID_DAB_LM_SRVC" id="0331" size="1"/> + <item name="D_BK_ID_NVM_ID_DAB_LM_SRV_ORDER" id="0332" size="1"/> + <item name="D_BK_ID_NVM_ID_DAB_LM_CMP" id="0333" size="1"/> + <item name="D_BK_ID_NVM_ID_DAB_LM_COMP_ORDER" id="0334" size="1"/> + <item name="D_BK_ID_NVM_ID_DAB_LM_HARD_LINK" id="0335" size="1"/> + <item name="D_BK_ID_NVM_ID_DAB_LM_HARD_LINK_ORDER" id="0336" size="1"/> + <item name="D_BK_ID_NVM_ID_DAB_LM_LINK_INFO" id="0337" size="1"/> + <item name="D_BK_ID_NVM_ID_DAB_LM_LINK_INFO_ORDER" id="0338" size="1"/> + <item name="D_BK_ID_NVM_ID_DAB_TPEG_LIST" id="0339" size="1"/> + <item name="D_BK_ID_NVM_ID_DAB_TPEG_LIST_ORDER" id="0340" size="1"/> + <item name="D_BK_ID_NVM_ID_DAB_OE_FREQ" id="0341" size="1"/> + <item name="D_BK_ID_NVM_ID_DAB_OE_FREQ_ORDER" id="0342" size="1"/> + <item name="D_BK_ID_NVM_DAB_OE_EID" id="0343" size="1"/> + <item name="D_BK_ID_NVM_DAB_OE_EID_ORDER" id="0344" size="1"/> + <item name="D_BK_ID_NVM_ID_DAB_BEST_FM_LINK" id="0440" size="1"/> + <item name="D_BK_ID_NVM_ID_DAB_ERROR_COUNT" id="0441" size="1"/> + </category> + <category name="D_BK_CA_DBG_POSTMORTEM" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_NVM_ID_CPF_POSTMORTEM" id="0345" size="1"/> + </category> + <category name="D_BK_CA_DBG_FILTER_SET" nand="true" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_NVM_ID_DBG_FILTER_SET" id="0346" size="1"/> + </category> + <category name="D_BK_CA_DCM_CNCT_EN" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_DCM_CNCT_EN" id="0347" size="1"/> + </category> + <category name="D_BK_CA_PMG_CLK" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_PMG_CLK" id="0348" size="1"/> + </category> + <category name="D_BK_CA_PMG_CP" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_PMG_CP" id="0349" size="1"/> + </category> + <category name="D_BK_CA_PMG_LCTY" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_PMG_LCTY" id="0350" size="1"/> + </category> + <category name="D_BK_CA_PMG_LPOS" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_PMG_LPOS" id="0351" size="1"/> + </category> + <category name="D_BK_CA_PMG_SRCA" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_PMG_SRCA" id="0352" size="1"/> + </category> + <category name="D_BK_CA_MPTMNG_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_MPTMNG_D" id="0353" size="1"/> + </category> + <category name="D_BK_CA_MPTMNG_F" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_MPTMNG_F" id="0354" size="1"/> + </category> + <category name="D_BK_CA_POS_GPS_TEST_ROLLOVER_CNT" nand="false" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_POS_GPS_TEST_ROLLOVER_CNT" id="0355" size="1"/> + </category> + <category name="D_BK_CA_PAYD_ODO" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_PAYD_ODO" id="0358" size="1"/> + </category> + <category name="D_BK_CA_RS_RSDDS_STATS" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_RS_RSDDS_STATS" id="0359" size="1"/> + </category> + <category name="D_BK_CA_RS_UPDATE_DB_STATS" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_RS_UPDATE_DB_STATS" id="0360" size="1"/> + </category> + <category name="D_BK_CA_RS_WNG_HISTORY_LIST" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_RS_WNG_HISTORY_LIST" id="0361" size="1"/> + </category> + <category name="D_BK_CA_RS_WC_INFO" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_RS_WC_INFO" id="0362" size="1"/> + </category> + <category name="D_BK_CA_RS_VIDCM_DEPLOYMENT_INFO" nand="false" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_RS_VIDCM_DEPLOYMENT_INFO" id="0363" size="1"/> + </category> + <category name="D_BK_CA_RS_DEALER_INFO" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_RS_DEALER_INFO" id="0384" size="1"/> + </category> + <category name="D_BK_CA_SKN_J01" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J01" id="0388" size="1"/> + </category> + <category name="D_BK_CA_SKN_J02" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J02" id="0389" size="1"/> + </category> + <category name="D_BK_CA_SKN_J03" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J03" id="0390" size="1"/> + </category> + <category name="D_BK_CA_SKN_J04" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J04" id="0391" size="1"/> + </category> + <category name="D_BK_CA_SKN_J05" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J05" id="0392" size="1"/> + </category> + <category name="D_BK_CA_SKN_J06" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J06" id="0393" size="1"/> + </category> + <category name="D_BK_CA_SKN_J07" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J07" id="0394" size="1"/> + </category> + <category name="D_BK_CA_SKN_J08" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_SKN_J08" id="0395" size="1"/> + </category> + <category name="D_BK_CA_MODEMANAGER_LASTMODE" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_MODEMANAGER_LASTMODE" id="0396" size="1"/> + </category> + <category name="D_BK_CA_MODBPFSG" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_MODBPFSG" id="0397" size="1"/> + </category> + <category name="D_BK_CA_ASS_PARAMETER" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_ASS_PARAMETER" id="0406" size="1"/> + </category> + <category name="D_BK_CA_DPSSERVICE_ASPECTSET_N" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_DPSSERVICE_ASPECTSET_N" id="0407" size="1"/> + </category> + <category name="D_BK_CA_DPSSERVICE_ASPECTSET_D" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_DPSSERVICE_ASPECTSET_D" id="0408" size="1"/> + </category> + <category name="D_BK_CA_VR_SYNC_NAND" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_VR_INPUT_AUDIO_DUMP" id="0258" size="1"/> + <item name="D_BK_ID_VR_PVR_FLAG" id="0364" size="1"/> + </category> + <category name="D_BK_CA_CUSERVICE_MANAGEINFO" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_CUSERVICE_MANAGEINFO" id="0409" size="1"/> + </category> + <category name="D_BK_CA_PCSECBK" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_PCSECBK" id="0410" size="1"/> + </category> + <category name="D_BK_CA_HV_LRN_1" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_HV_LRN_1" id="0412" size="1"/> + </category> + <category name="D_BK_CA_HV_LRN_2" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_HV_LRN_2" id="0413" size="1"/> + </category> + <category name="D_BK_CA_HV_LRN_3" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_HV_LRN_3" id="0414" size="1"/> + </category> + <category name="D_BK_CA_HV_LRN_4" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_HV_LRN_4" id="0415" size="1"/> + </category> + <category name="D_BK_CA_HV_LRN_5" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_HV_LRN_5" id="0416" size="1"/> + </category> + <category name="D_BK_CA_HV_HISORY" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_HV_HISORY" id="0417" size="1"/> + </category> + <category name="D_BK_CA_REPROS_MAPUPDATE_PARAM" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_REPROS_MAPUPDATE_STATUS" id="0418" size="1"/> + </category> + <category name="D_BK_CA_VS_FUCSRV__CWORD66__SYNC" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_VS_FUCSRV__CWORD66__SYNC_GRP" id="0419" size="1"/> + </category> + <category name="D_BK_CA_HMI_PNS1" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_HMI_PNS1" id="0421" size="1"/> + </category> + <category name="D_BK_CA_HMI_PNS2" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_HMI_PNS2" id="0422" size="1"/> + </category> + <category name="D_BK_CA_HMI_USER" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_HMI_USER" id="0423" size="1"/> + </category> + <category name="D_BK_CA_PMG_SMAP" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_PMG_SMAP" id="0424" size="1"/> + </category> + <category name="D_BK_CA_LPT1_F" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LPT1_F" id="0425" size="1"/> + </category> + <category name="D_BK_CA_LPT2_F" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LPT2_F" id="0426" size="1"/> + </category> + <category name="D_BK_CA_LPT3_F" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LPT3_F" id="0427" size="1"/> + </category> + <category name="D_BK_CA_LPT4_F" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LPT4_F" id="0428" size="1"/> + </category> + <category name="D_BK_CA_LPT5_F" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_LPT5_F" id="0429" size="1"/> + </category> + <category name="D_BK_CA_MUDINFO" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_MUDINFO" id="0430" size="1"/> + </category> + <category name="D_BK_CA_CTRRTSRV" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_CTRRTSRV" id="0431" size="1"/> + </category> + <category name="D_BK_CA_VDU_MNG" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_VDU_MNG" id="0432" size="1"/> + </category> + <category name="D_BK_CA_VDU_ICON" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_VDU_ICON" id="0433" size="1"/> + </category> + <category name="D_BK_CA_DIAG_DEVICEINFO" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_DIAG_DEVICEINFO" id="0434" size="1"/> + </category> + <category name="D_BK_CA_BT_PAIRING" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_BT_PAIRING" id="0435" size="1"/> + </category> + <category name="D_BK_CA_POS_GPS_SET_TIME" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_POS_GPS_SET_TIME" id="0436" size="1"/> + </category> + <category name="D_BK_CA_DTSERVICE_WRITE_AT_SHUT_DOWN" nand="true" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_DTSERVICE_FORECAST" id="0221" size="1"/> + <item name="D_BK_ID_DTSERVICE_COORDINATE" id="0223" size="1"/> + <item name="D_BK_ID_DTSERVICE_AFLIST" id="0224" size="1"/> + <item name="D_BK_ID_DTSERVICE_DOPPLER" id="0225" size="1"/> + </category> + <category name="D_BK_CA_DTSERVICE_WRITE_AT_IMMIEDIATELY" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_DTSERVICE_CITYDB" id="0220" size="1"/> + <item name="D_BK_ID_DTSERVICE_SETUP" id="0222" size="1"/> + <item name="D_BK_ID_DTSERVICE_WEATHER_HISTORY" id="0226" size="1"/> + </category> + <category name="D_BK_CA_TCS_LEARN_DICTIONARY" nand="true" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_TCS_LEARN_DICTIONARY" id="437" size="1"/> + <item name="D_BK_ID_TCS_WNN_LEARN_DICTIONARY" id="438" size="1"/> + </category> + <category name="D_BK_CA_POS_GPS_TIME_SET_INFO" nand="false" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_POS_GPS_TIME_SET_INFO" id="0442" size="1"/> + </category> + <category name="D_BK_CA_POS_GPS_TIME_SET_FLAG" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_POS_GPS_TIME_SET_FLAG" id="0443" size="1"/> + </category> + <category name="D_BK_CA_GRA_MSTR_CTRL_IMM" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_LIST" id="0325" size="1"/> + <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_USER1_LIST" id="0366" size="1"/> + <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_USER2_LIST" id="0367" size="1"/> + <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_USER3_LIST" id="0368" size="1"/> + <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_USER4_LIST" id="0369" size="1"/> + <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_USER5_LIST" id="0370" size="1"/> + </category> + <category name="D_BK_CA_CON_CWORD57__INFO" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_CON_CWORD57__INFO" id="0445" size="1"/> + </category> + <category name="D_BK_CA_HELP_DATA" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_HELP_DATA" id="0446" size="1"/> + </category> + <category name="D_BK_CA__CWORD76__INFO_DRAM" nand="false" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID__CWORD76__INFO_DRAM_OFFSET" id="0447" size="1"/> + </category> + <category name="D_BK_CA_VS_METSRV_PARAMETER" nand="false" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_VS_METSRV_PARAMETER" id="0448" size="1"/> + </category> + <category name="D_BK_CA_DIAGCODE_MASK" nand="false" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_DIAGCODE_MASK" id="0449" size="1"/> + </category> + <category name="D_BK_CA_NAVIPROXY" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_NAVIPROXY" id="0450" size="1"/> + </category> + <category name="D_BK_CA_AWBPROXY" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_AWBPROXY" id="0451" size="1"/> + </category> + <category name="D_BK_CA_VS_CMRSRV_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_VS_CMRSRV_PARAMETER" id="0452" size="1"/> + </category> + <category name="D_BK_CA_DWR_DWRM" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_DWR_DWRM" id="0453" size="1"/> + </category> + <category name="D_BK_CA_MUDINIT" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_MUDINIT" id="0454" size="1"/> + </category> + <category name="D_BK_CA__CWORD27__USER_DATA" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID__CWORD27__SETTING" id="0457" size="1"/> + </category> + <category name="D_BK_CA__CWORD27__SHARED_RAM" nand="false" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID__CWORD27__CONNECTION_MODE" id="0456" size="1"/> + </category> + <category name="D_BK_CA_DTI_ETCC" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false"> + <item name="D_BK_ID_DTI_ETCC" id="0458" size="1"/> + </category> + <category name="D_BK_CA_BT_MANAGEMENT" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_BT_POWER" id="0459" size="1"/> + <item name="D_BK_ID_BT_PINCODE" id="0460" size="1"/> + <item name="D_BK_ID_BT_NAME" id="0461" size="1"/> + <item name="D_BK_ID_BT_DEFAULT_NAME" id="0462" size="1"/> + <item name="D_BK_ID_BT_ADDRESS" id="0463" size="1"/> + <item name="D_BK_ID_BT_AUTOMATIC_CONNECTION" id="0464" size="1"/> + <item name="D_BK_ID_BT_PREFERRED_SETTING" id="0465" size="1"/> + <item name="D_BK_ID_BT_PHONE_DISPLAY_STATE" id="0466" size="1"/> + <item name="D_BK_ID_BT_AUDIOPLAYER_DISPLAY_STATE" id="0467" size="1"/> + <item name="D_BK_ID_BT_PROFILE_AVAILABLE" id="0468" size="1"/> + <item name="D_BK_ID_BT_DCM_PHONE" id="0469" size="1"/> + </category> + <category name="D_BK_CA_EOMSERVICE_LOCALSTORAGE" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_EOMSERVICE_LOCALSTORAGE" id="0470" size="1"/> + </category> + <category name="D_BK_CA_DOA_EXISTENCE" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_DOA_EXISTENCE" id="0471" size="1"/> + </category> + <category name="D_BK_CA_INFS_VOICE_INTERRUPT_SETTING" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_INFS_VOICE_INTERRUPT_SETTING" id="0472" size="1"/> + </category> + <category name="D_BK_CA_DIAGCODE_ODOMETER" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_DIAGCODE_ODOMETER" id="0473" size="1"/> + </category> + <category name="D_BK_CA_DIAGCODE_DIAGMODE" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_DIAGCODE_DIAGMODE" id="0474" size="1"/> + </category> + <category name="D_BK_CA_VS_FUCSRV__CWORD66__ASYNC" nand="true" backupDram="true" sync="false" backupCycle="60" encrypt="false"> + <item name="D_BK_ID_VS_FUCSRV__CWORD66__ASYNC_GRP" id="0475" size="1"/> + </category> + <category name="D_BK_CA_VS_FUCSRV__CWORD66__1TRIP_ASYNC" nand="true" backupDram="true" sync="false" backupCycle="60" encrypt="false"> + <item name="D_BK_ID_VS_FUCSRV__CWORD66__1TRIP_ASYNC_GRP" id="0476" size="1"/> + </category> + <category name="D_BK_CA__CWORD28_AUTO_SHARED_RAM" nand="false" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID__CWORD28_AUTO_CONNECTION_MODE" id="0477" size="1"/> + </category> + <category name="D_BK_CA__CWORD28_AUTO_USER_DATA" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID__CWORD28_AUTO_SETTING" id="0478" size="1"/> + </category> + <category name="D_BK_CA__CWORD24_" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID__CWORD24_" id="0479" size="1"/> + </category> +</backup> diff --git a/backup_manager/config/conf/backup/backup.xml b/backup_manager/config/conf/backup/backup.xml new file mode 100644 index 00000000..68e1d685 --- /dev/null +++ b/backup_manager/config/conf/backup/backup.xml @@ -0,0 +1,278 @@ +<?xml version="1.0" encoding="UTF-8"?> +<backup> + <category name="D_BK_CA_VEHICLE_NAND" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_VEHICLE_STABLE_DATA" id="0227" size="16"/> + </category> + <category name="D_BK_CA_VEHICLE_DRAM" nand="false" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_VEHICLE_DRAMBKUP_DATA" id="0228" size="16"/> + </category> + <category name="D_BK_CA_DUMMYREAD_OFFSET" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_DUMMYREAD_OFFSET" id="0229" size="512"/> + </category> + <category name="D_BK_CA_DPSSERVICE_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_DPSSERVICE_PARAMETER" id="0230" size="4096"/> + </category> + <category name="D_BK_CA_MEDSRV_RESUME" nand="false" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_MEDSRV_MMCOM_RESUME" id="0231" size="53280"/> + <item name="D_BK_ID_MEDSRV_ITGP_RESUME" id="0274" size="1024"/> + <item name="D_BK_ID_MEDSRV_DISC_RESUME" id="0275" size="1024"/> + <item name="D_BK_ID_MEDSRV__CWORD57__RESUME" id="0276" size="10656"/> + <item name="D_BK_ID_MEDSRV_BTA_RESUME" id="0277" size="1024"/> + <item name="D_BK_ID_MEDSRV_SDVCOM_RESUME" id="0444" size="256"/> + </category> + <category name="D_BK_CA_REPROS_UPDATEPARAM" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_REPROS_UPDATEPARAM" id="0232" size="32"/> + <item name="D_BK_ID_REPROS_AUTO_UPDATE_CHECK" id="0372" size="1"/> + <item name="D_BK_ID_REPROS_NA03OUT_DLID" id="0373" size="4"/> + <item name="D_BK_ID_REPROS_RESUME_TIME" id="0375" size="6"/> + <item name="D_BK_ID_REPROS_NA03OUT_PCGVER" id="0376" size="4"/> + <item name="D_BK_ID_REPROS_NA03OUT_UPDATE_TIMING" id="0377" size="2"/> + <item name="D_BK_ID_REPROS_NA03OUT_UPDATE_TIMEOUT" id="0378" size="2"/> + <item name="D_BK_ID_REPROS_NA03OUT_DLURL" id="0380" size="2048"/> + <item name="D_BK_ID_REPROS_NA03OUT_UPDATE_INFO" id="0381" size="8192"/> + <item name="D_BK_ID_REPROS_CENTERCOMM_STATE" id="0382" size="1"/> + <item name="D_BK_ID_REPROS_NA07_HISTORY_INFO" id="0385" size="169192"/> + <item name="D_BK_ID_REPROS_NA05_DOWNLOAD_SIZE" id="0387" size="8"/> + <item name="D_BK_ID_REPROS_FILE_PATH_INFO" id="0399" size="1024"/> + <item name="D_BK_ID_REPROS_UPDATE_FILE_EXIST" id="0401" size="4"/> + <item name="D_BK_ID_REPROS_CHECKFORUPDATE_TIME" id="0404" size="4"/> + </category> + <category name="D_BK_CA_REPROS_UPDATEHISTORY" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_REPROS_UPDATEHISTORY" id="0233" size="4096"/> + </category> + <category name="D_BK_CA_REPROS_UPDATEINFO" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_REPROS_UPDATEINFO" id="0234" size="33792"/> + </category> + <category name="D_BK_CA_CLOCK" nand="false" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_CLOCK_OFFSET" id="0240" size="16"/> + <item name="D_BK_ID_CLOCK_STATE" id="0241" size="4"/> + </category> + <category name="D_BK_CA__CWORD76__INFO_SYNC" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID__CWORD76__INFO_SYNC_OFFSET" id="0242" size="256"/> + </category> + <category name="D_BK_CA_DIAG_INFORMATION" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_DIAG_INFORMATION" id="0244" size="2048"/> + </category> + <category name="D_BK_CA_DIAG_UTILIZATION" nand="true" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_DIAG_UTILIZATION" id="0245" size="515072"/> + </category> + <category name="D_BK_CA_VS_VSDSRV_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_VS_VSDSRV_PARAMETER" id="0246" size="2048"/> + </category> + <category name="D_BK_CA_VS_ACNSRV_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_VS_ACNSRV_PARAMETER" id="0247" size="256"/> + </category> + <category name="D_BK_CA_VS_FUCSRV_ASYNC" nand="true" backupDram="true" sync="false" backupCycle="15" encrypt="false"> + <item name="D_BK_ID_VS_FUCSRV_ASYNC_GRP" id="0248" size="1024"/> + </category> + <category name="D_BK_CA_VS_FUCSRV_SYNC" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_VS_FUCSRV_SYNC_GRP" id="0249" size="1024"/> + </category> + <category name="D_BK_CA_VINFOSRV_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_VINFOSRV_PARAMETER" id="0250" size="256"/> + </category> + <category name="D_BK_CA_POS_GPS_FIX_CNT" nand="true" cacheDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_POS_GPS_FIX_CNT" id="0251" size="16"/> + </category> + <category name="D_BK_CA_POS_GPS_ROLLOVER_CNT" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_POS_GPS_ROLLOVER_CNT" id="0253" size="32"/> + </category> + <category name="D_BK_CA_WLANM_INFO" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_WLANM_INFO" id="0254" size="1024"/> + </category> + <category name="D_BK_CA_BTSTK_LINKKEY" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_BTSTK_LINKKEY" id="0255" size="20480"/> + </category> + <category name="D_BK_CA_UPDSERVICE_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_UPDSERVICE_PARAMETER" id="0257" size="4096"/> + </category> + <category name="D_BK_CA_RS_WNG_RCV" nand="false" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_RS_WNG_RCV" id="0259" size="1"/> + </category> + <category name="D_BK_CA_INFS_GENERAL_GRP" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_INFS_GENERAL_GRP" id="0260" size="128"/> + </category> + <category name="D_BK_CA_INFS_CLOCK_GRP" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_INFS_CLOCK_GRP" id="0262" size="128"/> + </category> + <category name="D_BK_CA_INFS_HOME_GRP" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_INFS_HOME_GRP" id="0263" size="128"/> + </category> + <category name="D_BK_CA_INFS_VOICE_GRP" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_INFS_VOICE_GRP" id="0264" size="128"/> + </category> + <category name="D_BK_CA_INFS_VOICE_INTERRUPT_VOL" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_INFS_VOICE_INTERRUPT_VOL" id="0265" size="64"/> + </category> + <category name="D_BK_CA_INFS_MENU_GRP" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_INFS_MENU_GRP" id="0266" size="384"/> + </category> + <category name="D_BK_CA_INFS_METERCOOP_GRP" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_INFS_METERCOOP_GRP" id="0269" size="128"/> + </category> + <category name="D_BK_CA_INFS_SMARTAGENT_GRP" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_INFS_SMARTAGENT_GRP" id="0273" size="128"/> + </category> + <category name="D_BK_CA_MEDSRV_SETTING" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_MEDSRV_DISC_SETTING" id="0279" size="1024"/> + <item name="D_BK_ID_MEDSRV_COM_SETTING" id="420" size="32"/> + </category> + <category name="D_BK_CA_GNDB_UPDATE_HISTORY" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_GNDB_UPDATE_HISTORY" id="0281" size="400"/> + </category> + <category name="D_BK_CA_DIAGCODE_MEM" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_DIAGCODE_MEM" id="0282" size="441000"/> + </category> + <category name="D_BK_CA_DIAGCODE_EXTINFO" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_DIAGCODE_EXTINFO" id="0283" size="32"/> + </category> + <category name="D_BK_CA_DIAGCODE_TRIPCNT" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_DIAGCODE_TRIPCNT" id="0284" size="16"/> + </category> + <category name="D_BK_CA_PFDREC_FUNC" nand="false" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_PFDREC_FUNC" id="0285" size="16"/> + </category> + <category name="D_BK_CA_DIAGCODE_WORK_BUF" nand="false" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_DIAGCODE_WORK_BUF" id="0286" size="495000"/> + </category> + <category name="D_BK_CA_AS__CWORD76_VOLUME" nand="true" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_AS__CWORD76_VOLUME" id="0287" size="200"/> + </category> + <category name="D_BK_CA_KEYBOARD_PARAMETER" nand="true" cacheDram="true" sync="false" backupCycle="60" encrypt="false"> + <item name="D_BK_ID_KEYBOARD_PARAMETER" id="0296" size="8"/> + </category> + <category name="D_BK_CA_TOUCH" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_TOUCH_CONFIG" id="0300" size="32"/> + <item name="D_BK_ID_TOUCH_PARAMETER" id="0301" size="4"/> + </category> + <category name="D_BK_CA_CUSERVICE_DCMFLAG" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_CUSERVICE_DCMFLAG" id="0302" size="8"/> + </category> + <category name="D_BK_CA_CUSERVICE_SRVFLAG" nand="true" cacheDram="true" sync="false" backupCycle="60" encrypt="false"> + <item name="D_BK_ID_CUSERVICE_SRVFLAG" id="0303" size="2048"/> + </category> + <category name="D_BK_CA_CUSERVICE_ACCON_CDF" nand="true" cacheDram="true" sync="false" backupCycle="60" encrypt="false"> + <item name="D_BK_ID_CUSERVICE_ACCON_CDF" id="0304" size="2048"/> + </category> + <category name="D_BK_CA_CUSERVICE_SRVFLAG_CDF" nand="true" cacheDram="true" sync="false" backupCycle="60" encrypt="false"> + <item name="D_BK_ID_CUSERVICE_SRVFLAG_CDF" id="0305" size="2048"/> + </category> + <category name="D_BK_CA_GRA_AMFMHD_CTRL" nand="false" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_NVM_ID_GRA_AMFMHD_STATION_LIST" id="0321" size="13168"/> + </category> + <category name="D_BK_CA_GRA_MSTR_CTRL" nand="true" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_NVM_ID_GRA_MSTR_LSM_DATA" id="0323" size="2048"/> + <item name="D_BK_ID_NVM_ID_GRA_MSTR_SC_CONFIG_PARAMS" id="0324" size="64"/> + </category> + <category name="D_BK_CA_GRA_SDARS_CTRL" nand="true" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_NVM_ID_GRA_SDARS_STATION_LIST" id="0326" size="45056"/> + <item name="D_BK_ID_NVM_ID_GRA_SDARS_CATEGORY_LIST" id="0327" size="7168"/> + <item name="D_BK_ID_NVM_ID_GRA_SDARS_SMS_CFG" id="0365" size="65536"/> + <item name="D_BK_ID_NVM_ID_GRA_SDARS_RADIO_ID" id="0405" size="16"/> + <item name="D_BK_ID_NVM_ID_GRA_SDARS_SUBSCRIPTION_STATUS" id="0439" size="8"/> + </category> + <category name="D_BK_CA_DBG_FILTER_SET" nand="true" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_NVM_ID_DBG_FILTER_SET" id="0346" size="240"/> + </category> + <category name="D_BK_CA_DCM_CNCT_EN" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_DCM_CNCT_EN" id="0347" size="4"/> + </category> + <category name="D_BK_CA_RS_RSDDS_STATS" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_RS_RSDDS_STATS" id="0359" size="1"/> + </category> + <category name="D_BK_CA_RS_UPDATE_DB_STATS" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_RS_UPDATE_DB_STATS" id="0360" size="1"/> + </category> + <category name="D_BK_CA_RS_WNG_HISTORY_LIST" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_RS_WNG_HISTORY_LIST" id="0361" size="2804"/> + </category> + <category name="D_BK_CA_RS_WC_INFO" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_RS_WC_INFO" id="0362" size="400"/> + </category> + <category name="D_BK_CA_RS_VIDCM_DEPLOYMENT_INFO" nand="false" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_RS_VIDCM_DEPLOYMENT_INFO" id="0363" size="1"/> + </category> + <category name="D_BK_CA_RS_DEALER_INFO" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_RS_DEALER_INFO" id="0384" size="712"/> + </category> + <category name="D_BK_CA_MODEMANAGER_LASTMODE" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_MODEMANAGER_LASTMODE" id="0396" size="512"/> + </category> + <category name="D_BK_CA_ASS_PARAMETER" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_ASS_PARAMETER" id="0406" size="26384"/> + </category> + <category name="D_BK_CA_DPSSERVICE_ASPECTSET_N" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_DPSSERVICE_ASPECTSET_N" id="0407" size="16"/> + </category> + <category name="D_BK_CA_DPSSERVICE_ASPECTSET_D" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_DPSSERVICE_ASPECTSET_D" id="0408" size="8"/> + </category> + <category name="D_BK_CA_VR_SYNC_NAND" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_VR_INPUT_AUDIO_DUMP" id="0258" size="4"/> + <item name="D_BK_ID_VR_PVR_FLAG" id="0364" size="4"/> + </category> + <category name="D_BK_CA_CUSERVICE_MANAGEINFO" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_CUSERVICE_MANAGEINFO" id="0409" size="128"/> + </category> + <category name="D_BK_CA_DIAG_DEVICEINFO" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_DIAG_DEVICEINFO" id="0434" size="10240"/> + </category> + <category name="D_BK_CA_BT_PAIRING" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_BT_PAIRING" id="0435" size="102400"/> + </category> + <category name="D_BK_CA_DTSERVICE_WRITE_AT_SHUT_DOWN" nand="true" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_DTSERVICE_FORECAST" id="0221" size="153600"/> + <item name="D_BK_ID_DTSERVICE_COORDINATE" id="0223" size="128"/> + <item name="D_BK_ID_DTSERVICE_AFLIST" id="0224" size="1024"/> + <item name="D_BK_ID_DTSERVICE_DOPPLER" id="0225" size="73728"/> + </category> + <category name="D_BK_CA_DTSERVICE_WRITE_AT_IMMIEDIATELY" nand="true" cacheDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_DTSERVICE_CITYDB" id="0220" size="113664"/> + <item name="D_BK_ID_DTSERVICE_SETUP" id="0222" size="64"/> + <item name="D_BK_ID_DTSERVICE_WEATHER_HISTORY" id="0226" size="1024"/> + </category> + <category name="D_BK_CA_TCS_LEARN_DICTIONARY" nand="true" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_TCS_LEARN_DICTIONARY" id="437" size="2097152"/> + </category> + <category name="D_BK_CA_POS_GPS_TIME_SET_INFO" nand="false" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_POS_GPS_TIME_SET_INFO" id="0442" size="8"/> + </category> + <category name="D_BK_CA_POS_GPS_TIME_SET_FLAG" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_POS_GPS_TIME_SET_FLAG" id="0443" size="4"/> + </category> + <category name="D_BK_CA_GRA_MSTR_CTRL_IMM" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_LIST" id="0325" size="22896"/> + <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_USER1_LIST" id="0366" size="10240"/> + <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_USER2_LIST" id="0367" size="10240"/> + <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_USER3_LIST" id="0368" size="10240"/> + <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_USER4_LIST" id="0369" size="10240"/> + <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_USER5_LIST" id="0370" size="10240"/> + </category> + <category name="D_BK_CA_CON_CWORD57__INFO" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_CON_CWORD57__INFO" id="0445" size="256"/> + </category> + <category name="D_BK_CA__CWORD76__INFO_DRAM" nand="false" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID__CWORD76__INFO_DRAM_OFFSET" id="0447" size="256"/> + </category> + <category name="D_BK_CA_VS_METSRV_PARAMETER" nand="false" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_VS_METSRV_PARAMETER" id="0448" size="128"/> + </category> + <category name="D_BK_CA_DIAGCODE_MASK" nand="false" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID_DIAGCODE_MASK" id="0449" size="4"/> + </category> + <category name="D_BK_CA__CWORD27__USER_DATA" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID__CWORD27__SETTING" id="0457" size="1024"/> + </category> + <category name="D_BK_CA__CWORD27__SHARED_RAM" nand="false" backupDram="true" sync="false" encrypt="false"> + <item name="D_BK_ID__CWORD27__CONNECTION_MODE" id="0456" size="1024"/> + </category> + <category name="D_BK_CA_INFS_VOICE_INTERRUPT_SETTING" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_INFS_VOICE_INTERRUPT_SETTING" id="0472" size="64"/> + </category> + <category name="D_BK_CA_DIAGCODE_ODOMETER" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_DIAGCODE_ODOMETER" id="0473" size="8"/> + </category> + <category name="D_BK_CA_DIAGCODE_DIAGMODE" nand="true" backupDram="true" sync="true" encrypt="false"> + <item name="D_BK_ID_DIAGCODE_DIAGMODE" id="0474" size="4"/> + </category> +</backup> diff --git a/backup_manager/config/createhdr.pl b/backup_manager/config/createhdr.pl new file mode 100755 index 00000000..73102d71 --- /dev/null +++ b/backup_manager/config/createhdr.pl @@ -0,0 +1,84 @@ +#!/usr/bin/perl +use strict; +use warnings; + +sub getlist($$) +{ + my $xmlfile = shift(@_); + my $xpath = shift(@_); + + $xmlfile =~ s/([\[\]\*\(\)])/\\$1/g; + + open(my $rs, "xmllint --xpath \"$xpath\" $xmlfile |") or die "Cannot open $xmlfile:$!"; + my $result = join('', <$rs>); + close $rs; + $result =~ s/^ +//; + my @result_array = split(/ +/, $result); + return @result_array; +} + +if ($#ARGV < 0 || !(-f $ARGV[0])) { + print "No such file or directory.\n"; + exit 1; +} + +my @item_array = getlist($ARGV[0], '//item/@name'); + +print<<'HEADER'; +/* + * @copyright Copyright (c) 2017-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file ns_backup_id.h + * @brief backup id define + */ + +#ifndef BACKUP_MANAGER_CONFIG_NS_BACKUP_ID_H_ +#define BACKUP_MANAGER_CONFIG_NS_BACKUP_ID_H_ + +/** @addtogroup BaseSystem + * @{ + */ +/** @addtogroup native_service + * @ingroup BaseSystem + * @{ + */ +/** @addtogroup backup_manager + * @ingroup native_service + * @{ + */ + +HEADER + +foreach my $item (@item_array) { + if ($item =~ /^name="(.+)"$/) { + printf("#define %s \"%s\"\n", $1, $1); + } + else { + print "Invalid input:$item\n"; + exit 1; + } +} + +print<<'FOOTER'; + +/**@}*/ // end of backup_manager +/**@}*/ // end of native_service +/**@}*/ // end of BaseSystem + +#endif // BACKUP_MANAGER_CONFIG_NS_BACKUP_ID_H_ +FOOTER + +0; diff --git a/backup_manager/config/sample.xml b/backup_manager/config/sample.xml new file mode 100644 index 00000000..cbf6c7ae --- /dev/null +++ b/backup_manager/config/sample.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<backup> + <category name="NandUnsync" nand="true" cacheDram="true" sync="false"> + <item name="NandUnsync_001" id="1000" size="4491"/> + <item name="NandUnsync_002" id="1001" size="18752"/> + </category> + <category name="NandCycle" nand="true" cacheDram="true" sync="false" backupCycle="30"> + <item name="NandCycle_001" id="2000" size="32231"/> + <item name="NandCycle_002" id="2001" size="8353"/> + </category> + <category name="NandSync" nand="true" cacheDram="false" sync="true"> + <item name="NandSync_001" id="3000" size="25120"/> + <item name="NandSync_002" id="3001" size="18187"/> + </category> + <category name="BackupOnly" backupDram="true"> + <item name="BackupOnly_001" id="4000" size="657"/> + <item name="BackupOnly_002" id="4001" size="526"/> + </category> + <category name="CacheOnly" cacheDram="true"> + <item name="CacheOnly_001" id="5000" size="8694"/> + <item name="CacheOnly_002" id="5001" size="2051"/> + </category> +</backup> diff --git a/backup_manager/config/uniqcheck.pl b/backup_manager/config/uniqcheck.pl new file mode 100755 index 00000000..1470d7c8 --- /dev/null +++ b/backup_manager/config/uniqcheck.pl @@ -0,0 +1,46 @@ +#!/usr/bin/perl +use strict; +use warnings; + +my @checkxpath = ('//item/@name', '//item/@id', '//category/@name'); + +sub uniqcheck($$) +{ + my $xpath = shift(@_); + my $list = shift(@_); + my %u = (); + foreach my $key (@{$list}) { + if (exists($u{$key})) { + print "detect duplicate $xpath $key\n"; + exit 1; + } + $u{$key} = 1; + } +} + +sub getlist($$) +{ + my $xmlfile = shift(@_); + my $xpath = shift(@_); + + $xmlfile =~ s/([\[\]\*\(\)])/\\$1/g; + + open(my $rs, "xmllint --xpath \"$xpath\" $xmlfile |") or die "Cannot open $xmlfile:$!"; + my $result = join('', <$rs>); + close $rs; + $result =~ s/^ +//; + my @result_array = split(/ +/, $result); + return @result_array; +} + +if ($#ARGV < 0 || !(-f $ARGV[0])) { + print "No such file or directory.\n"; + exit 1; +} + +foreach my $xpath (@checkxpath) { + my @result_array = getlist($ARGV[0], $xpath); + uniqcheck($xpath, \@result_array); +} + +0; diff --git a/backup_manager/server/Makefile b/backup_manager/server/Makefile new file mode 100644 index 00000000..9293d7c0 --- /dev/null +++ b/backup_manager/server/Makefile @@ -0,0 +1,61 @@ +# +# @copyright Copyright (c) 2017-2019 TOYOTA MOTOR CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +######### programs to be installed ############# +INST_PROGS := NS_BackupMgr + +######### sources to be compiled ############# +NS_BackupMgr_SRCS := backupmanager_main.cpp \ + bkup_process.cpp \ + bkup_param.cpp \ + bkup_crc32.cpp \ + backupmanager_application.cpp + +######### search paths ############# +VPATH += ./src ./include ../client/include/$(COMPONENT_NAME) + +######### include paths ############# +CPPFLAGS += -I./include +CPPFLAGS += -I../client/include +CPPFLAGS += -I$(SDKTARGETSYSROOT)/usr/include/libxml2 + +######### frameworkunifiedlog options ############# +CPPFLAGS += -DFRAMEWORKUNIFIEDLOGOPTIONS=0x08 -DFRAMEWORKUNIFIEDLOGAPPZONES=31,30,29,28,27,26,9,8,3 + +LDFLAGS += -Wl,--no-as-needed +LDFLAGS += -Wl,--no-undefined + +######### libraries to be linked(dynamic)############# +LDLIBS += -Wl,-Bdynamic \ + -lSS_SystemIfUnified \ + -lNS_FrameworkUnified \ + -lxml2 \ + -lrt \ +# -lnv_hal + +######### other unit specific options ############# +LINK_CXX=Y + +CPPFLAGS += -Werror=implicit-function-declaration +CPPFLAGS += -Werror=format-security + +CPPFLAGS += -Wconversion +CPPFLAGS += -Wint-to-pointer-cast +CPPFLAGS += -Wpointer-arith +CPPFLAGS += -Wformat +CPPFLAGS += -DIMPL_AGL_APPLICATION_CALLBACKS_PRE_BACKGROUND + +include ../../native_service.mk diff --git a/backup_manager/server/include/bkup_backupmanagerlog.h b/backup_manager/server/include/bkup_backupmanagerlog.h new file mode 100644 index 00000000..74a11a78 --- /dev/null +++ b/backup_manager/server/include/bkup_backupmanagerlog.h @@ -0,0 +1,80 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef BACKUP_MANAGER_SERVER_INCLUDE_BKUP_BACKUPMANAGERLOG_H_ +#define BACKUP_MANAGER_SERVER_INCLUDE_BKUP_BACKUPMANAGERLOG_H_ + +#include <native_service/ns_logger_if.h> + +#define ZONE_INIT ZONEMASK(10) +#define ZONE_FUNC ZONEMASK(11) +#define ZONE_MEM ZONEMASK(12) +#define ZONE_APP ZONEMASK(13) +#define ZONE_14 ZONEMASK(14) +#define ZONE_15 ZONEMASK(15) +#define ZONE_16 ZONEMASK(16) +#define ZONE_17 ZONEMASK(17) +#define ZONE_18 ZONEMASK(18) +#define ZONE_19 ZONEMASK(19) +#define ZONE_20 ZONEMASK(20) +#define ZONE_21 ZONEMASK(21) +#define ZONE_22 ZONEMASK(22) +#define ZONE_23 ZONEMASK(23) +#define ZONE_24 ZONEMASK(24) +#define ZONE_25 ZONEMASK(25) +#define ZONE_26 ZONEMASK(26) +#define ZONE_27 ZONEMASK(27) +#define ZONE_28 ZONEMASK(28) +#define ZONE_INFO ZONEMASK(29) +#define ZONE_WARN ZONEMASK(30) +#define ZONE_ERR ZONEMASK(31) +#define ZONE_ALSA ZONEMASK(103) + +#define ZONE_TEXT_10 "Init" +#define ZONE_TEXT_11 "Function" +#define ZONE_TEXT_12 "Memory" +#define ZONE_TEXT_13 "StateMachine Example" +#define ZONE_TEXT_14 "" +#define ZONE_TEXT_15 "" +#define ZONE_TEXT_16 "" +#define ZONE_TEXT_17 "" +#define ZONE_TEXT_18 "" +#define ZONE_TEXT_19 "" +#define ZONE_TEXT_20 "" +#define ZONE_TEXT_21 "" +#define ZONE_TEXT_22 "" +#define ZONE_TEXT_23 "" +#define ZONE_TEXT_24 "" +#define ZONE_TEXT_25 "" +#define ZONE_TEXT_26 "" +#define ZONE_TEXT_27 "" +#define ZONE_TEXT_28 "" +#define ZONE_TEXT_29 "Info" +#define ZONE_TEXT_30 "Warning" +#define ZONE_TEXT_31 "Error" +#define ZONE_TEXT_103 "Api" + +#ifndef FRAMEWORKUNIFIEDLOGOPTIONS +#define FRAMEWORKUNIFIEDLOGOPTIONS (LPRINT) // LPRINT , LMSGQ, LSLOGGER +#endif + +#ifndef FRAMEWORKUNIFIEDLOGAPPZONES +#define FRAMEWORKUNIFIEDLOGAPPZONES ZONE_APP, ZONE_ERR, ZONE_WARN, ZONE_INFO, ZONE_ALSA +#endif + +extern const CHAR kAppName[]; + +#endif // BACKUP_MANAGER_SERVER_INCLUDE_BKUP_BACKUPMANAGERLOG_H_ diff --git a/backup_manager/server/include/bkup_crc32.h b/backup_manager/server/include/bkup_crc32.h new file mode 100644 index 00000000..1d3c25bb --- /dev/null +++ b/backup_manager/server/include/bkup_crc32.h @@ -0,0 +1,22 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef BACKUP_MANAGER_SERVER_INCLUDE_BKUP_CRC32_H_ +#define BACKUP_MANAGER_SERVER_INCLUDE_BKUP_CRC32_H_ + +uint32_t BkupCrc32(const void *data, size_t length); + +#endif // BACKUP_MANAGER_SERVER_INCLUDE_BKUP_CRC32_H_ diff --git a/backup_manager/server/include/bkup_param.h b/backup_manager/server/include/bkup_param.h new file mode 100644 index 00000000..e23ba47a --- /dev/null +++ b/backup_manager/server/include/bkup_param.h @@ -0,0 +1,39 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef BACKUP_MANAGER_SERVER_INCLUDE_BKUP_PARAM_H_ +#define BACKUP_MANAGER_SERVER_INCLUDE_BKUP_PARAM_H_ + +typedef struct { + int id; + int size; + void *opt; + bool nand; + bool cache_dram; + bool backup_dram; + bool sync; + bool encrypt; + int backup_cycle; + char category_name[64]; +} bkup_query_result_t; + +int BckupParamInit(void); + +int BkupParamGet(const char *item_name, bkup_query_result_t *result); +int BkupParamGetNumid(uint32_t num_id, bkup_query_result_t *result, char *item_name, size_t item_name_size); +void *BkupParamSetOpt(const char *item_name, void *opt); + +#endif // BACKUP_MANAGER_SERVER_INCLUDE_BKUP_PARAM_H_ diff --git a/backup_manager/server/include/bkup_process.h b/backup_manager/server/include/bkup_process.h new file mode 100644 index 00000000..cf28c55f --- /dev/null +++ b/backup_manager/server/include/bkup_process.h @@ -0,0 +1,31 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef BACKUP_MANAGER_SERVER_INCLUDE_BKUP_PROCESS_H_ +#define BACKUP_MANAGER_SERVER_INCLUDE_BKUP_PROCESS_H_ + +#include <native_service/frameworkunified_types.h> + +EFrameworkunifiedStatus BkupHandler(HANDLE h_app); + +EFrameworkunifiedStatus bkup_power_handler(HANDLE hApp); +EFrameworkunifiedStatus BkupInitHandler(HANDLE h_app); +EFrameworkunifiedStatus BkupTerminateHandler(HANDLE h_app); + +void *BkupNandThread(void *arg); +void *BkupDelayThread(void *arg); + +#endif // BACKUP_MANAGER_SERVER_INCLUDE_BKUP_PROCESS_H_ diff --git a/backup_manager/server/include/bkup_util.h b/backup_manager/server/include/bkup_util.h new file mode 100644 index 00000000..0352b143 --- /dev/null +++ b/backup_manager/server/include/bkup_util.h @@ -0,0 +1,48 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef BACKUP_MANAGER_SERVER_INCLUDE_BKUP_UTIL_H_ +#define BACKUP_MANAGER_SERVER_INCLUDE_BKUP_UTIL_H_ + +#include <sys/mman.h> +#include <ctime> +#include <cstring> + +static inline size_t BkupStrlcpy(char *dst, const char *src, size_t siz) { + size_t ret = strlen(src); + + if (siz) { // LCOV_EXCL_BR_LINE 6:double check + size_t len = (ret >= siz) ? siz - 1 : ret; // LCOV_EXCL_BR_LINE 11:unexpected branch + memcpy(dst, src, len); + dst[len] = '\0'; + } + return ret; +} + +static inline char *BkupAnonMmap(size_t size) { + char *map = static_cast<char *>(mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0)); + return map; +} + +static inline uint64_t BkupTimerReal(void) { + struct timespec ts; + if (clock_gettime(CLOCK_MONOTONIC_RAW, &ts) != -1) { // LCOV_EXCL_BR_LINE 5:clock_gettime's error case. + return (uint64_t)ts.tv_sec * 1000000000 + ts.tv_nsec; + } + return -1; +} + +#endif // BACKUP_MANAGER_SERVER_INCLUDE_BKUP_UTIL_H_ diff --git a/backup_manager/server/src/backupmanager_application.cpp b/backup_manager/server/src/backupmanager_application.cpp new file mode 100644 index 00000000..0e9a6352 --- /dev/null +++ b/backup_manager/server/src/backupmanager_application.cpp @@ -0,0 +1,276 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <native_service/ns_backup.h> +#include <agl_thread.h> +#include <system_service/ss_system_if.h> +#include <system_service/ss_system_manager_notifications.h> +#include <native_service/frameworkunified_multithreading.h> + +//#include <nv_hal.h> +#include <signal.h> +#include <cerrno> +#include <cstdio> +#include "bkup_api.h" +#include "bkup_param.h" +#include "bkup_backupmanagerlog.h" +#include "bkup_process.h" + +pthread_t g_work_thread_id = 0; +pthread_t g_delay_thread_id = 0; +pthread_t g_nand_thread_id = 0; +HANDLE g_msg_handle_thread = NULL; + +typedef void (* signal_handler)(int); + +void SignalHandlerFuncForMsgHandleThread(int signum) { + pthread_exit(0); +} + +EFrameworkunifiedStatus MsgHandleThreadStart(HANDLE h_app) { + signal_handler p_signal = SignalHandlerFuncForMsgHandleThread; + signal(SIGUSR1, p_signal); + + g_work_thread_id = pthread_self(); + + EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK; + // LCOV_EXCL_BR_START 4: NSFW error case + if ((e_status = FrameworkunifiedAttachCallbackToDispatcher(h_app, FRAMEWORKUNIFIED_ANY_SOURCE, BACKUP_CID, BkupHandler)) != eFrameworkunifiedStatusOK) { + // LCOV_EXCL_BR_STOP 4: NSFW error case + // LCOV_EXCL_START 4: NSFW error case + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedAttachCallbacksToDispatcher e_status:%d\n", e_status); + exit(EXIT_FAILURE); + // LCOV_EXCL_STOP 4: NSFW error case + } + + return e_status; +} + +EFrameworkunifiedStatus MsgHandleThreadStop(HANDLE h_app) { + EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK; + return e_status; +} + +EFrameworkunifiedStatus FrameworkunifiedOnInitialization(HANDLE h_app) { + EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK; + pthread_attr_t t_attr; + pthread_t t; + + // LCOV_EXCL_BR_START 4: NSFW error case + if ((e_status = FrameworkunifiedRegisterServiceAvailabilityNotification(h_app, NTFY_BackupMgr_Availability)) != eFrameworkunifiedStatusOK) { + // LCOV_EXCL_BR_STOP 4: NSFW error case + // LCOV_EXCL_START 4: NSFW error case + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedRegisterServiceAvailabilityNotification e_status:%d\n", e_status); + exit(EXIT_FAILURE); + // LCOV_EXCL_STOP 4: NSFW error case + } + + if (pthread_attr_init(&t_attr) < 0) { // LCOV_EXCL_BR_LINE 5:pthread_attr_init's error case. + // LCOV_EXCL_START 5:pthread_attr_init's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "pthread_attr_init:%s", strerror(errno)); + exit(EXIT_FAILURE); + // LCOV_EXCL_STOP 5:pthread_attr_init's error case. + } + + // LCOV_EXCL_BR_START 5:pthread_attr_setinheritsched's error case. + if (pthread_attr_setinheritsched(&t_attr, PTHREAD_INHERIT_SCHED) < 0) { + // LCOV_EXCL_BR_STOP 5:pthread_attr_setinheritsched's error case. + // LCOV_EXCL_START 5:pthread_attr_setinheritsched's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "pthread_attr_setinheritsched:%s", strerror(errno)); + exit(EXIT_FAILURE); + // LCOV_EXCL_STOP 5:pthread_attr_setinheritsched's error case. + } + + if (pthread_create(&t, &t_attr, BkupNandThread, NULL) < 0) { // LCOV_EXCL_BR_LINE 5:pthread_create's error case. + // LCOV_EXCL_START 5:pthread_create's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "pthread_create:%s", strerror(errno)); + exit(EXIT_FAILURE); + // LCOV_EXCL_STOP 5:pthread_create's error case. + } + + if (pthread_create(&t, &t_attr, BkupDelayThread, NULL) < 0) { // LCOV_EXCL_BR_LINE 5:pthread_create's error case. + // LCOV_EXCL_START 5:pthread_create's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "pthread_create:%s", strerror(errno)); + exit(EXIT_FAILURE); + // LCOV_EXCL_STOP 5:pthread_create's error case. + } + +// if ((e_status = InitNv()) != eFrameworkunifiedStatusOK) { +// FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "InitNv e_status:%d", e_status); +// exit(EXIT_FAILURE); +// } + + if (BckupParamInit() < 0) { // LCOV_EXCL_BR_LINE 5:C API's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + exit(EXIT_FAILURE); // LCOV_EXCL_LINE 5:C API's error case. + } + + // LCOV_EXCL_BR_START 4: NSFW error case + if ((e_status = FrameworkunifiedAttachCallbackToDispatcher(h_app, FRAMEWORKUNIFIED_ANY_SOURCE, BACKUP_CID, BkupHandler)) != eFrameworkunifiedStatusOK) { + // LCOV_EXCL_BR_STOP 4: NSFW error case + // LCOV_EXCL_START 4: NSFW error case + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedAttachCallbacksToDispatcher e_status:%d\n", e_status); + exit(EXIT_FAILURE); + // LCOV_EXCL_STOP 4: NSFW error case + } + + + g_msg_handle_thread = FrameworkunifiedCreateChildThread(h_app, SERVICE_BACKUP_MANAGER_MSG_HANDLE_THREAD, MsgHandleThreadStart, MsgHandleThreadStop); // LCOV_EXCL_BR_LINE 11:Unexpected branch // NOLINT (whitespace/line_length) + if (g_msg_handle_thread == NULL) { // LCOV_EXCL_BR_LINE 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + // LCOV_EXCL_START 4: NSFW error case. + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, + "Fail to create SERVICE_BACKUP_MANAGER_MSG_HANDLE_THREAD"); + // LCOV_EXCL_STOP 4: NSFW error case. + } else { + if (eFrameworkunifiedStatusOK != (e_status = FrameworkunifiedStartChildThread(h_app, g_msg_handle_thread, 0, NULL))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT (whitespace/line_length) + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Fail to Start SERVICE_BACKUP_MANAGER_MSG_HANDLE_THREAD. Status:%#x", e_status); // LCOV_EXCL_LINE 4: NSFW error case. // NOLINT (whitespace/line_length) + } + } + + // LCOV_EXCL_BR_START 4: NSFW error case + if ((e_status = FrameworkunifiedSubscribeNotificationWithCallback(h_app, + NTFY_SSSystemMgrPowerOnOff, + bkup_power_handler)) != eFrameworkunifiedStatusOK) { + // LCOV_EXCL_BR_STOP 4: NSFW error case + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedSubscribeNotificationWithCallback eStatus:%d", e_status); // LCOV_EXCL_LINE 4: NSFW error case. // NOLINT (whitespace/line_length) + } + + e_status = BkupInitHandler(h_app); // LCOV_EXCL_BR_LINE 11:unexpected branch + + // LCOV_EXCL_BR_START 4: NSFW error case + if ((e_status = FrameworkunifiedPublishServiceAvailability(h_app, TRUE)) != eFrameworkunifiedStatusOK) { + // LCOV_EXCL_BR_STOP 4: NSFW error case + // LCOV_EXCL_START 4: NSFW error case + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedPublishServiceAvailability e_status:%d\n", e_status); + exit(EXIT_FAILURE); + // LCOV_EXCL_STOP 4: NSFW error case + } + + return e_status; +} + +// LCOV_EXCL_START 14 Resident process, not called by NSFW +EFrameworkunifiedStatus FrameworkunifiedOnDestroy(HANDLE h_app) { + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "called"); + return eFrameworkunifiedStatusOK; +} +// LCOV_EXCL_STOP 14 Resident process, not called by NSFW + +EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE h_app) { + // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "called"); + // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h" + return eFrameworkunifiedStatusOK; +} + +EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE h_app) { + EFrameworkunifiedStatus e_status = BkupTerminateHandler(h_app); + + if (FrameworkunifiedPublishServiceAvailability(h_app, FALSE) != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: NSFW error case + // LCOV_EXCL_START 15:marco defined in "native_service/ns_logger_if.h" + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedPublishServiceAvailability fail\n"); + // LCOV_EXCL_STOP 15:marco defined in "native_service/ns_logger_if.h" + } + + // LCOV_EXCL_BR_START 4: NSFW error case + if (eFrameworkunifiedStatusOK == (FrameworkunifiedStopChildThread(h_app, g_msg_handle_thread, 0, NULL))) { + // LCOV_EXCL_BR_STOP 4: NSFW error case + FrameworkunifiedDestroyChildThread(h_app, g_msg_handle_thread); + g_msg_handle_thread = NULL; + } + + int ret2 = pthread_kill(g_work_thread_id, SIGUSR1); + if (ESRCH == ret2) { + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, + "thread is already exit !"); + } else if (EINVAL == ret2) { + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, + "signal is invalid !"); + } else { + pthread_join(g_work_thread_id, NULL); + } + + ret2 = pthread_kill(g_nand_thread_id, SIGUSR1); + if (ESRCH == ret2) { + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, + "thread is already exit !"); + } else if (EINVAL == ret2) { + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, + "signal is invalid !"); + } else { + pthread_join(g_nand_thread_id, NULL); + } + + ret2 = pthread_kill(g_delay_thread_id, SIGUSR1); + if (ESRCH == ret2) { + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, + "thread is already exit !"); + } else if (EINVAL == ret2) { + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, + "signal is invalid !"); + } else { + pthread_join(g_delay_thread_id, NULL); + } + + return e_status; +} + +EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE hApp) { + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "called"); + return eFrameworkunifiedStatusOK; +} + +EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE hApp) { + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "called"); + return eFrameworkunifiedStatusOK; +} + +EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE hApp) { + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "called"); + return eFrameworkunifiedStatusOK; +} + +EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE hApp) { + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "called"); + return eFrameworkunifiedStatusOK; +} + +EFrameworkunifiedStatus FrameworkunifiedOnDebugDump(HANDLE h_app) { // LCOV_EXCL_START 7:debug code + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "called"); + return eFrameworkunifiedStatusOK; +} +// LCOV_EXCL_STOP 7:debug code + +EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE h_app) { // LCOV_EXCL_START 7:debug code + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "called"); + return eFrameworkunifiedStatusOK; +} +// LCOV_EXCL_STOP 7:debug code diff --git a/backup_manager/server/src/backupmanager_main.cpp b/backup_manager/server/src/backupmanager_main.cpp new file mode 100644 index 00000000..9ad6e602 --- /dev/null +++ b/backup_manager/server/src/backupmanager_main.cpp @@ -0,0 +1,61 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <native_service/ns_version_if.h> +#include <native_service/frameworkunified_dispatcher.h> +#include <agl_thread.h> +#include <system_service/ss_system_if.h> +#include <cerrno> +#include <cstdio> +#include "bkup_backupmanagerlog.h" + +CFrameworkunifiedVersion g_FrameworkunifiedVersion(0, 0, 0); // NOLINT(readability/nolint). + +FRAMEWORKUNIFIEDLOGPARAM g_FrameworkunifiedLogParams = { // NOLINT(readability/nolint) The varable is used by FW + FRAMEWORKUNIFIEDLOGOPTIONS, + { + ZONE_TEXT_10, ZONE_TEXT_11, ZONE_TEXT_12, + ZONE_TEXT_13, ZONE_TEXT_14, ZONE_TEXT_15, + ZONE_TEXT_16, ZONE_TEXT_17, ZONE_TEXT_18, + ZONE_TEXT_19, ZONE_TEXT_20, ZONE_TEXT_21, + ZONE_TEXT_22, ZONE_TEXT_23, ZONE_TEXT_24, + ZONE_TEXT_25, ZONE_TEXT_26, ZONE_TEXT_27, + ZONE_TEXT_28, ZONE_TEXT_29, ZONE_TEXT_30, + ZONE_TEXT_31 + }, + FRAMEWORKUNIFIEDLOGZONES +}; + +int main(int argc, char *argv[]) { + // LCOV_EXCL_BR_START 11:unexpected branch + FrameworkunifiedDefaultCallbackHandler cb_funcs; + FRAMEWORKUNIFIED_MAKE_DEFAULT_CALLBACK(cb_funcs); + FRAMEWORKUNIFIED_SET_ZONES(); + // LCOV_EXCL_BR_STOP 11:unexpected branch + + // LCOV_EXCL_BR_START 11:unexpected branch + EFrameworkunifiedStatus e_status = FrameworkunifiedDispatcherWithArguments(MN_NS_BACKUPMGR, argc, argv, &cb_funcs); + // LCOV_EXCL_BR_STOP 11:unexpected branch + if (e_status != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: NSFW error case + // LCOV_EXCL_START 4: NSFW error case + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedDispatcherWithArguments: %d", e_status); + return EXIT_FAILURE; + // LCOV_EXCL_STOP 4: NSFW error case + } + + return EXIT_SUCCESS; +} // LCOV_EXCL_BR_LINE 10:The final line diff --git a/backup_manager/server/src/bkup_crc32.cpp b/backup_manager/server/src/bkup_crc32.cpp new file mode 100644 index 00000000..f460b44e --- /dev/null +++ b/backup_manager/server/src/bkup_crc32.cpp @@ -0,0 +1,59 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <cstdio> +#include "bkup_crc32.h" +#include "bkup_util.h" + +/* + * CRC-32C lookup table + * + * Polynomial 0x1EDC6F41 + */ +static const uint32_t kBkupCrc32Lookup[4][256] = { + { + }, + { + }, + { + }, + { + } +}; + +/** + * compute CRC-32C (Slicing-by-4) + */ +uint32_t BkupCrc32(const void *data, size_t length) { + uint32_t crc = 0xFFFFFFFF; + const uint32_t *current = (const uint32_t *)data; + + while (length >= 4) { + uint32_t one = *current++ ^ crc; + crc = kBkupCrc32Lookup[0][(one >> 24) & 0xFF] ^ + kBkupCrc32Lookup[1][(one >> 16) & 0xFF] ^ + kBkupCrc32Lookup[2][(one >> 8) & 0xFF] ^ + kBkupCrc32Lookup[3][one & 0xFF]; + length -= 4; + } + + const uint8_t *current_char = (const uint8_t *)current; + while (length-- > 0) { + crc = (crc >> 8) ^ kBkupCrc32Lookup[0][(crc & 0xFF) ^ *current_char++]; + } + + return ~crc; +} diff --git a/backup_manager/server/src/bkup_param.cpp b/backup_manager/server/src/bkup_param.cpp new file mode 100644 index 00000000..5e44b3dc --- /dev/null +++ b/backup_manager/server/src/bkup_param.cpp @@ -0,0 +1,352 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <fcntl.h> +#include <sys/mman.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <stdlib.h> +#include <unistd.h> +#include <libxml/xmlerror.h> +#include <libxml/parser.h> +#include <libxml/SAX2.h> +#include <inttypes.h> +#include <cerrno> +#include <cstdio> +#include <string> +#include <map> +#include <utility> +#include "bkup_param.h" +#include "bkup_backupmanagerlog.h" +#include "bkup_util.h" + +#define BKUP_XML_PATH "/usr/agl/conf/backup_manager/backup.xml" + +typedef std::string Category; +typedef struct { + bool nand; + bool cache_dram; + bool backup_dram; + bool sync; + bool encrypt; + int backup_cycle; +} CategoryProperty; +typedef std::map<Category, CategoryProperty> CategoryTable; + +typedef std::string Item; +typedef struct { + int id; + int size; + void *opt; + Category category; +} ItemProperty; // LCOV_EXCL_BR_LINE 11:except,C++ STL +typedef std::map<Item, ItemProperty> ItemTable; +typedef std::map<int, Item> IdTable; + +typedef struct { + Category current; + CategoryTable category_table; + ItemTable item_table; + IdTable id_table; +} BackupParams; // LCOV_EXCL_BR_LINE 11:except,C++ STL + +static BackupParams *g_backup_params = NULL; + +static void StartElementNs(void *ctx, const xmlChar *localname, + const xmlChar *prefix, const xmlChar *uri, + int nb_namespaces, const xmlChar **namespaces, + int nb_attributes, int nb_defaulted, + const xmlChar **attributes) { + BackupParams *p_backup_params = static_cast<BackupParams *>(ctx); + std::string tag = (const char *)localname; // LCOV_EXCL_BR_LINE 11:except,C++ STL + + if (tag.compare("backup") == 0) { // LCOV_EXCL_BR_LINE 11:except,C++ STL + // do nothing + } else if (tag.compare("category") == 0) { // LCOV_EXCL_BR_LINE 11:except,C++ STL + CategoryProperty category_property = {false, false, false, false, false, 0}; + std::string category_name; // LCOV_EXCL_BR_LINE 11:except,C++ STL + + for (int i = 0; i < nb_attributes; i++) { + // LCOV_EXCL_BR_START 11:except,C++ STL + std::string localname = (const char *)attributes[i * 5]; + std::string value((const char *)attributes[i * 5 + 3], (const char *)attributes[i * 5 + 4]); + if (localname.compare("name") == 0) { + category_name = value; + } else if (localname.compare("nand") == 0) { + if (value.compare("true") == 0) { + category_property.nand = true; + } + } else if (localname.compare("backupDram") == 0) { + if (value.compare("true") == 0) { + category_property.backup_dram = true; + } + } else if (localname.compare("cacheDram") == 0) { + if (value.compare("true") == 0) { + category_property.cache_dram = true; + } + } else if (localname.compare("sync") == 0) { + if (value.compare("true") == 0) { + category_property.sync = true; + } + } else if (localname.compare("encrypt") == 0) { + if (value.compare("true") == 0) { + category_property.encrypt = true; + } + } else if (localname.compare("backupCycle") == 0) { + category_property.backup_cycle = atoi(value.c_str()); + // LCOV_EXCL_BR_STOP 11:except,C++ STL + } else { + // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" + FRAMEWORKUNIFIEDLOG(ZONE_WARN, __func__, "Unknown attribute:%s", localname.c_str()); + // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h" + } + } + + // LCOV_EXCL_BR_START 11:except,C++ STL + CategoryTable::iterator c_it = p_backup_params->category_table.find(category_name); + // LCOV_EXCL_BR_STOP 11:except,C++ STL + if (c_it != p_backup_params->category_table.end()) { // LCOV_EXCL_BR_LINE 11:except,C++ STL + // LCOV_EXCL_START 200:Execute in server start period + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "duplicate category:%s", category_name.c_str()); + exit(EXIT_FAILURE); + // LCOV_EXCL_STOP 200:Execute in server start period + } + // LCOV_EXCL_BR_START 11:except,C++ STL + p_backup_params->category_table.insert(std::make_pair(category_name, category_property)); + // LCOV_EXCL_BR_STOP 11:except,C++ STL + p_backup_params->current = category_name; // LCOV_EXCL_BR_LINE 11:except,C++ STL + } else if (tag.compare("item") == 0) { // LCOV_EXCL_BR_LINE 11:except,C++ STL + if (p_backup_params->current.compare("") == 0) { // LCOV_EXCL_BR_LINE 11:except,C++ STL + // LCOV_EXCL_START 200:Execute in server start period + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Detect item before category"); + exit(EXIT_FAILURE); + // LCOV_EXCL_STOP 200:Execute in server start period + } + + ItemProperty item_property = {0, 0, NULL, p_backup_params->current}; // LCOV_EXCL_BR_LINE 11:except,C++ STL + std::string item_name; // LCOV_EXCL_BR_LINE 11:except,C++ STL + + for (int i = 0; i < nb_attributes; i++) { + // LCOV_EXCL_BR_START 11:except,C++ STL + std::string localname = (const char *)attributes[i * 5]; + std::string value((const char *)attributes[i * 5 + 3], (const char *)attributes[i * 5 + 4]); + if (localname.compare("name") == 0) { + item_name = value; + } else if (localname.compare("id") == 0) { + item_property.id = atoi(value.c_str()); + } else if (localname.compare("size") == 0) { + item_property.size = atoi(value.c_str()); + // LCOV_EXCL_BR_STOP 11:except,C++ STL + } else { + // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" + FRAMEWORKUNIFIEDLOG(ZONE_WARN, __func__, "Unknown attribute:%s", localname.c_str()); + // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h" + } + } + + ItemTable::iterator i_it = p_backup_params->item_table.find(item_name); // LCOV_EXCL_BR_LINE 11:except,C++ STL + if (i_it != p_backup_params->item_table.end()) { // LCOV_EXCL_BR_LINE 11:except,C++ STL + // LCOV_EXCL_START 200:Execute in server start period + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Duplicate item:%s", item_name.c_str()); + exit(EXIT_FAILURE); + // LCOV_EXCL_STOP 200:Execute in server start period + } + // LCOV_EXCL_BR_START 11:except,C++ STL + p_backup_params->item_table.insert(std::make_pair(item_name, item_property)); + // LCOV_EXCL_BR_STOP 11:except,C++ STL + + IdTable::iterator id_it = p_backup_params->id_table.find(item_property.id); // LCOV_EXCL_BR_LINE 11:except,C++ STL + if (id_it != p_backup_params->id_table.end()) { // LCOV_EXCL_BR_LINE 11:except,C++ STL + // LCOV_EXCL_START 200:Execute in server start period + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Duplicate id:%d", item_property.id); + exit(EXIT_FAILURE); + // LCOV_EXCL_STOP 200:Execute in server start period + } + // LCOV_EXCL_BR_START 11:except,C++ STL + p_backup_params->id_table.insert(std::make_pair(item_property.id, item_name)); + // LCOV_EXCL_BR_STOP 11:except,C++ STL + } else { + // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" + FRAMEWORKUNIFIEDLOG(ZONE_WARN, __func__, "Unknown tag:%s", localname); + // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h" + } +} + +int BckupParamInit(void) { + int ret = -1; + xmlParserCtxtPtr xmlctx; + xmlSAXHandler saxh; + xmlDocPtr doc; + int fd = -1; + struct stat sb; + char *map = NULL; + uint64_t start, end; + + g_backup_params = new BackupParams; // LCOV_EXCL_BR_LINE 11:except,C++ operator + + LIBXML_TEST_VERSION // LCOV_EXCL_BR_LINE 11:unexpected branch + // LCOV_EXCL_BR_START 11:unexpected branch + xmlInitParser(); // NOLINT(readability/nolint) Defined in library of libxml + // LCOV_EXCL_BR_STOP 11:unexpected branch + + memset(&saxh, 0, sizeof(saxh)); + saxh.initialized = XML_SAX2_MAGIC; + saxh.startElementNs = StartElementNs; + + xmlctx = xmlCreatePushParserCtxt(&saxh, g_backup_params, NULL, 0, NULL); // LCOV_EXCL_BR_LINE 11:unexpected branch + + if ((fd = open(BKUP_XML_PATH, O_RDONLY)) < 0) { // LCOV_EXCL_BR_LINE 5:open's error case. + // LCOV_EXCL_START 5:open's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "open:%s", strerror(errno)); + goto exit; + // LCOV_EXCL_STOP 5:open's error case. + } + if (fstat(fd, &sb) < 0) { // LCOV_EXCL_BR_LINE 5:fstat's error case. + // LCOV_EXCL_START 5:fstat's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "fstat:%s", strerror(errno)); + goto exit; + // LCOV_EXCL_STOP 5:fstat's error case. + } + map = reinterpret_cast<char *>(mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0)); + if (map == MAP_FAILED) { // LCOV_EXCL_BR_LINE 5:mmap's error case. + // LCOV_EXCL_START 5:mmap's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mmap:%s", strerror(errno)); + goto exit; + // LCOV_EXCL_STOP 5:mmap's error case. + } + + start = BkupTimerReal(); + if (xmlParseChunk(xmlctx, map, static_cast<int>(sb.st_size), 1)) { // LCOV_EXCL_BR_LINE 5:xmlParseChunk's error case. + // LCOV_EXCL_START 5:xmlParseChunk's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + xmlParserError(xmlctx, "xmlParseChunk"); + goto exit; + // LCOV_EXCL_STOP 5:xmlParseChunk's error case. + } + end = BkupTimerReal(); + // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "spent:%" PRIu64 ".%06" PRIu64 "ms", + static_cast<uint64_t>((end - start) / 1000000), + static_cast<uint64_t>((end - start) % 1000000)); + // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h" + + doc = xmlctx->myDoc; + xmlFreeParserCtxt(xmlctx); // LCOV_EXCL_BR_LINE 11:unexpected branch + xmlFreeDoc(doc); // LCOV_EXCL_BR_LINE 11:unexpected branch + xmlCleanupParser(); // LCOV_EXCL_BR_LINE 11:unexpected branch + ret = 0; + +exit: + if (fd >= 0) { // LCOV_EXCL_BR_LINE 5:open's error case. + if (close(fd) < 0) { // LCOV_EXCL_BR_LINE 5:close's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, "close:%s", strerror(errno)); // LCOV_EXCL_LINE 5:close's error case. + } + } + if (map) { // LCOV_EXCL_BR_LINE 5:mmap's error case. + if (munmap(map, sb.st_size) < 0) { // LCOV_EXCL_BR_LINE 5:munmap's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, "munmap:%s", strerror(errno)); // LCOV_EXCL_LINE 5:munmap's error case. + } + } + return ret; +} + +int BkupParamGet(const char *item_name, bkup_query_result_t *result) { + if (g_backup_params == NULL) { // LCOV_EXCL_BR_LINE 6:g_backup_params will not be NULL + // LCOV_EXCL_START 6:g_backup_params will not be NULL + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Uninitialize call"); + return -1; + // LCOV_EXCL_STOP 6:g_backup_params will not be NULL + } + + ItemTable::iterator item_it = g_backup_params->item_table.find(item_name); // LCOV_EXCL_BR_LINE 11:except,C++ STL + if (item_it == g_backup_params->item_table.end()) { // LCOV_EXCL_BR_LINE 11:except,C++ STL + return -1; + } + + // LCOV_EXCL_BR_START 11:except,C++ STL + CategoryTable::iterator category_it = g_backup_params->category_table.find(item_it->second.category); + // LCOV_EXCL_BR_STOP 11:except,C++ STL + if (category_it == g_backup_params->category_table.end()) { // LCOV_EXCL_BR_LINE 6:double check + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + return -1; // LCOV_EXCL_LINE 6:double check + } + + // LCOV_EXCL_BR_START 11:except,C++ STL + result->id = item_it->second.id; + result->size = item_it->second.size; + result->opt = item_it->second.opt; + result->nand = category_it->second.nand; + result->cache_dram = category_it->second.cache_dram; + result->backup_dram = category_it->second.backup_dram; + result->sync = category_it->second.sync; + result->encrypt = category_it->second.encrypt; + result->backup_cycle = category_it->second.backup_cycle; + BkupStrlcpy(result->category_name, item_it->second.category.c_str(), sizeof(result->category_name)); + // LCOV_EXCL_BR_STOP 11:except,C++ STL + + return 0; +} + +int BkupParamGetNumid(uint32_t num_id, bkup_query_result_t *result, + char *item_name, size_t item_name_size) { + if (g_backup_params == NULL) { // LCOV_EXCL_BR_LINE 6:g_backup_params will not be NULL + // LCOV_EXCL_START 6:g_backup_params will not be NULL + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Uninitialize call"); + return -1; + // LCOV_EXCL_STOP 6:g_backup_params will not be NULL + } + + // LCOV_EXCL_BR_START 11:except,C++ STL + IdTable::iterator id_it = g_backup_params->id_table.find(static_cast<int>(num_id)); + // LCOV_EXCL_BR_STOP 11:except,C++ STL + if (id_it == g_backup_params->id_table.end()) { // LCOV_EXCL_BR_LINE 11:except,C++ STL + return -1; + } + BkupStrlcpy(item_name, id_it->second.c_str(), item_name_size); // LCOV_EXCL_BR_LINE 11:except,C++ STL + + return BkupParamGet(id_it->second.c_str(), result); // LCOV_EXCL_BR_LINE 11:except,C++ STL +} + +void *BkupParamSetOpt(const char *item_name, void *opt) { + if (g_backup_params == NULL) { // LCOV_EXCL_BR_LINE 6:g_backup_params will not be NULL + // LCOV_EXCL_START 6:g_backup_params will not be NULL + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Uninitialize call"); + return reinterpret_cast<void *>((-1)); + // LCOV_EXCL_STOP 6:g_backup_params will not be NULL + } + + ItemTable::iterator item_it = g_backup_params->item_table.find(item_name); // LCOV_EXCL_BR_LINE 11:except,C++ STL + if (item_it == g_backup_params->item_table.end()) { // LCOV_EXCL_BR_LINE 6:double check + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + return reinterpret_cast<void *>((-1)); // LCOV_EXCL_LINE 6:double check + } + + // LCOV_EXCL_BR_START 11:unexpected branch + return __sync_val_compare_and_swap(&item_it->second.opt, NULL, opt); // NOLINT(readability/nolint) Supplied by gcc + // LCOV_EXCL_BR_STOP 11:unexpected branch +} diff --git a/backup_manager/server/src/bkup_process.cpp b/backup_manager/server/src/bkup_process.cpp new file mode 100644 index 00000000..0f132acb --- /dev/null +++ b/backup_manager/server/src/bkup_process.cpp @@ -0,0 +1,2441 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <dirent.h> +#include <fcntl.h> +#include <libgen.h> +#include <inttypes.h> +#include <mqueue.h> +#include <agl_thread.h> +#include <poll.h> +#include <signal.h> +#include <sys/epoll.h> +#include <sys/eventfd.h> +#include <sys/prctl.h> +#include <sys/stat.h> +#include <sys/syscall.h> +#include <sys/timerfd.h> +#include <sys/types.h> +#include <unistd.h> +#include <native_service/frameworkunified_framework_if.h> +#include <system_service/ss_system_manager_if.h> +//#include <nv_hal.h> +#include <aglpath.h> +#include <cerrno> +#include <cstdio> +#include <map> +#include <set> +#include <string> +#include <utility> +#include "bkup_api.h" +#include "bkup_backupmanagerlog.h" +#include "bkup_param.h" +#include "bkup_crc32.h" +#include "bkup_util.h" + +#define BKUP_THREAD_NAND "NS_BkupNAND" +#define BKUP_THREAD_DELAY "NS_BkupDelay" +const char kBkupPrexixEncryption[] = "ENC_"; +const size_t kBkupPrexixEncryptionSize = 4; + +typedef void (* signal_handler)(int); +extern void SignalHandlerFuncForMsgHandleThread(int signum); +extern pthread_t g_delay_thread_id; +extern pthread_t g_nand_thread_id; + +#define MAX_FD_EPOLL 8 + +/** + * internal state + */ +typedef enum { + BKUP_STATE_INIT = 0, + BKUP_STATE_NORMAL, + BKUP_STATE_TERM, +} bkup_state_t; +static bkup_state_t g_bkup_internal_state = BKUP_STATE_INIT; + + +/** + * delay thread command + */ +typedef enum { + BKUP_DELAY_CMD_TERM = 0, + BKUP_DELAY_CMD_PRE_ACCOFF, + BKUP_DELAY_CMD_REGIST, +} bkup_delay_cmd_t; + + +/** + * inter thread communication message + */ +typedef union { + struct { + char client_name[16]; + uint32_t seq_id; + char *rcv_buf; + int rcv_size; + } nand; + struct { + +// bool terminate; + bkup_delay_cmd_t cmd; + + int event_fd; + char item_name[64]; + } delay; +} bkup_itc_message_t; + +/** + * reference response function + */ +typedef struct { + int (*set_response)(void *, void *, int, EFrameworkunifiedStatus); + void *opt; +} bkup_response_t; + +/** + * response MQ map(TLS) + */ +typedef std::map<std::string, HANDLE> g_bkup_response_mq_t; +static __thread g_bkup_response_mq_t *g_bkup_response_mq; + +/** + * NAND thread itc MQ + */ +static mqd_t g_bkup_nand_mqd = -1; + +/** + * Delay thread itc MQ + */ +static mqd_t g_bkup_delay_mqd = -1; + +static int g_bkup_nand_tid; +static int g_bkup_delay_tid; + +/** + * prototype declared + */ +//static void BkupApilog(bkup_response_t *response, enum NvHalMedia current_media, +static void BkupApilog(bkup_response_t *response, + bkup_protocol_header_t *hdr, + bkup_query_result_t *query_result, char *buf, + uint32_t crc32, EFrameworkunifiedStatus ret_value); + +/** + * check status of file spicefied by path + */ +//static int BkupCheckStatFromNv(enum NvHalMedia media, const char *path, +static int BkupCheckStatFromNv(const char *path, + int check_size); + +/** + * rwlock unlock + */ +static inline void BkupRwlockUnlock(pthread_rwlock_t *rwlock, const char *path); + +/** + * rwlock read lock + */ +static inline void BkupRwlockRdlock(pthread_rwlock_t *rwlock, const char *path); + +/** + * rwlock write lock + */ +static inline void BkupRwlockWrlock(pthread_rwlock_t *rwlock, const char *path); + +/**\ingroup CheckNv + * \~english @par Brief + * Check the data stored on the storage device and check the data size. + * \~english @param [in] media + * enum NvHalMedia - Media type + * \~english @param [in] filename + * const char* - Concatenated string of "category name/item name" + * \~english @param [in] size + * uint32_t - Data size to be checked + * \~english @retval eFrameworkunifiedStatusOK OK + * \~english @retval eFrameworkunifiedStatusFileLoadError The file does not exist. + * \~english @retval eFrameworkunifiedStatusAccessError Check size failed + * \~english @retval eFrameworkunifiedStatusInvldParam Parameter error + * \~english @par Preconditons + * - none + * \~english @par Conditions of processing failure + * - If the media (media) specified in the parameter is smaller than NVHALMEDIA_CACHEDRAM or larger than NVHALMEDIA_NAND.\n + * [eFrameworkunifiedStatusInvldParam] + * - The identifier specified in the arguments is a NULL.[eFrameworkunifiedStatusInvldParam] + * - When the size specified in the arguments is 0.[eFrameworkunifiedStatusInvldParam] + * - Internal I/O handling errors (lstat).[eFrameworkunifiedStatusFileLoadError] + * - The size specified by the parameter does not correspond to the file size specified by the identifier.[eFrameworkunifiedStatusAccessError] + */ +//static EFrameworkunifiedStatus CheckNv(enum NvHalMedia media, const char *filename, uint32_t size) { +static EFrameworkunifiedStatus CheckNv(const char *filename, uint32_t size) { + uint32_t size_; + EFrameworkunifiedStatus ret; +// ret = GetSizeNv(media, filename, &size_); // Get size + if (ret != eFrameworkunifiedStatusOK) { // If the GetSizeNv fails, the error is returned unchanged. + return ret; + } + if (size_ != size) { // Returns eFrameworkunifiedStatusAccessError if the sizes do not match. + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "invalid size:%d\n", size); + return eFrameworkunifiedStatusAccessError; + } + return eFrameworkunifiedStatusOK; // Returns eFrameworkunifiedStatusOK if size matches +} + + + +/** + * read file spicefied by id + * + * \retval 0 read success + * \retval -1 crc error + * \retval -2 read failed + * \retval -3 invalid param + */ +//static int32_t BkupBufferReadFromNv(enum NvHalMedia media, const char *path, +static int32_t BkupBufferReadFromNv(const char *path, + char *buf, size_t size, uint32_t *crc32) { + int32_t ret = -1; + uint32_t size_all = static_cast<uint32_t>(size + sizeof(uint32_t)); + char *buffer = reinterpret_cast<char *>(MAP_FAILED); + uint32_t calc_crc32, get_crc32; + + if (!path) { // LCOV_EXCL_BR_LINE 6:double check + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + return -1; // LCOV_EXCL_LINE 6:double check + } + + if ((buffer = BkupAnonMmap(size_all)) == MAP_FAILED) { // LCOV_EXCL_BR_LINE 5:mmap's error case. + // LCOV_EXCL_START 5:mmap's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mmap:%s", strerror(errno)); + ret = eFrameworkunifiedStatusFail; + goto exit; + // LCOV_EXCL_STOP 5:mmap's error case. + } + +// if ((ret = ReadNv(media, path, reinterpret_cast<uint8_t *>(buffer), +// size_all)) == 0) { +// memcpy(&get_crc32, buffer + size, sizeof(uint32_t)); +// calc_crc32 = BkupCrc32(buffer, size); // LCOV_EXCL_BR_LINE 11:unexpected branch +// if (get_crc32 != calc_crc32) { + // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" +// FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "invalid crc(%s):%#x:%#x", path, get_crc32, calc_crc32); + // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h" +// ret = -1; +// goto exit; +// } +// if (crc32) { +// *crc32 = get_crc32; +// } +// memcpy(buf, buffer, size); +// } else if (ret == eFrameworkunifiedStatusInvldParam) { // LCOV_EXCL_BR_LINE 6:double check +// AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +// ret = -3; // LCOV_EXCL_LINE 6:double check +// } else { +// ret = -2; +// } +exit: + if (buffer != MAP_FAILED) { // LCOV_EXCL_BR_LINE 5:mmap's error case. + munmap(buffer, size_all); + } + + return ret; +} + +/* + * buffer -> file write + */ +//static int32_t BkupBufferWriteToNv(enum NvHalMedia media, const char *path, +static int32_t BkupBufferWriteToNv(const char *path, + char *buf, size_t size, uint32_t *crc32) { + int32_t ret; + uint32_t size_all = static_cast<uint32_t>(size + sizeof(uint32_t)); + char *buffer = reinterpret_cast<char *>(MAP_FAILED); + uint32_t calc_crc32; + + if ((buffer = BkupAnonMmap(size_all)) == MAP_FAILED) { // LCOV_EXCL_BR_LINE 5:mmap's error case. + // LCOV_EXCL_START 5:mmap's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mmap:%s", strerror(errno)); + ret = eFrameworkunifiedStatusFail; + goto exit; + // LCOV_EXCL_STOP 5:mmap's error case. + } + + calc_crc32 = BkupCrc32(buf, size); // LCOV_EXCL_BR_LINE 11:unexpected branch + if (crc32) { + *crc32 = calc_crc32; + } + + memcpy(buffer, buf, size); + memcpy(buffer + size, &calc_crc32, sizeof(uint32_t)); + +// if ((ret = WriteNv(media, path, reinterpret_cast<uint8_t *>(buffer), +// size_all)) != 0) { + // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" +// FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "write to nv(%s):%s", path, strerror(ret)); + // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h" +// ret = eFrameworkunifiedStatusFail; +// } + +exit: + if (buffer != MAP_FAILED) { // LCOV_EXCL_BR_LINE 5:mmap's error case. + munmap(buffer, size_all); + } + + return ret; +} + +/** + * inter media copy + */ +static int BkupMediaCopyFromNv(char *category_name, const char *item_name, +// enum NvHalMedia src, enum NvHalMedia dst, + pthread_rwlock_t *src_rwlock, + pthread_rwlock_t *dst_rwlock) { + int ret = -1; + uint32_t crc32; + char id_path[FILENAME_MAX]; + char *buffer = reinterpret_cast<char *>(MAP_FAILED); + + bkup_query_result_t query_result; + BkupParamGet(item_name, &query_result); // LCOV_EXCL_BR_LINE 11:unexpected branch + + char prefix_name[kBkupPrexixEncryptionSize + 1] = {0}; + if (query_result.encrypt != false) { + strncpy(prefix_name, kBkupPrexixEncryption, kBkupPrexixEncryptionSize); + } + snprintf(id_path, FILENAME_MAX, "%s/%s%s", category_name, prefix_name, item_name); + + if ((buffer = BkupAnonMmap(query_result.size)) == MAP_FAILED) { // LCOV_EXCL_BR_LINE 5:mmap's error case. + // LCOV_EXCL_START 5:mmap's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mmap:%s", strerror(errno)); + ret = eFrameworkunifiedStatusFail; + goto exit; + // LCOV_EXCL_STOP 5:mmap's error case. + } + + BkupRwlockRdlock(src_rwlock, id_path); // LCOV_EXCL_BR_LINE 11:unexpected branch +// if ((ret = BkupBufferReadFromNv(src, id_path, buffer, query_result.size, + if ((ret = BkupBufferReadFromNv(id_path, buffer, query_result.size, + &crc32)) >= 0) { + // LCOV_EXCL_BR_START 11:unexpected branch + BkupRwlockWrlock(dst_rwlock, id_path); +// ret = BkupBufferWriteToNv(dst, id_path, buffer, query_result.size, &crc32); + ret = BkupBufferWriteToNv(id_path, buffer, query_result.size, &crc32); + BkupRwlockUnlock(dst_rwlock, id_path); + // LCOV_EXCL_BR_STOP 11:unexpected branch + } + BkupRwlockUnlock(src_rwlock, id_path); // LCOV_EXCL_BR_LINE 11:unexpected branch + +exit: + if (buffer != MAP_FAILED) { // LCOV_EXCL_BR_LINE 5:mmap's error case. + munmap(buffer, query_result.size); + } + + return ret; +} + +/** + * make backup path + */ +static int BkupMakeBkupPathToNvId(const char *category_name, + const char *item_name, char **path_buf, + int buf_size) { + int ret = -1; + char prefix_name[kBkupPrexixEncryptionSize + 1] = {0}; + + if ((*path_buf = BkupAnonMmap(buf_size)) == MAP_FAILED) { // LCOV_EXCL_BR_LINE 5:mmap's error case. + // LCOV_EXCL_START 5:mmap's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mmap:%s", strerror(errno)); + goto exit; + // LCOV_EXCL_STOP 5:mmap's error case. + } + bkup_query_result_t query_result; + if (BkupParamGet(item_name, &query_result) < 0) { // LCOV_EXCL_BR_LINE 6:Excluded due to checking by upper-level function + // LCOV_EXCL_START 6:Excluded due to checking by upper-level function + AGL_ASSERT_NOT_TESTED(); + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Invalid item_name:%s", item_name); + goto exit; + // LCOV_EXCL_STOP 6:Excluded due to checking by upper-level function + } + if (query_result.encrypt != false) { + strncpy(prefix_name, kBkupPrexixEncryption, kBkupPrexixEncryptionSize); + } + snprintf(*path_buf, static_cast<size_t>(buf_size), "%s/%s%s", + category_name, prefix_name, item_name); + ret = 0; + +exit: + return ret; +} + +/** + * delete data + */ +//static int BkupDeleteDataFromNv(const enum NvHalMedia media, const char* const path) { +static int BkupDeleteDataFromNv(const char* const path) { + int ret = 0; + EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK; + + if (path == NULL) { // LCOV_EXCL_BR_LINE 6:Excluded due to checking by upper-level function + // LCOV_EXCL_START 6:Excluded due to checking by upper-level function + AGL_ASSERT_NOT_TESTED(); + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "path is NULL"); + ret = -1; + return ret; + // LCOV_EXCL_STOP 6:Excluded due to checking by upper-level function + } + const size_t path_size = std::string(path).length(); + if (path_size > FILENAME_MAX) { // LCOV_EXCL_BR_LINE 6:Excluded due to checking by upper-level function + // LCOV_EXCL_START 6:Excluded due to checking by upper-level function + AGL_ASSERT_NOT_TESTED(); + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "path size error"); + ret = -1; + return ret; + // LCOV_EXCL_STOP 6:Excluded due to checking by upper-level function + } + +// if ((e_status = DeleteNv(media, path)) != eFrameworkunifiedStatusOK) { +// ret = -1; +// FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "DeleteNv e_status:%d\n", e_status); +// } + return ret; +} + +/** + * get rwlock + */ +static pthread_rwlock_t *BkupGetRwlock(const char *item_name, +// enum NvHalMedia media, + bkup_query_result_t *query_result) { + int ret; + pthread_rwlock_t *rwlock, *org_rwlock; + pthread_rwlockattr_t attr; + +// if (media != NVHALMEDIA_BACKUPDRAM || query_result->backup_dram == false || query_result->nand == false) { + if (query_result->backup_dram == false || query_result->nand == false) { + return NULL; + } + // backupDram && nand + if (query_result->opt != NULL) { + return reinterpret_cast<pthread_rwlock_t *>(query_result->opt); + } + + if ((ret = pthread_rwlockattr_init(&attr)) != 0) { // LCOV_EXCL_BR_LINE 5:pthread_rwlockattr_init's error case. + // LCOV_EXCL_START 5:pthread_rwlockattr_init's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "pthread_rwlockattr_init:%s", strerror(ret)); + return NULL; + // LCOV_EXCL_STOP 5:pthread_rwlockattr_init's error case. + } + + // LCOV_EXCL_BR_START 5:pthread_rwlockattr_setkind_np's error case. + if ((ret = pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP)) != 0) { + // LCOV_EXCL_BR_STOP 5:pthread_rwlockattr_setkind_np's error case. + // LCOV_EXCL_START 5:pthread_rwlockattr_setkind_np's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "pthread_rwlockattr_setkind_np:%s", strerror(ret)); + return NULL; + // LCOV_EXCL_STOP 5:pthread_rwlockattr_setkind_np's error case. + } + + // LCOV_EXCL_BR_START 5:malloc's error case. + if ((rwlock = reinterpret_cast<pthread_rwlock_t *>(malloc(sizeof(pthread_rwlock_t)))) == NULL) { + // LCOV_EXCL_BR_STOP 5:malloc's error case. + // LCOV_EXCL_START 5:malloc's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "malloc failed"); + return NULL; + // LCOV_EXCL_STOP 5:malloc's error case. + } + + if ((ret = pthread_rwlock_init(rwlock, &attr)) != 0) { // LCOV_EXCL_BR_LINE 5:pthread_rwlock_init's error case. + // LCOV_EXCL_START 5:pthread_rwlock_init's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "pthread_rwlock_init:%s", strerror(ret)); + free(rwlock); + return NULL; + // LCOV_EXCL_STOP 5:pthread_rwlock_init's error case. + } + + // LCOV_EXCL_BR_START 11:unexpected branch + org_rwlock = reinterpret_cast<pthread_rwlock_t *>(BkupParamSetOpt(item_name, rwlock)); + // LCOV_EXCL_BR_STOP 11:unexpected branch + if (org_rwlock == reinterpret_cast<void *>(-1)) { // LCOV_EXCL_BR_LINE 6:org_rwlock will not be -1 + // LCOV_EXCL_START 6:org_rwlock will not be -1 + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Invalid item_name:%s", item_name != 0 ? item_name : NULL); + free(rwlock); + return NULL; + // LCOV_EXCL_STOP 6:org_rwlock will not be -1 + } else if (org_rwlock != NULL) { // LCOV_EXCL_BR_LINE 5:gcc builtin function's error case + // conflict + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + free(rwlock); // LCOV_EXCL_LINE 5:gcc builtin function's error case + rwlock = org_rwlock; // LCOV_EXCL_LINE 5:gcc builtin function's error case + } + + query_result->opt = rwlock; + return rwlock; +} + +/** + * rwlock read lock + */ +static inline void BkupRwlockRdlock(pthread_rwlock_t *rwlock, const char *path) { + if (rwlock) { + int ret; + if ((ret = pthread_rwlock_rdlock(rwlock)) != 0) { // LCOV_EXCL_BR_LINE 5:pthread_rwlock_rdlock's error case. + // LCOV_EXCL_START 5:pthread_rwlock_rdlock's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "pthread_rwlock_rdlock(%s):%s", path, strerror(ret)); + // LCOV_EXCL_STOP 5:pthread_rwlock_rdlock's error case. + } + } +} + +/** + * rwlock write lock + */ +static inline void BkupRwlockWrlock(pthread_rwlock_t *rwlock, const char *path) { + if (rwlock) { + int ret; + if ((ret = pthread_rwlock_wrlock(rwlock)) != 0) { // LCOV_EXCL_BR_LINE 5:pthread_rwlock_wrlock's error case. + // LCOV_EXCL_START 5:pthread_rwlock_wrlock's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "pthread_rwlock_wrlock(%s):%s", path, strerror(ret)); + // LCOV_EXCL_STOP 5:pthread_rwlock_wrlock's error case. + } + } +} + +/** + * rwlock unlock + */ +static inline void BkupRwlockUnlock(pthread_rwlock_t *rwlock, const char *path) { + if (rwlock) { + int ret; + if ((ret = pthread_rwlock_unlock(rwlock)) != 0) { // LCOV_EXCL_BR_LINE 5:pthread_rwlock_unlock's error case. + // LCOV_EXCL_START 5:pthread_rwlock_unlock's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "pthread_rwlock_unlock(%s):%s", path, strerror(ret)); + // LCOV_EXCL_STOP 5:pthread_rwlock_unlock's error case. + } + } +} + +/** + * inter thread communication MQ open + */ +static mqd_t BkupItcMqopen(const char *mq_name, int flags) { + struct mq_attr attr; + + attr.mq_flags = 0; + attr.mq_maxmsg = 256; + attr.mq_msgsize = sizeof(bkup_itc_message_t); + + return mq_open(mq_name, flags, 0660, &attr); +} + +/** + * write & rename + */ +static int BkupWriteRename(const char *category_name, const char *item_name, +// enum NvHalMedia media, char *buf, int size, + char *buf, int size, + pthread_rwlock_t *rwlock) { + int ret = -1; + char *full_path = reinterpret_cast<char *>(MAP_FAILED); + + // LCOV_EXCL_BR_START 5:mmap's error case. + if (BkupMakeBkupPathToNvId(category_name, item_name, &full_path, FILENAME_MAX) < 0) { + // LCOV_EXCL_BR_STOP 5:mmap's error case. + // LCOV_EXCL_START 5:mmap's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + goto exit; + // LCOV_EXCL_STOP 5:mmap's error case. + } + + BkupRwlockWrlock(rwlock, full_path); // LCOV_EXCL_BR_LINE 11:unexpected branch +// if (BkupBufferWriteToNv(media, full_path, buf, size, NULL) < 0) { + if (BkupBufferWriteToNv(full_path, buf, size, NULL) < 0) { + BkupRwlockUnlock(rwlock, full_path); // LCOV_EXCL_BR_LINE 11:unexpected branch + goto exit; + } + BkupRwlockUnlock(rwlock, full_path); // LCOV_EXCL_BR_LINE 11:unexpected branch + + ret = size; + +exit: + if (full_path != MAP_FAILED) { // LCOV_EXCL_BR_LINE 5:mmap's error case. + munmap(full_path, FILENAME_MAX); + } + return ret; +} + +/** + * stat check + * + * \retval 0 file exists + * \retval -1 file not exists + * \retval -2 size error + */ +//static int BkupCheckStatFromNv(enum NvHalMedia media, const char *path, +static int BkupCheckStatFromNv(const char *path, + int check_size) { + uint32_t size = check_size + static_cast<uint32_t>(sizeof(uint32_t)); +// EFrameworkunifiedStatus ret = CheckNv(media, path, size); + EFrameworkunifiedStatus ret = CheckNv(path, size); + + if (eFrameworkunifiedStatusOK == ret) { + return 0; + } else if (eFrameworkunifiedStatusAccessError == ret) { + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "CheckNv e_status:%d", ret); + return -2; + } else { + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "CheckNv e_status:%d", ret); + return -1; + } +} + +/** + * media stat + */ +//static int BkupMediaStat(const char *category_name, const char *item_name, enum NvHalMedia src, int size) { +static int BkupMediaStat(const char *category_name, const char *item_name, int size) { + int ret = -1; + char *path = reinterpret_cast<char *>(MAP_FAILED); + + // LCOV_EXCL_BR_START 5:mmap's error case. + if (BkupMakeBkupPathToNvId(category_name, item_name, &path, FILENAME_MAX) < 0) { + // LCOV_EXCL_BR_STOP 5:mmap's error case. + // LCOV_EXCL_START 5:mmap's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + goto exit; + // LCOV_EXCL_STOP 5:mmap's error case. + } +// ret = BkupCheckStatFromNv(src, path, size); // LCOV_EXCL_BR_LINE 11:unexpected branch + ret = BkupCheckStatFromNv(path, size); // LCOV_EXCL_BR_LINE 11:unexpected branch + +exit: + if (path != MAP_FAILED) { // LCOV_EXCL_BR_LINE 5:mmap's error case. + munmap(path, FILENAME_MAX); + } + return ret; +} + +/** + * stat check & read + * + * \retval 0 file exists + * \retval -1 file not exists + */ +//static int BkupCheckStatRead(enum NvHalMedia current_media, const char *path, +static int BkupCheckStatRead(const char *path, + char *buf, int check_size, uint32_t *crc32, + pthread_rwlock_t *rwlock) { + int ret; + +// if ((ret = BkupCheckStatFromNv(current_media, path, check_size)) < 0) { + if ((ret = BkupCheckStatFromNv(path, check_size)) < 0) { + return ret; + } + + BkupRwlockRdlock(rwlock, path); + +// if (BkupBufferReadFromNv(current_media, path, buf, check_size, crc32) < 0) { + if (BkupBufferReadFromNv(path, buf, check_size, crc32) < 0) { + BkupRwlockUnlock(rwlock, path); + return -1; + } + + BkupRwlockUnlock(rwlock, path); + return 0; +} + +/** + * valid check + * + * \retval 0 file invalid & do nothing + * \retval -1 file invalid but create 0 fill file + * \retval 1 file valid + */ +//static int BkupCheckRead(const char *path, enum NvHalMedia current_media, +static int BkupCheckRead(const char *path, + bkup_protocol_command_t command, char *rcv_buf, + char *read_buf, uint32_t *crc32, + bkup_query_result_t *query_result, + pthread_rwlock_t *rwlock) { + int ret = -1; + bkup_protocol_header_t *hdr = reinterpret_cast<bkup_protocol_header_t *>(rcv_buf); + +// if (BkupCheckStatRead(current_media, path, read_buf, query_result->size, crc32, rwlock) < 0) { + if (BkupCheckStatRead(path, read_buf, query_result->size, crc32, rwlock) < 0) { + // file not exists +// if (current_media == NVHALMEDIA_NAND || query_result->nand == false) { + if (query_result->nand == false) { + goto exit; + } else { + if (command == BKUP_CMD_READ) { + /* + * Read + */ +// if (BkupCheckStatFromNv(NVHALMEDIA_NAND, path, query_result->size) == 0) { + if (BkupCheckStatFromNv(path, query_result->size) == 0) { + // do nothing + ret = 0; + } else { + // take preference BackupDRAM or CacheDRAM + ret = -1; + } + } else { + /* + * Write/Fill + */ +// pthread_rwlock_t *nand_rwlock = BkupGetRwlock(hdr->item_name, NVHALMEDIA_NAND, query_result); + pthread_rwlock_t *nand_rwlock = BkupGetRwlock(hdr->item_name, query_result); +// if (BkupCheckStatRead(NVHALMEDIA_NAND, path, read_buf, query_result->size, NULL, nand_rwlock) == 0) { + if (BkupCheckStatRead(path, read_buf, query_result->size, NULL, nand_rwlock) == 0) { + // write back cache + if (BkupWriteRename(query_result->category_name, hdr->item_name, +// current_media, read_buf, query_result->size, + read_buf, query_result->size, + rwlock) >= 0) { + ret = 1; + } else { + // copy error, do nothing + ret = 0; + } + } else { + // take preference BackupDRAM or CacheDRAM + ret = -1; + } + } + goto exit; + } + } + ret = 1; +exit: + return ret; +} + +/** + * read command + */ +//static int BkupCmdRead(bkup_response_t *response, enum NvHalMedia current_media, +static int BkupCmdRead(bkup_response_t *response, + char *rcv_buf, bkup_query_result_t *query_result) { + int ret = -1; + bkup_protocol_header_t *hdr = reinterpret_cast<bkup_protocol_header_t *>(rcv_buf); + // LCOV_EXCL_BR_START 11:unexpected branch +// pthread_rwlock_t *rwlock = BkupGetRwlock(hdr->item_name, current_media, query_result); + pthread_rwlock_t *rwlock = BkupGetRwlock(hdr->item_name, query_result); + // LCOV_EXCL_BR_STOP 11:unexpected branch + char *full_path = reinterpret_cast<char *>(MAP_FAILED); + char *buf = reinterpret_cast<char *>(MAP_FAILED); + size_t buf_size = 0; + uint32_t crc32 = 0; + EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK; + + // LCOV_EXCL_BR_START 5:mmap's error case. + if (BkupMakeBkupPathToNvId(query_result->category_name, hdr->item_name, &full_path, FILENAME_MAX) < 0) { + // LCOV_EXCL_BR_STOP 5:mmap's error case. + // LCOV_EXCL_START 5:mmap's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + e_status = eFrameworkunifiedStatusFail; + goto exit; + // LCOV_EXCL_STOP 5:mmap's error case. + } + + if ((buf = BkupAnonMmap(query_result->size)) == MAP_FAILED) { // LCOV_EXCL_BR_LINE 5:mmap's error case. + // LCOV_EXCL_START 5:mmap's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mmap:%s", strerror(errno)); + e_status = eFrameworkunifiedStatusFail; + goto exit; + // LCOV_EXCL_STOP 5:mmap's error case. + } + buf_size = query_result->size; + +// ret = BkupCheckRead(full_path, current_media, hdr->command, rcv_buf, buf, + ret = BkupCheckRead(full_path, hdr->command, rcv_buf, buf, + &crc32, query_result, rwlock); // LCOV_EXCL_BR_LINE 11:unexpected branch + if (ret == -1) { + // return all 0 + ret = hdr->size; + goto exit; + } else if (ret == 0) { + // do nothing + goto exit; + } + + // success + ret = hdr->size; + + // caching to memory +// if (current_media == NVHALMEDIA_NAND) { + if (query_result->cache_dram) { + if (BkupMediaStat(query_result->category_name, hdr->item_name, +// NVHALMEDIA_CACHEDRAM, query_result->size) < 0) { + query_result->size) < 0) { + // LCOV_EXCL_BR_START 11:unexpected branch + pthread_rwlock_t *dst_rwlock = +// BkupGetRwlock(hdr->item_name, NVHALMEDIA_CACHEDRAM, query_result); + BkupGetRwlock(hdr->item_name, query_result); + // LCOV_EXCL_BR_STOP 11:unexpected branch + BkupWriteRename(query_result->category_name, hdr->item_name, +// NVHALMEDIA_CACHEDRAM, buf, query_result->size, + buf, query_result->size, + dst_rwlock); // LCOV_EXCL_BR_LINE 11:unexpected branch + } + } + if (query_result->backup_dram) { + if (BkupMediaStat(query_result->category_name, hdr->item_name, +// NVHALMEDIA_BACKUPDRAM, query_result->size) < 0) { + query_result->size) < 0) { + // LCOV_EXCL_BR_START 11:unexpected branch + pthread_rwlock_t *dst_rwlock = +// BkupGetRwlock(hdr->item_name, NVHALMEDIA_BACKUPDRAM, query_result); + BkupGetRwlock(hdr->item_name, query_result); + // LCOV_EXCL_BR_STOP 11:unexpected branch + BkupWriteRename(query_result->category_name, hdr->item_name, +// NVHALMEDIA_BACKUPDRAM, buf, query_result->size, + buf, query_result->size, + dst_rwlock); // LCOV_EXCL_BR_LINE 11:unexpected branch + } + } +// } + +exit: + if (ret != 0 && buf != MAP_FAILED) { // LCOV_EXCL_BR_LINE 5: mmap's error case. + // LCOV_EXCL_BR_START 11:unexpected branch +// BkupApilog(response, current_media, hdr, query_result, buf, crc32, e_status); + BkupApilog(response, hdr, query_result, buf, crc32, e_status); + // LCOV_EXCL_BR_STOP 11:unexpected branch + // LCOV_EXCL_BR_START 4: NSFW error case + if ((*response->set_response)(response->opt, buf + hdr->offset, hdr->size, e_status) < 0) { + // LCOV_EXCL_BR_STOP 4: NSFW error case + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + ret = -1; // LCOV_EXCL_LINE 4: NSFW error case + } + } + + if (full_path != MAP_FAILED) { // LCOV_EXCL_BR_LINE 5: mmap's error case. + munmap(full_path, FILENAME_MAX); + } + if (buf != MAP_FAILED) { // LCOV_EXCL_BR_LINE 5: mmap's error case. + munmap(buf, buf_size); + } + return ret; +} + +/** + * write command + */ +static int BkupCmdWrite(bkup_response_t *response, +// enum NvHalMedia current_media, char *rcv_buf, + char *rcv_buf, + bkup_query_result_t *query_result) { + int ret = -1; + bkup_protocol_header_t *hdr = reinterpret_cast<bkup_protocol_header_t *>(rcv_buf); + // LCOV_EXCL_BR_START 11:unexpected branch +// pthread_rwlock_t *rwlock = BkupGetRwlock(hdr->item_name, current_media, query_result); + pthread_rwlock_t *rwlock = BkupGetRwlock(hdr->item_name, query_result); + // LCOV_EXCL_BR_STOP 11:unexpected branch + char *full_path = reinterpret_cast<char *>(MAP_FAILED); + char *tmp_path = reinterpret_cast<char *>(MAP_FAILED); + char *buf = reinterpret_cast<char *>(MAP_FAILED); + char *header = NULL; + uint32_t crc32 = 0; + int buf_size = 0; + + // LCOV_EXCL_BR_START 5: mmap's error case. + if (BkupMakeBkupPathToNvId(query_result->category_name, hdr->item_name, &full_path, FILENAME_MAX) < 0) { + // LCOV_EXCL_BR_STOP 5: mmap's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + goto exit; // LCOV_EXCL_LINE 5: mmap's error case. + } + + if (hdr->offset != 0 || hdr->size != (uint32_t)query_result->size) { + /* + * partial write + */ + if ((buf = BkupAnonMmap(query_result->size)) == MAP_FAILED) { // LCOV_EXCL_BR_LINE 5: mmap's error case. + // LCOV_EXCL_START 5: mmap's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mmap:%s", strerror(errno)); + goto exit; + // LCOV_EXCL_STOP 5: mmap's error case. + } + buf_size = query_result->size; + + // LCOV_EXCL_BR_START 11:unexpected branch +// ret = BkupCheckRead(full_path, current_media, hdr->command, rcv_buf, buf, NULL, query_result, rwlock); + ret = BkupCheckRead(full_path, hdr->command, rcv_buf, buf, NULL, query_result, rwlock); + // LCOV_EXCL_BR_STOP 11:unexpected branch + if (ret == 0) { + // do nothing + goto exit; + } + + header = buf; + memcpy(buf + hdr->offset, rcv_buf + sizeof(bkup_protocol_header_t), hdr->size); + BkupRwlockWrlock(rwlock, full_path); // LCOV_EXCL_BR_LINE 11:unexpected branch +// if (BkupBufferWriteToNv(current_media, full_path, buf, query_result->size, &crc32) < 0) { + if (BkupBufferWriteToNv(full_path, buf, query_result->size, &crc32) < 0) { + BkupRwlockUnlock(rwlock, full_path); // LCOV_EXCL_BR_LINE 11:unexpected branch + goto exit; + } + BkupRwlockUnlock(rwlock, full_path); // LCOV_EXCL_BR_LINE 11:unexpected branch + } else { + /* + * whole write + */ + header = rcv_buf + sizeof(bkup_protocol_header_t); + BkupRwlockWrlock(rwlock, full_path); // LCOV_EXCL_BR_LINE 11:unexpected branch +// if (BkupBufferWriteToNv(current_media, full_path, + if (BkupBufferWriteToNv(full_path, + rcv_buf + sizeof(bkup_protocol_header_t), hdr->size, &crc32) < 0) { + BkupRwlockUnlock(rwlock, full_path); // LCOV_EXCL_BR_LINE 11:unexpected branch + goto exit; + } + BkupRwlockUnlock(rwlock, full_path); // LCOV_EXCL_BR_LINE 11:unexpected branch + } + + // success + ret = hdr->size; + +exit: + EFrameworkunifiedStatus e_status = ret < 0 ? eFrameworkunifiedStatusFail : eFrameworkunifiedStatusOK; +// if (current_media == NVHALMEDIA_NAND) { +// if (query_result->cache_dram == false && query_result->backup_dram == false) { + // LCOV_EXCL_BR_START 11:unexpected branch +// BkupApilog(response, current_media, hdr, query_result, header, crc32, e_status); + // LCOV_EXCL_BR_STOP 11:unexpected branch +// } +// if ((*response->set_response)(response->opt, NULL, 0, e_status) < 0) { // LCOV_EXCL_BR_LINE 4: NSFW error case +// AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +// ret = -1; // LCOV_EXCL_LINE 4: NSFW error case +// } +// } else { + // LCOV_EXCL_BR_START 11:unexpected branch +// BkupApilog(response, current_media, hdr, query_result, header, crc32, e_status); + BkupApilog(response, hdr, query_result, header, crc32, e_status); + // LCOV_EXCL_BR_STOP 11:unexpected branch +// } + + if (buf != MAP_FAILED) { // LCOV_EXCL_BR_LINE 5: mmap's error case. + munmap(buf, buf_size); + } + if (full_path != MAP_FAILED) { // LCOV_EXCL_BR_LINE 5: mmap's error case. + munmap(full_path, FILENAME_MAX); + } + if (tmp_path != MAP_FAILED) { // LCOV_EXCL_BR_LINE 8: dead code + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + munmap(tmp_path, FILENAME_MAX); // LCOV_EXCL_LINE 8: dead code + } + return ret; +} + +/** + * fill command + */ +//static int BkupCmdFill(bkup_response_t *response, enum NvHalMedia current_media, +static int BkupCmdFill(bkup_response_t *response, + char *rcv_buf, bkup_query_result_t *query_result) { + int ret = -1; + bkup_protocol_header_t *hdr = reinterpret_cast<bkup_protocol_header_t *>(rcv_buf); + // LCOV_EXCL_BR_START 11:unexpected branch +// pthread_rwlock_t *rwlock = BkupGetRwlock(hdr->item_name, current_media, query_result); + pthread_rwlock_t *rwlock = BkupGetRwlock(hdr->item_name, query_result); + // LCOV_EXCL_BR_STOP 11:unexpected branch + char *full_path = reinterpret_cast<char *>(MAP_FAILED); + char *buf = reinterpret_cast<char *>(MAP_FAILED); + uint32_t crc32 = 0; + + // LCOV_EXCL_BR_START 5: mmap's error case. + if (BkupMakeBkupPathToNvId(query_result->category_name, hdr->item_name, &full_path, FILENAME_MAX) < 0) { + // LCOV_EXCL_BR_STOP 5: mmap's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + goto exit; // LCOV_EXCL_LINE 5: mmap's error case. + } + + // LCOV_EXCL_BR_START 5: mmap's error case. + if ((buf = BkupAnonMmap(query_result->size)) == MAP_FAILED) { + // LCOV_EXCL_BR_STOP 5: mmap's error case. + // LCOV_EXCL_START 5: mmap's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mmap:%s", strerror(errno)); + goto exit; + // LCOV_EXCL_STOP 5: mmap's error case. + } + + if (hdr->offset != 0 || hdr->size != (uint32_t)query_result->size) { + /* + * partial fill + */ + // LCOV_EXCL_BR_START 11:unexpected branch +// ret = BkupCheckRead(full_path, current_media, hdr->command, rcv_buf, buf, NULL, query_result, rwlock); + ret = BkupCheckRead(full_path, hdr->command, rcv_buf, buf, NULL, query_result, rwlock); + // LCOV_EXCL_BR_STOP 11:unexpected branch + if (ret == 0) { + // do nothing + goto exit; + } + } + + memset(buf + hdr->offset, hdr->fill_patern, hdr->size); + BkupRwlockWrlock(rwlock, full_path); // LCOV_EXCL_BR_LINE 11:unexpected branch +// if (BkupBufferWriteToNv(current_media, full_path, buf, query_result->size, &crc32) < 0) { + if (BkupBufferWriteToNv(full_path, buf, query_result->size, &crc32) < 0) { + BkupRwlockUnlock(rwlock, full_path); // LCOV_EXCL_BR_LINE 11:unexpected branch + goto exit; + } + BkupRwlockUnlock(rwlock, full_path); // LCOV_EXCL_BR_LINE 11:unexpected branch + + // success + ret = hdr->size; + +exit: + EFrameworkunifiedStatus e_status = ret < 0 ? eFrameworkunifiedStatusFail : eFrameworkunifiedStatusOK; +// if (current_media == NVHALMEDIA_NAND) { + if (query_result->cache_dram == false && query_result->backup_dram == false) { + // LCOV_EXCL_BR_START 11:unexpected branch +// BkupApilog(response, current_media, hdr, query_result, buf, crc32, e_status); + BkupApilog(response, hdr, query_result, buf, crc32, e_status); + // LCOV_EXCL_BR_STOP 11:unexpected branch + } + if ((*response->set_response)(response->opt, NULL, 0, e_status) < 0) { // LCOV_EXCL_BR_LINE 4: NSFW error case + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + ret = -1; // LCOV_EXCL_LINE 4: NSFW error case + } +// } else { + // LCOV_EXCL_BR_START 11:unexpected branch +// BkupApilog(response, current_media, hdr, query_result, buf, crc32, e_status); + // LCOV_EXCL_BR_STOP 11:unexpected branch +// } + + if (buf != MAP_FAILED) { // LCOV_EXCL_BR_LINE 5: mmap's error case. + munmap(buf, query_result->size); + } + if (full_path != MAP_FAILED) { // LCOV_EXCL_BR_LINE 5: mmap's error case. + munmap(full_path, FILENAME_MAX); + } + return ret; +} + +/** + * copy command + */ +//static int BkupCmdCopy(bkup_response_t *response, enum NvHalMedia current_media, +static int BkupCmdCopy(bkup_response_t *response, + char *rcv_buf, bkup_query_result_t *query_result) { + bkup_protocol_header_t *hdr = + reinterpret_cast<bkup_protocol_header_t *>(rcv_buf); + pthread_rwlock_t *src_rwlock = +// BkupGetRwlock(hdr->item_name, hdr->src_media, query_result); + BkupGetRwlock(hdr->item_name, query_result); + pthread_rwlock_t *dst_rwlock = +// BkupGetRwlock(hdr->item_name, current_media, query_result); + BkupGetRwlock(hdr->item_name, query_result); + +// int ret = BkupMediaCopyFromNv(query_result->category_name, hdr->item_name, hdr->src_media, current_media, src_rwlock, + int ret = BkupMediaCopyFromNv(query_result->category_name, hdr->item_name, src_rwlock, + dst_rwlock); + +// if (current_media == NVHALMEDIA_NAND) { + // LCOV_EXCL_BR_START 4: NSFW error case + if ((*response->set_response)(response->opt, NULL, 0, ret < 0 ? eFrameworkunifiedStatusFail : eFrameworkunifiedStatusOK) < 0) { + // LCOV_EXCL_BR_STOP 4: NSFW error case + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + ret = -1; // LCOV_EXCL_LINE 4: NSFW error case + } +// } + return ret; +} + +/** + * check command + */ +static int BkupCmdCheck(bkup_response_t *response, +// enum NvHalMedia current_media, char *rcv_buf, + char *rcv_buf, + bkup_query_result_t *query_result) { + int ret = 0; + bkup_protocol_header_t *hdr = reinterpret_cast<bkup_protocol_header_t *>(rcv_buf); + char *full_path = reinterpret_cast<char *>(MAP_FAILED); + + // LCOV_EXCL_BR_START 5: mmap's error case. + if (BkupMakeBkupPathToNvId(query_result->category_name, hdr->item_name, &full_path, FILENAME_MAX) < 0) { + // LCOV_EXCL_BR_STOP 5: mmap's error case. + // LCOV_EXCL_START 5: mmap's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + ret = -3; + goto exit; + // LCOV_EXCL_STOP 5: mmap's error case. + } +// ret = BkupCheckStatFromNv(current_media, full_path, query_result->size); // LCOV_EXCL_BR_LINE 11:unexpected branch + ret = BkupCheckStatFromNv(full_path, query_result->size); // LCOV_EXCL_BR_LINE 11:unexpected branch + +exit: + if (full_path != MAP_FAILED) { // LCOV_EXCL_BR_LINE 5: mmap's error case. + munmap(full_path, FILENAME_MAX); + } + return ret; +} + +/** + * delete command + */ +static int BkupCmdDeleteData(bkup_response_t* const response, +// const enum NvHalMedia current_media, + char* const rcv_buf, + bkup_query_result_t* const query_result) { + int ret = -1; + char *full_path = NULL; + bkup_protocol_header_t* hdr = nullptr; + pthread_rwlock_t* rwlock = nullptr; + if ((response == nullptr) || (rcv_buf == nullptr) || (query_result == nullptr)) { // LCOV_EXCL_BR_LINE 6:Excluded as no NULL is currently passed + // LCOV_EXCL_START 6:Excluded as no NULL is currently passed + AGL_ASSERT_NOT_TESTED(); + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Resp or Buf or Query is NULL"); + goto exit; + // LCOV_EXCL_STOP 6:Excluded as no NULL is currently passed + } + hdr = reinterpret_cast<bkup_protocol_header_t *>(rcv_buf); +// rwlock = BkupGetRwlock(hdr->item_name, current_media, query_result); + rwlock = BkupGetRwlock(hdr->item_name, query_result); + if (BkupMakeBkupPathToNvId(query_result->category_name, hdr->item_name, &full_path, FILENAME_MAX) < 0) { // LCOV_EXCL_BR_LINE 6:Excluded due to checking by upper-level function + // LCOV_EXCL_START 6:Excluded due to checking by upper-level function + AGL_ASSERT_NOT_TESTED(); + goto exit; + // LCOV_EXCL_STOP 6:Excluded due to checking by upper-level function + } + BkupRwlockWrlock(rwlock, full_path); +// ret = BkupDeleteDataFromNv(current_media, full_path); + ret = BkupDeleteDataFromNv(full_path); + if (ret != 0) { + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "BkupDeleteDataFromNv Error"); + } + BkupRwlockUnlock(rwlock, full_path); + +exit: + if ((response != nullptr) && (query_result != nullptr)) { // LCOV_EXCL_BR_LINE 6:Excluded as no NULL is currently passed + EFrameworkunifiedStatus e_status = (ret < 0) ? eFrameworkunifiedStatusFail : eFrameworkunifiedStatusOK; +// if (current_media == NVHALMEDIA_NAND) { + if ((query_result->cache_dram == false) && (query_result->backup_dram == false)) { +// BkupApilog(response, current_media, hdr, query_result, nullptr, 0, e_status); + BkupApilog(response, hdr, query_result, nullptr, 0, e_status); + } + if ((*response->set_response)(response->opt, nullptr, 0, e_status) < 0) { + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Response Error"); + ret = -1; + } +// } else { +// BkupApilog(response, current_media, hdr, query_result, NULL, 0, e_status); +// } + } + + if (full_path != NULL) { // LCOV_EXCL_BR_LINE 6:Excluded because checked by BkupMakeBkupPathToNvId() + munmap(full_path, FILENAME_MAX); + } + return ret; +} + +/** + * common file handler + */ +static int BkupHandlerFile(bkup_response_t *response, +// enum NvHalMedia current_media, char *rcv_buf, + char *rcv_buf, + bkup_query_result_t *query_result) { + int ret = 0; + bkup_protocol_header_t *hdr = reinterpret_cast<bkup_protocol_header_t *>(rcv_buf); + + switch (hdr->command) { // LCOV_EXCL_BR_LINE 6:double check + case BKUP_CMD_READ: +// ret = BkupCmdRead(response, current_media, rcv_buf, query_result); + ret = BkupCmdRead(response, rcv_buf, query_result); + break; + + case BKUP_CMD_WRITE: +// ret = BkupCmdWrite(response, current_media, rcv_buf, query_result); + ret = BkupCmdWrite(response, rcv_buf, query_result); + break; + + case BKUP_CMD_FILL: +// ret = BkupCmdFill(response, current_media, rcv_buf, query_result); + ret = BkupCmdFill(response, rcv_buf, query_result); + break; + + case BKUP_CMD_COPY_INNER: +// ret = BkupCmdCopy(response, current_media, rcv_buf, query_result); + ret = BkupCmdCopy(response, rcv_buf, query_result); + break; + + case BKUP_CMD_DELETE: +// ret = BkupCmdDeleteData(response, current_media, rcv_buf, query_result); + ret = BkupCmdDeleteData(response, rcv_buf, query_result); + break; + + default: + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + break; // LCOV_EXCL_LINE 6:double check + } + return ret; +} + +/** + * Main's response + */ +static int BkupSetResponseNsfw(void *opt, void *buf, int size, EFrameworkunifiedStatus ret_value) { + EFrameworkunifiedStatus e_status; + + if (buf != NULL) { // LCOV_EXCL_BR_LINE 6:double check + // LCOV_EXCL_BR_START 4: NSFW error case + if ((e_status = FrameworkunifiedSetSyncResponseData((HANDLE)opt, buf, size)) != eFrameworkunifiedStatusOK) { + // LCOV_EXCL_BR_STOP 4: NSFW error case + // LCOV_EXCL_START 4: NSFW error case + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedSetSyncResponseData:%d", e_status); + return -1; + // LCOV_EXCL_STOP 4: NSFW error case + } + } + return 0; +} + +/** + * write apilog + */ +//static void BkupApilog(bkup_response_t *response, enum NvHalMedia current_media, +static void BkupApilog(bkup_response_t *response, + bkup_protocol_header_t *hdr, + bkup_query_result_t *query_result, char *buf, + uint32_t crc32, EFrameworkunifiedStatus ret_value) { + const char *src; + const char *cmd; + char header[12] = "-- -- -- --"; + const char c[] = "0123456789abcdef"; + + if (response->set_response == BkupSetResponseNsfw) { + src = FrameworkunifiedGetMsgSrc((HANDLE)response->opt); // LCOV_EXCL_BR_LINE 11:unexpected branch + } else { + // LCOV_EXCL_BR_START 11:unexpected branch + src = (reinterpret_cast<bkup_itc_message_t *>(response->opt))->nand.client_name; + // LCOV_EXCL_BR_STOP 11:unexpected branch + } + + switch (hdr->command) { // LCOV_EXCL_BR_LINE 6:double check + case BKUP_CMD_READ: + cmd = "RD"; + break; + case BKUP_CMD_WRITE: + cmd = "WR"; + break; + case BKUP_CMD_FILL: + cmd = "FILL"; + break; + case BKUP_CMD_READ_NUM: + // LCOV_EXCL_START 6:double check + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + cmd = "RDN"; + break; + // LCOV_EXCL_STOP 6:double check + case BKUP_CMD_SIZE_NUM: + // LCOV_EXCL_START 6:double check + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + cmd = "SZN"; + break; + // LCOV_EXCL_STOP 6:double check + case BKUP_CMD_DELETE: + cmd = "DEL"; + break; + default: + // LCOV_EXCL_START 6:double check + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + cmd = "UNKNOWN"; + break; + // LCOV_EXCL_STOP 6:double check + } + + if (buf) { // LCOV_EXCL_BR_LINE 6:double check + int i; + for (i = 0; i < 4; i++) { + if (query_result->size > i) { + header[i * 3] = c[*(buf + i) >> 4]; + header[i * 3 + 1] = c[*(buf + i) & 0xf]; + } + } + } + + // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" + FRAMEWORKUNIFIEDLOG(ZONE_ALSA, "", "%s/%s/%s/o:%d/s:%d/h:%s/c:%x/r:%d", src, cmd, hdr->item_name, hdr->offset, hdr->size, + header, crc32, ret_value); + // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h" +} + +/** + * Tweak command + */ +//static int BkupTweakCommand(enum NvHalMedia current_media, char **rcv_buf, +static int BkupTweakCommand(char **rcv_buf, + int *rcv_size, bkup_query_result_t *query_result) { + int ret = -1; + bkup_protocol_header_t update_hdr; + bkup_protocol_header_t *hdr = reinterpret_cast<bkup_protocol_header_t *>(*rcv_buf); + +// if (current_media == NVHALMEDIA_NAND) { // LCOV_EXCL_BR_LINE 6:current_media never will be NVHALMEDIA_NAND +// AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert +// ret = 0; // LCOV_EXCL_LINE 6:current_media never will be NVHALMEDIA_NAND +// goto exit; // LCOV_EXCL_LINE 6:current_media never will be NVHALMEDIA_NAND +// } + + if ((hdr->command == BKUP_CMD_WRITE || hdr->command == BKUP_CMD_FILL) && + (hdr->offset != 0 || hdr->size != (uint32_t)query_result->size)) { + // partial request +// if ((current_media == NVHALMEDIA_CACHEDRAM && +// (query_result->nand || query_result->backup_dram)) || +// (current_media == NVHALMEDIA_BACKUPDRAM && query_result->nand)) { + if (query_result->nand || query_result->backup_dram) { + memset(&update_hdr, 0, sizeof(update_hdr)); + BkupStrlcpy(update_hdr.item_name, hdr->item_name, sizeof(update_hdr.item_name)); + update_hdr.command = BKUP_CMD_COPY_INNER; +// update_hdr.src_media = current_media; + munmap(*rcv_buf, *rcv_size); + *rcv_size = 0; + // LCOV_EXCL_BR_START 5: mmap's error case. + if ((*rcv_buf = BkupAnonMmap(sizeof(bkup_protocol_header_t))) == MAP_FAILED) { + // LCOV_EXCL_BR_STOP 5: mmap's error case. + // LCOV_EXCL_START 5: mmap's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mmap:%s", strerror(errno)); + goto exit; + // LCOV_EXCL_STOP 5: mmap's error case. + } + *rcv_size = sizeof(bkup_protocol_header_t); + memcpy(*rcv_buf, &update_hdr, sizeof(update_hdr)); + } + } + ret = 0; + +exit: + return ret; +} + +/** + * Main callback handler + */ +EFrameworkunifiedStatus BkupHandler(HANDLE h_app) { + EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK; + uint32_t rcv_size = 0; + char *rcv_buf = NULL; + bkup_protocol_header_t *hdr; + bkup_query_result_t query_result; + bool hold_rcv_buf = false; + int ret = 0; + bkup_response_t response_nsfw = {BkupSetResponseNsfw, h_app}; + + if ((rcv_size = FrameworkunifiedGetMsgLength(h_app)) < sizeof(bkup_protocol_header_t)) { // LCOV_EXCL_BR_LINE 4: NSFW error case. + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedGetMsgLength: size fail:%d", rcv_size); + e_status = eFrameworkunifiedStatusFail; + goto exit; + // LCOV_EXCL_STOP 4: NSFW error case. + } + + rcv_buf = reinterpret_cast<char *>(mmap(NULL, rcv_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0)); + if (rcv_buf == MAP_FAILED) { // LCOV_EXCL_BR_LINE 5: mmap's error case. + // LCOV_EXCL_START 5: mmap's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + rcv_size = 0; + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mmap:%s", strerror(errno)); + e_status = eFrameworkunifiedStatusInvldParam; + goto exit; + // LCOV_EXCL_STOP 5: mmap's error case. + } + + // LCOV_EXCL_BR_START 4: NSFW error case. + if ((e_status = FrameworkunifiedGetMsgDataOfSize(h_app, rcv_buf, rcv_size, eSMRRelease)) != eFrameworkunifiedStatusOK) { + // LCOV_EXCL_BR_STOP 4: NSFW error case. + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedGetMsgDataOfSize:%d", e_status); + goto exit; + // LCOV_EXCL_STOP 4: NSFW error case. + } + + hdr = reinterpret_cast<bkup_protocol_header_t *>(rcv_buf); + if (hdr->command < 0 || hdr->command >= BKUP_CMD_MAX) { // LCOV_EXCL_BR_LINE 6:double check + // LCOV_EXCL_START 6:double check + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Invalid command:%d", hdr->command); + e_status = eFrameworkunifiedStatusInvldParam; + goto exit; + // LCOV_EXCL_STOP 6:double check + } + + if (hdr->command == BKUP_CMD_READ_NUM || hdr->command == BKUP_CMD_SIZE_NUM) { + // LCOV_EXCL_BR_START 11:unexpected branch + if (BkupParamGetNumid(hdr->num_id, &query_result, hdr->item_name, sizeof(hdr->item_name)) < 0) { + // LCOV_EXCL_BR_STOP 11:unexpected branch + // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Invalid num_id:%d", hdr->num_id); + // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h" + e_status = eFrameworkunifiedStatusInvldParam; + goto exit; + } + + if (hdr->command == BKUP_CMD_READ_NUM) { + hdr->command = BKUP_CMD_READ; + } + } else { + if (BkupParamGet(hdr->item_name, &query_result) < 0) { // LCOV_EXCL_BR_LINE 11:unexpected branch + // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Invalid item_name:%s", hdr->item_name != 0 ? hdr->item_name : NULL); + // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h" + e_status = eFrameworkunifiedStatusInvldParam; + goto exit; + } + } + + if (hdr->command == BKUP_CMD_READ || hdr->command == BKUP_CMD_WRITE || hdr->command == BKUP_CMD_FILL) { + if (hdr->size == 0) { + // do nothing + goto exit; + } + if (hdr->size + hdr->offset > (uint32_t)query_result.size) { + // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Invalid size+offset:%d+%d", hdr->size, hdr->offset); + // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h" + e_status = eFrameworkunifiedStatusInvldParam; + goto exit; + } + } + + // LCOV_EXCL_BR_START 6: g_bkup_internal_state will not be BKUP_STATE_INIT + if (g_bkup_internal_state == BKUP_STATE_INIT) { + // LCOV_EXCL_BR_STOP 6: g_bkup_internal_state will not be BKUP_STATE_INIT + // LCOV_EXCL_START 6: same as above + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + e_status = eFrameworkunifiedStatusErrOther; + goto exit; + // LCOV_EXCL_STOP 6: same as above + } + // LCOV_EXCL_BR_START 6: g_bkup_internal_state will not be BKUP_STATE_TERM + if (g_bkup_internal_state == BKUP_STATE_TERM) { + // LCOV_EXCL_BR_STOP 6: g_bkup_internal_state will not be BKUP_STATE_TERM + // LCOV_EXCL_START 6: same as above + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + e_status = eFrameworkunifiedStatusExit; + goto exit; + // LCOV_EXCL_STOP 6: same as above + } + + if (hdr->command == BKUP_CMD_SIZE || hdr->command == BKUP_CMD_SIZE_NUM) { + // LCOV_EXCL_BR_START 11:unexpected branch + BkupSetResponseNsfw(h_app, &query_result.size, sizeof(query_result.size), eFrameworkunifiedStatusOK); + // LCOV_EXCL_BR_STOP 11:unexpected branch + } else if (hdr->command == BKUP_CMD_CHECK) { + if (query_result.nand) { + // LCOV_EXCL_BR_START 11:unexpected branch +// ret = BkupCmdCheck(&response_nsfw, NVHALMEDIA_NAND, rcv_buf, &query_result); + ret = BkupCmdCheck(&response_nsfw, rcv_buf, &query_result); + // LCOV_EXCL_BR_STOP 11:unexpected branch + } else if (query_result.backup_dram) { + // LCOV_EXCL_BR_START 11:unexpected branch +// ret = BkupCmdCheck(&response_nsfw, NVHALMEDIA_BACKUPDRAM, rcv_buf, &query_result); + ret = BkupCmdCheck(&response_nsfw, rcv_buf, &query_result); + // LCOV_EXCL_BR_STOP 11:unexpected branch + } else if (query_result.cache_dram) { + // LCOV_EXCL_BR_START 11:unexpected branch +// ret = BkupCmdCheck(&response_nsfw, NVHALMEDIA_CACHEDRAM, rcv_buf, &query_result); + ret = BkupCmdCheck(&response_nsfw, rcv_buf, &query_result); + // LCOV_EXCL_BR_STOP 11:unexpected branch + } else { + ret = -3; + } + + if (ret == -1) { + // not exists + // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Not exists:%s", hdr->item_name != 0 ? hdr->item_name : NULL); + // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h" + e_status = eFrameworkunifiedStatusFileLoadError; + } else if (ret == -2) { + // size error + e_status = eFrameworkunifiedStatusAccessError; + } else if (ret == -3) { + e_status = eFrameworkunifiedStatusFail; + } + } else { + /* + * Cache DRAM + */ + if (query_result.cache_dram) { + // LCOV_EXCL_BR_START 11:unexpected branch +// ret = BkupHandlerFile(&response_nsfw, NVHALMEDIA_CACHEDRAM, rcv_buf, &query_result); + ret = BkupHandlerFile(&response_nsfw, rcv_buf, &query_result); + // LCOV_EXCL_BR_STOP 11:unexpected branch + if (ret > 0) { + if (hdr->command == BKUP_CMD_READ) { + goto exit; + } + // LCOV_EXCL_BR_START 5: mmap's error case. +// if (BkupTweakCommand(NVHALMEDIA_CACHEDRAM, &rcv_buf, + if (BkupTweakCommand(&rcv_buf, + reinterpret_cast<int *>(&rcv_size), + &query_result) < 0) { + // LCOV_EXCL_BR_STOP 5: mmap's error case. + // LCOV_EXCL_START 5: mmap's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + e_status = eFrameworkunifiedStatusFail; + goto exit; + // LCOV_EXCL_STOP 5: mmap's error case. + } + hdr = reinterpret_cast<bkup_protocol_header_t *>(rcv_buf); + } + } + + /* + * Backup DRAM + */ + if (query_result.backup_dram) { + // LCOV_EXCL_BR_START 11:unexpected branch +// ret = BkupHandlerFile(&response_nsfw, NVHALMEDIA_BACKUPDRAM, rcv_buf, &query_result); + ret = BkupHandlerFile(&response_nsfw, rcv_buf, &query_result); + // LCOV_EXCL_BR_STOP 11:unexpected branch + if (ret > 0) { + if (hdr->command == BKUP_CMD_READ) { + goto exit; + } + // LCOV_EXCL_BR_START 5: mmap's error case. +// if (BkupTweakCommand(NVHALMEDIA_BACKUPDRAM, &rcv_buf, + if (BkupTweakCommand(&rcv_buf, + reinterpret_cast<int *>(&rcv_size), + &query_result) < 0) { + // LCOV_EXCL_BR_STOP 5: mmap's error case. + // LCOV_EXCL_START 5: mmap's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + e_status = eFrameworkunifiedStatusFail; + goto exit; + // LCOV_EXCL_STOP 5: mmap's error case. + } + hdr = reinterpret_cast<bkup_protocol_header_t *>(rcv_buf); + } + } + + /* + * NAND + */ + if (query_result.nand) { + bkup_itc_message_t snd_msg; + + if ((hdr->command == BKUP_CMD_READ) || (hdr->command == BKUP_CMD_DELETE) || (query_result.sync) || (ret == 0)) { + /* + * operation offload + */ + const char *client_name; + char system_info[MAX_SYS_INFO_SIZE]; + + if (g_bkup_nand_mqd == -1) { + // LCOV_EXCL_BR_START 5: mq_open's error case. + if ((g_bkup_nand_mqd = BkupItcMqopen("/" BKUP_THREAD_NAND, O_WRONLY | O_CREAT | O_NONBLOCK)) < 0) { + // LCOV_EXCL_BR_STOP 5: mq_open's error case. + // LCOV_EXCL_START 5: mq_open's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mq_open:%s", strerror(errno)); + exit(EXIT_FAILURE); + // LCOV_EXCL_STOP 5: mq_open's error case. + } + } + + if ((client_name = FrameworkunifiedGetMsgSrc(h_app)) == NULL) { // LCOV_EXCL_BR_LINE 4: NSFW error case. + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "invalid client_name"); + e_status = eFrameworkunifiedStatusFail; + goto exit; + // LCOV_EXCL_STOP 4: NSFW error case. + } + FrameworkunifiedGetSystemInfo(h_app, system_info); // LCOV_EXCL_BR_LINE 11:unexpected branch. + + memset(&snd_msg, 0, sizeof(snd_msg)); + BkupStrlcpy(snd_msg.nand.client_name, client_name, sizeof(snd_msg.nand.client_name)); + snd_msg.nand.seq_id = static_cast<uint32_t>(strtoul(system_info, NULL, 16)); + snd_msg.nand.rcv_buf = rcv_buf; + snd_msg.nand.rcv_size = rcv_size; + + // LCOV_EXCL_BR_START 5: mq_send's error case. + if (mq_send(g_bkup_nand_mqd, reinterpret_cast<char *>(&snd_msg), sizeof(snd_msg), 0) < 0) { + // LCOV_EXCL_BR_STOP 5: mq_send's error case. + // LCOV_EXCL_START 5: mq_send's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + int save_errno = errno; + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mq_send:%s", strerror(errno)); + e_status = eFrameworkunifiedStatusFail; + if (save_errno == EAGAIN) { + kill(g_bkup_nand_tid, SIGABRT); + } + goto exit; + // LCOV_EXCL_STOP 5: mq_send's error case. + } + FrameworkunifiedSetDeferredSyncResponse(h_app); // LCOV_EXCL_BR_LINE 11:unexpected branch. + hold_rcv_buf = true; + } else { + /* + * delay write + */ + if (g_bkup_delay_mqd == -1) { + // LCOV_EXCL_BR_START 5: mq_open's error case. + if ((g_bkup_delay_mqd = BkupItcMqopen("/" BKUP_THREAD_DELAY, O_WRONLY | O_CREAT | O_NONBLOCK)) < 0) { + // LCOV_EXCL_BR_STOP 5: mq_open's error case. + // LCOV_EXCL_START 5: mq_open's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mq_open:%s", strerror(errno)); + exit(EXIT_FAILURE); + // LCOV_EXCL_STOP 5: mq_open's error case. + } + } + + memset(&snd_msg, 0, sizeof(snd_msg)); + +// snd_msg.delay.terminate = false; + snd_msg.delay.cmd = BKUP_DELAY_CMD_REGIST; + + BkupStrlcpy(snd_msg.delay.item_name, hdr->item_name, sizeof(snd_msg.delay.item_name)); + + // LCOV_EXCL_BR_START 5: mq_send's error case. + if (mq_send(g_bkup_delay_mqd, reinterpret_cast<char *>(&snd_msg), sizeof(snd_msg), 0) < 0) { + // LCOV_EXCL_BR_STOP 5: mq_send's error case. + // LCOV_EXCL_START 5: mq_send's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + int save_errno = errno; + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mq_send:%s", strerror(errno)); + e_status = eFrameworkunifiedStatusFail; + if (save_errno == EAGAIN) { + kill(g_bkup_delay_tid, SIGABRT); + } + goto exit; + // LCOV_EXCL_STOP 5: mq_send's error case. + } + } + } + } + +exit: + if (hold_rcv_buf == false && rcv_buf != MAP_FAILED) { // LCOV_EXCL_BR_LINE 5: mmap's error case + munmap(rcv_buf, rcv_size); + } + return e_status; +} + + +/** + * Power callback handler + */ +EFrameworkunifiedStatus bkup_power_handler(HANDLE hApp) { + EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK; + uint32_t rcv_size = 0; + T_SS_SM_UserModeOnOffNotification_StructType power_status; + + if ((rcv_size = FrameworkunifiedGetMsgLength(hApp)) != sizeof(power_status)) { // LCOV_EXCL_BR_START 4: NSFW error case + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + // LCOV_EXCL_START 4: NSFW error case + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedGetMsgLength: size fail:%d", rcv_size); + eStatus = eFrameworkunifiedStatusFail; + goto exit; + // LCOV_EXCL_STOP 4: NSFW error case + } + + // LCOV_EXCL_BR_START 4: NSFW error case + if ((eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &power_status, rcv_size, eSMRRelease)) != eFrameworkunifiedStatusOK) { + // LCOV_EXCL_BR_STOP 4: NSFW error case + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + // LCOV_EXCL_START 4: NSFW error case + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedGetMsgDataOfSize:%d", eStatus); + goto exit; + // LCOV_EXCL_STOP 4: NSFW error case + } + + if (g_bkup_internal_state != BKUP_STATE_NORMAL) { // LCOV_EXCL_BR_LINE 6:double check + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + // LCOV_EXCL_START 6:double check + FRAMEWORKUNIFIEDLOG(ZONE_WARN, __func__, "Invalid state:%d", g_bkup_internal_state); + goto exit; + // LCOV_EXCL_STOP 6:double check + } + + if (power_status.isUserModeOn == FALSE) { + bkup_itc_message_t snd_msg; + + if (g_bkup_delay_mqd == -1) { + // LCOV_EXCL_BR_START 5: mq_open's error case. + if ((g_bkup_delay_mqd = BkupItcMqopen("/" BKUP_THREAD_DELAY, O_WRONLY|O_CREAT|O_NONBLOCK)) < 0) { + // LCOV_EXCL_BR_STOP 5: mq_open's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + // LCOV_EXCL_START 5: mq_open's error case. + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mq_open:%s", strerror(errno)); + eStatus = eFrameworkunifiedStatusFail; + goto exit; + // LCOV_EXCL_STOP 5: mq_open's error case. + } + } + + memset(&snd_msg, 0, sizeof(snd_msg)); + snd_msg.delay.cmd = BKUP_DELAY_CMD_PRE_ACCOFF; + + // LCOV_EXCL_BR_START 5: mq_send's error case. + if (mq_send(g_bkup_delay_mqd, (char *)&snd_msg, sizeof(snd_msg), 0) < 0) { + // LCOV_EXCL_BR_START 5: mq_send's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + // LCOV_EXCL_START 5: mq_send's error case. + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mq_send:%s", strerror(errno)); + eStatus = eFrameworkunifiedStatusFail; + goto exit; + // LCOV_EXCL_STOP 5: mq_send's error case. + } + } + +exit: + return eStatus; +} + + +/** + * thread's response + */ +static int BkupSetResponseThread(void *opt, void *buf, int size, EFrameworkunifiedStatus ret_value) { + HANDLE response_mq; + char invoker_name[MAX_QUEUE_NAME_SIZE]; + bkup_itc_message_t *msg = reinterpret_cast<bkup_itc_message_t *>(opt); + EFrameworkunifiedStatus e_status; + // LCOV_EXCL_BR_START 11:unexpected branch. + McCreateInvokerName(msg->nand.client_name, 0, invoker_name, sizeof(invoker_name)); + // LCOV_EXCL_BR_STOP 11:unexpected branch. + + if (g_bkup_response_mq == NULL) { + g_bkup_response_mq = new g_bkup_response_mq_t; // LCOV_EXCL_BR_LINE 11:except,C++ operator + } + g_bkup_response_mq_t::iterator mq_it = g_bkup_response_mq->find(invoker_name); // LCOV_EXCL_BR_LINE 11:except,C++ STL + if (mq_it != g_bkup_response_mq->end()) { // LCOV_EXCL_BR_LINE 11:except,C++ STL + response_mq = mq_it->second; // LCOV_EXCL_BR_LINE 11:except,C++ STL + } else { + if ((response_mq = McOpenSyncSender(invoker_name)) == NULL) { // LCOV_EXCL_BR_LINE 4: NSFW error case. + // LCOV_EXCL_START 4: NSFW error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mcOpenSyncSender"); + return -1; + // LCOV_EXCL_STOP 4: NSFW error case. + } + g_bkup_response_mq->insert(std::make_pair(invoker_name, response_mq)); // LCOV_EXCL_BR_LINE 11:except,C++ STL + } + + // LCOV_EXCL_BR_START 11:unexpected branch. + e_status = McSendSyncResponse(response_mq, MN_NS_BACKUPMGR, BACKUP_CID, msg->nand.seq_id, ret_value, size, buf); + // LCOV_EXCL_BR_STOP 11:unexpected branch. + return (e_status == eFrameworkunifiedStatusOK) ? 0 : -1; // LCOV_EXCL_BR_LINE 11:unexpected branch +} + +/** + * NAND Thread + */ +void *BkupNandThread(void *arg) { + mqd_t mqd; + struct pollfd fds[1]; + bkup_itc_message_t rcv_msg; + bkup_protocol_header_t *hdr; + bkup_query_result_t query_result; + bkup_response_t response_thread = {BkupSetResponseThread, NULL}; + + signal_handler p_signal = SignalHandlerFuncForMsgHandleThread; + signal(SIGUSR1, p_signal); + g_nand_thread_id = pthread_self(); + + if (prctl(PR_SET_NAME, BKUP_THREAD_NAND) < 0) { // LCOV_EXCL_BR_LINE 5: prctl's error case. + // LCOV_EXCL_START 5: prctl's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "prctl(PR_SET_NAME):%s", strerror(errno)); + exit(EXIT_FAILURE); + // LCOV_EXCL_STOP 5: prctl's error case. + } + + // LCOV_EXCL_BR_START 5: mq_open's error case. + if ((mqd = BkupItcMqopen("/" BKUP_THREAD_NAND, O_RDONLY | O_CREAT)) < -1) { + // LCOV_EXCL_BR_STOP 5: mq_open's error case. + // LCOV_EXCL_START 5: mq_open's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mq_open:%s", strerror(errno)); + exit(EXIT_FAILURE); + // LCOV_EXCL_STOP 5: mq_open's error case. + } + g_bkup_nand_tid = static_cast<int>(syscall(__NR_gettid)); + + fds[0].fd = mqd; + fds[0].events = POLLIN; + + while (1) { + int ret = poll(fds, sizeof(fds) / sizeof(struct pollfd), -1); // LCOV_EXCL_BR_LINE 11:unexpected branch + if (ret < 0) { // LCOV_EXCL_BR_LINE 5: poll's error case. + // LCOV_EXCL_START 5: poll's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + if (errno == EINTR) { + continue; + } + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "poll errno:%s", strerror(errno)); + // LCOV_EXCL_STOP 5: poll's error case. + } else { + if ((fds[0].revents & POLLIN) != 0) { + // LCOV_EXCL_BR_START 5: mq_receive's error case. + if (mq_receive(mqd, reinterpret_cast<char *>(&rcv_msg), sizeof(rcv_msg), NULL) < 0) { + // LCOV_EXCL_BR_STOP 5: mq_receive's error case. + // LCOV_EXCL_START 5: mq_receive's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + if (errno != EINTR) { + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mq_receive:%s", strerror(errno)); + } + continue; + // LCOV_EXCL_STOP 5: mq_receive's error case. + } + hdr = reinterpret_cast<bkup_protocol_header_t *>(rcv_msg.nand.rcv_buf); + BkupParamGet(hdr->item_name, &query_result); // LCOV_EXCL_BR_LINE 11:unexpected branch + response_thread.opt = &rcv_msg; + // LCOV_EXCL_BR_START 11:unexpected branch +// ret = BkupHandlerFile(&response_thread, NVHALMEDIA_NAND, rcv_msg.nand.rcv_buf, &query_result); + ret = BkupHandlerFile(&response_thread, rcv_msg.nand.rcv_buf, &query_result); + // LCOV_EXCL_BR_STOP 11:unexpected branch + + munmap(rcv_msg.nand.rcv_buf, rcv_msg.nand.rcv_size); + } + } + } + + return NULL; +} + +/* + * delay backup thread + */ +typedef struct { + int fd; + std::string name; +} bkup_delay_t; // LCOV_EXCL_BR_LINE 11:except,C++ STL + +static int BkupDelayTimerAdd(int efd, const char *item_name, time_t backup_cycle) { + int ret = -1; + struct epoll_event ev; + bkup_delay_t *timer_ev = new bkup_delay_t; // LCOV_EXCL_BR_LINE 11:except,C++ operator + struct itimerspec itime; + + if ((timer_ev->fd = timerfd_create(CLOCK_MONOTONIC, 0)) < 0) { // LCOV_EXCL_BR_LINE 5: timerfd_create's error case. + // LCOV_EXCL_START 5: timerfd_create's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "timerfd_create:%s", strerror(errno)); + goto exit; + // LCOV_EXCL_STOP 5: timerfd_create's error case. + } + timer_ev->name = item_name; // LCOV_EXCL_BR_LINE 11:except,C++ STL + + ev.events = EPOLLIN; + ev.data.ptr = timer_ev; + if (epoll_ctl(efd, EPOLL_CTL_ADD, timer_ev->fd, &ev) < 0) { // LCOV_EXCL_BR_LINE 5: epoll_ctl's error case. + // LCOV_EXCL_START 5: epoll_ctl's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "epoll_ctl:%s", strerror(errno)); + goto exit; + // LCOV_EXCL_STOP 5: epoll_ctl's error case. + } + + memset(&itime, 0, sizeof(itime)); + itime.it_value.tv_sec = backup_cycle; + itime.it_interval.tv_sec = backup_cycle; + + if (timerfd_settime(timer_ev->fd, 0, &itime, NULL) < 0) { // LCOV_EXCL_BR_LINE 5: timerfd_settime's error case. + // LCOV_EXCL_START 5: timerfd_settime's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "timerfd_settime:%s", strerror(errno)); + epoll_ctl(efd, EPOLL_CTL_DEL, timer_ev->fd, &ev); + goto exit; + // LCOV_EXCL_STOP 5: timerfd_settime's error case. + } + ret = 0; + +exit: + if (ret < 0) { // LCOV_EXCL_BR_LINE 5: C API's error case. + // LCOV_EXCL_START 5: C API's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + if (timer_ev->fd >= 0) { + if (close(timer_ev->fd) < 0) { + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "timerfd_settime:%s", strerror(errno)); + } + } + delete timer_ev; + } + // LCOV_EXCL_STOP 5: C API's error case. + return ret; +} + +static uint64_t *g_bkup_syncreq; +static pthread_rwlock_t g_syncreq_rwlock = PTHREAD_RWLOCK_INITIALIZER; +#define BKUP_SYNCREQ_SIZE (4096) +#define BKUP_SYNCREQ_ID_MAX (BKUP_SYNCREQ_SIZE * 8 - 1) +#define BKUP_SYNCREQ_NAME "syncreq" + +static int BkupSyncreqInit(void) { + int ret = -1; + char *map; + + map = reinterpret_cast<char *>(mmap(NULL, BKUP_SYNCREQ_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0)); + if (map == MAP_FAILED) { // LCOV_EXCL_BR_LINE 5: mmap's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + // LCOV_EXCL_START 5: mmap's error case. + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mmap failed"); + goto exit; + // LCOV_EXCL_STOP 5: mmap's error case. + } + g_bkup_syncreq = reinterpret_cast<uint64_t *>(map); + memset(g_bkup_syncreq, 0, BKUP_SYNCREQ_SIZE); + + pthread_rwlock_wrlock(&g_syncreq_rwlock); +// BkupBufferWriteToNv(NVHALMEDIA_BACKUPDRAM, BKUP_SYNCREQ_NAME, + BkupBufferWriteToNv(BKUP_SYNCREQ_NAME, + reinterpret_cast<char *>(g_bkup_syncreq), + BKUP_SYNCREQ_SIZE, NULL); + pthread_rwlock_unlock(&g_syncreq_rwlock); + ret = 0; + +exit: + return ret; +} + +static void BkupSyncreqTerm(void) { + if (g_bkup_syncreq != NULL) { // LCOV_EXCL_BR_LINE 6:g_bkup_syncreq will not be NULL + munmap(g_bkup_syncreq, BKUP_SYNCREQ_SIZE); + g_bkup_syncreq = NULL; + } +} + +static int BkupSyncreqSet(int id) { + if (g_bkup_syncreq == NULL) { // LCOV_EXCL_BR_LINE 6:g_bkup_syncreq will not be NULL + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + return -1; // LCOV_EXCL_LINE 5: mmap's error case. + } + if (id > BKUP_SYNCREQ_ID_MAX) { + return -1; + } + if (!(*(g_bkup_syncreq + id / 64) & (1ULL << (id % 64)))) { + *(g_bkup_syncreq + id / 64) |= (1ULL << (id % 64)); + pthread_rwlock_wrlock(&g_syncreq_rwlock); +// BkupBufferWriteToNv(NVHALMEDIA_BACKUPDRAM, BKUP_SYNCREQ_NAME, + BkupBufferWriteToNv(BKUP_SYNCREQ_NAME, + reinterpret_cast<char *>(g_bkup_syncreq), + BKUP_SYNCREQ_SIZE, NULL); + pthread_rwlock_unlock(&g_syncreq_rwlock); + } + return 0; +} + +static int BkupSyncreqClear(int id) { + if (g_bkup_syncreq == NULL) { // LCOV_EXCL_BR_LINE 6:g_bkup_syncreq will not be NULL + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + return -1; // LCOV_EXCL_LINE 5: mmap's error case. + } + if (id > BKUP_SYNCREQ_ID_MAX) { + return -1; + } + if (*(g_bkup_syncreq + id / 64) & (1ULL << (id % 64))) { + *(g_bkup_syncreq + id / 64) &= ~(1ULL << (id % 64)); + pthread_rwlock_wrlock(&g_syncreq_rwlock); +// BkupBufferWriteToNv(NVHALMEDIA_BACKUPDRAM, BKUP_SYNCREQ_NAME, + BkupBufferWriteToNv(BKUP_SYNCREQ_NAME, + reinterpret_cast<char *>(g_bkup_syncreq), + BKUP_SYNCREQ_SIZE, NULL); + pthread_rwlock_unlock(&g_syncreq_rwlock); + } + + return 0; +} + +static inline int BkupPopcnt64(uint64_t x) { + uint64_t n; + + n = (x >> 1) & 0x7777777777777777ULL; + x = x - n; + n = (n >> 1) & 0x7777777777777777ULL; + x = x - n; + n = (n >> 1) & 0x7777777777777777ULL; + x = x - n; + x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0fULL; + x = x * 0x0101010101010101ULL; + return static_cast<int>(x >> 56); +} + +static int BkupSyncreqSearch(void) { + int i; + + if (g_bkup_syncreq == NULL) { // LCOV_EXCL_BR_LINE 6:g_bkup_syncreq will not be NULL + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + return -1; // LCOV_EXCL_LINE 5: mmap's error case. + } + + for (i = 0; i < static_cast<int>(BKUP_SYNCREQ_SIZE / sizeof(uint64_t)); i++) { + if (*(g_bkup_syncreq + i) != 0) { + uint64_t bits, mrb1; // most right bit 1 + bits = *(g_bkup_syncreq + i); + mrb1 = bits & (-bits); + return i * 64 + BkupPopcnt64(mrb1 - 1); + } + } + + return -1; +} + +static void BkupSyncreqDone(bool skip_cache) { + int id; + uint64_t start, end; + + start = BkupTimerReal(); + + while ((id = BkupSyncreqSearch()) >= 0) { + char item_name[64]; + bkup_query_result_t query_result; + + if (BkupParamGetNumid(id, &query_result, item_name, sizeof(item_name)) < 0) { + // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Invalid num_id:%d", id); + // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h" + } else { + if (query_result.cache_dram) { + if (!skip_cache) { + BkupMediaCopyFromNv(query_result.category_name, item_name, +// NVHALMEDIA_CACHEDRAM, NVHALMEDIA_NAND, NULL, + NULL, + NULL); + } + } else if (query_result.backup_dram) { + // LCOV_EXCL_BR_START 11:unexpected branch + BkupMediaCopyFromNv(query_result.category_name, item_name, +// NVHALMEDIA_BACKUPDRAM, NVHALMEDIA_NAND, NULL, NULL); + NULL, NULL); + // LCOV_EXCL_BR_STOP 11:unexpected branch + } + } + + BkupSyncreqClear(id); // LCOV_EXCL_BR_LINE 11:unexpected branch + + } + + end = BkupTimerReal(); + // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "spent:%" PRIu64 ".%06" PRIu64 "ms", + static_cast<uint64_t>((end - start) / 1000000), + static_cast<uint64_t>((end - start) % 1000000)); + // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h" +} + +void BkupSyncreqRestart(void) { + char *map; + + map = reinterpret_cast<char *>(mmap(NULL, BKUP_SYNCREQ_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0)); + if (map == MAP_FAILED) { // LCOV_EXCL_BR_LINE 5: mmap's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + // LCOV_EXCL_START 5: mmap's error case. + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mmap failed"); + goto exit; + // LCOV_EXCL_STOP 5: mmap's error case. + } + g_bkup_syncreq = reinterpret_cast<uint64_t *>(map); + +// if (BkupBufferReadFromNv(NVHALMEDIA_BACKUPDRAM, BKUP_SYNCREQ_NAME, + if (BkupBufferReadFromNv(BKUP_SYNCREQ_NAME, + reinterpret_cast<char *>(g_bkup_syncreq), + BKUP_SYNCREQ_SIZE, NULL) < 0) { + goto exit; + } + BkupSyncreqDone(true); + BkupSyncreqTerm(); + +exit: + return; +} + +void *BkupDelayThread(void *arg) { + mqd_t mqd; + int efd; + struct epoll_event ev; + bkup_delay_t *mq_ev; + bkup_itc_message_t rcv_msg; + std::map<std::string, int> delay_req; // LCOV_EXCL_BR_LINE 11:except,C++ STL + + signal_handler p_signal = SignalHandlerFuncForMsgHandleThread; + signal(SIGUSR1, p_signal); + g_delay_thread_id = pthread_self(); + + + if (prctl(PR_SET_NAME, BKUP_THREAD_DELAY) < 0) { // LCOV_EXCL_BR_LINE 5: prctl's error case. + // LCOV_EXCL_START 5: prctl's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "prctl(PR_SET_NAME):%s", strerror(errno)); + exit(EXIT_FAILURE); + // LCOV_EXCL_STOP 5: prctl's error case. + } + + // LCOV_EXCL_BR_START 5: mq_open's error case. + if ((mqd = BkupItcMqopen("/" BKUP_THREAD_DELAY, O_RDONLY | O_CREAT)) < 0) { + // LCOV_EXCL_BR_STOP 5: mq_open's error case. + // LCOV_EXCL_START 5: mq_open's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mq_open:%s", strerror(errno)); + exit(EXIT_FAILURE); + // LCOV_EXCL_STOP 5: mq_open's error case. + } + + if ((efd = epoll_create(MAX_FD_EPOLL)) < 0) { // LCOV_EXCL_BR_LINE 5: epoll_create's error case. + // LCOV_EXCL_START 5: epoll_create's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "epoll_create:%s", strerror(errno)); + exit(EXIT_FAILURE); + // LCOV_EXCL_STOP 5: epoll_create's error case. + } + g_bkup_delay_tid = static_cast<int>(syscall(__NR_gettid)); + + mq_ev = new bkup_delay_t; // LCOV_EXCL_BR_LINE 11:except,C++ operator + mq_ev->fd = static_cast<int>(mqd); + mq_ev->name = "mq"; // LCOV_EXCL_BR_LINE 11:except,C++ STL + + ev.events = EPOLLIN; + ev.data.ptr = mq_ev; + // LCOV_EXCL_BR_START 5: epoll_ctl's error case. + if (epoll_ctl(efd, EPOLL_CTL_ADD, static_cast<int>(mqd), &ev) < 0) { + // LCOV_EXCL_BR_STOP 5: epoll_ctl's error case. + // LCOV_EXCL_START 5: epoll_ctl's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "epoll_ctl:%s", strerror(errno)); + exit(EXIT_FAILURE); + // LCOV_EXCL_STOP 5: epoll_ctl's error case. + } + + while (1) { + struct epoll_event events[MAX_FD_EPOLL]; + int nfds; + + nfds = epoll_wait(efd, events, MAX_FD_EPOLL, -1); // LCOV_EXCL_BR_LINE 11:unexpected branch + if (nfds < 0) { // LCOV_EXCL_BR_LINE 5: epoll_wait's error case. + // LCOV_EXCL_START 5: epoll_wait's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + if (errno != EINTR) { + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "epoll_wait:%s", strerror(errno)); + } + continue; + // LCOV_EXCL_STOP 5: epoll_wait's error case. + } + + for (int i = 0; i < nfds; i++) { + bkup_delay_t *cur_ev = reinterpret_cast<bkup_delay_t *>(events[i].data.ptr); + + if (cur_ev->fd == mqd) { + /* + * mq + */ + // LCOV_EXCL_BR_START 5: mq_receive's error case. + if (mq_receive(mqd, reinterpret_cast<char *>(&rcv_msg), sizeof(rcv_msg), NULL) < 0) { + // LCOV_EXCL_BR_STOP 5: mq_receive's error case. + // LCOV_EXCL_START 5: mq_receive's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + if (errno != EINTR) { + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mq_receive:%s", strerror(errno)); + } + continue; + // LCOV_EXCL_STOP 5: mq_receive's error case. + } + +#if 0 + if (rcv_msg.delay.terminate) { + // terminate request + // shutdown sync + BkupSyncreqDone(false); // LCOV_EXCL_BR_LINE 11:unexpected branch + + for (std::map<std::string, int>::iterator i = delay_req.begin(); i != delay_req.end(); ++i) { + i->second = 0; // LCOV_EXCL_BR_LINE 11:except,C++ STL + } + + // terminate finish response + int64_t term_event = 1; + // LCOV_EXCL_BR_START 5: write's error case. + if (write(rcv_msg.delay.event_fd, &term_event, sizeof(term_event)) < 0) { + // LCOV_EXCL_BR_STOP 5: write's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "write:%s", strerror(errno)); // LCOV_EXCL_LINE 5: write's error case. + } + } else { + // delay request + bkup_query_result_t query_result; + BkupParamGet(rcv_msg.delay.item_name, &query_result); // LCOV_EXCL_BR_LINE 11:unexpected branch + + if (query_result.backup_cycle > 0) { // LCOV_EXCL_BR_LINE 11:unexpected branch + if (delay_req.find(rcv_msg.delay.item_name) != delay_req.end()) { // LCOV_EXCL_BR_LINE 11:except,C++ STL + delay_req[rcv_msg.delay.item_name]++; // LCOV_EXCL_BR_LINE 11:except,C++ STL + } else { + // LCOV_EXCL_BR_START 11:unexpected branch + BkupDelayTimerAdd(efd, rcv_msg.delay.item_name, query_result.backup_cycle); + // LCOV_EXCL_BR_STOP 11:unexpected branch + delay_req[rcv_msg.delay.item_name] = 1; // LCOV_EXCL_BR_LINE 11:unexpected branch + } + + if (BkupSyncreqSet(query_result.id) < 0) { + // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Invalid num_id:%d", query_result.id); + // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h" + } + } else { + // write to ACC OFF + bkup_query_result_t query_result; + if (BkupParamGet(rcv_msg.delay.item_name, &query_result) < 0) { // LCOV_EXCL_BR_LINE 11:except,C++ STL + // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Invalid item_name:%s", + rcv_msg.delay.item_name != 0 ? rcv_msg.delay.item_name : NULL); + // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h" + } else { + if (BkupSyncreqSet(query_result.id) < 0) { + // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Invalid num_id:%d", query_result.id); + // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h" + } + } + } + } +#endif + switch (rcv_msg.delay.cmd) { + case BKUP_DELAY_CMD_TERM: + case BKUP_DELAY_CMD_PRE_ACCOFF: + /* + * terminate or pre-acc_off request + */ + // shutdown sync + BkupSyncreqDone(false); + + for (std::map<std::string, int>::iterator i = delay_req.begin(); i != delay_req.end(); ++i) { + i->second = 0; + } + + if (rcv_msg.delay.cmd == BKUP_DELAY_CMD_TERM) { + BkupSyncreqTerm(); + + // terminate finish response + int64_t term_event = 1; + // LCOV_EXCL_BR_START 5: write's error case. + if (write(rcv_msg.delay.event_fd, &term_event, sizeof(term_event)) < 0) { + // LCOV_EXCL_BR_STOP 5: write's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "write:%s", strerror(errno)); // LCOV_EXCL_LINE 5: write's error case. + } + } + break; + + case BKUP_DELAY_CMD_REGIST: + // delay regist request + bkup_query_result_t query_result; + BkupParamGet(rcv_msg.delay.item_name, &query_result); + + if (query_result.backup_cycle > 0) { + if (delay_req.find(rcv_msg.delay.item_name) != delay_req.end()) { + delay_req[rcv_msg.delay.item_name]++; + } else { + BkupDelayTimerAdd(efd, rcv_msg.delay.item_name, query_result.backup_cycle); + delay_req[rcv_msg.delay.item_name] = 1; + } + + if (BkupSyncreqSet(query_result.id) < 0) { + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Invalid num_id:%d", query_result.id); + } + } else { + // wite to ACC OFF + bkup_query_result_t query_result; + if (BkupParamGet(rcv_msg.delay.item_name, &query_result) < 0) { // LCOV_EXCL_BR_LINE 6:double check + // LCOV_EXCL_START 6:double check + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Invalid item_name:%s", rcv_msg.delay.item_name); + // LCOV_EXCL_STOP 6:double check + } else { + if (BkupSyncreqSet(query_result.id) < 0) { + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Invalid num_id:%d", query_result.id); + } + } + } + break; + } + + } else { + /* + * timerfd + */ + uint64_t exp; + if (read(cur_ev->fd, &exp, sizeof(exp)) < 0) { // LCOV_EXCL_BR_LINE 5: read's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "read:%s", strerror(errno)); // LCOV_EXCL_LINE 5: read's error case. + } + + if (delay_req[cur_ev->name] > 0) { // LCOV_EXCL_BR_LINE 11:unexpected branch + bkup_query_result_t query_result; + BkupParamGet(cur_ev->name.c_str(), &query_result); // LCOV_EXCL_BR_LINE 11:unexpected branch + + if (query_result.cache_dram) { + // LCOV_EXCL_BR_START 11:unexpected branch + pthread_rwlock_t *src_rwlock = BkupGetRwlock( +// cur_ev->name.c_str(), NVHALMEDIA_CACHEDRAM, &query_result); + cur_ev->name.c_str(), &query_result); + pthread_rwlock_t *dst_rwlock = BkupGetRwlock( +// cur_ev->name.c_str(), NVHALMEDIA_NAND, &query_result); + cur_ev->name.c_str(), &query_result); + BkupMediaCopyFromNv(query_result.category_name, +// cur_ev->name.c_str(), NVHALMEDIA_CACHEDRAM, +// NVHALMEDIA_NAND, src_rwlock, dst_rwlock); + cur_ev->name.c_str(), + src_rwlock, dst_rwlock); + BkupMediaCopyFromNv(query_result.category_name, +// cur_ev->name.c_str(), NVHALMEDIA_CACHEDRAM, +// NVHALMEDIA_NAND, NULL, NULL); + cur_ev->name.c_str(), + NULL, NULL); + // LCOV_EXCL_BR_STOP 11:unexpected branch + } else if (query_result.backup_dram) { + // LCOV_EXCL_BR_START 11:unexpected branch + pthread_rwlock_t *src_rwlock = BkupGetRwlock( +// cur_ev->name.c_str(), NVHALMEDIA_BACKUPDRAM, &query_result); + cur_ev->name.c_str(), &query_result); + pthread_rwlock_t *dst_rwlock = BkupGetRwlock( +// cur_ev->name.c_str(), NVHALMEDIA_NAND, &query_result); + cur_ev->name.c_str(), &query_result); + BkupMediaCopyFromNv(query_result.category_name, +// cur_ev->name.c_str(), NVHALMEDIA_BACKUPDRAM, +// NVHALMEDIA_NAND, src_rwlock, dst_rwlock); + cur_ev->name.c_str(), + src_rwlock, dst_rwlock); + // LCOV_EXCL_BR_STOP 11:unexpected branch + } + delay_req[cur_ev->name] = 0; // LCOV_EXCL_BR_LINE 11:unexpected branch + if (BkupSyncreqClear(query_result.id) < 0) { + // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Invalid num_id:%d", query_result.id); + // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h" + } + } else { + // not update. timer delte + // LCOV_EXCL_BR_START 5: epoll_ctl's error case. + if (epoll_ctl(efd, EPOLL_CTL_DEL, cur_ev->fd, &events[i]) < 0) { + // LCOV_EXCL_BR_STOP 5: epoll_ctl's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "epoll_ctl:%s", strerror(errno)); // LCOV_EXCL_LINE 5: epoll_ctl's error case. + } + if (close(cur_ev->fd) < 0) { // LCOV_EXCL_BR_LINE 5: close's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "close:%s", strerror(errno)); // LCOV_EXCL_LINE 5: close's error case. + } + delay_req.erase(cur_ev->name); // LCOV_EXCL_BR_LINE 11:unexpected branch + delete cur_ev; // LCOV_EXCL_BR_LINE 11:except,C++ operator + } + } + } + } + + return NULL; +} + +/** + * Terminate handler + */ +EFrameworkunifiedStatus BkupTerminateHandler(HANDLE h_app) { + bkup_itc_message_t snd_msg; + int event_fd; + int64_t term_event; + + g_bkup_internal_state = BKUP_STATE_TERM; + + if (g_bkup_delay_mqd == -1) { + // LCOV_EXCL_BR_START 5: mq_open's error case. + if ((g_bkup_delay_mqd = BkupItcMqopen("/" BKUP_THREAD_DELAY, O_WRONLY | O_CREAT | O_NONBLOCK)) < 0) { + // LCOV_EXCL_BR_STOP 5: mq_open's error case. + // LCOV_EXCL_START 5: mq_open's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mq_open:%s", strerror(errno)); + return eFrameworkunifiedStatusFail; + // LCOV_EXCL_STOP 5: mq_open's error case. + } + } + + if ((event_fd = eventfd(0, 0)) < 0) { // LCOV_EXCL_BR_LINE 5: eventfd's error case. + // LCOV_EXCL_START 5: eventfd's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "eventfd:%s", strerror(errno)); + return eFrameworkunifiedStatusFail; + // LCOV_EXCL_STOP 5: eventfd's error case. + } + + memset(&snd_msg, 0, sizeof(snd_msg)); + +// snd_msg.delay.terminate = true; + snd_msg.delay.cmd = BKUP_DELAY_CMD_TERM; + + snd_msg.delay.event_fd = event_fd; + + // LCOV_EXCL_BR_START 5: mq_send's error case. + if (mq_send(g_bkup_delay_mqd, reinterpret_cast<char *>(&snd_msg), sizeof(snd_msg), 0) < 0) { + // LCOV_EXCL_BR_STOP 5: mq_send's error case. + // LCOV_EXCL_START 5: mq_send's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mq_send:%s", strerror(errno)); + return eFrameworkunifiedStatusFail; + // LCOV_EXCL_STOP 5: mq_send's error case. + } + + while (1) { + if (read(event_fd, &term_event, sizeof(term_event)) < 0) { // LCOV_EXCL_BR_LINE 5: read's error case. + // LCOV_EXCL_START 5: read's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + if (errno == EINTR) { + continue; + } + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "read:%s", strerror(errno)); + return eFrameworkunifiedStatusFail; + // LCOV_EXCL_STOP 5: read's error case. + } else { + break; + } + } + if (close(event_fd) < 0) { // LCOV_EXCL_BR_LINE 5: close's error case. + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "close:%s", strerror(errno)); // LCOV_EXCL_LINE 5: close's error case. + } + + return eFrameworkunifiedStatusOK; +} + +/** + * Init handler + */ +EFrameworkunifiedStatus BkupInitHandler(HANDLE h_app) { + BkupSyncreqRestart(); + BkupSyncreqInit(); + + g_bkup_internal_state = BKUP_STATE_NORMAL; + + return eFrameworkunifiedStatusOK; +} |