The text of a manual · part 27 of 40
2D JANUS PSK for C/C++ Reference Manual, pages 261 to 270
Pages 261 to 270 of 400
The original document is the PDF (793 KB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
For the Intermec J2020, Intermec J2010 and Intermec J2050
Page 261
Advanced Programming
4
Certain system events, such as low battery, cannot wait for this process to occur and instead cause an immediate transition to Suspend. The resume following each Suspend includes, as the first PM event response, the fact of resume and the resume type: normal or critical. After a critical resume occurs, your application must continue to operate as effectively as possible. You can use power state commands to transition from Ready to Standby or Suspend. The APM interface coordinates with IPM to allow transitions from Ready only when both interfaces allow it. This coordination also applies to CPU Busy and CPU Idle. Either interface can keep the CPU in Ready, and both must allow other states. A transition to Suspend stops the time and date of the system clock. Upon each resume, the IPM interface restores the time function from the real-time clock. Upon resume in some situations, such as when the unit is suspended over midnight or when the date changes, the APM client must restore the DOS date function by using the real-time clock and date. POWER.EXE restores the date when it is active. Note: For an example of how to enter the APM interface registers from the DOS command line and then connect to the APM interface, see the application listing APMIF.C in Appendix B, “Sample Interrupt Programs.”
4-21
Page 262
2D JANUS PSK for C/C++ Reference Manual
Special APM BIOS Calls APM requires a real mode interface and is implemented with an extension to INT 15. The system BIOS must operate in either real mode or virtual-86 mode on 80386 and later processors. Since the INT 15H processor instruction normally disables the interrupts, the system BIOS typically expects to be entered with interrupts disabled. However, the BIOS routines should not depend on any particular setting and should explicitly enable and disable interrupts as necessary. To avoid reentering INT 15H, an interrupt service routine (ISR) should not use any of the APM functions. To better support the protected modes of 80286 and later processors, the system BIOS optionally supports a 16- and 32-bit protect mode interface directly callable from protected mode. First, you must initialize the protected mode interfaces using the real mode INT 15H AH = 53H. Systems not supporting APM return from this call with the carry flag (CY) set and the AH register equals 86H. You must initialize 16- and 32-bit protected mode interfaces using the appropriate protected mode 16-bit interface connect or protected mode 32-bit interface connect functions. If an error condition is detected when processing a system BIOS function, the function returns to the caller with the carry flag set and an error code in the AH register. The carry flag is cleared upon return from any successful call, and the content of the AH register is dependent on the particular call. This interface adopts a convention for identifying a device class and specific subclasses within that class to use in direct device control. For example, a class might be all disk devices and the subclasses could be the physical unit numbers. APM calls take this parameter in a word-length register where the most significant byte (MSB) is the device class and the least significant byte (LSB) is the device subclass. This parameter is described in the individual interface descriptions.
4-22
Page 263
Advanced Programming
4
The APM device class and subclass IDs are defined using BX = Device ID as follows: Device Class ID
Device Subclass ID
00XXH
00H
System BIOS
01H
All devices power managed by the system BIOS
System
01XXH
Display n/a
02XXH
Secondary Storage n/a
03XXH
Parallel Ports n/a
04XXH
Serial Ports n/a
0500H to FFFFH
Reserved n/a
Where XXH indicates the physical device number (zero-based). Where FFH indicates all devices in this class. The following pages list the special APM system BIOS software interrupts that are unique to power management.
4-23
Page 264
APM Installation Check
APM Installation Check Purpose:
This function determines if the system BIOS supports the APM functionality.
Call With:
AH =
53H
AL=
00H
BX =
0000H System BIOS
Return Value:
Do APM installation check
If the function is successful: Carry flag =
Clear
AH =
Major version number (in BCD format)
AL =
Minor version number (in BCD format)
BH =
ASCII P character
BL =
ASCII M character
CX =
Bit 0 = 1 if the BIOS supports 16-bit protected mode Bit 1 = 1 if the BIOS supports 32-bit protected mode Bit 2 = 1 if CPU Idle call slows processor clock speed Bit 3 = 1 if BIOS Power Management is disabled All other bits reserved
If the function is unsuccessful:
Notes:
Carry flag =
Set
AH =
APM is not present
86H
The interpretation of bit 2 is documented under the CPU Busy call description. This call is only available using the real mode INT 15H interface.
4-24
Page 265
CPU Busy
4
CPU Busy Purpose:
This function informs the system BIOS that the system is now busy and should continue at full speed. Some system implementations may only be able to slow the CPU clock rate and return in response to the CPU Idle call. The system BIOS usually restores the CPU clock rate to its normal rate when it recognizes increased system activity (typically interrupt driven), but it may be unable to do so when interrupts are hooked by external software and do not invoke BIOS routines. You can ensure the system is running at full speed by using the CPU Busy function. Upon return from the APM Installation Check call, bit 2 of the CX register indicates if the system BIOS slowed the CPU clock rate during the CPU Idle call. You can use this bit to determine whether to call CPU Busy before executing code that should run at full speed. Calling CPU Busy is discouraged when the system is already operating at full speed because of the unnecessary call overhead, but the operation is allowed and has no unexpected side effects. AH =
53H
AL =
06H
Return Value:
CY =
00H
Notes:
This function is available in both the APM INT 15H and protect mode interface. Either APM or IPM busy can keep the CPU processing at full speed.
Call With:
4-25
Page 266
CPU Idle
CPU Idle Purpose:
This function informs the system BIOS that the system is currently idle and that processing can be suspended until the next system event (typically an interrupt) occurs. This function allows the system BIOS to take some implementation-specific power saving action, such as stopping the CPU clock. In cases where an interrupt causes the system to leave the idle state, the interrupt might have been serviced when the BIOS returns from the CPU Idle call. The calling application should not make any assumptions concerning interrupt servicing and should allow pending interrupts to be taken upon return from CPU Idle. If interrupts are serviced from within the BIOS CPU Idle function, the interrupt handler must return to the BIOS when interrupt processing is completed. The caller cannot use knowledge of being in the idle state to regain control from an interrupt handler. For example, some system implementations can slow the processor CPU clock rate before waiting on an interrupt, and restore the normal clock rate after the interrupt is serviced but before returning from the idle call. When the caller regains control, it should determine if there is actually any processing waiting to be performed and reissue the CPU Idle call if not. If the caller is a multitasking supervisor, it may be necessary to dispatch all of the applications (through calls to the supervisor), allowing them to check for incomplete activity. AH =
53H
AL =
05H
Return Value:
CY =
00H
Notes:
This function is available in both the APM INT 15H and protect mode interface. Either the APM or IPM interface can keep the CPU in the busy state.
Call With:
4-26
Page 267
Enable/Disable Power Management
4
Enable/Disable Power Management Purpose:
This function enables or disables all APM automatic power down functionality. When disabled, the system BIOS does not automatically power down devices, enter the Standby state or Suspend state, or take powersaving steps in response to CPU Idle calls. In addition, many system BIOS functions are disabled and return the error 01H, indicating that power management functionality is disabled.
Call With:
AH =
53H
AL =
08H
BX =
FFFFH Enable/disable all power management
CX =
00H 01H
Return Value:
Disable power management Enable power management
If the function is successful: Carry flag =
Clear
If the function is unsuccessful: Carry flag = AH =
Notes:
Set
Error code: 01H Power management functionality disabled 09H Unrecognized device ID 0AH Parameter value in CX is out of range
This call is available in both the APM INT 15H and protect mode interfaces. Either APM or IPM can use this call to disable power management. Both APM and IPM must be enabled before enabling power management.
4-27
Page 268
Get PM Event
Get PM Event Purpose:
This function returns the next pending PM event (or indicates that no PM events are pending).
Call With:
AH =
53H
AL =
0BH
Return Value:
If the function is successful: Carry flag = BX =
Clear
PM event code: 01H System Standby request notification 02H System Suspend request notification 03H Normal resume system notification 04H Critical resume system notification 05H Battery low notification
If the function is unsuccessful: Carry flag = AH =
Notes:
Set
Error code: 03H Interface connection is not established 80H No PM events are pending
Power events can occur when the system software is not immediately ready to process the event. In order to synchronize power events with other system software, the system BIOS withholds event notification until polled with the get PM event function. The cooperative PM software is only notified when it is ready to process the event. The PM partner receives power event notification by periodically calling the get PM event function. Since power management events are not extremely time critical, a polling frequency of once or twice a second should be sufficient.
4-28
Page 269
Get PM Event
4
The 01H system Standby request notification informs the PM partner that the system BIOS wants to place the system in a Standby state. The system BIOS does not take any action at this time, but waits passively for the PM partner to call the system Standby function. The 02H system Suspend request notification informs the PM partner that the system BIOS wants to place the system into a Suspend state. The system BIOS does not actually perform a Suspend at this time, but waits passively for the partner to call the Suspend system function. A Resume system notification indicates that a critical system Suspend and Resume operation occurred without the cooperation of the PM partner. When a Suspend operation is scheduled to occur, the system BIOS normally notifies the partner through the Suspend system request, but does not actually perform the Suspend until the partner calls the Suspend system function. In some emergency situations the system BIOS needs to Suspend the system immediately. In this situation, the system BIOS informs the partner that the system has resumed from such a Suspend through a Resume system notification. The partner must recover from the Suspend as best it can. Critical Suspend situations include power on and off, low battery, dead battery, and battery interlock. The 05H battery low notification informs the PM partner that the system battery is running low. This call is available in both the APM INT 15H and protect mode interfaces.
4-29
Page 270
Get Power Status
Get Power Status Purpose:
This function returns the system current power status.
Call With:
AH =
53H
AL =
0AH
BX =
0001H
Return Value:
If the function is successful: Carry flag =
Clear
BH =
AC line status: 00H 0 indicates offline 01H 1 indicates online FFH 255 indicates unknown All other values reserved
BL =
Battery status: 00H 0 indicates high 01H 1 indicates low 02H 2 indicates critical 03H 3 indicates charging FFH 255 indicates unknown All other values reserved
CL =
Remaining battery life: 00H–64H Percent of full charge (0–100) in increments of 10 FFH 255 indicates unknown
If the function is unsuccessful:
Notes:
4-30
Carry flag =
Set
AH =
Unrecognized device ID
09H
This call is available in both the APM INT 15H and protect mode interfaces.