smp_32.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. #ifdef CONFIG_SMP
  20. /*
  21. * This function is needed by all SMP systems. It must _always_ be valid
  22. * from the initial startup. We map APIC_BASE very early in page_setup(),
  23. * so this is correct in the x86 case.
  24. */
  25. DECLARE_PER_CPU(int, cpu_number);
  26. #define raw_smp_processor_id() (x86_read_percpu(cpu_number))
  27. extern int safe_smp_processor_id(void);
  28. /* We don't mark CPUs online until __cpu_up(), so we need another measure */
  29. static inline int num_booting_cpus(void)
  30. {
  31. return cpus_weight(cpu_callout_map);
  32. }
  33. #else /* CONFIG_SMP */
  34. #define safe_smp_processor_id() 0
  35. #endif /* !CONFIG_SMP */
  36. #ifdef CONFIG_X86_LOCAL_APIC
  37. static inline int logical_smp_processor_id(void)
  38. {
  39. /* we don't want to mark this access volatile - bad code generation */
  40. return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR));
  41. }
  42. # ifdef APIC_DEFINITION
  43. extern int hard_smp_processor_id(void);
  44. # else
  45. # include <mach_apicdef.h>
  46. static inline int hard_smp_processor_id(void)
  47. {
  48. /* we don't want to mark this access volatile - bad code generation */
  49. return GET_APIC_ID(*(u32 *)(APIC_BASE + APIC_ID));
  50. }
  51. # endif /* APIC_DEFINITION */
  52. #else /* CONFIG_X86_LOCAL_APIC */
  53. # ifndef CONFIG_SMP
  54. # define hard_smp_processor_id() 0
  55. # endif
  56. #endif /* CONFIG_X86_LOCAL_APIC */
  57. #endif /* !ASSEMBLY */
  58. #endif