autoconf.c revision 131814
1249033Ssjg/*-
2236769Sobrien * Copyright (c) 1998 Doug Rabson
3236769Sobrien * All rights reserved.
4236769Sobrien *
5236769Sobrien * Redistribution and use in source and binary forms, with or without
6236769Sobrien * modification, are permitted provided that the following conditions
7236769Sobrien * are met:
8236769Sobrien * 1. Redistributions of source code must retain the above copyright
9236769Sobrien *    notice, this list of conditions and the following disclaimer.
10236769Sobrien * 2. Redistributions in binary form must reproduce the above copyright
11236769Sobrien *    notice, this list of conditions and the following disclaimer in the
12236769Sobrien *    documentation and/or other materials provided with the distribution.
13236769Sobrien *
14236769Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15236769Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16236769Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17236769Sobrien * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18236769Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19236769Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20236769Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21236769Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22236769Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23236769Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24236769Sobrien * SUCH DAMAGE.
25236769Sobrien *
26236769Sobrien * $FreeBSD: head/sys/ia64/ia64/autoconf.c 131814 2004-07-08 13:40:33Z brian $
27236769Sobrien */
28236769Sobrien
29236769Sobrien#include "opt_isa.h"
30236769Sobrien#include "opt_nfs.h"
31236769Sobrien#include "opt_nfsroot.h"
32236769Sobrien
33236769Sobrien#include <sys/param.h>
34236769Sobrien#include <sys/systm.h>
35236769Sobrien#include <sys/conf.h>
36236769Sobrien#include <sys/reboot.h>
37236769Sobrien#include <sys/kernel.h>
38236769Sobrien#include <sys/mount.h>
39236769Sobrien#include <sys/sysctl.h>
40236769Sobrien#include <sys/bus.h>
41236769Sobrien#include <sys/cons.h>
42236769Sobrien
43236769Sobrien#include <machine/md_var.h>
44236769Sobrien#include <machine/bootinfo.h>
45236769Sobrien
46236769Sobrien#include <cam/cam.h>
47236769Sobrien#include <cam/cam_ccb.h>
48236769Sobrien#include <cam/cam_sim.h>
49236769Sobrien#include <cam/cam_periph.h>
50236769Sobrien#include <cam/cam_xpt_sim.h>
51236769Sobrien#include <cam/cam_debug.h>
52236769Sobrien
53236769Sobrienstatic void	configure(void *);
54236769SobrienSYSINIT(configure, SI_SUB_CONFIGURE, SI_ORDER_THIRD, configure, NULL)
55236769Sobrien
56236769Sobrienvoid bootpc_init(void);
57236769Sobrien
58236769Sobrien#ifdef DEV_ISA
59236769Sobrien#include <isa/isavar.h>
60236769Sobriendevice_t isa_bus_device = 0;
61236769Sobrien#endif
62236769Sobrien
63236769Sobrienextern int nfs_diskless_valid;		/* XXX use include file */
64236769Sobrien
65236769Sobrien/*
66236769Sobrien * Determine i/o configuration for a machine.
67236769Sobrien */
68236769Sobrienstatic void
69236769Sobrienconfigure(void *dummy)
70236769Sobrien{
71236769Sobrien	device_add_child(root_bus, "nexus", 0);
72236769Sobrien
73249033Ssjg	root_bus_configure();
74236769Sobrien
75236769Sobrien	/*
76236769Sobrien	 * Probe ISA devices after everything.
77236769Sobrien	 */
78236769Sobrien#ifdef DEV_ISA
79236769Sobrien	if (isa_bus_device)
80249033Ssjg		isa_probe_children(isa_bus_device);
81236769Sobrien#endif
82236769Sobrien
83236769Sobrien	/*
84236769Sobrien	 * Now we're ready to handle (pending) interrupts.
85236769Sobrien	 * XXX this is slightly misplaced.
86236769Sobrien	 */
87236769Sobrien	enable_intr();
88236769Sobrien
89236769Sobrien	cold = 0;
90236769Sobrien}
91236769Sobrien
92236769Sobrien/*
93236769Sobrien * Do legacy root filesystem discovery.  This isn't really
94236769Sobrien * needed on the Alpha, which has always used the loader.
95236769Sobrien */
96236769Sobrienvoid
97236769Sobriencpu_rootconf()
98236769Sobrien{
99236769Sobrien	char	*cp;
100236769Sobrien
101236769Sobrien	if ((cp = getenv("bootp")) != NULL) {
102236769Sobrien        	bootpc_init();
103236769Sobrien		freeenv(cp);
104236769Sobrien		cp = NULL;
105236769Sobrien	}
106236769Sobrien#if defined(NFSCLIENT) && defined(NFS_ROOT)
107236769Sobrien	if (nfs_diskless_valid || (cp = getenv("bootp.nfsroot")) != NULL)
108236769Sobrien		rootdevnames[0] = "nfs:";
109236769Sobrien	if (cp != NULL)
110236769Sobrien		freeenv(cp);
111236769Sobrien#endif
112236769Sobrien}
113236769SobrienSYSINIT(cpu_rootconf, SI_SUB_ROOT_CONF, SI_ORDER_FIRST, cpu_rootconf, NULL)
114236769Sobrien