From 2ab042f11e5848089b343cc565acb65d4a5bc64a Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Thu, 25 Dec 2014 17:44:49 +0100 Subject: [PATCH] getfcr: change getfcr/setfcr to use VFP --- arm/include/u.h | 37 +++++++++++++++++++-------------- sys/src/ape/lib/ap/arm/getfcr.s | 17 +++++++++------ sys/src/libc/arm/getfcr.s | 11 +++++++++- sys/src/libc/arm/getfcr.vfp.S | 21 ------------------- 4 files changed, 42 insertions(+), 44 deletions(-) delete mode 100644 sys/src/libc/arm/getfcr.vfp.S diff --git a/arm/include/u.h b/arm/include/u.h index 916b8cc6f..5a86e34d8 100644 --- a/arm/include/u.h +++ b/arm/include/u.h @@ -21,27 +21,32 @@ typedef unsigned short u16int; typedef unsigned int u32int; typedef unsigned long long u64int; -/* FCR */ -#define FPINEX (1<<20) -#define FPUNFL (1<<19) -#define FPOVFL (1<<18) -#define FPZDIV (1<<17) -#define FPINVAL (1<<16) -#define FPRNR (0<<0) -#define FPRZ (1<<0) -#define FPRPINF (2<<0) -#define FPRNINF (3<<0) -#define FPRMASK (3<<0) +/* VFP FPSCR (exceptions) */ +#define FPINEX (1<<12) +#define FPUNFL (1<<11) +#define FPOVFL (1<<10) +#define FPZDIV (1<<9) +#define FPINVAL (1<<8) + +/* VFP FPSCR (rounding) */ +#define FPRNR (0<<22) +#define FPRPINF (1<<22) +#define FPRNINF (2<<22) +#define FPRZ (3<<22) + +#define FPRMASK (3<<22) + +/* VFP FPSCR (status) */ #define FPPEXT 0 #define FPPSGL 0 #define FPPDBL 0 #define FPPMASK 0 -/* FSR */ -#define FPAINEX (1<<4) -#define FPAUNFL (1<<3) -#define FPAOVFL (1<<2) -#define FPAZDIV (1<<1) +#define FPAINEX (1<<4) +#define FPAUNFL (1<<3) +#define FPAOVFL (1<<2) +#define FPAZDIV (1<<1) #define FPAINVAL (1<<0) + union FPdbleword { double x; diff --git a/sys/src/ape/lib/ap/arm/getfcr.s b/sys/src/ape/lib/ap/arm/getfcr.s index b27c7f082..4822a5f5b 100644 --- a/sys/src/ape/lib/ap/arm/getfcr.s +++ b/sys/src/ape/lib/ap/arm/getfcr.s @@ -1,16 +1,21 @@ +/* for VFP */ +#define VMRS(fp, cpu) WORD $(0xeef00a10 | (fp)<<16 | (cpu)<<12) /* FP → arm */ +#define VMSR(cpu, fp) WORD $(0xeee00a10 | (fp)<<16 | (cpu)<<12) /* arm → FP */ -TEXT setfcr(SB), $4 - MOVW R0, FPCR +#define Fpscr 1 + +TEXT setfcr(SB), $0 + VMSR(0, Fpscr) RET -TEXT getfcr(SB), $4 - MOVW FPCR, R0 +TEXT getfcr(SB), $0 + VMRS(Fpscr, 0) RET TEXT getfsr(SB), $0 - MOVW FPSR, R0 + VMSR(0, Fpscr) RET TEXT setfsr(SB), $0 - MOVW R0, FPSR + VMRS(Fpscr, 0) RET diff --git a/sys/src/libc/arm/getfcr.s b/sys/src/libc/arm/getfcr.s index dc9a207bc..4822a5f5b 100644 --- a/sys/src/libc/arm/getfcr.s +++ b/sys/src/libc/arm/getfcr.s @@ -1,12 +1,21 @@ +/* for VFP */ +#define VMRS(fp, cpu) WORD $(0xeef00a10 | (fp)<<16 | (cpu)<<12) /* FP → arm */ +#define VMSR(cpu, fp) WORD $(0xeee00a10 | (fp)<<16 | (cpu)<<12) /* arm → FP */ + +#define Fpscr 1 + TEXT setfcr(SB), $0 + VMSR(0, Fpscr) RET TEXT getfcr(SB), $0 + VMRS(Fpscr, 0) RET TEXT getfsr(SB), $0 + VMSR(0, Fpscr) RET TEXT setfsr(SB), $0 + VMRS(Fpscr, 0) RET - diff --git a/sys/src/libc/arm/getfcr.vfp.S b/sys/src/libc/arm/getfcr.vfp.S deleted file mode 100644 index 4822a5f5b..000000000 --- a/sys/src/libc/arm/getfcr.vfp.S +++ /dev/null @@ -1,21 +0,0 @@ -/* for VFP */ -#define VMRS(fp, cpu) WORD $(0xeef00a10 | (fp)<<16 | (cpu)<<12) /* FP → arm */ -#define VMSR(cpu, fp) WORD $(0xeee00a10 | (fp)<<16 | (cpu)<<12) /* arm → FP */ - -#define Fpscr 1 - -TEXT setfcr(SB), $0 - VMSR(0, Fpscr) - RET - -TEXT getfcr(SB), $0 - VMRS(Fpscr, 0) - RET - -TEXT getfsr(SB), $0 - VMSR(0, Fpscr) - RET - -TEXT setfsr(SB), $0 - VMRS(Fpscr, 0) - RET