[ASM]
[reactos.git] / reactos / hal / halx86 / amd64 / systimer.S
1 /*
2 * FILE: hal/halx86/generic/timer.S
3 * COPYRIGHT: See COPYING in the top level directory
4 * PURPOSE: System Timer Interrupt and Management
5 * PROGRAMMER: Alex Ionescu (alex@relsoft.net)
6 */
7
8 /* INCLUDES ******************************************************************/
9
10 #include <asm.inc>
11
12 #include <ksamd64.inc>
13
14 /* GLOBALS *******************************************************************/
15
16 .data
17
18 .global MsgUnimplemented
19 MsgUnimplemented:
20 .asciz "WARNING: %s at %s:%d is UNIMPLEMENTED!\n"
21
22
23 /* FUNCTIONS *****************************************************************/
24
25 .text
26 .code64
27
28 PUBLIC HalpCalibrateStallExecution@0
29 HalpCalibrateStallExecution@0:
30
31
32 PUBLIC HalpProfileInterrupt
33 HalpProfileInterrupt:
34
35
36 PUBLIC KeStallExecutionProcessor
37 KeStallExecutionProcessor:
38
39 /* Get the number of microseconds required */
40 jecxz Done
41
42 /* Multiply by the stall factor */
43 mov eax, gs:[KPCR_STALL_SCALE_FACTOR]
44 mul ecx
45
46 /* Align to 16 bytes */
47 .align 16
48
49 /* Jump to subtraction loop */
50 jmp SubtractLoop
51
52 /* Align to 16 bytes */
53 .align 16
54
55 /* Subtract one count */
56 SubtractLoop:
57 sub eax, 1
58 jnz SubtractLoop
59
60 Done:
61 /* Return */
62 ret 4
63
64
65 PUBLIC HalpQuery8254Counter
66 HalpQuery8254Counter:
67
68 /* Save EFLAGS and disable interrupts */
69 pushfq
70 cli
71
72 /* Set timer data */
73 mov al, 0
74 out 0x43, al
75 jmp $+2
76
77 /* Read current timer */
78 in al, 0x40
79 jmp $+2
80 movzx ecx, al
81 in al, 0x40
82 mov ch, al
83
84 /* Return it and restore interrupt state */
85 mov eax, ecx
86 popfq
87 ret
88
89 PUBLIC HalpClockInterrupt
90 HalpClockInterrupt:
91 UNIMPLEMENTED _HalpClockInterrupt
92 iret
93
94 END