probe.c 2.9 KB

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