Back to home page

OSCL-LXR

 
 

    


0001 /*
0002     NetWinder Floating Point Emulator
0003     (c) Rebel.COM, 1998,1999
0004 
0005     Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
0006 
0007     This program is free software; you can redistribute it and/or modify
0008     it under the terms of the GNU General Public License as published by
0009     the Free Software Foundation; either version 2 of the License, or
0010     (at your option) any later version.
0011 
0012     This program is distributed in the hope that it will be useful,
0013     but WITHOUT ANY WARRANTY; without even the implied warranty of
0014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0015     GNU General Public License for more details.
0016 
0017     You should have received a copy of the GNU General Public License
0018     along with this program; if not, write to the Free Software
0019     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
0020 */
0021 
0022 static inline unsigned long readRegister(const unsigned int nReg)
0023 {
0024         /* Note: The CPU thinks it has dealt with the current instruction.
0025            As a result the program counter has been advanced to the next
0026            instruction, and points 4 bytes beyond the actual instruction
0027            that caused the invalid instruction trap to occur.  We adjust
0028            for this in this routine.  LDF/STF instructions with Rn = PC
0029            depend on the PC being correct, as they use PC+8 in their
0030            address calculations. */
0031         struct pt_regs *regs = GET_USERREG();
0032         unsigned int val = regs->uregs[nReg];
0033         if (REG_PC == nReg)
0034                 val -= 4;
0035         return val;
0036 }
0037 
0038 static inline void
0039 writeRegister(const unsigned int nReg, const unsigned long val)
0040 {
0041         struct pt_regs *regs = GET_USERREG();
0042         regs->uregs[nReg] = val;
0043 }
0044 
0045 static inline unsigned long readCPSR(void)
0046 {
0047         return (readRegister(REG_CPSR));
0048 }
0049 
0050 static inline void writeCPSR(const unsigned long val)
0051 {
0052         writeRegister(REG_CPSR, val);
0053 }
0054 
0055 static inline unsigned long readConditionCodes(void)
0056 {
0057 #ifdef __FPEM_TEST__
0058         return (0);
0059 #else
0060         return (readCPSR() & CC_MASK);
0061 #endif
0062 }
0063 
0064 static inline void writeConditionCodes(const unsigned long val)
0065 {
0066         struct pt_regs *regs = GET_USERREG();
0067         unsigned long rval;
0068         /*
0069          * Operate directly on userRegisters since
0070          * the CPSR may be the PC register itself.
0071          */
0072         rval = regs->ARM_cpsr & ~CC_MASK;
0073         regs->ARM_cpsr = rval | (val & CC_MASK);
0074 }