genapic_64.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 <asm/smp.h>
  19. #include <asm/ipi.h>
  20. #include <asm/genapic.h>
  21. #ifdef CONFIG_ACPI
  22. #include <acpi/acpi_bus.h>
  23. #endif
  24. /*
  25. * which logical CPU number maps to which CPU (physical APIC ID)
  26. *
  27. * The following static array is used during kernel startup
  28. * and the x86_cpu_to_apicid_ptr contains the address of the
  29. * array during this time. Is it zeroed when the per_cpu
  30. * data area is removed.
  31. */
  32. u8 x86_cpu_to_apicid_init[NR_CPUS] __initdata
  33. = { [0 ... NR_CPUS-1] = BAD_APICID };
  34. void *x86_cpu_to_apicid_ptr;
  35. DEFINE_PER_CPU(u8, x86_cpu_to_apicid) = BAD_APICID;
  36. EXPORT_PER_CPU_SYMBOL(x86_cpu_to_apicid);
  37. struct genapic __read_mostly *genapic = &apic_flat;
  38. /*
  39. * Check the APIC IDs in bios_cpu_apicid and choose the APIC mode.
  40. */
  41. void __init setup_apic_routing(void)
  42. {
  43. #ifdef CONFIG_ACPI
  44. /*
  45. * Quirk: some x86_64 machines can only use physical APIC mode
  46. * regardless of how many processors are present (x86_64 ES7000
  47. * is an example).
  48. */
  49. if (acpi_gbl_FADT.header.revision > FADT2_REVISION_ID &&
  50. (acpi_gbl_FADT.flags & ACPI_FADT_APIC_PHYSICAL))
  51. genapic = &apic_physflat;
  52. else
  53. #endif
  54. if (cpus_weight(cpu_possible_map) <= 8)
  55. genapic = &apic_flat;
  56. else
  57. genapic = &apic_physflat;
  58. printk(KERN_INFO "Setting APIC routing to %s\n", genapic->name);
  59. }
  60. /* Same for both flat and physical. */
  61. void send_IPI_self(int vector)
  62. {
  63. __send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL);
  64. }