userspace: remove APP_SHARED_MEM Kconfig

This is an integral part of userspace and cannot be used
on its own. Fold into the main userspace configuration.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2019-02-22 16:08:44 -08:00 committed by Anas Nashif
parent f1920fff46
commit 4ce652e4b2
28 changed files with 57 additions and 77 deletions

View file

@ -362,9 +362,7 @@ zephyr_cc_option(-Wpointer-arith)
# Declare MPU userspace dependencies before the linker scripts to make # Declare MPU userspace dependencies before the linker scripts to make
# sure the order of dependencies are met # sure the order of dependencies are met
if(CONFIG_USERSPACE) if(CONFIG_USERSPACE)
if(CONFIG_APP_SHARED_MEM) set(APP_SMEM_DEP app_smem_linker)
set(APP_SMEM_DEP app_smem_linker)
endif()
if(CONFIG_ARM) if(CONFIG_ARM)
set(PRIV_STACK_DEP priv_stacks_prebuilt) set(PRIV_STACK_DEP priv_stacks_prebuilt)
endif() endif()
@ -1152,7 +1150,7 @@ configure_file(
$ENV{ZEPHYR_BASE}/include/arch/arm/cortex_m/scripts/app_smem.ld $ENV{ZEPHYR_BASE}/include/arch/arm/cortex_m/scripts/app_smem.ld
${PROJECT_BINARY_DIR}/include/generated/app_smem.ld) ${PROJECT_BINARY_DIR}/include/generated/app_smem.ld)
if(CONFIG_APP_SHARED_MEM AND CONFIG_USERSPACE) if(CONFIG_USERSPACE)
set(APP_SMEM_LD "${PROJECT_BINARY_DIR}/include/generated/app_smem.ld") set(APP_SMEM_LD "${PROJECT_BINARY_DIR}/include/generated/app_smem.ld")
set(OBJ_FILE_DIR "${PROJECT_BINARY_DIR}/../") set(OBJ_FILE_DIR "${PROJECT_BINARY_DIR}/../")

View file

@ -446,8 +446,8 @@ void arc_core_mpu_configure_user_context(struct k_thread *thread)
/* for kernel threads, no need to configure user context */ /* for kernel threads, no need to configure user context */
if (!(thread->base.user_options & K_USER)) { if (!(thread->base.user_options & K_USER)) {
#if defined(CONFIG_APP_SHARED_MEM) && CONFIG_ARC_MPU_VER == 3 #if defined(CONFIG_USERSPACE) && CONFIG_ARC_MPU_VER == 3
/* APP_SHARED_MEM is handled here, all privileged threads have /* USERSPACE is handled here, all privileged threads have
* the right to access it. * the right to access it.
*/ */
base = (u32_t)&_app_smem_start; base = (u32_t)&_app_smem_start;

View file

@ -37,11 +37,11 @@ LOG_MODULE_REGISTER(mpu);
/* Convenience macros to denote the start address and the size of the system /* Convenience macros to denote the start address and the size of the system
* memory area, where dynamic memory regions may be programmed at run-time. * memory area, where dynamic memory regions may be programmed at run-time.
*/ */
#if defined(CONFIG_APP_SHARED_MEM) #if defined(CONFIG_USERSPACE)
#define _MPU_DYNAMIC_REGIONS_AREA_START ((u32_t)&_app_smem_start) #define _MPU_DYNAMIC_REGIONS_AREA_START ((u32_t)&_app_smem_start)
#else #else
#define _MPU_DYNAMIC_REGIONS_AREA_START ((u32_t)&__kernel_ram_start) #define _MPU_DYNAMIC_REGIONS_AREA_START ((u32_t)&__kernel_ram_start)
#endif /* CONFIG_APP_SHARED_MEM */ #endif /* CONFIG_USERSPACE */
#define _MPU_DYNAMIC_REGIONS_AREA_SIZE ((u32_t)&__kernel_ram_end - \ #define _MPU_DYNAMIC_REGIONS_AREA_SIZE ((u32_t)&__kernel_ram_end - \
_MPU_DYNAMIC_REGIONS_AREA_START) _MPU_DYNAMIC_REGIONS_AREA_START)

View file

