Commit 46def95f authored by Andrew Boie's avatar Andrew Boie Committed by Anas Nashif
Browse files

doc: memory domain updates



Update memory domain documentation to reflect the policy, API,
and code changes in this PR.

Signed-off-by: default avatarAndrew Boie <andrew.p.boie@intel.com>
parent 00f71b0d
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -786,11 +786,23 @@ details:
  number of regions for a memory domain. MMU systems have an unlimited amount,
  MPU systems have constraints on this.

* :cpp:func:`arch_mem_domain_partition_remove()` Remove a partition from
  a memory domain if the currently executing thread was part of that domain.
Some architectures may need to update software memory management structures
or modify hardware registers on another CPU when memory domain APIs are invoked.
If so, CONFIG_ARCH_MEM_DOMAIN_SYNCHRONOUS_API must be selected by the
architecture and some additional APIs must be implemented. This is common
on MMU systems and uncommon on MPU systems:

* :cpp:func:`arch_mem_domain_destroy()` Reset the thread's memory domain
  configuration
* :cpp:func:`arch_mem_domain_thread_add()`

* :cpp:func:`arch_mem_domain_thread_remove()`

* :cpp:func:`arch_mem_domain_partition_add()`

* :cpp:func:`arch_mem_domain_partition_remove()`

* :cpp:func:`arch_mem_domain_destroy()`

Please see the doxygen documentation of these APIs for details.

In addition to implementing these APIs, there are some other tasks as well:

+15 −19
Original line number Diff line number Diff line
@@ -146,12 +146,21 @@ mode. In some cases this may be unavoidable; for example some architectures do
not allow for the definition of regions which are read-only to user mode but
read-write to supervisor mode. A great deal of care must be taken when working
with such regions to not unintentionally cause the kernel to crash when
accessing such a region.
accessing such a region. Any attempt to use memory domain APIs to control
supervisor mode access is at best undefined behavior; supervisor mode access
policy is only intended to be controlled by boot-time memory regions.

Memory domain APIs are only available to supervisor mode. The only control
user mode has over memory domains is that any user thread's child threads
will automatically become members of the parent's domain.

All threads are members of a memory domain, including supervisor threads
(even though this has no implications on their memory access). There is a
default domain ``k_mem_domain_default`` which will be assigned to threads if
they have not been specifically assigned to a domain, or inherited a memory
domain membership from their parent thread. The main thread starts as a
member of the default domain.

Memory Partitions
=================

@@ -395,6 +404,9 @@ call:

    k_mem_domain_add_thread(&app0_domain, app_thread_id);

If the thread was already a member of some other domain (including the
default domain), it will be removed from it in favor of the new one.

In addition, if a thread is a member of a memory domain, and it creates a
child thread, that thread will belong to the domain as well.

@@ -412,24 +424,6 @@ The k_mem_domain_remove_partition() API finds the memory partition
that matches the given parameter and removes that partition from the
memory domain.

Remove a Thread from the Memory Domain
--------------------------------------

The following code shows how to remove a thread from the memory domain.

.. code-block:: c

    k_mem_domain_remove_thread(app_thread_id);

Destroy a Memory Domain
-----------------------

The following code shows how to destroy a memory domain.

.. code-block:: c

    k_mem_domain_destroy(&app0_domain);

Available Partition Attributes
------------------------------

@@ -450,6 +444,8 @@ Some examples of partition attributes are:
    /* Denote partition is privileged read/write, unprivileged read-only */
    K_MEM_PARTITION_P_RW_U_RO

In almost all cases ``K_MEM_PARTITION_P_RW_U_RW`` is the right choice.

Configuration Options
*********************