Deleted Added
full compact
autoconf.c (35974) autoconf.c (36809)
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * William Jolitz.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 20 unchanged lines hidden (view full) ---

29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * from: @(#)autoconf.c 7.1 (Berkeley) 5/9/91
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * William Jolitz.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 20 unchanged lines hidden (view full) ---

29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * from: @(#)autoconf.c 7.1 (Berkeley) 5/9/91
37 * $Id: autoconf.c,v 1.96 1998/05/06 22:14:40 julian Exp $
37 * $Id: autoconf.c,v 1.97 1998/05/12 17:33:58 bde Exp $
38 */
39
40/*
41 * Setup the system to run on the current machine.
42 *
43 * Configure() is called at boot time and initializes the vba
44 * device tables and the memory controller monitoring. Available
45 * devices are determined (from possibilities mentioned in ioconf.c),

--- 5 unchanged lines hidden (view full) ---

51#include "opt_cd9660.h"
52#include "opt_mfs.h"
53#include "opt_nfs.h"
54
55#include <sys/param.h>
56#include <sys/systm.h>
57#include <sys/conf.h>
58#include <sys/disklabel.h>
38 */
39
40/*
41 * Setup the system to run on the current machine.
42 *
43 * Configure() is called at boot time and initializes the vba
44 * device tables and the memory controller monitoring. Available
45 * devices are determined (from possibilities mentioned in ioconf.c),

--- 5 unchanged lines hidden (view full) ---

51#include "opt_cd9660.h"
52#include "opt_mfs.h"
53#include "opt_nfs.h"
54
55#include <sys/param.h>
56#include <sys/systm.h>
57#include <sys/conf.h>
58#include <sys/disklabel.h>
59#include <sys/diskslice.h> /* for BASE_SLICE, MAX_SLICES */
59#include
60#include <sys/reboot.h>
61#include <sys/kernel.h>
60#include <sys/reboot.h>
61#include <sys/kernel.h>
62#include <sys/malloc.h>
62#include <sys/mount.h>
63#include <sys/sysctl.h>
64
65#include <machine/bootinfo.h>
66#include <machine/cons.h>
67#include <machine/ipl.h>
68#include <machine/md_var.h>
69#ifdef APIC_IO
70#include <machine/smp.h>
71#endif /* APIC_IO */
72
63#include <sys/mount.h>
64#include <sys/sysctl.h>
65
66#include <machine/bootinfo.h>
67#include <machine/cons.h>
68#include <machine/ipl.h>
69#include <machine/md_var.h>
70#ifdef APIC_IO
71#include <machine/smp.h>
72#endif /* APIC_IO */
73
73#include <i386/isa/icu.h> /* For interrupts */
74#include
74
75#include "isa.h"
76#if NISA > 0
77#include <i386/isa/isa_device.h>
78#endif
79
80#include "pnp.h"
81#if NPNP > 0

--- 50 unchanged lines hidden (view full) ---

132 { "scd", 16 },
133 { "matcd", 17 },
134 { "wcd", 19 },
135 { 0, 0}
136};
137
138static int find_cdrom_root __P((void));
139
75
76#include "isa.h"
77#if NISA > 0
78#include <i386/isa/isa_device.h>
79#endif
80
81#include "pnp.h"
82#if NPNP > 0

--- 50 unchanged lines hidden (view full) ---

133 { "scd", 16 },
134 { "matcd", 17 },
135 { "wcd", 19 },
136 { 0, 0}
137};
138
139static int find_cdrom_root __P((void));
140
140
141static int
142find_cdrom_root()
143{
144 int i, j, error;
145 struct bdevsw *bd;
146 dev_t orootdev;
147
148#if CD9660_ROOTDELAY > 0

--- 229 unchanged lines hidden (view full) ---

378
379 if (!mountrootfsname) {
380 panic("Nobody wants to mount my root for me");
381 }
382
383 setconf();
384}
385
141static int
142find_cdrom_root()
143{
144 int i, j, error;
145 struct bdevsw *bd;
146 dev_t orootdev;
147
148#if CD9660_ROOTDELAY > 0

--- 229 unchanged lines hidden (view full) ---

378
379 if (!mountrootfsname) {
380 panic("Nobody wants to mount my root for me");
381 }
382
383 setconf();
384}
385
386#endif
386#endif /* !SLICE */
387
388void
389cpu_dumpconf()
390{
391 if (setdumpdev(dumpdev) != 0)
392 dumpdev = NODEV;
393}
394

--- 32 unchanged lines hidden (view full) ---

427 dumplo = newdumplo;
428 return (0);
429}
430
431#ifndef SLICE
432
433u_long bootdev = 0; /* not a dev_t - encoding is different */
434
387
388void
389cpu_dumpconf()
390{
391 if (setdumpdev(dumpdev) != 0)
392 dumpdev = NODEV;
393}
394

--- 32 unchanged lines hidden (view full) ---

