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