[英]Writing/Accessing I/O port hardware watchdog register linux
我正在尝试从Linux访问/写入CPU上的硬件看门狗。 这是我从未做过的事情,所以我的知识很少。 RTD用户手册的链接是http://www.rtd.com/NEW_manuals/hardware/cpumodules/CMV34M_BDM610000077A.pdf (有关看门狗定时器的信息,请参见第64页)以及我在网上找到并编辑的小型示例程序。 我在BIOS中启用了看门狗设置寄存器,并运行了附带的程序。 该程序运行并且不输出任何错误,但是似乎并没有实际执行任何操作,因为我的系统没有重置(即使您不“踢狗”也应该这样做),即使我通过编写启用看门狗1秒。 希望也许有人会对我做错了什么有见识。
#include <stdio.h>
#include <unistd.h>
#include <sys/io.h>
#include <stdlib.h>
#define BASEPORT 0x985
int main()
{
/* Get access to the ports */
if (ioperm(BASEPORT, 3, 1)) {perror("ioperm"); exit(1);}
/* Set the data signals (D0-7) of the port to all high (1) */
outb(1, BASEPORT);
/* Sleep for a while (100 ms) */
usleep(100000);
/* Read from the status port (BASE+1) and display the result */
printf("status: %d\n", inb(BASEPORT + 1));
/* We don't need the ports anymore */
if (ioperm(BASEPORT, 3, 0)) {perror("ioperm"); exit(1);}
exit(0);
}
在outb()
命令之前尝试iopl
(3)。 iopl()
并不是真正的“不错”的可移植命令,但我成功地将其用于类似的看门狗问题。
ioperm
的文档说: 如果turn_on
不为零,则调用线程必须具有特权( CAP_SYS_RAWIO
) 。 您需要确保满足此条件。 同样,您的电话outb(1, BASEPORT)
只是将BASEPORT
设置为0x01
,而不是您的注释所说的“全高”。 如果要“全部高”,则需要outb(0xFF, BASEPORT)
。
如果您正在考虑使用watchdog timer
,则可能需要通过正常方式来writing a driver for that bit of hardware
它,方法是writing a driver for that bit of hardware
显示/dev/watchdog
接口的writing a driver for that bit of hardware
,然后使用支持多个系统范围测试的watchdog daemon
以及简单地让狗吃饱。
现有看门狗驱动程序代码的示例可在此处找到:
http://tomoyo.sourceforge.jp/cgi-bin/lxr/source/drivers/watchdog/
看门狗守护程序的操作信息(以及我自己的实验版本)可以在以下位置找到:
http://www.sat.dundee.ac.uk/~psc/watchdog/Linux-Watchdog.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.