2a7dcff56f30c64559c048ddc58c9ed3e5b6cfb3
[reactos.git] / reactos / hal / halx86 / generic / 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.h>
11 #include <ndk/amd64/asmmacro.S>
12
13 /* GLOBALS *******************************************************************/
14
15 .data
16
17 .global _MsgUnimplemented
18 _MsgUnimplemented:
19 .asciz "WARNING: %s at %s:%d is UNIMPLEMENTED!\n"
20
21
22 /* FUNCTIONS *****************************************************************/
23
24 .text
25 .code64
26
27 .global _HalpCalibrateStallExecution@0
28 .func HalpCalibrateStallExecution@0
29 _HalpCalibrateStallExecution@0:
30
31 .endfunc
32
33 .globl _HalpProfileInterrupt
34 .func HalpProfileInterrupt
35 _HalpProfileInterrupt:
36
37 .endfunc
38
39
40 .globl _KeStallExecutionProcessor
41 .func KeStallExecutionProcessor
42 _KeStallExecutionProcessor:
43
44 /* Get the number of microseconds required */
45 jecxz Done
46
47 /* Multiply by the stall factor */
48 mov eax, gs:[KPCR_STALL_SCALE_FACTOR]
49 mul ecx
50
51 /* Align to 16 bytes */
52 .align 16
53
54 /* Jump to subtraction loop */
55 jmp SubtractLoop
56
57 /* Align to 16 bytes */
58 .align 16
59
60 /* Subtract one count */
61 SubtractLoop:
62 sub eax, 1
63 jnz SubtractLoop
64
65 Done:
66 /* Return */
67 ret 4
68 .endfunc
69
70
71 .globl _HalpQuery8254Counter
72 .func HalpQuery8254Counter
73 _HalpQuery8254Counter:
74
75 /* Save EFLAGS and disable interrupts */
76 pushfq
77 cli
78
79 /* Set timer data */
80 mov al, 0
81 out 0x43, al
82 jmp $+2
83
84 /* Read current timer */
85 in al, 0x40
86 jmp $+2
87 movzx ecx, al
88 in al, 0x40
89 mov ch, al
90
91 /* Return it and restore interrupt state */
92 mov eax, ecx
93 popfq
94 ret
95 .endfunc
96
97 .globl _HalpClockInterrupt
98 .func HalpClockInterrupt
99 _HalpClockInterrupt:
100 UNIMPLEMENTED _HalpClockInterrupt
101 iret
102 .endfunc
103