Mercurial > ecos-v3_0-branch
changeset 2754:403e17f06bec
Add support for overriding bit index macros.
| author | nickg |
|---|---|
| date | Wed, 04 Feb 2009 11:33:47 +0000 |
| parents | b8eabd9f6ab3 |
| children | f935377c1228 |
| files | packages/hal/mips/arch/current/ChangeLog packages/hal/mips/arch/current/include/hal_arch.h packages/hal/mips/mips32/current/ChangeLog packages/hal/mips/mips32/current/include/var_arch.h |
| diffstat | 4 files changed, 51 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/hal/mips/arch/current/ChangeLog +++ b/packages/hal/mips/arch/current/ChangeLog @@ -1,3 +1,8 @@ +2009-02-04 Nick Garnett <nickg@ecoscentric.com> + + * include/hal_arch.h: Ifdef bit index macros to allow them to be + overridden by variant or platform HAL. + 2004-05-27 Gary Thomas <gary@mlbassoc.com> * src/redboot_linux_exec.c (do_exec): Be sensitive to value in
--- a/packages/hal/mips/arch/current/include/hal_arch.h +++ b/packages/hal/mips/arch/current/include/hal_arch.h @@ -125,6 +125,8 @@ externC void cyg_hal_deliver_exception( //-------------------------------------------------------------------------- // Bit manipulation macros +#ifndef CYGHWR_HAL_BIT_INDEXES_DEFINED + externC cyg_uint32 hal_lsbit_index(cyg_uint32 mask); externC cyg_uint32 hal_msbit_index(cyg_uint32 mask); @@ -132,6 +134,8 @@ externC cyg_uint32 hal_msbit_index(cyg_u #define HAL_MSBIT_INDEX(index, mask) index = hal_msbit_index(mask); +#endif + //-------------------------------------------------------------------------- // Context Initialization
--- a/packages/hal/mips/mips32/current/ChangeLog +++ b/packages/hal/mips/mips32/current/ChangeLog @@ -1,3 +1,8 @@ +2009-02-04 Nick Garnett <nickg@ecoscentric.com> + + * include/var_arch.h (HAL_LSBIT_INDEX, HAL_MSBIT_INDEX): Provide + overrides for these macros that use the clz instruction. + 2009-01-31 Bart Veer <bartv@ecoscentric.com> * cdl/hal_mips_mips32.cdl: update compiler flags for gcc 4.x
--- a/packages/hal/mips/mips32/current/include/var_arch.h +++ b/packages/hal/mips/mips32/current/include/var_arch.h @@ -85,6 +85,43 @@ HAL_SET_CP0_REGISTER_32( _regval_, _cp0_regno_, _cp0_regsel_ ) //-------------------------------------------------------------------------- +// Bit manipulation macros + +#ifndef CYGHWR_HAL_BIT_INDEXES_DEFINED + +//-------------------------------------------------------- +// Determine the index of the ls bit of the supplied mask. + +#define HAL_LSBIT_INDEX(_index_, _mask_) \ + CYG_MACRO_START \ + unsigned _reg_; \ + \ + _reg_ = (_mask_); \ + _reg_ &= -_reg_; \ + asm volatile ("clz %0, %1\n" \ + : "=r" (_reg_) \ + : "r" (_reg_) ); \ + (_index_) = 31 - _reg_; \ + CYG_MACRO_END + +//-------------------------------------------------------- +// Determine the index of the ms bit of the supplied mask. + +#define HAL_MSBIT_INDEX(_index_, _mask_) \ + CYG_MACRO_START \ + unsigned _reg_; \ + \ + _reg_ = (_mask_); \ + asm volatile ("clz %0, %1\n" \ + : "=r" (_reg_) \ + : "r" (_reg_) ); \ + (_index_) = 31 - _reg_; \ + CYG_MACRO_END + +#define CYGHWR_HAL_BIT_INDEXES_DEFINED +#endif + +//-------------------------------------------------------------------------- #ifdef CYGARC_HAL_COMMON_EXPORT_CPU_MACROS /* System Control Coprocessor (CP0) exception processing registers */
