2008-09-03 01:10:10 +00:00
|
|
|
/*
|
|
|
|
* FILE: hal/halx86/generic/timer.S
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PURPOSE: System Timer Interrupt and Management
|
|
|
|
* PROGRAMMER: Alex Ionescu (alex@relsoft.net)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
|
2010-11-27 22:12:15 +00:00
|
|
|
#include <asm.inc>
|
|
|
|
|
|
|
|
#include <ksamd64.inc>
|
2008-09-03 01:10:10 +00:00
|
|
|
|
|
|
|
/* GLOBALS *******************************************************************/
|
|
|
|
|
2009-12-28 17:53:26 +00:00
|
|
|
.data
|
2008-09-03 01:10:10 +00:00
|
|
|
|
2010-02-06 01:26:52 +00:00
|
|
|
.global MsgUnimplemented
|
|
|
|
MsgUnimplemented:
|
2009-12-28 17:53:26 +00:00
|
|
|
.asciz "WARNING: %s at %s:%d is UNIMPLEMENTED!\n"
|
|
|
|
|
|
|
|
|
2008-09-03 01:10:10 +00:00
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
|
2009-12-28 17:53:26 +00:00
|
|
|
.text
|
|
|
|
.code64
|
|
|
|
|
2010-02-04 04:58:09 +00:00
|
|
|
PUBLIC HalpCalibrateStallExecution@0
|
|
|
|
HalpCalibrateStallExecution@0:
|
2009-11-10 02:40:48 +00:00
|
|
|
|
|
|
|
|
2010-02-04 04:58:09 +00:00
|
|
|
PUBLIC HalpProfileInterrupt
|
|
|
|
HalpProfileInterrupt:
|
2009-11-10 02:40:48 +00:00
|
|
|
|
|
|
|
|
2010-02-04 04:58:09 +00:00
|
|
|
PUBLIC KeStallExecutionProcessor
|
|
|
|
KeStallExecutionProcessor:
|
2008-09-03 01:10:10 +00:00
|
|
|
|
|
|
|
/* Get the number of microseconds required */
|
|
|
|
jecxz Done
|
|
|
|
|
|
|
|
/* Multiply by the stall factor */
|
|
|
|
mov eax, gs:[KPCR_STALL_SCALE_FACTOR]
|
|
|
|
mul ecx
|
|
|
|
|
|
|
|
/* Align to 16 bytes */
|
|
|
|
.align 16
|
|
|
|
|
|
|
|
/* Jump to subtraction loop */
|
|
|
|
jmp SubtractLoop
|
|
|
|
|
|
|
|
/* Align to 16 bytes */
|
|
|
|
.align 16
|
|
|
|
|
|
|
|
/* Subtract one count */
|
|
|
|
SubtractLoop:
|
|
|
|
sub eax, 1
|
|
|
|
jnz SubtractLoop
|
|
|
|
|
|
|
|
Done:
|
|
|
|
/* Return */
|
|
|
|
ret 4
|
|
|
|
|
2009-10-15 21:40:00 +00:00
|
|
|
|
2010-02-04 04:58:09 +00:00
|
|
|
PUBLIC HalpQuery8254Counter
|
|
|
|
HalpQuery8254Counter:
|
2009-10-15 21:40:00 +00:00
|
|
|
|
|
|
|
/* Save EFLAGS and disable interrupts */
|
|
|
|
pushfq
|
|
|
|
cli
|
|
|
|
|
|
|
|
/* Set timer data */
|
|
|
|
mov al, 0
|
|
|
|
out 0x43, al
|
|
|
|
jmp $+2
|
|
|
|
|
|
|
|
/* Read current timer */
|
|
|
|
in al, 0x40
|
|
|
|
jmp $+2
|
|
|
|
movzx ecx, al
|
|
|
|
in al, 0x40
|
|
|
|
mov ch, al
|
|
|
|
|
|
|
|
/* Return it and restore interrupt state */
|
|
|
|
mov eax, ecx
|
|
|
|
popfq
|
|
|
|
ret
|
|
|
|
|
2010-02-04 04:58:09 +00:00
|
|
|
PUBLIC HalpClockInterrupt
|
|
|
|
HalpClockInterrupt:
|
2009-12-28 17:53:26 +00:00
|
|
|
UNIMPLEMENTED _HalpClockInterrupt
|
|
|
|
iret
|
2008-09-03 01:10:10 +00:00
|
|
|
|
2010-11-27 22:12:15 +00:00
|
|
|
END
|