Lines Matching refs:cpu

68 static int cpuctl_do_msr(int cpu, cpuctl_msr_args_t *data, u_long cmd,
70 static void cpuctl_do_cpuid(int cpu, cpuctl_cpuid_args_t *data,
72 static void cpuctl_do_cpuid_count(int cpu, cpuctl_cpuid_count_args_t *data,
74 static int cpuctl_do_update(int cpu, cpuctl_update_args_t *data,
76 static int update_intel(int cpu, cpuctl_update_args_t *args,
78 static int update_amd(int cpu, cpuctl_update_args_t *args, struct thread *td);
79 static int update_via(int cpu, cpuctl_update_args_t *args,
93 * This function checks if specified cpu enabled or not.
96 cpu_enabled(int cpu)
99 return (pmc_cpu_is_disabled(cpu) == 0);
103 * Check if the current thread is bound to a specific cpu.
117 * Switch to target cpu to run.
120 set_cpu(int cpu, struct thread *td)
123 KASSERT(cpu >= 0 && cpu < mp_ncpus && cpu_enabled(cpu),
124 ("[cpuctl,%d]: bad cpu number %d", __LINE__, cpu));
126 sched_bind(td, cpu);
128 KASSERT(td->td_oncpu == cpu,
129 ("[cpuctl,%d]: cannot bind to target cpu %d", __LINE__, cpu));
137 ("[cpuctl,%d]: bad cpu number %d", __LINE__, oldcpu));
151 int cpu = dev2unit(dev);
153 if (cpu >= mp_ncpus || !cpu_enabled(cpu)) {
154 DPRINTF("[cpuctl,%d]: bad cpu number %d\n", __LINE__, cpu);
163 ret = cpuctl_do_msr(cpu, (cpuctl_msr_args_t *)data, cmd, td);
171 ret = cpuctl_do_msr(cpu, (cpuctl_msr_args_t *)data, cmd, td);
174 cpuctl_do_cpuid(cpu, (cpuctl_cpuid_args_t *)data, td);
181 ret = cpuctl_do_update(cpu, (cpuctl_update_args_t *)data, td);
184 cpuctl_do_cpuid_count(cpu, (cpuctl_cpuid_count_args_t *)data,
200 cpuctl_do_cpuid_count(int cpu, cpuctl_cpuid_count_args_t *data,
206 KASSERT(cpu >= 0 && cpu < mp_ncpus,
207 ("[cpuctl,%d]: bad cpu number %d", __LINE__, cpu));
211 DPRINTF("[cpuctl,%d]: retrieving cpuid lev %#0x type %#0x for %d cpu\n",
212 __LINE__, data->level, data->level_type, cpu);
215 set_cpu(cpu, td);
221 cpuctl_do_cpuid(int cpu, cpuctl_cpuid_args_t *data, struct thread *td)
228 cpuctl_do_cpuid_count(cpu, &cdata, td);
236 cpuctl_do_msr(int cpu, cpuctl_msr_args_t *data, u_long cmd, struct thread *td)
243 KASSERT(cpu >= 0 && cpu < mp_ncpus,
244 ("[cpuctl,%d]: bad cpu number %d", __LINE__, cpu));
250 DPRINTF("[cpuctl,%d]: operating on MSR %#0x for %d cpu\n", __LINE__,
251 data->msr, cpu);
254 set_cpu(cpu, td);
282 cpuctl_do_update(int cpu, cpuctl_update_args_t *data, struct thread *td)
290 KASSERT(cpu >= 0 && cpu < mp_ncpus,
291 ("[cpuctl,%d]: bad cpu number %d", __LINE__, cpu));
292 DPRINTF("[cpuctl,%d]: XXX %d", __LINE__, cpu);
294 cpuctl_do_cpuid(cpu, &args, td);
300 ret = update_intel(cpu, data, td);
302 ret = update_amd(cpu, data, td);
304 ret = update_via(cpu, data, td);
311 update_intel(int cpu, cpuctl_update_args_t *args, struct thread *td)
343 set_cpu(cpu, td);
370 update_amd(int cpu, cpuctl_update_args_t *args, struct thread *td)
403 set_cpu(cpu, td);
425 update_via(int cpu, cpuctl_update_args_t *args, struct thread *td)
455 set_cpu(cpu, td);
485 DPRINTF("[cpu,%d]: rev0=%x rev1=%x res=%x\n", __LINE__,
501 int cpu;
503 cpu = dev2unit(dev);
504 if (cpu >= mp_ncpus || !cpu_enabled(cpu)) {
505 DPRINTF("[cpuctl,%d]: incorrect cpu number %d\n", __LINE__,
506 cpu);
517 int cpu;
530 for (cpu = 0; cpu < mp_ncpus; cpu++)
531 if (cpu_enabled(cpu))
532 cpuctl_devs[cpu] = make_dev(&cpuctl_cdevsw, cpu,
533 UID_ROOT, GID_KMEM, 0640, "cpuctl%d", cpu);
536 for (cpu = 0; cpu < mp_ncpus; cpu++) {
537 if (cpuctl_devs[cpu] != NULL)
538 destroy_dev(cpuctl_devs[cpu]);