DevHelp TickCount: Difference between revisions
Created page with "This service registers a new timer handler or modifies a previously registered timer handler to be called on every n timer ticks instead of every timer tick. ==Syntax== ===C..." |
No edit summary |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
This service registers a new timer handler or modifies a previously registered timer handler to be called on every n timer ticks instead of every timer tick. | {{DISPLAYTITLE:DevHelp_TickCount}} | ||
This service registers a new timer handler or modifies a previously registered timer handler to be called on every n timer ticks instead of every timer tick. | |||
==Syntax== | ==Syntax== | ||
;C | |||
USHORT APIENTRY DevHelp_TickCount( NPFN TimerHandler, USHORT TickCount ) | |||
USHORT APIENTRY DevHelp_TickCount( NPFN TimerHandler, | |||
CALL [Device_Help] | ;Assembler | ||
MOV AX,OFFSET CS:timer_handler ; Offset to timer handler | |||
MOV BX,count ; Value of n; the number of tick counts | |||
; (0 - FFFF) | |||
; 0 means FFFFH+1 ticks | |||
MOV DL,DevHlp_TickCount | |||
CALL [Device_Help] | |||
==Parameters== | ==Parameters== | ||
;TimerHandler (NPFN): Offset to timer handler. | |||
; TimerHandler (NPFN) | ;TickCount (USHORT): The number of ticks between calls to timer handler | ||
; TickCount (USHORT) | |||
==Return Code== | ==Return Code== | ||
;C | |||
Success Indicator: 0 | Success Indicator: 0 | ||
Possible errors: Timer handler cannot be modified or set. | Possible errors: Timer handler cannot be modified or set. | ||
;Assembler | |||
<PRE> | <PRE> | ||
'C' Clear if successful. | 'C' Clear if successful. | ||
Line 45: | Line 31: | ||
'C' Set if error. | 'C' Set if error. | ||
AX = Error code. | AX = Error code. | ||
</PRE> | </PRE> | ||
Line 59: | Line 42: | ||
Notice that SetTimer sets a default of n ticks to 1. Multiple TickCount requests can be issued for a given timer handler, but only the last TickCount setting will be in effect. TickCount affects only the specified registered timer handler. It has no effect on other timer handlers. Timer handlers are responsible for saving and restoring registers on entry to and exit from this service. A maximum of 32 timer handlers are available in the system. | Notice that SetTimer sets a default of n ticks to 1. Multiple TickCount requests can be issued for a given timer handler, but only the last TickCount setting will be in effect. TickCount affects only the specified registered timer handler. It has no effect on other timer handlers. Timer handlers are responsible for saving and restoring registers on entry to and exit from this service. A maximum of 32 timer handlers are available in the system. | ||
DS should be set to the physical device driver's data segment. If the physical device driver did a call to PhysToVirt referencing the DS register, it will restore DS to the original value. | DS should be set to the physical device driver's data segment. If the physical device driver did a call to PhysToVirt referencing the DS register, it will restore DS to the original value. | ||
==Example Code== | ==Example Code== | ||
;C | |||
<PRE> | <PRE> | ||
#include "dhcalls.h" | #include "dhcalls.h" | ||
Line 69: | Line 52: | ||
USHORT TickCount ); | USHORT TickCount ); | ||
</PRE> | </PRE> | ||
[[Category:DevHlps]] | [[Category:DevHlps]] |
Latest revision as of 05:39, 11 May 2025
This service registers a new timer handler or modifies a previously registered timer handler to be called on every n timer ticks instead of every timer tick.
Syntax
- C
USHORT APIENTRY DevHelp_TickCount( NPFN TimerHandler, USHORT TickCount )
- Assembler
MOV AX,OFFSET CS:timer_handler ; Offset to timer handler MOV BX,count ; Value of n; the number of tick counts ; (0 - FFFF) ; 0 means FFFFH+1 ticks MOV DL,DevHlp_TickCount CALL [Device_Help]
Parameters
- TimerHandler (NPFN)
- Offset to timer handler.
- TickCount (USHORT)
- The number of ticks between calls to timer handler
Return Code
- C
Success Indicator: 0
Possible errors: Timer handler cannot be modified or set.
- Assembler
'C' Clear if successful. 'C' Set if error. AX = Error code.
Remarks
A physical device driver can use a timer handler to drive a non-interrupt device instead of using timeouts with the ProcBlock and ProcRun services. ProcBlock and ProcRun are costly on a character-by-character basis; the cost is one or more task switches for each character I/O. Timer handlers are required to save and restore registers. While a timer handler is in the format of a far call/return routine, it operates at interrupt time. The timer handler is analogous to the user timer (INT 1Ch) handler. As with any handler that runs in an interrupt context, care must be taken to make the execution path as short as possible.
For a new timer handler, TickCount registers the timer handler to be called on every n timer ticks instead of every timer tick. For a previously registered timer handler, TickCount changes the number of ticks that must take place before the timer handler gets control. This allows physical device drivers to support the timeout function without needing to count ticks.
At task time, this DevHlp can be used to modify a timer handler registered through SetTimer, or to register a new timer handler that is initially invoked every n ticks. In user mode (task time), TickCount can be used only to modify a timer handler already registered. In interrupt mode (interrupt time), this service can be used only to modify a timer handler already registered. This allows an interrupt handler to reset the timing condition at interrupt time.
Notice that SetTimer sets a default of n ticks to 1. Multiple TickCount requests can be issued for a given timer handler, but only the last TickCount setting will be in effect. TickCount affects only the specified registered timer handler. It has no effect on other timer handlers. Timer handlers are responsible for saving and restoring registers on entry to and exit from this service. A maximum of 32 timer handlers are available in the system.
DS should be set to the physical device driver's data segment. If the physical device driver did a call to PhysToVirt referencing the DS register, it will restore DS to the original value.
Example Code
- C
#include "dhcalls.h" USHORT APIENTRY DevHelp_TickCount( NPFN TimerHandler, USHORT TickCount );