Chinaunix首页 | 论坛 | 博客
  • 博客访问: 396501
  • 博文数量: 380
  • 博客积分: 75
  • 博客等级: 民兵
  • 技术积分: 1925
  • 用 户 组: 普通用户
  • 注册时间: 2011-09-05 15:35
文章分类

全部博文(380)

文章存档

2014年(1)

2013年(2)

2012年(19)

2011年(358)

我的朋友

分类:

2011-09-05 18:25:18

原文地址:reboot的底层实现 作者:chenxibing008


如果没有实现底层reboot支持,输入reboot命令不能重启系统,或者会引起系统出错。

需要实现体系结构的arch_reset(char mode)函数。

文件:arch/arm/mach-lpc32xx/include/mach/system.h

static inline void arch_reset(char mode)
{
// cpu_reset(0);
    extern void lpc32xx_watchdog_reset(void);

    switch (mode) {
    case 's':
    case 'h':
        printk(KERN_CRIT "RESET: Rebooting system\n");
        /* Disable interrupts */
        local_irq_disable();
        lpc32xx_watchdog_reset();
        break;

    default:
        /* Do nothing */
        break;
    }

    /* Wait for watchdog to reset system */
    while (1)
        ;
}


可以看到,是通过看门狗实现系统复位的,所以必须实现看门狗的操作。

文件:arch/arm/mach-lpc32xx/arch-lpc32xx.c

/*
 * System reset via the watchdog timer
 */

void lpc32xx_watchdog_reset(void)
{
    /* Make sure WDT clocks are enabled */
    __raw_writel(CLKPWR_PWMCLK_WDOG_EN,
            CLKPWR_TIMER_CLK_CTRL(CLKPWR_IOBASE));

    /* Instant assert of RESETOUT_N with pulse length 1mS */
    __raw_writel(13000, io_p2v(WDTIM_BASE + 0x18));
    __raw_writel(0x70, io_p2v(WDTIM_BASE + 0xC));
}


这样的内核就能使用reboot命令而不会出错了。


阅读(218) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~