2001-10-06 03:36:19

by Thomas Hood

[permalink] [raw]
Subject: Linux should not set the "PnP OS" boot flag

My problem was: After running a recent 2.4.x kernel, on a subsequent
boot of Linux, all configurable devices (internal modem, audio chip,
parallel, serial and IR ports) were disabled. This would causes
oopses in my sound device drivers.

My workarounds were:
(1) to reinitialize the BIOS prior to booting, or,
(2) to run "setpnp on" on all the configurable devices early in
the boot sequence.

I just now figured out what was going on. When the PnP BIOS is
going to boot a non-PnP OS, it configures all configurable devices
itself. When the PnP BIOS is going to boot a PnP OS (which it
tells from a "boot flag") it leaves configurable devices, other
than those needed to boot the OS, unconfigured. Recent Linux
kernels have set the "boot flag" indicating that the OS being booted
is a PnP OS.

Unfortunately, Linux isn't really a "PnP OS". The kernel alone
doesn't configure the devices. One has to use setpnp to do that.

On the ThinkPad there is an additional solution:
(3) Disable QuickBoot in EasySetup Config (the BIOS setup program)

The PnP BIOS mode in which it refrains from configuring the
configurable devices (because it thinks it's booting a PnP OS)
is called "QuickBoot" on the ThinkPad. Recent Linux kernels switch
on QuickBoot. However if QuickBoot is disabled in EasySetup then
the boot flag is ignored and the PnP BIOS goes ahead and configures
the devices itself. One can still use setpnp to reconfigure the
devices, so this doesn't create a problem.

The best solution, though, is
(4) to modify Linux so that it doesn't set the QuickBoot boot flag.
The problem isn't just that Linux isn't a PnP OS. It's that Linux
can't possibly know in a multi-boot setup WHICH OS is going to be
booted _next_. So it just shouldn't futz with that boot flag.
Instead, control over the flag should be given to the user via
a /proc entry or something like that. I append a short patch
to remove the bit of code that sets the boot flag. (I see where
the function also zeroes out the sbf value if it appears not to be
a valid value. That seems rather rash to me, but I leave it
alone because I don't understand why it's there.)

Thanks to [email protected] for pointing me to the bootflag
code, of whose existence I was until recently unaware.

--
Thomas Hood

The patch:
--- linux-2.4.10-ac5/arch/i386/kernel/bootflag.c Fri Oct 5 14:57:10 2001
+++ linux-2.4.10-ac5-fix/arch/i386/kernel/bootflag.c Fri Oct 5 23:20:43 2001
@@ -119,7 +119,7 @@
u8 v = sbf_read();
if(!sbf_value_valid(v))
v = 0;
-#if defined(CONFIG_PNPBIOS)
+#if 0 // WAS: #if defined(CONFIG_PNPBIOS)
/* Tell the BIOS to fast init as we are a PnP OS */
v |= (1<<0); /* Set PNPOS flag */
#endif



2001-10-06 19:33:47

by ebiederman

[permalink] [raw]
Subject: Re: Linux should not set the "PnP OS" boot flag

Thomas Hood <[email protected]> writes:

> My problem was: After running a recent 2.4.x kernel, on a subsequent
> boot of Linux, all configurable devices (internal modem, audio chip,
> parallel, serial and IR ports) were disabled. This would causes
> oopses in my sound device drivers.
>
> My workarounds were:
> (1) to reinitialize the BIOS prior to booting, or,
> (2) to run "setpnp on" on all the configurable devices early in
> the boot sequence.
>
> I just now figured out what was going on. When the PnP BIOS is
> going to boot a non-PnP OS, it configures all configurable devices
> itself. When the PnP BIOS is going to boot a PnP OS (which it
> tells from a "boot flag") it leaves configurable devices, other
> than those needed to boot the OS, unconfigured. Recent Linux
> kernels have set the "boot flag" indicating that the OS being booted
> is a PnP OS.
>
> Unfortunately, Linux isn't really a "PnP OS". The kernel alone
> doesn't configure the devices. One has to use setpnp to do that.

Hmm. Linux isn't quite a "PnP OS". I agree that in the short
term we should not set the boot flag. But we should also investigate
what needs to added so that setpnp does not need to be called.

In the normal case the pci subsystem gets this correct, and we need
the logic to get this correct to support hot plug devices.

Do you have any insite into what needs to be done so that the kernel
will automatically configure isa pnp devices?

Eric



2001-10-06 21:06:35

by Alan

[permalink] [raw]
Subject: Re: Linux should not set the "PnP OS" boot flag

> Do you have any insite into what needs to be done so that the kernel
> will automatically configure isa pnp devices?

We already configure isapnp devices. We don't yet configure all the PnPbios
devices

2001-10-07 01:18:09

by ebiederman

[permalink] [raw]
Subject: Re: Linux should not set the "PnP OS" boot flag

"Alan Cox" <[email protected]> writes:

> > Do you have any insite into what needs to be done so that the kernel
> > will automatically configure isa pnp devices?
>
> We already configure isapnp devices. We don't yet configure all the PnPbios
> devices

O.k. I'm getting more interested as I read this. So we have things like
superio chips and the like with configureable resources, (and possibly some
pci<->isa bridge resources that need to bec onfigured.)

Coming from the linuxBIOS side I'm interested as that will allow me to
rip out more code, from linuxBIOS. And I think it is only sane to report
such devices.

I don't know about the stock BIOS interfaces to those devices though. I'll
keep an eye on them and see what I can do. Hopefully within the next couple
of mounths I can start attacking this problem.

Eric


2001-10-07 02:54:49

by Thomas Hood

[permalink] [raw]
Subject: Re: Linux should not set the "PnP OS" boot flag

[email protected] wrote:
> Hmm. Linux isn't quite a "PnP OS". I agree that in the short
> term we should not set the boot flag. But we should also investigate
> what needs to added so that setpnp does not need to be called.

This change has to be permanent. Linux should never automatically
set the boot flag, no matter how PnP-competent we make it.
The reason is that setting the flag affects what the BIOS will
do on the _subsequent_ boot. But Linux can't possibly know
which operating system will be booted _next time_. This is
something that has to be left up to the user to control.

Assuming I've made that point, I'll go on to say that I do not
know of any reason why the PnP-OS flag should _ever_ be set.
SFAIK all that setting the flag does is stop the PnP BIOS
from configuring devices in the way that it has been told to do
(if we used "setpnp -b" to set the nonvolative configuration).
I don't see why we would ever want to do this. If the BIOS does
configure the devices, nothing stops us from reconfiguring them
(using "setpnp") once Linux has booted. The PnP-OS flag is called
a "quick boot" flag, but the time savings involved must be on the
order of milliseconds. All that we seem to achieve by booting
Linux with disabled devices is to induce certain device drivers
to segfault.

Please let me know if I'm overlooking something.

If I'm right, then bootflag.c should be modified (see my patch)
to remove the bit that sets the flag. It would be nice,
however, if the flag could be controlled via a /proc entry.

--
Thomas



2001-10-07 09:57:25

by Alan

[permalink] [raw]
Subject: Re: Linux should not set the "PnP OS" boot flag

> This change has to be permanent. Linux should never automatically
> set the boot flag, no matter how PnP-competent we make it.
> The reason is that setting the flag affects what the BIOS will
> do on the _subsequent_ boot. But Linux can't possibly know
> which operating system will be booted _next time_. This is
> something that has to be left up to the user to control.

When it cuts your reboot time right down then its a very useful thing to
set. Also remember that this is entirely configurable. In fact the last
stage of a pnp aware bootup requires that user space sets the "booted ok"
flag.

> a "quick boot" flag, but the time savings involved must be on the
> order of milliseconds. All that we seem to achieve by booting

On some boxes they are much higher

> If I'm right, then bootflag.c should be modified (see my patch)
> to remove the bit that sets the flag. It would be nice,
> however, if the flag could be controlled via a /proc entry.

No need. It's all already handled

Alan

2001-10-07 13:51:23

by Thomas Hood

[permalink] [raw]
Subject: Re: Linux should not set the "PnP OS" boot flag

On Sun, 2001-10-07 at 06:02, Alan Cox wrote:
> > This change has to be permanent. Linux should never automatically
> > set the boot flag, no matter how PnP-competent we make it.
> > The reason is that setting the flag affects what the BIOS will
> > do on the _subsequent_ boot. But Linux can't possibly know
> > which operating system will be booted _next time_. This is
> > something that has to be left up to the user to control.
>
> When it cuts your reboot time right down then its a very useful thing to
> set.

Okay, clearly we do need the ability to set the PnP-OS flag. But this
has to be under the user's control. Microsoft itself says (from their
Simple Boot Flag FAQ
http://www.microsoft.com/hwdev/desinit/simp_bios.htm):

---------------------------------------------------------------------
How does this specification solve the multi-boot scenarios?
This specification does not attempt to solve multi-boot scenarios in
which a user has several different operating systems, some Plug and
Play, some not, installed on the machine. This specification only
provides a more reliable technique for detecting the presence of these
operating systems than previously published designs.

The multi-boot problem is fundamentally intractable: the information
needed by the system BIOS in order to boot is not available until after
boot. A system BIOS would like to know whether or not a Plug and Play
operating system will be booted. If so, it will only configure devices
that are required for boot. If not, it will configure all devices it
controls. The information about which OS will be booted is not known
until the user chooses the operating system in a boot menu. To present
the boot menu, however, the system BIOS must start booting the operating
system, which means it must have already configured devices. Thus, the
situation is a catch 22. The best any design can do is provide some hint
to the system BIOS that a Plug and Play operating system is installed.
This specification does no more than that.
---------------------------------------------------------------------

For these reasons it must be left up to the user to provide this
"hint".

> Also remember that this is entirely configurable.

I'm not sure what you mean by 'configurable' here. All I see is that
the code that sets the PnP-OS flag gets compiled in if one chooses
to build the PnP BIOS driver by defining CONFIG_PNPBIOS. But having
a PnP BIOS driver (merely an interface to the PnP BIOS) is not the
same thing as "being a PnP OS". There ought to be some way of
overriding this---of building in the PnP BIOS driver without setting
the PnP-OS flag. One solution is to put #ifdef CONFIG_PNPOS ... #endif
around the flag-setting code and add a new choice to the configuration.

> In fact the last stage of a pnp aware bootup requires that user space
> sets the "booted ok" flag.

Yes (if you mean: clears the "Booting" flag). This is a different
flag from the PnP-OS flag. The PnP-OS flag is bit 0; the "Booting"
flag is bit 1. So this is a separate issue.

But look at the code (following). The code DOES NOT clear the "Booting"
flag. It ONLY sets the PnP-OS flag. Not only that: when it does so
it fails to change bit 7 in order to preserve odd parity, as the spec
requires.

------------------------------------------------------------------
static void __init sbf_bootup(void)
{
u8 v = sbf_read();
if(!sbf_value_valid(v))
v = 0;
#if defined(CONFIG_PNPBIOS)
/* Tell the BIOS to fast init as we are a PnP OS */
v |= (1<<0); /* Set PNPOS flag */
#endif
sbf_write(v);
}

#ifdef NOT_USED
void linux_booted_ok(void)
{
u8 v = sbf_read();
if(!sbf_value_valid(v))
return;
v &= ~(1<<1); /* Clear BOOTING flag */
sbf_write(v);
}
#endif /* NOT_USED */
----------------------------------------------------------------


> > If I'm right, then bootflag.c should be modified (see my patch)
> > to remove the bit that sets the flag. It would be nice,
> > however, if the flag could be controlled via a /proc entry.
>
> No need. It's all already handled

I think you'll understand why I say that it is not handled
_correctly_ and that the handling must be brought under
the user's control ... if not via a /proc entry then by
a build option or boot option. I invite advice about this.

Please let me know if you still disagree.

--
Thomas



2001-10-07 14:07:10

by Dave Jones

[permalink] [raw]
Subject: Re: Linux should not set the "PnP OS" boot flag

On 7 Oct 2001, Thomas Hood wrote:

> I think you'll understand why I say that it is not handled
> _correctly_ and that the handling must be brought under
> the user's control ... if not via a /proc entry then by
> a build option or boot option. I invite advice about this.

The final part doesn't need to be in kernel space at all.
(And from my reading of the spec, shouldn't be, as it signifies
the OS completed the final stages of booting successfully)

http://www.codemonkey.org.uk/sbf.c
is some quick code I hacked up when bootflag.c first appeared.
Its not perfect, and I have some outstanding patches that Randy Dunlap
sent to clean up some bits, but I've not got around to merging them.

regards,

Dave.

--
| Dave Jones. http://www.suse.de/~davej
| SuSE Labs

2001-10-07 14:12:31

by Alan

[permalink] [raw]
Subject: Re: Linux should not set the "PnP OS" boot flag

> Yes (if you mean: clears the "Booting" flag). This is a different
> flag from the PnP-OS flag. The PnP-OS flag is bit 0; the "Booting"
> flag is bit 1. So this is a separate issue.

Its very much the same issue. Only a marked successful PnP boot counts
for anything

> But look at the code (following). The code DOES NOT clear the "Booting"
> flag. It ONLY sets the PnP-OS flag. Not only that: when it does so
> it fails to change bit 7 in order to preserve odd parity, as the spec
> requires.

sbf_write computes parity

2001-10-07 17:10:24

by Thomas Hood

[permalink] [raw]
Subject: Re: Linux should not set the "PnP OS" boot flag

On Sun, 2001-10-07 at 10:18, Alan Cox wrote:
> > Yes (if you mean: clears the "Booting" flag). This is a different
> > flag from the PnP-OS flag. The PnP-OS flag is bit 0; the "Booting"
> > flag is bit 1. So this is a separate issue.
>
> Its very much the same issue. Only a marked successful PnP boot counts
> for anything

Well, the SBF spec treats the two bits as totally separate.
The PnP-OS bit controls PnP BIOS device configuration.
The Booting and Diag bits control whether or not POSTs are run:

------------------------------------------------------------------
BOOT register structure
-----------------------
0 PNPOS -- Indicates that a Plug-and-Play capable OS is installed on the
system. The system BIOS must check the state of this bit during its
initialization. If this bit is not set, the system BIOS must assume a
legacy operating system and configure the resources of all devices it
controls. If the bit is set, the system BIOS must assume a Plug and
Play operating system and only configure devices required for boot as
per the PC98 specification.
1 BOOTING -- Indicates whether or not the previous boot was not
completed. The system BIOS must check the state of this flag at the
beginning of POST. If this bit is set, the system BIOS will set DIAG to
1 to inform itself and other components to run a full diagnostic suite.
If this bit is not set, DIAG will be cleared to inform components to
skip all tests and to begin loading the boot sector as soon as possible.
This bit is set by the system BIOS at the earliest possible moment of
POST. This bit is cleared by the OS after it has completed its boot
procedure.
2 DIAG -- Indicates whether or not to run diagnostics. This bit is set
based on the state of BOOTING at the beginning of POST, or by the
operating system during the previous boot. If set at the beginning of
POST, this bit must remain set to allow the operating system to request
diagnostic boots. If set during POST, the system BIOS, option ROMs, and
operating systems should run diagnostic tests. If not set, these
components must not run diagnostic tests and should boot the machine as
quickly as possible.
3-6 Reserved -- Reserved. Must be 0.
7 PARITY -- A parity bit used to check used to verify the integrity of
this register. This bit should be set with ODD parity based on the
contents of the rest of the register. If the system BIOS detects that
the PARITY bit is not set correctly, it must assume the register is
corrupted.
------------------------------------------------------------------

> > But look at the code (following). The code DOES NOT clear the "Booting"
> > flag. It ONLY sets the PnP-OS flag. Not only that: when it does so
> > it fails to change bit 7 in order to preserve odd parity, as the spec
> > requires.
>
> sbf_write computes parity

oh. ;)

