source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HTimer.asm@ 145

Last change on this file since 145 was 143, checked in by Tomi Tilli, 14 years ago

Changes to XTIDE Universal BIOS:

  • Removed "Boot sector found!" string.
  • Added option to specify display mode for boot menu.
File size: 3.0 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Timeout and delay functions for INT 13h services.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; HTimer_InitializeTimeoutWithTicksInCL
9; Parameters:
10; CL: Timeout value in system timer ticks
11; DS: Segment to RAMVARS
12; Returns:
13; Nothing
14; Corrupts registers:
15; CX
16;--------------------------------------------------------------------
17ALIGN JUMP_ALIGN
18HTimer_InitializeTimeoutWithTicksInCL:
19 xor ch, ch ; Timeout ticks now in CX
20 mov [RAMVARS.wTimeoutCounter], cx ; Store timeout ticks
21 call ReadTimeFromBdaToCX
22 add [RAMVARS.wTimeoutCounter], cx ; End time for timeout
23 ret
24
25
26;--------------------------------------------------------------------
27; HTimer_SetCFifTimeout
28; Parameters:
29; DS: Segment to RAMVARS
30; Returns:
31; CF: Set if timeout
32; Cleared if time left
33; Corrupts registers:
34; CX
35;--------------------------------------------------------------------
36ALIGN JUMP_ALIGN
37HTimer_SetCFifTimeout:
38 call ReadTimeFromBdaToCX
39 cmp [RAMVARS.wTimeoutCounter], cx
40 ret
41
42
43;--------------------------------------------------------------------
44; Delay is always at least one millisecond since
45; RTC resolution is 977 microsecs.
46;
47; HTimer_MicrosecondsFromAX
48; Parameters:
49; AX: Number of microsecs to wait
50; Returns:
51; Nothing
52; Corrupts registers:
53; AX
54;--------------------------------------------------------------------
55HTimer_MicrosecondsFromAX:
56%ifndef USE_AT
57 mov ax, 1
58 ; Fall to Delay_TimerTicksFromAX
59%else
60 push dx
61 push cx
62
63 xor cx, cx
64 xchg dx, ax ; Microsecs now in CX:DX
65 mov ah, EVENT_WAIT
66 int BIOS_SYSTEM_INTERRUPT_15h
67 sti ; XT BIOSes return with interrupt disabled
68
69 pop cx
70 pop dx
71 mov ax, 1 ; Prepare to wait 1 timer tick
72 jc SHORT HTimer_TimerTicksFromAX ; Event Wait was unsupported or busy
73 ret
74%endif
75
76
77;--------------------------------------------------------------------
78; First tick might take 0...54.9 ms and remaining ticks
79; will occur at 54.9 ms intervals.
80;
81; HTimer_TimerTicksFromAX
82; Parameters:
83; AX: Number of timer ticks to wait
84; Returns:
85; Nothing
86; Corrupts registers:
87; AX
88;--------------------------------------------------------------------
89HTimer_TimerTicksFromAX:
90 sti ; Make sure that interrupts are enabled
91 call ReadTimeFromBdaToCX
92 add ax, cx ; AX = end time
93.WaitLoop:
94 call ReadTimeFromBdaToCX
95 cmp cx, ax
96 jb SHORT .WaitLoop ; Loop until end time is reached
97 ret
98
99
100;--------------------------------------------------------------------
101; ReadTimeFromBdaToCX
102; Parameters
103; Nothing
104; Returns:
105; CX: System time in 54.9 ms ticks
106; Corrupts registers:
107; Nothing
108;--------------------------------------------------------------------
109ALIGN JUMP_ALIGN
110ReadTimeFromBdaToCX:
111 push ds
112 LOAD_BDA_SEGMENT_TO ds, cx
113 mov cx, [BDA.dwTimerTicks] ; Read low WORD only
114 pop ds
115 ret
Note: See TracBrowser for help on using the repository browser.