zephyr/doc/services
Carlo Caione e4a125b6a4 dt: Make zephyr,memory-attr a capabilities bitmask
This is the final step in making the `zephyr,memory-attr` property
actually useful.

The problem with the current implementation is that `zephyr,memory-attr`
is an enum type, this is making very difficult to use that to actually
describe the memory capabilities. The solution proposed in this PR is to
use the `zephyr,memory-attr` property as an OR-ed bitmask of memory
attributes.

With the change proposed in this PR it is possible in the DeviceTree to
mark the memory regions with a bitmask of attributes by using the
`zephyr,memory-attr` property. This property and the related memory
region can then be retrieved at run-time by leveraging a provided helper
library or the usual DT helpers.

The set of general attributes that can be specified in the property are
defined and explained in
`include/zephyr/dt-bindings/memory-attr/memory-attr.h` (the list can be
extended when needed).

For example, to mark a memory region in the DeviceTree as volatile,
non-cacheable, out-of-order:

   mem: memory@10000000 {
       compatible = "mmio-sram";
       reg = <0x10000000 0x1000>;
       zephyr,memory-attr = <( DT_MEM_VOLATILE |
			       DT_MEM_NON_CACHEABLE |
			       DT_MEM_OOO )>;
   };

The `zephyr,memory-attr` property can also be used to set
architecture-specific custom attributes that can be interpreted at run
time. This is leveraged, among other things, to create MPU regions out
of DeviceTree defined memory regions on ARM, for example:

   mem: memory@10000000 {
       compatible = "mmio-sram";
       reg = <0x10000000 0x1000>;
       zephyr,memory-region = "NOCACHE_REGION";
       zephyr,memory-attr = <( DT_ARM_MPU(ATTR_MPU_RAM_NOCACHE) )>;
   };

See `include/zephyr/dt-bindings/memory-attr/memory-attr-mpu.h` to see
how an architecture can define its own special memory attributes (in
this case ARM MPU).

The property can also be used to set custom software-specific
attributes. For example we can think of marking a memory region as
available to be used for memory allocation (not yet implemented):

   mem: memory@10000000 {
       compatible = "mmio-sram";
       reg = <0x10000000 0x1000>;
       zephyr,memory-attr = <( DT_MEM_NON_CACHEABLE |
			       DT_MEM_SW_ALLOCATABLE )>;
   };

Or maybe we can leverage the property to specify some alignment
requirements for the region:

   mem: memory@10000000 {
       compatible = "mmio-sram";
       reg = <0x10000000 0x1000>;
       zephyr,memory-attr = <( DT_MEM_CACHEABLE |
			       DT_MEM_SW_ALIGN(32) )>;
   };

The conventional and recommended way to deal and manage with memory
regions marked with attributes is by using the provided `mem-attr`
helper library by enabling `CONFIG_MEM_ATTR` (or by using the usual DT
helpers).

When this option is enabled the list of memory regions and their
attributes are compiled in a user-accessible array and a set of
functions is made available that can be used to query, probe and act on
regions and attributes, see `include/zephyr/mem_mgmt/mem_attr.h`

Note that the `zephyr,memory-attr` property is only a descriptive
property of the capabilities of the associated memory  region, but it
does not result in any actual setting for the memory to be set. The
user, code or subsystem willing to use this information to do some work
(for example creating an MPU region out of the property) must use either
the provided `mem-attr` library or the usual DeviceTree helpers to
perform the required work / setting.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-09-15 12:46:54 +02:00
..
crypto Revert "random: Change testing random generator" 2023-01-09 19:29:50 +09:00
debugging doc: services: debug: coredump: add flash partition 2023-06-21 16:06:06 -04:00
device_mgmt doc: services: device_mgmt: smp: Add SMP version 2 details 2023-09-06 13:05:40 +02:00
dsp zdsp: add ARC DSPLIB backend for zdsp 2023-02-21 15:06:06 +01:00
file_system
input input: rename callback define macro to INPUT_CALLBACK_DEFINE 2023-08-10 08:15:10 +00:00
ipc documentation: Fix several typos 2023-08-07 13:07:50 +02:00
logging doc: drop usage of numref 2023-05-22 11:08:53 +02:00
mem_mgmt dt: Make zephyr,memory-attr a capabilities bitmask 2023-09-15 12:46:54 +02:00
modbus
pm doc: Add hint for automatic power domain swiching 2023-07-20 16:23:36 +02:00
portability docs: update posix docs with pthread_equal 2023-07-20 16:24:16 +02:00
resource_management
retention doc: Add documentation for retention subsystem 2023-04-24 13:27:53 +02:00
rtio rtio: Remove references to simple executor 2023-08-16 20:41:18 +02:00
sensing doc: sensing: fix structure and remove top doxygen reference 2023-06-19 22:09:47 -04:00
settings doc: Switch main return type from void to int. 2023-04-14 07:49:41 +09:00
shell doc: shell: fix incorrect use of :kbd: role 2023-09-13 11:35:44 +02:00
smf drivers: gpio: use gpio_is_ready_dt helper function 2023-08-28 08:48:35 -05:00
storage doc: disk: Mention eMMC support in disk subsystem 2023-08-18 10:14:01 +02:00
task_wdt
tfm doc: tfm: Update TFM overview.rst 2023-08-23 10:05:45 +02:00
tracing samples: fully migrate basic samples to the new Sphinx extension 2023-09-13 09:15:34 +02:00
virtualization doc: ivshmem: Simple syntax correction 2023-08-31 10:00:06 -04:00
zbus doc: zbus: samples: Use new Sphinx extension to document samples 2023-09-11 19:56:57 +02:00
formatted_output.rst
index.rst dt: Make zephyr,memory-attr a capabilities bitmask 2023-09-15 12:46:54 +02:00
misc.rst
notify.rst
poweroff.rst lib: os: add support for system power off 2023-08-04 16:59:36 +02:00