platform/efi: platform_cpu_info
* This models the CpuInfo into a cross-architecture platform_cpu_info * Originally I was looking at merging this with "arch_cpu_info" however that is "overall cpu" while CpuInfo is "indivial core information" packed into an array. * Since every dtb platform will report individual cores in fdt, having a common cpu core info struct with at minimum the core id makes sense. * This could likely be refined further to some kind of core info packed inside of arch_cpu_info, but this will fix arm,arm64,etc for now until someone wants to dive into that. Change-Id: Ia18a352403cd0da7130c1e637fc205d4311478ef Reviewed-on: https://review.haiku-os.org/c/haiku/+/4363 Reviewed-by: Fredrik Holmqvist <[email protected]> Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
committed by
Alex von Gluck IV
parent
9e511d5342
commit
a03687553b
@@ -5,17 +5,18 @@
|
|||||||
#ifndef KERNEL_BOOT_PLATFORM_EFI_ARCH_SMP_H
|
#ifndef KERNEL_BOOT_PLATFORM_EFI_ARCH_SMP_H
|
||||||
#define KERNEL_BOOT_PLATFORM_EFI_ARCH_SMP_H
|
#define KERNEL_BOOT_PLATFORM_EFI_ARCH_SMP_H
|
||||||
|
|
||||||
|
|
||||||
#include <boot/menu.h>
|
#include <boot/menu.h>
|
||||||
|
|
||||||
|
|
||||||
#ifdef __riscv
|
#if defined(__riscv) || defined(__ARM__) || defined(__ARM64__)
|
||||||
|
// These platforms take inventory of cpu cores from fdt
|
||||||
|
|
||||||
struct CpuInfo {
|
struct platform_cpu_info {
|
||||||
uint32 id;
|
uint32 id;
|
||||||
};
|
};
|
||||||
|
|
||||||
void arch_smp_register_cpu(CpuInfo** cpu);
|
void arch_smp_register_cpu(platform_cpu_info** cpu);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,24 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static platform_cpu_info sCpus[SMP_MAX_CPUS];
|
||||||
|
uint32 sCpuCount = 0;
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
arch_smp_register_cpu(platform_cpu_info** cpu)
|
||||||
|
{
|
||||||
|
dprintf("arch_smp_register_cpu()\n");
|
||||||
|
uint32 newCount = sCpuCount + 1;
|
||||||
|
if (newCount > SMP_MAX_CPUS) {
|
||||||
|
*cpu = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
*cpu = &sCpus[sCpuCount];
|
||||||
|
sCpuCount = newCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
arch_smp_get_current_cpu(void)
|
arch_smp_get_current_cpu(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ struct CpuEntryInfo {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static CpuInfo sCpus[SMP_MAX_CPUS];
|
static platform_cpu_info sCpus[SMP_MAX_CPUS];
|
||||||
uint32 sCpuCount = 0;
|
uint32 sCpuCount = 0;
|
||||||
|
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ CpuEntry(int hartId, CpuEntryInfo* info)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
arch_smp_register_cpu(CpuInfo** cpu)
|
arch_smp_register_cpu(platform_cpu_info** cpu)
|
||||||
{
|
{
|
||||||
dprintf("arch_smp_register_cpu()\n");
|
dprintf("arch_smp_register_cpu()\n");
|
||||||
uint32 newCount = sCpuCount + 1;
|
uint32 newCount = sCpuCount + 1;
|
||||||
|
|||||||
@@ -356,11 +356,12 @@ HandleFdt(const void* fdt, int node, uint32 addressCells, uint32 sizeCells,
|
|||||||
|
|
||||||
if (deviceType != NULL) {
|
if (deviceType != NULL) {
|
||||||
if (strcmp(deviceType, "cpu") == 0) {
|
if (strcmp(deviceType, "cpu") == 0) {
|
||||||
CpuInfo* info;
|
platform_cpu_info* info;
|
||||||
arch_smp_register_cpu(&info);
|
arch_smp_register_cpu(&info);
|
||||||
if (info == NULL)
|
if (info == NULL)
|
||||||
return;
|
return;
|
||||||
info->id = fdt32_to_cpu(*(uint32*)fdt_getprop(fdt, node, "reg", NULL));
|
info->id = fdt32_to_cpu(*(uint32*)fdt_getprop(fdt, node,
|
||||||
|
"reg", NULL));
|
||||||
dprintf("cpu\n");
|
dprintf("cpu\n");
|
||||||
dprintf(" id: %" B_PRIu32 "\n", info->id);
|
dprintf(" id: %" B_PRIu32 "\n", info->id);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user