Zephyr API Documentation 4.3.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
map.h File Reference

Map devicetree macro public API header file. More...

Go to the source code of this file.

Macros

#define DT_NODE_HAS_MAP(node_id, prop)
 Returns the existence of map property.
#define DT_MAP_LEN(node_id, prop)
 Returns the number of maps for the given property.
#define DT_MAP_HAS_ENTRY_BY_IDX(node_id, prop, entry_idx)
 Is index idx valid for an array type property?
#define DT_MAP_HAS_ENTRY(node_id, prop)
 Checks if the map property has any entries.
#define DT_MAP_ENTRY_CHILD_ADDRESS_LEN(node_id, prop, entry_idx)
 Get the number of child addresses.
#define DT_MAP_ENTRY_HAS_CHILD_ADDRESS_BY_IDX(node_id, prop, entry_idx, param_idx)
 Checks if the child address has the specified index.
#define DT_MAP_ENTRY_HAS_CHILD_ADDRESS(node_id, prop, entry_idx)
 Checks if the mapping entry has any child addresses.
#define DT_MAP_ENTRY_CHILD_ADDRESS_BY_IDX(node_id, prop, entry_idx, param_idx)
 Get the child address element from a mapping entry, by index.
#define DT_MAP_ENTRY_CHILD_ADDRESS(node_id, prop, entry_idx)
 Get the first child address element from a mapping entry.
#define DT_MAP_ENTRY_CHILD_SPECIFIER_LEN(node_id, prop, entry_idx)
 Get the number of child specifiers.
#define DT_MAP_ENTRY_HAS_CHILD_SPECIFIER_BY_IDX(node_id, prop, entry_idx, param_idx)
 Checks if the child specifier has the specified index.
#define DT_MAP_ENTRY_HAS_CHILD_SPECIFIER(node_id, prop, entry_idx)
 Checks if the mapping entry has any child specifiers.
#define DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(node_id, prop, entry_idx, param_idx)
 Get the child specifier element from a mapping entry, by index.
#define DT_MAP_ENTRY_CHILD_SPECIFIER(node_id, prop, entry_idx)
 Get the first child specifier element from a mapping entry.
#define DT_MAP_ENTRY_PARENT_BY_IDX(node_id, prop, entry_idx)
 Extracts the parent node from a mapping entry.
#define DT_MAP_ENTRY_PARENT(node_id, prop)
 Extracts the parent node from the first mapping entry.
#define DT_MAP_ENTRY_PARENT_ADDRESS_LEN(node_id, prop, entry_idx)
 Get the number of parent addresses.
#define DT_MAP_ENTRY_HAS_PARENT_ADDRESS_BY_IDX(node_id, prop, entry_idx, param_idx)
 Checks if the parent address has the specified index.
#define DT_MAP_ENTRY_HAS_PARENT_ADDRESS(node_id, prop, entry_idx)
 Checks if the mapping entry has any parent addresses.
#define DT_MAP_ENTRY_PARENT_ADDRESS_BY_IDX(node_id, prop, entry_idx, param_idx)
 Get the parent address element from a mapping entry, by index.
#define DT_MAP_ENTRY_PARENT_ADDRESS(node_id, prop, entry_idx)
 Get the first parent address element from a mapping entry.
#define DT_MAP_ENTRY_PARENT_SPECIFIER_LEN(node_id, prop, entry_idx)
 Get the number of parent specifiers.
#define DT_MAP_ENTRY_HAS_PARENT_SPECIFIER_BY_IDX(node_id, prop, entry_idx, param_idx)
 Checks if the parent specifier has the specified index.
#define DT_MAP_ENTRY_HAS_PARENT_SPECIFIER(node_id, prop, entry_idx)
 Checks if the mapping entry has any parent specifiers.
#define DT_MAP_ENTRY_PARENT_SPECIFIER_BY_IDX(node_id, prop, entry_idx, param_idx)
 Get the parent specifier element from a mapping entry, by index.
#define DT_MAP_ENTRY_PARENT_SPECIFIER(node_id, prop, entry_idx)
 Get the first parent specifier element from a mapping entry.
#define DT_FOREACH_MAP_ENTRY(node_id, prop, fn)
 Invokes fn for each map entry in the map.
#define DT_FOREACH_MAP_ENTRY_SEP(node_id, prop, fn, sep)
 Invokes fn for each map entry in the map with separator.
#define DT_FOREACH_MAP_ENTRY_VARGS(node_id, prop, fn, ...)
 Invokes fn for each map entry in the map with separator.
#define DT_FOREACH_MAP_ENTRY_SEP_VARGS(node_id, prop, fn, sep, ...)
 Invokes fn for each map entry in the map with separator.

Detailed Description

Map devicetree macro public API header file.

This module provides helper macros that facilitate interrupt mapping and specifier mapping based on DeviceTree specifications. It enables the extraction and interpretation of mapping data represented as phandle-arrays.

In a typical DeviceTree fragment, properties ending with "-map" specify:

  • The child specifier to be mapped.
  • The parent node (phandle) to which the mapping applies.
  • The parent specifier associated with the mapping.

For example, when the following DeviceTree snippet is defined:

n: node {
gpio-map = <0 1 &gpio0 2 3>, <4 5 &gpio0 6 7>;
};

In the first mapping entry:

  • 0 1 are the child specifiers.
  • &gpio0 is the parent node.
  • 2 3 are the parent specifiers.

The map API provides the following macros for access to specific parts of a mapping entry:

These macros extract, respectively, the child specifier arguments, the parent specifier arguments, and the parent node argument from a mapping element identified by its node ID, property name, and index.

For instance:

#define SRC_AND_DST(node_id, map, entry_idx) \
{ DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(node_id, map, entry_idx, 0), \
DT_MAP_ENTRY_PARENT_SPECIFIER_BY_IDX(node_id, map, entry_idx, 0) }
int src_and_dst[][2] = {
DT_FOREACH_MAP_ENTRY_SEP(DT_NODELABEL(n), gpio_map, SRC_AND_DST, (,))
};
#define DT_NODELABEL(label)
Get a node identifier for a node label.
Definition devicetree.h:197
#define DT_FOREACH_MAP_ENTRY_SEP(node_id, prop, fn, sep)
Invokes fn for each map entry in the map with separator.
Definition map.h:422

The above expansion yields:

int src_and_dst[][2] = {{0, 2}, {4, 6}};