Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Memory domain APIs

Modules

 Application memory domain APIs
 Application memory domain APIs.
 

Data Structures

struct  k_mem_partition
 Memory Partition. More...
 
struct  k_mem_domain
 Memory Domain. More...
 

Macros

#define K_MEM_PARTITION_DEFINE(name, start, size, attr)
 Statically declare a memory partition.
 

Functions

int k_mem_domain_init (struct k_mem_domain *domain, uint8_t num_parts, struct k_mem_partition *parts[])
 Initialize a memory domain.
 
int k_mem_domain_add_partition (struct k_mem_domain *domain, struct k_mem_partition *part)
 Add a memory partition into a memory domain.
 
int k_mem_domain_remove_partition (struct k_mem_domain *domain, struct k_mem_partition *part)
 Remove a memory partition from a memory domain.
 
int k_mem_domain_add_thread (struct k_mem_domain *domain, k_tid_t thread)
 Add a thread into a memory domain.
 

Variables

struct k_mem_domain k_mem_domain_default
 Default memory domain.
 

Detailed Description

Macro Definition Documentation

◆ K_MEM_PARTITION_DEFINE

#define K_MEM_PARTITION_DEFINE (   name,
  start,
  size,
  attr 
)

#include <zephyr/app_memory/mem_domain.h>

Value:
struct k_mem_partition name =\
__UINTPTR_TYPE__ uintptr_t
Definition: stdint.h:105
Memory Partition.
Definition: mem_domain.h:55
uintptr_t start
start address of memory partition
Definition: mem_domain.h:57
size_t size
size of memory partition
Definition: mem_domain.h:59
k_mem_partition_attr_t attr
attribute of memory partition
Definition: mem_domain.h:61

Statically declare a memory partition.

Function Documentation

◆ k_mem_domain_add_partition()

int k_mem_domain_add_partition ( struct k_mem_domain domain,
struct k_mem_partition part 
)

#include <zephyr/app_memory/mem_domain.h>

Add a memory partition into a memory domain.

Add a memory partition into a memory domain. Partitions must conform to the following constraints:

  • Partitions in the same memory domain may not overlap each other.
  • Partitions must not be defined which expose private kernel data structures or kernel objects.
  • The starting address alignment, and the partition size must conform to the constraints of the underlying memory management hardware, which varies per architecture.
  • Memory domain partitions are only intended to control access to memory from user mode threads.
  • If CONFIG_EXECUTE_XOR_WRITE is enabled, the partition must not allow both writes and execution.

Violating these constraints may lead to CPU exceptions or undefined behavior.

Parameters
domainThe memory domain to be added a memory partition.
partThe memory partition to be added
Return values
0if successful
-EINVALif invalid parameters supplied
-ENOSPCif no free partition slots available

◆ k_mem_domain_add_thread()

int k_mem_domain_add_thread ( struct k_mem_domain domain,
k_tid_t  thread 
)

#include <zephyr/app_memory/mem_domain.h>

Add a thread into a memory domain.

Add a thread into a memory domain. It will be removed from whatever memory domain it previously belonged to.

Parameters
domainThe memory domain that the thread is going to be added into.
threadID of thread going to be added into the memory domain.
Returns
0 if successful, fails otherwise.

◆ k_mem_domain_init()

int k_mem_domain_init ( struct k_mem_domain domain,
uint8_t  num_parts,
struct k_mem_partition parts[] 
)

#include <zephyr/app_memory/mem_domain.h>

Initialize a memory domain.

Initialize a memory domain with given name and memory partitions.

See documentation for k_mem_domain_add_partition() for details about partition constraints.

Do not call k_mem_domain_init() on the same memory domain more than once, doing so is undefined behavior.

Parameters
domainThe memory domain to be initialized.
num_partsThe number of array items of "parts" parameter.
partsAn array of pointers to the memory partitions. Can be NULL if num_parts is zero.
Return values
0if successful
-EINVALif invalid parameters supplied
-ENOMEMif insufficient memory

◆ k_mem_domain_remove_partition()

int k_mem_domain_remove_partition ( struct k_mem_domain domain,
struct k_mem_partition part 
)

#include <zephyr/app_memory/mem_domain.h>

Remove a memory partition from a memory domain.

Remove a memory partition from a memory domain.

Parameters
domainThe memory domain to be removed a memory partition.
partThe memory partition to be removed
Return values
0if successful
-EINVALif invalid parameters supplied
-ENOENTif no matching partition found

Variable Documentation

◆ k_mem_domain_default

struct k_mem_domain k_mem_domain_default
extern

#include <zephyr/app_memory/mem_domain.h>

Default memory domain.

All threads are a member of some memory domain, even if running in supervisor mode. Threads belong to this default memory domain if they haven't been added to or inherited membership from some other domain.

This memory domain has the z_libc_partition partition for the C library added to it if exists.