|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Bannato
Iscritto dal: Jan 2003
Città:
Messaggi: 4421
|
[c] watchdog da win a linux...
...come da titolo avrei la necessità di convertire questo piccolo programma da win a linux...premetto che non so nulla di c...vorresi solo capire come riscrivere e ricompilare tale codice su una macchina linux al fine di attivare il watchdog hardware presente nella motherboard...il codice è stato trovato nel manuale della scheda madre...
Codice:
//============================================
//DOS Watchdog sample program
//Please compile with Turbo C 3.0 to utilized the program
//============================================
int main()
{
//Initialized the WDT program
outp(0x2e,0x87);
outp(0x2e,0x01);
outp(0x2e,0x55);
outp(0x2e,0x55);
//Setting Logical Device Number to 0x07
outp(0x2e,0x07);
outp(0x2f,0x07);
//Set Timer Value(0x73 is LSB while 0x74 is MSB)
outp(0x2e,0x73);
outp(0x2f,0x14);//set to 20 sec (0x14)
//Set Timer Unit to Second/Minute(Bit 7 equal to 1 is second/0 is minute)
//Enable WDT (Bit 6 equal to 1 is enable/0 is disable)
outp(0x2e,0x72);
outp(0x2f,0xC0);//The unit is set as second
return 0;
}
|
|
|
|
|
|
#2 |
|
Bannato
Iscritto dal: Jan 2003
Città:
Messaggi: 4421
|
Codice:
// Copyright 2011, Kees Cook <[email protected]>, License: GPLv2 */ #include <unistd.h> #include <stdio.h> #include <sys/io.h> int main() { printf("via\n"); /* access to watchdog port */ if (ioperm(0x2e, 0x2e, 1) < 0) { perror("0x2e"); return 1; } /* access to watchdog port */ if (ioperm(0x2f, 0x2f, 1) < 0) { perror("0x2f"); return 2; } sleep(1); printf("leggo \n"); printf("%d\n",inb(0x2e)); printf("scrivo 87\n"); //outb(0x2e,0x87); outb(0x87,0x2e); printf("leggo \n"); printf("%d\n",inb(0x2e)); //outb(0x2e,0x01); outb(0x01,0x2e); printf("riscritto\n"); //outb(0x2e,0x55); outb(0x55,0x2e); printf("4\n"); outb(0x2e,0x55); //Setting Logical Device Number to 0x07 //outb(0x2e,0x07); printf("5\n"); outb(0x07,0x2e); //outb(0x2f,0x07); printf("6\n"); outb(0x07,0x2f); //Set Timer Value(0x73 is LSB while 0x74 is MSB) //outb(0x2e,0x73); printf("7\n"); outb(0x73,0x2e); //outb(0x2f,0x14);//set to 20 sec (0x14) printf("8\n"); outb(0x14,0x2e); //Set Timer Unit to Second/Minute(Bit 7 equal to 1 is second/0 is minute) //Enable WDT (Bit 6 equal to 1 is enable/0 is disable) //outb(0x2e,0x72); printf("9\n"); outb(0x72,0x2e); //outb(0x2f,0xC0);//The unit is set as second printf("10\n"); outb(0xc0,0x2f); return 0; } |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 21:28.



















