Fix path to various non-standard directories
[staging/basesystem.git] / service / system / rom_access_library / library / include / system_service / ss_sm_ram_access.h
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 /**
18  * @file ss_sm_ram_access.h
19  * @brief This file provides API for get ram information from extension memory
20  */
21
22 /** @addtogroup BaseSystem
23  *  @{
24  */
25 /** @addtogroup system_service
26  *  @ingroup BaseSystem
27  *  @{
28  */
29 /** @addtogroup rom_access_library
30  *  @ingroup system_service
31  *  @{
32  */
33
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_
36
37 #include <native_service/frameworkunified_types.h>
38 #include <native_service/frameworkunified_framework_types.h>
39
40 /**
41  * \~english max length of ram product private
42  */
43 #define RAM_PRODUCT_PRIVATE_MAX (96)
44 /**
45  * \~english max length of order file name
46  */
47 #define SS_SM_ORDER_NAME_MAX    (32)
48
49 /**
50  * \~english System management information
51  */
52 typedef struct {
53   char              signature_in[4];
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];
61   BOOL              isErrorReset;
62   char              signature_out[4];
63 }RAM_SM_INFO_t;
64
65 /**
66  * \~english System wakeup state type
67  */
68 typedef enum {
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*/
72 }RAM_WAKEUP_STATE;
73
74 /**
75  * @class RAM_AccessIf
76  * \~english @brief RAM_AccessIf
77  * \~english @par   Brief Introduction
78  *        Class to provide the function of RAM AccessIf
79  *
80  */
81 class RAM_AccessIf{
82  private:
83   static void*         g_m_plock;
84   static void*         g_m_bakup_map;
85   static bool          g_m_is_first_access;
86   RAM_SM_INFO_t        m_buf;
87   bool                 m_dirty;
88   void initRamBackupEnable(RAM_WAKEUP_STATE wup_state);
89   void finalRamBackupEnable(void);
90
91  public:
92 /**
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
98  * \~english @par
99  *           RAM_WAKEUP_STATE
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:
105  *       - None
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
109  *       - None
110  * \~english @par Classification:
111  *       Public
112  * \~english @par Type
113  *       None
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
119  */
120 explicit RAM_AccessIf(RAM_WAKEUP_STATE wup_state = RAM_WAKEUP_STATE_DONT_CARE);
121
122 /**
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:
129  *       - None
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
133  *       - None
134  * \~english @par Classification:
135  *       Public
136  * \~english @par Type
137  *       None
138  * \~english @par Detail:
139  *       Release the access permission to the system management information.\n
140  * \~english @see  RAM_AccessIf, CL_LockRelease
141  */
142   ~RAM_AccessIf();
143
144 /**
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.
150  * \~english @par
151  *           RAM_SM_INFO_t Structure body
152  * \~english @code
153  *           typedef struct {
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];
162  *             BOOL              isErrorReset;
163  *             char              signature_out[4];
164  *           }RAM_SM_INFO_t;
165  *           @endcode
166  * \~english @retval eFrameworkunifiedStatusOK   Reading success
167  * \~english @retval eFrameworkunifiedStatusFail Reading failed
168  * \~english @par Precondition:
169  *       - None
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:
177  *       Public
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
184  */
185   EFrameworkunifiedStatus getRamInfo(RAM_SM_INFO_t* p_boot_info);
186
187 /**
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
193  * \~english @par
194  *           RAM_SM_INFO_t Structure body
195  * \~english @code
196  *           typedef struct {
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];
205  *             BOOL              isErrorReset;
206  *             char              signature_out[4];
207  *           }RAM_SM_INFO_t;
208  *           @endcode
209  * \~english @retval eFrameworkunifiedStatusOK   Write success
210  * \~english @retval eFrameworkunifiedStatusFail Write failed
211  * \~english @par Precondition:
212  *       - None
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:
220  *       Public
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
227  */
228   EFrameworkunifiedStatus setRamInfo(RAM_SM_INFO_t* p_boot_info);
229 };
230
231 #endif  //  ROM_ACCESS_LIBRARY_LIBRARY_INCLUDE_SYSTEM_SERVICE_SS_SM_RAM_ACCESS_H_
232
233 /** @}*/  // end of rom_access_library
234 /** @}*/  // end of system_service
235 /** @}*/  // end of BaseSystem