Reboot/Shutdown Code

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
PatrickV
Member
Member
Posts: 151
Joined: Sun Jul 06, 2008 7:50 pm
Location: New Zealand
Contact:

Reboot/Shutdown Code

Post 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.
LoseThos
Member
Member
Posts: 112
Joined: Tue Oct 30, 2007 6:41 pm
Location: Las Vegas, NV USA
Contact:

Re: Reboot/Shutdown Code

Post 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
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Re: Reboot/Shutdown Code

Post 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
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
LoseThos
Member
Member
Posts: 112
Joined: Tue Oct 30, 2007 6:41 pm
Location: Las Vegas, NV USA
Contact:

Re: Reboot/Shutdown Code

Post 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.
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Re: Reboot/Shutdown Code

Post by piranha »

You could also trigger a triple fault.

-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
ru2aqare
Member
Member
Posts: 342
Joined: Fri Jul 11, 2008 5:15 am
Location: Hungary

Re: Reboot/Shutdown Code

Post 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.
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Reboot/Shutdown Code

Post 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).
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
Post Reply