I append the patch that shows the sort of thing that I think needs
to be done. (This patch includes the change from spin_lock to
spin_lock_irqsave.) The patch would need to be accompanied by the
addition of stuff to allow the user to define CONFIG_PNPOS.

Cheers,
Thomas

The patch:
--- linux-2.4.10-ac7/arch/i386/kernel/bootflag.c Fri Oct 5 14:57:10 2001
+++ linux-2.4.10-ac7-fix/arch/i386/kernel/bootflag.c Sun Oct 7 13:07:03 2001
@@ -59,7 +59,7 @@
return 0;

if (sb.sbf_len == 39)
- printk (KERN_WARNING "ACPI BOOT descriptor is wrong length (%d)\n",
+ printk (KERN_WARNING "SBF: ACPI BOOT descriptor is wrong length (%d)\n",
sb.sbf_len);

sbf_port = sb.sbf_cmos; /* Save CMOS port */
@@ -81,32 +81,38 @@

static void __init sbf_write(u8 v)
{
+ unsigned long flags;
+
if(sbf_port != -1)
{
v &= ~(1<<7);
if(!parity(v))
v|=1<<7;

- spin_lock(&rtc_lock);
+ printk(KERN_INFO "SBF: Setting boot flags 0x%x\n",v);
+
+ spin_lock_irqsave(&rtc_lock, flags);
CMOS_WRITE(v, sbf_port);
- spin_unlock(&rtc_lock);
+ spin_unlock_irqrestore(&rtc_lock, flags);
}
}

static u8 __init sbf_read(void)
{
u8 v;
+ unsigned long flags;
+
if(sbf_port == -1)
return 0;
- spin_lock(&rtc_lock);
+ spin_lock_irqsave(&rtc_lock, flags);
v = CMOS_READ(sbf_port);
- spin_unlock(&rtc_lock);
+ spin_unlock_irqrestore(&rtc_lock, flags);
return v;
}

static int __init sbf_value_valid(u8 v)
{
- if(v&0x78) /* Reserved bits */
+ if(v&0x78) /* Reserved bits should be 0 */
return 0;
if(!parity(v))
return 0;
@@ -118,24 +124,18 @@
{
u8 v = sbf_read();
if(!sbf_value_valid(v))
- v = 0;
-#if defined(CONFIG_PNPBIOS)
+ printk(KERN_WARNING "SBF: Simple boot flag value read from CMOS RAM 0x%x is invalid\n",v);
+
+ v &= ~0x78; /* Clear reserved bits 3-6 */
+ v &= ~(1<<1); /* Clear BOOTING flag */
+ v &= ~(1<<2); /* Clear DIAG flag */
+#if defined(CONFIG_PNPOS)
/* Tell the BIOS to fast init as we are a PnP OS */
v |= (1<<0); /* Set PNPOS flag */
#endif
- sbf_write(v);
-}

-#ifdef NOT_USED
-void linux_booted_ok(void)
-{
- u8 v = sbf_read();
- if(!sbf_value_valid(v))
- return;
- v &= ~(1<<1); /* Clear BOOTING flag */
sbf_write(v);
}
-#endif /* NOT_USED */

static int __init sbf_init(void)
{
@@ -235,7 +235,7 @@
if(sbf_struct_valid(rp))
{
/* Found the BOOT table and processed it */
- printk(KERN_INFO "Simple Boot Flag extension found and enabled.\n");
+ printk(KERN_INFO "SBF: Simple Boot Flag extension found and enabled.\n");
}
iounmap((void *)rp);
}

2001-10-07 17:54:50

by Thomas Hood

[permalink] [raw]
Subject: Re: Linux should not set the "PnP OS" boot flag

Here's a slightly neater version of the patch which gives control
over the DIAG bit also. We'd need config options for "CONFIG_SBF_DIAG"
and "CONFIG_SBF_PNPOS".

I'd like to say in defense of this patch that the more conservative
thing to do _by default_ is to let the PnP BIOS configure devices
before Linux boots. The cost SFAIK is only time. The cost of leaving
devices unconfigured is, for some people, oopses.

--
Thomas

The patch:
--- linux-2.4.10-ac7/arch/i386/kernel/bootflag.c Fri Oct 5 14:57:10 2001
+++ linux-2.4.10-ac7-fix/arch/i386/kernel/bootflag.c Sun Oct 7 13:45:41 2001
@@ -15,6 +15,13 @@

#include <linux/mc146818rtc.h>

+
+#define SBF_RESERVED (0x78)
+#define SBF_PNPOS (1<<0)
+#define SBF_BOOTING (1<<1)
+#define SBF_DIAG (1<<2)
+#define SBF_PARITY (1<<7)
+
struct sbf_boot
{
u8 sbf_signature[4];
@@ -59,7 +66,7 @@
return 0;

if (sb.sbf_len == 39)
- printk (KERN_WARNING "ACPI BOOT descriptor is wrong length (%d)\n",
+ printk (KERN_WARNING "SBF: ACPI BOOT descriptor is wrong length (%d)\n",
sb.sbf_len);

sbf_port = sb.sbf_cmos; /* Save CMOS port */
@@ -81,61 +88,65 @@

static void __init sbf_write(u8 v)
{
+ unsigned long flags;
+
if(sbf_port != -1)
{
- v &= ~(1<<7);
+ v &= ~SBF_PARITY;
if(!parity(v))
- v|=1<<7;
+ v|=SBF_PARITY; /* Make parity odd */

- spin_lock(&rtc_lock);
+ printk(KERN_INFO "SBF: Setting boot flags 0x%x\n",v);
+
+ spin_lock_irqsave(&rtc_lock, flags);
CMOS_WRITE(v, sbf_port);
- spin_unlock(&rtc_lock);
+ spin_unlock_irqrestore(&rtc_lock, flags);
}
}

static u8 __init sbf_read(void)
{
u8 v;
+ unsigned long flags;
+
if(sbf_port == -1)
return 0;
- spin_lock(&rtc_lock);
+ spin_lock_irqsave(&rtc_lock, flags);
v = CMOS_READ(sbf_port);
- spin_unlock(&rtc_lock);
+ spin_unlock_irqrestore(&rtc_lock, flags);
return v;
}

static int __init sbf_value_valid(u8 v)
{
- if(v&0x78) /* Reserved bits */
+ if(v&SBF_RESERVED) /* Reserved bits should be 0 */
return 0;
if(!parity(v))
return 0;
return 1;
}

-
static void __init sbf_bootup(void)
{
u8 v = sbf_read();
if(!sbf_value_valid(v))
- v = 0;
-#if defined(CONFIG_PNPBIOS)
- /* Tell the BIOS to fast init as we are a PnP OS */
- v |= (1<<0); /* Set PNPOS flag */
+ printk(KERN_WARNING "SBF: Simple boot flag value 0x%x read from CMOS RAM was invalid\n",v);
+
+ v &= ~SBF_RESERVED;
+ v &= ~SBF_BOOTING;
+#if defined(CONFIG_SBF_DIAG)
+ v |= SBF_DIAG;
+#else
+ v &= ~SBF_DIAG;
+#endif
+#if defined(CONFIG_SBF_PNPOS)
+ v |= SBF_PNPOS;
+#else
+ v &= ~SBF_PNPOS;
#endif
- sbf_write(v);
-}

-#ifdef NOT_USED
-void linux_booted_ok(void)
-{
- u8 v = sbf_read();
- if(!sbf_value_valid(v))
- return;
- v &= ~(1<<1); /* Clear BOOTING flag */
sbf_write(v);
}
-#endif /* NOT_USED */

static int __init sbf_init(void)
{
@@ -235,7 +246,7 @@
if(sbf_struct_valid(rp))
{
/* Found the BOOT table and processed it */
- printk(KERN_INFO "Simple Boot Flag extension found and enabled.\n");
+ printk(KERN_INFO "SBF: Simple Boot Flag extension found and enabled.\n");
}
iounmap((void *)rp);
}

2001-10-07 21:53:52

by Alan

[permalink] [raw]
Subject: Re: Linux should not set the "PnP OS" boot flag

> I append the patch that shows the sort of thing that I think needs
> to be done. (This patch includes the change from spin_lock to
> spin_lock_irqsave.) The patch would need to be accompanied by the
> addition of stuff to allow the user to define CONFIG_PNPOS.

Would it not be better to tackle the job head on ? If the pnpbios scan
as it walks the devices configured them would that do the job ?

2001-10-08 12:40:47

by Thomas Hood

[permalink] [raw]
Subject: Re: Linux should not set the "PnP OS" boot flag

(Sorry if this is a repeat ... a lot of my mail is getting
bounced back today for some reason. This message hasn't
turned up in the archives, so I'm resending. // Thomas )

Alan Cox wrote:
> Would it not be better to tackle the job head on ? If the pnpbios scan
> as it walks the devices configured them would that do the job ?

Well, we could do the equivalent of a "setpnp xy on" on each device,
I suppose. That just copies the "boot" config to the "current"
config. That would suffice for me. I don't know if it would
suffice for other people. It wouldn't work for those Vaios and
Inspirons that have been causing problems, though.

I have a suspicion that those Phoenix BIOSes that oops when
"current" configuration is accessed are oopsing because
the BIOS hasn't initialized the "current" configuration ...
because the PnP-OS bit is set. I've asked Stelian to test
this hypothesis; no word back yet.

In any case, though, I think the decision as to whether or not
to bypass PnP BIOS configuration _next time_ should be left up
to the user. The user may want to boot Windows 3.1 next, or
some other non-PnP OS. Same goes for skipping BIOS diagnostics.

As for the "Booting" flag, you're right, it should be cleared
by us. SFAICT the current code fails to do this. That needs
to be fixed.

So here's a new bootflag.c patch, now against 2.4.10-ac8.
(It defines some nice macros for the flags, etc.
Until CONFIG_SBF_DIAG and CONFIG_SBF_PNPOS are defined
somewhere, the default will be not to set the DIAG flag
and not to set the PnP-OS flag. I still think a /proc
interface to these makes the most sense, but I haven't
implemented that yet.

--
Thomas

The patch:
--- linux-2.4.10-ac8/arch/i386/kernel/bootflag.c Sun Oct 7 14:38:05 2001
+++ linux-2.4.10-ac8-fix/arch/i386/kernel/bootflag.c Sun Oct 7 15:01:45 2001
@@ -15,6 +15,14 @@

#include <linux/mc146818rtc.h>

+
+#define SBF_RESERVED (0x78)
+#define SBF_PNPOS (1<<0)
+#define SBF_BOOTING (1<<1)
+#define SBF_DIAG (1<<2)
+#define SBF_PARITY (1<<7)
+
+
struct sbf_boot
{
u8 sbf_signature[4];
@@ -59,7 +67,7 @@
return 0;

if (sb.sbf_len == 39)
- printk (KERN_WARNING "ACPI BOOT descriptor is wrong length (%d)\n",
+ printk (KERN_WARNING "SBF: ACPI BOOT descriptor is wrong length (%d)\n",
sb.sbf_len);

sbf_port = sb.sbf_cmos; /* Save CMOS port */
@@ -84,10 +92,12 @@
unsigned long flags;
if(sbf_port != -1)
{
- v &= ~(1<<7);
+ v &= ~SBF_PARITY;
if(!parity(v))
- v|=1<<7;
-
+ v|=SBF_PARITY;
+
+ printk(KERN_INFO "SBF: Setting boot flags 0x%x\n",v);
+
spin_lock_irqsave(&rtc_lock, flags);
CMOS_WRITE(v, sbf_port);
spin_unlock_irqrestore(&rtc_lock, flags);
@@ -108,7 +118,7 @@

static int __init sbf_value_valid(u8 v)
{
- if(v&0x78) /* Reserved bits */
+ if(v&SBF_RESERVED) /* Reserved bits */
return 0;
if(!parity(v))
return 0;
@@ -120,24 +130,22 @@
{
u8 v = sbf_read();
if(!sbf_value_valid(v))
- v = 0;
-#if defined(CONFIG_PNPBIOS)
- /* Tell the BIOS to fast init as we are a PnP OS */
- v |= (1<<0); /* Set PNPOS flag */
-#endif
- sbf_write(v);
-}
+ printk(KERN_WARNING "SBF: Simple boot flag value 0x%x read from CMOS RAM was invalid\n",v);

-#ifdef NOT_USED
-void linux_booted_ok(void)
-{
- u8 v = sbf_read();
- if(!sbf_value_valid(v))
- return;
- v &= ~(1<<1); /* Clear BOOTING flag */
+ v &= ~SBF_RESERVED;
+ v &= ~SBF_BOOTING;
+#if defined(CONFIG_SBF_DIAG)
+ v |= SBF_DIAG;
+#else
+ v &= ~SBF_DIAG;
+#endif
+#if defined(CONFIG_SBF_PNPOS)
+ v |= SBF_PNPOS;
+#else
+ v &= ~SBF_PNPOS;
+#endif
sbf_write(v);
}
-#endif /* NOT_USED */

static int __init sbf_init(void)
{
@@ -237,7 +245,7 @@
if(sbf_struct_valid(rp))
{
/* Found the BOOT table and processed it */
- printk(KERN_INFO "Simple Boot Flag extension found and enabled.\n");
+ printk(KERN_INFO "SBF: Simple Boot Flag extension found and enabled.\n");
}
iounmap((void *)rp);
}

2001-10-08 13:26:17

by Stelian Pop

[permalink] [raw]
Subject: Re: Linux should not set the "PnP OS" boot flag

On Mon, Oct 08, 2001 at 08:40:21AM -0400, Thomas Hood wrote:

> I have a suspicion that those Phoenix BIOSes that oops when
> "current" configuration is accessed are oopsing because
> the BIOS hasn't initialized the "current" configuration ...
> because the PnP-OS bit is set. I've asked Stelian to test
> this hypothesis; no word back yet.

Sorry, the weekend is too short sometimes...

Anyway, the PnP OS setting in the BIOS doesn't change anything
regarding to the Linux PnP initialisation oops (same printouts,
same calltrace, etc).

Stelian.
--
Stelian Pop <[email protected]>
|---------------- Free Software Engineer -----------------|
| Alc?ve - http://www.alcove.com - Tel: +33 1 49 22 68 00 |
|------------- Alc?ve, liberating software ---------------|

2001-10-08 22:11:55

by Thomas Hood

[permalink] [raw]
Subject: Re: Linux should not set the "PnP OS" boot flag

--- Stelian Pop <[email protected]> wrote:
> Anyway, the PnP OS setting in the BIOS doesn't change anything
> regarding to the Linux PnP initialisation oops (same printouts,
> same calltrace, etc).

Too bad. :(

Although it apparently won't help Stelian, I still think it's
good practice (1) to set the boot flags to what's safe, and
then (2) to give the user the ability to change the default if
s/he wants to try speeding things up.

(Parenthesis re: time savings
Alan: You say that setting the PnP-OS flag can save up to
thirty seconds at boot time. My suspicion is that it may
actually be the diagnostics that take up all these seconds
(e.g., testing each of 128 million memory locations), not
the configuration process. Are you sure that it isn't
clearing the DIAG flag that's important for time savings,
not setting the PNPOS flag?)

It's useful to be able to select a different default at build
time (CONFIG_SBF_PNPOS). But in addition I would like to provide
/proc access to the bootflags. That way, if I suspect a hardware
problem I can "echo 1 > /proc/sys/bootflags/diag" and reboot; or
if I am going to boot DOS I can "echo 0 > /proc/sys/bootflags/pnpos"
and reboot. Question: Where should I put these entries under
/proc. Are my examples okay?

--
Thomas


____________________________________________________________
Do You Yahoo!?
Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
or your free @yahoo.ie address at http://mail.yahoo.ie