delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/04/19:36:02

From: Clemens Valens <c DOT valens AT mindless DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: How to restart computer?
Organization: http://www.remarq.com: The World's Usenet/Discussions Start Here
X-Originating-Host: 195.154.148.69
X-Wren-Trace: cI2qip+N0bObydmkncrMxMvezd3S2p3B3dDC393AzY3T0pjC0pjMzdDY0cbVlN6ZwpeAjp/cqaWBkMOAksiKlsbOg4k=
Message-ID: <933769851.26224@www.remarq.com>
References: <7o8r5i$2r9q$1 AT ns DOT felk DOT cvut DOT cz>
Lines: 47
Date: Wed, 04 Aug 1999 04:30:47 -0800
NNTP-Posting-Host: 10.0.3.195
X-Complaints-To: wrenabuse AT remarq DOT com
X-Trace: WReNphoon3 933769585 10.0.3.195 (Wed, 04 Aug 1999 05:26:25 PDT)
NNTP-Posting-Date: Wed, 04 Aug 1999 05:26:25 PDT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

You are in luck, I had to do the same and came up with this
code (it works very well):

/*
 * Reboot the PC by simulating a ctrl-alt-del.
 * Based on Frank van Gilluwe's "The Undocumented PC"
 */
int reboot(void)
{
  volatile char kb_status;
  unsigned short int i, timeout = 1;

  while ((kb_status=inportb(0x64))&0x02) {
    i=1; while(i) i++; /* Slow down I/O access. */
    timeout++;
    if (!timeout) goto reboot_error;
  }

  outportb(0x64,0xfe);

  i=1; while(i) i++; /* Slow down I/O access. */

  /*
   * If all went well you should never get below this line.
   */

  while ((kb_status=inportb(0x64))&0x02) {
    i=1; while(i) i++; /* Slow down I/O access. */
    timeout++;
    if (!timeout) goto reboot_error;
  }

  return 0;

reboot_error:
  return -1;
}

I have only tested it with DJGPP, but normally it should
work with BC as well.

Clemens



* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019