Xenomai  3.1.2
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)
36  : "0"(&e[0])
37  : "d0", "d1", "d2", "d3", "d4", "d5",
38  "d6", "d7", "d8", "d9", "d10", "d11",
39  "d12", "d13", "d14", "d15",
40  "memory");
41  }
42 }
43 
44 static inline unsigned int fp_regs_check(int features, unsigned int val,
45  int (*report)(const char *fmt, ...))
46 {
47  unsigned int result = val, i;
48  unsigned long long e[16];
49 
50  if (features & __COBALT_HAVE_VFP) {
51  /* vstm %0!, {d0-d15},
52  AKA fstmiax %0!, {d0-d15} */
53  __asm__ __volatile__("stc p11, cr0, [%0],#32*4":
54  "=r"(i): "0"(&e[0]): "memory");
55 
56  for (i = 0; i < 16; i++)
57  if (e[i] != val) {
58  report("d%d: %llu != %u\n", i, e[i], val);
59  result = e[i];
60  }
61  }
62 
63  return result;
64 }
65 
66 #endif /* !_COBALT_ARM_ASM_UAPI_FPTEST_H */