[syslinux:elflink] idle: Consolidate idle implementations

syslinux-bot for Matt Fleming matt.fleming at intel.com
Wed Jul 3 14:36:04 PDT 2013


Commit-ID:  bfd6b76bec6f2eadd48be2632dd96518bba66d40
Gitweb:     http://www.syslinux.org/commit/bfd6b76bec6f2eadd48be2632dd96518bba66d40
Author:     Matt Fleming <matt.fleming at intel.com>
AuthorDate: Tue, 2 Jul 2013 14:51:26 +0100
Committer:  Matt Fleming <matt.fleming at intel.com>
CommitDate: Wed, 3 Jul 2013 22:21:07 +0100

idle: Consolidate idle implementations

Duplicate code is bad. Move all the idle code to C and delete the old
assembly stuff.

Signed-off-by: Matt Fleming <matt.fleming at intel.com>

---
 core/comboot.inc  |  3 ++-
 core/common.inc   |  1 -
 core/conio.c      |  4 +---
 core/idle.c       |  2 +-
 core/idle.inc     | 72 -------------------------------------------------------
 core/pxelinux.asm |  2 +-
 6 files changed, 5 insertions(+), 79 deletions(-)

diff --git a/core/comboot.inc b/core/comboot.inc
index e5afbe2..f6270a8 100644
--- a/core/comboot.inc
+++ b/core/comboot.inc
@@ -294,7 +294,8 @@ comboot_getchar:
 comboot_int28:
 		sti
 		cld
-		call do_idle
+		extern __idle
+		pm_call __idle
 		iret
 
 ;
diff --git a/core/common.inc b/core/common.inc
index 65b4ab6..fd75dfe 100644
--- a/core/common.inc
+++ b/core/common.inc
@@ -7,7 +7,6 @@
 %include "pm.inc"		; Protected mode
 %include "bcopy32.inc"		; 32-bit bcopy
 %include "strcpy.inc"           ; strcpy()
-%include "idle.inc"		; Idle handling
 %include "adv.inc"		; Auxillary Data Vector
 %include "timer.inc"		; Timer handling
 
diff --git a/core/conio.c b/core/conio.c
index 3d59485..d342833 100644
--- a/core/conio.c
+++ b/core/conio.c
@@ -190,8 +190,6 @@ void pm_pollchar(com32sys_t *regs)
 		regs->eflags.l |= EFLAGS_ZF;
 }
 
-extern void do_idle(void);
-
 /*
  * getchar: Read a character from keyboard or serial port
  */
@@ -203,7 +201,7 @@ __export char getchar(char *hi)
 	memset(&ireg, 0, sizeof(ireg));
 	memset(&oreg, 0, sizeof(oreg));
 	while (1) {
-		call16(do_idle, &zero_regs, NULL);
+		__idle();
 
 		ireg.eax.b[1] = 0x11;	/* Poll keyboard */
 		__intcall(0x16, &ireg, &oreg);
diff --git a/core/idle.c b/core/idle.c
index 16d10d5..c805055 100644
--- a/core/idle.c
+++ b/core/idle.c
@@ -24,7 +24,7 @@
 
 #define TICKS_TO_IDLE	4	/* Also in idle.inc */
 
-extern jiffies_t _IdleTimer;
+static jiffies_t _IdleTimer;
 __export uint16_t NoHalt = 0;
 
 int (*idle_hook_func)(void);
diff --git a/core/idle.inc b/core/idle.inc
deleted file mode 100644
index c5ac7ef..0000000
--- a/core/idle.inc
+++ /dev/null
@@ -1,72 +0,0 @@
-;; -*- fundamental -*- ---------------------------------------------------
-;;
-;;   Copyright 2008 H. Peter Anvin - All Rights Reserved
-;;   Copyright 2009-2010 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 .text16
-TICKS_TO_IDLE	equ 4		; Also in idle.c
-
-		global do_idle:function hidden
-do_idle:
-		push eax
-		push ds
-		push es
-		mov ax,cs
-		mov ds,ax
-		mov es,ax
-		pushf
-		pop ax
-		test ah,2
-		jnz .ok
-		push si
-		push cx
-		mov si,hlt_err
-		pm_call pm_writestr
-		mov si,sp
-		add si,10
-		mov cx,16
-.errloop:
-		ss lodsw
-		pm_call pm_writehex4
-		dec cx
-		jz .endloop
-		mov al,' '
-		pm_call pm_writechr
-		jmp .errloop
-.endloop:
-		pm_call crlf
-		pop cx
-		pop si
-		sti
-.ok:
-		; Don't spend time jumping to PM unless we're actually idle...
-
-		mov eax,[__jiffies]
-		sub eax,[_IdleTimer]
-		cmp eax,TICKS_TO_IDLE
-		jb .done
-
-		extern __idle
-		pm_call __idle
-.done:
-		pop es
-		pop ds
-		pop eax
-.ret:		ret
-
-		section .data16
-		alignz 4
-		global _IdleTimer:data hidden
-_IdleTimer	dd 0
-
-hlt_err		db 'ERROR: idle with IF=0', CR, LF, 0 
-
-		section .text16
diff --git a/core/pxelinux.asm b/core/pxelinux.asm
index 414078a..9d7156c 100644
--- a/core/pxelinux.asm
+++ b/core/pxelinux.asm
@@ -341,7 +341,7 @@ kaboom:
 .wait2:		mov dx,[BIOS_timer]
 .wait3:		call pollchar
 		jnz .keypress
-		call do_idle
+		pm_call __idle
 		cmp dx,[BIOS_timer]
 		je .wait3
 		loop .wait2,ecx


More information about the Syslinux-commits mailing list