18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2023 WANG Xuerui <git@xen0n.name> 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * raid6/loongarch.h 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Definitions common to LoongArch RAID-6 code only 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#ifndef _LIB_RAID6_LOONGARCH_H 118c2ecf20Sopenharmony_ci#define _LIB_RAID6_LOONGARCH_H 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#ifdef __KERNEL__ 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#include <asm/cpu-features.h> 168c2ecf20Sopenharmony_ci#include <asm/fpu.h> 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#else /* for user-space testing */ 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#include <sys/auxv.h> 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci/* have to supply these defines for glibc 2.37- and musl */ 238c2ecf20Sopenharmony_ci#ifndef HWCAP_LOONGARCH_LSX 248c2ecf20Sopenharmony_ci#define HWCAP_LOONGARCH_LSX (1 << 4) 258c2ecf20Sopenharmony_ci#endif 268c2ecf20Sopenharmony_ci#ifndef HWCAP_LOONGARCH_LASX 278c2ecf20Sopenharmony_ci#define HWCAP_LOONGARCH_LASX (1 << 5) 288c2ecf20Sopenharmony_ci#endif 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci#define kernel_fpu_begin() 318c2ecf20Sopenharmony_ci#define kernel_fpu_end() 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci#define cpu_has_lsx (getauxval(AT_HWCAP) & HWCAP_LOONGARCH_LSX) 348c2ecf20Sopenharmony_ci#define cpu_has_lasx (getauxval(AT_HWCAP) & HWCAP_LOONGARCH_LASX) 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci#endif /* __KERNEL__ */ 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci#endif /* _LIB_RAID6_LOONGARCH_H */ 39