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.
19 * @brief el_mem function header file
22 #ifndef MEMORY_GPIO_ACCESS_LIBRARY_CLIENT_INCLUDE_NATIVE_SERVICE_EL_MEM_H_
23 #define MEMORY_GPIO_ACCESS_LIBRARY_CLIENT_INCLUDE_NATIVE_SERVICE_EL_MEM_H_
25 /** @addtogroup BaseSystem
28 /** @addtogroup native_service
32 /** @addtogroup memory_gpio_access_library
33 * @ingroup native_service
41 #include <sys/types.h>
44 * \~english Definitions of the Parametar of type
47 EL_MEM_TYPE_REGION_SYS, //!< \~english SYS region
48 EL_MEM_TYPE_REGION_LOG, //!< \~english LOG region
49 EL_MEM_TYPE_REGION_COM, //!< \~english COMMUNICATION region
50 EL_MEM_TYPE_REGION_NAVI, //!< \~english NAVI region
51 EL_MEM_TYPE_REGION_SH4A, //!< \~english SH4A region
52 EL_MEM_TYPE_REGION_PRAMFS, //!< \~english PRAMFS region
53 EL_MEM_TYPE_REGION_STARTUPBGM, //!< \~english STARTUPBGM region
54 EL_MEM_TYPE_REGION_NAVI_IR, //!< \~english NAVI picture recognition region
55 EL_MEM_TYPE_REGION_MAX //!< \~english (internal use)
59 * \~english Definitions of the Parametar of memory id
63 EL_MEM_ID_SYS_ALL = 0x0001, //!< \~english all SYS region
64 EL_MEM_ID_SYS_BOOT, //!< \~english particular: BOOT region
67 EL_MEM_ID_LOG_ALL = 0x1001, //!< \~english all LOG region
70 EL_MEM_ID_COM_ALL = 0x2001, //!< \~english all COMMUNICATION region
71 EL_MEM_ID_COM_SH4A, //!< \~english particular: SH4A abnornal observation
74 EL_MEM_ID_NAVI_ALL = 0x3001, //!< \~english NAVI region
75 EL_MEM_ID_NAVI_LOG, //!< \~english particular: NAVI(AW) LOG region
78 EL_MEM_ID_SH4A_ALL = 0x4001, //!< \~english SH4A region
79 EL_MEM_ID_SH4A_SHM, //!< \~english particular: SH4A SH share memory region
81 // PRAMFS region NOTE:Can be used only when ROM operation
82 EL_MEM_ID_PRAMFS_ALL = 0x5001, //!< \~english all PRAMFS region
85 EL_MEM_ID_STARTUPBGM_ALL = 0x6001, //!< \~english all STARTUPBGM region
87 // NAVI region (Picture Recognition: For Image Recognition)
88 EL_MEM_ID_NAVI_IR_ALL = 0x7001, //!< \~english all NAVI picture recognition region
92 * \~english Valid cache_flag
94 #define EL_MEM_CACHE_VALID 1
97 * \~english Invalid cache_flag
99 #define EL_MEM_CACHE_INVALID 0
101 /**\ingroup EL_mem_getOffset
102 * \~english @par Brief
103 * Get offset of function region according to mem_id.
104 * \~english @param [in] mem_id
107 * Defined memory id as follows.
111 * EL_MEM_ID_SYS_ALL = 0x0001, // all SYS region
112 * EL_MEM_ID_SYS_BOOT, // particular: BOOT region
114 * EL_MEM_ID_COM_ALL = 0x2001, // all COMMUNICATION region
115 * EL_MEM_ID_COM_SH4A, // particular: SH4A abnornal observation
117 * EL_MEM_ID_NAVI_ALL = 0x3001, // NAVI region
118 * EL_MEM_ID_NAVI_LOG, // particular: NAVI(AW) LOG region
120 * EL_MEM_ID_SH4A_ALL = 0x4001, // SH4A region
121 * EL_MEM_ID_SH4A_SHM, // particular: SH4A SH share memory region
122 * // PRAMFS NOTE:ROM only
123 * EL_MEM_ID_PRAMFS_ALL = 0x5001, // all PRAMFS region
125 * EL_MEM_ID_STARTUPBGM_ALL = 0x6001, // all STARTUPBGM region
126 * // NAVI (Image Recognition)
127 * EL_MEM_ID_NAVI_IR_ALL = 0x7001, // all NAVI picture recognition region
130 * \~english @retval offset Success
131 * \~english @retval -1 Error
132 * \~english @par Prerequisite
134 * \~english @par Change of internal state
135 * - Change of internal state according to the API does not occur.
136 * \~english @par Conditions of processing failure
137 * - Parameter mem_id is not defined.[-1]
138 * \~english @par Detail
139 * - Get offset of function region according to mem_id.
140 * \~english @par Classification
142 * \~english @par Type
144 * \~english @see none
146 off_t EL_mem_getOffset(int mem_id); // NOLINT [readability/naming]
148 /**\ingroup EL_mem_getLength
149 * \~english @par Brief
150 * Get length of function region according to mem_id.
151 * \~english @param [in] mem_id
154 * Defined memory id as follows.
158 * EL_MEM_ID_SYS_ALL = 0x0001, // all SYS region
159 * EL_MEM_ID_SYS_BOOT, // particular: BOOT region
161 * EL_MEM_ID_COM_ALL = 0x2001, // all COMMUNICATION region
162 * EL_MEM_ID_COM_SH4A, // particular: SH4A abnornal observation
164 * EL_MEM_ID_NAVI_ALL = 0x3001, // NAVI region
165 * EL_MEM_ID_NAVI_LOG, // particular: NAVI(AW) LOG region
167 * EL_MEM_ID_SH4A_ALL = 0x4001, // SH4A region
168 * EL_MEM_ID_SH4A_SHM, // particular: SH4A SH share memory region
169 * // PRAMFS NOTE:ROM only
170 * EL_MEM_ID_PRAMFS_ALL = 0x5001, // all PRAMFS region
172 * EL_MEM_ID_STARTUPBGM_ALL = 0x6001, // all STARTUPBGM region
173 * // NAVI (Image Recognition)
174 * EL_MEM_ID_NAVI_IR_ALL = 0x7001, // all NAVI picture recognition region
177 * \~english @retval length Success
178 * \~english @retval 0 Error
179 * \~english @par Prerequisite
181 * \~english @par Change of internal state
182 * - Change of internal state according to the API does not occur.
183 * \~english @par Conditions of processing failure
184 * - Parameter mem_id is not defined.[0]
185 * - syscall error(open(), ioctl()).[0]
186 * \~english @par Detail
187 * - Get length of function region according to mem_id.
188 * \~english @par Classification
190 * \~english @par Type
192 * \~english @see none
194 size_t EL_mem_getLength(int mem_id); // NOLINT [readability/naming]
196 /**\ingroup EL_mem_exram_mmap_simple
197 * \~english @par Brief
198 * Map device file to memory.(simple)
199 * \~english @param [in] mem_id
201 * \~english @param [in] prot
202 * int - Linux standard (same to mmap() of /dev/mem)
203 * \~english @param [in] flags
204 * int - Linux standard (same to mmap() of /dev/mem)
205 * \~english @param [in] cache_flag
206 * int - cache flag valid/invalid
208 * Defined memory id as follows.
212 * EL_MEM_ID_SYS_ALL = 0x0001, // all SYS region
213 * EL_MEM_ID_SYS_BOOT, // particular: BOOT region
215 * EL_MEM_ID_COM_ALL = 0x2001, // all COMMUNICATION region
216 * EL_MEM_ID_COM_SH4A, // particular: SH4A abnornal observation
218 * EL_MEM_ID_NAVI_ALL = 0x3001, // NAVI region
219 * EL_MEM_ID_NAVI_LOG, // particular: NAVI(AW) LOG region
221 * EL_MEM_ID_SH4A_ALL = 0x4001, // SH4A region
222 * EL_MEM_ID_SH4A_SHM, // particular: SH4A SH share memory region
223 * // PRAMFS NOTE:ROM only
224 * EL_MEM_ID_PRAMFS_ALL = 0x5001, // all PRAMFS region
226 * EL_MEM_ID_STARTUPBGM_ALL = 0x6001, // all STARTUPBGM region
227 * // NAVI (Image Recognition)
228 * EL_MEM_ID_NAVI_IR_ALL = 0x7001, // all NAVI picture recognition region
232 * Cache flag as follows.
234 * #define EL_MEM_CACHE_VALID 1 // valid cache
235 * #define EL_MEM_CACHE_INVALID 0 // invalid cache
237 * \~english @retval address Success
238 * \~english @retval -1 Error
239 * \~english @par Prerequisite
241 * \~english @par Change of internal state
242 * - Change of internal state according to the API does not occur.
243 * \~english @par Conditions of processing failure
244 * - Parameter mem_id is not defined.[-1]
245 * - Open device file failed.[-1]
246 * - Map device file to memory error.[-1]
247 * \~english @par Detail
248 * - Get type, offset and length from internal table specified by mem_id, then\n
249 * call \ref EL_mem_exram_mmap.
250 * \~english @par Classification
252 * \~english @par Type
254 * \~english @see EL_mem_getLength, EL_mem_exram_mmap, EL_mem_exram_munmap
256 void *EL_mem_exram_mmap_simple(int mem_id , int prot, int flags , int cache_flag); // NOLINT [readability/naming]
258 /**\ingroup EL_mem_exram_mmap
259 * \~english @par Brief
260 * Map device file to memory.
261 * \~english @param [in] type
263 * \~english @param [in] offset
264 * off_t - offset(From 0\ref EL_mem_getOffset)
265 * \~english @param [in] length
266 * size_t - length(From 1\ref EL_mem_getLength)
267 * \~english @param [in] prot
268 * int - Linux standard (same to mmap() of /dev/mem)
269 * \~english @param [in] flags
270 * int - Linux standard (same to mmap() of /dev/mem)
271 * \~english @param [in] cache_flag
272 * int - cache flag valid/invalid
274 * Defined memory type as follows.
277 * EL_MEM_TYPE_REGION_SYS, // SYS
278 * EL_MEM_TYPE_REGION_COM, // COMMUNICATION
279 * EL_MEM_TYPE_REGION_NAVI, // NAVI
280 * EL_MEM_TYPE_REGION_SH4A, // SH4A
281 * EL_MEM_TYPE_REGION_PRAMFS, // PRAMFS
282 * EL_MEM_TYPE_REGION_STARTUPBGM, // STARTUPBGM
283 * EL_MEM_TYPE_REGION_NAVI_IR, // NAVI IMAGE
287 * Cache flag as follows.
289 * #define EL_MEM_CACHE_VALID 1 // valid cache
290 * #define EL_MEM_CACHE_INVALID 0 // invalid cache
292 * \~english @retval address Success
293 * \~english @retval -1 Error
294 * \~english @par Prerequisite
296 * \~english @par Change of internal state
297 * - Change of internal state according to the API does not occur.
298 * \~english @par Conditions of processing failure
299 * - Open device file failed.[-1]
300 * - Map device file to memory error.[-1]
301 * \~english @par Detail
302 * - Access device file specified by memory type, map function region to user space.
303 * \~english @par Classification
305 * \~english @par Type
307 * \~english @see EL_mem_exram_munmap
309 void *EL_mem_exram_mmap(int type, off_t offset , size_t length , int prot, int flags , int cache_flag); // NOLINT [readability/naming]
311 /**\ingroup EL_mem_exram_munmap
312 * \~english @par Brief
313 * Unmap device file from memory.
314 * \~english @param [in] addr
316 * \~english @param [in] length
317 * size_t - size (1 ~ \ref EL_mem_getLength)
318 * \~english @retval 0 Success
319 * \~english @retval -1 Error:Set errno according to error type when error occurs.
320 * \~english @par Prerequisite
321 * - Map device file to memory(\ref EL_mem_exram_mmap,
322 * \ref EL_mem_exram_mmap_simple).
323 * \~english @par Change of internal state
324 * - Change of internal state according to the API does not occur.
325 * \~english @par Conditions of processing failure
326 * - Unmap device file from memory error.[-1]
327 * \~english @par Detail
328 * - Unmap specified address.Error occurs when refer to this memory after unmap.
329 * - Automatic unmap when process ends.
330 * - The memory will not be unmap even the file descriptor is closed.
331 * \~english @par Classification
333 * \~english @par Type
335 * \~english @see EL_mem_exram_mmap, EL_mem_exram_mmap_simple
337 int EL_mem_exram_munmap(void *addr, size_t length); // NOLINT [readability/naming]
339 /**\ingroup EL_mem_getPhysicalAddress
340 * \~english @par Brief
341 * Get physical address.
342 * \~english @param [in] mem_id
345 * Defined memory id as follows.
349 * EL_MEM_ID_SYS_ALL = 0x0001, // all SYS region
350 * EL_MEM_ID_SYS_BOOT, // particular: BOOT region
352 * EL_MEM_ID_COM_ALL = 0x2001, // all COMMUNICATION region
353 * EL_MEM_ID_COM_SH4A, // particular: SH4A abnornal observation
355 * EL_MEM_ID_NAVI_ALL = 0x3001, // NAVI region
356 * EL_MEM_ID_NAVI_LOG, // particular: NAVI(AW) LOG region
358 * EL_MEM_ID_SH4A_ALL = 0x4001, // SH4A region
359 * EL_MEM_ID_SH4A_SHM, // particular: SH4A SH share memory region
360 * // PRAMFS NOTE:ROM only
361 * EL_MEM_ID_PRAMFS_ALL = 0x5001, // all PRAMFS region
363 * EL_MEM_ID_STARTUPBGM_ALL = 0x6001, // all STARTUPBGM region
364 * // NAVI (Image Recognition)
365 * EL_MEM_ID_NAVI_IR_ALL = 0x7001, // all NAVI picture recognition region
368 * \~english @retval physical address Success
369 * \~english @retval 0 Error: Failed to open device file or get physical address(ioctl)
370 * \~english @retval -1 Error: Parameter mem_id is not defined.
371 * \~english @par Prerequisite
373 * \~english @par Change of internal state
374 * - Change of internal state according to the API does not occur.
375 * \~english @par Conditions of processing failure
376 * - Parameter mem_id is not defined.[-1]
377 * - Get physical address error.[0]
378 * \~english @par Detail
379 * - Get physical address from dummy-memory driver according to device file specified by mem_id.
380 * - Return the sum value of physical address and offset specified by mem_id.
381 * \~english @par Classification
383 * \~english @par Type
385 * \~english @see none
387 u_int64_t EL_mem_getPhysicalAddress(int mem_id); // NOLINT [readability/naming]
391 #endif // __cplusplus
393 /** @}*/ // end of memory_gpio_access_library
394 /** @}*/ // end of native_service
395 /** @}*/ // end of BaseSystem
396 #endif // MEMORY_GPIO_ACCESS_LIBRARY_CLIENT_INCLUDE_NATIVE_SERVICE_EL_MEM_H_