summaryrefslogtreecommitdiffstats
path: root/stub/memory_gpio_access_library/client/include/stub/el_mem.h
blob: b6f68559b0ceadee6bf05fc7090bcb52a957f8a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
/*
 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @file el_mem.h
 * @brief el_mem function header file
 */

#ifndef MEMORY_GPIO_ACCESS_LIBRARY_CLIENT_INCLUDE_NATIVE_SERVICE_EL_MEM_H_
#define MEMORY_GPIO_ACCESS_LIBRARY_CLIENT_INCLUDE_NATIVE_SERVICE_EL_MEM_H_

/** @addtogroup BaseSystem
 *  @{
 */
/** @addtogroup native_service
 *  @ingroup BaseSystem
 *  @{
 */
/** @addtogroup memory_gpio_access_library
 *  @ingroup native_service
 *  @{
 */

#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <sys/types.h>

/**
* \~english Definitions of the Parametar of type
*/
enum {
  EL_MEM_TYPE_REGION_SYS,            //!< \~english SYS region
  EL_MEM_TYPE_REGION_LOG,            //!< \~english LOG region
  EL_MEM_TYPE_REGION_COM,            //!< \~english COMMUNICATION region
  EL_MEM_TYPE_REGION_NAVI,           //!< \~english NAVI region
  EL_MEM_TYPE_REGION_SH4A,           //!< \~english SH4A region
  EL_MEM_TYPE_REGION_PRAMFS,         //!< \~english PRAMFS region
  EL_MEM_TYPE_REGION_STARTUPBGM,     //!< \~english STARTUPBGM region
  EL_MEM_TYPE_REGION_NAVI_IR,        //!< \~english NAVI picture recognition region
  EL_MEM_TYPE_REGION_MAX             //!< \~english (internal use)
};

/**
* \~english Definitions of the Parametar of memory id
*/
enum {
  // SYS region
  EL_MEM_ID_SYS_ALL   = 0x0001,          //!< \~english all SYS region
  EL_MEM_ID_SYS_BOOT,                    //!< \~english particular: BOOT region

  // LOG region
  EL_MEM_ID_LOG_ALL = 0x1001,            //!< \~english all LOG region

  // COM region
  EL_MEM_ID_COM_ALL = 0x2001,            //!< \~english all COMMUNICATION region
  EL_MEM_ID_COM_SH4A,            //!< \~english particular: SH4A abnornal observation

  // NAVI region
  EL_MEM_ID_NAVI_ALL  = 0x3001,          //!< \~english NAVI region
  EL_MEM_ID_NAVI_LOG,                //!< \~english particular: NAVI(AW) LOG region

  // SH4A region
  EL_MEM_ID_SH4A_ALL  = 0x4001,          //!< \~english SH4A region
  EL_MEM_ID_SH4A_SHM,   //!< \~english particular: SH4A SH share memory region

  // PRAMFS region NOTE:Can be used only when ROM operation
  EL_MEM_ID_PRAMFS_ALL = 0x5001,         //!< \~english all PRAMFS region

  // STARTUPBGM region
  EL_MEM_ID_STARTUPBGM_ALL = 0x6001,     //!< \~english all STARTUPBGM region

  // NAVI region (Picture Recognition: For Image Recognition)
  EL_MEM_ID_NAVI_IR_ALL = 0x7001,  //!< \~english all NAVI picture recognition region
};

/**
 * \~english Valid cache_flag
 */
#define EL_MEM_CACHE_VALID      1

/**
 * \~english Invalid cache_flag
 */
#define EL_MEM_CACHE_INVALID    0

