ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / asm-i386 / mach-numaq / mach_apic.h
1 #ifndef __ASM_MACH_APIC_H
2 #define __ASM_MACH_APIC_H
3
4 #include <asm/io.h>
5 #include <linux/mmzone.h>
6
7 #define APIC_DFR_VALUE  (APIC_DFR_CLUSTER)
8
9 static inline cpumask_t target_cpus(void)
10 {
11         cpumask_t tmp = CPU_MASK_ALL;
12         return tmp;
13 }
14
15 #define TARGET_CPUS (target_cpus())
16
17 #define NO_BALANCE_IRQ (1)
18 #define esr_disable (1)
19
20 #define NO_IOAPIC_CHECK (0)
21
22 #define INT_DELIVERY_MODE dest_LowestPrio
23 #define INT_DEST_MODE 0     /* physical delivery on LOCAL quad */
24  
25 #define APIC_BROADCAST_ID      0x0F
26 #define check_apicid_used(bitmap, apicid) physid_isset(apicid, bitmap)
27 #define check_apicid_present(bit) physid_isset(bit, phys_cpu_present_map)
28 #define apicid_cluster(apicid) (apicid & 0xF0)
29
30 static inline int apic_id_registered(void)
31 {
32         return 1;
33 }
34
35 static inline void init_apic_ldr(void)
36 {
37         /* Already done in NUMA-Q firmware */
38 }
39
40 static inline void clustered_apic_check(void)
41 {
42         printk("Enabling APIC mode:  %s.  Using %d I/O APICs\n",
43                 "NUMA-Q", nr_ioapics);
44 }
45
46 /*
47  * Skip adding the timer int on secondary nodes, which causes
48  * a small but painful rift in the time-space continuum.
49  */
50 static inline int multi_timer_check(int apic, int irq)
51 {
52         return apic != 0 && irq == 0;
53 }
54
55 static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map)
56 {
57         /* We don't have a good way to do this yet - hack */
58         return physids_promote(0xFUL);
59 }
60
61 /* Mapping from cpu number to logical apicid */
62 extern u8 cpu_2_logical_apicid[];
63 static inline int cpu_to_logical_apicid(int cpu)
64 {
65        if (cpu >= NR_CPUS)
66                return BAD_APICID;
67         return (int)cpu_2_logical_apicid[cpu];
68 }
69
70 /*
71  * Supporting over 60 cpus on NUMA-Q requires a locality-dependent
72  * cpu to APIC ID relation to properly interact with the intelligent
73  * mode of the cluster controller.
74  */
75 static inline int cpu_present_to_apicid(int mps_cpu)
76 {
77         if (mps_cpu < 60)
78                 return ((mps_cpu >> 2) << 4) | (1 << (mps_cpu & 0x3));
79         else
80                 return BAD_APICID;
81 }
82
83 static inline int generate_logical_apicid(int quad, int phys_apicid)
84 {
85         return (quad << 4) + (phys_apicid ? phys_apicid << 1 : 1);
86 }
87
88 static inline int apicid_to_node(int logical_apicid) 
89 {
90         return logical_apicid >> 4;
91 }
92
93 static inline physid_mask_t apicid_to_cpu_present(int logical_apicid)
94 {
95         int node = apicid_to_node(logical_apicid);
96         int cpu = __ffs(logical_apicid & 0xf);
97
98         return physid_mask_of_physid(cpu + 4*node);
99 }
100
101 static inline int mpc_apic_id(struct mpc_config_processor *m, 
102                         struct mpc_config_translation *translation_record)
103 {
104         int quad = translation_record->trans_quad;
105         int logical_apicid = generate_logical_apicid(quad, m->mpc_apicid);
106
107         printk("Processor #%d %ld:%ld APIC version %d (quad %d, apic %d)\n",
108                         m->mpc_apicid,
109                         (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8,
110                         (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4,
111                         m->mpc_apicver, quad, logical_apicid);
112         return logical_apicid;
113 }
114
115 static inline void setup_portio_remap(void)
116 {
117         if (numnodes <= 1)
118                 return;
119
120         printk("Remapping cross-quad port I/O for %d quads\n", numnodes);
121         xquad_portio = ioremap (XQUAD_PORTIO_BASE, numnodes*XQUAD_PORTIO_QUAD);
122         printk("xquad_portio vaddr 0x%08lx, len %08lx\n",
123                 (u_long) xquad_portio, (u_long) numnodes*XQUAD_PORTIO_QUAD);
124 }
125
126 static inline int check_phys_apicid_present(int boot_cpu_physical_apicid)
127 {
128         return (1);
129 }
130
131 static inline void enable_apic_mode(void)
132 {
133 }
134
135 /*
136  * We use physical apicids here, not logical, so just return the default
137  * physical broadcast to stop people from breaking us
138  */
139 static inline unsigned int cpu_mask_to_apicid(cpumask_const_t cpumask)
140 {
141         return (int) 0xF;
142 }
143
144 /* No NUMA-Q box has a HT CPU, but it can't hurt to use the default code. */
145 static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
146 {
147         return cpuid_apic >> index_msb;
148 }
149
150 #endif /* __ASM_MACH_APIC_H */