probe.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /* Copyright 2003 Andi Kleen, SuSE Labs.
  2. * Subject to the GNU Public License, v.2
  3. *
  4. * Generic x86 APIC driver probe layer.
  5. */
  6. #include <linux/config.h>
  7. #include <linux/threads.h>
  8. #include <linux/cpumask.h>
  9. #include <linux/string.h>
  10. #include <linux/kernel.h>
  11. #include <linux/ctype.h>
  12. #include <linux/init.h>
  13. #include <asm/fixmap.h>
  14. #include <asm/mpspec.h>
  15. #include <asm/apicdef.h>
  16. #include <asm/genapic.h>
  17. extern struct genapic apic_summit;
  18. extern struct genapic apic_bigsmp;
  19. extern struct genapic apic_es7000;
  20. extern struct genapic apic_default;
  21. struct genapic *genapic = &apic_default;
  22. struct genapic *apic_probe[] __initdata = {
  23. &apic_summit,
  24. &apic_bigsmp,
  25. &apic_es7000,
  26. &apic_default, /* must be last */
  27. NULL,
  28. };
  29. static int cmdline_apic;
  30. void __init generic_bigsmp_probe(void)
  31. {
  32. /*
  33. * This routine is used to switch to bigsmp mode when
  34. * - There is no apic= option specified by the user
  35. * - generic_apic_probe() has choosen apic_default as the sub_arch
  36. * - we find more than 8 CPUs in acpi LAPIC listing with xAPIC support
  37. */
  38. if (!cmdline_apic && genapic == &apic_default)
  39. if (apic_bigsmp.probe()) {
  40. genapic = &apic_bigsmp;
  41. printk(KERN_INFO "Overriding APIC driver with %s\n",
  42. genapic->name);
  43. }
  44. }
  45. void __init generic_apic_probe(char *command_line)
  46. {
  47. char *s;
  48. int i;
  49. int changed = 0;
  50. s = strstr(command_line, "apic=");
  51. if (s && (s == command_line || isspace(s[-1]))) {
  52. char *p = strchr(s, ' '), old;
  53. if (!p)
  54. p = strchr(s, '\0');
  55. old = *p;
  56. *p = 0;
  57. for (i = 0; !changed && apic_probe[i]; i++) {
  58. if (!strcmp(apic_probe[i]->name, s+5)) {
  59. changed = 1;
  60. genapic = apic_probe[i];
  61. }
  62. }
  63. if (!changed)
  64. printk(KERN_ERR "Unknown genapic `%s' specified.\n", s);
  65. *p = old;
  66. cmdline_apic = changed;
  67. }
  68. for (i = 0; !changed && apic_probe[i]; i++) {
  69. if (apic_probe[i]->probe()) {
  70. changed = 1;
  71. genapic = apic_probe[i];
  72. }
  73. }
  74. /* Not visible without early console */
  75. if (!changed)
  76. panic("Didn't find an APIC driver");
  77. printk(KERN_INFO "Using APIC driver %s\n", genapic->name);
  78. }
  79. /* These functions can switch the APIC even after the initial ->probe() */
  80. int __init mps_oem_check(struct mp_config_table *mpc, char *oem, char *productid)
  81. {
  82. int i;
  83. for (i = 0; apic_probe[i]; ++i) {
  84. if (apic_probe[i]->mps_oem_check(mpc,oem,productid)) {
  85. genapic = apic_probe[i];
  86. printk(KERN_INFO "Switched to APIC driver `%s'.\n",
  87. genapic->name);
  88. return 1;
  89. }
  90. }
  91. return 0;
  92. }
  93. int __init acpi_madt_oem_check(char *oem_id, char *oem_table_id)
  94. {
  95. int i;
  96. for (i = 0; apic_probe[i]; ++i) {
  97. if (apic_probe[i]->acpi_madt_oem_check(oem_id, oem_table_id)) {
  98. genapic = apic_probe[i];
  99. printk(KERN_INFO "Switched to APIC driver `%s'.\n",
  100. genapic->name);
  101. return 1;
  102. }
  103. }
  104. return 0;
  105. }
  106. int hard_smp_processor_id(void)
  107. {
  108. return genapic->get_apic_id(*(unsigned long *)(APIC_BASE+APIC_ID));
  109. }