-/* $OpenBSD: cpu.c,v 1.22 2018/08/04 11:55:40 kettenis Exp $ */
+/* $OpenBSD: cpu.c,v 1.23 2018/08/18 11:34:08 kettenis Exp $ */
/*
* Copyright (c) 2016 Dale Rahn <drahn@dalerahn.com>
cpu_match(struct device *parent, void *cfdata, void *aux)
{
struct fdt_attach_args *faa = aux;
+ uint64_t mpidr = READ_SPECIALREG(mpidr_el1);
char buf[32];
- if (OF_getprop(faa->fa_node, "device_type", buf, sizeof(buf)) > 0 &&
- strcmp(buf, "cpu") == 0)
+ if (OF_getprop(faa->fa_node, "device_type", buf, sizeof(buf)) <= 0 ||
+ strcmp(buf, "cpu") != 0)
+ return 0;
+
+ if (ncpus < MAXCPUS || faa->fa_reg[0].addr == (mpidr & MPIDR_AFF))
return 1;
return 0;
ci->ci_next = cpu_info_list->ci_next;
cpu_info_list->ci_next = ci;
ci->ci_flags |= CPUF_AP;
+ ncpus++;
}
#endif
uint64_t tcr;
int s;
- ncpus++;
ci->ci_flags |= CPUF_PRESENT;
__asm volatile("dsb sy");