mainbus.c revision 1.8
11.8Snonaka/*	$NetBSD: mainbus.c,v 1.8 2010/04/06 15:54:30 nonaka Exp $	*/
21.1Such
31.2Such/*-
41.2Such * Copyright (c) 2002 The NetBSD Foundation, Inc.
51.2Such * All rights reserved.
61.1Such *
71.1Such * Redistribution and use in source and binary forms, with or without
81.1Such * modification, are permitted provided that the following conditions
91.1Such * are met:
101.1Such * 1. Redistributions of source code must retain the above copyright
111.1Such *    notice, this list of conditions and the following disclaimer.
121.1Such * 2. Redistributions in binary form must reproduce the above copyright
131.1Such *    notice, this list of conditions and the following disclaimer in the
141.1Such *    documentation and/or other materials provided with the distribution.
151.1Such *
161.2Such * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
171.2Such * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
181.2Such * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
191.2Such * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
201.2Such * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
211.2Such * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
221.2Such * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
231.2Such * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
241.2Such * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
251.2Such * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
261.2Such * POSSIBILITY OF SUCH DAMAGE.
271.1Such */
281.5Slukem
291.5Slukem#include <sys/cdefs.h>
301.8Snonaka__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.8 2010/04/06 15:54:30 nonaka Exp $");
311.1Such
321.1Such#include <sys/param.h>
331.1Such#include <sys/systm.h>
341.1Such#include <sys/device.h>
351.8Snonaka
361.2Such#include <machine/autoconf.h>
371.1Such
381.8Snonakastatic int mainbus_match(struct device *, struct cfdata *, void *);
391.8Snonakastatic void mainbus_attach(struct device *, struct device *, void *);
401.1Such
411.8SnonakaCFATTACH_DECL_NEW(mainbus, sizeof(struct device),
421.4Sthorpej    mainbus_match, mainbus_attach, NULL, NULL);
431.1Such
441.8Snonakastatic int mainbus_search(device_t, cfdata_t, const int *, void *);
451.8Snonakastatic int mainbus_print(void *, const char *);
461.8Snonaka
471.8Snonakastatic int
481.8Snonakamainbus_match(device_t parent, cfdata_t cf, void *aux)
491.1Such{
501.1Such
511.2Such	return (1);
521.1Such}
531.1Such
541.8Snonakastatic void
551.8Snonakamainbus_attach(device_t parent, device_t self, void *aux)
561.8Snonaka{
571.8Snonaka	struct mainbus_attach_args maa;
581.8Snonaka
591.8Snonaka	aprint_naive("\n");
601.8Snonaka	aprint_normal("\n");
611.8Snonaka
621.8Snonaka	/* CPU  */
631.8Snonaka	memset(&maa, 0, sizeof(maa));
641.8Snonaka	maa.ma_name = "cpu";
651.8Snonaka	config_found_ia(self, "mainbus", &maa, mainbus_print);
661.8Snonaka
671.8Snonaka	/* Devices */
681.8Snonaka	config_search_ia(mainbus_search, self, "mainbus", NULL);
691.8Snonaka}
701.8Snonaka
711.8Snonakastatic int
721.8Snonakamainbus_search(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
731.1Such{
741.8Snonaka	struct mainbus_attach_args maa;
751.8Snonaka
761.8Snonaka	if (strcmp(cf->cf_name, "cpu") == 0)
771.8Snonaka		return 0;
781.8Snonaka
791.8Snonaka	maa.ma_name = cf->cf_name;
801.1Such
811.8Snonaka	if (config_match(parent, cf, &maa))
821.8Snonaka		config_attach(parent, cf, &maa, mainbus_print);
831.1Such
841.8Snonaka	return 0;
851.1Such}
861.1Such
871.8Snonakastatic int
881.2Suchmainbus_print(void *aux, const char *pnp)
891.1Such{
901.1Such
911.2Such	return (pnp ? QUIET : UNCONF);
921.1Such}
93