xref: /freebsd/sys/powerpc/mambo/mambo.c (revision 5b9c547c)
1 /*-
2  * Copyright 2008 by Nathan Whitehorn. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
18  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
20  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
21  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23  * SUCH DAMAGE.
24  *
25  */
26 
27 #include <sys/cdefs.h>
28 __FBSDID("$FreeBSD$");
29 
30 #include <sys/param.h>
31 #include <sys/systm.h>
32 #include <sys/module.h>
33 #include <sys/bus.h>
34 #include <sys/conf.h>
35 #include <sys/kernel.h>
36 
37 #include <dev/ofw/ofw_bus.h>
38 #include <dev/ofw/openfirm.h>
39 
40 #include <machine/bus.h>
41 
42 #include <vm/vm.h>
43 #include <vm/pmap.h>
44 
45 #include <sys/rman.h>
46 
47 /*
48  * Mambo interface
49  */
50 static int	mambobus_probe(device_t);
51 static int	mambobus_attach(device_t);
52 
53 static device_method_t  mambobus_methods[] = {
54 	/* Device interface */
55 	DEVMETHOD(device_probe,		mambobus_probe),
56 	DEVMETHOD(device_attach,	mambobus_attach),
57 
58 	/* Bus interface */
59 	DEVMETHOD(bus_add_child,	bus_generic_add_child),
60 	DEVMETHOD(bus_read_ivar,	bus_generic_read_ivar),
61 	DEVMETHOD(bus_setup_intr,	bus_generic_setup_intr),
62 	DEVMETHOD(bus_teardown_intr,	bus_generic_teardown_intr),
63 	DEVMETHOD(bus_alloc_resource,	bus_generic_alloc_resource),
64 	DEVMETHOD(bus_release_resource,	bus_generic_release_resource),
65 	DEVMETHOD(bus_activate_resource,bus_generic_activate_resource),
66 
67 	DEVMETHOD_END
68 };
69 
70 static driver_t mambobus_driver = {
71 	"mambo",
72 	mambobus_methods,
73 	0
74 };
75 
76 static devclass_t mambobus_devclass;
77 
78 DRIVER_MODULE(mambo, ofwbus, mambobus_driver, mambobus_devclass, 0, 0);
79 
80 static int
81 mambobus_probe(device_t dev)
82 {
83 	const char *name = ofw_bus_get_name(dev);
84 
85 	if (name && !strcmp(name, "mambo")) {
86 		device_set_desc(dev, "Mambo Simulator");
87 		return (0);
88 	}
89 
90 	return (ENXIO);
91 }
92 
93 static int
94 mambobus_attach(device_t dev)
95 {
96 	bus_generic_probe(dev);
97 	return (bus_generic_attach(dev));
98 }
99 
100