I am trying to access/write to the hardware watchdog on the CPU from Linux. This is something I have never done before so my knowledge is very little. The link for the RTD user manual is http://www.rtd.com/NEW_manuals/hardware/cpumodules/CMV34M_BDM610000077A.pdf (see page 64 for watchdog timer information) and my small example program which I found on the internet and edited. I enabled the Watchdog Setup Register in the BIOS, and ran the attached program. The program runs and doesn’t output any errors, but doesn’t seem to actually do anything as my system doesn’t reset(as it should if you don’t “kick the dog”) even though I am enabling watchdog by writing 1s. Was hoping maybe someone would have insight as to what I am doing wrong.
#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);
}
The doc for
ioperm
says, Ifturn_on
is nonzero, the calling thread must be privileged (CAP_SYS_RAWIO
). You need to ensure this condition is met. Also, your calloutb(1, BASEPORT)
just setsBASEPORT
to0x01
, not "all high" as your comment says. If you want "all high", you needoutb(0xFF, BASEPORT)
.