mambo.c revision 261513
11590Srgrimes/*-
21590Srgrimes * Copyright 2008 by Nathan Whitehorn. All rights reserved.
31590Srgrimes *
41590Srgrimes * Redistribution and use in source and binary forms, with or without
51590Srgrimes * modification, are permitted provided that the following conditions
61590Srgrimes * are met:
71590Srgrimes * 1. Redistributions of source code must retain the above copyright
81590Srgrimes *    notice, this list of conditions and the following disclaimer.
91590Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
101590Srgrimes *    notice, this list of conditions and the following disclaimer in the
111590Srgrimes *    documentation and/or other materials provided with the distribution.
121590Srgrimes *
131590Srgrimes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
141590Srgrimes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
151590Srgrimes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
161590Srgrimes * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
171590Srgrimes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
181590Srgrimes * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
191590Srgrimes * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
201590Srgrimes * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
211590Srgrimes * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
221590Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
231590Srgrimes * SUCH DAMAGE.
241590Srgrimes *
251590Srgrimes */
261590Srgrimes
271590Srgrimes#include <sys/cdefs.h>
281590Srgrimes__FBSDID("$FreeBSD: head/sys/powerpc/mambo/mambo.c 261513 2014-02-05 14:44:22Z nwhitehorn $");
291590Srgrimes
301590Srgrimes#include <sys/param.h>
311590Srgrimes#include <sys/systm.h>
321590Srgrimes#include <sys/module.h>
331590Srgrimes#include <sys/bus.h>
341590Srgrimes#include <sys/conf.h>
351590Srgrimes#include <sys/kernel.h>
361590Srgrimes
371590Srgrimes#include <dev/ofw/ofw_bus.h>
381590Srgrimes#include <dev/ofw/openfirm.h>
391590Srgrimes
401590Srgrimes#include <machine/bus.h>
411590Srgrimes
421590Srgrimes#include <vm/vm.h>
431590Srgrimes#include <vm/pmap.h>
441590Srgrimes
451590Srgrimes#include <sys/rman.h>
461590Srgrimes
471590Srgrimes/*
481590Srgrimes * Mambo interface
491590Srgrimes */
501590Srgrimesstatic int	mambobus_probe(device_t);
511590Srgrimesstatic int	mambobus_attach(device_t);
521590Srgrimes
531590Srgrimesstatic device_method_t  mambobus_methods[] = {
541590Srgrimes	/* Device interface */
551590Srgrimes	DEVMETHOD(device_probe,		mambobus_probe),
561590Srgrimes	DEVMETHOD(device_attach,	mambobus_attach),
571590Srgrimes
581590Srgrimes	/* Bus interface */
591590Srgrimes	DEVMETHOD(bus_add_child,	bus_generic_add_child),
601590Srgrimes	DEVMETHOD(bus_read_ivar,	bus_generic_read_ivar),
611590Srgrimes	DEVMETHOD(bus_setup_intr,	bus_generic_setup_intr),
621590Srgrimes	DEVMETHOD(bus_teardown_intr,	bus_generic_teardown_intr),
631590Srgrimes	DEVMETHOD(bus_alloc_resource,	bus_generic_alloc_resource),
641590Srgrimes	DEVMETHOD(bus_release_resource,	bus_generic_release_resource),
651590Srgrimes	DEVMETHOD(bus_activate_resource,bus_generic_activate_resource),
661590Srgrimes
671590Srgrimes	DEVMETHOD_END
681590Srgrimes};
691590Srgrimes
701590Srgrimesstatic driver_t mambobus_driver = {
711590Srgrimes	"mambo",
721590Srgrimes	mambobus_methods,
731590Srgrimes	0
741590Srgrimes};
751590Srgrimes
761590Srgrimesstatic devclass_t mambobus_devclass;
771590Srgrimes
781590SrgrimesDRIVER_MODULE(mambo, ofwbus, mambobus_driver, mambobus_devclass, 0, 0);
791590Srgrimes
801590Srgrimesstatic int
811590Srgrimesmambobus_probe(device_t dev)
821590Srgrimes{
831590Srgrimes	const char *name = ofw_bus_get_name(dev);
841590Srgrimes
851590Srgrimes	if (name && !strcmp(name, "mambo")) {
861590Srgrimes		device_set_desc(dev, "Mambo Simulator");
871590Srgrimes		return (0);
881590Srgrimes	}
891590Srgrimes
901590Srgrimes	return (ENXIO);
911590Srgrimes}
921590Srgrimes
931590Srgrimesstatic int
941590Srgrimesmambobus_attach(device_t dev)
951590Srgrimes{
961590Srgrimes	bus_generic_probe(dev);
971590Srgrimes	return (bus_generic_attach(dev));
981590Srgrimes}
991590Srgrimes
1001590Srgrimes