2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * @file ss_sm_ram_access.h
19 * @brief This file provides API for get ram information from extension memory
22 /** @addtogroup BaseSystem
25 /** @addtogroup system_service
29 /** @addtogroup rom_access_library
30 * @ingroup system_service
34 #ifndef ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_SYSTEM_SERVICE_SS_SM_RAM_ACCESS_H_
35 #define ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_SYSTEM_SERVICE_SS_SM_RAM_ACCESS_H_
37 #include <native_service/frameworkunified_types.h>
38 #include <native_service/frameworkunified_framework_types.h>
41 * \~english max length of ram product private
43 #define RAM_PRODUCT_PRIVATE_MAX (96)
45 * \~english max length of order file name
47 #define SS_SM_ORDER_NAME_MAX (32)
50 * \~english System management information
54 BOOL isImmediateReset;
55 BOOL needRenotifyStartPrm;
56 uint32_t lastWakeupType;
57 uint32_t lastDramBackupStatus;
58 uint32_t lastResetStatus;
59 char productPrivate[RAM_PRODUCT_PRIVATE_MAX];
60 char order_name[SS_SM_ORDER_NAME_MAX];
62 char signature_out[4];
66 * \~english System wakeup state type
69 RAM_WAKEUP_STATE_DONT_CARE = 0, /* \~english Don't care wakeup state*/
70 RAM_WAKEUP_STATE_BACKUP_NG, /* \~english Wakeup state is backup NG*/
71 RAM_WAKEUP_STATE_BATTERY_DOWN /* \~english Wakeup state is battery down*/
76 * \~english @brief RAM_AccessIf
77 * \~english @par Brief Introduction
78 * Class to provide the function of RAM AccessIf
83 static void* g_m_plock;
84 static void* g_m_bakup_map;
85 static bool g_m_is_first_access;
88 void initRamBackupEnable(RAM_WAKEUP_STATE wup_state);
89 void finalRamBackupEnable(void);
93 * \ingroup RAM_AccessIf
94 * \~english @par Summary:
95 * Obtain the access permission to the system management information.
96 * \~english @param [in] wup_state
97 * RAM_WAKEUP_STATE - System maneger wakeup state type
100 * - RAM_WAKEUP_STATE_DONT_CARE Don't care wakeup state\n
101 * - RAM_WAKEUP_STATE_BACKUP_NG Wakeup state is backup NG\n
102 * - RAM_WAKEUP_STATE_BATTERY_DOWN Wakeup state is battery down
103 * \~english @retval None
104 * \~english @par Precondition:
106 * \~english @par Change in the internal status:
107 * - The change in the internal status does not occur by this API.
108 * \~english @par Conditions of processing failure
110 * \~english @par Classification:
112 * \~english @par Type
114 * \~english @par Detail:
115 * Obtain the access permission to the system management information \n
116 * When the access permission is locked, the API waits for Mutex until the access permission is released. \n
117 * This API is supposed to be called by SystemManager.
118 * \~english @see ~RAM_AccessIf, CL_LockMap, CL_LockGet
120 explicit RAM_AccessIf(RAM_WAKEUP_STATE wup_state = RAM_WAKEUP_STATE_DONT_CARE);
123 * \ingroup ~RAM_AccessIf
124 * \~english @par Summary:
125 * Release the access permission to the system management information.
126 * \~english @param None
127 * \~english @retval None
128 * \~english @par Precondition:
130 * \~english @par Change in the internal status:
131 * - The change in the internal status does not occur by this API.
132 * \~english @par Conditions of processing failure
134 * \~english @par Classification:
136 * \~english @par Type
138 * \~english @par Detail:
139 * Release the access permission to the system management information.\n
140 * \~english @see RAM_AccessIf, CL_LockRelease
145 * \ingroup getRamInfo
146 * \~english @par Summary:
147 * Read the system management information.
148 * \~english @param [out] p_boot_info
149 * RAM_SM_INFO_t * - Destination buffer to read the system management information.
151 * RAM_SM_INFO_t Structure body
154 * char signature_in[4];
155 * BOOL isImmediateReset;
156 * BOOL needRenotifyStartPrm;
157 * uint32_t lastWakeupType;
158 * uint32_t lastDramBackupStatus;
159 * uint32_t lastResetStatus;
160 * char productPrivate[RAM_PRODUCT_PRIVATE_MAX];
161 * char order_name[SS_SM_ORDER_NAME_MAX];
163 * char signature_out[4];
166 * \~english @retval eFrameworkunifiedStatusOK Reading success
167 * \~english @retval eFrameworkunifiedStatusFail Reading failed
168 * \~english @par Precondition:
170 * \~english @par Change in the internal status:
171 * - The change in the internal status does not occur by this API.
172 * \~english @par Conditions of processing failure
173 * - If p_boot_info is NULL [eFrameworkunifiedStatusFail]
174 * - If read data from secondary storage area or /var/local/lib/basesystem/nv/BS/ss/rom_access_library/rwdata/ramdata.dat
175 * failed [eFrameworkunifiedStatusFail]
176 * \~english @par Classification:
178 * \~english @par Type
179 * Sync only(None communication)
180 * \~english @par Detail:
181 * Copy the system information stored in the secondary storage area or
182 * in /var/local/lib/basesystem/nv/BS/ss/rom_access_library/rwdata/ramdata.dat to p_boot_info. \n
183 * \~english @see setRamInfo
185 EFrameworkunifiedStatus getRamInfo(RAM_SM_INFO_t* p_boot_info);
188 * \ingroup setRamInfo
189 * \~english @par Summary:
190 * Write the system management information.
191 * \~english @param [in] p_boot_info
192 * RAM_SM_INFO_t * - Original buffer to write the system management information
194 * RAM_SM_INFO_t Structure body
197 * char signature_in[4];
198 * BOOL isImmediateReset;
199 * BOOL needRenotifyStartPrm;
200 * uint32_t lastWakeupType;
201 * uint32_t lastDramBackupStatus;
202 * uint32_t lastResetStatus;
203 * char productPrivate[RAM_PRODUCT_PRIVATE_MAX];
204 * char order_name[SS_SM_ORDER_NAME_MAX];
206 * char signature_out[4];
209 * \~english @retval eFrameworkunifiedStatusOK Write success
210 * \~english @retval eFrameworkunifiedStatusFail Write failed
211 * \~english @par Precondition:
213 * \~english @par Change in the internal status:
214 * - The change in the internal status does not occur by this API.
215 * \~english @par Conditions of processing failure
216 * - If p_boot_info is NULL [eFrameworkunifiedStatusFail]
217 * - If write data to secondary storage area or /var/local/lib/basesystem/nv/BS/ss/rom_access_library/rwdata/ramdata.dat
218 * failed [eFrameworkunifiedStatusFail]
219 * \~english @par Classification:
221 * \~english @par Type
222 * Sync only(None communication)
223 * \~english @par Detail:
224 * Write the system manegement information stored in p_boot_info to the
225 * secondary storage area or /var/local/lib/basesystem/nv/BS/ss/rom_access_library/rwdata/ramdata.dat. \n
226 * \~english @see getRamInfo
228 EFrameworkunifiedStatus setRamInfo(RAM_SM_INFO_t* p_boot_info);
231 #endif // ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_SYSTEM_SERVICE_SS_SM_RAM_ACCESS_H_
233 /** @}*/ // end of rom_access_library
234 /** @}*/ // end of system_service
235 /** @}*/ // end of BaseSystem