avk013.blogspot.com - другой мой блог "C# and etc"

понедельник, 27 декабря 2021 г.

ICOP VDX2 WD2 Linux

realy working  WDT1 Linux Example for ICOP Vortex86, оказалочь что в примере инструкции небольшая синтаксическая ошибка в определении define outport, да еще  kbhit характерна только для старого доброго DOS, хорошо что все рашаемо:

=========== wd2.c ====

#include <stdio.h>
#include <curses.h>
#include <sys/io.h>
#include <sys/select.h>

#define outp(a,b) outb(b,a)
#define inp(a) inb(a)
int kbhit(void)
{
  struct timeval tv;
  fd_set read_fd;
  /* Do not wait at all, not even a microsecond */
  tv.tv_sec=0;
  tv.tv_usec=0;
  /* Must be done first to initialize read_fd */
  FD_ZERO(&read_fd);
  /* Makes select() ask if input is ready:
   * 0 is the file descriptor for stdin    */
  FD_SET(0,&read_fd);
  /* The first parameter is the number of the
   * largest file descriptor to check + 1. */
  if(select(1, &read_fd,NULL, /*No writes*/NULL, /*No exceptions*/&tv) == -1)
    return 0;  /* An error occured */
  /*  read_fd now holds a bit map of files that are
   * readable. We test the entry for the standard
   * input (file 0). */
if(FD_ISSET(0,&read_fd))
    /* Character pending on stdin */
    return 1;
  /* no characters were pending */
  return 0;
}
 
int main(void)
{
iopl(3);
unsigned char c;
unsigned long lTime;
// 500 mini-second
//lTime = 0x20L * 500L;
lTime = 0x20L * 512000L;
outp(0x6c, (lTime >> 16) & 0xff);
outp(0x6b, (lTime >> 8) & 0xff);
outp(0x6a, (lTime >> 0) & 0xff);
// Reset system. For example, 0x50 to trigger IRQ7
outp(0x69, 0xd0);
// Enable watchdog timer
c = inp(0x68);
c |= 0x40;
outp(0x68, c);
printf("Press any key to stop trigger timer.\n");
while(!kbhit())
outp(0x67, 0x00);
printf("System will reboot after 500 milli-seconds.\n");
return 0;
}
=========== gcc -Wall wd2.c -o wd2.o

однако программу надо запускать через сервисы, там уже не нужен вывод на экран
попытка №2

  1. #include <stdio.h>
  2. #include <curses.h>
  3. #include <unistd.h>
  4. #include <time.h>
  5. #include <sys/io.h>
  6. #include <sys/select.h>
  7.  
  8. #define outp(a,b) outb(b,a)
  9. #define inp(a) inb(a)
  10.  
  11. int main(void)
  12. {
  13. iopl(3);
  14. unsigned char c;
  15. unsigned long lTime;
  16. unsigned int i;
  17. i=1;
  18. // 500 mini-second
  19. //lTime = 0x20L * 500L;
  20. lTime = 0x20L * 512000L;
  21. outp(0x6c, (lTime >> 16) & 0xff);
  22. outp(0x6b, (lTime >> 8) & 0xff);
  23. outp(0x6a, (lTime >> 0) & 0xff);
  24. // Reset system. For example, 0x50 to trigger IRQ7
  25. outp(0x69, 0xd0);
  26. // Enable watchdog timer
  27. c = inp(0x68);
  28. c |= 0x40;
  29. outp(0x68, c);
  30. while(i!=0){
  31. outp(0x67, 0x00);
  32. //usleep(10000000);//10 sec
  33. //usleep(300000000);//300 sec
  34. sleep(300);
  35. }
  36. return 0;
  37. }

1 комментарий:

  1. Casino at Foxwoods Casino- Casino in Welch, MN
    A map showing Foxwoods Casino-Casino, located in 공주 출장샵 Welch, 과천 출장샵 MN, with 19091 안성 출장안마 slot machines and 13 table 양산 출장안마 games, located 과천 출장샵 in Welch,

    ОтветитьУдалить