probe.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 <linux/errno.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 __initdata;
  30. static int __init parse_apic(char *arg)
  31. {
  32. int i;
  33. if (!arg)
  34. return -EINVAL;
  35. for (i = 0; apic_probe[i]; i++) {
  36. if (!strcmp(apic_probe[i]->name, arg)) {
  37. genapic = apic_probe[i];
  38. cmdline_apic = 1;
  39. return 0;
  40. }
  41. }
  42. /* Parsed again by __setup for debug/verbose */
  43. return 0;
  44. }
  45. early_param("apic", parse_apic);
  46. void __init generic_bigsmp_probe(void)
  47. {
  48. /*
  49. * This routine is used to switch to bigsmp mode when
  50. * - There is no apic= option specified by the user
  51. * - generic_apic_probe() has choosen apic_default as the sub_arch
  52. * - we find more than 8 CPUs in acpi LAPIC listing with xAPIC support
  53. */
  54. if (!cmdline_apic && genapic == &apic_default)
  55. if (apic_bigsmp.probe()) {
  56. genapic = &apic_bigsmp;
  57. printk(KERN_INFO "Overriding APIC driver with %s\n",
  58. genapic->name);
  59. }
  60. }
  61. void __init generic_apic_probe(void)
  62. {
  63. if (!cmdline_apic) {
  64. int i;
  65. for (i = 0; apic_probe[i]; i++) {
  66. if (apic_probe[i]->probe()) {
  67. genapic = apic_probe[i];
  68. break;
  69. }
  70. }
  71. /* Not visible without early console */
  72. if (!apic_probe[i])
  73. panic("Didn't find an APIC driver");
  74. }
  75. printk(KERN_INFO "Using APIC driver %s\n", genapic->name);
  76. }
  77. /* These functions can switch the APIC even after the initial ->probe() */
  78. int __init mps_oem_check(struct mp_config_table *mpc, char *oem, char *productid)
  79. {
  80. int i;
  81. for (i = 0; apic_probe[i]; ++i) {
  82. if (apic_probe[i]->mps_oem_check(mpc,oem,productid)) {
  83. if (!cmdline_apic) {
  84. genapic = apic_probe[i];
  85. printk(KERN_INFO "Switched to APIC driver `%s'.\n",
  86. genapic->name);
  87. }
  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. if (!cmdline_apic) {
  99. genapic = apic_probe[i];
  100. printk(KERN_INFO "Switched to APIC driver `%s'.\n",
  101. genapic->name);
  102. }
  103. return 1;
  104. }
  105. }
  106. return 0;
  107. }
  108. int hard_smp_processor_id(void)
  109. {
  110. return genapic->get_apic_id(*(unsigned long *)(APIC_BASE+APIC_ID));
  111. }