Revert r46466 this time for real
[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 <reactos/asm.h>
11 #include <ndk/amd64/asm.h>
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 PUBLIC HalpCalibrateStallExecution@0
28 HalpCalibrateStallExecution@0:
29
30
31 PUBLIC HalpProfileInterrupt
32 HalpProfileInterrupt:
33
34
35 PUBLIC KeStallExecutionProcessor
36 KeStallExecutionProcessor:
37
38 /* Get the number of microseconds required */
39 jecxz Done
40
41 /* Multiply by the stall factor */
42 mov eax, gs:[KPCR_STALL_SCALE_FACTOR]
43 mul ecx
44
45 /* Align to 16 bytes */
46 .align 16
47
48 /* Jump to subtraction loop */
49 jmp SubtractLoop
50
51 /* Align to 16 bytes */
52 .align 16
53
54 /* Subtract one count */
55 SubtractLoop:
56 sub eax, 1
57 jnz SubtractLoop
58
59 Done:
60 /* Return */
61 ret 4
62
63
64 PUBLIC HalpQuery8254Counter
65 HalpQuery8254Counter:
66
67 /* Save EFLAGS and disable interrupts */
68 pushfq
69 cli
70
71 /* Set timer data */
72 mov al, 0
73 out 0x43, al
74 jmp $+2
75
76 /* Read current timer */
77 in al, 0x40
78 jmp $+2
79 movzx ecx, al
80 in al, 0x40
81 mov ch, al
82
83 /* Return it and restore interrupt state */
84 mov eax, ecx
85 popfq
86 ret
87
88 PUBLIC HalpClockInterrupt
89 HalpClockInterrupt:
90 UNIMPLEMENTED _HalpClockInterrupt
91 iret
92