smp_32.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #ifndef __ASM_SMP_H
  2. #define __ASM_SMP_H
  3. #ifndef __ASSEMBLY__
  4. #include <linux/cpumask.h>
  5. #include <linux/init.h>
  6. /*
  7. * We need the APIC definitions automatically as part of 'smp.h'
  8. */
  9. #ifdef CONFIG_X86_LOCAL_APIC
  10. # include <asm/mpspec.h>
  11. # include <asm/apic.h>
  12. # ifdef CONFIG_X86_IO_APIC
  13. # include <asm/io_apic.h>
  14. # endif
  15. #endif
  16. extern cpumask_t cpu_callin_map;
  17. extern void (*mtrr_hook) (void);
  18. extern void zap_low_mappings (void);
  19. extern u16 __initdata x86_cpu_to_apicid_init[];
  20. extern void *x86_cpu_to_apicid_early_ptr;
  21. DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
  22. DECLARE_PER_CPU(cpumask_t, cpu_core_map);
  23. DECLARE_PER_CPU(u16, cpu_llc_id);
  24. DECLARE_PER_CPU(u16, x86_cpu_to_apicid);
  25. #ifdef CONFIG_SMP
  26. /*
  27. * This function is needed by all SMP systems. It must _always_ be valid
  28. * from the initial startup. We map APIC_BASE very early in page_setup(),
  29. * so this is correct in the x86 case.
  30. */
  31. DECLARE_PER_CPU(int, cpu_number);
  32. #define raw_smp_processor_id() (x86_read_percpu(cpu_number))
  33. #define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
  34. extern int safe_smp_processor_id(void);
  35. /* We don't mark CPUs online until __cpu_up(), so we need another measure */
  36. static inline int num_booting_cpus(void)
  37. {
  38. return cpus_weight(cpu_callout_map);
  39. }
  40. #else /* CONFIG_SMP */
  41. #define safe_smp_processor_id() 0
  42. #define cpu_physical_id(cpu) boot_cpu_physical_apicid
  43. #endif /* !CONFIG_SMP */
  44. #ifdef CONFIG_X86_LOCAL_APIC
  45. static __inline int logical_smp_processor_id(void)
  46. {
  47. /* we don't want to mark this access volatile - bad code generation */
  48. return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR));
  49. }
  50. # ifdef APIC_DEFINITION
  51. extern int hard_smp_processor_id(void);
  52. # else
  53. # include <mach_apicdef.h>
  54. static inline int hard_smp_processor_id(void)
  55. {
  56. /* we don't want to mark this access volatile - bad code generation */
  57. return GET_APIC_ID(*(u32 *)(APIC_BASE + APIC_ID));
  58. }
  59. # endif /* APIC_DEFINITION */
  60. #else /* CONFIG_X86_LOCAL_APIC */
  61. # ifndef CONFIG_SMP
  62. # define hard_smp_processor_id() 0
  63. # endif
  64. #endif /* CONFIG_X86_LOCAL_APIC */
  65. #endif /* !ASSEMBLY */
  66. #endif