Nothing fancy here, but it works, and I hope it helps...
We noticed that the reboot sequence would sometimes not reach its end, and a
hard reset would occur, say while unmounting local file systems. Obviously not
ideal. A standard UNIX technique here, just add a signal handler for the
SIGTERM signal. Then the handler physically turns off the hardware timer
before exiting. Source code:
/* wdt2.c, modified. */
#include <unistd.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <stdio.h>
#include <fcntl.h>
#include <assert.h>
#include <signal.h>
static volatile unsigned char *wdt_control;
static volatile unsigned char *wdt_feed;
static void
sig_hndlr( int signo )
{
//Turn off wdt
*wdt_feed=0x05;
*wdt_control=0x00;
}
static int
registerSignalHandlers()
{
struct sigaction act;
/* Install signal handler */
act.sa_handler = sig_hndlr;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
if( sigaction( SIGTERM, &act, NULL ) < 0 ) return 0;
else return 1;
}
int main(void)
{
int fd = open("/dev/mem", O_RDWR|O_SYNC);
assert(fd != -1);
wdt_control = (unsigned char
*)mmap(0,getpagesize(),PROT_READ|PROT_WRITE,MAP_SHARED,fd,0x23800000);
wdt_feed = (unsigned char
*)mmap(0,getpagesize(),PROT_READ|PROT_WRITE,MAP_SHARED,fd,0x23C00000);
if( !registerSignalHandlers() ) {
fprintf( stderr, "Problem registering signal handler\n" );
}
//printf("%d\n",*wdt_control);
*wdt_feed=0x05;
*wdt_control=0x07;
//printf("%d\n",*wdt_control);
while(1)
{
*wdt_feed=0x05;
sleep(5);
}
}
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|