Xenomai  3.0.8
fptest.h
1 /*
2  * Copyright (C) 2006 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13 
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18 #ifndef _COBALT_ARM_ASM_UAPI_FPTEST_H
19 #define _COBALT_ARM_ASM_UAPI_FPTEST_H
20 
21 #define __COBALT_HAVE_VFP 0x1
22 
23 static inline void fp_regs_set(int features, unsigned int val)
24 {
25  unsigned long long e[16];
26  unsigned int i;
27 
28  if (features & __COBALT_HAVE_VFP) {
29  for (i = 0; i < 16; i++)
30  e[i] = val;
31 
32  /* vldm %0!, {d0-d15},
33  AKA fldmiax %0!, {d0-d15} */
34  __asm__ __volatile__("ldc p11, cr0, [%0],#32*4":
35  "=r"(i): "0"(&e[0]): "memory");
36  }
37 }
38 
39 static inline unsigned int fp_regs_check(int features, unsigned int val,
40  int (*report)(const char *fmt, ...))
41 {
42  unsigned int result = val, i;
43  unsigned long long e[16];
44 
45  if (features & __COBALT_HAVE_VFP) {
46  /* vstm %0!, {d0-d15},
47  AKA fstmiax %0!, {d0-d15} */
48  __asm__ __volatile__("stc p11, cr0, [%0],#32*4":
49  "=r"(i): "0"(&e[0]): "memory");
50 
51  for (i = 0; i < 16; i++)
52  if (e[i] != val) {
53  report("d%d: %llu != %u\n", i, e[i], val);
54  result = e[i];
55  }
56  }
57 
58  return result;
59 }
60 
61 #endif /* !_COBALT_ARM_ASM_UAPI_FPTEST_H */