userspace: add optional member to memory domains

Some systems may need to associate arch-specific data to
a memory domain. Add a Kconfig and `arch` field for this,
and a new arch API to initialize it.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2020-08-19 13:11:47 -07:00 committed by Anas Nashif
commit bc35b0b780
4 changed files with 54 additions and 0 deletions

View file

@ -12,6 +12,10 @@
#include <stdbool.h>
#include <spinlock.h>
#define LOG_LEVEL CONFIG_KERNEL_LOG_LEVEL
#include <logging/log.h>
LOG_MODULE_DECLARE(os);
static struct k_spinlock lock;
static uint8_t max_partitions;
@ -124,6 +128,20 @@ void k_mem_domain_init(struct k_mem_domain *domain, uint8_t num_parts,
sys_dlist_init(&domain->mem_domain_q);
#ifdef CONFIG_ARCH_MEM_DOMAIN_DATA
int ret = arch_mem_domain_init(domain);
/* TODO propagate return values, see #24609.
*
* Not using an assertion here as this is a memory allocation error
*/
if (ret != 0) {
LOG_ERR("architecture-specific initialization failed for domain %p with %d",
domain, ret);
k_panic();
}
#endif
k_spin_unlock(&lock, key);
}