Subject: set_cp0_status (mipsregs.h)

From: Scott A McConnell <[email-masked]>
Date: Fri, 06 Apr 2001 11:32:03 -0700

Which is correct?
1 or 2 parameters ?
The first comes from a 2.4.0 kernel and the second from a 2.4.2
extracted from cvs a few days ago.

Thanks,
Scott

--------------------------------------------

/*
 * Manipulate the status register.
 * Mostly used to access the interrupt bits.
 */
#define __BUILD_SET_CP0(name,register)                          \
extern __inline__ unsigned int                                  \
set_cp0_##name(unsigned int change, unsigned int new)           \
{                                                               \
 unsigned int res;                                       \
                                                                \
 res = read_32bit_cp0_register(register);                \
 res &= ~change;                                         \
 res |= (new & change);                                  \
 if(change)                                              \
  write_32bit_cp0_register(register, res);        \
                                                                \
 return res;                                             \
}

__BUILD_SET_CP0(status,CP0_STATUS)
__BUILD_SET_CP0(cause,CP0_CAUSE)
__BUILD_SET_CP0(config,CP0_CONFIG)

------------------------- or --------------------------------

#define __BUILD_SET_CP0(name,register)                          \
extern __inline__ unsigned int                                  \
set_cp0_##name(unsigned int set)    \
{                                                               \
 unsigned int res;                                       \
                                                                \
 res = read_32bit_cp0_register(register);                \
 res |= set;      \
 write_32bit_cp0_register(register, res);         \
                                                                \
 return res;                                             \
}

---

From: Ralf Baechle <[email-masked]>
Date: Sat, 7 Apr 2001 04:59:16 +0200

> extracted from cvs a few days ago.

1 Parameter; I changed the functions since about half the calls in the
kernel code did show that whoever wrote the code didn't understand
what the function is supposed to do.

 - set_cp0_status(bits)

   Set all the bits described by the bitmask bits in the status register.
   
 - clear_cp0_status(bits)

   Clear all the bits set in the bitmask argument bits in the status register.

 - change_cp0_status(change, set)

   Set all bits which are set in the bitmask change to the value given by
   the bitmask set; all other bits stay unchanged.  This is the same as
   the old set_cp0_status function.

Most people want to use {set,clear}_cp0_status().

  Ralf