cpu.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* -*- linux-c -*- ------------------------------------------------------- *
  2. *
  3. * Copyright (C) 1991, 1992 Linus Torvalds
  4. * Copyright 2007 rPath, Inc. - All Rights Reserved
  5. *
  6. * This file is part of the Linux kernel, and is made available under
  7. * the terms of the GNU General Public License version 2.
  8. *
  9. * ----------------------------------------------------------------------- */
  10. /*
  11. * arch/i386/boot/cpu.c
  12. *
  13. * Check for obligatory CPU features and abort if the features are not
  14. * present.
  15. */
  16. #include "boot.h"
  17. #include "bitops.h"
  18. #include <asm/cpufeature.h>
  19. static char *cpu_name(int level)
  20. {
  21. static char buf[6];
  22. if (level == 64) {
  23. return "x86-64";
  24. } else {
  25. sprintf(buf, "i%d86", level);
  26. return buf;
  27. }
  28. }
  29. int validate_cpu(void)
  30. {
  31. u32 *err_flags;
  32. int cpu_level, req_level;
  33. check_cpu(&cpu_level, &req_level, &err_flags);
  34. if (cpu_level < req_level) {
  35. printf("This kernel requires an %s CPU, ",
  36. cpu_name(req_level));
  37. printf("but only detected an %s CPU.\n",
  38. cpu_name(cpu_level));
  39. return -1;
  40. }
  41. if (err_flags) {
  42. int i, j;
  43. puts("This kernel requires the following features "
  44. "not present on the CPU:\n");
  45. for (i = 0; i < NCAPINTS; i++) {
  46. u32 e = err_flags[i];
  47. for (j = 0; j < 32; j++) {
  48. if (e & 1)
  49. printf("%d:%d ", i, j);
  50. e >>= 1;
  51. }
  52. }
  53. putchar('\n');
  54. return -1;
  55. } else {
  56. return 0;
  57. }
  58. }