LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1469|回复: 0

linux下如何对看门狗(watchdog)编程?

[复制链接]
发表于 2005-5-25 15:26:31 | 显示全部楼层 |阅读模式
各位大侠:
      最近需要对看门狗进行编程,  我看了网上的资料写了一段:

  1. #include <stdio.h>
  2. #include <asm/io.h>

  3. #define WATCHDOG  0x443

  4. int restart_watchdog()
  5. {
  6.     // start or restart watchdog and setting timer                                                      
  7.     outb(0x10, WATCHDOG);
  8. }

  9. int main(void)
  10. {
  11.     // open watchdog
  12.     if (ioperm(WATCHDOG, 1, 1))
  13.     {
  14.           perror("ioperm");
  15.           exit(1);
  16.     }
  17.        
  18.     for (i=0; i<11; i++)
  19.     {
  20.           restart_watchdog();
  21.                
  22.           sleep(i);
  23.                
  24.           printf("i: %d \n", i);
  25.     }
  26. }

复制代码


可是每次我执行程序的时候都是  ioperm: Invalid argument 错误.

我已经在 BIOS 里面把 WDT 给 Enabled 了, 可是还是这个错误, 我尝试打开其他地址(0x2ef)的时候没有问题.

请问各位, 会是什么原因无法打开看门狗的地址 0x443
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表