Annotation of sys/arch/mvmeppc/mvmeppc/autoconf.c, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: autoconf.c,v 1.19 2007/06/01 23:14:07 deraadt Exp $ */
! 2: /*
! 3: * Copyright (c) 1996, 1997 Per Fogelstrom
! 4: * Copyright (c) 1995 Theo de Raadt
! 5: * Copyright (c) 1988 University of Utah.
! 6: * Copyright (c) 1992, 1993
! 7: * The Regents of the University of California. All rights reserved.
! 8: *
! 9: * This code is derived from software contributed to Berkeley by
! 10: * the Systems Programming Group of the University of Utah Computer
! 11: * Science Department and Ralph Campbell.
! 12: *
! 13: * Redistribution and use in source and binary forms, with or without
! 14: * modification, are permitted provided that the following conditions
! 15: * are met:
! 16: * 1. Redistributions of source code must retain the above copyright
! 17: * notice, this list of conditions and the following disclaimer.
! 18: * 2. Redistributions in binary form must reproduce the above copyright
! 19: * notice, this list of conditions and the following disclaimer in the
! 20: * documentation and/or other materials provided with the distribution.
! 21: * 3. Neither the name of the University nor the names of its contributors
! 22: * may be used to endorse or promote products derived from this software
! 23: * without specific prior written permission.
! 24: *
! 25: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
! 26: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
! 27: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
! 28: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
! 29: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
! 30: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
! 31: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
! 32: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
! 33: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
! 34: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
! 35: * SUCH DAMAGE.
! 36: *
! 37: * from: Utah Hdr: autoconf.c 1.31 91/01/21
! 38: *
! 39: * from: @(#)autoconf.c 8.1 (Berkeley) 6/10/93
! 40: * $Id: autoconf.c,v 1.19 2007/06/01 23:14:07 deraadt Exp $
! 41: */
! 42:
! 43: /*
! 44: * Setup the system to run on the current machine.
! 45: *
! 46: * cpu_configure() is called at boot time. Available
! 47: * devices are determined (from possibilities mentioned in ioconf.c),
! 48: * and the drivers are initialized.
! 49: */
! 50:
! 51: #include <sys/param.h>
! 52: #include <sys/systm.h>
! 53: #include <sys/buf.h>
! 54: #include <sys/disklabel.h>
! 55: #include <sys/conf.h>
! 56: #include <sys/reboot.h>
! 57: #include <sys/device.h>
! 58:
! 59: #include <machine/autoconf.h>
! 60: #include <machine/bugio.h>
! 61:
! 62: extern void dumpconf(void);
! 63: struct device *getdevunit(char *, int);
! 64: void calc_delayconst(void); /* clock.c */
! 65:
! 66: /*
! 67: * The following several variables are related to
! 68: * the configuration process, and are used in initializing
! 69: * the machine.
! 70: */
! 71: int cold = 1; /* if 1, still working on cold-start */
! 72: int bootdev; /* boot device as provided by locore */
! 73: struct device *bootdv = NULL;
! 74:
! 75: /*
! 76: * Configure all devices found that we know about.
! 77: * This is done at boot time.
! 78: */
! 79: void
! 80: cpu_configure()
! 81: {
! 82: (void)splhigh(); /* To be really sure.. */
! 83: calc_delayconst();
! 84:
! 85: if (config_rootfound("mainbus", "mainbus") == 0)
! 86: panic("no mainbus found");
! 87:
! 88: ppc_intr_enable(1);
! 89: spl0();
! 90:
! 91: /*
! 92: * We can not select the root device yet, because we use bugtty
! 93: * as the console for now, and it requires the clock to be ticking
! 94: * for proper operation (think boot -a ...)
! 95: */
! 96: cold = 0;
! 97: }
! 98:
! 99: void
! 100: diskconf(void)
! 101: {
! 102: printf("boot device: %s\n",
! 103: (bootdv != NULL) ? bootdv->dv_xname : "<unknown>");
! 104: setroot(bootdv, 0, RB_USERREQ);
! 105: #if 0
! 106: dumpconf();
! 107: #endif
! 108: }
! 109:
! 110: /*
! 111: * Crash dump handling.
! 112: */
! 113: u_long dumpmag = 0x8fca0101; /* magic number */
! 114: int dumpsize = 0; /* size of dump in pages */
! 115: long dumplo = -1; /* blocks */
! 116:
! 117: /*
! 118: * This is called by configure to set dumplo and dumpsize.
! 119: * Dumps always skip the first CLBYTES of disk space
! 120: * in case there might be a disk label stored there.
! 121: * If there is extra space, put dump at the end to
! 122: * reduce the chance that swapping trashes it.
! 123: */
! 124: #if 0
! 125: void
! 126: dumpconf(void)
! 127: {
! 128: int nblks; /* size of dump area */
! 129:
! 130: if (dumpdev == NODEV ||
! 131: (nblks = (bdevsw[major(dumpdev)].d_psize)(dumpdev)) == 0)
! 132: return;
! 133: if (nblks <= ctod(1))
! 134: return;
! 135:
! 136: dumpsize = btoc(IOM_END + ctob(dumpmem_high));
! 137:
! 138: /* Always skip the first CLBYTES, in case there is a label there. */
! 139: if (dumplo < ctod(1))
! 140: dumplo = ctod(1);
! 141:
! 142: /* Put dump at end of partition, and make it fit. */
! 143: if (dumpsize > dtoc(nblks - dumplo))
! 144: dumpsize = dtoc(nblks - dumplo);
! 145: if (dumplo < nblks - ctod(dumpsize))
! 146: dumplo = nblks - ctod(dumpsize);
! 147: }
! 148: #endif
! 149:
! 150: /*
! 151: * find a device matching "name" and unit number
! 152: */
! 153: struct device *
! 154: getdevunit(name, unit)
! 155: char *name;
! 156: int unit;
! 157: {
! 158: struct device *dev = TAILQ_FIRST(&alldevs);
! 159: char num[10], fullname[16];
! 160: int lunit;
! 161:
! 162: /* compute length of name and decimal expansion of unit number */
! 163: snprintf(num, sizeof num, "%d", unit);
! 164: lunit = strlen(num);
! 165: if (strlen(name) + lunit >= sizeof(fullname) - 1)
! 166: panic("config_attach: device name too long");
! 167:
! 168: strlcpy(fullname, name, sizeof fullname);
! 169: strlcat(fullname, num, sizeof fullname);
! 170:
! 171: while (strcmp(dev->dv_xname, fullname) != 0) {
! 172: if ((dev = TAILQ_NEXT(dev, dv_list)) == NULL)
! 173: return NULL;
! 174: }
! 175: return dev;
! 176: }
! 177:
! 178: struct nam2blk nam2blk[] = {
! 179: { "wd", 0 },
! 180: { "sd", 2 },
! 181: { "raid", 19 },
! 182: { NULL, -1 }
! 183: };
CVSweb