11da177e4SLinus Torvalds/* 21da177e4SLinus Torvalds NetWinder Floating Point Emulator 31da177e4SLinus Torvalds (c) Rebel.COM, 1998,1999 41da177e4SLinus Torvalds 51da177e4SLinus Torvalds Direct questions, comments to Scott Bambrough <scottb@netwinder.org> 61da177e4SLinus Torvalds 71da177e4SLinus Torvalds This program is free software; you can redistribute it and/or modify 81da177e4SLinus Torvalds it under the terms of the GNU General Public License as published by 91da177e4SLinus Torvalds the Free Software Foundation; either version 2 of the License, or 101da177e4SLinus Torvalds (at your option) any later version. 111da177e4SLinus Torvalds 121da177e4SLinus Torvalds This program is distributed in the hope that it will be useful, 131da177e4SLinus Torvalds but WITHOUT ANY WARRANTY; without even the implied warranty of 141da177e4SLinus Torvalds MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 151da177e4SLinus Torvalds GNU General Public License for more details. 161da177e4SLinus Torvalds 171da177e4SLinus Torvalds You should have received a copy of the GNU General Public License 181da177e4SLinus Torvalds along with this program; if not, write to the Free Software 191da177e4SLinus Torvalds Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 201da177e4SLinus Torvalds*/ 211da177e4SLinus Torvalds 221da177e4SLinus Torvalds#include "fpa11.h" 231da177e4SLinus Torvalds 241da177e4SLinus Torvalds/* Read and write floating point status register */ 25*38598105SAdrian Bunkstatic inline unsigned int readFPSR(void) 261da177e4SLinus Torvalds{ 271da177e4SLinus Torvalds FPA11 *fpa11 = GET_FPA11(); 281da177e4SLinus Torvalds return (fpa11->fpsr); 291da177e4SLinus Torvalds} 301da177e4SLinus Torvalds 31*38598105SAdrian Bunkstatic inline void writeFPSR(FPSR reg) 321da177e4SLinus Torvalds{ 331da177e4SLinus Torvalds FPA11 *fpa11 = GET_FPA11(); 341da177e4SLinus Torvalds /* the sysid byte in the status register is readonly */ 351da177e4SLinus Torvalds fpa11->fpsr = (fpa11->fpsr & MASK_SYSID) | (reg & ~MASK_SYSID); 361da177e4SLinus Torvalds} 371da177e4SLinus Torvalds 381da177e4SLinus Torvalds/* Read and write floating point control register */ 39*38598105SAdrian Bunkstatic inline FPCR readFPCR(void) 401da177e4SLinus Torvalds{ 411da177e4SLinus Torvalds FPA11 *fpa11 = GET_FPA11(); 421da177e4SLinus Torvalds /* clear SB, AB and DA bits before returning FPCR */ 431da177e4SLinus Torvalds return (fpa11->fpcr & ~MASK_RFC); 441da177e4SLinus Torvalds} 451da177e4SLinus Torvalds 46*38598105SAdrian Bunkstatic inline void writeFPCR(FPCR reg) 471da177e4SLinus Torvalds{ 481da177e4SLinus Torvalds FPA11 *fpa11 = GET_FPA11(); 491da177e4SLinus Torvalds fpa11->fpcr &= ~MASK_WFC; /* clear SB, AB and DA bits */ 501da177e4SLinus Torvalds fpa11->fpcr |= (reg & MASK_WFC); /* write SB, AB and DA bits */ 511da177e4SLinus Torvalds} 52