blob: 4c2d8d72a3b34daf4137fc45c0c644e6dfd7f31c [file] [log] [blame]
brians343bc112013-02-10 01:53:46 +00001#ifndef _SHARED_MEM_H_
2#define _SHARED_MEM_H_
3
brians343bc112013-02-10 01:53:46 +00004#include <stddef.h>
Brian Silverman08661c72013-09-01 17:24:38 -07005
John Park398c74a2018-10-20 21:17:39 -07006#include "aos/ipc_lib/shared_mem_types.h"
brians343bc112013-02-10 01:53:46 +00007
Brian Silvermana6d1b562013-09-01 14:39:39 -07008#ifdef __cplusplus
9extern "C" {
10#endif
11
Brian Silverman08661c72013-09-01 17:24:38 -070012void init_shared_mem_core(aos_shm_core *shm_core);
13
brians343bc112013-02-10 01:53:46 +000014ptrdiff_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 Silverman01be0002014-05-10 15:44:38 -070022void aos_core_use_address_as_shared_mem(void *address, size_t size);
brians343bc112013-02-10 01:53:46 +000023
Brian Silverman8a6dac92015-02-21 20:08:24 -050024// 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.
27void aos_core_create_shared_mem(int create, int lock);
Brian Silverman01be0002014-05-10 15:44:38 -070028void aos_core_free_shared_mem(void);
brians343bc112013-02-10 01:53:46 +000029
Brian Silvermanb263d302014-02-16 00:01:43 -080030// Returns whether or not the shared memory system is active.
31int aos_core_is_init(void);
32
brians343bc112013-02-10 01:53:46 +000033#ifdef __cplusplus
34}
35#endif
36
37#endif