Page 1 of 1
Shutting down the computer
Posted: Fri Apr 29, 2005 2:17 am
by srg_13
Hi,
How can you turn off a computer from protected mode in C?
Thanks,
Stephen
Re:Shutting down the computer
Posted: Fri Apr 29, 2005 2:32 am
by Brendan
Hi,
Stephen wrote:How can you turn off a computer from protected mode in C?
There's 3 options - APM, ACPI and direct hardware/IO instructions.
For APM there's a protected mode interface (16 bit and/or 32 bit) that's supported by some BIOSs, but not all. This option probably can't be done with C alone.
ACPI is an overcomplicated mess, requiring an interpretter for it's own OOP language (AML). It should be possible to do this all in C though.
Direct hardware/IO depends on the motherboard/chipset, so you'd heaps of "motherboard drivers" - one for each motherboard.
Then there's computers that lack the needed hardware, and therefore don't have any method of turning the power off (e.g. Pentium and older computers).
Cheers,
Brendan
Re:Shutting down the computer
Posted: Fri Apr 29, 2005 2:46 am
by srg_13
Brendan wrote:For APM there's a protected mode interface (16 bit and/or 32 bit) that's supported by some BIOSs, but not all. This option probably can't be done with C alone.
Thats ok, I can use NASM code as well.
Re:Shutting down the computer
Posted: Fri Apr 29, 2005 4:08 am
by aladdin
There is also the "Power button" method witch work on all computers
Re:Shutting down the computer
Posted: Fri Apr 29, 2005 5:34 am
by smiddy
aladdin wrote:
There is also the "Power button" method witch work on all computers
Yeah, but the trick is to get the software to push the button. ;D
Re:Shutting down the computer
Posted: Fri Apr 29, 2005 7:03 am
by AR
You can also reprogram what that button does using ACPI (not sure about APM) so it could open the painting program or some other weird thing instead...
Re:Shutting down the computer
Posted: Mon May 16, 2005 3:38 pm
by GLneo
hi,
if it helps anyone here is a reboot
Code: Select all
void reboot()
{
volatile unsigned char good = 0x02;
while ((good & 0x02) != 0)
good = inportb(0x64);
outportb(0x64, 0xFE);
for(;;);
}
Re:Shutting down the computer
Posted: Thu May 19, 2005 5:11 am
by srg_13
Thanks, but I already have a reboot. I was kinda hoping that it would be that simple to shut down the computer
-Stephen