apic.h 2.8 KB
Newer Older
Y
Yinghai Lu 已提交
1 2
#ifndef __ASM_NUMAQ_APIC_H
#define __ASM_NUMAQ_APIC_H
L
Linus Torvalds 已提交
3 4 5 6 7 8 9

#include <asm/io.h>
#include <linux/mmzone.h>
#include <linux/nodemask.h>

#define APIC_DFR_VALUE	(APIC_DFR_CLUSTER)

10
static inline const cpumask_t *numaq_target_cpus(void)
L
Linus Torvalds 已提交
11
{
12
	return &CPU_MASK_ALL;
L
Linus Torvalds 已提交
13 14
}

15 16
static inline unsigned long
numaq_check_apicid_used(physid_mask_t bitmap, int apicid)
17 18 19
{
	return physid_isset(apicid, bitmap);
}
20
static inline unsigned long numaq_check_apicid_present(int bit)
21 22 23
{
	return physid_isset(bit, phys_cpu_present_map);
}
L
Linus Torvalds 已提交
24 25
#define apicid_cluster(apicid) (apicid & 0xF0)

26
static inline int numaq_apic_id_registered(void)
L
Linus Torvalds 已提交
27 28 29 30
{
	return 1;
}

31
static inline void numaq_init_apic_ldr(void)
L
Linus Torvalds 已提交
32 33 34 35
{
	/* Already done in NUMA-Q firmware */
}

36
static inline void numaq_setup_apic_routing(void)
L
Linus Torvalds 已提交
37 38 39 40 41 42 43 44 45
{
	printk("Enabling APIC mode:  %s.  Using %d I/O APICs\n",
		"NUMA-Q", nr_ioapics);
}

/*
 * Skip adding the timer int on secondary nodes, which causes
 * a small but painful rift in the time-space continuum.
 */
46
static inline int numaq_multi_timer_check(int apic, int irq)
L
Linus Torvalds 已提交
47 48 49 50
{
	return apic != 0 && irq == 0;
}

51
static inline physid_mask_t numaq_ioapic_phys_id_map(physid_mask_t phys_map)
L
Linus Torvalds 已提交
52 53 54 55 56 57 58
{
	/* We don't have a good way to do this yet - hack */
	return physids_promote(0xFUL);
}

/* Mapping from cpu number to logical apicid */
extern u8 cpu_2_logical_apicid[];
59 60

static inline int numaq_cpu_to_logical_apicid(int cpu)
L
Linus Torvalds 已提交
61
{
62 63
	if (cpu >= nr_cpu_ids)
		return BAD_APICID;
L
Linus Torvalds 已提交
64 65 66 67 68 69 70 71
	return (int)cpu_2_logical_apicid[cpu];
}

/*
 * Supporting over 60 cpus on NUMA-Q requires a locality-dependent
 * cpu to APIC ID relation to properly interact with the intelligent
 * mode of the cluster controller.
 */
72
static inline int numaq_cpu_present_to_apicid(int mps_cpu)
L
Linus Torvalds 已提交
73 74 75 76 77 78 79
{
	if (mps_cpu < 60)
		return ((mps_cpu >> 2) << 4) | (1 << (mps_cpu & 0x3));
	else
		return BAD_APICID;
}

80
static inline int numaq_apicid_to_node(int logical_apicid) 
L
Linus Torvalds 已提交
81 82 83 84
{
	return logical_apicid >> 4;
}

85
static inline physid_mask_t numaq_apicid_to_cpu_present(int logical_apicid)
L
Linus Torvalds 已提交
86
{
87
	int node = numaq_apicid_to_node(logical_apicid);
L
Linus Torvalds 已提交
88 89 90 91 92
	int cpu = __ffs(logical_apicid & 0xf);

	return physid_mask_of_physid(cpu + 4*node);
}

93 94
extern void *xquad_portio;

95
static inline int numaq_check_phys_apicid_present(int boot_cpu_physical_apicid)
L
Linus Torvalds 已提交
96
{
97
	return 1;
L
Linus Torvalds 已提交
98 99 100 101 102 103
}

/*
 * We use physical apicids here, not logical, so just return the default
 * physical broadcast to stop people from breaking us
 */
104
static inline unsigned int numaq_cpu_mask_to_apicid(const cpumask_t *cpumask)
L
Linus Torvalds 已提交
105
{
106
	return 0x0F;
L
Linus Torvalds 已提交
107 108
}

109 110 111
static inline unsigned int
numaq_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
			     const struct cpumask *andmask)
M
Mike Travis 已提交
112
{
113
	return 0x0F;
M
Mike Travis 已提交
114 115
}

L
Linus Torvalds 已提交
116
/* No NUMA-Q box has a HT CPU, but it can't hurt to use the default code. */
117
static inline int numaq_phys_pkg_id(int cpuid_apic, int index_msb)
L
Linus Torvalds 已提交
118 119 120 121
{
	return cpuid_apic >> index_msb;
}

Y
Yinghai Lu 已提交
122
#endif /* __ASM_NUMAQ_APIC_H */