News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

turning off system

Started by thomasantony, January 23, 2005, 08:34:22 AM

Previous topic - Next topic

thomasantony

Hi,
    In my OS, I pulse the reset line in the keybrd controller to reset the system. There must be some way to power down teh system too as windows does it when I shut down the system. I think it was not possible on teh older PC's where windows just said "It is now safe to turn off the system". But it should be possible now. How do I do it?

Thomas Antony
There are 10 types of people in the world. Those who understand binary and those who don't.


Programmer's Directory. Submit for free

MichaelW

Although the specification is ~9 years old, I think I would try to use APM for this. AFAIK most recent systems support APM (or at least can support APM). The APM version 1.2 specification is available here, and there is a link to the ACPI specification on the same page.

For quick and dirty, there is a QuickBASIC program here that details how to do it. AFAIK, as a minimum, you would need to implement the last three interrupt calls.
eschew obfuscation

hutch--

I tried to build thew basic file but my old QB cannot load the format with the /L option so I portd it to 16 bit masm and built the tail end interrupts as a COM file.

Dunno if it works and it probably requires either int 20h or 21h 4Ch to terminate it properly but it may be useful.

[attachment deleted by admin]
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Mark_Larson

Quote from: MichaelW on January 23, 2005, 01:27:20 PM
Although the specification is ~9 years old, I think I would try to use APM for this. AFAIK most recent systems support APM (or at least can support APM). The APM version 1.2 specification is available here, and there is a link to the ACPI specification on the same page.

For quick and dirty, there is a QuickBASIC program here that details how to do it. AFAIK, as a minimum, you would need to implement the last three interrupt calls.


MichaelW's right.  All BIOSes are still going ot support it because you have to be backward compatible in features.  Doing APM is a bit more confusing though.  You have to connect to the APM BIOS before you can do things.  Hutch's example code is easy to follow.  I recommend looking up each software interrupt he is calling on ralf brown's list so you can get a better understanding of what is going on

http://www.ctyme.com/intr/int-15.htm
BIOS programmers do it fastest, hehe.  ;)

My Optimization webpage
htttp://www.website.masmforum.com/mark/index.htm

pbrennick

I tried Hutch's code on my Win98 box and it through an illegal operation error.  When I restarted in MS-DOS mode and ran the program it locked up the cpu.
Paul

Mark_Larson

Quote from: pbrennick on January 23, 2005, 04:14:31 PM
I tried Hutch's code on my Win98 box and it through an illegal operation error.  When I restarted in MS-DOS mode and ran the program it locked up the cpu.
Paul


That is cuz Win98 is running in ACPI mode.  You need to either use an older OS that uses APM or do it from DOS.  I think there was a trick for Win98 to force it to switch to APM mode, but I forget.  I would also be surprised if it works under 2k or XP for the same reason.  However they might emulate it when they get the int 15h.
BIOS programmers do it fastest, hehe.  ;)

My Optimization webpage
htttp://www.website.masmforum.com/mark/index.htm

pbrennick

#6
Perhaps you did not notice that I also tried it in DOS?
Paul

Edit:  I just tried it again after booting from a DOS diskette and it still doesn't work.

Paul

MichaelW

#7
I tested Hutch's app on my spare system, and it works just as I expected. From a DOS boot diskette, it shuts the system down regardless of my BIOS ACPI enabled/disabled and PM control by APM Yes/No settings. Under Windows 98 SE (running in ACPI mode) it fails to shut the system down (as expected) and it executes an invalid instruction, but I think the invalid instruction is because it lacks any proper termination code. Under Window 98 SE MS-DOS mode, it shuts the system down. The system motherboard is about 6 years old, has a VIA MVP3 chipset, and the BIOS date is 12/21/2000.

[edit] I forgot to add that the test system uses an ATX power supply. AFAIK there is no way to programmatically shut down a system with an AT power supply.[/edit]
eschew obfuscation

pbrennick

#8
MichaelW,
Evidently it is something to do with my motherboard.  Thank you for testing it so thoroughly.

Paul

EDIT: Your last EDIT explains my situation.  I probably should have realized that.  :'(