]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/bhnd/bhndb/bhndb_if.m
Copy ^/vendor/NetBSD/tests/dist/lib/libc/hash/t_hmac.c to
[FreeBSD/FreeBSD.git] / sys / dev / bhnd / bhndb / bhndb_if.m
1 #-
2 # Copyright (c) 2015 Landon Fuller <landon@landonf.org>
3 # All rights reserved.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
7 # are met:
8 # 1. Redistributions of source code must retain the above copyright
9 #    notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright
11 #    notice, this list of conditions and the following disclaimer in the
12 #    documentation and/or other materials provided with the distribution.
13 #
14 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 # IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18 # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
23 # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 #
25 # $FreeBSD$
26
27 #include <sys/param.h>
28 #include <sys/bus.h>
29
30 #include <machine/bus.h>
31 #include <sys/rman.h>
32 #include <machine/resource.h>
33
34 #include <dev/bhnd/bhnd.h>
35
36 #
37 # bhndb bridge device interface.
38 #
39
40 INTERFACE bhndb;
41
42 HEADER {
43         struct bhndb_regwin;
44         struct bhndb_hw;
45         struct bhndb_hw_priority;
46 }
47
48 CODE {
49         #include <sys/systm.h>
50         #include <dev/bhnd/bhndb/bhndbvar.h>
51
52         static const struct bhnd_chipid *
53         bhndb_null_get_chipid(device_t dev, device_t child)
54         {
55                 panic("bhndb_get_chipid unimplemented");
56         }
57
58         static int
59         bhndb_null_populate_board_info(device_t dev, device_t child,
60             struct bhnd_board_info *info)
61         {
62                 panic("bhndb_populate_board_info unimplemented");
63         }
64
65         static int
66         bhndb_null_is_core_disabled(device_t dev, device_t child,
67             struct bhnd_core_info *core)
68         {
69                 panic("bhndb_is_core_disabled unimplemented");
70         }
71
72         static int
73         bhndb_null_get_hostb_core(device_t dev, device_t child,
74             struct bhnd_core_info *core)
75         {
76                 panic("bhndb_get_hostb_core unimplemented");
77         }
78         
79         static void
80         bhndb_null_suspend_resource(device_t dev, device_t child, int type,
81             struct resource *r)
82         {
83                 panic("bhndb_suspend_resource unimplemented");
84         }
85
86         static int
87         bhndb_null_resume_resource(device_t dev, device_t child, int type,
88             struct resource *r)
89         {
90                 panic("bhndb_resume_resource unimplemented");
91         }
92
93         static int
94         bhndb_null_set_window_addr(device_t dev,
95             const struct bhndb_regwin *rw, bhnd_addr_t addr)
96         {
97                 panic("bhndb_set_window_addr unimplemented");
98         }
99 }
100
101 /**
102  * Return the chip identification information for @p child.
103  *
104  * @param dev The parent device of @p child.
105  * @param child The bhndb-attached device.
106  */
107 METHOD const struct bhnd_chipid * get_chipid {
108         device_t dev;
109         device_t child;
110 } DEFAULT bhndb_null_get_chipid;
111
112 /**
113  * Populate @p info with board info known only to the bridge,
114  * deferring to any existing initialized fields in @p info.
115  *
116  * @param dev The parent device of @p child.
117  * @param child The bhndb-attached device.
118  * @param[in,out] info A board info structure previously initialized with any
119  * information available from NVRAM.
120  */
121 METHOD int populate_board_info {
122         device_t dev;
123         device_t child;
124         struct bhnd_board_info *info;
125 } DEFAULT bhndb_null_populate_board_info;
126
127 /**
128  * Return true if the hardware required by @p core is unpopulated or
129  * otherwise unusable.
130  *
131  * In some cases, the core's pins may be left floating, or the hardware
132  * may otherwise be non-functional; this method allows the parent device
133  * to explicitly specify whether @p core should be disabled.
134  *
135  * @param dev The parent device of @p child.
136  * @param child The attached bhnd device.
137  * @param core A core discovered on @p child.
138  */
139 METHOD bool is_core_disabled {
140         device_t dev;
141         device_t child;
142         struct bhnd_core_info *core;
143 } DEFAULT bhndb_null_is_core_disabled;
144
145 /**
146  * Get the host bridge core info for the attached bhnd bus.
147  *
148  * @param       dev     The bridge device.
149  * @param       child   The bhnd bus device attached to @p dev.
150  * @param[out]  core    Will be populated with the host bridge core info, if
151  *                      found.
152  *
153  * @retval 0            success
154  * @retval ENOENT       No host bridge core found.
155  * @retval non-zero     If locating the host bridge core otherwise fails, a
156  *                      regular UNIX error code should be returned.
157  */
158 METHOD int get_hostb_core {
159         device_t dev;
160         device_t child;
161         struct bhnd_core_info *core;
162 } DEFAULT bhndb_null_get_hostb_core;
163
164 /**
165  * Mark a resource as 'suspended', gauranteeing to the bridge that no
166  * further use of the resource will be made until BHNDB_RESUME_RESOURCE()
167  * is called.
168  *
169  * Bridge resources consumed by the reference may be released; these will
170  * be reacquired if BHNDB_RESUME_RESOURCE() completes successfully.
171  *
172  * Requests to suspend a suspended resource will be ignored.
173  *
174  * @param dev The bridge device.
175  * @param child The child device requesting resource suspension. This does
176  * not need to be the owner of @p r.
177  * @param type The resource type.
178  * @param r The resource to be suspended.
179  */
180 METHOD void suspend_resource {
181         device_t dev;
182         device_t child;
183         int type;
184         struct resource *r;
185 } DEFAULT bhndb_null_suspend_resource;
186
187 /**
188  * Attempt to re-enable a resource previously suspended by
189  * BHNDB_SUSPEND_RESOURCE().
190  *
191  * Bridge resources required by the reference may not be available, in which
192  * case an error will be returned and the resource mapped by @p r must not be
193  * used in any capacity.
194  *
195  * Requests to resume a non-suspended resource will be ignored.
196  * 
197  * @param dev The bridge device.
198  * @param child The child device requesting resource suspension. This does
199  * not need to be the owner of @p r.
200  * @param type The resource type.
201  * @param r The resource to be suspended.
202  */
203 METHOD int resume_resource {
204         device_t dev;
205         device_t child;
206         int type;
207         struct resource *r;
208 } DEFAULT bhndb_null_resume_resource;
209
210 /**
211  * Set a given register window's base address.
212  *
213  * @param dev The bridge device.
214  * @param win The register window.
215  * @param addr The address to be configured for @p win.
216  *
217  * @retval 0 success
218  * @retval ENODEV The provided @p win is not memory-mapped on the bus or does
219  * not support setting a base address.
220  * @retval non-zero failure
221  */
222 METHOD int set_window_addr {
223         device_t dev;
224         const struct bhndb_regwin *win;
225         bhnd_addr_t addr;
226 } DEFAULT bhndb_null_set_window_addr;