0da96fcb543655e51d7768b5264f32422ec88a21
[platform/core/telephony/tel-plugin-imc.git] / include / nvm / nvm.h
1 /*
2  * tel-plugin-imc
3  *
4  * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19 #ifndef __NVM_H__
20 #define __NVM_H__
21
22 /* Priority level for suspension of all updates */
23 #define UTA_FLASH_PLUGIN_PRIO_SUSPEND_ALL               4294967295 /* 0xFFFFFFFF */
24
25 /* Priority level for suspension of High priority updates */
26 #define UTA_FLASH_PLUGIN_PRIO_SUSPEND_HIGH              3221225472 /* 0xFFFFFFFF */
27
28 /* Priority level for suspension of all updates of dynamic data */
29 #define UTA_FLASH_PLUGIN_PRIO_SUSPEND_ALL_DYN   1610612735 /* 0x5FFFFFFF */
30
31 /* Priority level for suspension of Medium all updates */
32 #define UTA_FLASH_PLUGIN_PRIO_SUSPEND_MEDIUM    2147483648 /* 0x5FFFFFFF */
33
34 /* Priority level for suspension of Low updates of Medium */
35 #define UTA_FLASH_PLUGIN_PRIO_SUSPEND_LOW               1073741824 /* 0x5FFFFFFF */
36
37 /* Priority level for unsuspension of all updates */
38 #define UTA_FLASH_PLUGIN_PRIO_UNSUSPEND_ALL             0 /* 0x0 */
39
40 #define NVM_FUNCTION_ID_OFFSET          20
41 #define XDRV_INDICATION                         0x04
42
43 #define XDRV_DISABLE                                    "0"
44 #define XDRV_ENABLE                                             "1"
45 #define XDRV_UNSUSPEND                                  "0"
46
47 /* Identifies our group with the xdrv AT command set */
48 #define IUFP_GROUP                                              "43"
49 #define IUFP_GROUP_ID                                   43
50
51 #define IUFP_REGISTER                                   0
52 #define IUFP_REGISTER_STR                               "0"
53
54 #define IUFP_SUSPEND                                    1
55 #define IUFP_SUSPEND_STR                                "1"
56
57 #define IUFP_FLUSH                                              2
58 #define IUFP_FLUSH_STR                                  "2"
59
60 #define IUFP_UPDATE_REQ                         3
61 #define IUFP_UPDATE_REQ_STR                     "3"
62
63 #define IUFP_UPDATE_REQ_ACK                     3
64 #define IUFP_UPDATE_REQ_ACK_STR         "3"
65
66 #define IUFP_UPDATE                                             4
67 #define IUFP_UPDATE_STR                         "4"
68
69 #define IUFP_UPDATE_ACK                         4
70 #define IUFP_UPDATE_ACK_STR                     "4"
71
72 #define IUFP_NO_PENDING_UPDATE          5
73 #define IUFP_NO_PENDING_UPDATE_STR      "5"
74
75 /*  XDRV command was executed without any error */
76 #define XDRV_RESULT_OK                                  0
77
78 typedef enum uta_common_return_codes {
79         UTA_SUCCESS = 0,
80         UTA_FAILURE = -1,
81         UTA_ERROR_OUT_OF_MEMORY = -2,
82         UTA_ERROR_INVALID_HANDLE = -3,
83         UTA_ERROR_OUT_OF_RANGE_PARAM = -4,
84         UTA_ERROR_INVALID_PARAM = -5,
85         UTA_ERROR_TOO_SMALL_BUF_PARAM = -6,
86         UTA_ERROR_NOT_SUPPORTED = -7,
87         UTA_ERROR_TIMEOUT = -8,
88         UTA_ERROR_WRONG_STATE = -9,
89         UTA_ERROR_BAD_FORMAT = -10,
90         UTA_ERROR_INSUFFICIENT_PERMISSIONS = -11,
91         UTA_ERROR_IO_ERROR = -12,
92         UTA_ERROR_OUT_OF_HANDLES = -13,
93         UTA_ERROR_OPERATION_PENDING = -14,
94         UTA_ERROR_SPECIFIC = -100
95 } nvm_return_codes;
96
97 typedef enum nvm_error_numbers {
98         NVM_NO_ERR = 0,
99         NVM_CMD_ERR,
100         NVM_DATA_ERR,
101         NVM_MEM_FULL_ERR,
102         NVM_RES_ERR,
103         NVM_WRITE_ERR,
104         NVM_READ_ERR,
105         NVM_RES_LEN_ERR,
106         NVM_PCKT_ERR,
107         NVM_REG_FAIL_ERR,
108         NVM_DATA_LEN_ERR,
109         NVM_FILE_ERR,
110         NVM_AT_PORT_ERR,
111         NVM_READ_AT_ERR,
112         NVM_DATA_PORT_ERR,
113         NVM_NO_PENDING_UPDATE,
114         NVM_UPDATE,
115         NVM_REGISTER_ERR,
116         NVM_UNKNOWN_ERR
117 } nvm_error;
118
119 int nvm_sum_4_bytes(const char *pos);
120 gboolean nvm_create_nvm_data();
121 nvm_error nvm_process_nv_update(const char *data);
122
123 #endif  /* __NVM_H__ */