genapic_64.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright 2004 James Cleverdon, IBM.
  3. * Subject to the GNU Public License, v.2
  4. *
  5. * Generic APIC sub-arch probe layer.
  6. *
  7. * Hacked for x86-64 by James Cleverdon from i386 architecture code by
  8. * Martin Bligh, Andi Kleen, James Bottomley, John Stultz, and
  9. * James Cleverdon.
  10. */
  11. #include <linux/threads.h>
  12. #include <linux/cpumask.h>
  13. #include <linux/string.h>
  14. #include <linux/module.h>
  15. #include <linux/kernel.h>
  16. #include <linux/ctype.h>
  17. #include <linux/init.h>
  18. #include <linux/hardirq.h>
  19. #include <asm/smp.h>
  20. #include <asm/ipi.h>
  21. #include <asm/genapic.h>
  22. #ifdef CONFIG_ACPI
  23. #include <acpi/acpi_bus.h>
  24. #endif
  25. DEFINE_PER_CPU(int, x2apic_extra_bits);
  26. struct genapic __read_mostly *genapic = &apic_flat;
  27. static enum uv_system_type uv_system_type;
  28. /*
  29. * Check the APIC IDs in bios_cpu_apicid and choose the APIC mode.
  30. */
  31. void __init setup_apic_routing(void)
  32. {
  33. if (uv_system_type == UV_NON_UNIQUE_APIC)
  34. genapic = &apic_x2apic_uv_x;
  35. else if (cpu_has_x2apic && intr_remapping_enabled)
  36. genapic = &apic_x2apic_cluster;
  37. else
  38. #ifdef CONFIG_ACPI
  39. /*
  40. * Quirk: some x86_64 machines can only use physical APIC mode
  41. * regardless of how many processors are present (x86_64 ES7000
  42. * is an example).
  43. */
  44. if (acpi_gbl_FADT.header.revision > FADT2_REVISION_ID &&
  45. (acpi_gbl_FADT.flags & ACPI_FADT_APIC_PHYSICAL))
  46. genapic = &apic_physflat;
  47. else
  48. #endif
  49. if (max_physical_apicid < 8)
  50. genapic = &apic_flat;
  51. else
  52. genapic = &apic_physflat;
  53. printk(KERN_INFO "Setting APIC routing to %s\n", genapic->name);
  54. }
  55. /* Same for both flat and physical. */
  56. void apic_send_IPI_self(int vector)
  57. {
  58. __send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL);
  59. }
  60. int __init acpi_madt_oem_check(char *oem_id, char *oem_table_id)
  61. {
  62. if (!strcmp(oem_id, "SGI")) {
  63. if (!strcmp(oem_table_id, "UVL"))
  64. uv_system_type = UV_LEGACY_APIC;
  65. else if (!strcmp(oem_table_id, "UVX"))
  66. uv_system_type = UV_X2APIC;
  67. else if (!strcmp(oem_table_id, "UVH"))
  68. uv_system_type = UV_NON_UNIQUE_APIC;
  69. }
  70. return 0;
  71. }
  72. enum uv_system_type get_uv_system_type(void)
  73. {
  74. return uv_system_type;
  75. }
  76. int is_uv_system(void)
  77. {
  78. return uv_system_type != UV_NONE;
  79. }