ia64/xen-unstable

view xen/arch/ia64/linux-xen/sal.c @ 10888:5379548bfc79

[NET] Enable TCPv4 segmentation offload in front/back drivers.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Tue Aug 01 11:54:45 2006 +0100 (2006-08-01)
parents 003157eafd66
children 6e7cc23ab18c
line source
1 /*
2 * System Abstraction Layer (SAL) interface routines.
3 *
4 * Copyright (C) 1998, 1999, 2001, 2003 Hewlett-Packard Co
5 * David Mosberger-Tang <davidm@hpl.hp.com>
6 * Copyright (C) 1999 VA Linux Systems
7 * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
8 */
9 #include <linux/config.h>
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/module.h>
14 #include <linux/spinlock.h>
15 #include <linux/string.h>
17 #ifdef XEN
18 #include <linux/smp.h>
19 #include <xen/lib.h>
20 #endif
21 #include <asm/page.h>
22 #include <asm/sal.h>
23 #include <asm/pal.h>
25 __cacheline_aligned DEFINE_SPINLOCK(sal_lock);
26 unsigned long sal_platform_features;
28 unsigned short sal_revision;
29 unsigned short sal_version;
31 #define SAL_MAJOR(x) ((x) >> 8)
32 #define SAL_MINOR(x) ((x) & 0xff)
34 static struct {
35 void *addr; /* function entry point */
36 void *gpval; /* gp value to use */
37 } pdesc;
39 static long
40 default_handler (void)
41 {
42 return -1;
43 }
45 ia64_sal_handler ia64_sal = (ia64_sal_handler) default_handler;
46 ia64_sal_desc_ptc_t *ia64_ptc_domain_info;
48 const char *
49 ia64_sal_strerror (long status)
50 {
51 const char *str;
52 switch (status) {
53 case 0: str = "Call completed without error"; break;
54 case 1: str = "Effect a warm boot of the system to complete "
55 "the update"; break;
56 case -1: str = "Not implemented"; break;
57 case -2: str = "Invalid argument"; break;
58 case -3: str = "Call completed with error"; break;
59 case -4: str = "Virtual address not registered"; break;
60 case -5: str = "No information available"; break;
61 case -6: str = "Insufficient space to add the entry"; break;
62 case -7: str = "Invalid entry_addr value"; break;
63 case -8: str = "Invalid interrupt vector"; break;
64 case -9: str = "Requested memory not available"; break;
65 case -10: str = "Unable to write to the NVM device"; break;
66 case -11: str = "Invalid partition type specified"; break;
67 case -12: str = "Invalid NVM_Object id specified"; break;
68 case -13: str = "NVM_Object already has the maximum number "
69 "of partitions"; break;
70 case -14: str = "Insufficient space in partition for the "
71 "requested write sub-function"; break;
72 case -15: str = "Insufficient data buffer space for the "
73 "requested read record sub-function"; break;
74 case -16: str = "Scratch buffer required for the write/delete "
75 "sub-function"; break;
76 case -17: str = "Insufficient space in the NVM_Object for the "
77 "requested create sub-function"; break;
78 case -18: str = "Invalid value specified in the partition_rec "
79 "argument"; break;
80 case -19: str = "Record oriented I/O not supported for this "
81 "partition"; break;
82 case -20: str = "Bad format of record to be written or "
83 "required keyword variable not "
84 "specified"; break;
85 default: str = "Unknown SAL status code"; break;
86 }
87 return str;
88 }
90 void __init
91 ia64_sal_handler_init (void *entry_point, void *gpval)
92 {
93 /* fill in the SAL procedure descriptor and point ia64_sal to it: */
94 pdesc.addr = entry_point;
95 pdesc.gpval = gpval;
96 ia64_sal = (ia64_sal_handler) &pdesc;
97 }
99 static void __init
100 check_versions (struct ia64_sal_systab *systab)
101 {
102 sal_revision = (systab->sal_rev_major << 8) | systab->sal_rev_minor;
103 sal_version = (systab->sal_b_rev_major << 8) | systab->sal_b_rev_minor;
105 /* Check for broken firmware */
106 if ((sal_revision == SAL_VERSION_CODE(49, 29))
107 && (sal_version == SAL_VERSION_CODE(49, 29)))
108 {
109 /*
110 * Old firmware for zx2000 prototypes have this weird version number,
111 * reset it to something sane.
112 */
113 sal_revision = SAL_VERSION_CODE(2, 8);
114 sal_version = SAL_VERSION_CODE(0, 0);
115 }
116 }
118 static void __init
119 sal_desc_entry_point (void *p)
120 {
121 struct ia64_sal_desc_entry_point *ep = p;
122 ia64_pal_handler_init(__va(ep->pal_proc));
123 ia64_sal_handler_init(__va(ep->sal_proc), __va(ep->gp));
124 }
126 #ifdef CONFIG_SMP
127 static void __init
128 set_smp_redirect (int flag)
129 {
130 #ifndef CONFIG_HOTPLUG_CPU
131 if (no_int_routing)
132 smp_int_redirect &= ~flag;
133 else
134 smp_int_redirect |= flag;
135 #else
136 /*
137 * For CPU Hotplug we dont want to do any chipset supported
138 * interrupt redirection. The reason is this would require that
139 * All interrupts be stopped and hard bind the irq to a cpu.
140 * Later when the interrupt is fired we need to set the redir hint
141 * on again in the vector. This is combersome for something that the
142 * user mode irq balancer will solve anyways.
143 */
144 no_int_routing=1;
145 smp_int_redirect &= ~flag;
146 #endif
147 }
148 #else
149 #define set_smp_redirect(flag) do { } while (0)
150 #endif
152 static void __init
153 sal_desc_platform_feature (void *p)
154 {
155 struct ia64_sal_desc_platform_feature *pf = p;
156 sal_platform_features = pf->feature_mask;
158 printk(KERN_INFO "SAL Platform features:");
159 if (!sal_platform_features) {
160 printk(" None\n");
161 return;
162 }
164 if (sal_platform_features & IA64_SAL_PLATFORM_FEATURE_BUS_LOCK)
165 printk(" BusLock");
166 if (sal_platform_features & IA64_SAL_PLATFORM_FEATURE_IRQ_REDIR_HINT) {
167 printk(" IRQ_Redirection");
168 set_smp_redirect(SMP_IRQ_REDIRECTION);
169 }
170 if (sal_platform_features & IA64_SAL_PLATFORM_FEATURE_IPI_REDIR_HINT) {
171 printk(" IPI_Redirection");
172 set_smp_redirect(SMP_IPI_REDIRECTION);
173 }
174 if (sal_platform_features & IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT)
175 printk(" ITC_Drift");
176 printk("\n");
177 }
179 #ifdef CONFIG_SMP
180 static void __init
181 sal_desc_ap_wakeup (void *p)
182 {
183 struct ia64_sal_desc_ap_wakeup *ap = p;
185 switch (ap->mechanism) {
186 case IA64_SAL_AP_EXTERNAL_INT:
187 ap_wakeup_vector = ap->vector;
188 printk(KERN_INFO "SAL: AP wakeup using external interrupt "
189 "vector 0x%lx\n", ap_wakeup_vector);
190 break;
191 default:
192 printk(KERN_ERR "SAL: AP wakeup mechanism unsupported!\n");
193 break;
194 }
195 }
197 static void __init
198 chk_nointroute_opt(void)
199 {
200 char *cp;
201 extern char saved_command_line[];
203 for (cp = saved_command_line; *cp; ) {
204 if (memcmp(cp, "nointroute", 10) == 0) {
205 no_int_routing = 1;
206 printk ("no_int_routing on\n");
207 break;
208 } else {
209 while (*cp != ' ' && *cp)
210 ++cp;
211 while (*cp == ' ')
212 ++cp;
213 }
214 }
215 }
217 #else
218 static void __init sal_desc_ap_wakeup(void *p) { }
219 #endif
221 void __init
222 ia64_sal_init (struct ia64_sal_systab *systab)
223 {
224 char *p;
225 int i;
227 if (!systab) {
228 printk(KERN_WARNING "Hmm, no SAL System Table.\n");
229 return;
230 }
232 #ifdef XEN /* warning cleanup */
233 if (strncmp((char *)systab->signature, "SST_", 4) != 0)
234 #else
235 if (strncmp(systab->signature, "SST_", 4) != 0)
236 #endif
238 printk(KERN_ERR "bad signature in system table!");
240 check_versions(systab);
241 #ifdef CONFIG_SMP
242 chk_nointroute_opt();
243 #endif
245 /* revisions are coded in BCD, so %x does the job for us */
246 printk(KERN_INFO "SAL %x.%x: %.32s %.32s%sversion %x.%x\n",
247 SAL_MAJOR(sal_revision), SAL_MINOR(sal_revision),
248 systab->oem_id, systab->product_id,
249 systab->product_id[0] ? " " : "",
250 SAL_MAJOR(sal_version), SAL_MINOR(sal_version));
252 p = (char *) (systab + 1);
253 for (i = 0; i < systab->entry_count; i++) {
254 /*
255 * The first byte of each entry type contains the type
256 * descriptor.
257 */
258 switch (*p) {
259 case SAL_DESC_ENTRY_POINT:
260 sal_desc_entry_point(p);
261 break;
262 case SAL_DESC_PLATFORM_FEATURE:
263 sal_desc_platform_feature(p);
264 break;
265 case SAL_DESC_PTC:
266 ia64_ptc_domain_info = (ia64_sal_desc_ptc_t *)p;
267 break;
268 case SAL_DESC_AP_WAKEUP:
269 sal_desc_ap_wakeup(p);
270 break;
271 }
272 p += SAL_DESC_SIZE(*p);
273 }
274 }
276 int
277 ia64_sal_oemcall(struct ia64_sal_retval *isrvp, u64 oemfunc, u64 arg1,
278 u64 arg2, u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7)
279 {
280 if (oemfunc < IA64_SAL_OEMFUNC_MIN || oemfunc > IA64_SAL_OEMFUNC_MAX)
281 return -1;
282 SAL_CALL(*isrvp, oemfunc, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
283 return 0;
284 }
285 EXPORT_SYMBOL(ia64_sal_oemcall);
287 int
288 ia64_sal_oemcall_nolock(struct ia64_sal_retval *isrvp, u64 oemfunc, u64 arg1,
289 u64 arg2, u64 arg3, u64 arg4, u64 arg5, u64 arg6,
290 u64 arg7)
291 {
292 if (oemfunc < IA64_SAL_OEMFUNC_MIN || oemfunc > IA64_SAL_OEMFUNC_MAX)
293 return -1;
294 SAL_CALL_NOLOCK(*isrvp, oemfunc, arg1, arg2, arg3, arg4, arg5, arg6,
295 arg7);
296 return 0;
297 }
298 EXPORT_SYMBOL(ia64_sal_oemcall_nolock);
300 int
301 ia64_sal_oemcall_reentrant(struct ia64_sal_retval *isrvp, u64 oemfunc,
302 u64 arg1, u64 arg2, u64 arg3, u64 arg4, u64 arg5,
303 u64 arg6, u64 arg7)
304 {
305 if (oemfunc < IA64_SAL_OEMFUNC_MIN || oemfunc > IA64_SAL_OEMFUNC_MAX)
306 return -1;
307 SAL_CALL_REENTRANT(*isrvp, oemfunc, arg1, arg2, arg3, arg4, arg5, arg6,
308 arg7);
309 return 0;
310 }
311 EXPORT_SYMBOL(ia64_sal_oemcall_reentrant);