J de Boyne Pollard <> writes:
> AA> It is my understanding that power down is controlled by the BIOS.
>
> It's controlled by circuitry on the motherboard that signals the power
> supply unit through a line on the power connector. This circuitry is
> in turn controllable from software via chipset registers. These
> registers vary according to chipset. The firmware, which has intimate
> knowledge of the chipset, knows exactly which registers to poke.
In the particular computer I am interested in doing this on, the CPU
is an AMD K6 processor and the chipset is an old VIA VT82585 chipset.
Does that help?
> AA> I'd like to write an assembly language program that shuts off the
> computer.
>
> Firrwares export interfaces so that other softwares can control system
> power states by invoking firmware functions. What you need to read
> about are Advanced Power Management and the Advanced Configuration and
> Power Interface. Bear in mind that operating systems are the intended
> users of these interfaces, not the applications programs that run on
> top of them.
Thanks for the lucid explanations. I found Wikipedia articles for both
APM and ACPI.
Some time ago, someone suggested some floppies with boot managers on them,
maybe including Smart Boot Manager. I vaguely recall that one of the options
it offered (if that is the one) was powering down the PC. So, maybe if I
can find documented source code for one of these boot managers, it will
have the secret of how to do this.
OK, I just went to
http://btmgr.sourceforge.net/download.html
and downloaded btmgr-3.7-1.tar.gz and untarred it and looked in
the source files. The file utils.asm contains the following:
;================================================= ============================
; power_off ---- turn the power off
;input:
; none
;output:
; never return if successful.
; cf = 1 on error.
;================================================= ============================
power_off:
pusha
call check_apm_bios
jc .end
mov ax, 0x5301
xor bx, bx
int 0x15
jc .end
mov ax, 0x5380
mov bh, 0x8c
int 0x15
mov ax, 0x40
mov bx, 0xd8
push ds
mov ds, ax
or byte [ds:bx], 0x10
pop ds
mov ax, 0x5307
mov bx, 1
mov cx, 3
int 0x15
..end:
popa
ret
;================================================= ============================
; check_apm_bios ---- check if the apm bios present
; output:
; cf = 1 error, cf = 0 ok
;================================================= ============================
check_apm_bios:
pusha
mov ax, 0x5300
xor bx, bx
int 0x15 ; check if apm present
jc .end
cmp bx, 0x504D
jnz .none
test cx, 1
jnz .end
..none:
stc
..end:
popa
ret
I'll have to look at it carefully, but in a nutshell it appears that
one can turn off the power using interrupt 0x15 provided there is
BIOS support for it. I'll see what Gilluwe's The Undocumented PC
says about that.
The next question is this: suppose I take a floppy disk and write this
code to the beginning of the boot sector and then set the PC to boot from
the floppy and boot. Will the machine start up, run through POST and then
shut itself off, assuming it has the APM support?
--
Ignorantly,
Allan Adler <>
* Disclaimer: I am a guest and *not* a member of the MIT CSAIL. My actions and
* comments do not reflect in any way on MIT. Also, I am nowhere near Boston.