* SAL version checking
@ 2004-02-23 21:01 Matthew Wilcox
2004-02-23 21:09 ` Jesse Barnes
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Matthew Wilcox @ 2004-02-23 21:01 UTC (permalink / raw)
To: linux-ia64
I need to check what version of SAL is available on the machine.
I didn't see a way to do this yet, so I'm writing one. My first attempt
was simply:
#define SAL_CHECK_VERSION(tab, major, minor) \
((tab->sal_rev_major > major) || \
((tab->sal_rev_major = major) && (tab->sal_rev_minor >= minor)))
which works except it requires callers to specify the version in hex
(and will work in 99% of cases if you don't ...) and requires the
caller to know that the SAL version is in sal_systab and sal_systab is
an EFI table. This is clearly suboptimal. Here's my current solution
(whitespace damaged :-P)
@@ -21,6 +21,8 @@
spinlock_t sal_lock __cacheline_aligned = SPIN_LOCK_UNLOCKED;
unsigned long sal_platform_features;
+static int sal_ver_major, sal_ver_minor;
+
static struct {
void *addr; /* function entry point */
void *gpval; /* gp value to use */
@@ -103,11 +105,13 @@ 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,
+ sal_rev_major = (systab->sal_rev_major / 16) * 10 +
+ systab->sal_rev_major % 16;
+ sal_rev_minor = (systab->sal_rev_minor / 16) * 10 +
+ systab->sal_rev_minor % 16;
+
+ printk(KERN_INFO "SAL v%d.%d: oem=%.32s, product=%.32s\n",
+ sal_rev_major, sal_rev_minor,
systab->oem_id, systab->product_id);
min = ~0UL;
@@ -185,4 +189,13 @@ ia64_sal_init (struct ia64_sal_systab *s
}
p += SAL_DESC_SIZE(*p);
}
+}
+
+int sal_check_version(int major, int minor)
+{
+ if (major < sal_rev_major)
+ return 1;
+ if (major > sal_rev_major)
+ return 0;
+ return (sal_rev_minor >= minor);
}
Anyone want to propose a different solution?
--
"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] 4+ messages in thread
* Re: SAL version checking
2004-02-23 21:01 SAL version checking Matthew Wilcox
@ 2004-02-23 21:09 ` Jesse Barnes
2004-02-23 21:21 ` Matthew Wilcox
2004-02-23 21:43 ` Jesse Barnes
2 siblings, 0 replies; 4+ messages in thread
From: Jesse Barnes @ 2004-02-23 21:09 UTC (permalink / raw)
To: linux-ia64
On Mon, Feb 23, 2004 at 09:01:05PM +0000, Matthew Wilcox wrote:
> +int sal_check_version(int major, int minor)
> +{
> + if (major < sal_rev_major)
> + return 1;
> + if (major > sal_rev_major)
> + return 0;
> + return (sal_rev_minor >= minor);
> }
>
>
> Anyone want to propose a different solution?
It looks reasonable to me, though I thought we were the only ones that
cared about PROM revisions ;). If you go ahead and push this in, we
could use it in arch/ia64/sn/kernel/setup.c, where we check for
incompatibilties bad enough to cause us to bail out...
Jesse
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: SAL version checking
2004-02-23 21:01 SAL version checking Matthew Wilcox
2004-02-23 21:09 ` Jesse Barnes
@ 2004-02-23 21:21 ` Matthew Wilcox
2004-02-23 21:43 ` Jesse Barnes
2 siblings, 0 replies; 4+ messages in thread
From: Matthew Wilcox @ 2004-02-23 21:21 UTC (permalink / raw)
To: linux-ia64
On Mon, Feb 23, 2004 at 01:09:20PM -0800, Jesse Barnes wrote:
> It looks reasonable to me, though I thought we were the only ones that
> cared about PROM revisions ;). If you go ahead and push this in, we
> could use it in arch/ia64/sn/kernel/setup.c, where we check for
> incompatibilties bad enough to cause us to bail out...
Well, you *were* the only ones who cared about SAL revisions ;-)
Actually, this isn't quite what you want. I'm asking the firmware
what rev of the SAL spec it reports; you want version number of the
prom. I want sal_rev_major/minor; you want sal_b_rev_major/minor.
I don't see why we shouldn't do both, and possibly even print both.
I've occasionally wondered what rev of firmware I'm running and
rebooting to figure that out is less satisfactory than grovelling through
/var/log/dmesg.
--
"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] 4+ messages in thread
* Re: SAL version checking
2004-02-23 21:01 SAL version checking Matthew Wilcox
2004-02-23 21:09 ` Jesse Barnes
2004-02-23 21:21 ` Matthew Wilcox
@ 2004-02-23 21:43 ` Jesse Barnes
2 siblings, 0 replies; 4+ messages in thread
From: Jesse Barnes @ 2004-02-23 21:43 UTC (permalink / raw)
To: linux-ia64
On Mon, Feb 23, 2004 at 09:21:01PM +0000, Matthew Wilcox wrote:
> On Mon, Feb 23, 2004 at 01:09:20PM -0800, Jesse Barnes wrote:
> > It looks reasonable to me, though I thought we were the only ones that
> > cared about PROM revisions ;). If you go ahead and push this in, we
> > could use it in arch/ia64/sn/kernel/setup.c, where we check for
> > incompatibilties bad enough to cause us to bail out...
>
> Well, you *were* the only ones who cared about SAL revisions ;-)
> Actually, this isn't quite what you want. I'm asking the firmware
> what rev of the SAL spec it reports; you want version number of the
> prom. I want sal_rev_major/minor; you want sal_b_rev_major/minor.
Right, I realized that after I sent the mail...
> I don't see why we shouldn't do both, and possibly even print both.
> I've occasionally wondered what rev of firmware I'm running and
> rebooting to figure that out is less satisfactory than grovelling through
> /var/log/dmesg.
Yeah, it would be nice to have it more generally available. It's one of
those few printk's which is actually useful. :)
Jesse
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-02-23 21:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-23 21:01 SAL version checking Matthew Wilcox
2004-02-23 21:09 ` Jesse Barnes
2004-02-23 21:21 ` Matthew Wilcox
2004-02-23 21:43 ` Jesse Barnes
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox