1#
2# Copyright 2020, Data61, CSIRO (ABN 41 687 119 230)
3#
4# SPDX-License-Identifier: GPL-2.0-only
5#
6
7from typing import List
8
9from hardware.device import WrappedNode
10from hardware.fdt import FdtParser
11
12# documentation for CPU bindings:
13# https://www.kernel.org/doc/Documentation/devicetree/bindings/arm/cpus.yaml
14
15
16def get_cpus(tree: FdtParser) -> List[WrappedNode]:
17    ' Return a list of all the CPUs described in this device tree. '
18    cpus_node = tree.get_path('/cpus')
19
20    found_cpus = []
21    for node in cpus_node:
22        if node.has_prop('device_type') and node.get_prop('device_type').strings[0] == 'cpu':
23            found_cpus.append(node)
24
25    return found_cpus
26