Reboot & shutdown...

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
eliscool

Reboot & shutdown...

Post by eliscool »

well I dont think I have yet seen one of you guys OS's actually reboot or shutdown the computer its self, they just hang the system and require the user to manually hit reset... so I was wondering just how you would add this functionality in? is this a BIOS call?
Berserk

Re:Reboot & shutdown...

Post by Berserk »

I was just about to ask that,

How do you make the OS reboot or Shut Down?? ;D
Whatever5k

Re:Reboot & shutdown...

Post by Whatever5k »

Just pulse the CPU reset line to the keyboard controller:

Code: Select all

void reboot(void)
{
        u_char temp;

        cli();
        
        /* flush the keyboard controller */
        do 
        {
                temp = inb(0x64);
                if (temp & 1)
                        inb(0x60);
        }while(temp & 2);

        /* send the CPU reset line */
        outb(0x64, 0xFE);
 
        hlt();
}
dronkit

Re:Reboot & shutdown...

Post by dronkit »

Officially, I think, according to intel's manual, is to triple fault the cpu if you want to shut it down.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Reboot & shutdown...

Post by Pype.Clicker »

dronkit wrote: Officially, I think, according to intel's manual, is to triple fault the cpu if you want to shut it down.
nah, it won't "shut down"; just reset. only a proper call to real-mode APM bios will be able to do such a performance (unless your name is Bill and your OS has a driver support from every motherboard manufacturer ...)
dronkit

Re:Reboot & shutdown...

Post by dronkit »

Right, it will just reboot. However, this is what intel says in the manual for
the 386
(unless your name is Bill and your OS has a driver support from every motherboard manufacturer ...)
Oh no, thanks god I'm not ;)
Tim

Re:Reboot & shutdown...

Post by Tim »

A computer won't necessarily reboot on a triple fault, either: that is just a conventional way for the motherboard to handle it. All that the CPU does on a triple fault is set up a special bus condition, which the motherboard chipset picks up on. I have a computer at home which does not reboot on a triple fault: it just hangs. Handy for OS development. :)

The only guaranteed way to induce a reboot is through the keyboard controller. The only guaranteed ways to turn off the computer are through APM (old-ish) or ACPI (difficult).
eliscool

Re:Reboot & shutdown...

Post by eliscool »

Ok, ill just leave it with the reboot code for now... and shutdown can come later... also, is it just a myth that manually shuting down your comp by holding down the power button is bad for it and damage the computer? or will this be alright, and just make sure all the data is saved to disk then have a screen saying "its now save to shut down" so they can do it manually?
Tim

Re:Reboot & shutdown...

Post by Tim »

You're the OS developer; it's up to you. The actual hardware won't get damaged regardless of how you shut down.
Schol-R-LEA

Re:Reboot & shutdown...

Post by Schol-R-LEA »

[attachment deleted by admin]
Post Reply