1 #-
2 # Copyright (c) 2001, 2003 by Thomas Moestl <tmm@FreeBSD.org>
3 # Copyright (c) 2004, 2005 by Marius Strobl <marius@FreeBSD.org>
4 # Copyright (c) 2006 by Kip Macy <kmacy@FreeBSD.org>
5 # All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
9 # are met:
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
15 #
16 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 # IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
20 # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
25 # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #
27 # $FreeBSD$
28
29 # Interface for retrieving the package handle and a subset, namely
30 # 'compatible', 'device_type', 'model' and 'name', of the standard
31 # properties of a device on an Open Firmware assisted bus for use
32 # in device drivers. The rest of the standard properties, 'address',
33 # 'interrupts', 'reg' and 'status', are not covered by this interface
34 # as they are expected to be only of interest in the respective bus
35 # driver.
36
37 #include <sys/bus.h>
38
39 #include <machine/cddl/mdesc.h>
40
41 INTERFACE mdesc_bus;
42
43 HEADER {
44 struct mdesc_bus_devinfo {
45 char *mbd_compat;
46 char *mbd_name;
47 char *mbd_type;
48 uint64_t mbd_handle;
49 };
50 };
51
52 CODE {
53 static mdesc_bus_get_devinfo_t mdesc_bus_default_get_devinfo;
54 static mdesc_bus_get_compat_t mdesc_bus_default_get_compat;
55 static mdesc_bus_get_name_t mdesc_bus_default_get_name;
56 static mdesc_bus_get_type_t mdesc_bus_default_get_type;
57
58 static const struct mdesc_bus_devinfo *
59 mdesc_bus_default_get_devinfo(device_t bus, device_t dev)
60 {
61
62 return (NULL);
63 }
64
65 static const char *
66 mdesc_bus_default_get_compat(device_t bus, device_t dev)
67 {
68
69 return (NULL);
70 }
71
72 static const char *
73 mdesc_bus_default_get_name(device_t bus, device_t dev)
74 {
75
76 return (NULL);
77 }
78
79 static const char *
80 mdesc_bus_default_get_type(device_t bus, device_t dev)
81 {
82
83 return (NULL);
84 }
85
86 static uint64_t
87 mdesc_bus_default_get_handle(device_t bus, device_t dev)
88 {
89
90 return (0);
91 }
92 };
93
94 # Get the mdesc_bus_devinfo struct for the device dev on the bus. Used for bus
95 # drivers which use the generic methods in mdesc_bus_subr.c to implement the
96 # reset of this interface. The default method will return NULL, which means
97 # there is no such struct associated with the device.
98 METHOD const struct mdesc_bus_devinfo * get_devinfo {
99 device_t bus;
100 device_t dev;
101 } DEFAULT mdesc_bus_default_get_devinfo;
102
103 # Get the alternate firmware name for the device dev on the bus. The default
104 # method will return NULL, which means the device doesn't have such a property.
105 METHOD const char * get_compat {
106 device_t bus;
107 device_t dev;
108 } DEFAULT mdesc_bus_default_get_compat;
109
110 # Get the firmware name for the device dev on the bus. The default method will
111 # return NULL, which means the device doesn't have such a property.
112 METHOD const char * get_name {
113 device_t bus;
114 device_t dev;
115 } DEFAULT mdesc_bus_default_get_name;
116
117 # Get the firmware device type for the device dev on the bus. The default
118 # method will return NULL, which means the device doesn't have such a property.
119 METHOD const char * get_type {
120 device_t bus;
121 device_t dev;
122 } DEFAULT mdesc_bus_default_get_type;
123
124 METHOD uint64_t get_handle {
125 device_t bus;
126 device_t dev;
127 } DEFAULT mdesc_bus_default_get_handle;
Cache object: f8400c62b92dec7f71dc364dfa62a487
|