]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - arch/x86/include/asm/bigsmp/apic.h
1 #ifndef __ASM_MACH_APIC_H
2 #define __ASM_MACH_APIC_H
4 #define xapic_phys_to_log_apicid(cpu) (per_cpu(x86_bios_cpu_apicid, cpu))
6 static inline int bigsmp_apic_id_registered(void)
11 static inline const cpumask_t
*bigsmp_target_cpus(void)
14 return &cpu_online_map
;
16 return &cpumask_of_cpu(0);
20 #define APIC_DFR_VALUE (APIC_DFR_FLAT)
22 static inline unsigned long
23 bigsmp_check_apicid_used(physid_mask_t bitmap
, int apicid
)
28 static inline unsigned long bigsmp_check_apicid_present(int bit
)
33 static inline unsigned long calculate_ldr(int cpu
)
35 unsigned long val
, id
;
36 val
= apic_read(APIC_LDR
) & ~APIC_LDR_MASK
;
37 id
= xapic_phys_to_log_apicid(cpu
);
38 val
|= SET_APIC_LOGICAL_ID(id
);
43 * Set up the logical destination ID.
45 * Intel recommends to set DFR, LDR and TPR before enabling
46 * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel
47 * document number 292116). So here it goes...
49 static inline void bigsmp_init_apic_ldr(void)
52 int cpu
= smp_processor_id();
54 apic_write(APIC_DFR
, APIC_DFR_VALUE
);
55 val
= calculate_ldr(cpu
);
56 apic_write(APIC_LDR
, val
);
59 static inline void bigsmp_setup_apic_routing(void)
61 printk("Enabling APIC mode: %s. Using %d I/O APICs\n",
62 "Physflat", nr_ioapics
);
65 static inline int bigsmp_apicid_to_node(int logical_apicid
)
67 return apicid_2_node
[hard_smp_processor_id()];
70 static inline int bigsmp_cpu_present_to_apicid(int mps_cpu
)
72 if (mps_cpu
< nr_cpu_ids
)
73 return (int) per_cpu(x86_bios_cpu_apicid
, mps_cpu
);
78 static inline physid_mask_t
bigsmp_apicid_to_cpu_present(int phys_apicid
)
80 return physid_mask_of_physid(phys_apicid
);
83 extern u8 cpu_2_logical_apicid
[];
84 /* Mapping from cpu number to logical apicid */
85 static inline int bigsmp_cpu_to_logical_apicid(int cpu
)
87 if (cpu
>= nr_cpu_ids
)
89 return cpu_physical_id(cpu
);
92 static inline physid_mask_t
bigsmp_ioapic_phys_id_map(physid_mask_t phys_map
)
94 /* For clustered we don't have a good way to do this yet - hack */
95 return physids_promote(0xFFL
);
98 static inline void bigsmp_setup_portio_remap(void)
102 static inline int bigsmp_check_phys_apicid_present(int boot_cpu_physical_apicid
)
107 /* As we are using single CPU as destination, pick only one CPU here */
108 static inline unsigned int bigsmp_cpu_mask_to_apicid(const cpumask_t
*cpumask
)
110 return bigsmp_cpu_to_logical_apicid(first_cpu(*cpumask
));
113 static inline unsigned int
114 bigsmp_cpu_mask_to_apicid_and(const struct cpumask
*cpumask
,
115 const struct cpumask
*andmask
)
120 * We're using fixed IRQ delivery, can only return one phys APIC ID.
121 * May as well be the first.
123 for_each_cpu_and(cpu
, cpumask
, andmask
) {
124 if (cpumask_test_cpu(cpu
, cpu_online_mask
))
127 if (cpu
< nr_cpu_ids
)
128 return bigsmp_cpu_to_logical_apicid(cpu
);
133 static inline int bigsmp_phys_pkg_id(int cpuid_apic
, int index_msb
)
135 return cpuid_apic
>> index_msb
;
138 #endif /* __ASM_MACH_APIC_H */