Commit 828a010f authored by Andrew Hodgkinson's avatar Andrew Hodgkinson
Browse files

Added modulefp_enable and modulefp_disable to allow floating point code usage...

Added modulefp_enable and modulefp_disable to allow floating point code usage from within modules. Added also fpsr_manipulate to read and set the

FPSR. First two tested on an STB from within Video Control, last one
not tested but the code is lifted straight from JSLib (where it works).

Version 0.05. Tagged as 'AsmUtils-0_05'
parent ed9966d9
......@@ -19,7 +19,8 @@
# ***********************************
# Date Name Description
# ---- ---- -----------
# 20-Nov-99 SNB Created.
# 20-Nov-1999 SNB Created.
# 10-Feb-2000 ADH Added modulefp and fpsr.
#
#
......@@ -77,13 +78,13 @@ SOURCE =
EXPORTS =
OBJS= o.callbacks o.sixtyfour o.heapswis o.rminfo o.irqs \
o.osvarlen o.muldiv
o.osvarlen o.muldiv o.modulefp o.fpsr
OBJSZ= oz.callbacks oz.sixtyfour oz.heapswis oz.rminfo oz.irqs \
oz.osvarlen oz.muldiv
oz.osvarlen oz.muldiv oz.modulefp oz.fpsr
HDRS= h.callbacks h.sixtyfour h.heapswis h.rminfo h.irqs \
h.osvarlen h.muldiv
h.osvarlen h.muldiv h.modulefp h.fpsr
LIBS = ${TARGET} ${TARGETZ}
......@@ -126,6 +127,8 @@ export_hdrs: ${HDRS} export_dirs
${CP} h.irqs ${LIBDIR}.h.irqs ${CPFLAGS}
${CP} h.osvarlen ${LIBDIR}.h.osvarlen ${CPFLAGS}
${CP} h.muldiv ${LIBDIR}.h.muldiv ${CPFLAGS}
${CP} h.modulefp ${LIBDIR}.h.modulefp ${CPFLAGS}
${CP} h.fpsr ${LIBDIR}.h.fpsr ${CPFLAGS}
${CP} VersionNum ${LIBDIR}.LibVersion ${CPFLAGS}
@echo ${COMPONENT}: export complete (hdrs)
......
/* (0.04)
/* (0.05)
*
* This file is automatically maintained by srccommit, do not edit manually.
*
*/
#define Module_MajorVersion_CMHG 0.04
#define Module_MajorVersion_CMHG 0.05
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 30 Nov 1999
#define Module_Date_CMHG 10 Feb 2000
#define Module_MajorVersion "0.04"
#define Module_Version 4
#define Module_MajorVersion "0.05"
#define Module_Version 5
#define Module_MinorVersion ""
#define Module_Date "30 Nov 1999"
#define Module_Date "10 Feb 2000"
#define Module_FullVersion "0.04"
#define Module_FullVersion "0.05"
/* Copyright 2000 Pace Micro Technology plc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* File : fpsr.h
* Purpose: Manipulate the floating point status register
* (C interface)
* Authors: KJB, ADH
* History: 20-Apr-98: Created
* 10-Feb-00: Imported to AsmUtils
*/
#define fspr_id_MASK 0xff000000
#define fpsr_id_SHIFT 24
#define fpsr_id_FPE2 0x00
#define fpsr_id_FPE4 0x01
#define fpsr_id_FPPC 0x80
#define fpsr_id_FPA 0x81
#define fpsr_id_FAST 0x80000000
#define fpsr_trap_INX 0x00100000
#define fpsr_trap_UFL 0x00080000
#define fpsr_trap_OFL 0x00040000
#define fpsr_trap_DVZ 0x00020000
#define fpsr_trap_IVO 0x00010000
#define fpsr_control_AC 0x00001000
#define fpsr_control_EP 0x00000800
#define fpsr_control_SO 0x00000400
#define fpsr_control_NE 0x00000200
#define fpsr_control_ND 0x00000100
#define fpsr_exception_INX 0x00000010
#define fpsr_exception_UFL 0x00000008
#define fpsr_exception_OFL 0x00000004
#define fpsr_exception_DVZ 0x00000002
#define fpsr_exception_IVO 0x00000001
#define fpsr_all_DEFAULT (fpsr_trap_OFL | fpsr_trap_DVZ | fpsr_trap_IVO)
unsigned int fpsr_manipulate(unsigned int eor, unsigned int mask);
/* Copyright 2000 Pace Micro Technology plc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* AsmUtils (modulefp.h)
*
* Copyright (C) Pace Micro Technology plc. 1999
*
*/
#ifndef asmutils_modulefp_h_inluded
#define asmutils_modulefp_h_inluded
#ifdef __cplusplus
extern "C" {
#endif
/*
* This function should be called before doing any floating point operations
* in a module. It cannot be called from interrupt routines. Note that if
* the caller was on the verge of generating a floating point exception (e.g.
* divide by zero), then the exception will be generated by your own
* floating point code instead. Since raising your own exceptions would be
* very ugly, all exceptions are disabled in the FPSR setup.
*
* Remember that the routine which calls this function may not then start
* using floating point code itself, it must invoke another APCS routine
* to do that. You must have a 32-bit FPEmulator module (there is no 'Z' in
* the help string).
*/
typedef struct modulefp_buf
{
unsigned int fpsr;
unsigned int regs[12];
} modulefp_buf;
extern void modulefp_enable(modulefp_buf * regs);
/*
* Once finished with floatng point code, you MUST call this function to
* restore the previous state of the system.
*/
extern void modulefp_disable(modulefp_buf * regs);
#ifdef __cplusplus
}
#endif
#endif
; Copyright 2000 Pace Micro Technology plc
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
; Title: s.fpsr
; Purpose: Allows floating point status register to be manipulated
; Authors: KJB, ADH
; History: 20-Apr-98: Created
; 10-Feb-00: Imported to AsmUtils
;
; Read/write the FPSR. Lots of useful definitions are in fpsr.h.
AREA |asmutils$fpsr$$Code|,CODE,READONLY,PIC
GET hdr:ListOpts
GET hdr:Macros
GET hdr:System
GET hdr:Machine.<Machine>
GET hdr:APCS.<APCS>
EXPORT fpsr_manipulate
; unsigned int fpsr_manipulate(unsigned int eor, unsigned int mask);
fpsr_manipulate
RFS a3
BIC a4, a3, a2
EOR a4, a4, a1
WFS a4
MOV a1,a3
Return ,LinkNotStacked
END
; Copyright 2000 Pace Micro Technology plc
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
; Title: s.modulefp
; Purpose: Wrappers to allow floating point use in modules
;
; This function should be called before doing any floating point operations
; in a module. It cannot be called from interrupt routines. Note that if
; the caller was on the verge of generating a floating point exception (e.g.
; divide by zero), then the exception will be generated by your own
; floating point code instead. Since raising your own exceptions would be
; very ugly, all exceptions are disabled in the FPSR setup.
;
; Remember that the routine which calls this function may not then start
; using floating point code itself, it must invoke another APCS routine
; to do that. You must have a 32-bit FPEmulator module (there is no 'Z' in
; the help string).
; Pre-condition: processor is in SVC26 or SVC32 mode, not in an interrupt
; routine - i.e. use of this call will make a SWI
; non-reentrant.
;
; It is assumed that you have a 32-bit FPEmulator module
; on your system.
;
; Post-condition: processor is in same mode as on entry, now safe to call
; other APCS routines that use floating point.
AREA |asmutils$modulefp$$Code|,CODE,READONLY,PIC
GET hdr:ListOpts
GET hdr:Macros
GET hdr:System
GET hdr:Machine.<Machine>
GET hdr:APCS.<APCS>
EXPORT modulefp_enable
EXPORT modulefp_disable
[ No32bitCode :LAND: No26bitCode
! 1, "This code cannot be used in No26bitCode and No32bitCode!"
]
; Assembler equivalent of modulefp_buf structure
^ 0
fpsr # 4
regs # 12 * 4
; extern void modulefp_enable(modulefp_buf * regs);
modulefp_enable
RFS r1
STR r1,[r0,#fpsr]
MOV r1,#&00000000 ; All exceptions suppressed
WFS r1
SFM f0,4,[r0,#regs]
Return ,LinkNotStacked
; Once finished with floatng point code, you MUST call this function to
; restore the previous state of the system.
; extern void modulefp_disable(modulefp_buf * regs);
modulefp_disable
LFM f0,4,[r0,#regs]
LDR r1,[r0,#fpsr]
WFS r1
Return ,LinkNotStacked
END
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment