Update- Eric adds:
Hi, I think you can update technote 190, telling that POWER is pretty complete now (current version only talks about lowlevel/midlevel functions existing).
Although, the UNIDLECHECK code still is not there. It would be the idea to use it to idle the CPU even when the program does not wait for keypresses, based on some heuristics and a timer tick handler - the SKETCH of the code is there, but OTHERS have to fill it with life if they want FDAPM to save even more power than in APMDOS mode (this is a call for contributions...).
Eric Auer posted this comment to the FreeDOS mailing list. It's long, but has some good APM info for those programmers interested in such things:
Hi, I remind that we wanted to improve the POWER driver, which ought to have 3 modes:
- no APM
- default APM
- APM low power mode while DOS is in idle (int 28h, I guess) state
I found some useful code snippet on the LadSoft page (went there because David released a new debugger, as mentioned on FreeDOS.org: by the way, FreeDOS debug also supports 32bit code, but is generally smaller and simpler, more MS DOSish, compared to LadSofts): http://members.tripod.com/~ladsoft/dos/pwm.txt
This explains how to APM-powerdown a PC. Of course, POWER would not turn the PC off, but the general idea is similar:
- int 15.5300.bx=0 install check APM, returns version AH.AL
- int 15.5301.bx=0 connect in real mode: must return NC or at least only AH=2 (already connected) if CY.
- int 15.530e.bx=0 enable latest APM version CX (set this from the CX of your choice or from the AX that int 15.5300 returned).
- int 15.530d.bx=1.cx=1 engage and enable CPU management (bx is 0 for BIOS, 1 for all, CX=1 means enable).
- int 15.530f.bx=1.cx=1 ...
- int 15.5307.bx=1.cx=3 for device ALL set mode CX=3 OFF (of course, POWER would not turn off but only go to low power mode)
- (this point is not reached if the power off call worked)
Check the RBIL to know more details:
Other useful things on LadSoft:
- DOS PPP driver http://members.tripod.com/~ladsoft/lsppp/
- DOS ICQ client http://members.tripod.com/~ladsoft/lsicq/ (no idea if it still works: I had for example to change from mICQ to centericq because AOL/Mirabillis/ICQ tries to lock out inofficial ICQs)...
Devices: 0 BIOS 1 all 1fff all display 2ff all disks 3ff all parports 4ff all comports 5ff all network (APM 1.1+) 6ff all PCMCIA (1.1+) ...
States: 0 on (not for device 1!?) 1 standby 2 suspend 3 off (APM 1.1+ if dev. 1) ...
Standby for example is often exited by IRQ, and to avoid nesting, you should be carefull if entering it from an IRQ. My APM, for example, is configured to wake up from most events, even soundcard IRQs, from that state. All kinds of low power / off states might return to where you called them just as if the int 15.5307... call IRETed. Especially after power off, you usually just reboot on powering on again, however.
Int 15.5308.bx=(1 means all in APM 1.1+, ffff same for APM 1.0).cx=0/1 dis/en
Disable/Enable APM: This is -imho- enough for 2 of the 3 modes of POWER already.
Int 15.530f is the corresponding disengage / engage...
In APM 1.2+ you also have a programmable resume timer (15.5311 etc.) various resume conditions and configuration, auto power off timer, calendar events, *CPU SPEED MODE* (int 15.5380.bh=0c get divider to CL and mode to BL / int 15.5380.bh=0d.cl=divider (1,2,4,8).bl=mode?) and other stuff.
Other standard calls:
- 15.5300 install check (BX and CX set as well),
- 15.5301 real mode connect 15.5302 protected mode connect,
- 15.5303 32bit protected mode connect, 15.5304 disconnect (for device BX),
- 15.5305 *CPU IDLE CALL* (go to lower power mode until next event / IRQ),
- 15.5306 tell that CPU is busy (lock system to full speed mode),
- 15.5307 set power state, see above, 15.5308 enable/disable power mgmt.,
- 15.5309 restore defaults, 15.530a get status, 15.530b get event,
- 15.530c get state, 15.530d enable/disable device power mgmt.,
- 15.530e driver version (?), 15.530f engage/disengage power mgmt.,
- 15.5310 get capabilities, 15.5311 get/set/disable resume timer,
- 15.5312 enable/disable resume on ring, 15.5313 enable/disable timer-based...,
- 15.5380 get suspend/global standby mode / timer / auto power off timer, set...,
- (and other stuff: resume conditions, calendar events...)
- (CPU SPEED is only available in APM SL Enhanced 1.0, sounds like 386SL !)
Other CPU speed stuff: AMI PCI BIOS int 15.da01.cl=0/1/2 set low/high/get speed, get returns to AH, working is similar to Ctrl Alt Gray+/- ... (int 15.da92 gets CPU type / speed to AL=stepping AH=model BL=family x, as in 80x86), CX=speed in BCD MHz, only returns FSB speed it seems)
Int 16.f0.xx is Compaq 386 CPU speed set (0=6, 1=8, 2=16 MHz, 3/8/9 special). (int 16.f1 reads to AL on this boards, if AL=9, percent returned in CX) ...
Int 1f.fb.bl=0/1 get/set speed AL (0 fast 1 slow) on C&T SuperState BIOS, ...
Those are all "cpu speed" things and common APM things that a quick RBIL browsing gave to me, which you should do.
Florian Xaver adds:
Aitor Santamaria Merino apm library is avaiable at http://www.apmlib.at.tf/ (for Borlandc/TurboC, DJGPP, Pascal) now. (i deleted the seal.de.vu page, since i don't use it anymore).
It seems that Eric has since built upon Aitor's APM lib, and created a new FreeDOS POWER utility ...
Eric writes, again:
Hi all, I started writing the POWER driver which would allow FreeDOS to: Enter standby / suspend / power off mode, Reboot hot / warm / cold, Lock CPU to busy state, Enable BIOS APM, Add DOS busy-checking to help BIOS APM, Go into HLT and/or APM IDLE mode when waiting for keyboard input/..., Show APM and POWER status, like battery information.
I currently have > 1000 lines of NASM code, but the central part of "parse command line and call midlevel functions as appropriate" is missing. I provide midlevel functions like "reboot type AX" or "enter mode AX" and so on. I also have the status reporting stuff done. Basic interrupt handlers are also present.
If you do not compile with -DUNIDLECHECK, far less interrupts are hooked, and only int 16 / 28 / 2a "idle" calls are used to detect "idle" state. WITH the -D..., you enable several other int hooks which try to detect when the system is busy in DOS sense. You need this to reach A D V modes apart from MAX. Not that important if you ask me: I think most useful things are HLT / CPU idle on IDLE, without further DOS BUSY checks, and the ability to show status / reboot / power down and the like.
As I need to get some real life again (weekend!), I would be very happy if OTHER programmers could contribute code and/or check my design for flaws. If you want to compile the current version, you first have to hardcode some action calls: As said, the command line PARSER is missing, but all the midlevel "library" functions are already waiting for work :-).
http://www.coli.uni-sb.de/~eric/stuff/soft/specials/ - fdapm.zip
This project is based on APMlib by Aitor, what-gets-hooked check by me on MS POWER, reading docs of a few Windows / Linux power savers, reading lots of RBIL docs (int 15.53xx, int 2f.54xx), and other factors that I forgot to mention.