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. return -ENOENT;
  43. }
  44. early_param("apic", parse_apic);
  45. void __init generic_bigsmp_probe(void)
  46. {
  47. /*
  48. * This routine is used to switch to bigsmp mode when
  49. * - There is no apic= option specified by the user
  50. * - generic_apic_probe() has choosen apic_default as the sub_arch
  51. * - we find more than 8 CPUs in acpi LAPIC listing with xAPIC support
  52. */
  53. if (!cmdline_apic && genapic == &apic_default)
  54. if (apic_bigsmp.probe()) {
  55. genapic = &apic_bigsmp;
  56. printk(KERN_INFO "Overriding APIC driver with %s\n",
  57. genapic->name);
  58. }
  59. }
  60. void __init generic_apic_probe(void)
  61. {
  62. if (!cmdline_apic) {
  63. int i;
  64. for (i = 0; apic_probe[i]; i++) {
  65. if (apic_probe[i]->probe()) {
  66. genapic = apic_probe[i];
  67. break;
  68. }
  69. }
  70. /* Not visible without early console */
  71. if (!apic_probe[i])
  72. panic("Didn't find an APIC driver");
  73. }
  74. printk(KERN_INFO "Using APIC driver %s\n", genapic->name);
  75. }
  76. /* These functions can switch the APIC even after the initial ->probe() */
  77. int __init mps_oem_check(struct mp_config_table *mpc, char *oem, char *productid)
  78. {
  79. int i;
  80. for (i = 0; apic_probe[i]; ++i) {
  81. if (apic_probe[i]->mps_oem_check(mpc,oem,productid)) {
  82. if (!cmdline_apic) {
  83. genapic = apic_probe[i];
  84. printk(KERN_INFO "Switched to APIC driver `%s'.\n",
  85. genapic->name);
  86. }
  87. return 1;
  88. }
  89. }
  90. return 0;
  91. }
  92. int __init acpi_madt_oem_check(char *oem_id, char *oem_table_id)
  93. {
  94. int i;
  95. for (i = 0; apic_probe[i]; ++i) {
  96. if (apic_probe[i]->acpi_madt_oem_check(oem_id, oem_table_id)) {
  97. if (!cmdline_apic) {
  98. genapic = apic_probe[i];
  99. printk(KERN_INFO "Switched to APIC driver `%s'.\n",
  100. genapic->name);
  101. }
  102. return 1;
  103. }
  104. }
  105. return 0;
  106. }
  107. #ifdef CONFIG_SMP
  108. int hard_smp_processor_id(void)
  109. {
  110. return genapic->get_apic_id(*(unsigned long *)(APIC_BASE+APIC_ID));
  111. }
  112. #endif