2 * System Abstraction Layer (SAL) interface routines.
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>
10 #include <linux/kernel.h>
11 #include <linux/init.h>
12 #include <linux/module.h>
13 #include <linux/spinlock.h>
14 #include <linux/string.h>
16 #include <asm/delay.h>
21 __cacheline_aligned
DEFINE_SPINLOCK(sal_lock
);
22 unsigned long sal_platform_features
;
24 unsigned short sal_revision
;
25 unsigned short sal_version
;
27 #define SAL_MAJOR(x) ((x) >> 8)
28 #define SAL_MINOR(x) ((x) & 0xff)
31 void *addr
; /* function entry point */
32 void *gpval
; /* gp value to use */
36 default_handler (void)
41 ia64_sal_handler ia64_sal
= (ia64_sal_handler
) default_handler
;
42 ia64_sal_desc_ptc_t
*ia64_ptc_domain_info
;
45 ia64_sal_strerror (long status
)
49 case 0: str
= "Call completed without error"; break;
50 case 1: str
= "Effect a warm boot of the system to complete "
52 case -1: str
= "Not implemented"; break;
53 case -2: str
= "Invalid argument"; break;
54 case -3: str
= "Call completed with error"; break;
55 case -4: str
= "Virtual address not registered"; break;
56 case -5: str
= "No information available"; break;
57 case -6: str
= "Insufficient space to add the entry"; break;
58 case -7: str
= "Invalid entry_addr value"; break;
59 case -8: str
= "Invalid interrupt vector"; break;
60 case -9: str
= "Requested memory not available"; break;
61 case -10: str
= "Unable to write to the NVM device"; break;
62 case -11: str
= "Invalid partition type specified"; break;
63 case -12: str
= "Invalid NVM_Object id specified"; break;
64 case -13: str
= "NVM_Object already has the maximum number "
65 "of partitions"; break;
66 case -14: str
= "Insufficient space in partition for the "
67 "requested write sub-function"; break;
68 case -15: str
= "Insufficient data buffer space for the "
69 "requested read record sub-function"; break;
70 case -16: str
= "Scratch buffer required for the write/delete "
71 "sub-function"; break;
72 case -17: str
= "Insufficient space in the NVM_Object for the "
73 "requested create sub-function"; break;
74 case -18: str
= "Invalid value specified in the partition_rec "
76 case -19: str
= "Record oriented I/O not supported for this "
78 case -20: str
= "Bad format of record to be written or "
79 "required keyword variable not "
81 default: str
= "Unknown SAL status code"; break;
87 ia64_sal_handler_init (void *entry_point
, void *gpval
)
89 /* fill in the SAL procedure descriptor and point ia64_sal to it: */
90 pdesc
.addr
= entry_point
;
92 ia64_sal
= (ia64_sal_handler
) &pdesc
;
96 check_versions (struct ia64_sal_systab
*systab
)
98 sal_revision
= (systab
->sal_rev_major
<< 8) | systab
->sal_rev_minor
;
99 sal_version
= (systab
->sal_b_rev_major
<< 8) | systab
->sal_b_rev_minor
;
101 /* Check for broken firmware */
102 if ((sal_revision
== SAL_VERSION_CODE(49, 29))
103 && (sal_version
== SAL_VERSION_CODE(49, 29)))
106 * Old firmware for zx2000 prototypes have this weird version number,
107 * reset it to something sane.
109 sal_revision
= SAL_VERSION_CODE(2, 8);
110 sal_version
= SAL_VERSION_CODE(0, 0);
112 <<<<<<< HEAD
:arch
/ia64
/kernel
/sal
.c
115 if (ia64_platform_is("sn2") && (sal_revision
== SAL_VERSION_CODE(2, 9)))
117 * SGI Altix has hard-coded version 2.9 in their prom
118 * but they actually implement 3.2, so let's fix it here.
120 sal_revision
= SAL_VERSION_CODE(3, 2);
121 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/ia64
/kernel
/sal
.c
125 sal_desc_entry_point (void *p
)
127 struct ia64_sal_desc_entry_point
*ep
= p
;
128 ia64_pal_handler_init(__va(ep
->pal_proc
));
129 ia64_sal_handler_init(__va(ep
->sal_proc
), __va(ep
->gp
));
134 set_smp_redirect (int flag
)
136 #ifndef CONFIG_HOTPLUG_CPU
138 smp_int_redirect
&= ~flag
;
140 smp_int_redirect
|= flag
;
143 * For CPU Hotplug we dont want to do any chipset supported
144 * interrupt redirection. The reason is this would require that
145 * All interrupts be stopped and hard bind the irq to a cpu.
146 * Later when the interrupt is fired we need to set the redir hint
147 * on again in the vector. This is cumbersome for something that the
148 * user mode irq balancer will solve anyways.
151 smp_int_redirect
&= ~flag
;
155 #define set_smp_redirect(flag) do { } while (0)
159 sal_desc_platform_feature (void *p
)
161 struct ia64_sal_desc_platform_feature
*pf
= p
;
162 sal_platform_features
= pf
->feature_mask
;
164 printk(KERN_INFO
"SAL Platform features:");
165 if (!sal_platform_features
) {
170 if (sal_platform_features
& IA64_SAL_PLATFORM_FEATURE_BUS_LOCK
)
172 if (sal_platform_features
& IA64_SAL_PLATFORM_FEATURE_IRQ_REDIR_HINT
) {
173 printk(" IRQ_Redirection");
174 set_smp_redirect(SMP_IRQ_REDIRECTION
);
176 if (sal_platform_features
& IA64_SAL_PLATFORM_FEATURE_IPI_REDIR_HINT
) {
177 printk(" IPI_Redirection");
178 set_smp_redirect(SMP_IPI_REDIRECTION
);
180 if (sal_platform_features
& IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT
)
181 printk(" ITC_Drift");
187 sal_desc_ap_wakeup (void *p
)
189 struct ia64_sal_desc_ap_wakeup
*ap
= p
;
191 switch (ap
->mechanism
) {
192 case IA64_SAL_AP_EXTERNAL_INT
:
193 ap_wakeup_vector
= ap
->vector
;
194 printk(KERN_INFO
"SAL: AP wakeup using external interrupt "
195 "vector 0x%lx\n", ap_wakeup_vector
);
198 printk(KERN_ERR
"SAL: AP wakeup mechanism unsupported!\n");
204 chk_nointroute_opt(void)
208 for (cp
= boot_command_line
; *cp
; ) {
209 if (memcmp(cp
, "nointroute", 10) == 0) {
211 printk ("no_int_routing on\n");
214 while (*cp
!= ' ' && *cp
)
223 static void __init
sal_desc_ap_wakeup(void *p
) { }
227 * HP rx5670 firmware polls for interrupts during SAL_CACHE_FLUSH by reading
228 * cr.ivr, but it never writes cr.eoi. This leaves any interrupt marked as
229 * "in-service" and masks other interrupts of equal or lower priority.
231 * HP internal defect reports: F1859, F2775, F3031.
233 static int sal_cache_flush_drops_interrupts
;
236 check_sal_cache_flush (void)
240 u64 vector
, cache_type
= 3;
241 struct ia64_sal_retval isrv
;
244 local_irq_save(flags
);
247 * Schedule a timer interrupt, wait until it's reported, and see if
248 * SAL_CACHE_FLUSH drops it.
250 ia64_set_itv(IA64_TIMER_VECTOR
);
251 ia64_set_itm(ia64_get_itc() + 1000);
253 while (!ia64_get_irr(IA64_TIMER_VECTOR
))
256 SAL_CALL(isrv
, SAL_CACHE_FLUSH
, cache_type
, 0, 0, 0, 0, 0, 0);
259 printk(KERN_ERR
"SAL_CAL_FLUSH failed with %ld\n", isrv
.status
);
261 if (ia64_get_irr(IA64_TIMER_VECTOR
)) {
262 vector
= ia64_get_ivr();
264 WARN_ON(vector
!= IA64_TIMER_VECTOR
);
266 sal_cache_flush_drops_interrupts
= 1;
267 printk(KERN_ERR
"SAL: SAL_CACHE_FLUSH drops interrupts; "
268 "PAL_CACHE_FLUSH will be used instead\n");
272 local_irq_restore(flags
);
277 ia64_sal_cache_flush (u64 cache_type
)
279 struct ia64_sal_retval isrv
;
281 if (sal_cache_flush_drops_interrupts
) {
287 local_irq_save(flags
);
288 rc
= ia64_pal_cache_flush(cache_type
,
289 PAL_CACHE_FLUSH_INVALIDATE
, &progress
, NULL
);
290 local_irq_restore(flags
);
294 SAL_CALL(isrv
, SAL_CACHE_FLUSH
, cache_type
, 0, 0, 0, 0, 0, 0);
297 EXPORT_SYMBOL_GPL(ia64_sal_cache_flush
);
300 ia64_sal_init (struct ia64_sal_systab
*systab
)
306 printk(KERN_WARNING
"Hmm, no SAL System Table.\n");
310 if (strncmp(systab
->signature
, "SST_", 4) != 0)
311 printk(KERN_ERR
"bad signature in system table!");
313 check_versions(systab
);
315 chk_nointroute_opt();
318 /* revisions are coded in BCD, so %x does the job for us */
319 printk(KERN_INFO
"SAL %x.%x: %.32s %.32s%sversion %x.%x\n",
320 SAL_MAJOR(sal_revision
), SAL_MINOR(sal_revision
),
321 systab
->oem_id
, systab
->product_id
,
322 systab
->product_id
[0] ? " " : "",
323 SAL_MAJOR(sal_version
), SAL_MINOR(sal_version
));
325 p
= (char *) (systab
+ 1);
326 for (i
= 0; i
< systab
->entry_count
; i
++) {
328 * The first byte of each entry type contains the type
332 case SAL_DESC_ENTRY_POINT
:
333 sal_desc_entry_point(p
);
335 case SAL_DESC_PLATFORM_FEATURE
:
336 sal_desc_platform_feature(p
);
339 ia64_ptc_domain_info
= (ia64_sal_desc_ptc_t
*)p
;
341 case SAL_DESC_AP_WAKEUP
:
342 sal_desc_ap_wakeup(p
);
345 p
+= SAL_DESC_SIZE(*p
);
351 ia64_sal_oemcall(struct ia64_sal_retval
*isrvp
, u64 oemfunc
, u64 arg1
,
352 u64 arg2
, u64 arg3
, u64 arg4
, u64 arg5
, u64 arg6
, u64 arg7
)
354 if (oemfunc
< IA64_SAL_OEMFUNC_MIN
|| oemfunc
> IA64_SAL_OEMFUNC_MAX
)
356 SAL_CALL(*isrvp
, oemfunc
, arg1
, arg2
, arg3
, arg4
, arg5
, arg6
, arg7
);
359 EXPORT_SYMBOL(ia64_sal_oemcall
);
362 ia64_sal_oemcall_nolock(struct ia64_sal_retval
*isrvp
, u64 oemfunc
, u64 arg1
,
363 u64 arg2
, u64 arg3
, u64 arg4
, u64 arg5
, u64 arg6
,
366 if (oemfunc
< IA64_SAL_OEMFUNC_MIN
|| oemfunc
> IA64_SAL_OEMFUNC_MAX
)
368 SAL_CALL_NOLOCK(*isrvp
, oemfunc
, arg1
, arg2
, arg3
, arg4
, arg5
, arg6
,
372 EXPORT_SYMBOL(ia64_sal_oemcall_nolock
);
375 ia64_sal_oemcall_reentrant(struct ia64_sal_retval
*isrvp
, u64 oemfunc
,
376 u64 arg1
, u64 arg2
, u64 arg3
, u64 arg4
, u64 arg5
,
379 if (oemfunc
< IA64_SAL_OEMFUNC_MIN
|| oemfunc
> IA64_SAL_OEMFUNC_MAX
)
381 SAL_CALL_REENTRANT(*isrvp
, oemfunc
, arg1
, arg2
, arg3
, arg4
, arg5
, arg6
,
385 EXPORT_SYMBOL(ia64_sal_oemcall_reentrant
);
388 ia64_sal_freq_base (unsigned long which
, unsigned long *ticks_per_second
,
389 unsigned long *drift_info
)
391 struct ia64_sal_retval isrv
;
393 SAL_CALL(isrv
, SAL_FREQ_BASE
, which
, 0, 0, 0, 0, 0, 0);
394 *ticks_per_second
= isrv
.v0
;
395 *drift_info
= isrv
.v1
;
398 EXPORT_SYMBOL_GPL(ia64_sal_freq_base
);