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