Port-i386 archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: boot device detection on cdboot



This has been committed.

I wrote:

> > Is there any good way to detect boot device on cdboot?
> > 
> > It will be useful on one CD system with cd9660 root file system
> > and working dirs on tmpfs/mfs, like restorecd for cobalt.
> > (recompiling a whole kernel only for "root on cd0a" is a bit pain)
> > 
> > Current arch/x86/x86/x86_autoconf.c:findroot() doesn't
> > check cd(4) for the booted device.
> > 
> > On the other hand, arch/i386/stand/lib/biosdisk_ll.c:set_geometry()
> > checks a number of BIOS disks via get_harddrives() and sets
> > BIOSDISK_TYPE_CD in struct biosdisk_extinfo.
> 
> I notice the number of BIOS disks is stored in BTINFO_BIOSGEOM
> so we can check it in findroot() function.
> 
> How about this patch?
> 
> ---
> Index: x86_autoconf.c
> ===================================================================
> RCS file: /cvsroot/src/sys/arch/x86/x86/x86_autoconf.c,v
> retrieving revision 1.34
> diff -u -r1.34 x86_autoconf.c
> --- x86_autoconf.c    16 Apr 2008 16:06:52 -0000      1.34
> +++ x86_autoconf.c    11 Oct 2008 20:03:42 -0000
> @@ -305,6 +305,7 @@
>       struct btinfo_rootdevice *biv;
>       struct btinfo_bootdisk *bid;
>       struct btinfo_bootwedge *biw;
> +     struct btinfo_biosgeom *big;
>       device_t dv;
>  
>       if (booted_device)
> @@ -432,6 +433,34 @@
>  
>               if (booted_device)
>                       return;
> +
> +             /*
> +              * No booted device found; check CD-ROM boot at last.
> +              *
> +              * Our bootloader assumes CD-ROM boot if biosdev is larger
> +              * than the number of hard drives recognized by the BIOS.
> +              * The number of drives can be found in BTINFO_BIOSGEOM here.
> +              *
> +              * See src/sys/arch/i386/stand/boot/devopen.c and
> +              * src/sys/arch/i386/stand/lib/bootinfo_biosgeom.c .
> +              */
> +             if ((big = lookup_bootinfo(BTINFO_BIOSGEOM)) != NULL &&
> +                 bid->biosdev > 0x80 + big->num) {
> +                     /*
> +                      * XXX
> +                      * There is no proper way to detect which unit is
> +                      * recognized as a bootable CD-ROM drive by the BIOS.
> +                      * Assume the first unit is the one.
> +                      */
> +                     TAILQ_FOREACH(dv, &alldevs, dv_list) {
> +                             if (device_class(dv) == DV_DISK &&
> +                                 device_is_a(dv, "cd")) {
> +                                     booted_device = dv;
> +                                     booted_partition = 0;
> +                                     break;
> +                             }
> +                     }
> +             }
>       }
>  }
>  

---
Izumi Tsutsui


Home | Main Index | Thread Index | Old Index