@ -314,13 +314,13 @@ __csSet:
call _x86_data_copy call _x86_data_copy
#ifdef CONFIG_APP_SHARED_MEM #ifdef CONFIG_USERSPACE
movl $_app_smem_start, %edi /* DATA in RAM (dest) */ movl $_app_smem_start, %edi /* DATA in RAM (dest) */
movl $_app_smem_rom_start, %esi /* DATA in ROM (src) */ movl $_app_smem_rom_start, %esi /* DATA in ROM (src) */
movl $_app_smem_num_words, %ecx /* Size of DATA in quad bytes */ movl $_app_smem_num_words, %ecx /* Size of DATA in quad bytes */
call _x86_data_copy call _x86_data_copy
#endif /* CONFIG_APP_SHARED_MEM */ #endif /* CONFIG_USERSPACE */
#endif /* CONFIG_XIP */ #endif /* CONFIG_XIP */

View file

@ -24,7 +24,7 @@ MMU_BOOT_REGION((u32_t)&_image_rodata_start, (u32_t)&_image_rodata_size,
MMU_ENTRY_READ | MMU_ENTRY_USER | MMU_ENTRY_READ | MMU_ENTRY_USER |
MMU_ENTRY_EXECUTE_DISABLE); MMU_ENTRY_EXECUTE_DISABLE);
#ifdef CONFIG_APP_SHARED_MEM #ifdef CONFIG_USERSPACE
MMU_BOOT_REGION((u32_t)&_app_smem_start, (u32_t)&_app_smem_size, MMU_BOOT_REGION((u32_t)&_app_smem_start, (u32_t)&_app_smem_size,
MMU_ENTRY_WRITE | MMU_ENTRY_RUNTIME_USER | MMU_ENTRY_WRITE | MMU_ENTRY_RUNTIME_USER |
MMU_ENTRY_EXECUTE_DISABLE); MMU_ENTRY_EXECUTE_DISABLE);

View file

@ -265,7 +265,6 @@ Configuration Options
Related configuration options: Related configuration options:
* :option:`CONFIG_USERSPACE` * :option:`CONFIG_USERSPACE`
* :option:`CONFIG_APP_SHARED_MEM`
* :option:`CONFIG_MAX_THREAD_BYTES` * :option:`CONFIG_MAX_THREAD_BYTES`
API Reference API Reference

View file

@ -33,8 +33,7 @@ the proper alignment for processors requiring power of two boundaries.
Without the wrapper, a developer is required to implement custom Without the wrapper, a developer is required to implement custom
linker scripts for each processor in the project. linker scripts for each processor in the project.
The general usage is as follows. Define CONFIG_APP_SHARED_MEM=y in the The general usage is as follows. Include app_memory/app_memdomain.h
proj.conf file in the project folder. Include app_memory/app_memdomain.h
in the userspace source file. Mark the variable to be placed in in the userspace source file. Mark the variable to be placed in
a memory partition. The two markers are for data and bss respectively: a memory partition. The two markers are for data and bss respectively:
K_APP_DMEM(id) and K_APP_BMEM(id). The id is used as the partition name. K_APP_DMEM(id) and K_APP_BMEM(id). The id is used as the partition name.

View file

