I've grabbed some source-code for shutting down a computer thru the APM
from the web, assembled it and, ofcourse, tried it out. To my amazement, my
computer responds to the program by or shutting down, or re-booting. both
in an aproximatily 50% to 50% ratio.
Can anyone tell me why this happens ?
By the way, sometimes my computer responds the same to the main power
switch. Re-booting instead of powering down.
Regards,
Rudy Wieser
>I've grabbed some source-code for shutting down a computer thru the
>APM from the web, assembled it and, ofcourse, tried it out. To my
>amazement, my computer responds to the program by or shutting down,
>or re-booting. both in an aproximatily 50% to 50% ratio.
>
>Can anyone tell me why this happens ?
Not without seeing the source code for the shut-down program! :)
>By the way, sometimes my computer responds the same to the main
>power switch. Re-booting instead of powering down.
If you're using real DOS (not Win-Doze), it sounds like you might
have a hardware problem.
De groeten...
In kind of the same thread, my ATX power supply is connected to a
master a-c switch, so that I never switch the rear-panel power supply
off. Sometimes, when I turn the master a-c switch on, the power
supply comes on without any further action on my part. And sometimes
I have to press the front-panel momentary switch to actuate the power
supply.
I know how an ATX power supply works, but I cannot figure out why the
above happens. It is completely random, and has nothing to do with
how long the a-c power has been off. I thought that the logic circuit
which is normally enabled via the momentary switch might be latched,
but the same thing happens to a friend who has an entirely different
computer, but also an ATX.
Any ideas?
Bob
Hello Anonymous,
> On 2001-09-22 rwi...@xs4all.nl said:
>
> >I've grabbed some source-code for shutting down a computer thru the
> >APM from the web, assembled it and, ofcourse, tried it out. To my
> >amazement, my computer responds to the program by or shutting down,
> >or re-booting. both in an aproximatily 50% to 50% ratio.
> >
> >Can anyone tell me why this happens ?
>
> Not without seeing the source code for the shut-down program! :)
Below is the source as I found it. I'm using DOS 5.0.
Groeten uit Nijmegen,
Rudy Wieser
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
; Turn CPU off...
;
; D. Lindauer, July 11 1997
;
; This program is public domain
;
.model tiny
.code
org 100h
start:
jmp go
ver dw 0
banner db 'Power Management utility V1.0 (LADSOFT) ',10,13,10,13,'$'
nopm db 'No power management functionality',10,13,'$'
errmsg db 'Power management error',10,13,'$'
wrongver db 'Need APM version 1.1 or better',10,13,'$'
;
; Display routine
;
print:
mov ah,9
int 21h
ret
;
; Entry point
;
go:
mov dx,offset banner ; Display banner
call print
mov ax,5300h ; See if APM available
mov bx,0 ; device = BIOS
int 15h
mov dx,offset nopm
jc error
cmp ax,101h ; See if version 1.1 or greater
mov dx,offset wrongver
jc error
mov [ver],ax
mov ax,5301h ; Do a real mode connection
mov bx,0 ; device = BIOS
int 15h
jnc noconerr
cmp ah,2 ; Pass if already connected
mov dx,offset errmsg ; else error
jnz error
noconerr:
mov ax,530eh ; Enable latest version of APM
mov bx,0 ; device = BIOS
mov cx,[ver] ; version
int 15h
mov dx,offset errmsg
jc error
mov ax,530dh ; Now engage and enable CPU management
mov bx,1 ; device = all
mov cx,1 ; enable
int 15h
mov dx,offset errmsg
jc error
mov ax,530fh
mov bx,1 ; device = ALL
mov cx,1 ; enable
int 15h
mov dx,offset errmsg
jc error
mov ax,5307h ; Do the power down
mov bx,1 ; device = ALL
mov cx,3 ; mode = OFF
int 15h ; shutdown CPU
mov dx,offset errmsg
error:
call print
mov ax,4c01h
int 21h
int 3
end start
>Below is the source as I found it. I'm using DOS 5.0.
Okay. I'm familiar with David Lindauer's source code.
In fact, I once adapted it to the CP/M-86 operating
system. :)
I have no idea why that code re-boots your computer
approximately 50% of the time.
But here's some code which solved a problem I was
having with another computer. It might work for you.
Try it.
The code is written for the A86 shareware assembler.
It can easily be adapted for other assemblers.
This is a 'brute force' approach, and does not have
any protection against possible negative consequences.
For that reason, use it only with =real= DOS. Do not
use it with 'DOS' that has been spawned from another
operating system (like Win-Doze or Linux).
Hij wou meer soep...
----------------------------< snip >-----------------------------
;
; POWRDOWN.ASM
; 'Brute Force' Computer Shutdown Utility
; Freeware from Phang Hong Wei and Kirk Lawrence
;
code segment
org 100h
jmp start
;
no_apm db 13,10,205,16,' ERROR! Power management is'
db ' either disabled, or not supported.',13,10,07,'$'
no_con db 13,10,205,16,' ERROR! Unable to connect to power'
db ' management functions.',13,10,07,'$'
fail db 13,10,205,16,' ERROR! The power shutdown failed.'
db 13,10,07,'$'
;
; Check to see if APM is available.
;
start:
mov ax,05300h
mov bx,0
int 15h
mov dx,offset no_apm
jc error
;
; Make a real mode interface connection to the power management functions.
;
mov ax,05301h ;do a real mode connection
mov bx,0 ;device = BIOS
int 15h
mov dx,offset no_con
jc error
;
; Enable and shut down.
;
mov ax,5308h ;APM power management
mov bx,0001h ;all devices managed by APM
mov cx,0001h ;enable power management
int 15h
jnc ten
;
mov ax,5308h ;APM power management
mov bx,0FFFFh ;all devices managed by APM ver. 1.0
mov cx,0001h ;enabled power management
int 15h
mov bx,01FFh
;
five:
mov ax,5307h ;APM set power state
mov cx,0000h ;0003h=off 0002h=suspend
int 15h
inc bh
cmp bx,07FFh
jle five
;
ten:
mov ax,5307h ;APM set power state
mov bx,0001h ;all devices managed by APM
mov cx,0003h ;0003h=Off 0002h=suspend
int 15h
jnc disconnect
mov bx,01FFh
;
eleven:
mov ax,5307h ;APM set power state
mov cx,0003h ;0003h=off 0002h=suspend
int 15h
inc bh
cmp bx,07FFh
jle eleven
;
disconnect:
mov ax,5304h ;APM real mode interface disconnect
mov bx,0000h ;APM BIOS
int 15h
mov dx,offset fail
;
; Our error handling routine.
;
error:
call prt_str ;go print the error message
;
; Exit to DOS.
;
int 20h
;
; Our print-string routine.
;
prt_str:
mov ah,9 ;function 9 - print string
int 21h ;call DOS services
ret
end
Ummm...the little gremlin people inside your computer that make it work are
on strike, demanding better working conditions? :)
Oh...you meant "any _sensible_ ideas?"...oh, in that case, no...keine Ahnung
:)
Beth :)
> I've grabbed some source-code for shutting down a computer thru the
> APM from the web, assembled it and, ofcourse, tried it out. To my
> amazement, my computer responds to the program by or shutting down,
> or re-booting. both in an aproximatily 50% to 50% ratio.
>
> Can anyone tell me why this happens ?
I've found some answers to the above question :
My (educated :-) guess is that the current-spike generated by switching the
power off to all devices at once re-starts the ATX power-supply again.
What I did was to precede the actual Shut-down by a Stand-by command. It
looks like it reduces the current-spike enough to get a reliable shut-down
again.
That's how simple it was :-)
Regards,
Rudy Wieser
"R.Wieser" <rwi...@xs4all.nl> schrieb im Newsbeitrag
news:3bac7808$0$65635$e4fe...@newszilla.xs4all.nl...
Hello MaxBanane,
> Can your reboot be a case of normal system crash ?
> And not a function of APM !?
Could be, but thet chance that that is what happens is *very* slim ...
> A crashed system can also do reboot.
> How you can difference this ?
I've played around with the (simple) program, removing several call's. Only
the actual "Shut-down" command will either shut-down , or re-boot the
system.
Adding another call, powering-down all devices, before the actual
"Shut-down" command seems to have resolved my problem. I'm not really sure
if the Time-delay does the trick, or the function's action is to "blame".
Regards,
Rudy Wieser