Line 0
Link Here
|
|
|
1 |
/* |
2 |
* This file is @generated automatically. |
3 |
* Do not modify anything in here by hand. |
4 |
* |
5 |
* Created from source file |
6 |
* /usr/src/sys/kern/bus_if.m |
7 |
* with |
8 |
* makeobjops.awk |
9 |
* |
10 |
* See the source file for legal information |
11 |
*/ |
12 |
|
13 |
/** |
14 |
* @defgroup BUS bus - KObj methods for drivers of devices with children |
15 |
* @brief A set of methods required device drivers that support |
16 |
* child devices. |
17 |
* @{ |
18 |
*/ |
19 |
|
20 |
#ifndef _bus_if_h_ |
21 |
#define _bus_if_h_ |
22 |
|
23 |
/** @brief Unique descriptor for the BUS_PRINT_CHILD() method */ |
24 |
extern struct kobjop_desc bus_print_child_desc; |
25 |
/** @brief A function implementing the BUS_PRINT_CHILD() method */ |
26 |
typedef int bus_print_child_t(device_t _dev, device_t _child); |
27 |
/** |
28 |
* @brief Print a description of a child device |
29 |
* |
30 |
* This is called from system code which prints out a description of a |
31 |
* device. It should describe the attachment that the child has with |
32 |
* the parent. For instance the TurboLaser bus prints which node the |
33 |
* device is attached to. See bus_generic_print_child() for more |
34 |
* information. |
35 |
* |
36 |
* @param _dev the device whose child is being printed |
37 |
* @param _child the child device to describe |
38 |
* |
39 |
* @returns the number of characters output. |
40 |
*/ |
41 |
|
42 |
static __inline int BUS_PRINT_CHILD(device_t _dev, device_t _child) |
43 |
{ |
44 |
kobjop_t _m; |
45 |
int rc; |
46 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_print_child); |
47 |
rc = ((bus_print_child_t *) _m)(_dev, _child); |
48 |
return (rc); |
49 |
} |
50 |
|
51 |
/** @brief Unique descriptor for the BUS_PROBE_NOMATCH() method */ |
52 |
extern struct kobjop_desc bus_probe_nomatch_desc; |
53 |
/** @brief A function implementing the BUS_PROBE_NOMATCH() method */ |
54 |
typedef void bus_probe_nomatch_t(device_t _dev, device_t _child); |
55 |
/** |
56 |
* @brief Print a notification about an unprobed child device. |
57 |
* |
58 |
* Called for each child device that did not succeed in probing for a |
59 |
* driver. |
60 |
* |
61 |
* @param _dev the device whose child was being probed |
62 |
* @param _child the child device which failed to probe |
63 |
*/ |
64 |
|
65 |
static __inline void BUS_PROBE_NOMATCH(device_t _dev, device_t _child) |
66 |
{ |
67 |
kobjop_t _m; |
68 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_probe_nomatch); |
69 |
((bus_probe_nomatch_t *) _m)(_dev, _child); |
70 |
} |
71 |
|
72 |
/** @brief Unique descriptor for the BUS_READ_IVAR() method */ |
73 |
extern struct kobjop_desc bus_read_ivar_desc; |
74 |
/** @brief A function implementing the BUS_READ_IVAR() method */ |
75 |
typedef int bus_read_ivar_t(device_t _dev, device_t _child, int _index, |
76 |
uintptr_t *_result); |
77 |
/** |
78 |
* @brief Read the value of a bus-specific attribute of a device |
79 |
* |
80 |
* This method, along with BUS_WRITE_IVAR() manages a bus-specific set |
81 |
* of instance variables of a child device. The intention is that |
82 |
* each different type of bus defines a set of appropriate instance |
83 |
* variables (such as ports and irqs for ISA bus etc.) |
84 |
* |
85 |
* This information could be given to the child device as a struct but |
86 |
* that makes it hard for a bus to add or remove variables without |
87 |
* forcing an edit and recompile for all drivers which may not be |
88 |
* possible for vendor supplied binary drivers. |
89 |
* |
90 |
* This method copies the value of an instance variable to the |
91 |
* location specified by @p *_result. |
92 |
* |
93 |
* @param _dev the device whose child was being examined |
94 |
* @param _child the child device whose instance variable is |
95 |
* being read |
96 |
* @param _index the instance variable to read |
97 |
* @param _result a location to receive the instance variable |
98 |
* value |
99 |
* |
100 |
* @retval 0 success |
101 |
* @retval ENOENT no such instance variable is supported by @p |
102 |
* _dev |
103 |
*/ |
104 |
|
105 |
static __inline int BUS_READ_IVAR(device_t _dev, device_t _child, int _index, |
106 |
uintptr_t *_result) |
107 |
{ |
108 |
kobjop_t _m; |
109 |
int rc; |
110 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_read_ivar); |
111 |
rc = ((bus_read_ivar_t *) _m)(_dev, _child, _index, _result); |
112 |
return (rc); |
113 |
} |
114 |
|
115 |
/** @brief Unique descriptor for the BUS_WRITE_IVAR() method */ |
116 |
extern struct kobjop_desc bus_write_ivar_desc; |
117 |
/** @brief A function implementing the BUS_WRITE_IVAR() method */ |
118 |
typedef int bus_write_ivar_t(device_t _dev, device_t _child, int _indx, |
119 |
uintptr_t _value); |
120 |
/** |
121 |
* @brief Write the value of a bus-specific attribute of a device |
122 |
* |
123 |
* This method sets the value of an instance variable to @p _value. |
124 |
* |
125 |
* @param _dev the device whose child was being updated |
126 |
* @param _child the child device whose instance variable is |
127 |
* being written |
128 |
* @param _index the instance variable to write |
129 |
* @param _value the value to write to that instance variable |
130 |
* |
131 |
* @retval 0 success |
132 |
* @retval ENOENT no such instance variable is supported by @p |
133 |
* _dev |
134 |
* @retval EINVAL the instance variable was recognised but |
135 |
* contains a read-only value |
136 |
*/ |
137 |
|
138 |
static __inline int BUS_WRITE_IVAR(device_t _dev, device_t _child, int _indx, |
139 |
uintptr_t _value) |
140 |
{ |
141 |
kobjop_t _m; |
142 |
int rc; |
143 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_write_ivar); |
144 |
rc = ((bus_write_ivar_t *) _m)(_dev, _child, _indx, _value); |
145 |
return (rc); |
146 |
} |
147 |
|
148 |
/** @brief Unique descriptor for the BUS_CHILD_DELETED() method */ |
149 |
extern struct kobjop_desc bus_child_deleted_desc; |
150 |
/** @brief A function implementing the BUS_CHILD_DELETED() method */ |
151 |
typedef void bus_child_deleted_t(device_t _dev, device_t _child); |
152 |
/** |
153 |
* @brief Notify a bus that a child was deleted |
154 |
* |
155 |
* Called at the beginning of device_delete_child() to allow the parent |
156 |
* to teardown any bus-specific state for the child. |
157 |
* |
158 |
* @param _dev the device whose child is being deleted |
159 |
* @param _child the child device which is being deleted |
160 |
*/ |
161 |
|
162 |
static __inline void BUS_CHILD_DELETED(device_t _dev, device_t _child) |
163 |
{ |
164 |
kobjop_t _m; |
165 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_child_deleted); |
166 |
((bus_child_deleted_t *) _m)(_dev, _child); |
167 |
} |
168 |
|
169 |
/** @brief Unique descriptor for the BUS_CHILD_DETACHED() method */ |
170 |
extern struct kobjop_desc bus_child_detached_desc; |
171 |
/** @brief A function implementing the BUS_CHILD_DETACHED() method */ |
172 |
typedef void bus_child_detached_t(device_t _dev, device_t _child); |
173 |
/** |
174 |
* @brief Notify a bus that a child was detached |
175 |
* |
176 |
* Called after the child's DEVICE_DETACH() method to allow the parent |
177 |
* to reclaim any resources allocated on behalf of the child. |
178 |
* |
179 |
* @param _dev the device whose child changed state |
180 |
* @param _child the child device which changed state |
181 |
*/ |
182 |
|
183 |
static __inline void BUS_CHILD_DETACHED(device_t _dev, device_t _child) |
184 |
{ |
185 |
kobjop_t _m; |
186 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_child_detached); |
187 |
((bus_child_detached_t *) _m)(_dev, _child); |
188 |
} |
189 |
|
190 |
/** @brief Unique descriptor for the BUS_DRIVER_ADDED() method */ |
191 |
extern struct kobjop_desc bus_driver_added_desc; |
192 |
/** @brief A function implementing the BUS_DRIVER_ADDED() method */ |
193 |
typedef void bus_driver_added_t(device_t _dev, driver_t *_driver); |
194 |
/** |
195 |
* @brief Notify a bus that a new driver was added |
196 |
* |
197 |
* Called when a new driver is added to the devclass which owns this |
198 |
* bus. The generic implementation of this method attempts to probe and |
199 |
* attach any un-matched children of the bus. |
200 |
* |
201 |
* @param _dev the device whose devclass had a new driver |
202 |
* added to it |
203 |
* @param _driver the new driver which was added |
204 |
*/ |
205 |
|
206 |
static __inline void BUS_DRIVER_ADDED(device_t _dev, driver_t *_driver) |
207 |
{ |
208 |
kobjop_t _m; |
209 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_driver_added); |
210 |
((bus_driver_added_t *) _m)(_dev, _driver); |
211 |
} |
212 |
|
213 |
/** @brief Unique descriptor for the BUS_ADD_CHILD() method */ |
214 |
extern struct kobjop_desc bus_add_child_desc; |
215 |
/** @brief A function implementing the BUS_ADD_CHILD() method */ |
216 |
typedef device_t bus_add_child_t(device_t _dev, u_int _order, const char *_name, |
217 |
int _unit); |
218 |
/** |
219 |
* @brief Create a new child device |
220 |
* |
221 |
* For buses which use use drivers supporting DEVICE_IDENTIFY() to |
222 |
* enumerate their devices, this method is used to create new |
223 |
* device instances. The new device will be added after the last |
224 |
* existing child with the same order. Implementations of bus_add_child |
225 |
* call device_add_child_ordered to add the child and often add |
226 |
* a suitable ivar to the device specific to that bus. |
227 |
* |
228 |
* @param _dev the bus device which will be the parent of the |
229 |
* new child device |
230 |
* @param _order a value which is used to partially sort the |
231 |
* children of @p _dev - devices created using |
232 |
* lower values of @p _order appear first in @p |
233 |
* _dev's list of children |
234 |
* @param _name devclass name for new device or @c NULL if not |
235 |
* specified |
236 |
* @param _unit unit number for new device or @c -1 if not |
237 |
* specified |
238 |
*/ |
239 |
|
240 |
static __inline device_t BUS_ADD_CHILD(device_t _dev, u_int _order, |
241 |
const char *_name, int _unit) |
242 |
{ |
243 |
kobjop_t _m; |
244 |
device_t rc; |
245 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_add_child); |
246 |
rc = ((bus_add_child_t *) _m)(_dev, _order, _name, _unit); |
247 |
return (rc); |
248 |
} |
249 |
|
250 |
/** @brief Unique descriptor for the BUS_RESCAN() method */ |
251 |
extern struct kobjop_desc bus_rescan_desc; |
252 |
/** @brief A function implementing the BUS_RESCAN() method */ |
253 |
typedef int bus_rescan_t(device_t _dev); |
254 |
/** |
255 |
* @brief Rescan the bus |
256 |
* |
257 |
* This method is called by a parent bridge or devctl to trigger a bus |
258 |
* rescan. The rescan should delete devices no longer present and |
259 |
* enumerate devices that have newly arrived. |
260 |
* |
261 |
* @param _dev the bus device |
262 |
*/ |
263 |
|
264 |
static __inline int BUS_RESCAN(device_t _dev) |
265 |
{ |
266 |
kobjop_t _m; |
267 |
int rc; |
268 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_rescan); |
269 |
rc = ((bus_rescan_t *) _m)(_dev); |
270 |
return (rc); |
271 |
} |
272 |
|
273 |
/** @brief Unique descriptor for the BUS_ALLOC_RESOURCE() method */ |
274 |
extern struct kobjop_desc bus_alloc_resource_desc; |
275 |
/** @brief A function implementing the BUS_ALLOC_RESOURCE() method */ |
276 |
typedef struct resource * bus_alloc_resource_t(device_t _dev, device_t _child, |
277 |
int _type, int *_rid, |
278 |
rman_res_t _start, |
279 |
rman_res_t _end, |
280 |
rman_res_t _count, u_int _flags); |
281 |
/** |
282 |
* @brief Allocate a system resource |
283 |
* |
284 |
* This method is called by child devices of a bus to allocate resources. |
285 |
* The types are defined in <machine/resource.h>; the meaning of the |
286 |
* resource-ID field varies from bus to bus (but @p *rid == 0 is always |
287 |
* valid if the resource type is). If a resource was allocated and the |
288 |
* caller did not use the RF_ACTIVE to specify that it should be |
289 |
* activated immediately, the caller is responsible for calling |
290 |
* BUS_ACTIVATE_RESOURCE() when it actually uses the resource. |
291 |
* |
292 |
* @param _dev the parent device of @p _child |
293 |
* @param _child the device which is requesting an allocation |
294 |
* @param _type the type of resource to allocate |
295 |
* @param _rid a pointer to the resource identifier |
296 |
* @param _start hint at the start of the resource range - pass |
297 |
* @c 0 for any start address |
298 |
* @param _end hint at the end of the resource range - pass |
299 |
* @c ~0 for any end address |
300 |
* @param _count hint at the size of range required - pass @c 1 |
301 |
* for any size |
302 |
* @param _flags any extra flags to control the resource |
303 |
* allocation - see @c RF_XXX flags in |
304 |
* <sys/rman.h> for details |
305 |
* |
306 |
* @returns the resource which was allocated or @c NULL if no |
307 |
* resource could be allocated |
308 |
*/ |
309 |
|
310 |
static __inline struct resource * BUS_ALLOC_RESOURCE(device_t _dev, |
311 |
device_t _child, int _type, |
312 |
int *_rid, |
313 |
rman_res_t _start, |
314 |
rman_res_t _end, |
315 |
rman_res_t _count, |
316 |
u_int _flags) |
317 |
{ |
318 |
kobjop_t _m; |
319 |
struct resource * rc; |
320 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_alloc_resource); |
321 |
rc = ((bus_alloc_resource_t *) _m)(_dev, _child, _type, _rid, _start, _end, _count, _flags); |
322 |
return (rc); |
323 |
} |
324 |
|
325 |
/** @brief Unique descriptor for the BUS_ACTIVATE_RESOURCE() method */ |
326 |
extern struct kobjop_desc bus_activate_resource_desc; |
327 |
/** @brief A function implementing the BUS_ACTIVATE_RESOURCE() method */ |
328 |
typedef int bus_activate_resource_t(device_t _dev, device_t _child, int _type, |
329 |
int _rid, struct resource *_r); |
330 |
/** |
331 |
* @brief Activate a resource |
332 |
* |
333 |
* Activate a resource previously allocated with |
334 |
* BUS_ALLOC_RESOURCE(). This may enable decoding of this resource in a |
335 |
* device for instance. It will also establish a mapping for the resource |
336 |
* unless RF_UNMAPPED was set when allocating the resource. |
337 |
* |
338 |
* @param _dev the parent device of @p _child |
339 |
* @param _child the device which allocated the resource |
340 |
* @param _type the type of resource |
341 |
* @param _rid the resource identifier |
342 |
* @param _r the resource to activate |
343 |
*/ |
344 |
|
345 |
static __inline int BUS_ACTIVATE_RESOURCE(device_t _dev, device_t _child, |
346 |
int _type, int _rid, |
347 |
struct resource *_r) |
348 |
{ |
349 |
kobjop_t _m; |
350 |
int rc; |
351 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_activate_resource); |
352 |
rc = ((bus_activate_resource_t *) _m)(_dev, _child, _type, _rid, _r); |
353 |
return (rc); |
354 |
} |
355 |
|
356 |
/** @brief Unique descriptor for the BUS_MAP_RESOURCE() method */ |
357 |
extern struct kobjop_desc bus_map_resource_desc; |
358 |
/** @brief A function implementing the BUS_MAP_RESOURCE() method */ |
359 |
typedef int bus_map_resource_t(device_t _dev, device_t _child, int _type, |
360 |
struct resource *_r, |
361 |
struct resource_map_request *_args, |
362 |
struct resource_map *_map); |
363 |
/** |
364 |
* @brief Map a resource |
365 |
* |
366 |
* Allocate a mapping for a range of an active resource. The mapping |
367 |
* is described by a struct resource_map object. This may for instance |
368 |
* map a memory region into the kernel's virtual address space. |
369 |
* |
370 |
* @param _dev the parent device of @p _child |
371 |
* @param _child the device which allocated the resource |
372 |
* @param _type the type of resource |
373 |
* @param _r the resource to map |
374 |
* @param _args optional attributes of the mapping |
375 |
* @param _map the mapping |
376 |
*/ |
377 |
|
378 |
static __inline int BUS_MAP_RESOURCE(device_t _dev, device_t _child, int _type, |
379 |
struct resource *_r, |
380 |
struct resource_map_request *_args, |
381 |
struct resource_map *_map) |
382 |
{ |
383 |
kobjop_t _m; |
384 |
int rc; |
385 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_map_resource); |
386 |
rc = ((bus_map_resource_t *) _m)(_dev, _child, _type, _r, _args, _map); |
387 |
return (rc); |
388 |
} |
389 |
|
390 |
/** @brief Unique descriptor for the BUS_UNMAP_RESOURCE() method */ |
391 |
extern struct kobjop_desc bus_unmap_resource_desc; |
392 |
/** @brief A function implementing the BUS_UNMAP_RESOURCE() method */ |
393 |
typedef int bus_unmap_resource_t(device_t _dev, device_t _child, int _type, |
394 |
struct resource *_r, |
395 |
struct resource_map *_map); |
396 |
/** |
397 |
* @brief Unmap a resource |
398 |
* |
399 |
* Release a mapping previously allocated with |
400 |
* BUS_MAP_RESOURCE(). This may for instance unmap a memory region |
401 |
* from the kernel's virtual address space. |
402 |
* |
403 |
* @param _dev the parent device of @p _child |
404 |
* @param _child the device which allocated the resource |
405 |
* @param _type the type of resource |
406 |
* @param _r the resource |
407 |
* @param _map the mapping to release |
408 |
*/ |
409 |
|
410 |
static __inline int BUS_UNMAP_RESOURCE(device_t _dev, device_t _child, |
411 |
int _type, struct resource *_r, |
412 |
struct resource_map *_map) |
413 |
{ |
414 |
kobjop_t _m; |
415 |
int rc; |
416 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_unmap_resource); |
417 |
rc = ((bus_unmap_resource_t *) _m)(_dev, _child, _type, _r, _map); |
418 |
return (rc); |
419 |
} |
420 |
|
421 |
/** @brief Unique descriptor for the BUS_DEACTIVATE_RESOURCE() method */ |
422 |
extern struct kobjop_desc bus_deactivate_resource_desc; |
423 |
/** @brief A function implementing the BUS_DEACTIVATE_RESOURCE() method */ |
424 |
typedef int bus_deactivate_resource_t(device_t _dev, device_t _child, int _type, |
425 |
int _rid, struct resource *_r); |
426 |
/** |
427 |
* @brief Deactivate a resource |
428 |
* |
429 |
* Deactivate a resource previously allocated with |
430 |
* BUS_ALLOC_RESOURCE(). |
431 |
* |
432 |
* @param _dev the parent device of @p _child |
433 |
* @param _child the device which allocated the resource |
434 |
* @param _type the type of resource |
435 |
* @param _rid the resource identifier |
436 |
* @param _r the resource to deactivate |
437 |
*/ |
438 |
|
439 |
static __inline int BUS_DEACTIVATE_RESOURCE(device_t _dev, device_t _child, |
440 |
int _type, int _rid, |
441 |
struct resource *_r) |
442 |
{ |
443 |
kobjop_t _m; |
444 |
int rc; |
445 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_deactivate_resource); |
446 |
rc = ((bus_deactivate_resource_t *) _m)(_dev, _child, _type, _rid, _r); |
447 |
return (rc); |
448 |
} |
449 |
|
450 |
/** @brief Unique descriptor for the BUS_ADJUST_RESOURCE() method */ |
451 |
extern struct kobjop_desc bus_adjust_resource_desc; |
452 |
/** @brief A function implementing the BUS_ADJUST_RESOURCE() method */ |
453 |
typedef int bus_adjust_resource_t(device_t _dev, device_t _child, int _type, |
454 |
struct resource *_res, rman_res_t _start, |
455 |
rman_res_t _end); |
456 |
/** |
457 |
* @brief Adjust a resource |
458 |
* |
459 |
* Adjust the start and/or end of a resource allocated by |
460 |
* BUS_ALLOC_RESOURCE. At least part of the new address range must overlap |
461 |
* with the existing address range. If the successful, the resource's range |
462 |
* will be adjusted to [start, end] on return. |
463 |
* |
464 |
* @param _dev the parent device of @p _child |
465 |
* @param _child the device which allocated the resource |
466 |
* @param _type the type of resource |
467 |
* @param _res the resource to adjust |
468 |
* @param _start the new starting address of the resource range |
469 |
* @param _end the new ending address of the resource range |
470 |
*/ |
471 |
|
472 |
static __inline int BUS_ADJUST_RESOURCE(device_t _dev, device_t _child, |
473 |
int _type, struct resource *_res, |
474 |
rman_res_t _start, rman_res_t _end) |
475 |
{ |
476 |
kobjop_t _m; |
477 |
int rc; |
478 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_adjust_resource); |
479 |
rc = ((bus_adjust_resource_t *) _m)(_dev, _child, _type, _res, _start, _end); |
480 |
return (rc); |
481 |
} |
482 |
|
483 |
/** @brief Unique descriptor for the BUS_TRANSLATE_RESOURCE() method */ |
484 |
extern struct kobjop_desc bus_translate_resource_desc; |
485 |
/** @brief A function implementing the BUS_TRANSLATE_RESOURCE() method */ |
486 |
typedef int bus_translate_resource_t(device_t _dev, int _type, |
487 |
rman_res_t _start, rman_res_t *_newstart); |
488 |
/** |
489 |
* @brief translate a resource value |
490 |
* |
491 |
* |
492 |
* @param _dev the device associated with the resource |
493 |
* @param _type the type of resource |
494 |
* @param _start the starting address of the resource range |
495 |
* @param _newstart the new starting address of the resource range |
496 |
*/ |
497 |
|
498 |
static __inline int BUS_TRANSLATE_RESOURCE(device_t _dev, int _type, |
499 |
rman_res_t _start, |
500 |
rman_res_t *_newstart) |
501 |
{ |
502 |
kobjop_t _m; |
503 |
int rc; |
504 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_translate_resource); |
505 |
rc = ((bus_translate_resource_t *) _m)(_dev, _type, _start, _newstart); |
506 |
return (rc); |
507 |
} |
508 |
|
509 |
/** @brief Unique descriptor for the BUS_RELEASE_RESOURCE() method */ |
510 |
extern struct kobjop_desc bus_release_resource_desc; |
511 |
/** @brief A function implementing the BUS_RELEASE_RESOURCE() method */ |
512 |
typedef int bus_release_resource_t(device_t _dev, device_t _child, int _type, |
513 |
int _rid, struct resource *_res); |
514 |
/** |
515 |
* @brief Release a resource |
516 |
* |
517 |
* Free a resource allocated by the BUS_ALLOC_RESOURCE. The @p _rid |
518 |
* value must be the same as the one returned by BUS_ALLOC_RESOURCE() |
519 |
* (which is not necessarily the same as the one the client passed). |
520 |
* |
521 |
* @param _dev the parent device of @p _child |
522 |
* @param _child the device which allocated the resource |
523 |
* @param _type the type of resource |
524 |
* @param _rid the resource identifier |
525 |
* @param _r the resource to release |
526 |
*/ |
527 |
|
528 |
static __inline int BUS_RELEASE_RESOURCE(device_t _dev, device_t _child, |
529 |
int _type, int _rid, |
530 |
struct resource *_res) |
531 |
{ |
532 |
kobjop_t _m; |
533 |
int rc; |
534 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_release_resource); |
535 |
rc = ((bus_release_resource_t *) _m)(_dev, _child, _type, _rid, _res); |
536 |
return (rc); |
537 |
} |
538 |
|
539 |
/** @brief Unique descriptor for the BUS_SETUP_INTR() method */ |
540 |
extern struct kobjop_desc bus_setup_intr_desc; |
541 |
/** @brief A function implementing the BUS_SETUP_INTR() method */ |
542 |
typedef int bus_setup_intr_t(device_t _dev, device_t _child, |
543 |
struct resource *_irq, int _flags, |
544 |
driver_filter_t *_filter, driver_intr_t *_intr, |
545 |
void *_arg, void **_cookiep); |
546 |
/** |
547 |
* @brief Install an interrupt handler |
548 |
* |
549 |
* This method is used to associate an interrupt handler function with |
550 |
* an irq resource. When the interrupt triggers, the function @p _intr |
551 |
* will be called with the value of @p _arg as its single |
552 |
* argument. The value returned in @p *_cookiep is used to cancel the |
553 |
* interrupt handler - the caller should save this value to use in a |
554 |
* future call to BUS_TEARDOWN_INTR(). |
555 |
* |
556 |
* @param _dev the parent device of @p _child |
557 |
* @param _child the device which allocated the resource |
558 |
* @param _irq the resource representing the interrupt |
559 |
* @param _flags a set of bits from enum intr_type specifying |
560 |
* the class of interrupt |
561 |
* @param _intr the function to call when the interrupt |
562 |
* triggers |
563 |
* @param _arg a value to use as the single argument in calls |
564 |
* to @p _intr |
565 |
* @param _cookiep a pointer to a location to receive a cookie |
566 |
* value that may be used to remove the interrupt |
567 |
* handler |
568 |
*/ |
569 |
|
570 |
static __inline int BUS_SETUP_INTR(device_t _dev, device_t _child, |
571 |
struct resource *_irq, int _flags, |
572 |
driver_filter_t *_filter, |
573 |
driver_intr_t *_intr, void *_arg, |
574 |
void **_cookiep) |
575 |
{ |
576 |
kobjop_t _m; |
577 |
int rc; |
578 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_setup_intr); |
579 |
rc = ((bus_setup_intr_t *) _m)(_dev, _child, _irq, _flags, _filter, _intr, _arg, _cookiep); |
580 |
return (rc); |
581 |
} |
582 |
|
583 |
/** @brief Unique descriptor for the BUS_TEARDOWN_INTR() method */ |
584 |
extern struct kobjop_desc bus_teardown_intr_desc; |
585 |
/** @brief A function implementing the BUS_TEARDOWN_INTR() method */ |
586 |
typedef int bus_teardown_intr_t(device_t _dev, device_t _child, |
587 |
struct resource *_irq, void *_cookie); |
588 |
/** |
589 |
* @brief Uninstall an interrupt handler |
590 |
* |
591 |
* This method is used to disassociate an interrupt handler function |
592 |
* with an irq resource. The value of @p _cookie must be the value |
593 |
* returned from a previous call to BUS_SETUP_INTR(). |
594 |
* |
595 |
* @param _dev the parent device of @p _child |
596 |
* @param _child the device which allocated the resource |
597 |
* @param _irq the resource representing the interrupt |
598 |
* @param _cookie the cookie value returned when the interrupt |
599 |
* was originally registered |
600 |
*/ |
601 |
|
602 |
static __inline int BUS_TEARDOWN_INTR(device_t _dev, device_t _child, |
603 |
struct resource *_irq, void *_cookie) |
604 |
{ |
605 |
kobjop_t _m; |
606 |
int rc; |
607 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_teardown_intr); |
608 |
rc = ((bus_teardown_intr_t *) _m)(_dev, _child, _irq, _cookie); |
609 |
return (rc); |
610 |
} |
611 |
|
612 |
/** @brief Unique descriptor for the BUS_SUSPEND_INTR() method */ |
613 |
extern struct kobjop_desc bus_suspend_intr_desc; |
614 |
/** @brief A function implementing the BUS_SUSPEND_INTR() method */ |
615 |
typedef int bus_suspend_intr_t(device_t _dev, device_t _child, |
616 |
struct resource *_irq); |
617 |
/** |
618 |
* @brief Suspend an interrupt handler |
619 |
* |
620 |
* This method is used to mark a handler as suspended in the case |
621 |
* that the associated device is powered down and cannot be a source |
622 |
* for the, typically shared, interrupt. |
623 |
* The value of @p _irq must be the interrupt resource passed |
624 |
* to a previous call to BUS_SETUP_INTR(). |
625 |
* |
626 |
* @param _dev the parent device of @p _child |
627 |
* @param _child the device which allocated the resource |
628 |
* @param _irq the resource representing the interrupt |
629 |
*/ |
630 |
|
631 |
static __inline int BUS_SUSPEND_INTR(device_t _dev, device_t _child, |
632 |
struct resource *_irq) |
633 |
{ |
634 |
kobjop_t _m; |
635 |
int rc; |
636 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_suspend_intr); |
637 |
rc = ((bus_suspend_intr_t *) _m)(_dev, _child, _irq); |
638 |
return (rc); |
639 |
} |
640 |
|
641 |
/** @brief Unique descriptor for the BUS_RESUME_INTR() method */ |
642 |
extern struct kobjop_desc bus_resume_intr_desc; |
643 |
/** @brief A function implementing the BUS_RESUME_INTR() method */ |
644 |
typedef int bus_resume_intr_t(device_t _dev, device_t _child, |
645 |
struct resource *_irq); |
646 |
/** |
647 |
* @brief Resume an interrupt handler |
648 |
* |
649 |
* This method is used to clear suspended state of a handler when |
650 |
* the associated device is powered up and can be an interrupt source |
651 |
* again. |
652 |
* The value of @p _irq must be the interrupt resource passed |
653 |
* to a previous call to BUS_SETUP_INTR(). |
654 |
* |
655 |
* @param _dev the parent device of @p _child |
656 |
* @param _child the device which allocated the resource |
657 |
* @param _irq the resource representing the interrupt |
658 |
*/ |
659 |
|
660 |
static __inline int BUS_RESUME_INTR(device_t _dev, device_t _child, |
661 |
struct resource *_irq) |
662 |
{ |
663 |
kobjop_t _m; |
664 |
int rc; |
665 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_resume_intr); |
666 |
rc = ((bus_resume_intr_t *) _m)(_dev, _child, _irq); |
667 |
return (rc); |
668 |
} |
669 |
|
670 |
/** @brief Unique descriptor for the BUS_SET_RESOURCE() method */ |
671 |
extern struct kobjop_desc bus_set_resource_desc; |
672 |
/** @brief A function implementing the BUS_SET_RESOURCE() method */ |
673 |
typedef int bus_set_resource_t(device_t _dev, device_t _child, int _type, |
674 |
int _rid, rman_res_t _start, rman_res_t _count); |
675 |
/** |
676 |
* @brief Define a resource which can be allocated with |
677 |
* BUS_ALLOC_RESOURCE(). |
678 |
* |
679 |
* This method is used by some buses (typically ISA) to allow a |
680 |
* driver to describe a resource range that it would like to |
681 |
* allocate. The resource defined by @p _type and @p _rid is defined |
682 |
* to start at @p _start and to include @p _count indices in its |
683 |
* range. |
684 |
* |
685 |
* @param _dev the parent device of @p _child |
686 |
* @param _child the device which owns the resource |
687 |
* @param _type the type of resource |
688 |
* @param _rid the resource identifier |
689 |
* @param _start the start of the resource range |
690 |
* @param _count the size of the resource range |
691 |
*/ |
692 |
|
693 |
static __inline int BUS_SET_RESOURCE(device_t _dev, device_t _child, int _type, |
694 |
int _rid, rman_res_t _start, |
695 |
rman_res_t _count) |
696 |
{ |
697 |
kobjop_t _m; |
698 |
int rc; |
699 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_set_resource); |
700 |
rc = ((bus_set_resource_t *) _m)(_dev, _child, _type, _rid, _start, _count); |
701 |
return (rc); |
702 |
} |
703 |
|
704 |
/** @brief Unique descriptor for the BUS_GET_RESOURCE() method */ |
705 |
extern struct kobjop_desc bus_get_resource_desc; |
706 |
/** @brief A function implementing the BUS_GET_RESOURCE() method */ |
707 |
typedef int bus_get_resource_t(device_t _dev, device_t _child, int _type, |
708 |
int _rid, rman_res_t *_startp, |
709 |
rman_res_t *_countp); |
710 |
/** |
711 |
* @brief Describe a resource |
712 |
* |
713 |
* This method allows a driver to examine the range used for a given |
714 |
* resource without actually allocating it. |
715 |
* |
716 |
* @param _dev the parent device of @p _child |
717 |
* @param _child the device which owns the resource |
718 |
* @param _type the type of resource |
719 |
* @param _rid the resource identifier |
720 |
* @param _start the address of a location to receive the start |
721 |
* index of the resource range |
722 |
* @param _count the address of a location to receive the size |
723 |
* of the resource range |
724 |
*/ |
725 |
|
726 |
static __inline int BUS_GET_RESOURCE(device_t _dev, device_t _child, int _type, |
727 |
int _rid, rman_res_t *_startp, |
728 |
rman_res_t *_countp) |
729 |
{ |
730 |
kobjop_t _m; |
731 |
int rc; |
732 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_get_resource); |
733 |
rc = ((bus_get_resource_t *) _m)(_dev, _child, _type, _rid, _startp, _countp); |
734 |
return (rc); |
735 |
} |
736 |
|
737 |
/** @brief Unique descriptor for the BUS_DELETE_RESOURCE() method */ |
738 |
extern struct kobjop_desc bus_delete_resource_desc; |
739 |
/** @brief A function implementing the BUS_DELETE_RESOURCE() method */ |
740 |
typedef void bus_delete_resource_t(device_t _dev, device_t _child, int _type, |
741 |
int _rid); |
742 |
/** |
743 |
* @brief Delete a resource. |
744 |
* |
745 |
* Use this to delete a resource (possibly one previously added with |
746 |
* BUS_SET_RESOURCE()). |
747 |
* |
748 |
* @param _dev the parent device of @p _child |
749 |
* @param _child the device which owns the resource |
750 |
* @param _type the type of resource |
751 |
* @param _rid the resource identifier |
752 |
*/ |
753 |
|
754 |
static __inline void BUS_DELETE_RESOURCE(device_t _dev, device_t _child, |
755 |
int _type, int _rid) |
756 |
{ |
757 |
kobjop_t _m; |
758 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_delete_resource); |
759 |
((bus_delete_resource_t *) _m)(_dev, _child, _type, _rid); |
760 |
} |
761 |
|
762 |
/** @brief Unique descriptor for the BUS_GET_RESOURCE_LIST() method */ |
763 |
extern struct kobjop_desc bus_get_resource_list_desc; |
764 |
/** @brief A function implementing the BUS_GET_RESOURCE_LIST() method */ |
765 |
typedef struct resource_list * bus_get_resource_list_t(device_t _dev, |
766 |
device_t _child); |
767 |
/** |
768 |
* @brief Return a struct resource_list. |
769 |
* |
770 |
* Used by drivers which use bus_generic_rl_alloc_resource() etc. to |
771 |
* implement their resource handling. It should return the resource |
772 |
* list of the given child device. |
773 |
* |
774 |
* @param _dev the parent device of @p _child |
775 |
* @param _child the device which owns the resource list |
776 |
*/ |
777 |
|
778 |
static __inline struct resource_list * BUS_GET_RESOURCE_LIST(device_t _dev, |
779 |
device_t _child) |
780 |
{ |
781 |
kobjop_t _m; |
782 |
struct resource_list * rc; |
783 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_get_resource_list); |
784 |
rc = ((bus_get_resource_list_t *) _m)(_dev, _child); |
785 |
return (rc); |
786 |
} |
787 |
|
788 |
/** @brief Unique descriptor for the BUS_CHILD_PRESENT() method */ |
789 |
extern struct kobjop_desc bus_child_present_desc; |
790 |
/** @brief A function implementing the BUS_CHILD_PRESENT() method */ |
791 |
typedef int bus_child_present_t(device_t _dev, device_t _child); |
792 |
/** |
793 |
* @brief Is the hardware described by @p _child still attached to the |
794 |
* system? |
795 |
* |
796 |
* This method should return 0 if the device is not present. It |
797 |
* should return -1 if it is present. Any errors in determining |
798 |
* should be returned as a normal errno value. Client drivers are to |
799 |
* assume that the device is present, even if there is an error |
800 |
* determining if it is there. Buses are to try to avoid returning |
801 |
* errors, but newcard will return an error if the device fails to |
802 |
* implement this method. |
803 |
* |
804 |
* @param _dev the parent device of @p _child |
805 |
* @param _child the device which is being examined |
806 |
*/ |
807 |
|
808 |
static __inline int BUS_CHILD_PRESENT(device_t _dev, device_t _child) |
809 |
{ |
810 |
kobjop_t _m; |
811 |
int rc; |
812 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_child_present); |
813 |
rc = ((bus_child_present_t *) _m)(_dev, _child); |
814 |
return (rc); |
815 |
} |
816 |
|
817 |
/** @brief Unique descriptor for the BUS_CHILD_PNPINFO_STR() method */ |
818 |
extern struct kobjop_desc bus_child_pnpinfo_str_desc; |
819 |
/** @brief A function implementing the BUS_CHILD_PNPINFO_STR() method */ |
820 |
typedef int bus_child_pnpinfo_str_t(device_t _dev, device_t _child, char *_buf, |
821 |
size_t _buflen); |
822 |
/** |
823 |
* @brief Returns the pnp info for this device. |
824 |
* |
825 |
* Return it as a string. If the storage is insufficient for the |
826 |
* string, then return EOVERFLOW. |
827 |
* |
828 |
* The string must be formatted as a space-separated list of |
829 |
* name=value pairs. Names may only contain alphanumeric characters, |
830 |
* underscores ('_') and hyphens ('-'). Values can contain any |
831 |
* non-whitespace characters. Values containing whitespace can be |
832 |
* quoted with double quotes ('"'). Double quotes and backslashes in |
833 |
* quoted values can be escaped with backslashes ('\'). |
834 |
* |
835 |
* @param _dev the parent device of @p _child |
836 |
* @param _child the device which is being examined |
837 |
* @param _buf the address of a buffer to receive the pnp |
838 |
* string |
839 |
* @param _buflen the size of the buffer pointed to by @p _buf |
840 |
*/ |
841 |
|
842 |
static __inline int BUS_CHILD_PNPINFO_STR(device_t _dev, device_t _child, |
843 |
char *_buf, size_t _buflen) |
844 |
{ |
845 |
kobjop_t _m; |
846 |
int rc; |
847 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_child_pnpinfo_str); |
848 |
rc = ((bus_child_pnpinfo_str_t *) _m)(_dev, _child, _buf, _buflen); |
849 |
return (rc); |
850 |
} |
851 |
|
852 |
/** @brief Unique descriptor for the BUS_CHILD_LOCATION_STR() method */ |
853 |
extern struct kobjop_desc bus_child_location_str_desc; |
854 |
/** @brief A function implementing the BUS_CHILD_LOCATION_STR() method */ |
855 |
typedef int bus_child_location_str_t(device_t _dev, device_t _child, char *_buf, |
856 |
size_t _buflen); |
857 |
/** |
858 |
* @brief Returns the location for this device. |
859 |
* |
860 |
* Return it as a string. If the storage is insufficient for the |
861 |
* string, then return EOVERFLOW. |
862 |
* |
863 |
* The string must be formatted as a space-separated list of |
864 |
* name=value pairs. Names may only contain alphanumeric characters, |
865 |
* underscores ('_') and hyphens ('-'). Values can contain any |
866 |
* non-whitespace characters. Values containing whitespace can be |
867 |
* quoted with double quotes ('"'). Double quotes and backslashes in |
868 |
* quoted values can be escaped with backslashes ('\'). |
869 |
* |
870 |
* @param _dev the parent device of @p _child |
871 |
* @param _child the device which is being examined |
872 |
* @param _buf the address of a buffer to receive the location |
873 |
* string |
874 |
* @param _buflen the size of the buffer pointed to by @p _buf |
875 |
*/ |
876 |
|
877 |
static __inline int BUS_CHILD_LOCATION_STR(device_t _dev, device_t _child, |
878 |
char *_buf, size_t _buflen) |
879 |
{ |
880 |
kobjop_t _m; |
881 |
int rc; |
882 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_child_location_str); |
883 |
rc = ((bus_child_location_str_t *) _m)(_dev, _child, _buf, _buflen); |
884 |
return (rc); |
885 |
} |
886 |
|
887 |
/** @brief Unique descriptor for the BUS_BIND_INTR() method */ |
888 |
extern struct kobjop_desc bus_bind_intr_desc; |
889 |
/** @brief A function implementing the BUS_BIND_INTR() method */ |
890 |
typedef int bus_bind_intr_t(device_t _dev, device_t _child, |
891 |
struct resource *_irq, int _cpu); |
892 |
/** |
893 |
* @brief Allow drivers to request that an interrupt be bound to a specific |
894 |
* CPU. |
895 |
* |
896 |
* @param _dev the parent device of @p _child |
897 |
* @param _child the device which allocated the resource |
898 |
* @param _irq the resource representing the interrupt |
899 |
* @param _cpu the CPU to bind the interrupt to |
900 |
*/ |
901 |
|
902 |
static __inline int BUS_BIND_INTR(device_t _dev, device_t _child, |
903 |
struct resource *_irq, int _cpu) |
904 |
{ |
905 |
kobjop_t _m; |
906 |
int rc; |
907 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_bind_intr); |
908 |
rc = ((bus_bind_intr_t *) _m)(_dev, _child, _irq, _cpu); |
909 |
return (rc); |
910 |
} |
911 |
|
912 |
/** @brief Unique descriptor for the BUS_CONFIG_INTR() method */ |
913 |
extern struct kobjop_desc bus_config_intr_desc; |
914 |
/** @brief A function implementing the BUS_CONFIG_INTR() method */ |
915 |
typedef int bus_config_intr_t(device_t _dev, int _irq, enum intr_trigger _trig, |
916 |
enum intr_polarity _pol); |
917 |
/** |
918 |
* @brief Allow (bus) drivers to specify the trigger mode and polarity |
919 |
* of the specified interrupt. |
920 |
* |
921 |
* @param _dev the bus device |
922 |
* @param _irq the interrupt number to modify |
923 |
* @param _trig the trigger mode required |
924 |
* @param _pol the interrupt polarity required |
925 |
*/ |
926 |
|
927 |
static __inline int BUS_CONFIG_INTR(device_t _dev, int _irq, |
928 |
enum intr_trigger _trig, |
929 |
enum intr_polarity _pol) |
930 |
{ |
931 |
kobjop_t _m; |
932 |
int rc; |
933 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_config_intr); |
934 |
rc = ((bus_config_intr_t *) _m)(_dev, _irq, _trig, _pol); |
935 |
return (rc); |
936 |
} |
937 |
|
938 |
/** @brief Unique descriptor for the BUS_DESCRIBE_INTR() method */ |
939 |
extern struct kobjop_desc bus_describe_intr_desc; |
940 |
/** @brief A function implementing the BUS_DESCRIBE_INTR() method */ |
941 |
typedef int bus_describe_intr_t(device_t _dev, device_t _child, |
942 |
struct resource *_irq, void *_cookie, |
943 |
const char *_descr); |
944 |
/** |
945 |
* @brief Allow drivers to associate a description with an active |
946 |
* interrupt handler. |
947 |
* |
948 |
* @param _dev the parent device of @p _child |
949 |
* @param _child the device which allocated the resource |
950 |
* @param _irq the resource representing the interrupt |
951 |
* @param _cookie the cookie value returned when the interrupt |
952 |
* was originally registered |
953 |
* @param _descr the description to associate with the interrupt |
954 |
*/ |
955 |
|
956 |
static __inline int BUS_DESCRIBE_INTR(device_t _dev, device_t _child, |
957 |
struct resource *_irq, void *_cookie, |
958 |
const char *_descr) |
959 |
{ |
960 |
kobjop_t _m; |
961 |
int rc; |
962 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_describe_intr); |
963 |
rc = ((bus_describe_intr_t *) _m)(_dev, _child, _irq, _cookie, _descr); |
964 |
return (rc); |
965 |
} |
966 |
|
967 |
/** @brief Unique descriptor for the BUS_HINTED_CHILD() method */ |
968 |
extern struct kobjop_desc bus_hinted_child_desc; |
969 |
/** @brief A function implementing the BUS_HINTED_CHILD() method */ |
970 |
typedef void bus_hinted_child_t(device_t _dev, const char *_dname, int _dunit); |
971 |
/** |
972 |
* @brief Notify a (bus) driver about a child that the hints mechanism |
973 |
* believes it has discovered. |
974 |
* |
975 |
* The bus is responsible for then adding the child in the right order |
976 |
* and discovering other things about the child. The bus driver is |
977 |
* free to ignore this hint, to do special things, etc. It is all up |
978 |
* to the bus driver to interpret. |
979 |
* |
980 |
* This method is only called in response to the parent bus asking for |
981 |
* hinted devices to be enumerated. |
982 |
* |
983 |
* @param _dev the bus device |
984 |
* @param _dname the name of the device w/o unit numbers |
985 |
* @param _dunit the unit number of the device |
986 |
*/ |
987 |
|
988 |
static __inline void BUS_HINTED_CHILD(device_t _dev, const char *_dname, |
989 |
int _dunit) |
990 |
{ |
991 |
kobjop_t _m; |
992 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_hinted_child); |
993 |
((bus_hinted_child_t *) _m)(_dev, _dname, _dunit); |
994 |
} |
995 |
|
996 |
/** @brief Unique descriptor for the BUS_GET_DMA_TAG() method */ |
997 |
extern struct kobjop_desc bus_get_dma_tag_desc; |
998 |
/** @brief A function implementing the BUS_GET_DMA_TAG() method */ |
999 |
typedef bus_dma_tag_t bus_get_dma_tag_t(device_t _dev, device_t _child); |
1000 |
/** |
1001 |
* @brief Returns bus_dma_tag_t for use w/ devices on the bus. |
1002 |
* |
1003 |
* @param _dev the parent device of @p _child |
1004 |
* @param _child the device to which the tag will belong |
1005 |
*/ |
1006 |
|
1007 |
static __inline bus_dma_tag_t BUS_GET_DMA_TAG(device_t _dev, device_t _child) |
1008 |
{ |
1009 |
kobjop_t _m; |
1010 |
bus_dma_tag_t rc; |
1011 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_get_dma_tag); |
1012 |
rc = ((bus_get_dma_tag_t *) _m)(_dev, _child); |
1013 |
return (rc); |
1014 |
} |
1015 |
|
1016 |
/** @brief Unique descriptor for the BUS_GET_BUS_TAG() method */ |
1017 |
extern struct kobjop_desc bus_get_bus_tag_desc; |
1018 |
/** @brief A function implementing the BUS_GET_BUS_TAG() method */ |
1019 |
typedef bus_space_tag_t bus_get_bus_tag_t(device_t _dev, device_t _child); |
1020 |
/** |
1021 |
* @brief Returns bus_space_tag_t for use w/ devices on the bus. |
1022 |
* |
1023 |
* @param _dev the parent device of @p _child |
1024 |
* @param _child the device to which the tag will belong |
1025 |
*/ |
1026 |
|
1027 |
static __inline bus_space_tag_t BUS_GET_BUS_TAG(device_t _dev, device_t _child) |
1028 |
{ |
1029 |
kobjop_t _m; |
1030 |
bus_space_tag_t rc; |
1031 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_get_bus_tag); |
1032 |
rc = ((bus_get_bus_tag_t *) _m)(_dev, _child); |
1033 |
return (rc); |
1034 |
} |
1035 |
|
1036 |
/** @brief Unique descriptor for the BUS_HINT_DEVICE_UNIT() method */ |
1037 |
extern struct kobjop_desc bus_hint_device_unit_desc; |
1038 |
/** @brief A function implementing the BUS_HINT_DEVICE_UNIT() method */ |
1039 |
typedef void bus_hint_device_unit_t(device_t _dev, device_t _child, |
1040 |
const char *_name, int *_unitp); |
1041 |
/** |
1042 |
* @brief Allow the bus to determine the unit number of a device. |
1043 |
* |
1044 |
* @param _dev the parent device of @p _child |
1045 |
* @param _child the device whose unit is to be wired |
1046 |
* @param _name the name of the device's new devclass |
1047 |
* @param _unitp a pointer to the device's new unit value |
1048 |
*/ |
1049 |
|
1050 |
static __inline void BUS_HINT_DEVICE_UNIT(device_t _dev, device_t _child, |
1051 |
const char *_name, int *_unitp) |
1052 |
{ |
1053 |
kobjop_t _m; |
1054 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_hint_device_unit); |
1055 |
((bus_hint_device_unit_t *) _m)(_dev, _child, _name, _unitp); |
1056 |
} |
1057 |
|
1058 |
/** @brief Unique descriptor for the BUS_NEW_PASS() method */ |
1059 |
extern struct kobjop_desc bus_new_pass_desc; |
1060 |
/** @brief A function implementing the BUS_NEW_PASS() method */ |
1061 |
typedef void bus_new_pass_t(device_t _dev); |
1062 |
/** |
1063 |
* @brief Notify a bus that the bus pass level has been changed |
1064 |
* |
1065 |
* @param _dev the bus device |
1066 |
*/ |
1067 |
|
1068 |
static __inline void BUS_NEW_PASS(device_t _dev) |
1069 |
{ |
1070 |
kobjop_t _m; |
1071 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_new_pass); |
1072 |
((bus_new_pass_t *) _m)(_dev); |
1073 |
} |
1074 |
|
1075 |
/** @brief Unique descriptor for the BUS_REMAP_INTR() method */ |
1076 |
extern struct kobjop_desc bus_remap_intr_desc; |
1077 |
/** @brief A function implementing the BUS_REMAP_INTR() method */ |
1078 |
typedef int bus_remap_intr_t(device_t _dev, device_t _child, u_int _irq); |
1079 |
/** |
1080 |
* @brief Notify a bus that specified child's IRQ should be remapped. |
1081 |
* |
1082 |
* @param _dev the bus device |
1083 |
* @param _child the child device |
1084 |
* @param _irq the irq number |
1085 |
*/ |
1086 |
|
1087 |
static __inline int BUS_REMAP_INTR(device_t _dev, device_t _child, u_int _irq) |
1088 |
{ |
1089 |
kobjop_t _m; |
1090 |
int rc; |
1091 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_remap_intr); |
1092 |
rc = ((bus_remap_intr_t *) _m)(_dev, _child, _irq); |
1093 |
return (rc); |
1094 |
} |
1095 |
|
1096 |
/** @brief Unique descriptor for the BUS_SUSPEND_CHILD() method */ |
1097 |
extern struct kobjop_desc bus_suspend_child_desc; |
1098 |
/** @brief A function implementing the BUS_SUSPEND_CHILD() method */ |
1099 |
typedef int bus_suspend_child_t(device_t _dev, device_t _child); |
1100 |
/** |
1101 |
* @brief Suspend a given child |
1102 |
* |
1103 |
* @param _dev the parent device of @p _child |
1104 |
* @param _child the device to suspend |
1105 |
*/ |
1106 |
|
1107 |
static __inline int BUS_SUSPEND_CHILD(device_t _dev, device_t _child) |
1108 |
{ |
1109 |
kobjop_t _m; |
1110 |
int rc; |
1111 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_suspend_child); |
1112 |
rc = ((bus_suspend_child_t *) _m)(_dev, _child); |
1113 |
return (rc); |
1114 |
} |
1115 |
|
1116 |
/** @brief Unique descriptor for the BUS_RESUME_CHILD() method */ |
1117 |
extern struct kobjop_desc bus_resume_child_desc; |
1118 |
/** @brief A function implementing the BUS_RESUME_CHILD() method */ |
1119 |
typedef int bus_resume_child_t(device_t _dev, device_t _child); |
1120 |
/** |
1121 |
* @brief Resume a given child |
1122 |
* |
1123 |
* @param _dev the parent device of @p _child |
1124 |
* @param _child the device to resume |
1125 |
*/ |
1126 |
|
1127 |
static __inline int BUS_RESUME_CHILD(device_t _dev, device_t _child) |
1128 |
{ |
1129 |
kobjop_t _m; |
1130 |
int rc; |
1131 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_resume_child); |
1132 |
rc = ((bus_resume_child_t *) _m)(_dev, _child); |
1133 |
return (rc); |
1134 |
} |
1135 |
|
1136 |
/** @brief Unique descriptor for the BUS_GET_DOMAIN() method */ |
1137 |
extern struct kobjop_desc bus_get_domain_desc; |
1138 |
/** @brief A function implementing the BUS_GET_DOMAIN() method */ |
1139 |
typedef int bus_get_domain_t(device_t _dev, device_t _child, int *_domain); |
1140 |
/** |
1141 |
* @brief Get the VM domain handle for the given bus and child. |
1142 |
* |
1143 |
* @param _dev the bus device |
1144 |
* @param _child the child device |
1145 |
* @param _domain a pointer to the bus's domain handle identifier |
1146 |
*/ |
1147 |
|
1148 |
static __inline int BUS_GET_DOMAIN(device_t _dev, device_t _child, int *_domain) |
1149 |
{ |
1150 |
kobjop_t _m; |
1151 |
int rc; |
1152 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_get_domain); |
1153 |
rc = ((bus_get_domain_t *) _m)(_dev, _child, _domain); |
1154 |
return (rc); |
1155 |
} |
1156 |
|
1157 |
/** @brief Unique descriptor for the BUS_GET_CPUS() method */ |
1158 |
extern struct kobjop_desc bus_get_cpus_desc; |
1159 |
/** @brief A function implementing the BUS_GET_CPUS() method */ |
1160 |
typedef int bus_get_cpus_t(device_t _dev, device_t _child, enum cpu_sets _op, |
1161 |
size_t _setsize, struct _cpuset *_cpuset); |
1162 |
/** |
1163 |
* @brief Request a set of CPUs |
1164 |
* |
1165 |
* @param _dev the bus device |
1166 |
* @param _child the child device |
1167 |
* @param _op type of CPUs to request |
1168 |
* @param _setsize the size of the set passed in _cpuset |
1169 |
* @param _cpuset a pointer to a cpuset to receive the requested |
1170 |
* set of CPUs |
1171 |
*/ |
1172 |
|
1173 |
static __inline int BUS_GET_CPUS(device_t _dev, device_t _child, |
1174 |
enum cpu_sets _op, size_t _setsize, |
1175 |
struct _cpuset *_cpuset) |
1176 |
{ |
1177 |
kobjop_t _m; |
1178 |
int rc; |
1179 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_get_cpus); |
1180 |
rc = ((bus_get_cpus_t *) _m)(_dev, _child, _op, _setsize, _cpuset); |
1181 |
return (rc); |
1182 |
} |
1183 |
|
1184 |
/** @brief Unique descriptor for the BUS_RESET_PREPARE() method */ |
1185 |
extern struct kobjop_desc bus_reset_prepare_desc; |
1186 |
/** @brief A function implementing the BUS_RESET_PREPARE() method */ |
1187 |
typedef int bus_reset_prepare_t(device_t _dev, device_t _child); |
1188 |
/** |
1189 |
* @brief Prepares the given child of the bus for reset |
1190 |
* |
1191 |
* Typically bus detaches or suspends children' drivers, and then |
1192 |
* calls this method to save bus-specific information, for instance, |
1193 |
* PCI config space, which is damaged by reset. |
1194 |
* |
1195 |
* The bus_helper_reset_prepare() helper is provided to ease |
1196 |
* implementing bus reset methods. |
1197 |
* |
1198 |
* @param _dev the bus device |
1199 |
* @param _child the child device |
1200 |
*/ |
1201 |
|
1202 |
static __inline int BUS_RESET_PREPARE(device_t _dev, device_t _child) |
1203 |
{ |
1204 |
kobjop_t _m; |
1205 |
int rc; |
1206 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_reset_prepare); |
1207 |
rc = ((bus_reset_prepare_t *) _m)(_dev, _child); |
1208 |
return (rc); |
1209 |
} |
1210 |
|
1211 |
/** @brief Unique descriptor for the BUS_RESET_POST() method */ |
1212 |
extern struct kobjop_desc bus_reset_post_desc; |
1213 |
/** @brief A function implementing the BUS_RESET_POST() method */ |
1214 |
typedef int bus_reset_post_t(device_t _dev, device_t _child); |
1215 |
/** |
1216 |
* @brief Restores the child operations after the reset |
1217 |
* |
1218 |
* The bus_helper_reset_post() helper is provided to ease |
1219 |
* implementing bus reset methods. |
1220 |
* |
1221 |
* @param _dev the bus device |
1222 |
* @param _child the child device |
1223 |
*/ |
1224 |
|
1225 |
static __inline int BUS_RESET_POST(device_t _dev, device_t _child) |
1226 |
{ |
1227 |
kobjop_t _m; |
1228 |
int rc; |
1229 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_reset_post); |
1230 |
rc = ((bus_reset_post_t *) _m)(_dev, _child); |
1231 |
return (rc); |
1232 |
} |
1233 |
|
1234 |
/** @brief Unique descriptor for the BUS_RESET_CHILD() method */ |
1235 |
extern struct kobjop_desc bus_reset_child_desc; |
1236 |
/** @brief A function implementing the BUS_RESET_CHILD() method */ |
1237 |
typedef int bus_reset_child_t(device_t _dev, device_t _child, int _flags); |
1238 |
/** |
1239 |
* @brief Performs reset of the child |
1240 |
* |
1241 |
* @param _dev the bus device |
1242 |
* @param _child the child device |
1243 |
* @param _flags DEVF_RESET_ flags |
1244 |
*/ |
1245 |
|
1246 |
static __inline int BUS_RESET_CHILD(device_t _dev, device_t _child, int _flags) |
1247 |
{ |
1248 |
kobjop_t _m; |
1249 |
int rc; |
1250 |
KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_reset_child); |
1251 |
rc = ((bus_reset_child_t *) _m)(_dev, _child, _flags); |
1252 |
return (rc); |
1253 |
} |
1254 |
|
1255 |
#endif /* _bus_if_h_ */ |