Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
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. More...
 

Functions

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

Variables

struct k_mem_domain k_mem_domain_default
 

Detailed Description

Macro Definition Documentation

◆ K_MEM_PARTITION_DEFINE

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

#include <include/app_memory/mem_domain.h>

Value:
struct k_mem_partition name =\
__UINTPTR_TYPE__ uintptr_t
Definition: stdint.h:75
Memory Partition.
Definition: mem_domain.h:55
uintptr_t start
Definition: mem_domain.h:57
size_t size
Definition: mem_domain.h:59
k_mem_partition_attr_t attr
Definition: mem_domain.h:61

Statically declare a memory partition.

Function Documentation

◆ k_mem_domain_add_partition()

void k_mem_domain_add_partition ( struct k_mem_domain domain,
struct k_mem_partition part 
)

#include <include/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

◆ k_mem_domain_add_thread()

void k_mem_domain_add_thread ( struct k_mem_domain domain,
k_tid_t  thread 
)

#include <include/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.

◆ k_mem_domain_init()

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

#include <include/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.

◆ k_mem_domain_remove_partition()

void k_mem_domain_remove_partition ( struct k_mem_domain domain,
struct k_mem_partition part 
)

#include <include/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

Variable Documentation

◆ k_mem_domain_default

struct k_mem_domain k_mem_domain_default
extern

#include <include/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.