patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / include / asm-i386 / mach-bigsmp / mach_apic.h
1 #ifndef __ASM_MACH_APIC_H
2 #define __ASM_MACH_APIC_H
3 #include <asm/smp.h>
4
5 #define SEQUENTIAL_APICID
6 #ifdef SEQUENTIAL_APICID
7 #define xapic_phys_to_log_apicid(phys_apic) ( (1ul << ((phys_apic) & 0x3)) |\
8                 ((phys_apic<<2) & (~0xf)) )
9 #elif CLUSTERED_APICID
10 #define xapic_phys_to_log_apicid(phys_apic) ( (1ul << ((phys_apic) & 0x3)) |\
11                 ((phys_apic) & (~0xf)) )
12 #endif
13
14 #define NO_BALANCE_IRQ (1)
15 #define esr_disable (1)
16
17 #define NO_IOAPIC_CHECK (0)
18
19 static inline int apic_id_registered(void)
20 {
21         return (1);
22 }
23
24 #define APIC_DFR_VALUE  (APIC_DFR_CLUSTER)
25 /* Round robin the irqs amoung the online cpus */
26 static inline cpumask_t target_cpus(void)
27
28         static unsigned long cpu = NR_CPUS;
29         do {
30                 if (cpu >= NR_CPUS)
31                         cpu = first_cpu_const(cpu_online_map);
32                 else
33                         cpu = next_cpu_const(cpu, cpu_online_map);
34         } while (cpu >= NR_CPUS);
35         return mk_cpumask_const(cpumask_of_cpu(cpu));
36 }
37 #define TARGET_CPUS     (target_cpus())
38
39 #define INT_DELIVERY_MODE dest_Fixed
40 #define INT_DEST_MODE 1     /* logical delivery broadcast to all procs */
41
42 #define APIC_BROADCAST_ID     (0xff)
43 static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid)
44 {
45         return 0;
46 }
47
48 /* we don't use the phys_cpu_present_map to indicate apicid presence */
49 static inline unsigned long check_apicid_present(int bit) 
50 {
51         return 1;
52 }
53
54 #define apicid_cluster(apicid) (apicid & 0xF0)
55
56 static inline unsigned long calculate_ldr(unsigned long old)
57 {
58         unsigned long id;
59         id = xapic_phys_to_log_apicid(hard_smp_processor_id());
60         return ((old & ~APIC_LDR_MASK) | SET_APIC_LOGICAL_ID(id));
61 }
62
63 /*
64  * Set up the logical destination ID.
65  *
66  * Intel recommends to set DFR, LDR and TPR before enabling
67  * an APIC.  See e.g. "AP-388 82489DX User's Manual" (Intel
68  * document number 292116).  So here it goes...
69  */
70 static inline void init_apic_ldr(void)
71 {
72         unsigned long val;
73
74         apic_write_around(APIC_DFR, APIC_DFR_VALUE);
75         val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
76         val = calculate_ldr(val);
77         apic_write_around(APIC_LDR, val);
78 }
79
80 static inline void clustered_apic_check(void)
81 {
82         printk("Enabling APIC mode:  %s.  Using %d I/O APICs\n",
83                 "Cluster", nr_ioapics);
84 }
85
86 static inline int multi_timer_check(int apic, int irq)
87 {
88         return 0;
89 }
90
91 static inline int apicid_to_node(int logical_apicid)
92 {
93         return 0;
94 }
95
96 extern u8 bios_cpu_apicid[];
97
98 static inline int cpu_present_to_apicid(int mps_cpu)
99 {
100         if (mps_cpu < NR_CPUS)
101                 return (int)bios_cpu_apicid[mps_cpu];
102         else
103                 return BAD_APICID;
104 }
105
106 static inline physid_mask_t apicid_to_cpu_present(int phys_apicid)
107 {
108         return physid_mask_of_physid(phys_apicid);
109 }
110
111 extern u8 cpu_2_logical_apicid[];
112 /* Mapping from cpu number to logical apicid */
113 static inline int cpu_to_logical_apicid(int cpu)
114 {
115        if (cpu >= NR_CPUS)
116                return BAD_APICID;
117        return (int)cpu_2_logical_apicid[cpu];
118  }
119
120 static inline int mpc_apic_id(struct mpc_config_processor *m,
121                         struct mpc_config_translation *translation_record)
122 {
123         printk("Processor #%d %ld:%ld APIC version %d\n",
124                 m->mpc_apicid,
125                 (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8,
126                 (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4,
127                 m->mpc_apicver);
128         return m->mpc_apicid;
129 }
130
131 static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map)
132 {
133         /* For clustered we don't have a good way to do this yet - hack */
134         return physids_promote(0xFUL);
135 }
136
137 #define WAKE_SECONDARY_VIA_INIT
138
139 static inline void setup_portio_remap(void)
140 {
141 }
142
143 static inline void enable_apic_mode(void)
144 {
145 }
146
147 static inline int check_phys_apicid_present(int boot_cpu_physical_apicid)
148 {
149         return (1);
150 }
151
152 /* As we are using single CPU as destination, pick only one CPU here */
153 static inline unsigned int cpu_mask_to_apicid(cpumask_const_t cpumask)
154 {
155         int cpu;
156         int apicid;     
157
158         cpu = first_cpu_const(cpumask);
159         apicid = cpu_to_logical_apicid(cpu);
160         return apicid;
161 }
162
163 static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
164 {
165         return cpuid_apic >> index_msb;
166 }
167
168 #endif /* __ASM_MACH_APIC_H */