* Re: [PATCH] sal cleanup
2004-02-26 21:37 [PATCH] sal cleanup Matthew Wilcox
@ 2004-02-26 21:55 ` David Mosberger
2004-02-26 22:04 ` Matthew Wilcox
` (19 subsequent siblings)
20 siblings, 0 replies; 22+ messages in thread
From: David Mosberger @ 2004-02-26 21:55 UTC (permalink / raw)
To: linux-ia64
>>>>> On Thu, 26 Feb 2004 21:37:04 +0000, Matthew Wilcox <willy@debian.org> said:
Matthew> - Don't print the SAL platform features line if there's no features.
How about printing "none" or something like that instead?
--david
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH] sal cleanup
2004-02-26 21:37 [PATCH] sal cleanup Matthew Wilcox
2004-02-26 21:55 ` David Mosberger
@ 2004-02-26 22:04 ` Matthew Wilcox
2004-02-27 18:52 ` David Mosberger
` (18 subsequent siblings)
20 siblings, 0 replies; 22+ messages in thread
From: Matthew Wilcox @ 2004-02-26 22:04 UTC (permalink / raw)
To: linux-ia64
On Thu, Feb 26, 2004 at 01:55:34PM -0800, David Mosberger wrote:
> How about printing "none" or something like that instead?
Sure.
This patch reorganises sal.c and adds two new functions:
- Split the body of the switch statement in ia64_sal_init() into
separate functions.
- Delete min/max since they were only assigned to, never used.
- Print the version of the SAL implementation as well as the spec version
it supports.
- Stop printing the pal_proc and sal_proc entry addresses.
- Print "none" if there are no platform features.
- Remember the sal revision and version and add two functions to compare them.
Index: arch/ia64/kernel/sal.c
=================================RCS file: /var/cvs/linux-2.6/arch/ia64/kernel/sal.c,v
retrieving revision 1.1
diff -u -p -r1.1 sal.c
--- a/arch/ia64/kernel/sal.c 29 Jul 2003 17:00:27 -0000 1.1
+++ b/arch/ia64/kernel/sal.c 26 Feb 2004 22:02:31 -0000
@@ -8,9 +8,9 @@
*/
#include <linux/config.h>
+#include <linux/bcd.h>
#include <linux/kernel.h>
#include <linux/init.h>
-#include <linux/smp.h>
#include <linux/spinlock.h>
#include <linux/string.h>
@@ -21,6 +21,9 @@
spinlock_t sal_lock __cacheline_aligned = SPIN_LOCK_UNLOCKED;
unsigned long sal_platform_features;
+int sal_rev_major, sal_rev_minor;
+int sal_b_rev_major, sal_b_rev_minor;
+
static struct {
void *addr; /* function entry point */
void *gpval; /* gp value to use */
@@ -86,13 +89,73 @@ ia64_sal_handler_init (void *entry_point
ia64_sal = (ia64_sal_handler) &pdesc;
}
+static void __init sal_desc_entry_point(void *p)
+{
+ struct ia64_sal_desc_entry_point *ep = p;
+ ia64_pal_handler_init(__va(ep->pal_proc));
+ ia64_sal_handler_init(__va(ep->sal_proc), __va(ep->gp));
+}
+
+static void __init sal_desc_platform_feature(void *p)
+{
+ struct ia64_sal_desc_platform_feature *pf = p;
+ sal_platform_features = pf->feature_mask;
+
+ printk(KERN_INFO "SAL: Platform features");
+ if (!sal_platform_features) {
+ printk(" none\n");
+ return;
+ }
+
+ if (sal_platform_features & IA64_SAL_PLATFORM_FEATURE_BUS_LOCK)
+ printk(" BusLock");
+ if (sal_platform_features & IA64_SAL_PLATFORM_FEATURE_IRQ_REDIR_HINT) {
+ printk(" IRQ_Redirection");
+#ifdef CONFIG_SMP
+ if (no_int_routing)
+ smp_int_redirect &= ~SMP_IRQ_REDIRECTION;
+ else
+ smp_int_redirect |= SMP_IRQ_REDIRECTION;
+#endif
+ }
+ if (sal_platform_features & IA64_SAL_PLATFORM_FEATURE_IPI_REDIR_HINT) {
+ printk(" IPI_Redirection");
+#ifdef CONFIG_SMP
+ if (no_int_routing)
+ smp_int_redirect &= ~SMP_IPI_REDIRECTION;
+ else
+ smp_int_redirect |= SMP_IPI_REDIRECTION;
+#endif
+ }
+ if (sal_platform_features & IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT)
+ printk(" ITC_Drift");
+ printk("\n");
+}
+
+#ifdef CONFIG_SMP
+static void __init sal_desc_ap_wakeup(void *p)
+{
+ struct ia64_sal_desc_ap_wakeup *ap = p;
+
+ switch (ap->mechanism) {
+ case IA64_SAL_AP_EXTERNAL_INT:
+ ap_wakeup_vector = ap->vector;
+ printk(KERN_INFO "SAL: AP wakeup using external interrupt "
+ "vector 0x%lx\n", ap_wakeup_vector);
+ break;
+ default:
+ printk(KERN_ERR "SAL: AP wakeup mechanism unsupported!\n");
+ break;
+ }
+}
+#else
+static void __init sal_desc_ap_wakeup(void *p) { }
+#endif
void __init
ia64_sal_init (struct ia64_sal_systab *systab)
{
- unsigned long min, max;
char *p;
- struct ia64_sal_desc_entry_point *ep;
int i;
if (!systab) {
@@ -103,86 +166,73 @@ ia64_sal_init (struct ia64_sal_systab *s
if (strncmp(systab->signature, "SST_", 4) != 0)
printk(KERN_ERR "bad signature in system table!");
- /*
- * revisions are coded in BCD, so %x does the job for us
- */
- printk(KERN_INFO "SAL v%x.%02x: oem=%.32s, product=%.32s\n",
- systab->sal_rev_major, systab->sal_rev_minor,
- systab->oem_id, systab->product_id);
-
- min = ~0UL;
- max = 0;
+ sal_rev_major = BCD2BIN(systab->sal_rev_major);
+ sal_rev_minor = BCD2BIN(systab->sal_rev_minor);
+ sal_b_rev_major = BCD2BIN(systab->sal_b_rev_major);
+ sal_b_rev_minor = BCD2BIN(systab->sal_b_rev_minor);
+
+ printk(KERN_INFO "SAL %d.%d: oem=%.32s, product=%.32s, version %d.%d\n",
+ sal_rev_major, sal_rev_minor, systab->oem_id,
+ systab->product_id, sal_b_rev_major, sal_b_rev_minor);
p = (char *) (systab + 1);
for (i = 0; i < systab->entry_count; i++) {
/*
- * The first byte of each entry type contains the type descriptor.
+ * The first byte of each entry type contains the type
+ * descriptor.
*/
switch (*p) {
- case SAL_DESC_ENTRY_POINT:
- ep = (struct ia64_sal_desc_entry_point *) p;
- printk(KERN_INFO "SAL: entry: pal_proc=0x%lx, sal_proc=0x%lx\n",
- ep->pal_proc, ep->sal_proc);
- ia64_pal_handler_init(__va(ep->pal_proc));
- ia64_sal_handler_init(__va(ep->sal_proc), __va(ep->gp));
+ case SAL_DESC_ENTRY_POINT:
+ sal_desc_entry_point(p);
break;
-
- case SAL_DESC_PTC:
+ case SAL_DESC_PLATFORM_FEATURE:
+ sal_desc_platform_feature(p);
+ break;
+ case SAL_DESC_PTC:
ia64_ptc_domain_info = (ia64_sal_desc_ptc_t *)p;
break;
-
- case SAL_DESC_AP_WAKEUP:
-#ifdef CONFIG_SMP
- {
- struct ia64_sal_desc_ap_wakeup *ap = (void *) p;
-
- switch (ap->mechanism) {
- case IA64_SAL_AP_EXTERNAL_INT:
- ap_wakeup_vector = ap->vector;
- printk(KERN_INFO "SAL: AP wakeup using external interrupt "
- "vector 0x%lx\n", ap_wakeup_vector);
- break;
-
- default:
- printk(KERN_ERR "SAL: AP wakeup mechanism unsupported!\n");
- break;
- }
- break;
- }
-#endif
- case SAL_DESC_PLATFORM_FEATURE:
- {
- struct ia64_sal_desc_platform_feature *pf = (void *) p;
- sal_platform_features = pf->feature_mask;
- printk(KERN_INFO "SAL: Platform features ");
-
- if (pf->feature_mask & IA64_SAL_PLATFORM_FEATURE_BUS_LOCK)
- printk("BusLock ");
- if (pf->feature_mask & IA64_SAL_PLATFORM_FEATURE_IRQ_REDIR_HINT) {
- printk("IRQ_Redirection ");
-#ifdef CONFIG_SMP
- if (no_int_routing)
- smp_int_redirect &= ~SMP_IRQ_REDIRECTION;
- else
- smp_int_redirect |= SMP_IRQ_REDIRECTION;
-#endif
- }
- if (pf->feature_mask & IA64_SAL_PLATFORM_FEATURE_IPI_REDIR_HINT) {
- printk("IPI_Redirection ");
-#ifdef CONFIG_SMP
- if (no_int_routing)
- smp_int_redirect &= ~SMP_IPI_REDIRECTION;
- else
- smp_int_redirect |= SMP_IPI_REDIRECTION;
-#endif
- }
- if (pf->feature_mask & IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT)
- printk("ITC_Drift ");
- printk("\n");
- break;
- }
-
+ case SAL_DESC_AP_WAKEUP:
+ sal_desc_ap_wakeup(p);
+ break;
}
p += SAL_DESC_SIZE(*p);
}
+}
+
+/**
+ * sal_check_revision - Check the revision of the SAL spec supported by firmware
+ * @major: The major number of the SAL spec
+ * @minor: The minor number of the SAL spec
+ *
+ * This function returns 1 if the SAL implementation on this machine
+ * supports the required revision. Use it as:
+ *
+ * if (sal_check_revision(3, 2)) { ... }
+ */
+int sal_check_revision(int major, int minor)
+{
+ if (major < sal_rev_major)
+ return 1;
+ if (major > sal_rev_major)
+ return 0;
+ return (minor <= sal_rev_minor);
+}
+
+/**
+ * sal_check_version - Check what version of SAL is installed
+ * @major: The major number of the implementation
+ * @minor: The minor number of the implementation
+ *
+ * This function returns 1 if the version of the implementation of SAL is
+ * equal or higher than the required version. You can only use this function
+ * if you already know what manufacturer your SAL comes from as every vendor
+ * may have a different version.
+ */
+int sal_check_version(int major, int minor)
+{
+ if (major < sal_b_rev_major)
+ return 1;
+ if (major > sal_b_rev_major)
+ return 0;
+ return (minor <= sal_b_rev_minor);
}
Index: include/asm-ia64/sal.h
=================================RCS file: /var/cvs/linux-2.6/include/asm-ia64/sal.h,v
retrieving revision 1.4
diff -u -p -r1.4 sal.h
--- a/include/asm-ia64/sal.h 7 Jan 2004 21:30:42 -0000 1.4
+++ b/include/asm-ia64/sal.h 26 Feb 2004 22:02:31 -0000
@@ -231,6 +231,8 @@ extern struct ia64_sal_desc_ptc *ia64_pt
extern const char *ia64_sal_strerror (long status);
extern void ia64_sal_init (struct ia64_sal_systab *sal_systab);
+extern int sal_check_revision(int major, int minor);
+extern int sal_check_version(int major, int minor);
/* SAL information type encodings */
enum {
@@ -741,10 +743,10 @@ ia64_sal_mc_set_params (u64 param_type,
/* Read from PCI configuration space */
static inline s64
-ia64_sal_pci_config_read (u64 pci_config_addr, u64 size, u64 *value)
+ia64_sal_pci_config_read (u64 pci_config_addr, u64 size, u64 *value, int type)
{
struct ia64_sal_retval isrv;
- SAL_CALL(isrv, SAL_PCI_CONFIG_READ, pci_config_addr, size, 0, 0, 0, 0, 0);
+ SAL_CALL(isrv, SAL_PCI_CONFIG_READ, pci_config_addr, size, type, 0, 0, 0, 0);
if (value)
*value = isrv.v0;
return isrv.status;
@@ -752,11 +754,11 @@ ia64_sal_pci_config_read (u64 pci_config
/* Write to PCI configuration space */
static inline s64
-ia64_sal_pci_config_write (u64 pci_config_addr, u64 size, u64 value)
+ia64_sal_pci_config_write (u64 pci_config_addr, u64 size, u64 value, int type)
{
struct ia64_sal_retval isrv;
SAL_CALL(isrv, SAL_PCI_CONFIG_WRITE, pci_config_addr, size, value,
- 0, 0, 0, 0);
+ type, 0, 0, 0);
return isrv.status;
}
--
"Next the statesmen will invent cheap lies, putting the blame upon
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince
himself that the war is just, and will thank God for the better sleep
he enjoys after this process of grotesque self-deception." -- Mark Twain
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH] sal cleanup
2004-02-26 21:37 [PATCH] sal cleanup Matthew Wilcox
2004-02-26 21:55 ` David Mosberger
2004-02-26 22:04 ` Matthew Wilcox
@ 2004-02-27 18:52 ` David Mosberger
2004-02-27 19:24 ` Matthew Wilcox
` (17 subsequent siblings)
20 siblings, 0 replies; 22+ messages in thread
From: David Mosberger @ 2004-02-27 18:52 UTC (permalink / raw)
To: linux-ia64
>>>>> On Thu, 26 Feb 2004 22:04:56 +0000, Matthew Wilcox <willy@debian.org> said:
Matthew> On Thu, Feb 26, 2004 at 01:55:34PM -0800, David Mosberger
Matthew> wrote:
>> How about printing "none" or something like that instead?
Matthew> Sure.
Matthew> This patch reorganises sal.c and adds two new functions:
Matthew> - Split the body of the switch statement in
Matthew> ia64_sal_init() into separate functions. - Delete min/max
Matthew> since they were only assigned to, never used. - Print the
Matthew> version of the SAL implementation as well as the spec
Matthew> version it supports. - Stop printing the pal_proc and
Matthew> sal_proc entry addresses. - Print "none" if there are no
Matthew> platform features. - Remember the sal revision and version
Matthew> and add two functions to compare them.
The patch also changes the arguments for ia64_sal_pci_config_read()
and ia64_sal_pci_config_write(), without changing any callers.
Why?
Also, how about putting a colon after "SAL Platform features"?
--david
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH] sal cleanup
2004-02-26 21:37 [PATCH] sal cleanup Matthew Wilcox
` (2 preceding siblings ...)
2004-02-27 18:52 ` David Mosberger
@ 2004-02-27 19:24 ` Matthew Wilcox
2004-02-27 19:33 ` David Mosberger
` (16 subsequent siblings)
20 siblings, 0 replies; 22+ messages in thread
From: Matthew Wilcox @ 2004-02-27 19:24 UTC (permalink / raw)
To: linux-ia64
On Fri, Feb 27, 2004 at 10:52:46AM -0800, David Mosberger wrote:
> The patch also changes the arguments for ia64_sal_pci_config_read()
> and ia64_sal_pci_config_write(), without changing any callers.
> Why?
Because I made a mistake; I intended to delete that part from that patch.
It's part of the [3/4] patch I sent you earlier today.
> Also, how about putting a colon after "SAL Platform features"?
Sure. While we're nitpicking, how about deleting the 'oem=' and `product='
from the printk? It currently looks like:
SAL 3.1: oem=HP, product=, version 2.21
How about instead it reading
SAL 3.1: HP version 2.21
(if we filled in the product field, it'd read something like
SAL 3.1: HP rx2600 version 2.21
)
--
"Next the statesmen will invent cheap lies, putting the blame upon
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince
himself that the war is just, and will thank God for the better sleep
he enjoys after this process of grotesque self-deception." -- Mark Twain
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH] sal cleanup
2004-02-26 21:37 [PATCH] sal cleanup Matthew Wilcox
` (3 preceding siblings ...)
2004-02-27 19:24 ` Matthew Wilcox
@ 2004-02-27 19:33 ` David Mosberger
2004-02-27 20:25 ` Matthew Wilcox
` (15 subsequent siblings)
20 siblings, 0 replies; 22+ messages in thread
From: David Mosberger @ 2004-02-27 19:33 UTC (permalink / raw)
To: linux-ia64
>>>>> On Fri, 27 Feb 2004 19:24:59 +0000, Matthew Wilcox <willy@debian.org> said:
Matthew> Sure. While we're nitpicking, how about deleting the
Matthew> 'oem=' and `product=' from the printk? It currently looks
Matthew> like:
Matthew> SAL 3.1: oem=HP, product=, version 2.21
Matthew> How about instead it reading
Matthew> SAL 3.1: HP version 2.21
Matthew> (if we filled in the product field, it'd read something
Matthew> like SAL 3.1: HP rx2600 version 2.21 )
Sounds good to me. The extra blank kills me though... ;-)
--david
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH] sal cleanup
2004-02-26 21:37 [PATCH] sal cleanup Matthew Wilcox
` (4 preceding siblings ...)
2004-02-27 19:33 ` David Mosberger
@ 2004-02-27 20:25 ` Matthew Wilcox
2004-02-27 21:48 ` Randy.Dunlap
` (14 subsequent siblings)
20 siblings, 0 replies; 22+ messages in thread
From: Matthew Wilcox @ 2004-02-27 20:25 UTC (permalink / raw)
To: linux-ia64
On Fri, Feb 27, 2004 at 11:33:36AM -0800, David Mosberger wrote:
> Sounds good to me. The extra blank kills me though... ;-)
Weeeeeelllllllll.... if you're not allergic to trigraphs,
printk(KERN_INFO "SAL %d.%d: %.32s %.32s%sversion %d.%d\n",
sal_rev_major, sal_rev_minor, systab->oem_id,
systab->product_id, systab->product_id[0] ? " " : "",
sal_b_rev_major, sal_b_rev_minor);
does the trick nicely ;-)
I'll send a patch when you've come to a decision about how you want the
SAL revision comparison to look -- it all touches the same area of code.
--
"Next the statesmen will invent cheap lies, putting the blame upon
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince
himself that the war is just, and will thank God for the better sleep
he enjoys after this process of grotesque self-deception." -- Mark Twain
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH] sal cleanup
2004-02-26 21:37 [PATCH] sal cleanup Matthew Wilcox
` (5 preceding siblings ...)
2004-02-27 20:25 ` Matthew Wilcox
@ 2004-02-27 21:48 ` Randy.Dunlap
2004-02-27 22:09 ` David Mosberger
` (13 subsequent siblings)
20 siblings, 0 replies; 22+ messages in thread
From: Randy.Dunlap @ 2004-02-27 21:48 UTC (permalink / raw)
To: linux-ia64
On Fri, 27 Feb 2004 20:25:05 +0000 Matthew Wilcox wrote:
| On Fri, Feb 27, 2004 at 11:33:36AM -0800, David Mosberger wrote:
| > Sounds good to me. The extra blank kills me though... ;-)
|
| Weeeeeelllllllll.... if you're not allergic to trigraphs,
|
| printk(KERN_INFO "SAL %d.%d: %.32s %.32s%sversion %d.%d\n",
| sal_rev_major, sal_rev_minor, systab->oem_id,
| systab->product_id, systab->product_id[0] ? " " : "",
| sal_b_rev_major, sal_b_rev_minor);
|
| does the trick nicely ;-)
|
| I'll send a patch when you've come to a decision about how you want the
| SAL revision comparison to look -- it all touches the same area of code.
Where's the trigraph???
A conditional operator ("?:") [section 6.5.15 of C99 spec.]
does not make a 'trigraph'.
Conditional operators are fine IMO, so long as the gcc extension of
"omitted second operand implies repeat the first operand" is not used... :)
This is ugly and prone to mistakes.
--
~Randy
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH] sal cleanup
2004-02-26 21:37 [PATCH] sal cleanup Matthew Wilcox
` (6 preceding siblings ...)
2004-02-27 21:48 ` Randy.Dunlap
@ 2004-02-27 22:09 ` David Mosberger
2004-02-27 22:42 ` Matthew Wilcox
` (12 subsequent siblings)
20 siblings, 0 replies; 22+ messages in thread
From: David Mosberger @ 2004-02-27 22:09 UTC (permalink / raw)
To: linux-ia64
>>>>> On Fri, 27 Feb 2004 13:48:50 -0800, "Randy.Dunlap" <rddunlap@osdl.org> said:
Randy> Where's the trigraph???
Thanks, you just saved me some typing... ;-)
(Trigraphs are a really ugly way to type curly braces and stuff like
that for people who have keyboards without a curly brace key etc.)
Randy> A conditional operator ("?:") [section 6.5.15 of C99 spec.]
Randy> does not make a 'trigraph'.
Randy> Conditional operators are fine IMO, so long as the gcc
Randy> extension of "omitted second operand implies repeat the first
Randy> operand" is not used... :) This is ugly and prone to
Randy> mistakes.
Agreed. The patched looked perfectly fine to me.
--david
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH] sal cleanup
2004-02-26 21:37 [PATCH] sal cleanup Matthew Wilcox
` (7 preceding siblings ...)
2004-02-27 22:09 ` David Mosberger
@ 2004-02-27 22:42 ` Matthew Wilcox
2004-02-27 23:02 ` David Mosberger
` (11 subsequent siblings)
20 siblings, 0 replies; 22+ messages in thread
From: Matthew Wilcox @ 2004-02-27 22:42 UTC (permalink / raw)
To: linux-ia64
On Fri, Feb 27, 2004 at 02:09:29PM -0800, David Mosberger wrote:
> >>>>> On Fri, 27 Feb 2004 13:48:50 -0800, "Randy.Dunlap" <rddunlap@osdl.org> said:
>
> Randy> Where's the trigraph???
>
> Thanks, you just saved me some typing... ;-)
> (Trigraphs are a really ugly way to type curly braces and stuff like
> that for people who have keyboards without a curly brace key etc.)
Oh, I don't know??! For some reason I'd thought that ?: was called a
digraph and then confused it with trigraphs. I actually can't find a
name for the ?: operator in the C FAQ.
> Agreed. The patched looked perfectly fine to me.
Great ;-) Now make a decision on how you want SAL version testing to
work and I'll send you a patch.
--
"Next the statesmen will invent cheap lies, putting the blame upon
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince
himself that the war is just, and will thank God for the better sleep
he enjoys after this process of grotesque self-deception." -- Mark Twain
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH] sal cleanup
2004-02-26 21:37 [PATCH] sal cleanup Matthew Wilcox
` (8 preceding siblings ...)
2004-02-27 22:42 ` Matthew Wilcox
@ 2004-02-27 23:02 ` David Mosberger
2004-03-01 16:03 ` Matthew Wilcox
` (10 subsequent siblings)
20 siblings, 0 replies; 22+ messages in thread
From: David Mosberger @ 2004-02-27 23:02 UTC (permalink / raw)
To: linux-ia64
>>>>> On Fri, 27 Feb 2004 22:42:15 +0000, Matthew Wilcox <willy@debian.org> said:
Matthew> I actually can't find a name for the ?: operator in the C
Matthew> FAQ.
conditional expression?
Matthew> Great ;-) Now make a decision on how you want SAL version
Matthew> testing to work and I'll send you a patch.
I'd really prefer sal_revision() combined with a SAL_VERSION() macro.
I can just look at that and intuitively understand what it's doing
(especially given the symmetry with the LINUX_VERSION macros), whereas
with the sal_version_check() function, I have to go look at it's
definition.
Thanks,
--david
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH] sal cleanup
2004-02-26 21:37 [PATCH] sal cleanup Matthew Wilcox
` (9 preceding siblings ...)
2004-02-27 23:02 ` David Mosberger
@ 2004-03-01 16:03 ` Matthew Wilcox
2004-03-01 16:05 ` Matthew Wilcox
` (9 subsequent siblings)
20 siblings, 0 replies; 22+ messages in thread
From: Matthew Wilcox @ 2004-03-01 16:03 UTC (permalink / raw)
To: linux-ia64
On Fri, Feb 27, 2004 at 03:02:06PM -0800, David Mosberger wrote:
> >>>>> On Fri, 27 Feb 2004 22:42:15 +0000, Matthew Wilcox <willy@debian.org> said:
>
> Matthew> I actually can't find a name for the ?: operator in the C
> Matthew> FAQ.
>
> conditional expression?
I remembered I had a copy of the C99 spec ... 6.5.15 calls it the
"conditional operator". I also found a document calling it the "ternary
operator".
> I'd really prefer sal_revision() combined with a SAL_VERSION() macro.
> I can just look at that and intuitively understand what it's doing
> (especially given the symmetry with the LINUX_VERSION macros), whereas
> with the sal_version_check() function, I have to go look at it's
> definition.
Okey dokey, done. I'll send it as a separate message to keep the
?:??! discussion out of the changelog ;-)
--
"Next the statesmen will invent cheap lies, putting the blame upon
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince
himself that the war is just, and will thank God for the better sleep
he enjoys after this process of grotesque self-deception." -- Mark Twain
^ permalink raw reply [flat|nested] 22+ messages in thread* [PATCH] sal cleanup
2004-02-26 21:37 [PATCH] sal cleanup Matthew Wilcox
` (10 preceding siblings ...)
2004-03-01 16:03 ` Matthew Wilcox
@ 2004-03-01 16:05 ` Matthew Wilcox
2004-03-02 1:30 ` David Mosberger
` (8 subsequent siblings)
20 siblings, 0 replies; 22+ messages in thread
From: Matthew Wilcox @ 2004-03-01 16:05 UTC (permalink / raw)
To: linux-ia64
This patch reorganises sal.c and adds a small amount of new functionality.
- Introduce sal_revision to report what revision of the SAL spec is
supported by the system.
- Introduce sal_version to report what version of the vendor's SAL
implementation is present.
- Introduce SAL_VERSION_CODE to allow for easy comparisons.
- Print the version at boot, and remove the 'oem=' and 'vendor=' strings.
- Refactor ia64_sal_init() into several smaller functions.
- Delete the dead variables 'max' and 'min'.
- Stop printing the pal_proc and sal_proc entry addresses.
- Print "None" if there are no SAL platform features.
Index: arch/ia64/kernel/sal.c
=================================RCS file: /var/cvs/linux-2.6/arch/ia64/kernel/sal.c,v
retrieving revision 1.2
diff -u -p -r1.2 sal.c
--- a/arch/ia64/kernel/sal.c 28 Feb 2004 01:49:51 -0000 1.2
+++ b/arch/ia64/kernel/sal.c 1 Mar 2004 15:34:04 -0000
@@ -10,7 +10,6 @@
#include <linux/kernel.h>
#include <linux/init.h>
-#include <linux/smp.h>
#include <linux/spinlock.h>
#include <linux/string.h>
@@ -21,6 +20,12 @@
spinlock_t sal_lock __cacheline_aligned = SPIN_LOCK_UNLOCKED;
unsigned long sal_platform_features;
+unsigned short sal_revision;
+unsigned short sal_version;
+
+#define SAL_MAJOR(x) ((x) >> 8)
+#define SAL_MINOR(x) ((x) & 0xff)
+
static struct {
void *addr; /* function entry point */
void *gpval; /* gp value to use */
@@ -86,13 +91,75 @@ ia64_sal_handler_init (void *entry_point
ia64_sal = (ia64_sal_handler) &pdesc;
}
+static void __init sal_desc_entry_point(void *p)
+{
+ struct ia64_sal_desc_entry_point *ep = p;
+ ia64_pal_handler_init(__va(ep->pal_proc));
+ ia64_sal_handler_init(__va(ep->sal_proc), __va(ep->gp));
+}
+
+#ifdef CONFIG_SMP
+static void __init set_smp_redirect(int flag)
+{
+ if (no_int_routing)
+ smp_int_redirect &= ~flag;
+ else
+ smp_int_redirect |= flag;
+}
+#else
+static void __init set_smp_redirect(int flag) { }
+#endif
+
+static void __init sal_desc_platform_feature(void *p)
+{
+ struct ia64_sal_desc_platform_feature *pf = p;
+ sal_platform_features = pf->feature_mask;
+
+ printk(KERN_INFO "SAL Platform features:");
+ if (!sal_platform_features) {
+ printk(" None\n");
+ return;
+ }
+
+ if (sal_platform_features & IA64_SAL_PLATFORM_FEATURE_BUS_LOCK)
+ printk(" BusLock");
+ if (sal_platform_features & IA64_SAL_PLATFORM_FEATURE_IRQ_REDIR_HINT) {
+ printk(" IRQ_Redirection");
+ set_smp_redirect(SMP_IRQ_REDIRECTION);
+ }
+ if (sal_platform_features & IA64_SAL_PLATFORM_FEATURE_IPI_REDIR_HINT) {
+ printk(" IPI_Redirection");
+ set_smp_redirect(SMP_IPI_REDIRECTION);
+ }
+ if (sal_platform_features & IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT)
+ printk(" ITC_Drift");
+ printk("\n");
+}
+
+#ifdef CONFIG_SMP
+static void __init sal_desc_ap_wakeup(void *p)
+{
+ struct ia64_sal_desc_ap_wakeup *ap = p;
+
+ switch (ap->mechanism) {
+ case IA64_SAL_AP_EXTERNAL_INT:
+ ap_wakeup_vector = ap->vector;
+ printk(KERN_INFO "SAL: AP wakeup using external interrupt "
+ "vector 0x%lx\n", ap_wakeup_vector);
+ break;
+ default:
+ printk(KERN_ERR "SAL: AP wakeup mechanism unsupported!\n");
+ break;
+ }
+}
+#else
+static void __init sal_desc_ap_wakeup(void *p) { }
+#endif
void __init
ia64_sal_init (struct ia64_sal_systab *systab)
{
- unsigned long min, max;
char *p;
- struct ia64_sal_desc_entry_point *ep;
int i;
if (!systab) {
@@ -103,85 +170,35 @@ ia64_sal_init (struct ia64_sal_systab *s
if (strncmp(systab->signature, "SST_", 4) != 0)
printk(KERN_ERR "bad signature in system table!");
- /*
- * revisions are coded in BCD, so %x does the job for us
- */
- printk(KERN_INFO "SAL v%x.%x: oem=%.32s, product=%.32s\n",
- systab->sal_rev_major, systab->sal_rev_minor,
- systab->oem_id, systab->product_id);
+ sal_revision = (systab->sal_rev_major << 8) | systab->sal_rev_minor;
+ sal_version = (systab->sal_b_rev_major << 8) | systab->sal_b_rev_minor;
- min = ~0UL;
- max = 0;
+ /* revisions are coded in BCD, so %x does the job for us */
+ printk(KERN_INFO "SAL %x.%x: %.32s %.32s%sversion %x.%x\n",
+ SAL_MAJOR(sal_revision), SAL_MINOR(sal_revision),
+ systab->oem_id, systab->product_id,
+ systab->product_id[0] ? " " : "",
+ SAL_MAJOR(sal_version), SAL_MINOR(sal_version));
p = (char *) (systab + 1);
for (i = 0; i < systab->entry_count; i++) {
/*
- * The first byte of each entry type contains the type descriptor.
+ * The first byte of each entry type contains the type
+ * descriptor.
*/
switch (*p) {
- case SAL_DESC_ENTRY_POINT:
- ep = (struct ia64_sal_desc_entry_point *) p;
- printk(KERN_INFO "SAL: entry: pal_proc=0x%lx, sal_proc=0x%lx\n",
- ep->pal_proc, ep->sal_proc);
- ia64_pal_handler_init(__va(ep->pal_proc));
- ia64_sal_handler_init(__va(ep->sal_proc), __va(ep->gp));
+ case SAL_DESC_ENTRY_POINT:
+ sal_desc_entry_point(p);
break;
-
- case SAL_DESC_PTC:
+ case SAL_DESC_PLATFORM_FEATURE:
+ sal_desc_platform_feature(p);
+ break;
+ case SAL_DESC_PTC:
ia64_ptc_domain_info = (ia64_sal_desc_ptc_t *)p;
break;
-
- case SAL_DESC_AP_WAKEUP:
-#ifdef CONFIG_SMP
- {
- struct ia64_sal_desc_ap_wakeup *ap = (void *) p;
-
- switch (ap->mechanism) {
- case IA64_SAL_AP_EXTERNAL_INT:
- ap_wakeup_vector = ap->vector;
- printk(KERN_INFO "SAL: AP wakeup using external interrupt "
- "vector 0x%lx\n", ap_wakeup_vector);
- break;
-
- default:
- printk(KERN_ERR "SAL: AP wakeup mechanism unsupported!\n");
- break;
- }
- break;
- }
-#endif
- case SAL_DESC_PLATFORM_FEATURE:
- {
- struct ia64_sal_desc_platform_feature *pf = (void *) p;
- sal_platform_features = pf->feature_mask;
- printk(KERN_INFO "SAL: Platform features ");
-
- if (pf->feature_mask & IA64_SAL_PLATFORM_FEATURE_BUS_LOCK)
- printk("BusLock ");
- if (pf->feature_mask & IA64_SAL_PLATFORM_FEATURE_IRQ_REDIR_HINT) {
- printk("IRQ_Redirection ");
-#ifdef CONFIG_SMP
- if (no_int_routing)
- smp_int_redirect &= ~SMP_IRQ_REDIRECTION;
- else
- smp_int_redirect |= SMP_IRQ_REDIRECTION;
-#endif
- }
- if (pf->feature_mask & IA64_SAL_PLATFORM_FEATURE_IPI_REDIR_HINT) {
- printk("IPI_Redirection ");
-#ifdef CONFIG_SMP
- if (no_int_routing)
- smp_int_redirect &= ~SMP_IPI_REDIRECTION;
- else
- smp_int_redirect |= SMP_IPI_REDIRECTION;
-#endif
- }
- if (pf->feature_mask & IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT)
- printk("ITC_Drift ");
- printk("\n");
- break;
- }
-
+ case SAL_DESC_AP_WAKEUP:
+ sal_desc_ap_wakeup(p);
+ break;
}
p += SAL_DESC_SIZE(*p);
}
Index: include/asm-ia64/sal.h
=================================RCS file: /var/cvs/linux-2.6/include/asm-ia64/sal.h,v
retrieving revision 1.4
diff -u -p -r1.4 sal.h
--- a/include/asm-ia64/sal.h 7 Jan 2004 21:30:42 -0000 1.4
+++ b/include/asm-ia64/sal.h 1 Mar 2004 15:34:07 -0000
@@ -35,6 +35,7 @@
#ifndef __ASSEMBLY__
+#include <linux/bcd.h>
#include <linux/spinlock.h>
#include <linux/efi.h>
@@ -229,6 +230,10 @@ typedef struct ia64_sal_desc_ap_wakeup {
extern ia64_sal_handler ia64_sal;
extern struct ia64_sal_desc_ptc *ia64_ptc_domain_info;
+extern unsigned short sal_revision; /* supported SAL spec revision */
+extern unsigned short sal_version; /* SAL version; OEM dependent */
+#define SAL_VERSION_CODE(major, minor) ((BIN2BCD(major) << 8) | BIN2BCD(minor))
+
extern const char *ia64_sal_strerror (long status);
extern void ia64_sal_init (struct ia64_sal_systab *sal_systab);
--
"Next the statesmen will invent cheap lies, putting the blame upon
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince
himself that the war is just, and will thank God for the better sleep
he enjoys after this process of grotesque self-deception." -- Mark Twain
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH] sal cleanup
2004-02-26 21:37 [PATCH] sal cleanup Matthew Wilcox
` (11 preceding siblings ...)
2004-03-01 16:05 ` Matthew Wilcox
@ 2004-03-02 1:30 ` David Mosberger
2004-03-02 7:46 ` David Mosberger
` (7 subsequent siblings)
20 siblings, 0 replies; 22+ messages in thread
From: David Mosberger @ 2004-03-02 1:30 UTC (permalink / raw)
To: linux-ia64
>>>>> On Mon, 1 Mar 2004 16:05:32 +0000, Matthew Wilcox <willy@debian.org> said:
Matthew> This patch reorganises sal.c and adds a small amount of new
Matthew> functionality.
The patch breaks UP kernels because SMP_IRQ_REDIRECTION and SMP_IPI_REDIRECTION
aren't defined for UP kernels.
--david
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH] sal cleanup
2004-02-26 21:37 [PATCH] sal cleanup Matthew Wilcox
` (12 preceding siblings ...)
2004-03-02 1:30 ` David Mosberger
@ 2004-03-02 7:46 ` David Mosberger
2004-03-02 15:56 ` Matthew Wilcox
` (6 subsequent siblings)
20 siblings, 0 replies; 22+ messages in thread
From: David Mosberger @ 2004-03-02 7:46 UTC (permalink / raw)
To: linux-ia64
Well, this patch is giving me lots of grief. It appears that old
(prototype) zx1 systems report a huge SAL version:
SAL 49.29: INTEL MSL REF SAL version 49.29
Unfortunately, the hardware is too old to upgrade to newer firmware,
yet the hardware is good enough to be useful. Perhaps we could have a
command-line option to override the SAL version?
--david
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH] sal cleanup
2004-02-26 21:37 [PATCH] sal cleanup Matthew Wilcox
` (13 preceding siblings ...)
2004-03-02 7:46 ` David Mosberger
@ 2004-03-02 15:56 ` Matthew Wilcox
2004-03-02 16:00 ` Matthew Wilcox
` (5 subsequent siblings)
20 siblings, 0 replies; 22+ messages in thread
From: Matthew Wilcox @ 2004-03-02 15:56 UTC (permalink / raw)
To: linux-ia64
On Mon, Mar 01, 2004 at 11:46:22PM -0800, David Mosberger wrote:
> Well, this patch is giving me lots of grief. It appears that old
> (prototype) zx1 systems report a huge SAL version:
>
> SAL 49.29: INTEL MSL REF SAL version 49.29
>
> Unfortunately, the hardware is too old to upgrade to newer firmware,
> yet the hardware is good enough to be useful. Perhaps we could have a
> command-line option to override the SAL version?
I don't have an objection to doing that, but how about making it Just
Work for this particular case? Something like ..
static void check_versions(struct ia64_sal_systab *systab)
{
sal_revision = (systab->sal_rev_major << 8) | systab->sal_rev_minor;
sal_version = (systab->sal_b_rev_major << 8) | systab->sal_b_rev_minor;
/* Check for broken firmware */
if ((sal_revision = SAL_VERSION_CODE(49, 29)) &&
(sal_version = SAL_VERSION_CODE(49, 29))) {
sal_revision = SAL_VERSION_CODE(2, 8);
sal_version = SAL_VERSION_CODE(0, 0);
}
}
...
if (strncmp(systab->signature, "SST_", 4) != 0)
printk(KERN_ERR "bad signature in system table!");
check_versions(systab);
/* revisions are coded in BCD, so %x does the job for us */
printk(KERN_INFO "SAL %x.%x: %.32s %.32s%sversion %x.%x\n",
...
SAL rev 2.8 was published in January 2000. It should be safe to claim
compliance with this. The version number change I'm not 100% sure of,
but it seems better than leaving it too high.
(I note this fix shows the wisdom of going with the SAL_VERSION_CODE
option. Good call.)
--
"Next the statesmen will invent cheap lies, putting the blame upon
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince
himself that the war is just, and will thank God for the better sleep
he enjoys after this process of grotesque self-deception." -- Mark Twain
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH] sal cleanup
2004-02-26 21:37 [PATCH] sal cleanup Matthew Wilcox
` (14 preceding siblings ...)
2004-03-02 15:56 ` Matthew Wilcox
@ 2004-03-02 16:00 ` Matthew Wilcox
2004-03-02 17:42 ` David Mosberger
` (4 subsequent siblings)
20 siblings, 0 replies; 22+ messages in thread
From: Matthew Wilcox @ 2004-03-02 16:00 UTC (permalink / raw)
To: linux-ia64
On Mon, Mar 01, 2004 at 05:30:18PM -0800, David Mosberger wrote:
> >>>>> On Mon, 1 Mar 2004 16:05:32 +0000, Matthew Wilcox <willy@debian.org> said:
>
> Matthew> This patch reorganises sal.c and adds a small amount of new
> Matthew> functionality.
>
> The patch breaks UP kernels because SMP_IRQ_REDIRECTION and SMP_IPI_REDIRECTION
> aren't defined for UP kernels.
Ack, sorry. I'll change them to #defines.
--
"Next the statesmen will invent cheap lies, putting the blame upon
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince
himself that the war is just, and will thank God for the better sleep
he enjoys after this process of grotesque self-deception." -- Mark Twain
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH] sal cleanup
2004-02-26 21:37 [PATCH] sal cleanup Matthew Wilcox
` (15 preceding siblings ...)
2004-03-02 16:00 ` Matthew Wilcox
@ 2004-03-02 17:42 ` David Mosberger
2004-03-02 17:57 ` Matthew Wilcox
` (3 subsequent siblings)
20 siblings, 0 replies; 22+ messages in thread
From: David Mosberger @ 2004-03-02 17:42 UTC (permalink / raw)
To: linux-ia64
>>>>> On Tue, 2 Mar 2004 15:56:01 +0000, Matthew Wilcox <willy@debian.org> said:
Matthew> I don't have an objection to doing that, but how about
Matthew> making it Just Work for this particular case? Something
Matthew> like ..
Well, that would be more convenient for me, but I don't know how many
other "strange" SAL version numbers are out there in the wild. It's
can be handy to have an override option when dealing with buggy
firmware (fortunately, quite rare with production systems, but it's
all to common with prototypes).
Just a caveat:
Matthew> SAL_VERSION_CODE(49, 29)
shouldn't these be in hex?
--david
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH] sal cleanup
2004-02-26 21:37 [PATCH] sal cleanup Matthew Wilcox
` (16 preceding siblings ...)
2004-03-02 17:42 ` David Mosberger
@ 2004-03-02 17:57 ` Matthew Wilcox
2004-03-02 18:01 ` David Mosberger
` (2 subsequent siblings)
20 siblings, 0 replies; 22+ messages in thread
From: Matthew Wilcox @ 2004-03-02 17:57 UTC (permalink / raw)
To: linux-ia64
On Tue, Mar 02, 2004 at 09:42:33AM -0800, David Mosberger wrote:
> >>>>> On Tue, 2 Mar 2004 15:56:01 +0000, Matthew Wilcox <willy@debian.org> said:
>
> Matthew> I don't have an objection to doing that, but how about
> Matthew> making it Just Work for this particular case? Something
> Matthew> like ..
>
> Well, that would be more convenient for me, but I don't know how many
> other "strange" SAL version numbers are out there in the wild. It's
> can be handy to have an override option when dealing with buggy
> firmware (fortunately, quite rare with production systems, but it's
> all to common with prototypes).
Yeah. That's why I moved it into a separate function so we can add
other bad version numbers. If we were really keen, we could even add a
check for the oem and product IDs matching, or a data table of known-bad
BIOSes but let's keep it simple until we have to make it complex.
> Just a caveat:
>
> Matthew> SAL_VERSION_CODE(49, 29)
>
> shouldn't these be in hex?
Nope, that's the beauty of it:
#define SAL_VERSION_CODE(major, minor) ((BIN2BCD(major) << 8) | BIN2BCD(minor))
BIN2BCD is defined in linux/bcd.h as ((((val)/10)<<4) + (val)%10)
So you get to specify things in decimal.
--
"Next the statesmen will invent cheap lies, putting the blame upon
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince
himself that the war is just, and will thank God for the better sleep
he enjoys after this process of grotesque self-deception." -- Mark Twain
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH] sal cleanup
2004-02-26 21:37 [PATCH] sal cleanup Matthew Wilcox
` (17 preceding siblings ...)
2004-03-02 17:57 ` Matthew Wilcox
@ 2004-03-02 18:01 ` David Mosberger
2004-03-02 19:25 ` Matthew Wilcox
2004-03-03 2:53 ` David Mosberger
20 siblings, 0 replies; 22+ messages in thread
From: David Mosberger @ 2004-03-02 18:01 UTC (permalink / raw)
To: linux-ia64
>>>>> On Tue, 2 Mar 2004 17:57:01 +0000, Matthew Wilcox <willy@debian.org> said:
Matthew> Yeah. That's why I moved it into a separate function so we
Matthew> can add other bad version numbers. If we were really keen,
Matthew> we could even add a check for the oem and product IDs
Matthew> matching, or a data table of known-bad BIOSes but let's
Matthew> keep it simple until we have to make it complex.
Well, I can live with either approach, so it's your call. It's just that
a command-line option can come in handy when you're urgently trying to boot
a kernel and you can't rebuild a kernel (like when trying to demo a new
machine... ;-).
Matthew> SAL_VERSION_CODE(49, 29)
>> shouldn't these be in hex?
Matthew> Nope, that's the beauty of it:
Matthew> #define SAL_VERSION_CODE(major, minor) ((BIN2BCD(major) <<
Matthew> 8) | BIN2BCD(minor))
Matthew> BIN2BCD is defined in linux/bcd.h as ((((val)/10)<<4) +
Matthew> (val)%10)
Matthew> So you get to specify things in decimal.
Ah, I missed that. Nice.
--daivd
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH] sal cleanup
2004-02-26 21:37 [PATCH] sal cleanup Matthew Wilcox
` (18 preceding siblings ...)
2004-03-02 18:01 ` David Mosberger
@ 2004-03-02 19:25 ` Matthew Wilcox
2004-03-03 2:53 ` David Mosberger
20 siblings, 0 replies; 22+ messages in thread
From: Matthew Wilcox @ 2004-03-02 19:25 UTC (permalink / raw)
To: linux-ia64
This patch reorganises sal.c and adds a small amount of new functionality.
- Introduce sal_revision to report what revision of the SAL spec is
supported by the system.
- Introduce sal_version to report what version of the vendor's SAL
implementation is present.
- Introduce SAL_VERSION_CODE to allow for easy comparisons.
- Print the version at boot, and remove the 'oem=' and 'vendor=' strings.
- Fix the revision if we have a known-bad firmware version.
- Refactor ia64_sal_init() into several smaller functions.
- Delete the dead variables 'max' and 'min'.
- Stop printing the pal_proc and sal_proc entry addresses.
- Print "None" if there are no SAL platform features.
Index: arch/ia64/kernel/sal.c
=================================RCS file: /var/cvs/linux-2.6/arch/ia64/kernel/sal.c,v
retrieving revision 1.2
diff -u -p -r1.2 sal.c
--- a/arch/ia64/kernel/sal.c 28 Feb 2004 01:49:51 -0000 1.2
+++ b/arch/ia64/kernel/sal.c 2 Mar 2004 18:36:42 -0000
@@ -21,6 +21,12 @@
spinlock_t sal_lock __cacheline_aligned = SPIN_LOCK_UNLOCKED;
unsigned long sal_platform_features;
+unsigned short sal_revision;
+unsigned short sal_version;
+
+#define SAL_MAJOR(x) ((x) >> 8)
+#define SAL_MINOR(x) ((x) & 0xff)
+
static struct {
void *addr; /* function entry point */
void *gpval; /* gp value to use */
@@ -86,13 +92,88 @@ ia64_sal_handler_init (void *entry_point
ia64_sal = (ia64_sal_handler) &pdesc;
}
+static void check_versions(struct ia64_sal_systab *systab)
+{
+ sal_revision = (systab->sal_rev_major << 8) | systab->sal_rev_minor;
+ sal_version = (systab->sal_b_rev_major << 8) | systab->sal_b_rev_minor;
+
+ /* Check for broken firmware */
+ if ((sal_revision = SAL_VERSION_CODE(49, 29)) &&
+ (sal_version = SAL_VERSION_CODE(49, 29))) {
+ sal_revision = SAL_VERSION_CODE(2, 8);
+ sal_version = SAL_VERSION_CODE(0, 0);
+ }
+}
+
+static void __init sal_desc_entry_point(void *p)
+{
+ struct ia64_sal_desc_entry_point *ep = p;
+ ia64_pal_handler_init(__va(ep->pal_proc));
+ ia64_sal_handler_init(__va(ep->sal_proc), __va(ep->gp));
+}
+
+#ifdef CONFIG_SMP
+static void __init set_smp_redirect(int flag)
+{
+ if (no_int_routing)
+ smp_int_redirect &= ~flag;
+ else
+ smp_int_redirect |= flag;
+}
+#else
+#define set_smp_redirect(flag) do { } while (0)
+#endif
+
+static void __init sal_desc_platform_feature(void *p)
+{
+ struct ia64_sal_desc_platform_feature *pf = p;
+ sal_platform_features = pf->feature_mask;
+
+ printk(KERN_INFO "SAL Platform features:");
+ if (!sal_platform_features) {
+ printk(" None\n");
+ return;
+ }
+
+ if (sal_platform_features & IA64_SAL_PLATFORM_FEATURE_BUS_LOCK)
+ printk(" BusLock");
+ if (sal_platform_features & IA64_SAL_PLATFORM_FEATURE_IRQ_REDIR_HINT) {
+ printk(" IRQ_Redirection");
+ set_smp_redirect(SMP_IRQ_REDIRECTION);
+ }
+ if (sal_platform_features & IA64_SAL_PLATFORM_FEATURE_IPI_REDIR_HINT) {
+ printk(" IPI_Redirection");
+ set_smp_redirect(SMP_IPI_REDIRECTION);
+ }
+ if (sal_platform_features & IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT)
+ printk(" ITC_Drift");
+ printk("\n");
+}
+
+#ifdef CONFIG_SMP
+static void __init sal_desc_ap_wakeup(void *p)
+{
+ struct ia64_sal_desc_ap_wakeup *ap = p;
+
+ switch (ap->mechanism) {
+ case IA64_SAL_AP_EXTERNAL_INT:
+ ap_wakeup_vector = ap->vector;
+ printk(KERN_INFO "SAL: AP wakeup using external interrupt "
+ "vector 0x%lx\n", ap_wakeup_vector);
+ break;
+ default:
+ printk(KERN_ERR "SAL: AP wakeup mechanism unsupported!\n");
+ break;
+ }
+}
+#else
+static void __init sal_desc_ap_wakeup(void *p) { }
+#endif
void __init
ia64_sal_init (struct ia64_sal_systab *systab)
{
- unsigned long min, max;
char *p;
- struct ia64_sal_desc_entry_point *ep;
int i;
if (!systab) {
@@ -103,85 +184,34 @@ ia64_sal_init (struct ia64_sal_systab *s
if (strncmp(systab->signature, "SST_", 4) != 0)
printk(KERN_ERR "bad signature in system table!");
- /*
- * revisions are coded in BCD, so %x does the job for us
- */
- printk(KERN_INFO "SAL v%x.%x: oem=%.32s, product=%.32s\n",
- systab->sal_rev_major, systab->sal_rev_minor,
- systab->oem_id, systab->product_id);
+ check_versions(systab);
- min = ~0UL;
- max = 0;
+ /* revisions are coded in BCD, so %x does the job for us */
+ printk(KERN_INFO "SAL %x.%x: %.32s %.32s%sversion %x.%x\n",
+ SAL_MAJOR(sal_revision), SAL_MINOR(sal_revision),
+ systab->oem_id, systab->product_id,
+ systab->product_id[0] ? " " : "",
+ SAL_MAJOR(sal_version), SAL_MINOR(sal_version));
p = (char *) (systab + 1);
for (i = 0; i < systab->entry_count; i++) {
/*
- * The first byte of each entry type contains the type descriptor.
+ * The first byte of each entry type contains the type
+ * descriptor.
*/
switch (*p) {
- case SAL_DESC_ENTRY_POINT:
- ep = (struct ia64_sal_desc_entry_point *) p;
- printk(KERN_INFO "SAL: entry: pal_proc=0x%lx, sal_proc=0x%lx\n",
- ep->pal_proc, ep->sal_proc);
- ia64_pal_handler_init(__va(ep->pal_proc));
- ia64_sal_handler_init(__va(ep->sal_proc), __va(ep->gp));
+ case SAL_DESC_ENTRY_POINT:
+ sal_desc_entry_point(p);
break;
-
- case SAL_DESC_PTC:
+ case SAL_DESC_PLATFORM_FEATURE:
+ sal_desc_platform_feature(p);
+ break;
+ case SAL_DESC_PTC:
ia64_ptc_domain_info = (ia64_sal_desc_ptc_t *)p;
break;
-
- case SAL_DESC_AP_WAKEUP:
-#ifdef CONFIG_SMP
- {
- struct ia64_sal_desc_ap_wakeup *ap = (void *) p;
-
- switch (ap->mechanism) {
- case IA64_SAL_AP_EXTERNAL_INT:
- ap_wakeup_vector = ap->vector;
- printk(KERN_INFO "SAL: AP wakeup using external interrupt "
- "vector 0x%lx\n", ap_wakeup_vector);
- break;
-
- default:
- printk(KERN_ERR "SAL: AP wakeup mechanism unsupported!\n");
- break;
- }
- break;
- }
-#endif
- case SAL_DESC_PLATFORM_FEATURE:
- {
- struct ia64_sal_desc_platform_feature *pf = (void *) p;
- sal_platform_features = pf->feature_mask;
- printk(KERN_INFO "SAL: Platform features ");
-
- if (pf->feature_mask & IA64_SAL_PLATFORM_FEATURE_BUS_LOCK)
- printk("BusLock ");
- if (pf->feature_mask & IA64_SAL_PLATFORM_FEATURE_IRQ_REDIR_HINT) {
- printk("IRQ_Redirection ");
-#ifdef CONFIG_SMP
- if (no_int_routing)
- smp_int_redirect &= ~SMP_IRQ_REDIRECTION;
- else
- smp_int_redirect |= SMP_IRQ_REDIRECTION;
-#endif
- }
- if (pf->feature_mask & IA64_SAL_PLATFORM_FEATURE_IPI_REDIR_HINT) {
- printk("IPI_Redirection ");
-#ifdef CONFIG_SMP
- if (no_int_routing)
- smp_int_redirect &= ~SMP_IPI_REDIRECTION;
- else
- smp_int_redirect |= SMP_IPI_REDIRECTION;
-#endif
- }
- if (pf->feature_mask & IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT)
- printk("ITC_Drift ");
- printk("\n");
- break;
- }
-
+ case SAL_DESC_AP_WAKEUP:
+ sal_desc_ap_wakeup(p);
+ break;
}
p += SAL_DESC_SIZE(*p);
}
Index: include/asm-ia64/sal.h
=================================RCS file: /var/cvs/linux-2.6/include/asm-ia64/sal.h,v
retrieving revision 1.4
diff -u -p -r1.4 sal.h
--- a/include/asm-ia64/sal.h 7 Jan 2004 21:30:42 -0000 1.4
+++ b/include/asm-ia64/sal.h 2 Mar 2004 18:36:51 -0000
@@ -35,6 +35,7 @@
#ifndef __ASSEMBLY__
+#include <linux/bcd.h>
#include <linux/spinlock.h>
#include <linux/efi.h>
@@ -229,6 +230,10 @@ typedef struct ia64_sal_desc_ap_wakeup {
extern ia64_sal_handler ia64_sal;
extern struct ia64_sal_desc_ptc *ia64_ptc_domain_info;
+extern unsigned short sal_revision; /* supported SAL spec revision */
+extern unsigned short sal_version; /* SAL version; OEM dependent */
+#define SAL_VERSION_CODE(major, minor) ((BIN2BCD(major) << 8) | BIN2BCD(minor))
+
extern const char *ia64_sal_strerror (long status);
extern void ia64_sal_init (struct ia64_sal_systab *sal_systab);
--
"Next the statesmen will invent cheap lies, putting the blame upon
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince
himself that the war is just, and will thank God for the better sleep
he enjoys after this process of grotesque self-deception." -- Mark Twain
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH] sal cleanup
2004-02-26 21:37 [PATCH] sal cleanup Matthew Wilcox
` (19 preceding siblings ...)
2004-03-02 19:25 ` Matthew Wilcox
@ 2004-03-03 2:53 ` David Mosberger
20 siblings, 0 replies; 22+ messages in thread
From: David Mosberger @ 2004-03-03 2:53 UTC (permalink / raw)
To: linux-ia64
>>>>> On Tue, 2 Mar 2004 19:25:26 +0000, Matthew Wilcox <willy@debian.org> said:
Matthew> This patch reorganises sal.c and adds a small amount of new
Matthew> functionality.
I already had your earlier patch in my tree, so I merged the changes
by hand. Should show up in my bk repos shortly.
--david
^ permalink raw reply [flat|nested] 22+ messages in thread