app_shmem: create generic libc partition
We need a generic name for the partition containing essential C library globals. We're going to need to add the stack canary guard to this area so user mode can read it. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
80e3a2c246
commit
17ce822ed9
|
@ -1157,7 +1157,7 @@ if(CONFIG_APP_SHARED_MEM AND CONFIG_USERSPACE)
|
|||
)
|
||||
|
||||
if(CONFIG_NEWLIB_LIBC)
|
||||
set(NEWLIB_PART -l libc.a z_newlib_partition)
|
||||
set(NEWLIB_PART -l libc.a z_libc_partition)
|
||||
endif()
|
||||
add_custom_command(
|
||||
OUTPUT ${APP_SMEM_LD}
|
||||
|
|
|
@ -27,13 +27,6 @@ __syscall int _zephyr_read(char *buf, int nbytes);
|
|||
|
||||
__syscall int _zephyr_write(const void *buf, int nbytes);
|
||||
|
||||
#ifdef CONFIG_APP_SHARED_MEM
|
||||
/* Memory partition containing newlib's globals. This includes all the globals
|
||||
* within libc.a and the supporting zephyr hooks, but not the malloc arena.
|
||||
*/
|
||||
extern struct k_mem_partition z_newlib_partition;
|
||||
#endif /* CONFIG_APP_SHARED_MEM */
|
||||
|
||||
#else
|
||||
/* Minimal libc */
|
||||
|
||||
|
@ -46,6 +39,9 @@ __syscall size_t _zephyr_fwrite(const void *_MLIBC_RESTRICT ptr, size_t size,
|
|||
#ifdef CONFIG_APP_SHARED_MEM
|
||||
/* Memory partition containing the libc malloc arena */
|
||||
extern struct k_mem_partition z_malloc_partition;
|
||||
|
||||
/* C library globals, except the malloc arena */
|
||||
extern struct k_mem_partition z_libc_partition;
|
||||
#endif
|
||||
|
||||
#include <syscalls/libc-hooks.h>
|
||||
|
|
|
@ -17,6 +17,9 @@
|
|||
#include <device.h>
|
||||
#include <init.h>
|
||||
#include <stdbool.h>
|
||||
#include <app_memory/app_memdomain.h>
|
||||
|
||||
K_APPMEM_PARTITION_DEFINE(z_libc_partition);
|
||||
|
||||
#define LOG_LEVEL CONFIG_KERNEL_LOG_LEVEL
|
||||
#include <logging/log.h>
|
||||
|
|
|
@ -17,22 +17,14 @@
|
|||
#include <app_memory/app_memdomain.h>
|
||||
#include <init.h>
|
||||
|
||||
#ifdef CONFIG_APP_SHARED_MEM
|
||||
K_APPMEM_PARTITION_DEFINE(z_newlib_partition);
|
||||
#define LIBC_BSS K_APP_BMEM(z_newlib_partition)
|
||||
#define LIBC_DATA K_APP_DMEM(z_newlib_partition)
|
||||
#define LIBC_BSS K_APP_BMEM(z_libc_partition)
|
||||
#define LIBC_DATA K_APP_DMEM(z_libc_partition)
|
||||
|
||||
#if CONFIG_NEWLIB_LIBC_ALIGNED_HEAP_SIZE
|
||||
K_APPMEM_PARTITION_DEFINE(z_malloc_partition);
|
||||
#define MALLOC_BSS K_APP_BMEM(z_malloc_partition)
|
||||
#endif /* CONFIG_NEWLIB_LIBC_ALIGNED_HEAP_SIZE */
|
||||
|
||||
#else
|
||||
#define LIBC_BSS
|
||||
#define LIBC_DATA
|
||||
#define MALLOC_BSS
|
||||
#endif /* CONFIG_APP_SHARED_MEM */
|
||||
|
||||
#define USED_RAM_END_ADDR POINTER_TO_UINT(&_end)
|
||||
|
||||
#if CONFIG_NEWLIB_LIBC_ALIGNED_HEAP_SIZE
|
||||
|
|
|
@ -302,11 +302,9 @@ void main(void)
|
|||
#ifdef CONFIG_APP_SHARED_MEM
|
||||
struct k_mem_partition *parts[] = {
|
||||
&ztest_mem_partition,
|
||||
#ifdef CONFIG_NEWLIB_LIBC
|
||||
/* Newlib libc.a library and hooks globals */
|
||||
&z_newlib_partition,
|
||||
#endif
|
||||
/* Both minimal and newlib libc expose this for malloc arena */
|
||||
/* C library globals, stack canary storage, etc */
|
||||
&z_libc_partition,
|
||||
/* Required for access to malloc arena */
|
||||
&z_malloc_partition
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue