Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Devicetree Interrupt CPU API

Macros

#define DT_FOREACH_CPU(fn)
 Invokes fn for each child of the devicetree's "/cpus" node whose device_type is "cpu".
#define DT_FOREACH_CPU_SEP(fn, sep)
 Invokes fn for each child of the devicetree's "/cpus" node whose device_type is "cpu", with a separator.
#define DT_FOREACH_CPU_VARGS(fn, ...)
 Invokes fn for each child of the devicetree's "/cpus" node whose device_type is "cpu", with multiple arguments.
#define DT_FOREACH_CPU_SEP_VARGS(fn, sep, ...)
 Invokes fn for each child of the devicetree's "/cpus" node whose device_type is "cpu", with a separator and multiple arguments.
#define DT_FOREACH_CPU_STATUS_OKAY(fn)
 Invokes fn for each child of the devicetree's "/cpus" node whose device_type is "cpu" and status is "okay".
#define DT_FOREACH_CPU_STATUS_OKAY_SEP(fn, sep)
 Invokes fn for each child of the devicetree's "/cpus" node whose device_type is "cpu" and status is "okay", with a separator.
#define DT_FOREACH_CPU_STATUS_OKAY_SEP_VARGS(fn, sep, ...)
 Invokes fn for each child of the devicetree's "/cpus" node whose device_type is "cpu" and status is "okay", with a separator and multiple arguments.

Detailed Description

Macro Definition Documentation

◆ DT_FOREACH_CPU

#define DT_FOREACH_CPU ( fn)

#include <cpu.h>

Value:
DT_FOREACH_CHILD_VARGS(DT_PATH(cpus), DT_FOREACH_CPU_INTERNAL, fn)
#define DT_FOREACH_CHILD_VARGS(node_id, fn,...)
Invokes fn for each child of node_id with multiple arguments.
Definition devicetree.h:3467
#define DT_PATH(...)
Get a node identifier for a devicetree path.
Definition devicetree.h:141

Invokes fn for each child of the devicetree's "/cpus" node whose device_type is "cpu".

The macro fn must take one parameter, which will be the node identifier of a "/cpus" child node with device_type = "cpu". Children of "/cpus" that do not have device_type = "cpu" are skipped.

Example devicetree fragment:

cpus {
cpu0: cpu@0 {
device_type = "cpu";
reg = <0>;
};
cpu1: cpu@1 {
device_type = "cpu";
reg = <1>;
};
power-states {
idle: idle { ... };
};
};

Example usage:

#define REG_AND_COMMA(node_id) DT_REG_ADDR(node_id),
const uint32_t cpu_regs[] = {
DT_FOREACH_CPU(REG_AND_COMMA)
};
#define DT_FOREACH_CPU(fn)
Invokes fn for each child of the devicetree's "/cpus" node whose device_type is "cpu".
Definition cpu.h:74
__UINT32_TYPE__ uint32_t
Definition stdint.h:90

This expands to:

const uint32_t cpu_regs[] = {
0, 1,
};

Notice that "power-states" is skipped, since its device_type is not "cpu".

Parameters
fnmacro to invoke

◆ DT_FOREACH_CPU_SEP

#define DT_FOREACH_CPU_SEP ( fn,
sep )

#include <cpu.h>

Value:
DT_FOREACH_CHILD_VARGS(DT_PATH(cpus), DT_FOREACH_CPU_SEP_INTERNAL, fn, sep)

Invokes fn for each child of the devicetree's "/cpus" node whose device_type is "cpu", with a separator.

The macro fn must take one parameter, which will be the node identifier of a "/cpus" child node with device_type = "cpu". Children of "/cpus" that do not have device_type = "cpu" are skipped.

sep is placed after each invocation of fn, not between invocations. This means the expansion has a trailing sep, which is convenient for initializers since a trailing comma is legal.

Example usage:

const uint32_t cpu_regs[] = {
};
#define DT_FOREACH_CPU_SEP(fn, sep)
Invokes fn for each child of the devicetree's "/cpus" node whose device_type is "cpu",...
Definition cpu.h:103
#define DT_REG_ADDR(node_id)
Get a node's (only) register block address.
Definition devicetree.h:2584
Parameters
fnmacro to invoke
sepSeparator (e.g. comma or semicolon) placed after each invocation of fn. Must be in parentheses; this is required to enable providing a comma as separator.
See also
DT_FOREACH_CPU