/**\ingroup EL_mem_getOffset
* \~english @par Brief
*        Get offset of function region according to mem_id.
* \~english @param [in] mem_id
*        int   - memory id
* \~english @par
*        Defined memory id as follows.
* \~english @code
*        enum {
*                   // SYS
*                   EL_MEM_ID_SYS_ALL   = 0x0001,          // all SYS region
*                   EL_MEM_ID_SYS_BOOT,                    // particular: BOOT region
*                   // COM
*                   EL_MEM_ID_COM_ALL = 0x2001,            // all COMMUNICATION region
*                   EL_MEM_ID_COM_SH4A,                    // particular: SH4A abnornal observation
*                   // NAVI
*                   EL_MEM_ID_NAVI_ALL  = 0x3001,          // NAVI region
*                   EL_MEM_ID_NAVI_LOG,                    // particular: NAVI(AW) LOG region
*                   // SH4A
*                   EL_MEM_ID_SH4A_ALL  = 0x4001,          // SH4A region
*                   EL_MEM_ID_SH4A_SHM,                    // particular: SH4A SH share memory region
*                   // PRAMFS NOTE:ROM only
*                   EL_MEM_ID_PRAMFS_ALL = 0x5001,         // all PRAMFS region
*                   // STARTUPBGM
*                   EL_MEM_ID_STARTUPBGM_ALL = 0x6001,     // all STARTUPBGM region
*                   // NAVI (Image Recognition)
*                   EL_MEM_ID_NAVI_IR_ALL = 0x7001,        // all NAVI picture recognition region
*        };
*            @endcode
* \~english @retval offset Success
* \~english @retval -1 Error
* \~english @par Prerequisite
*        - None.
* \~english @par Change of internal state
*        - Change of internal state according to the API does not occur.
* \~english @par Conditions of processing failure
*        - Parameter mem_id is not defined.[-1]
* \~english @par Detail
*        - Get offset of function region according to mem_id.
* \~english @par Classification
*        Public
* \~english @par Type
*        Sync
* \~english @see none
*/
off_t EL_mem_getOffset(int mem_id);  // NOLINT [readability/naming]

/**\ingroup EL_mem_getLength
* \~english @par Brief
*        Get length of function region according to mem_id.
* \~english @param [in] mem_id
*        int   - memory id
* \~english @par
*        Defined memory id as follows.
* \~english @code
*        enum {
*                   // SYS
*                   EL_MEM_ID_SYS_ALL   = 0x0001,          // all SYS region
*                   EL_MEM_ID_SYS_BOOT,                    // particular: BOOT region
*                   // COM
*                   EL_MEM_ID_COM_ALL = 0x2001,            // all COMMUNICATION region
*                   EL_MEM_ID_COM_SH4A,                    // particular: SH4A abnornal observation
*                   // NAVI
*                   EL_MEM_ID_NAVI_ALL  = 0x3001,          // NAVI region
*                   EL_MEM_ID_NAVI_LOG,                    // particular: NAVI(AW) LOG region
*                   // SH4A
*                   EL_MEM_ID_SH4A_ALL  = 0x4001,          // SH4A region
*                   EL_MEM_ID_SH4A_SHM,                    // particular: SH4A SH share memory region
*                   // PRAMFS NOTE:ROM only
*                   EL_MEM_ID_PRAMFS_ALL = 0x5001,         // all PRAMFS region
*                   // STARTUPBGM
*                   EL_MEM_ID_STARTUPBGM_ALL = 0x6001,     // all STARTUPBGM region
*                   // NAVI (Image Recognition)
*                   EL_MEM_ID_NAVI_IR_ALL = 0x7001,        // all NAVI picture recognition region
*        };
*            @endcode
* \~english @retval length Success
* \~english @retval 0 Error
* \~english @par Prerequisite
*        - None.
* \~english @par Change of internal state
*        - Change of internal state according to the API does not occur.
* \~english @par Conditions of processing failure
*        - Parameter mem_id is not defined.[0]
*        - syscall error(open(), ioctl()).[0]
* \~english @par Detail
*        - Get length of function region according to mem_id.
* \~english @par Classification
*        Public
* \~english @par Type
*        Sync
* \~english @see none
*/
size_t EL_mem_getLength(int mem_id);  // NOLINT [readability/naming]

