probe.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. void __init generic_apic_probe(char *command_line)
  30. {
  31. char *s;
  32. int i;
  33. int changed = 0;
  34. s = strstr(command_line, "apic=");
  35. if (s && (s == command_line || isspace(s[-1]))) {
  36. char *p = strchr(s, ' '), old;
  37. if (!p)
  38. p = strchr(s, '\0');
  39. old = *p;
  40. *p = 0;
  41. for (i = 0; !changed && apic_probe[i]; i++) {
  42. if (!strcmp(apic_probe[i]->name, s+5)) {
  43. changed = 1;
  44. genapic = apic_probe[i];
  45. }
  46. }
  47. if (!changed)
  48. printk(KERN_ERR "Unknown genapic `%s' specified.\n", s);
  49. *p = old;
  50. }
  51. for (i = 0; !changed && apic_probe[i]; i++) {
  52. if (apic_probe[i]->probe()) {
  53. changed = 1;
  54. genapic = apic_probe[i];
  55. }
  56. }
  57. /* Not visible without early console */
  58. if (!changed)
  59. panic("Didn't find an APIC driver");
  60. printk(KERN_INFO "Using APIC driver %s\n", genapic->name);
  61. }
  62. /* These functions can switch the APIC even after the initial ->probe() */
  63. int __init mps_oem_check(struct mp_config_table *mpc, char *oem, char *productid)
  64. {
  65. int i;
  66. for (i = 0; apic_probe[i]; ++i) {
  67. if (apic_probe[i]->mps_oem_check(mpc,oem,productid)) {
  68. genapic = apic_probe[i];
  69. printk(KERN_INFO "Switched to APIC driver `%s'.\n",
  70. genapic->name);
  71. return 1;
  72. }
  73. }
  74. return 0;
  75. }
  76. int __init acpi_madt_oem_check(char *oem_id, char *oem_table_id)
  77. {
  78. int i;
  79. for (i = 0; apic_probe[i]; ++i) {
  80. if (apic_probe[i]->acpi_madt_oem_check(oem_id, oem_table_id)) {
  81. genapic = apic_probe[i];
  82. printk(KERN_INFO "Switched to APIC driver `%s'.\n",
  83. genapic->name);
  84. return 1;
  85. }
  86. }
  87. return 0;
  88. }
  89. int hard_smp_processor_id(void)
  90. {
  91. return genapic->get_apic_id(*(unsigned long *)(APIC_BASE+APIC_ID));
  92. }