aboutsummaryrefslogtreecommitdiffstats
path: root/core/idle.inc
blob: c2ce1348da1d546f82a08882a7ee24e2d48c0556 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
;; -*- fundamental -*- ---------------------------------------------------
;;
;;   Copyright 2008 H. Peter Anvin - All Rights Reserved
;;   Copyright 2009 Intel Corporation; author: H. Peter Anvin
;;
;;   This program is free software; you can redistribute it and/or modify
;;   it under the terms of the GNU General Public License as published by
;;   the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
;;   Boston MA 02110-1301, USA; either version 2 of the License, or
;;   (at your option) any later version; incorporated herein by reference.
;;
;; -----------------------------------------------------------------------

		section .text
TICKS_TO_IDLE	equ 4

reset_idle:
		push ax
		mov ax,[cs:BIOS_timer]
		mov [cs:IdleTimer],ax
		pop ax
		ret

do_idle:
		push ax
		push ds
		push es
		mov ax,cs
		mov ds,ax
		mov es,ax
		mov ax,[BIOS_timer]
		sub ax,[IdleTimer]
		cmp ax,TICKS_TO_IDLE
		jb .done
		call [IdleHook]
		cmp word [NoHalt],0
		jne .done
		hlt
.done:
		pop es
		pop ds
		pop ax
.ret:		ret

		section .data
NoHalt		dw 0
IdleHook	dw do_idle.ret

		section .bss
IdleTimer	resw 1