◆ DT_FOREACH_CPU_SEP_VARGS

#define DT_FOREACH_CPU_SEP_VARGS ( fn,
sep,
... )

#include <cpu.h>

Value:
DT_FOREACH_CHILD_VARGS(DT_PATH(cpus), DT_FOREACH_CPU_SEP_VARGS_INTERNAL, fn, sep, \
__VA_ARGS__)

Invokes fn for each child of the devicetree's "/cpus" node whose device_type is "cpu", with a separator and multiple arguments.

The macro fn takes multiple arguments. The remaining are passed-in by the caller.

Parameters
fnmacro to invoke
sepSeparator (e.g. comma or semicolon) placed after each invocation of fn. Must be in parentheses; this is required to enable providing a comma as separator.
...variable number of arguments to pass to fn
See also
DT_FOREACH_CPU_SEP

◆ DT_FOREACH_CPU_STATUS_OKAY

#define DT_FOREACH_CPU_STATUS_OKAY ( fn)

#include <cpu.h>

Value:
DT_FOREACH_CHILD_VARGS(DT_PATH(cpus), DT_FOREACH_CPU_STATUS_OKAY_INTERNAL, fn)

Invokes fn for each child of the devicetree's "/cpus" node whose device_type is "cpu" and status is "okay".

This macro iterates through children of the "/cpus" node in the same order as they appear in the final devicetree, but children whose status is not okay are also skipped.

Parameters
fnmacro to invoke
See also
DT_FOREACH_CPU

◆ DT_FOREACH_CPU_STATUS_OKAY_SEP

#define DT_FOREACH_CPU_STATUS_OKAY_SEP ( fn,
sep )

#include <cpu.h>

Value:
DT_FOREACH_CHILD_VARGS(DT_PATH(cpus), DT_FOREACH_CPU_STATUS_OKAY_SEP_INTERNAL, fn, sep)

Invokes fn for each child of the devicetree's "/cpus" node whose device_type is "cpu" and status is "okay", with a separator.

This macro iterates through children of the "/cpus" node in the same order as they appear in the final devicetree, but children whose status is not okay are also skipped.

Parameters
fnmacro to invoke
sepSeparator (e.g. comma or semicolon) placed after each invocation of fn. Must be in parentheses; this is required to enable providing a comma as separator.
See also
DT_FOREACH_CPU_SEP

◆ DT_FOREACH_CPU_STATUS_OKAY_SEP_VARGS

#define DT_FOREACH_CPU_STATUS_OKAY_SEP_VARGS ( fn,
sep,
... )

#include <cpu.h>

Value:
DT_FOREACH_CHILD_VARGS(DT_PATH(cpus), DT_FOREACH_CPU_STATUS_OKAY_SEP_VARGS_INTERNAL, fn, \
sep, __VA_ARGS__)

Invokes fn for each child of the devicetree's "/cpus" node whose device_type is "cpu" and status is "okay", with a separator and multiple arguments.

This macro iterates through children of the "/cpus" node in the same order as they appear in the final devicetree, but children whose status is not okay are also skipped.

Parameters
fnmacro to invoke
sepSeparator (e.g. comma or semicolon) placed after each invocation of fn. Must be in parentheses; this is required to enable providing a comma as separator.
...variable number of arguments to pass to fn
See also
DT_FOREACH_CPU_STATUS_OKAY_SEP

◆ DT_FOREACH_CPU_VARGS

#define DT_FOREACH_CPU_VARGS ( fn,
... )

#include <cpu.h>

Value:
DT_FOREACH_CHILD_VARGS(DT_PATH(cpus), DT_FOREACH_CPU_VARGS_INTERNAL, fn, __VA_ARGS__)

Invokes fn for each child of the devicetree's "/cpus" node whose device_type is "cpu", with multiple arguments.

The macro fn takes multiple arguments. The first should be the node identifier for the "/cpus" child node. The remaining are passed-in by the caller.

Parameters
fnmacro to invoke
...variable number of arguments to pass to fn
See also
DT_FOREACH_CPU