@ -5,7 +5,7 @@
#include <misc/dlist.h> #include <misc/dlist.h>
#include <kernel.h> #include <kernel.h>
#ifdef CONFIG_APP_SHARED_MEM #ifdef CONFIG_USERSPACE
#if defined(CONFIG_X86) #if defined(CONFIG_X86)
#define MEM_DOMAIN_ALIGN_SIZE _STACK_BASE_ALIGN #define MEM_DOMAIN_ALIGN_SIZE _STACK_BASE_ALIGN
@ -104,5 +104,5 @@ struct z_app_region {
#define K_APP_BMEM_SECTION(ptn) .bss #define K_APP_BMEM_SECTION(ptn) .bss
#define K_APPMEM_PARTITION_DEFINE(name) #define K_APPMEM_PARTITION_DEFINE(name)
#endif /* CONFIG_APP_SHARED_MEM */ #endif /* CONFIG_USERSPACE */
#endif /* ZEPHYR_INCLUDE_APP_MEMORY_APP_MEMDOMAIN_H_ */ #endif /* ZEPHYR_INCLUDE_APP_MEMORY_APP_MEMDOMAIN_H_ */

View file

@ -138,7 +138,7 @@ SECTIONS {
#include <app_data_alignment.ld> #include <app_data_alignment.ld>
#if defined(CONFIG_APP_SHARED_MEM) #if defined(CONFIG_USERSPACE)
#define APP_SHARED_ALIGN MPU_MIN_SIZE_ALIGN #define APP_SHARED_ALIGN MPU_MIN_SIZE_ALIGN
#define SMEM_PARTITION_ALIGN MPU_ALIGN #define SMEM_PARTITION_ALIGN MPU_ALIGN
@ -147,7 +147,7 @@ SECTIONS {
_image_ram_start = _app_smem_start; _image_ram_start = _app_smem_start;
_app_smem_size = _app_smem_end - _app_smem_start; _app_smem_size = _app_smem_end - _app_smem_start;
_app_smem_rom_start = LOADADDR(_APP_SMEM_SECTION_NAME); _app_smem_rom_start = LOADADDR(_APP_SMEM_SECTION_NAME);
#endif /* CONFIG_APP_SHARED_MEM */ #endif /* CONFIG_USERSPACE */
SECTION_DATA_PROLOGUE(_BSS_SECTION_NAME,(NOLOAD),) { SECTION_DATA_PROLOGUE(_BSS_SECTION_NAME,(NOLOAD),) {
MPU_MIN_SIZE_ALIGN MPU_MIN_SIZE_ALIGN

View file

@ -382,7 +382,7 @@ SECTIONS
_ramfunc_rom_start = LOADADDR(.ramfunc); _ramfunc_rom_start = LOADADDR(.ramfunc);
#endif /* CONFIG_ARCH_HAS_RAMFUNC_SUPPORT */ #endif /* CONFIG_ARCH_HAS_RAMFUNC_SUPPORT */
#if defined(CONFIG_APP_SHARED_MEM) #if defined(CONFIG_USERSPACE)
#define APP_SHARED_ALIGN . = ALIGN(_region_min_align); #define APP_SHARED_ALIGN . = ALIGN(_region_min_align);
#define SMEM_PARTITION_ALIGN MPU_ALIGN #define SMEM_PARTITION_ALIGN MPU_ALIGN
@ -390,7 +390,7 @@ SECTIONS
_app_smem_size = _app_smem_end - _app_smem_start; _app_smem_size = _app_smem_end - _app_smem_start;
_app_smem_rom_start = LOADADDR(_APP_SMEM_SECTION_NAME); _app_smem_rom_start = LOADADDR(_APP_SMEM_SECTION_NAME);
#endif /* CONFIG_APP_SHARED_MEM */ #endif /* CONFIG_USERSPACE */
SECTION_DATA_PROLOGUE(_BSS_SECTION_NAME,(NOLOAD),) SECTION_DATA_PROLOGUE(_BSS_SECTION_NAME,(NOLOAD),)
{ {

View file

@ -207,7 +207,7 @@ SECTIONS
__gcov_bss_size = __gcov_bss_end - __gcov_bss_start; __gcov_bss_size = __gcov_bss_end - __gcov_bss_start;
#endif /* CONFIG_COVERAGE_GCOV */ #endif /* CONFIG_COVERAGE_GCOV */
#ifdef CONFIG_APP_SHARED_MEM #ifdef CONFIG_USERSPACE
/* APP SHARED MEMORY REGION */ /* APP SHARED MEMORY REGION */
#define SMEM_PARTITION_ALIGN(size) MMU_PAGE_ALIGN #define SMEM_PARTITION_ALIGN(size) MMU_PAGE_ALIGN
#define APP_SHARED_ALIGN MMU_PAGE_ALIGN #define APP_SHARED_ALIGN MMU_PAGE_ALIGN
@ -219,12 +219,12 @@ SECTIONS
_app_smem_num_words = _app_smem_size >> 2; _app_smem_num_words = _app_smem_size >> 2;
_app_smem_rom_start = LOADADDR(_APP_SMEM_SECTION_NAME); _app_smem_rom_start = LOADADDR(_APP_SMEM_SECTION_NAME);
_app_smem_num_words = _app_smem_size >> 2; _app_smem_num_words = _app_smem_size >> 2;
#endif /* CONFIG_APP_SHARED_MEM */ #endif /* CONFIG_USERSPACE */
SECTION_PROLOGUE(_BSS_SECTION_NAME, (NOLOAD OPTIONAL),) SECTION_PROLOGUE(_BSS_SECTION_NAME, (NOLOAD OPTIONAL),)
{ {
MMU_PAGE_ALIGN MMU_PAGE_ALIGN
#if !defined(CONFIG_APP_SHARED_MEM) #if !defined(CONFIG_USERSPACE)
_image_ram_start = .; _image_ram_start = .;
#endif #endif
/* /*

View file

@ -36,7 +36,7 @@ __syscall size_t _zephyr_fwrite(const void *_MLIBC_RESTRICT ptr, size_t size,
size_t nitems, FILE *_MLIBC_RESTRICT stream); size_t nitems, FILE *_MLIBC_RESTRICT stream);
#endif /* CONFIG_NEWLIB_LIBC */ #endif /* CONFIG_NEWLIB_LIBC */
#ifdef CONFIG_APP_SHARED_MEM #ifdef CONFIG_USERSPACE
/* Memory partition containing the libc malloc arena */ /* Memory partition containing the libc malloc arena */
extern struct k_mem_partition z_malloc_partition; extern struct k_mem_partition z_malloc_partition;

View file

@ -46,7 +46,7 @@ void FUNC_NORETURN _StackCheckHandler(void)
* Symbol referenced by GCC compiler generated code for canary value. * Symbol referenced by GCC compiler generated code for canary value.
* The canary value gets initialized in _Cstart(). * The canary value gets initialized in _Cstart().
*/ */
#ifdef CONFIG_APP_SHARED_MEM #ifdef CONFIG_USERSPACE
K_APP_DMEM(z_libc_partition) uintptr_t __stack_chk_guard; K_APP_DMEM(z_libc_partition) uintptr_t __stack_chk_guard;
#else #else
__noinit uintptr_t __stack_chk_guard; __noinit uintptr_t __stack_chk_guard;

View file

@ -190,7 +190,7 @@ void _data_copy(void)
data_copy_xip_relocation(); data_copy_xip_relocation();
#endif /* CONFIG_CODE_DATA_RELOCATION */ #endif /* CONFIG_CODE_DATA_RELOCATION */
#ifdef CONFIG_APP_SHARED_MEM #ifdef CONFIG_USERSPACE
#ifdef CONFIG_STACK_CANARIES #ifdef CONFIG_STACK_CANARIES
/* stack canary checking is active for all C functions. /* stack canary checking is active for all C functions.
* __stack_chk_guard is some uninitialized value living in the * __stack_chk_guard is some uninitialized value living in the
@ -213,7 +213,7 @@ void _data_copy(void)
(void)memcpy(&_app_smem_start, &_app_smem_rom_start, (void)memcpy(&_app_smem_start, &_app_smem_rom_start,
((u32_t) &_app_smem_end - (u32_t) &_app_smem_start)); ((u32_t) &_app_smem_end - (u32_t) &_app_smem_start));
#endif /* CONFIG_STACK_CANARIES */ #endif /* CONFIG_STACK_CANARIES */
#endif /* CONFIG_APP_SHARED_MEM */ #endif /* CONFIG_USERSPACE */
} }
#endif #endif

View file

@ -727,6 +727,29 @@ out:
return ret; return ret;
} }
/*
* Application memory region initialization
*/
extern char __app_shmem_regions_start[];
extern char __app_shmem_regions_end[];
static int app_shmem_bss_zero(struct device *unused)
{
struct z_app_region *region, *end;
end = (struct z_app_region *)&__app_shmem_regions_end;
region = (struct z_app_region *)&__app_shmem_regions_start;
for ( ; region < end; region++) {
(void)memset(region->bss_start, 0, region->bss_size);
}
return 0;
}
SYS_INIT(app_shmem_bss_zero, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
/* /*
* Default handlers if otherwise unimplemented * Default handlers if otherwise unimplemented
*/ */

View file

@ -16,16 +16,16 @@
#include <logging/log.h> #include <logging/log.h>
LOG_MODULE_DECLARE(os); LOG_MODULE_DECLARE(os);
#ifdef CONFIG_APP_SHARED_MEM #ifdef CONFIG_USERSPACE
K_APPMEM_PARTITION_DEFINE(z_malloc_partition); K_APPMEM_PARTITION_DEFINE(z_malloc_partition);
#endif #endif
#if (CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE > 0) #if (CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE > 0)
#ifdef CONFIG_APP_SHARED_MEM #ifdef CONFIG_USERSPACE
#define POOL_SECTION K_APP_DMEM_SECTION(z_malloc_partition) #define POOL_SECTION K_APP_DMEM_SECTION(z_malloc_partition)
#else #else
#define POOL_SECTION .data #define POOL_SECTION .data
#endif /* CONFIG_APP_SHARED_MEM */ #endif /* CONFIG_USERSPACE */
K_MUTEX_DEFINE(malloc_mutex); K_MUTEX_DEFINE(malloc_mutex);
SYS_MEM_POOL_DEFINE(z_malloc_mem_pool, &malloc_mutex, 16, SYS_MEM_POOL_DEFINE(z_malloc_mem_pool, &malloc_mutex, 16,

View file

@ -59,7 +59,7 @@ extern void *_heap_sentry;
static unsigned char *heap_base = UINT_TO_POINTER(USED_RAM_END_ADDR); static unsigned char *heap_base = UINT_TO_POINTER(USED_RAM_END_ADDR);
#ifdef CONFIG_APP_SHARED_MEM #ifdef CONFIG_USERSPACE
struct k_mem_partition z_malloc_partition; struct k_mem_partition z_malloc_partition;
static int malloc_prepare(struct device *unused) static int malloc_prepare(struct device *unused)

View file

@ -1,2 +1 @@
CONFIG_USERSPACE=y CONFIG_USERSPACE=y
CONFIG_APP_SHARED_MEM=y

View file

@ -16,7 +16,7 @@ from elftools.elf.elffile import ELFFile
# This script will create sections and linker variables to place the # This script will create sections and linker variables to place the
# application shared memory partitions. # application shared memory partitions.
# these are later read by the macros defined in app_memdomain.h for # these are later read by the macros defined in app_memdomain.h for
# initialization purpose when APP_SHARED_MEM is enabled. # initialization purpose when USERSPACE is enabled.
data_template = """ data_template = """
/* Auto generated code do not modify */ /* Auto generated code do not modify */
SMEM_PARTITION_ALIGN(data_smem_{0}_bss_end - data_smem_{0}_start); SMEM_PARTITION_ALIGN(data_smem_{0}_bss_end - data_smem_{0}_start);

View file

@ -1,4 +1,3 @@
add_subdirectory_ifdef(CONFIG_APP_SHARED_MEM app_memory)
add_subdirectory(debug) add_subdirectory(debug)
add_subdirectory(logging) add_subdirectory(logging)
add_subdirectory_ifdef(CONFIG_BT bluetooth) add_subdirectory_ifdef(CONFIG_BT bluetooth)

View file

@ -37,8 +37,6 @@ source "subsys/settings/Kconfig"
source "subsys/testsuite/Kconfig" source "subsys/testsuite/Kconfig"
source "subsys/app_memory/Kconfig"
source "subsys/fb/Kconfig" source "subsys/fb/Kconfig"
source "subsys/jwt/Kconfig" source "subsys/jwt/Kconfig"

View file

@ -1,2 +0,0 @@
zephyr_library()
zephyr_library_sources(app_memdomain.c)

View file

@ -1,8 +0,0 @@
menu "General Kernel Options"
config APP_SHARED_MEM
bool "Application shared memory with app_memory"
help
This is a wrapper around app_memory to simplify usage.
endmenu

View file

@ -1,24 +0,0 @@
#include <zephyr.h>
#include <init.h>
#include <app_memory/app_memdomain.h>
#include <string.h>
#include <misc/__assert.h>
extern char __app_shmem_regions_start[];
extern char __app_shmem_regions_end[];
static int app_shmem_bss_zero(struct device *unused)
{
struct z_app_region *region, *end;
end = (struct z_app_region *)&__app_shmem_regions_end;
region = (struct z_app_region *)&__app_shmem_regions_start;
for ( ; region < end; region++) {
(void)memset(region->bss_start, 0, region->bss_size);
}
return 0;
}
SYS_INIT(app_shmem_bss_zero, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);

View file

@ -63,7 +63,6 @@ config TEST_USERSPACE
depends on ARCH_HAS_USERSPACE depends on ARCH_HAS_USERSPACE
depends on TEST depends on TEST
select USERSPACE select USERSPACE
select APP_SHARED_MEM
select DYNAMIC_OBJECTS select DYNAMIC_OBJECTS
default y default y
help help

View file

@ -143,7 +143,7 @@ static inline void unit_test_noop(void)
*/ */
/* definitions for use with testing application shared memory */ /* definitions for use with testing application shared memory */
#ifdef CONFIG_APP_SHARED_MEM #ifdef CONFIG_USERSPACE
#define ZTEST_DMEM K_APP_DMEM(ztest_mem_partition) #define ZTEST_DMEM K_APP_DMEM(ztest_mem_partition)
#define ZTEST_BMEM K_APP_BMEM(ztest_mem_partition) #define ZTEST_BMEM K_APP_BMEM(ztest_mem_partition)
#define ZTEST_SECTION K_APP_DMEM_SECTION(ztest_mem_partition) #define ZTEST_SECTION K_APP_DMEM_SECTION(ztest_mem_partition)

View file

@ -7,7 +7,7 @@
#include <ztest.h> #include <ztest.h>
#include <stdio.h> #include <stdio.h>
#include <app_memory/app_memdomain.h> #include <app_memory/app_memdomain.h>
#ifdef CONFIG_APP_SHARED_MEM #ifdef CONFIG_USERSPACE
#include <misc/libc-hooks.h> #include <misc/libc-hooks.h>
#endif #endif
@ -282,7 +282,7 @@ void end_report(void)
} }
} }
#ifdef CONFIG_APP_SHARED_MEM #ifdef CONFIG_USERSPACE
struct k_mem_domain ztest_mem_domain; struct k_mem_domain ztest_mem_domain;
K_APPMEM_PARTITION_DEFINE(ztest_mem_partition); K_APPMEM_PARTITION_DEFINE(ztest_mem_partition);
#endif #endif
@ -299,7 +299,7 @@ int main(void)
#else #else
void main(void) void main(void)
{ {
#ifdef CONFIG_APP_SHARED_MEM #ifdef CONFIG_USERSPACE
struct k_mem_partition *parts[] = { struct k_mem_partition *parts[] = {
&ztest_mem_partition, &ztest_mem_partition,
/* C library globals, stack canary storage, etc */ /* C library globals, stack canary storage, etc */
@ -314,7 +314,7 @@ void main(void)
*/ */
k_mem_domain_init(&ztest_mem_domain, ARRAY_SIZE(parts), parts); k_mem_domain_init(&ztest_mem_domain, ARRAY_SIZE(parts), parts);
k_mem_domain_add_thread(&ztest_mem_domain, k_current_get()); k_mem_domain_add_thread(&ztest_mem_domain, k_current_get());
#endif /* CONFIG_APP_SHARED_MEM */ #endif /* CONFIG_USERSPACE */
_init_mock(); _init_mock();
test_main(); test_main();

View file

@ -207,7 +207,7 @@ void test_main(void)
{ {
k_thread_access_grant(k_current_get(), &thread_preempt, &stack_preempt, k_thread_access_grant(k_current_get(), &thread_preempt, &stack_preempt,
&start_sema, &end_sema); &start_sema, &end_sema);
#ifdef CONFIG_APP_SHARED_MEM #ifdef CONFIG_USERSPACE
k_mem_domain_add_thread(&ztest_mem_domain, T_KDEFINE_COOP_THREAD); k_mem_domain_add_thread(&ztest_mem_domain, T_KDEFINE_COOP_THREAD);
k_mem_domain_add_thread(&ztest_mem_domain, T_KDEFINE_PREEMPT_THREAD); k_mem_domain_add_thread(&ztest_mem_domain, T_KDEFINE_PREEMPT_THREAD);
#endif #endif