smp.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #ifndef __ASM_SMP_H
  2. #define __ASM_SMP_H
  3. /*
  4. * We need the APIC definitions automatically as part of 'smp.h'
  5. */
  6. #ifndef __ASSEMBLY__
  7. #include <linux/config.h>
  8. #include <linux/kernel.h>
  9. #include <linux/threads.h>
  10. #include <linux/cpumask.h>
  11. #endif
  12. #ifdef CONFIG_X86_LOCAL_APIC
  13. #ifndef __ASSEMBLY__
  14. #include <asm/fixmap.h>
  15. #include <asm/bitops.h>
  16. #include <asm/mpspec.h>
  17. #ifdef CONFIG_X86_IO_APIC
  18. #include <asm/io_apic.h>
  19. #endif
  20. #include <asm/apic.h>
  21. #endif
  22. #endif
  23. #define BAD_APICID 0xFFu
  24. #ifdef CONFIG_SMP
  25. #ifndef __ASSEMBLY__
  26. /*
  27. * Private routines/data
  28. */
  29. extern void smp_alloc_memory(void);
  30. extern int pic_mode;
  31. extern int smp_num_siblings;
  32. extern cpumask_t cpu_sibling_map[];
  33. extern cpumask_t cpu_core_map[];
  34. extern void smp_flush_tlb(void);
  35. extern void smp_message_irq(int cpl, void *dev_id, struct pt_regs *regs);
  36. extern void smp_invalidate_rcv(void); /* Process an NMI */
  37. extern void (*mtrr_hook) (void);
  38. extern void zap_low_mappings (void);
  39. #define MAX_APICID 256
  40. extern u8 x86_cpu_to_apicid[];
  41. /*
  42. * This function is needed by all SMP systems. It must _always_ be valid
  43. * from the initial startup. We map APIC_BASE very early in page_setup(),
  44. * so this is correct in the x86 case.
  45. */
  46. #define raw_smp_processor_id() (current_thread_info()->cpu)
  47. extern cpumask_t cpu_callout_map;
  48. extern cpumask_t cpu_callin_map;
  49. #define cpu_possible_map cpu_callout_map
  50. /* We don't mark CPUs online until __cpu_up(), so we need another measure */
  51. static inline int num_booting_cpus(void)
  52. {
  53. return cpus_weight(cpu_callout_map);
  54. }
  55. #ifdef CONFIG_X86_LOCAL_APIC
  56. #ifdef APIC_DEFINITION
  57. extern int hard_smp_processor_id(void);
  58. #else
  59. #include <mach_apicdef.h>
  60. static inline int hard_smp_processor_id(void)
  61. {
  62. /* we don't want to mark this access volatile - bad code generation */
  63. return GET_APIC_ID(*(unsigned long *)(APIC_BASE+APIC_ID));
  64. }
  65. #endif
  66. static __inline int logical_smp_processor_id(void)
  67. {
  68. /* we don't want to mark this access volatile - bad code generation */
  69. return GET_APIC_LOGICAL_ID(*(unsigned long *)(APIC_BASE+APIC_LDR));
  70. }
  71. #endif
  72. #endif /* !__ASSEMBLY__ */
  73. #define NO_PROC_ID 0xFF /* No processor magic marker */
  74. #endif
  75. #endif