1 #ifndef __ASM_MACH_APIC_H
2 #define __ASM_MACH_APIC_H
3 
4 #include <asm/apic.h>
5 #include <asm/io_apic.h>
6 #include <asm/genapic.h>
7 #include <asm/smp.h>
8 
9 /* The following are dependent on APIC delivery mode (logical vs. physical). */
10 #define INT_DELIVERY_MODE (genapic.int_delivery_mode)
11 #define INT_DEST_MODE (genapic.int_dest_mode)
12 #define TARGET_CPUS ((const typeof(cpu_online_map) *)&cpu_online_map)
13 #define init_apic_ldr() alternative_vcall(genapic.init_apic_ldr)
14 #define cpu_mask_to_apicid(mask) ({ \
15 	/* \
16 	 * There are a number of places where the address of a local variable \
17 	 * gets passed here. The use of ?: in alternative_call<N>() triggers an \
18 	 * "address of ... is always true" warning in such a case with at least \
19 	 * gcc 7 and 8. Hence the seemingly pointless local variable here. \
20 	 */ \
21 	const cpumask_t *m_ = (mask); \
22 	alternative_call(genapic.cpu_mask_to_apicid, m_); \
23 })
24 #define vector_allocation_cpumask(cpu) \
25 	alternative_call(genapic.vector_allocation_cpumask, cpu)
26 
enable_apic_mode(void)27 static inline void enable_apic_mode(void)
28 {
29 	/* Not needed for modern ES7000 which boot in Virtual Wire mode. */
30 	/*es7000_sw_apic();*/
31 }
32 
33 #define apicid_to_node(apicid) ((int)apicid_to_node[(u32)apicid])
34 
35 extern u32 bios_cpu_apicid[];
36 
multi_timer_check(int apic,int irq)37 static inline int multi_timer_check(int apic, int irq)
38 {
39 	return 0;
40 }
41 
42 extern void generic_apic_probe(void);
43 extern void generic_bigsmp_probe(void);
44 
45 /*
46  * The following functions based around phys_cpu_present_map are disabled in
47  * some i386 Linux subarchitectures, and in x86_64 'cluster' genapic mode. I'm
48  * really not sure why, since all local APICs should have distinct physical
49  * IDs, and we need to know what they are.
50  */
apic_id_registered(void)51 static inline int apic_id_registered(void)
52 {
53 	return physid_isset(get_apic_id(),
54 			    phys_cpu_present_map);
55 }
56 
ioapic_phys_id_map(physid_mask_t * map)57 static inline void ioapic_phys_id_map(physid_mask_t *map)
58 {
59 	*map = phys_cpu_present_map;
60 }
61 
check_apicid_used(const physid_mask_t * map,int apicid)62 static inline int check_apicid_used(const physid_mask_t *map, int apicid)
63 {
64 	return physid_isset(apicid, *map);
65 }
66 
check_apicid_present(int apicid)67 static inline int check_apicid_present(int apicid)
68 {
69 	return physid_isset(apicid, phys_cpu_present_map);
70 }
71 
set_apicid(int phys_apicid,physid_mask_t * map)72 static inline void set_apicid(int phys_apicid, physid_mask_t *map)
73 {
74 	physid_set(phys_apicid, *map);
75 }
76 
77 #endif /* __ASM_MACH_APIC_H */
78