/**\ingroup EL_mem_exram_mmap_simple
* \~english @par Brief
*        Map device file to memory.(simple)
* \~english @param [in] mem_id
*        int   - memory id
* \~english @param [in] prot
*        int   - Linux standard (same to mmap() of /dev/mem)
* \~english @param [in] flags
*        int   - Linux standard (same to mmap() of /dev/mem)
* \~english @param [in] cache_flag
*        int   - cache flag valid/invalid
* \~english @par
*        Defined memory id as follows.
* \~english @code
*        enum {
*                   // SYS
*                   EL_MEM_ID_SYS_ALL   = 0x0001,          // all SYS region
*                   EL_MEM_ID_SYS_BOOT,                    // particular: BOOT region
*                   // COM
*                   EL_MEM_ID_COM_ALL = 0x2001,            // all COMMUNICATION region
*                   EL_MEM_ID_COM_SH4A,                    // particular: SH4A abnornal observation
*                   // NAVI
*                   EL_MEM_ID_NAVI_ALL  = 0x3001,          // NAVI region
*                   EL_MEM_ID_NAVI_LOG,                    // particular: NAVI(AW) LOG region
*                   // SH4A
*                   EL_MEM_ID_SH4A_ALL  = 0x4001,          // SH4A region
*                   EL_MEM_ID_SH4A_SHM,                    // particular: SH4A SH share memory region
*                   // PRAMFS NOTE:ROM only
*                   EL_MEM_ID_PRAMFS_ALL = 0x5001,         // all PRAMFS region
*                   // STARTUPBGM
*                   EL_MEM_ID_STARTUPBGM_ALL = 0x6001,     // all STARTUPBGM region
*                   // NAVI (Image Recognition)
*                   EL_MEM_ID_NAVI_IR_ALL = 0x7001,        // all NAVI picture recognition region
*        };
*            @endcode
* \~english @par
*        Cache flag as follows.
* \~english @code
*                 #define EL_MEM_CACHE_VALID      1   // valid cache
*                 #define EL_MEM_CACHE_INVALID    0   // invalid cache
*            @endcode
* \~english @retval address Success
* \~english @retval -1 Error
* \~english @par Prerequisite
*        - None.
* \~english @par Change of internal state
*        - Change of internal state according to the API does not occur.
* \~english @par Conditions of processing failure
*        - Parameter mem_id is not defined.[-1]
*        - Open device file failed.[-1]
*        - Map device file to memory error.[-1]
* \~english @par Detail
*        - Get type, offset and length from internal table specified by mem_id, then\n
*        call \ref EL_mem_exram_mmap.
* \~english @par Classification
*        Public
* \~english @par Type
*        Sync
* \~english @see EL_mem_getLength, EL_mem_exram_mmap, EL_mem_exram_munmap
*/
void *EL_mem_exram_mmap_simple(int mem_id , int prot, int flags , int cache_flag);  // NOLINT [readability/naming]

/**\ingroup EL_mem_exram_mmap
* \~english @par Brief
*        Map device file to memory.
* \~english @param [in] type
*        int   - memory type
* \~english @param [in] offset
*        off_t   - offset(From 0\ref EL_mem_getOffset)
* \~english @param [in] length
*        size_t   - length(From 1\ref EL_mem_getLength)
* \~english @param [in] prot
*        int   - Linux standard (same to mmap() of /dev/mem)
* \~english @param [in] flags
*        int   - Linux standard (same to mmap() of /dev/mem)
* \~english @param [in] cache_flag
*        int   - cache flag valid/invalid
* \~english @par
*        Defined memory type as follows.
* \~english @code
*        enum {
*                   EL_MEM_TYPE_REGION_SYS,            // SYS
*                   EL_MEM_TYPE_REGION_COM,            // COMMUNICATION
*                   EL_MEM_TYPE_REGION_NAVI,           // NAVI
*                   EL_MEM_TYPE_REGION_SH4A,           // SH4A
*                   EL_MEM_TYPE_REGION_PRAMFS,         // PRAMFS
*                   EL_MEM_TYPE_REGION_STARTUPBGM,     // STARTUPBGM
*                   EL_MEM_TYPE_REGION_NAVI_IR,        // NAVI IMAGE
*        };
*            @endcode
* \~english @par
*        Cache flag as follows.
* \~english @code
*                 #define EL_MEM_CACHE_VALID      1   // valid cache
*                 #define EL_MEM_CACHE_INVALID    0   // invalid cache
*            @endcode
* \~english @retval address Success
* \~english @retval -1 Error
* \~english @par Prerequisite
*        - None.
* \~english @par Change of internal state
*        - Change of internal state according to the API does not occur.
* \~english @par Conditions of processing failure
*        - Open device file failed.[-1]
*        - Map device file to memory error.[-1]
* \~english @par Detail
*        - Access device file specified by memory type, map function region to user space.
* \~english @par Classification
*        Public
* \~english @par Type
*        Sync
* \~english @see EL_mem_exram_munmap
*/
void *EL_mem_exram_mmap(int type, off_t offset , size_t length , int prot, int flags , int cache_flag);  // NOLINT [readability/naming]

