/usr/include/xenomai/asm-arm/fptest.h is in libxenomai-dev 2.6.4+dfsg-0.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | /*
* Copyright (C) 2006-2013 Gilles Chanteperdrix <gch@xenomai.org>.
*
* Xenomai is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version.
*
* Xenomai is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Xenomai; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifndef _XENO_ASM_ARM_FPTEST_H
#define _XENO_ASM_ARM_FPTEST_H
#ifdef __KERNEL__
#include <linux/module.h>
#include <asm/hwcap.h>
#ifdef CONFIG_VFP
#define have_vfp (elf_hwcap & HWCAP_VFP)
#else /* !CONFIG_VFP */
#define have_vfp (0)
#endif /* !CONFIG_VFP */
static inline int fp_kernel_supported(void)
{
return 1;
}
static inline int fp_linux_begin(void)
{
return -ENOSYS;
}
static inline void fp_linux_end(void)
{
}
static inline void fp_features_init(void)
{
}
#else /* !__KERNEL__ */
#include <stdio.h>
#include <string.h>
#define printk(fmt, args...) fprintf(stderr, fmt, ## args)
static int have_vfp;
static void fp_features_init(void)
{
char buffer[1024];
FILE *f = fopen("/proc/cpuinfo", "r");
if(!f)
return;
while(fgets(buffer, sizeof(buffer), f)) {
if(strncmp(buffer, "Features", sizeof("Features") - 1))
continue;
if (strstr(buffer, "vfp")) {
have_vfp = 1;
break;
}
}
fclose(f);
}
#endif /* !__KERNEL__ */
static inline void fp_regs_set(unsigned val)
{
if (have_vfp) {
unsigned long long e[16];
unsigned i;
for (i = 0; i < 16; i++)
e[i] = val;
/* vldm %0!, {d0-d15},
AKA fldmiax %0!, {d0-d15} */
__asm__ __volatile__("ldc p11, cr0, [%0],#32*4":
"=r"(i): "0"(&e[0]): "memory");
}
}
static inline unsigned fp_regs_check(unsigned val)
{
unsigned result = val;
if (have_vfp) {
unsigned long long e[16];
unsigned i;
/* vstm %0!, {d0-d15},
AKA fstmiax %0!, {d0-d15} */
__asm__ __volatile__("stc p11, cr0, [%0],#32*4":
"=r"(i): "0"(&e[0]): "memory");
for (i = 0; i < 16; i++)
if (e[i] != val) {
printk("d%d: %llu != %u\n", i, e[i], val);
result = e[i];
}
}
return result;
}
#endif /* _XENO_ASM_ARM_FPTEST_H */
|