blob: edb90919e8a6f283bb60bf684910b035df9129c0 [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>
5#include <unistd.h>
Brian Silverman08661c72013-09-01 17:24:38 -07006#include <time.h>
7
John Park398c74a2018-10-20 21:17:39 -07008#include "aos/ipc_lib/shared_mem_types.h"
brians343bc112013-02-10 01:53:46 +00009
Brian Silvermana6d1b562013-09-01 14:39:39 -070010#ifdef __cplusplus
11extern "C" {
12#endif
13
Brian Silverman08661c72013-09-01 17:24:38 -070014void init_shared_mem_core(aos_shm_core *shm_core);
15
brians343bc112013-02-10 01:53:46 +000016ptrdiff_t aos_core_get_mem_usage(void);
17
18// Takes the specified memory address and uses it as the shared memory.
19// address is the memory address, and size is the size of the memory.
20// global_core needs to point to an instance of struct aos_core, and owner
21// should be set correctly there.
22// The owner should verify that the first sizeof(mutex) of data is set to 0
23// before passing the memory to this function.
Brian Silverman01be0002014-05-10 15:44:38 -070024void aos_core_use_address_as_shared_mem(void *address, size_t size);
brians343bc112013-02-10 01:53:46 +000025
Brian Silverman8a6dac92015-02-21 20:08:24 -050026// create is true to remove any existing shm to create a fresh one or false to
27// fail if it does not already exist.
28// lock is true to lock shared memory into RAM or false to not.
29void aos_core_create_shared_mem(int create, int lock);
Brian Silverman01be0002014-05-10 15:44:38 -070030void aos_core_free_shared_mem(void);
brians343bc112013-02-10 01:53:46 +000031
Brian Silvermanb263d302014-02-16 00:01:43 -080032// Returns whether or not the shared memory system is active.
33int aos_core_is_init(void);
34
brians343bc112013-02-10 01:53:46 +000035#ifdef __cplusplus
36}
37#endif
38
39#endif