probe.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. * Copyright 2003 Andi Kleen, SuSE Labs.
  3. * Subject to the GNU Public License, v.2
  4. *
  5. * Generic x86 APIC driver probe layer.
  6. */
  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 <linux/errno.h>
  14. #include <asm/fixmap.h>
  15. #include <asm/mpspec.h>
  16. #include <asm/apicdef.h>
  17. #include <asm/genapic.h>
  18. #include <asm/setup.h>
  19. extern struct genapic apic_numaq;
  20. extern struct genapic apic_summit;
  21. extern struct genapic apic_bigsmp;
  22. extern struct genapic apic_es7000;
  23. extern struct genapic apic_default;
  24. struct genapic *genapic = &apic_default;
  25. static struct genapic *apic_probe[] __initdata = {
  26. #ifdef CONFIG_X86_NUMAQ
  27. &apic_numaq,
  28. #endif
  29. #ifdef CONFIG_X86_SUMMIT
  30. &apic_summit,
  31. #endif
  32. #ifdef CONFIG_X86_BIGSMP
  33. &apic_bigsmp,
  34. #endif
  35. #ifdef CONFIG_X86_ES7000
  36. &apic_es7000,
  37. #endif
  38. &apic_default, /* must be last */
  39. NULL,
  40. };
  41. static int cmdline_apic __initdata;
  42. static int __init parse_apic(char *arg)
  43. {
  44. int i;
  45. if (!arg)
  46. return -EINVAL;
  47. for (i = 0; apic_probe[i]; i++) {
  48. if (!strcmp(apic_probe[i]->name, arg)) {
  49. genapic = apic_probe[i];
  50. cmdline_apic = 1;
  51. return 0;
  52. }
  53. }
  54. if (x86_quirks->update_genapic)
  55. x86_quirks->update_genapic();
  56. /* Parsed again by __setup for debug/verbose */
  57. return 0;
  58. }
  59. early_param("apic", parse_apic);
  60. void __init generic_bigsmp_probe(void)
  61. {
  62. #ifdef CONFIG_X86_BIGSMP
  63. /*
  64. * This routine is used to switch to bigsmp mode when
  65. * - There is no apic= option specified by the user
  66. * - generic_apic_probe() has chosen apic_default as the sub_arch
  67. * - we find more than 8 CPUs in acpi LAPIC listing with xAPIC support
  68. */
  69. if (!cmdline_apic && genapic == &apic_default) {
  70. if (apic_bigsmp.probe()) {
  71. genapic = &apic_bigsmp;
  72. if (x86_quirks->update_genapic)
  73. x86_quirks->update_genapic();
  74. printk(KERN_INFO "Overriding APIC driver with %s\n",
  75. genapic->name);
  76. }
  77. }
  78. #endif
  79. }
  80. void __init generic_apic_probe(void)
  81. {
  82. if (!cmdline_apic) {
  83. int i;
  84. for (i = 0; apic_probe[i]; i++) {
  85. if (apic_probe[i]->probe()) {
  86. genapic = apic_probe[i];
  87. break;
  88. }
  89. }
  90. /* Not visible without early console */
  91. if (!apic_probe[i])
  92. panic("Didn't find an APIC driver");
  93. if (x86_quirks->update_genapic)
  94. x86_quirks->update_genapic();
  95. }
  96. printk(KERN_INFO "Using APIC driver %s\n", genapic->name);
  97. }
  98. /* These functions can switch the APIC even after the initial ->probe() */
  99. int __init mps_oem_check(struct mp_config_table *mpc, char *oem,
  100. char *productid)
  101. {
  102. int i;
  103. for (i = 0; apic_probe[i]; ++i) {
  104. if (apic_probe[i]->mps_oem_check(mpc, oem, productid)) {
  105. if (!cmdline_apic) {
  106. genapic = apic_probe[i];
  107. if (x86_quirks->update_genapic)
  108. x86_quirks->update_genapic();
  109. printk(KERN_INFO "Switched to APIC driver `%s'.\n",
  110. genapic->name);
  111. }
  112. return 1;
  113. }
  114. }
  115. return 0;
  116. }
  117. int __init acpi_madt_oem_check(char *oem_id, char *oem_table_id)
  118. {
  119. int i;
  120. for (i = 0; apic_probe[i]; ++i) {
  121. if (apic_probe[i]->acpi_madt_oem_check(oem_id, oem_table_id)) {
  122. if (!cmdline_apic) {
  123. genapic = apic_probe[i];
  124. if (x86_quirks->update_genapic)
  125. x86_quirks->update_genapic();
  126. printk(KERN_INFO "Switched to APIC driver `%s'.\n",
  127. genapic->name);
  128. }
  129. return 1;
  130. }
  131. }
  132. return 0;
  133. }
  134. int hard_smp_processor_id(void)
  135. {
  136. return genapic->get_apic_id(*(unsigned long *)(APIC_BASE+APIC_ID));
  137. }