brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 1 | #ifndef _SHARED_MEM_H_ |
| 2 | #define _SHARED_MEM_H_ |
| 3 | |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 4 | #include <stddef.h> |
Brian Silverman | 08661c7 | 2013-09-01 17:24:38 -0700 | [diff] [blame] | 5 | |
John Park | 398c74a | 2018-10-20 21:17:39 -0700 | [diff] [blame] | 6 | #include "aos/ipc_lib/shared_mem_types.h" |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 7 | |
Brian Silverman | a6d1b56 | 2013-09-01 14:39:39 -0700 | [diff] [blame] | 8 | #ifdef __cplusplus |
| 9 | extern "C" { |
| 10 | #endif |
| 11 | |
Brian Silverman | 08661c7 | 2013-09-01 17:24:38 -0700 | [diff] [blame] | 12 | void init_shared_mem_core(aos_shm_core *shm_core); |
| 13 | |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 14 | ptrdiff_t aos_core_get_mem_usage(void); |
| 15 | |
| 16 | // Takes the specified memory address and uses it as the shared memory. |
| 17 | // address is the memory address, and size is the size of the memory. |
| 18 | // global_core needs to point to an instance of struct aos_core, and owner |
| 19 | // should be set correctly there. |
| 20 | // The owner should verify that the first sizeof(mutex) of data is set to 0 |
| 21 | // before passing the memory to this function. |
Brian Silverman | 01be000 | 2014-05-10 15:44:38 -0700 | [diff] [blame] | 22 | void aos_core_use_address_as_shared_mem(void *address, size_t size); |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 23 | |
Brian Silverman | 8a6dac9 | 2015-02-21 20:08:24 -0500 | [diff] [blame] | 24 | // create is true to remove any existing shm to create a fresh one or false to |
| 25 | // fail if it does not already exist. |
| 26 | // lock is true to lock shared memory into RAM or false to not. |
| 27 | void aos_core_create_shared_mem(int create, int lock); |
Brian Silverman | 01be000 | 2014-05-10 15:44:38 -0700 | [diff] [blame] | 28 | void aos_core_free_shared_mem(void); |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 29 | |
Brian Silverman | b263d30 | 2014-02-16 00:01:43 -0800 | [diff] [blame] | 30 | // Returns whether or not the shared memory system is active. |
| 31 | int aos_core_is_init(void); |
| 32 | |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 33 | #ifdef __cplusplus |
| 34 | } |
| 35 | #endif |
| 36 | |
| 37 | #endif |