The text of a manual · part 27 of 42
JANUS PSK for C/C++ Reference Manual, Version 2.1, pages 261 to 270
Pages 261 to 270 of 414
The original document is the PDF (690 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
Critical Suspend The reader enters a critical Suspend transition when the battery is removed, the main battery is low, or the front panel 1/0 key is pressed. The reader attempts to enter a normal Suspend transition before entering a critical Suspend transition. Several warning periods occur prior to entering a low main battery state. Initially, the battery icon flashes as the battery begins to reach end of charge. Next the system emits warning beeps. Automatic shutoff with fully saved states occurs at a somewhat lower charge level. Certain system events (such as transmitting data using RF or a laser scanner) can add enough load to a low battery charge to cause an immediate transition to the low battery cutoff critical Suspend state. A critical Suspend transition is always enabled. The application software must deal with the subsequent resume as effectively as possible. Functions in process might not be completely restored following a critical Suspend.
Critical Resume The reader enters a critical Resume transition when the front panel 1/0 key is pressed or the battery is replaced. A critical Resume transition follows a critical Suspend transition. A critical Resume is not possible unless there has been a prior valid critical Suspend to save the system state. If the system state is not valid, a critical Resume forces a reboot. The operator can use the boot screen function to dump the system memory state (through the communications port) to a host system prior to a reboot.
4-19
Page 262
JANUS PSK for C/C++ Reference Manual
APM Interface Functionality Programs that need to connect to and use the APM interface should observe the following suggested protocol: • Turn off POWER.EXE (at the DOS command line) prior to connecting with the APM interface. • Issue an APM installation check call. This call returns information on the current APM functionality (such as whether power management is currently enabled or disabled). • Issue an APM interface connect call. If the return from this call shows an already connected client (such as POWER.EXE mentioned above), the application should terminate. The APM interface only allows one connected client. • Issue an interface disconnect call, prior to exiting (for example, returning to the DOS prompt), so that another client can be connected. Note: For an example of APM interface protocol as discussed above, see the application listing FIFO.CPP in Appendix B, “Sample Interrupt Programs.” You must enable power management for the interface connect call to be successful, otherwise the CPU stays in the Ready state until the operator presses an 1/0 key to transition to the Suspend state. Certain system activities (such as file access to the PC card) temporarily disable PM to protect their integrity. Your application might have its own reasons to disable PM. You can use the enable/disable power management call to enable PM. When PM is enabled, your application can initiate a get PM event call, and either use the result to change states or ignore the PM event call, in which case the unit stays in the Ready state (unless reader services is active to prompt state changes). A get PM event returns a battery status value that your application can use. When your application is connected as an APM client, it is notified during get PM event calls when a system Suspend condition occurs. APM requires your client application to complete current processes, issue a set power state command, and enter the Suspend state (effectively turning the unit off) as soon as possible.
4-20
Page 263
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 264
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 265
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 266
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 267
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 268
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 a 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 269
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 270
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