home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / diverses / tctnt / reboot.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-28  |  1.5 KB  |  41 lines

  1. /* REBOOT.C:  If given a command line argument of /w the program
  2.                             will only warm boot the CPU.  All other command line
  3.                             arguments are ignored.  If the /w argument is not
  4.                             specified the cpu will be cold booted.
  5. */
  6.  
  7. #include <dos.h>                    // MK_FP()
  8. #include <stdio.h>                  // printf()
  9. #include <conio.h>                  // getch()
  10. #include <string.h>                 // strcmp()
  11.  
  12. //*******************************************************************
  13. #pragma warn -par                                 // we know argc is nver used!
  14. int main(int argc, char *argv[])
  15. {
  16.     typedef void (far *reboot)(void); // Function pointer.
  17.     unsigned far *warmpt;             // Absolute pointer.
  18.     int warmfl;                       // Warm boot flag.
  19.   reboot aboot;
  20.  
  21.     warmpt = (unsigned far*) MK_FP(0x0040, 0x0072); // Obtain far pointer to 0040:0072.
  22.     aboot = (reboot) MK_FP(0xFFFF, 0x0000); // Obtain far pointer to FFFF:0000.
  23.  
  24.     if(strcmp("/w",argv[1]) == 0) {   // Decide whether or not to...
  25.                                                                       // warmboot the CPU.
  26.         *warmpt = (0x1234);
  27.         warmfl = 1;
  28.     }
  29.  
  30.   if(warmfl == 1)                   // Is warm boot flag set?
  31.     printf("WARM booting.");        // YES, warm boot message.
  32.   else
  33.     printf("COLD booting.");        // NO, cold boot message.
  34.  
  35.     aboot();                          // Reboot the machine now...
  36.                                     // by jumping to the function
  37.                                     // pointer that was created.
  38.  
  39.     return 0;                       // SUCCESS!
  40. } // end of main()
  41.