1 /*
2 * File : cpu.c
3 * COPYRIGHT (C) 2008 - 2016, RT-Thread Development Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Change Logs:
20 * Date Author Notes
21 * 2010-07-09 Bernard first version
22 * 2010-09-11 Bernard add CPU reset implementation
23 */
24 #include <rtthread.h>
25 #include <board.h>
26
27 /**
28 * @addtogroup Ingenic
29 */
30 /*@{*/
31
32 /**
33 * this function will reset CPU
34 *
35 */
rt_hw_cpu_reset()36 void rt_hw_cpu_reset()
37 {
38 /* open the watch-dog */
39 REG_WDT_TCSR = WDT_TCSR_EXT_EN;
40 REG_WDT_TCSR |= WDT_TCSR_PRESCALE_1024;
41 REG_WDT_TDR = 0x03;
42 REG_WDT_TCNT = 0x00;
43 REG_WDT_TCER |= WDT_TCER_TCEN;
44
45 rt_kprintf("reboot system...\n");
46 while (1);
47 }
48
49 /**
50 * this function will shutdown CPU
51 *
52 */
rt_hw_cpu_shutdown()53 void rt_hw_cpu_shutdown()
54 {
55 rt_kprintf("shutdown...\n");
56
57 while (1);
58 }
59
60 /**
61 * This function finds the first bit set (beginning with the least significant bit)
62 * in value and return the index of that bit.
63 *
64 * Bits are numbered starting at 1 (the least significant bit). A return value of
65 * zero from any of these functions means that the argument was zero.
66 *
67 * @return return the index of the first bit set. If value is 0, then this function
68 * shall return 0.
69 */
__rt_ffs(int value)70 int __rt_ffs(int value)
71 {
72 return __builtin_ffs(value);
73 }
74
75 /*@}*/
76