aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorYinghai Lu <yhlu.kernel@gmail.com>2008-07-12 04:01:20 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-13 02:27:46 -0400
commitf910a9dc7c865896815e2a95fe33363e9522f277 (patch)
treea4d1361f7d38dd358da62a1c14191cdbf6011d98 /arch
parent4c9961d56ec20c27ec5d02e49fd7427748312741 (diff)
x86: make 64bit have get_apic_id
generalize the x2apic code some more. let read_apic_id become a macro (later on a function/inline) GET_APIC_ID(apic_read(APIC_ID)) +#define read_apic_id() (GET_APIC_ID(apic_read(APIC_ID))) instead of this weird construct: -#define read_apic_id (genapic->read_apic_id) Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com> Cc: Suresh Siddha <suresh.b.siddha@intel.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kernel/genapic_flat_64.c26
-rw-r--r--arch/x86/kernel/genx2apic_cluster.c20
-rw-r--r--arch/x86/kernel/genx2apic_phys.c20
-rw-r--r--arch/x86/kernel/genx2apic_uv_x.c23
4 files changed, 81 insertions, 8 deletions
diff --git a/arch/x86/kernel/genapic_flat_64.c b/arch/x86/kernel/genapic_flat_64.c
index 7dac2f275fad..2c973cbf054f 100644
--- a/arch/x86/kernel/genapic_flat_64.c
+++ b/arch/x86/kernel/genapic_flat_64.c
@@ -97,11 +97,27 @@ static void flat_send_IPI_all(int vector)
97 __send_IPI_shortcut(APIC_DEST_ALLINC, vector, APIC_DEST_LOGICAL); 97 __send_IPI_shortcut(APIC_DEST_ALLINC, vector, APIC_DEST_LOGICAL);
98} 98}
99 99
100static unsigned int get_apic_id(unsigned long x)
101{
102 unsigned int id;
103
104 id = (((x)>>24) & 0xFFu);
105 return id;
106}
107
108static unsigned long set_apic_id(unsigned int id)
109{
110 unsigned long x;
111
112 x = ((id & 0xFFu)<<24);
113 return x;
114}
115
100static unsigned int read_xapic_id(void) 116static unsigned int read_xapic_id(void)
101{ 117{
102 unsigned int id; 118 unsigned int id;
103 119
104 id = GET_APIC_ID(apic_read(APIC_ID)); 120 id = get_apic_id(apic_read(APIC_ID));
105 return id; 121 return id;
106} 122}
107 123
@@ -134,7 +150,9 @@ struct genapic apic_flat = {
134 .send_IPI_self = apic_send_IPI_self, 150 .send_IPI_self = apic_send_IPI_self,
135 .cpu_mask_to_apicid = flat_cpu_mask_to_apicid, 151 .cpu_mask_to_apicid = flat_cpu_mask_to_apicid,
136 .phys_pkg_id = phys_pkg_id, 152 .phys_pkg_id = phys_pkg_id,
137 .read_apic_id = read_xapic_id, 153 .get_apic_id = get_apic_id,
154 .set_apic_id = set_apic_id,
155 .apic_id_mask = (0xFFu<<24),
138}; 156};
139 157
140/* 158/*
@@ -200,5 +218,7 @@ struct genapic apic_physflat = {
200 .send_IPI_self = apic_send_IPI_self, 218 .send_IPI_self = apic_send_IPI_self,
201 .cpu_mask_to_apicid = physflat_cpu_mask_to_apicid, 219 .cpu_mask_to_apicid = physflat_cpu_mask_to_apicid,
202 .phys_pkg_id = phys_pkg_id, 220 .phys_pkg_id = phys_pkg_id,
203 .read_apic_id = read_xapic_id, 221 .get_apic_id = get_apic_id,
222 .set_apic_id = set_apic_id,
223 .apic_id_mask = (0xFFu<<24),
204}; 224};
diff --git a/arch/x86/kernel/genx2apic_cluster.c b/arch/x86/kernel/genx2apic_cluster.c
index ed0fdede800a..40bc0140d89f 100644
--- a/arch/x86/kernel/genx2apic_cluster.c
+++ b/arch/x86/kernel/genx2apic_cluster.c
@@ -94,6 +94,22 @@ static unsigned int x2apic_cpu_mask_to_apicid(cpumask_t cpumask)
94 return BAD_APICID; 94 return BAD_APICID;
95} 95}
96 96
97static unsigned int get_apic_id(unsigned long x)
98{
99 unsigned int id;
100
101 id = x;
102 return id;
103}
104
105static unsigned long set_apic_id(unsigned int id)
106{
107 unsigned long x;
108
109 x = id;
110 return x;
111}
112
97static unsigned int x2apic_read_id(void) 113static unsigned int x2apic_read_id(void)
98{ 114{
99 return apic_read(APIC_ID); 115 return apic_read(APIC_ID);
@@ -131,5 +147,7 @@ struct genapic apic_x2apic_cluster = {
131 .send_IPI_self = x2apic_send_IPI_self, 147 .send_IPI_self = x2apic_send_IPI_self,
132 .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid, 148 .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid,
133 .phys_pkg_id = phys_pkg_id, 149 .phys_pkg_id = phys_pkg_id,
134 .read_apic_id = x2apic_read_id, 150 .get_apic_id = get_apic_id,
151 .set_apic_id = set_apic_id,
152 .apic_id_mask = (0xFFFFFFFFu),
135}; 153};
diff --git a/arch/x86/kernel/genx2apic_phys.c b/arch/x86/kernel/genx2apic_phys.c
index 3c70b9d692b2..2f3c6ca19de9 100644
--- a/arch/x86/kernel/genx2apic_phys.c
+++ b/arch/x86/kernel/genx2apic_phys.c
@@ -84,6 +84,22 @@ static unsigned int x2apic_cpu_mask_to_apicid(cpumask_t cpumask)
84 return BAD_APICID; 84 return BAD_APICID;
85} 85}
86 86
87static unsigned int get_apic_id(unsigned long x)
88{
89 unsigned int id;
90
91 id = x;
92 return id;
93}
94
95static unsigned long set_apic_id(unsigned int id)
96{
97 unsigned long x;
98
99 x = id;
100 return x;
101}
102
87static unsigned int x2apic_read_id(void) 103static unsigned int x2apic_read_id(void)
88{ 104{
89 return apic_read(APIC_ID); 105 return apic_read(APIC_ID);
@@ -118,5 +134,7 @@ struct genapic apic_x2apic_phys = {
118 .send_IPI_self = x2apic_send_IPI_self, 134 .send_IPI_self = x2apic_send_IPI_self,
119 .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid, 135 .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid,
120 .phys_pkg_id = phys_pkg_id, 136 .phys_pkg_id = phys_pkg_id,
121 .read_apic_id = x2apic_read_id, 137 .get_apic_id = get_apic_id,
138 .set_apic_id = set_apic_id,
139 .apic_id_mask = (0xFFFFFFFFu),
122}; 140};
diff --git a/arch/x86/kernel/genx2apic_uv_x.c b/arch/x86/kernel/genx2apic_uv_x.c
index c915f750241e..3ca29cd8c23c 100644
--- a/arch/x86/kernel/genx2apic_uv_x.c
+++ b/arch/x86/kernel/genx2apic_uv_x.c
@@ -139,16 +139,31 @@ static unsigned int uv_cpu_mask_to_apicid(cpumask_t cpumask)
139 return BAD_APICID; 139 return BAD_APICID;
140} 140}
141 141
142static unsigned int uv_read_apic_id(void) 142static unsigned int get_apic_id(unsigned long x)
143{ 143{
144 unsigned int id; 144 unsigned int id;
145 145
146 WARN_ON(preemptible() && num_online_cpus() > 1); 146 WARN_ON(preemptible() && num_online_cpus() > 1);
147 id = apic_read(APIC_ID) | __get_cpu_var(x2apic_extra_bits); 147 id = x | __get_cpu_var(x2apic_extra_bits);
148 148
149 return id; 149 return id;
150} 150}
151 151
152static long set_apic_id(unsigned int id)
153{
154 unsigned long x;
155
156 /* maskout x2apic_extra_bits ? */
157 x = id;
158 return x;
159}
160
161static unsigned int uv_read_apic_id(void)
162{
163
164 return get_apic_id(apic_read(APIC_ID));
165}
166
152static unsigned int phys_pkg_id(int index_msb) 167static unsigned int phys_pkg_id(int index_msb)
153{ 168{
154 return uv_read_apic_id() >> index_msb; 169 return uv_read_apic_id() >> index_msb;
@@ -175,7 +190,9 @@ struct genapic apic_x2apic_uv_x = {
175 /* ZZZ.send_IPI_self = uv_send_IPI_self, */ 190 /* ZZZ.send_IPI_self = uv_send_IPI_self, */
176 .cpu_mask_to_apicid = uv_cpu_mask_to_apicid, 191 .cpu_mask_to_apicid = uv_cpu_mask_to_apicid,
177 .phys_pkg_id = phys_pkg_id, /* Fixme ZZZ */ 192 .phys_pkg_id = phys_pkg_id, /* Fixme ZZZ */
178 .read_apic_id = uv_read_apic_id, 193 .get_apic_id = get_apic_id,
194 .set_apic_id = set_apic_id,
195 .apic_id_mask = (0xFFFFFFFFu),
179}; 196};
180 197
181static __cpuinit void set_x2apic_extra_bits(int pnode) 198static __cpuinit void set_x2apic_extra_bits(int pnode)