| 834 | } |
| 835 | |
| 836 | struct rt_ofw_node *rt_ofw_get_cpu_node(int cpu, int *thread, rt_bool_t (*match_cpu_hwid)(int cpu, rt_uint64_t hwid)) |
| 837 | { |
| 838 | const char *propname = "reg"; |
| 839 | struct rt_ofw_node *cpu_np = RT_NULL; |
| 840 | |
| 841 | /* |
| 842 | * "reg" (some of the obsolete arch may be other names): |
| 843 | * The value of reg is a <prop-encoded-array> that defines a unique |
| 844 | * CPU/thread id for the CPU/threads represented by the CPU node. |
| 845 | * |
| 846 | * If a CPU supports more than one thread (i.e. multiple streams of |
| 847 | * execution) the reg property is an array with 1 element per thread. The |
| 848 | * #address-cells on the /cpus node specifies how many cells each element |
| 849 | * of the array takes. Software can determine the number of threads by |
| 850 | * dividing the size of reg by the parent node’s #address-cells: |
| 851 | * |
| 852 | * thread-number = reg-cells / address-cells |
| 853 | * |
| 854 | * If a CPU/thread can be the target of an external interrupt the reg |
| 855 | * property value must be a unique CPU/thread id that is addressable by the |
| 856 | * interrupt controller. |
| 857 | * |
| 858 | * If a CPU/thread cannot be the target of an external interrupt, then reg |
| 859 | * must be unique and out of bounds of the range addressed by the interrupt |
| 860 | * controller |
| 861 | * |
| 862 | * If a CPU/thread’s PIR (pending interrupt register) is modifiable, a |
| 863 | * client program should modify PIR to match the reg property value. If PIR |
| 864 | * cannot be modified and the PIR value is distinct from the interrupt |
| 865 | * controller number space, the CPUs binding may define a binding-specific |
| 866 | * representation of PIR values if desired. |
| 867 | */ |
| 868 | |
| 869 | rt_ofw_foreach_cpu_node(cpu_np) |
| 870 | { |
| 871 | rt_ssize_t prop_len = 0; |
| 872 | rt_bool_t is_end = RT_FALSE; |
| 873 | int tid, addr_cells = rt_ofw_io_addr_cells(cpu_np); |
| 874 | const fdt32_t *cell = rt_ofw_prop_read_raw(cpu_np, propname, &prop_len); |
| 875 | |
| 876 | if (!cell && !addr_cells) |
| 877 | { |
| 878 | if (match_cpu_hwid && match_cpu_hwid(cpu, 0)) |
| 879 | { |
| 880 | break; |
| 881 | } |
| 882 | |
| 883 | continue; |
| 884 | } |
| 885 | |
| 886 | if (!match_cpu_hwid) |
| 887 | { |
| 888 | continue; |
| 889 | } |
| 890 | |
| 891 | prop_len /= sizeof(*cell) * addr_cells; |
| 892 | |
| 893 | for (tid = 0; tid < prop_len; ++tid) |
nothing calls this directly
no test coverage detected