Hi Peter,
Only two sub-minor nits:
On Mon, 9 Jul 2007 19:52:01 -0700 "H. Peter Anvin" <[email protected]> wrote:
> From: H. Peter Anvin <[email protected]>
>
> Verify that the CPU has enough features to run the kernel. This may
> entail enabling features on some CPUs.
>
> By doing this in the setup code we can be guaranteed to still be able to
> write to the console through the BIOS.
>
> Signed-off-by: H. Peter Anvin <[email protected]>
> ---
> arch/i386/boot/cpu.c | 69 ++++++++++++
> arch/i386/boot/cpucheck.c | 267 +++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 336 insertions(+), 0 deletions(-)
> create mode 100644 arch/i386/boot/cpu.c
> create mode 100644 arch/i386/boot/cpucheck.c
>
> diff --git a/arch/i386/boot/cpu.c b/arch/i386/boot/cpu.c
> new file mode 100644
> index 0000000..042d894
> --- /dev/null
> +++ b/arch/i386/boot/cpu.c
> @@ -0,0 +1,69 @@
> +/* -*- linux-c -*- ------------------------------------------------------- *
> + *
> + * Copyright (C) 1991, 1992 Linus Torvalds
> + * Copyright 2007 rPath, Inc. - All Rights Reserved
> + *
> + * This file is part of the Linux kernel, and is made available under
> + * the terms of the GNU General Public License version 2.
> + *
> + * ----------------------------------------------------------------------- */
> +
> +/*
> + * arch/i386/boot/cpucheck.c
^^^^^
cpu.c ?
> + *
> + * Check for obligatory CPU features and abort if the features are not
> + * present.
> + */
> +
> +#include "boot.h"
> +#include "bitops.h"
> +#include <asm/cpufeature.h>
> +
> +static char *cpu_name(int level)
> +{
> + static char buf[6];
> +
> + if (level == 64) {
> + return "x86-64";
> + } else {
> + sprintf(buf, "i%d86", level);
> + return buf;
> + }
> +}
> +
> +int validate_cpu(void)
> +{
> + u32 *err_flags;
> + int cpu_level, req_level;
> +
> + check_cpu(&cpu_level, &req_level, &err_flags);
> +
> + if (cpu_level < req_level) {
> + printf("This kernel requires an %s CPU, ",
> + cpu_name(req_level));
> + printf("but only detected an %s CPU.\n",
> + cpu_name(cpu_level));
> + return -1;
> + }
> +
> + if (err_flags) {
> + int i, j;
> + puts("This kernel requires the following features "
> + "not present on the CPU:\n");
> +
> + for (i = 0; i < NCAPINTS; i++) {
> + u32 e = err_flags[i];
> +
> + for (j = 0; j < 32; j++) {
> + if (e & 1)
> + printf("%d:%d ", i, j);
> +
> + e >>= 1;
> + }
> + }
> + putchar('\n');
> + return -1;
> + } else {
> + return 0;
> + }
> +}
> diff --git a/arch/i386/boot/cpucheck.c b/arch/i386/boot/cpucheck.c
> new file mode 100644
> index 0000000..431bef8
> --- /dev/null
> +++ b/arch/i386/boot/cpucheck.c
> @@ -0,0 +1,267 @@
> +/* -*- linux-c -*- ------------------------------------------------------- *
> + *
> + * Copyright (C) 1991, 1992 Linus Torvalds
> + * Copyright 2007 rPath, Inc. - All Rights Reserved
> + *
> + * This file is part of the Linux kernel, and is made available under
> + * the terms of the GNU General Public License version 2.
> + *
> + * ----------------------------------------------------------------------- */
> +
> +/*
> + * arch/i386/boot/cpu.c
^^^^^
cpucheck.c ?
> + *
> + * Check for obligatory CPU features and abort if the features are not
> + * present. This code should be compilable as 16-, 32- or 64-bit
> + * code, so be very careful with types and inline assembly.
> + *
> + * This code should not contain any messages; that requires an
> + * additional wrapper.
> + *
Sébastien.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]