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