Page 1 of 1

Reboot/Shutdown Code

Posted: Tue Dec 30, 2008 10:00 pm
by PatrickV
Hey, does anyone have some an idea how the reboot/shutdown source code go. Wiki source code of reboot does not seem quite complete. It does not work. Can you help me.I use Grub as my bootloader and use c language for Patricknet. I am working big time creating Patricknet Beta 0.3 which will be sometime next year when it will be released.

Re: Reboot/Shutdown Code

Posted: Tue Dec 30, 2008 10:29 pm
by LoseThos
I use this to reboot. I forgot if it's official or not, but it reboots the machines I have tested it on.

Code: Select all

  
  OutP(0x70,0x8F);
  OutP(0x71,0x00);
  OutP(0x70,0x00);
  OutP(0x92,InP(0x92)|1);
I forgot why I did the stuff to 70,71.

Here's a port description.
http://bochs.sourceforge.net/techspec/PORTS.LST

Re: Reboot/Shutdown Code

Posted: Tue Dec 30, 2008 10:44 pm
by piranha
My reboot code. I can't remember where I got it from but it works.

Code: Select all

	/* flush the keyboard controller */
	unsigned temp;
	do
	{
		temp = inb(0x64);
		if((temp & 0x01) != 0)
		{
			(void)inb(0x60);
			continue;
		}
	} while((temp & 0x02) != 0);
	/* Reset! */
	outb(0x64, 0xFE);
-JL

Re: Reboot/Shutdown Code

Posted: Tue Dec 30, 2008 10:51 pm
by LoseThos
As anyone who's worked on operating systems knows, there are multiple ways to reboot :)

The 0x92 bit is official and the 0x70 stuff is to enable resets.

Re: Reboot/Shutdown Code

Posted: Tue Dec 30, 2008 10:52 pm
by piranha
You could also trigger a triple fault.

-JL

Re: Reboot/Shutdown Code

Posted: Wed Dec 31, 2008 2:52 am
by ru2aqare
piranha wrote:You could also trigger a triple fault.

-JL
Some VMware versions (5.0, 5.5 at least) complain about triple faults not implemented or something similar.

Re: Reboot/Shutdown Code

Posted: Wed Dec 31, 2008 6:23 am
by Love4Boobies
This was discussed many times before. The best option is probably ACPI. If that doesn't work, try something else (as said on different threads).