Adding upstream version 4.00~pre55+dfsg.
[syslinux-debian/hramrach.git] / core / idle.inc
blob9677c8228c50b113adc4ccb6b3677a4719eb4590
1 ;; -*- fundamental -*- ---------------------------------------------------
2 ;;
3 ;;   Copyright 2008 H. Peter Anvin - All Rights Reserved
4 ;;   Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin
5 ;;
6 ;;   This program is free software; you can redistribute it and/or modify
7 ;;   it under the terms of the GNU General Public License as published by
8 ;;   the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
9 ;;   Boston MA 02110-1301, USA; either version 2 of the License, or
10 ;;   (at your option) any later version; incorporated herein by reference.
12 ;; -----------------------------------------------------------------------
14                 section .text16
15 TICKS_TO_IDLE   equ 4           ; Also in idle.c
17 reset_idle:
18                 push eax
19                 mov eax,[cs:__jiffies]
20                 mov [cs:_IdleTimer],eax
21                 pop eax
22                 sti             ; Guard against BIOS/PXE brokenness...
23                 ret
25 do_idle:
26                 push eax
27                 push ds
28                 push es
29                 mov ax,cs
30                 mov ds,ax
31                 mov es,ax
32                 pushf
33                 pop ax
34                 test ah,2
35                 jnz .ok
36                 push si
37                 push cx
38                 mov si,hlt_err
39                 call writestr
40                 mov si,sp
41                 add si,10
42                 mov cx,16
43 .errloop:
44                 ss lodsw
45                 call writehex4
46                 dec cx
47                 jz .endloop
48                 mov al,' '
49                 call writechr
50                 jmp .errloop
51 .endloop:
52                 call crlf
53                 pop cx
54                 pop si
55                 sti
56 .ok:
57                 ; Don't spend time jumping to PM unless we're actually idle...
59                 mov eax,[__jiffies]
60                 sub eax,[_IdleTimer]
61                 cmp eax,TICKS_TO_IDLE
62                 jb .done
64                 extern __idle
65                 pm_call __idle
66 .done:
67                 pop es
68                 pop ds
69                 pop eax
70 .ret:           ret
72                 section .data16
73                 alignz 4
74                 global _IdleTimer
75 _IdleTimer      dd 0
76                 global NoHalt
77 NoHalt          dw 0
79 hlt_err         db 'ERROR: idle with IF=0', CR, LF, 0 
81                 section .text16