From 50cdf3827dff1cdf97fab81361b91905676ff7bc Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Thu, 12 Jul 2007 13:01:42 +0000 Subject: [PATCH] Merge hlt() into cpu.h where it belongs. Add some documentation. Signed-off-by: Uwe Hermann Acked-by: Peter Stuge git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@449 f3766cd6-281f-0410-b1cd-43a5c92072e9 --- arch/x86/geodelx/geodelx.c | 2 +- include/arch/x86/cpu.h | 14 +++++++++++++- include/arch/x86/hlt.h | 29 ----------------------------- lib/console.c | 6 ++---- lib/ram.c | 2 +- northbridge/amd/geodelx/raminit.c | 2 +- 6 files changed, 18 insertions(+), 37 deletions(-) delete mode 100644 include/arch/x86/hlt.h diff --git a/arch/x86/geodelx/geodelx.c b/arch/x86/geodelx/geodelx.c index a8b6c82fd8..f9c9f42e52 100644 --- a/arch/x86/geodelx/geodelx.c +++ b/arch/x86/geodelx/geodelx.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/arch/x86/cpu.h b/include/arch/x86/cpu.h index 556a8580ce..a2e93b5829 100644 --- a/include/arch/x86/cpu.h +++ b/include/arch/x86/cpu.h @@ -181,7 +181,19 @@ static inline void disable_cache(void) */ static inline void cpu_relax(void) { - __asm__ __volatile__("rep;nop" : : : "memory"); + __asm__ __volatile__("rep; nop" : : : "memory"); +} + +/** + * Shut down the CPU. + * + * This function is '__attribute__((always_inline))' because it might be + * called before RAM is set up, thus pushing stuff on stack (for a function + * call) will not work. + */ +static inline __attribute__((always_inline)) void hlt(void) +{ + __asm__ __volatile__("hlt" : : : "memory"); } /* Random other functions. These are not architecture-specific, except they diff --git a/include/arch/x86/hlt.h b/include/arch/x86/hlt.h deleted file mode 100644 index 7fa813fac6..0000000000 --- a/include/arch/x86/hlt.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * This file is part of the LinuxBIOS project. - * - * Copyright (C) 2007 Stefan Reinauer - * - * 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; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef ARCH_X86_HLT_H -#define ARCH_X86_HLT_H - -static inline __attribute__((always_inline)) void hlt(void) -{ - asm("hlt"); -} - -#endif /* ARCH_X86_HLT_H */ diff --git a/lib/console.c b/lib/console.c index ecb60b145c..bd44faf4c1 100644 --- a/lib/console.c +++ b/lib/console.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -57,13 +57,11 @@ void console_init(void) " starting...\n"; printk(BIOS_INFO, console_test); - } void die(const char *str) { printk(BIOS_EMERG, str); - do { + while (1) hlt(); - } while (1); } diff --git a/lib/ram.c b/lib/ram.c index 0f973fd68e..e3eb03d3c4 100644 --- a/lib/ram.c +++ b/lib/ram.c @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include +#include #include /** diff --git a/northbridge/amd/geodelx/raminit.c b/northbridge/amd/geodelx/raminit.c index 64fd431676..41fb5bc26b 100644 --- a/northbridge/amd/geodelx/raminit.c +++ b/northbridge/amd/geodelx/raminit.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include