427 dumplo = newdumplo;
428 return (0);
429}
430
431#ifndef SLICE
432
433u_long bootdev = 0; /* not a dev_t - encoding is different */
434
435/* Name lookup for bootable majors XXX extend me */
436static char *devname[] = {
437 "wd",
438 "wfd",
439#define FDMAJOR 2
435#define FDMAJOR 2
440 "fd",
441 "wt",
442 "sd",
443 "st",
444 "cd",
445};
446
447#define PARTITIONMASK 0x7
448#define PARTITIONSHIFT 3
449#define FDUNITSHIFT 6
436#define FDUNITSHIFT 6
450#define RAW_PART 2
451
452/*
453 * Attempt to find the device from which we were booted.
454 * If we can do so, and not instructed not to do so,
437
438/*
439 * Attempt to find the device from which we were booted.
440 * If we can do so, and not instructed not to do so,
455 * change rootdev to correspond to the load device.
441 * set rootdevs[] and rootdevnames[] to correspond to the
442 * boot device(s).
456 */
457static void
458setroot()
459{
443 */
444static void
445setroot()
446{
460 int majdev, mindev, unit, part, adaptor, slice;
461 dev_t orootdev;
462 char *sname, partname[2];
447 int majdev, mindev, unit, slice, part;
448 dev_t newrootdev;
449 char partname[2];
450 char *sname;
463
451
464/*printf("howto %x bootdev %x ", boothowto, bootdev);*/
465 if (boothowto & RB_DFLTROOT ||
466 (bootdev & B_MAGICMASK) != (u_long)B_DEVMAGIC)
452 if (boothowto & RB_DFLTROOT || (bootdev & B_MAGICMASK) != B_DEVMAGIC)
467 return;
453 return;
468 majdev = B_TYPE(bootdev);
469 adaptor = B_ADAPTOR(bootdev);
470 unit = B_UNIT(bootdev);
471 slice = B_SLICE(bootdev);
472 if ((slice < BASE_SLICE) || (slice >= MAX_SLICES))
454 majdev = B_TYPE(bootdev);
455 if (bdevsw[majdev] == NULL)
456 return;
457 unit = B_UNIT(bootdev);
458 slice = B_SLICE(bootdev);
459 if (slice == WHOLE_DISK_SLICE)
473 slice = COMPATIBILITY_SLICE;
460 slice = COMPATIBILITY_SLICE;
474 if (majdev > sizeof(devname) / sizeof(devname[0]))
461 if (slice < 0 || slice >= MAX_SLICES)
475 return;
462 return;
463
464 /*
465 * XXX kludge for inconsistent unit numbering and lack of slice
466 * support for floppies.
467 */
476 if (majdev == FDMAJOR) {
468 if (majdev == FDMAJOR) {
469 slice = COMPATIBILITY_SLICE;
477 part = RAW_PART;
478 mindev = unit << FDUNITSHIFT;
470 part = RAW_PART;
471 mindev = unit << FDUNITSHIFT;
479 }
480 else {
481 part = (bootdev >> B_PARTITIONSHIFT) & B_PARTITIONMASK;
472 } else {
473 part = B_PARTITION(bootdev);
482 mindev = dkmakeminor(unit, slice, part);
483 }
474 mindev = dkmakeminor(unit, slice, part);
475 }
484 orootdev = rootdev;
485 rootdev = makedev(majdev, mindev);
476
477 newrootdev = makedev(majdev, mindev);
478 rootdevs[0] = newrootdev;
479 sname = dsname(bdevsw[majdev]->d_name, unit, slice, part, partname);
480 rootdevnames[0] = malloc(strlen(sname) + 2, M_DEVBUF, M_NOWAIT);
481 sprintf(rootdevnames[0], "%s%s", sname, partname);
482
486 /*
483 /*
487 * If the original rootdev is the same as the one
488 * just calculated modulo the slice number, don't print an otherwise
489 * confusing diagnostic.
484 * For properly dangerously dedicated disks (ones with a historical
485 * bogus partition table), the boot blocks will give slice = 4, but
486 * the kernel will only provide the compatibility slice since it
487 * knows that slice 4 is not a real slice. Arrange to try mounting
488 * the compatibility slice as root if mounting the slice passed by
489 * the boot blocks fails. This handles the dangerously dedicated
490 * case and perhaps others.
490 */
491 */
491 if ((rootdev & ~0xff0000) == (orootdev & ~0xff0000))
492 if (slice == COMPATIBILITY_SLICE)
492 return;
493 return;
493 sname = dsname(devname[majdev], unit, slice, part, partname);
494 printf("changing root device to %s%s\n", sname, partname);
494 slice = COMPATIBILITY_SLICE;
495 rootdevs[1] = dkmodslice(newrootdev, slice);
496 sname = dsname(bdevsw[majdev]->d_name, unit, slice, part, partname);
497 rootdevnames[1] = malloc(strlen(sname) + 2, M_DEVBUF, M_NOWAIT);
498 sprintf(rootdevnames[1], "%s%s", sname, partname);
495}
496
499}
500
497#endif
501#endif /* !SLICE */
498
499static int
500sysctl_kern_dumpdev SYSCTL_HANDLER_ARGS
501{
502 int error;
503 dev_t ndumpdev;
504
505 ndumpdev = dumpdev;
506 error = sysctl_handle_opaque(oidp, &ndumpdev, sizeof ndumpdev, req);
507 if (error == 0 && req->newptr != NULL)
508 error = setdumpdev(ndumpdev);
509 return (error);
510}
511
512SYSCTL_PROC(_kern, KERN_DUMPDEV, dumpdev, CTLTYPE_OPAQUE|CTLFLAG_RW,
513 0, sizeof dumpdev, sysctl_kern_dumpdev, "T,dev_t", "");
502
503static int
504sysctl_kern_dumpdev SYSCTL_HANDLER_ARGS
505{
506 int error;
507 dev_t ndumpdev;
508
509 ndumpdev = dumpdev;
510 error = sysctl_handle_opaque(oidp, &ndumpdev, sizeof ndumpdev, req);
511 if (error == 0 && req->newptr != NULL)
512 error = setdumpdev(ndumpdev);
513 return (error);
514}
515
516SYSCTL_PROC(_kern, KERN_DUMPDEV, dumpdev, CTLTYPE_OPAQUE|CTLFLAG_RW,
517 0, sizeof dumpdev, sysctl_kern_dumpdev, "T,dev_t", "");