/**\ingroup EL_mem_exram_munmap
* \~english @par Brief
*        Unmap device file from memory.
* \~english @param [in] addr
*        void *   - address
* \~english @param [in] length
*        size_t   - size (1 ~ \ref EL_mem_getLength)
* \~english @retval 0 Success
* \~english @retval -1 Error:Set errno according to error type when error occurs.
* \~english @par Prerequisite
*        - Map device file to memory(\ref EL_mem_exram_mmap,
*          \ref EL_mem_exram_mmap_simple).
* \~english @par Change of internal state
*        - Change of internal state according to the API does not occur.
* \~english @par Conditions of processing failure
*        - Unmap device file from memory error.[-1]
* \~english @par Detail
*        - Unmap specified address.Error occurs when refer to this memory after unmap.
*        - Automatic unmap when process ends.
*        - The memory will not be unmap even the file descriptor is closed.
* \~english @par Classification
*        Public
* \~english @par Type
*        Sync
* \~english @see EL_mem_exram_mmap, EL_mem_exram_mmap_simple
*/
int EL_mem_exram_munmap(void *addr, size_t length);  // NOLINT [readability/naming]

/**\ingroup EL_mem_getPhysicalAddress
* \~english @par Brief
*        Get physical address.
* \~english @param [in] mem_id
*        int   - memory id
* \~english @par
*        Defined memory id as follows.
* \~english @code
*        enum {
*                   // SYS
*                   EL_MEM_ID_SYS_ALL   = 0x0001,          // all SYS region
*                   EL_MEM_ID_SYS_BOOT,                    // particular: BOOT region
*                   // COM
*                   EL_MEM_ID_COM_ALL = 0x2001,            // all COMMUNICATION region
*                   EL_MEM_ID_COM_SH4A,                    // particular: SH4A abnornal observation
*                   // NAVI
*                   EL_MEM_ID_NAVI_ALL  = 0x3001,          // NAVI region
*                   EL_MEM_ID_NAVI_LOG,                    // particular: NAVI(AW) LOG region
*                   // SH4A
*                   EL_MEM_ID_SH4A_ALL  = 0x4001,          // SH4A region
*                   EL_MEM_ID_SH4A_SHM,                    // particular: SH4A SH share memory region
*                   // PRAMFS NOTE:ROM only
*                   EL_MEM_ID_PRAMFS_ALL = 0x5001,         // all PRAMFS region
*                   // STARTUPBGM
*                   EL_MEM_ID_STARTUPBGM_ALL = 0x6001,     // all STARTUPBGM region
*                   // NAVI (Image Recognition)
*                   EL_MEM_ID_NAVI_IR_ALL = 0x7001,        // all NAVI picture recognition region
*        };
*            @endcode
* \~english @retval physical address Success
* \~english @retval 0 Error: Failed to open device file or get physical address(ioctl)
* \~english @retval -1 Error: Parameter mem_id is not defined.
* \~english @par Prerequisite
*        - None.
* \~english @par Change of internal state
*        - Change of internal state according to the API does not occur.
* \~english @par Conditions of processing failure
*        - Parameter mem_id is not defined.[-1]
*        - Get physical address error.[0]
* \~english @par Detail
*        - Get physical address from dummy-memory driver according to device file specified by mem_id.
*        - Return the sum value of physical address and offset specified by mem_id.
* \~english @par Classification
*        Public
* \~english @par Type
*        Sync
* \~english @see none
*/
u_int64_t EL_mem_getPhysicalAddress(int mem_id);  // NOLINT [readability/naming]

#ifdef __cplusplus
}
#endif  // __cplusplus

/** @}*/  // end of memory_gpio_access_library
/** @}*/  // end of native_service
/** @}*/  // end of BaseSystem
#endif  // MEMORY_GPIO_ACCESS_LIBRARY_CLIENT_INCLUDE_NATIVE_SERVICE_EL_MEM_H_