mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-11-05 20:35:44 +00:00
0885f1221e
Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Jiajie Chen <c@jia.je> Message-Id: <20230916220151.526140-4-richard.henderson@linaro.org>
35 lines
673 B
C
35 lines
673 B
C
/*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
* Host specific cpu identification for LoongArch.
|
|
*/
|
|
|
|
#include "qemu/osdep.h"
|
|
#include "host/cpuinfo.h"
|
|
|
|
#ifdef CONFIG_GETAUXVAL
|
|
# include <sys/auxv.h>
|
|
#else
|
|
# include "elf.h"
|
|
#endif
|
|
#include <asm/hwcap.h>
|
|
|
|
unsigned cpuinfo;
|
|
|
|
/* Called both as constructor and (possibly) via other constructors. */
|
|
unsigned __attribute__((constructor)) cpuinfo_init(void)
|
|
{
|
|
unsigned info = cpuinfo;
|
|
unsigned long hwcap;
|
|
|
|
if (info) {
|
|
return info;
|
|
}
|
|
|
|
hwcap = qemu_getauxval(AT_HWCAP);
|
|
|
|
info = CPUINFO_ALWAYS;
|
|
info |= (hwcap & HWCAP_LOONGARCH_LSX ? CPUINFO_LSX : 0);
|
|
|
|
cpuinfo = info;
|
|
return info;
|
|
}
|