mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-02-21 01:07:18 +08:00
Update cpuport.c
This commit is contained in:
parent
f0061b14d3
commit
c2f028ed8d
@ -1,20 +1,22 @@
|
|||||||
/*
|
/*
|
||||||
* File : cpuport.c
|
* File : cpuport.c
|
||||||
* This file is part of RT-Thread RTOS
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* The license and distribution terms for this file may be
|
* This program is distributed in the hope that it will be useful,
|
||||||
* found in the file LICENSE in this distribution or at
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* http://www.rt-thread.org/license/LICENSE
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*
|
*
|
||||||
* Change Logs:
|
* Change Logs:
|
||||||
* Date Author Notes
|
* Date Author Notes
|
||||||
* 2009-01-05 Bernard first version
|
* 2017-08-25 Archer first version
|
||||||
* 2011-02-14 onelife Modify for EFM32
|
|
||||||
* 2011-06-17 onelife Merge all of the C source code into cpuport.c
|
|
||||||
* 2012-12-23 aozima stack addr align to 8byte.
|
|
||||||
* 2012-12-29 Bernard Add exception hook.
|
|
||||||
* 2013-07-09 aozima enhancement hard fault exception handler.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <rtthread.h>
|
#include <rtthread.h>
|
||||||
@ -190,28 +192,7 @@ void rt_hw_exception_install(rt_err_t (*exception_handle)(void* context))
|
|||||||
* @return return the index of the first bit set. If value is 0, then this function
|
* @return return the index of the first bit set. If value is 0, then this function
|
||||||
* shall return 0.
|
* shall return 0.
|
||||||
*/
|
*/
|
||||||
#if defined(__CC_ARM)
|
#if defined(__GNUC__)
|
||||||
__asm int __rt_ffs(int value)
|
|
||||||
{
|
|
||||||
CMP r0, #0x00
|
|
||||||
BEQ exit
|
|
||||||
RBIT r0, r0
|
|
||||||
CLZ r0, r0
|
|
||||||
ADDS r0, r0, #0x01
|
|
||||||
|
|
||||||
exit
|
|
||||||
BX lr
|
|
||||||
}
|
|
||||||
#elif defined(__IAR_SYSTEMS_ICC__)
|
|
||||||
int __rt_ffs(int value)
|
|
||||||
{
|
|
||||||
if (value == 0) return value;
|
|
||||||
|
|
||||||
__ASM("RBIT r0, r0");
|
|
||||||
__ASM("CLZ r0, r0");
|
|
||||||
__ASM("ADDS r0, r0, #0x01");
|
|
||||||
}
|
|
||||||
#elif defined(__GNUC__)
|
|
||||||
int __rt_ffs(int value)
|
int __rt_ffs(int value)
|
||||||
{
|
{
|
||||||
return __builtin_ffs(value);
|
return __builtin_ffs(value);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user