static int init_plic(void) { struct udevice *dev; int ret; ret = uclass_find_first_device(UCLASS_CPU, &dev); if (ret) return ret; if (ret == 0 && dev) { ret = cpu_get_count(dev); if (ret < 0) return ret; enable_ipi(ret); return 0; } return -ENODEV; }
void acpi_create_gnvs(struct acpi_global_nvs *gnvs) { struct udevice *dev; int ret; /* at least we have one processor */ gnvs->pcnt = 1; /* override the processor count with actual number */ ret = uclass_find_first_device(UCLASS_CPU, &dev); if (ret == 0 && dev != NULL) { ret = cpu_get_count(dev); if (ret > 0) gnvs->pcnt = ret; } /* determine whether internal uart is on */ if (IS_ENABLED(CONFIG_INTERNAL_UART)) gnvs->iuart_en = 1; else gnvs->iuart_en = 0; }
int mp_init(struct mp_params *p) { int num_aps; atomic_t *ap_count; struct udevice *cpu; int ret; /* This will cause the CPUs devices to be bound */ struct uclass *uc; ret = uclass_get(UCLASS_CPU, &uc); if (ret) return ret; ret = init_bsp(&cpu); if (ret) { debug("Cannot init boot CPU: err=%d\n", ret); return ret; } if (p == NULL || p->flight_plan == NULL || p->num_records < 1) { printf("Invalid MP parameters\n"); return -1; } num_cpus = cpu_get_count(cpu); if (num_cpus < 0) { debug("Cannot get number of CPUs: err=%d\n", num_cpus); return num_cpus; } if (num_cpus < 2) debug("Warning: Only 1 CPU is detected\n"); ret = check_cpu_devices(num_cpus); if (ret) debug("Warning: Device tree does not describe all CPUs. Extra ones will not be started correctly\n"); /* Copy needed parameters so that APs have a reference to the plan */ mp_info.num_records = p->num_records; mp_info.records = p->flight_plan; /* Load the SIPI vector */ ret = load_sipi_vector(&ap_count); if (ap_count == NULL) return -1; /* * Make sure SIPI data hits RAM so the APs that come up will see * the startup code even if the caches are disabled */ wbinvd(); /* Start the APs providing number of APs and the cpus_entered field */ num_aps = num_cpus - 1; ret = start_aps(num_aps, ap_count); if (ret) { mdelay(1000); debug("%d/%d eventually checked in?\n", atomic_read(ap_count), num_aps); return ret; } /* Walk the flight plan for the BSP */ ret = bsp_do_flight_plan(cpu, p); if (ret) { debug("CPU init failed: err=%d\n", ret); return ret; } return 0; }
int main(int argc, char *argv[]) { int flags; unsigned long long start = 0; start = nanotime(); results = (tResults *)malloc( sizeof(tResults) ); memset(results, 0, sizeof(tResults)); flags = parse_args(argc, argv); if ((flags & FLAG_NETS_STAT) && (flags & FLAG_NETC_STAT)) { fprintf(stderr, "Error: Cannot use network client and network server together!\n"); return 1; } if (flags & FLAG_CA_GET) get_affinity(); if (flags & FLAG_CPU_GET) { uint32_t proc; proc = cpu_get_count(); results->cpu_online = PROCESSOR_COUNT_ONLINE(proc); results->cpu_total = PROCESSOR_COUNT_TOTAL(proc); DPRINTF("Processors: %d total / %d online\n", PROCESSOR_COUNT_TOTAL(proc), PROCESSOR_COUNT_ONLINE(proc)); } if (flags & FLAG_CPU_SPEED) { results->cpu_speed = cpu_get_speed_mhz(); DPRINTF("Measured CPU Speed is: %.*f Mhz\n", prec, cpu_get_speed_mhz()); } if (flags & FLAG_CPU_DHRYSTONE) { unsigned long dhrystone, loops, btime; cpu_dhrystone_get(&dhrystone, &loops, &btime); results->cpu_dhrystone = (float)dhrystone / 1757; DPRINTF("Dhrystone: %.*f DMIPS(*), loops: %lu, benchmark time: %ld\n", prec, (float)dhrystone / 1757, loops, btime); DPRINTF("* Calculated as dhrystone store divided by 1757 (see: http://en.wikipedia.org/wiki/Dhrystone)\n"); } if (flags & FLAG_CPU_WHETSTONE) { unsigned long loops, iter, btime, mips; cpu_whetstone_get(&loops, &iter, &btime, &mips); results->cpu_whetstone = mips; DPRINTF("Whetstone: %lu MIPS, loops: %lu, iteration count: %ld, benchmark time: %ld sec\n", mips, loops, iter, btime); } if (flags & FLAG_CPU_LINPACK) { unsigned long memory; float minMFLOPS, maxMFLOPS, avgMFLOPS; get_linpack_score(lpArrSize, &memory, &minMFLOPS, &maxMFLOPS, &avgMFLOPS); results->cpu_linpack_size = lpArrSize; results->cpu_linpack_mem = memory; results->cpu_linpack_min = minMFLOPS; results->cpu_linpack_max = maxMFLOPS; results->cpu_linpack_avg = avgMFLOPS; DPRINTF("Linpack array size: %dx%d, memory %ld KB, MFLOPS: min=%.*f, max=%.*f, average=%.*f\n", lpArrSize, lpArrSize, memory >> 10, prec, minMFLOPS, prec, maxMFLOPS, prec, avgMFLOPS); DPRINTF("* For more information about LINPACK benchmarking see http://en.wikipedia.org/wiki/Linpack\n"); }