MCPcopy Create free account
hub / github.com/F-Stack/f-stack / platform_cpu_mask

Function platform_cpu_mask

freebsd/mips/beri/beri_mp.c:68–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66}
67
68void
69platform_cpu_mask(cpuset_t *mask)
70{
71 int ncores, ncpus, nthreads;
72 phandle_t cpus, cpu;
73 pcell_t reg;
74 char prop[16];
75 struct spin_entry *se;
76
77 ncores = beri_get_ncores();
78 nthreads = beri_get_nthreads();
79 KASSERT(ncores <= 0x10000, ("%s: too many cores %d", __func__, ncores));
80 KASSERT(nthreads <= 0x10000, ("%s: too many threads %d", __func__,
81 nthreads));
82 KASSERT(ncores < 0xffff || nthreads < 0xffff,
83 ("%s: cores x thread (%d x %d) would overflow", __func__, ncores,
84 nthreads));
85 ncpus = ncores * nthreads;
86 if (MAXCPU > 1 && ncpus > MAXCPU)
87 printf("%s: Hardware supports more CPUs (%d) than kernel (%d)\n",
88 __func__, ncpus, MAXCPU);
89 printf("%s: hardware has %d cores with %d threads each\n", __func__,
90 ncores, nthreads);
91
92 if ((cpus = OF_finddevice("/cpus")) <= 0) {
93 printf("%s: no \"/cpus\" device found in FDT\n", __func__);
94 goto error;
95 }
96 if ((cpu = OF_child(cpus)) <= 0) {
97 printf("%s: no children of \"/cpus\" found in FDT\n", __func__);
98 goto error;
99 }
100 CPU_ZERO(mask);
101 do {
102 if (OF_getprop(cpu, "reg", &reg, sizeof(reg)) <= 0) {
103 printf("%s: cpu device with no reg property\n",
104 __func__);
105 goto error;
106 }
107 if (reg > MAXCPU) {
108 printf("%s: cpu ID too large (%d > %d)\n", __func__,
109 reg, MAXCPU);
110 continue;
111 }
112 cpu_of_nodes[reg] = cpu;
113
114 if (reg != 0) {
115 if (OF_getprop(cpu, "enable-method", &prop,
116 sizeof(prop)) <= 0 && OF_getprop(OF_parent(cpu),
117 "enable-method", &prop, sizeof(prop)) <= 0) {
118 printf("%s: CPU %d has no enable-method "
119 "property\n", __func__, reg);
120 continue;
121 }
122 if (strcmp("spin-table", prop) != 0) {
123 printf("%s: CPU %d enable-method is '%s' not "
124 "'spin-table'\n", __func__, reg, prop);
125 continue;

Callers

nothing calls this directly

Calls 4

beri_get_ncoresFunction · 0.85
beri_get_nthreadsFunction · 0.85
strcmpFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected