1f9f848faSopenharmony_ci/* 2f9f848faSopenharmony_ci * This file is produced automatically. 3f9f848faSopenharmony_ci * Do not modify anything in here by hand. 4f9f848faSopenharmony_ci * 5f9f848faSopenharmony_ci * Created from source file 6f9f848faSopenharmony_ci * bus_if.m 7f9f848faSopenharmony_ci * with 8f9f848faSopenharmony_ci * makeobjops.awk 9f9f848faSopenharmony_ci * 10f9f848faSopenharmony_ci * See the source file for legal information 11f9f848faSopenharmony_ci */ 12f9f848faSopenharmony_ci 13f9f848faSopenharmony_ci/** 14f9f848faSopenharmony_ci * @defgroup BUS bus - KObj methods for drivers of devices with children 15f9f848faSopenharmony_ci * @brief A set of methods required device drivers that support 16f9f848faSopenharmony_ci * child devices. 17f9f848faSopenharmony_ci * @{ 18f9f848faSopenharmony_ci */ 19f9f848faSopenharmony_ci 20f9f848faSopenharmony_ci#ifndef _bus_if_h_ 21f9f848faSopenharmony_ci#define _bus_if_h_ 22f9f848faSopenharmony_ci 23f9f848faSopenharmony_ci/** @brief Unique descriptor for the BUS_ALLOC_RESOURCE() method */ 24f9f848faSopenharmony_ciextern struct kobjop_desc bus_alloc_resource_desc; 25f9f848faSopenharmony_ci/** @brief A function implementing the BUS_ALLOC_RESOURCE() method */ 26f9f848faSopenharmony_citypedef struct resource * bus_alloc_resource_t(device_t _dev, device_t _child, 27f9f848faSopenharmony_ci int _type, int *_rid, 28f9f848faSopenharmony_ci rman_res_t _start, 29f9f848faSopenharmony_ci rman_res_t _end, 30f9f848faSopenharmony_ci rman_res_t _count, u_int _flags); 31f9f848faSopenharmony_ci/** 32f9f848faSopenharmony_ci * @brief Allocate a system resource 33f9f848faSopenharmony_ci * 34f9f848faSopenharmony_ci * This method is called by child devices of a bus to allocate resources. 35f9f848faSopenharmony_ci * The types are defined in <machine/resource.h>; the meaning of the 36f9f848faSopenharmony_ci * resource-ID field varies from bus to bus (but @p *rid == 0 is always 37f9f848faSopenharmony_ci * valid if the resource type is). If a resource was allocated and the 38f9f848faSopenharmony_ci * caller did not use the RF_ACTIVE to specify that it should be 39f9f848faSopenharmony_ci * activated immediately, the caller is responsible for calling 40f9f848faSopenharmony_ci * BUS_ACTIVATE_RESOURCE() when it actually uses the resource. 41f9f848faSopenharmony_ci * 42f9f848faSopenharmony_ci * @param _dev the parent device of @p _child 43f9f848faSopenharmony_ci * @param _child the device which is requesting an allocation 44f9f848faSopenharmony_ci * @param _type the type of resource to allocate 45f9f848faSopenharmony_ci * @param _rid a pointer to the resource identifier 46f9f848faSopenharmony_ci * @param _start hint at the start of the resource range - pass 47f9f848faSopenharmony_ci * @c 0 for any start address 48f9f848faSopenharmony_ci * @param _end hint at the end of the resource range - pass 49f9f848faSopenharmony_ci * @c ~0 for any end address 50f9f848faSopenharmony_ci * @param _count hint at the size of range required - pass @c 1 51f9f848faSopenharmony_ci * for any size 52f9f848faSopenharmony_ci * @param _flags any extra flags to control the resource 53f9f848faSopenharmony_ci * allocation - see @c RF_XXX flags in 54f9f848faSopenharmony_ci * <sys/rman.h> for details 55f9f848faSopenharmony_ci * 56f9f848faSopenharmony_ci * @returns the resource which was allocated or @c NULL if no 57f9f848faSopenharmony_ci * resource could be allocated 58f9f848faSopenharmony_ci */ 59f9f848faSopenharmony_ci 60f9f848faSopenharmony_cistatic __inline struct resource * BUS_ALLOC_RESOURCE(device_t _dev, 61f9f848faSopenharmony_ci device_t _child, int _type, 62f9f848faSopenharmony_ci int *_rid, 63f9f848faSopenharmony_ci rman_res_t _start, 64f9f848faSopenharmony_ci rman_res_t _end, 65f9f848faSopenharmony_ci rman_res_t _count, 66f9f848faSopenharmony_ci u_int _flags) 67f9f848faSopenharmony_ci{ 68f9f848faSopenharmony_ci kobjop_t _m; 69f9f848faSopenharmony_ci KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_alloc_resource); 70f9f848faSopenharmony_ci return ((bus_alloc_resource_t *) _m)(_dev, _child, _type, _rid, _start, _end, _count, _flags); 71f9f848faSopenharmony_ci} 72f9f848faSopenharmony_ci/** @brief Unique descriptor for the BUS_CHILD_PNPINFO_STR() method */ 73f9f848faSopenharmony_ciextern struct kobjop_desc bus_child_pnpinfo_str_desc; 74f9f848faSopenharmony_ci/** @brief A function implementing the BUS_CHILD_PNPINFO_STR() method */ 75f9f848faSopenharmony_citypedef int bus_child_pnpinfo_str_t(device_t _dev, device_t _child, char *_buf, 76f9f848faSopenharmony_ci size_t _buflen); 77f9f848faSopenharmony_ci 78f9f848faSopenharmony_ci/** 79f9f848faSopenharmony_ci * @brief Returns the pnp info for this device. 80f9f848faSopenharmony_ci * 81f9f848faSopenharmony_ci * Return it as a string. If the storage is insufficient for the 82f9f848faSopenharmony_ci * string, then return EOVERFLOW. 83f9f848faSopenharmony_ci * 84f9f848faSopenharmony_ci * The string must be formatted as a space-separated list of 85f9f848faSopenharmony_ci * name=value pairs. Names may only contain alphanumeric characters, 86f9f848faSopenharmony_ci * underscores ('_') and hyphens ('-'). Values can contain any 87f9f848faSopenharmony_ci * non-whitespace characters. Values containing whitespace can be 88f9f848faSopenharmony_ci * quoted with double quotes ('"'). Double quotes and backslashes in 89f9f848faSopenharmony_ci * quoted values can be escaped with backslashes ('\'). 90f9f848faSopenharmony_ci * 91f9f848faSopenharmony_ci * @param _dev the parent device of @p _child 92f9f848faSopenharmony_ci * @param _child the device which is being examined 93f9f848faSopenharmony_ci * @param _buf the address of a buffer to receive the pnp 94f9f848faSopenharmony_ci * string 95f9f848faSopenharmony_ci * @param _buflen the size of the buffer pointed to by @p _buf 96f9f848faSopenharmony_ci */ 97f9f848faSopenharmony_ci 98f9f848faSopenharmony_cistatic __inline int BUS_CHILD_PNPINFO_STR(device_t _dev, device_t _child, 99f9f848faSopenharmony_ci char *_buf, size_t _buflen) 100f9f848faSopenharmony_ci{ 101f9f848faSopenharmony_ci kobjop_t _m; 102f9f848faSopenharmony_ci KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_child_pnpinfo_str); 103f9f848faSopenharmony_ci return ((bus_child_pnpinfo_str_t *) _m)(_dev, _child, _buf, _buflen); 104f9f848faSopenharmony_ci} 105f9f848faSopenharmony_ci 106f9f848faSopenharmony_ci/** @brief Unique descriptor for the BUS_CHILD_LOCATION_STR() method */ 107f9f848faSopenharmony_ciextern struct kobjop_desc bus_child_location_str_desc; 108f9f848faSopenharmony_ci/** @brief A function implementing the BUS_CHILD_LOCATION_STR() method */ 109f9f848faSopenharmony_citypedef int bus_child_location_str_t(device_t _dev, device_t _child, char *_buf, 110f9f848faSopenharmony_ci size_t _buflen); 111f9f848faSopenharmony_ci/** 112f9f848faSopenharmony_ci * @brief Returns the location for this device. 113f9f848faSopenharmony_ci * 114f9f848faSopenharmony_ci * Return it as a string. If the storage is insufficient for the 115f9f848faSopenharmony_ci * string, then return EOVERFLOW. 116f9f848faSopenharmony_ci * 117f9f848faSopenharmony_ci * The string must be formatted as a space-separated list of 118f9f848faSopenharmony_ci * name=value pairs. Names may only contain alphanumeric characters, 119f9f848faSopenharmony_ci * underscores ('_') and hyphens ('-'). Values can contain any 120f9f848faSopenharmony_ci * non-whitespace characters. Values containing whitespace can be 121f9f848faSopenharmony_ci * quoted with double quotes ('"'). Double quotes and backslashes in 122f9f848faSopenharmony_ci * quoted values can be escaped with backslashes ('\'). 123f9f848faSopenharmony_ci * 124f9f848faSopenharmony_ci * @param _dev the parent device of @p _child 125f9f848faSopenharmony_ci * @param _child the device which is being examined 126f9f848faSopenharmony_ci * @param _buf the address of a buffer to receive the location 127f9f848faSopenharmony_ci * string 128f9f848faSopenharmony_ci * @param _buflen the size of the buffer pointed to by @p _buf 129f9f848faSopenharmony_ci */ 130f9f848faSopenharmony_ci 131f9f848faSopenharmony_cistatic __inline int BUS_CHILD_LOCATION_STR(device_t _dev, device_t _child, 132f9f848faSopenharmony_ci char *_buf, size_t _buflen) 133f9f848faSopenharmony_ci{ 134f9f848faSopenharmony_ci kobjop_t _m; 135f9f848faSopenharmony_ci KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_child_location_str); 136f9f848faSopenharmony_ci return ((bus_child_location_str_t *) _m)(_dev, _child, _buf, _buflen); 137f9f848faSopenharmony_ci} 138f9f848faSopenharmony_ci 139f9f848faSopenharmony_ci/** @brief Unique descriptor for the BUS_PRINT_CHILD() method */ 140f9f848faSopenharmony_ciextern struct kobjop_desc bus_print_child_desc; 141f9f848faSopenharmony_ci/** @brief A function implementing the BUS_PRINT_CHILD() method */ 142f9f848faSopenharmony_citypedef int bus_print_child_t(device_t _dev, device_t _child); 143f9f848faSopenharmony_ci 144f9f848faSopenharmony_ci/** 145f9f848faSopenharmony_ci * @brief Print a description of a child device 146f9f848faSopenharmony_ci * 147f9f848faSopenharmony_ci * This is called from system code which prints out a description of a 148f9f848faSopenharmony_ci * device. It should describe the attachment that the child has with 149f9f848faSopenharmony_ci * the parent. For instance the TurboLaser bus prints which node the 150f9f848faSopenharmony_ci * device is attached to. See bus_generic_print_child() for more 151f9f848faSopenharmony_ci * information. 152f9f848faSopenharmony_ci * 153f9f848faSopenharmony_ci * @param _dev the device whose child is being printed 154f9f848faSopenharmony_ci * @param _child the child device to describe 155f9f848faSopenharmony_ci * 156f9f848faSopenharmony_ci * @returns the number of characters output. 157f9f848faSopenharmony_ci */ 158f9f848faSopenharmony_ci 159f9f848faSopenharmony_cistatic __inline int BUS_PRINT_CHILD(device_t _dev, device_t _child) 160f9f848faSopenharmony_ci{ 161f9f848faSopenharmony_ci kobjop_t _m; 162f9f848faSopenharmony_ci KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_print_child); 163f9f848faSopenharmony_ci return ((bus_print_child_t *) _m)(_dev, _child); 164f9f848faSopenharmony_ci} 165f9f848faSopenharmony_ci 166f9f848faSopenharmony_ci/** @brief Unique descriptor for the BUS_PROBE_NOMATCH() method */ 167f9f848faSopenharmony_ciextern struct kobjop_desc bus_probe_nomatch_desc; 168f9f848faSopenharmony_ci/** @brief A function implementing the BUS_PROBE_NOMATCH() method */ 169f9f848faSopenharmony_citypedef void bus_probe_nomatch_t(device_t _dev, device_t _child); 170f9f848faSopenharmony_ci/** 171f9f848faSopenharmony_ci * @brief Print a notification about an unprobed child device. 172f9f848faSopenharmony_ci * 173f9f848faSopenharmony_ci * Called for each child device that did not succeed in probing for a 174f9f848faSopenharmony_ci * driver. 175f9f848faSopenharmony_ci * 176f9f848faSopenharmony_ci * @param _dev the device whose child was being probed 177f9f848faSopenharmony_ci * @param _child the child device which failed to probe 178f9f848faSopenharmony_ci */ 179f9f848faSopenharmony_ci 180f9f848faSopenharmony_cistatic __inline void BUS_PROBE_NOMATCH(device_t _dev, device_t _child) 181f9f848faSopenharmony_ci{ 182f9f848faSopenharmony_ci kobjop_t _m; 183f9f848faSopenharmony_ci KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_probe_nomatch); 184f9f848faSopenharmony_ci ((bus_probe_nomatch_t *) _m)(_dev, _child); 185f9f848faSopenharmony_ci} 186f9f848faSopenharmony_ci 187f9f848faSopenharmony_ci/** @brief Unique descriptor for the BUS_READ_IVAR() method */ 188f9f848faSopenharmony_ciextern struct kobjop_desc bus_read_ivar_desc; 189f9f848faSopenharmony_ci/** @brief A function implementing the BUS_READ_IVAR() method */ 190f9f848faSopenharmony_citypedef int bus_read_ivar_t(device_t _dev, device_t _child, int _index, 191f9f848faSopenharmony_ci uintptr_t *_result); 192f9f848faSopenharmony_ci/** 193f9f848faSopenharmony_ci * @brief Read the value of a bus-specific attribute of a device 194f9f848faSopenharmony_ci * 195f9f848faSopenharmony_ci * This method, along with BUS_WRITE_IVAR() manages a bus-specific set 196f9f848faSopenharmony_ci * of instance variables of a child device. The intention is that 197f9f848faSopenharmony_ci * each different type of bus defines a set of appropriate instance 198f9f848faSopenharmony_ci * variables (such as ports and irqs for ISA bus etc.) 199f9f848faSopenharmony_ci * 200f9f848faSopenharmony_ci * This information could be given to the child device as a struct but 201f9f848faSopenharmony_ci * that makes it hard for a bus to add or remove variables without 202f9f848faSopenharmony_ci * forcing an edit and recompile for all drivers which may not be 203f9f848faSopenharmony_ci * possible for vendor supplied binary drivers. 204f9f848faSopenharmony_ci * 205f9f848faSopenharmony_ci * This method copies the value of an instance variable to the 206f9f848faSopenharmony_ci * location specified by @p *_result. 207f9f848faSopenharmony_ci * 208f9f848faSopenharmony_ci * @param _dev the device whose child was being examined 209f9f848faSopenharmony_ci * @param _child the child device whose instance variable is 210f9f848faSopenharmony_ci * being read 211f9f848faSopenharmony_ci * @param _index the instance variable to read 212f9f848faSopenharmony_ci * @param _result a location to receive the instance variable 213f9f848faSopenharmony_ci * value 214f9f848faSopenharmony_ci * 215f9f848faSopenharmony_ci * @retval 0 success 216f9f848faSopenharmony_ci * @retval ENOENT no such instance variable is supported by @p 217f9f848faSopenharmony_ci * _dev 218f9f848faSopenharmony_ci */ 219f9f848faSopenharmony_ci 220f9f848faSopenharmony_cistatic __inline int BUS_READ_IVAR(device_t _dev, device_t _child, int _index, 221f9f848faSopenharmony_ci uintptr_t *_result) 222f9f848faSopenharmony_ci{ 223f9f848faSopenharmony_ci kobjop_t _m; 224f9f848faSopenharmony_ci KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_read_ivar); 225f9f848faSopenharmony_ci return ((bus_read_ivar_t *) _m)(_dev, _child, _index, _result); 226f9f848faSopenharmony_ci} 227f9f848faSopenharmony_ci 228f9f848faSopenharmony_ci/** @brief Unique descriptor for the BUS_WRITE_IVAR() method */ 229f9f848faSopenharmony_ciextern struct kobjop_desc bus_write_ivar_desc; 230f9f848faSopenharmony_ci/** @brief A function implementing the BUS_WRITE_IVAR() method */ 231f9f848faSopenharmony_citypedef int bus_write_ivar_t(device_t _dev, device_t _child, int _indx, 232f9f848faSopenharmony_ci uintptr_t _value); 233f9f848faSopenharmony_ci/** 234f9f848faSopenharmony_ci * @brief Write the value of a bus-specific attribute of a device 235f9f848faSopenharmony_ci * 236f9f848faSopenharmony_ci * This method sets the value of an instance variable to @p _value. 237f9f848faSopenharmony_ci * 238f9f848faSopenharmony_ci * @param _dev the device whose child was being updated 239f9f848faSopenharmony_ci * @param _child the child device whose instance variable is 240f9f848faSopenharmony_ci * being written 241f9f848faSopenharmony_ci * @param _index the instance variable to write 242f9f848faSopenharmony_ci * @param _value the value to write to that instance variable 243f9f848faSopenharmony_ci * 244f9f848faSopenharmony_ci * @retval 0 success 245f9f848faSopenharmony_ci * @retval ENOENT no such instance variable is supported by @p 246f9f848faSopenharmony_ci * _dev 247f9f848faSopenharmony_ci * @retval EINVAL the instance variable was recognised but 248f9f848faSopenharmony_ci * contains a read-only value 249f9f848faSopenharmony_ci */ 250f9f848faSopenharmony_ci 251f9f848faSopenharmony_cistatic __inline int BUS_WRITE_IVAR(device_t _dev, device_t _child, int _indx, 252f9f848faSopenharmony_ci uintptr_t _value) 253f9f848faSopenharmony_ci{ 254f9f848faSopenharmony_ci kobjop_t _m; 255f9f848faSopenharmony_ci KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_write_ivar); 256f9f848faSopenharmony_ci return ((bus_write_ivar_t *) _m)(_dev, _child, _indx, _value); 257f9f848faSopenharmony_ci} 258f9f848faSopenharmony_ci 259f9f848faSopenharmony_ci/** @brief Unique descriptor for the BUS_CHILD_DELETED() method */ 260f9f848faSopenharmony_ciextern struct kobjop_desc bus_child_deleted_desc; 261f9f848faSopenharmony_ci/** @brief A function implementing the BUS_CHILD_DELETED() method */ 262f9f848faSopenharmony_citypedef void bus_child_deleted_t(device_t _dev, device_t _child); 263f9f848faSopenharmony_ci/** 264f9f848faSopenharmony_ci * @brief Notify a bus that a child was deleted 265f9f848faSopenharmony_ci * 266f9f848faSopenharmony_ci * Called at the beginning of device_delete_child() to allow the parent 267f9f848faSopenharmony_ci * to teardown any bus-specific state for the child. 268f9f848faSopenharmony_ci * 269f9f848faSopenharmony_ci * @param _dev the device whose child is being deleted 270f9f848faSopenharmony_ci * @param _child the child device which is being deleted 271f9f848faSopenharmony_ci */ 272f9f848faSopenharmony_ci 273f9f848faSopenharmony_cistatic __inline void BUS_CHILD_DELETED(device_t _dev, device_t _child) 274f9f848faSopenharmony_ci{ 275f9f848faSopenharmony_ci kobjop_t _m; 276f9f848faSopenharmony_ci KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_child_deleted); 277f9f848faSopenharmony_ci ((bus_child_deleted_t *) _m)(_dev, _child); 278f9f848faSopenharmony_ci} 279f9f848faSopenharmony_ci 280f9f848faSopenharmony_ci/** @brief Unique descriptor for the BUS_CHILD_DETACHED() method */ 281f9f848faSopenharmony_ciextern struct kobjop_desc bus_child_detached_desc; 282f9f848faSopenharmony_ci/** @brief A function implementing the BUS_CHILD_DETACHED() method */ 283f9f848faSopenharmony_citypedef void bus_child_detached_t(device_t _dev, device_t _child); 284f9f848faSopenharmony_ci/** 285f9f848faSopenharmony_ci * @brief Notify a bus that a child was detached 286f9f848faSopenharmony_ci * 287f9f848faSopenharmony_ci * Called after the child's DEVICE_DETACH() method to allow the parent 288f9f848faSopenharmony_ci * to reclaim any resources allocated on behalf of the child. 289f9f848faSopenharmony_ci * 290f9f848faSopenharmony_ci * @param _dev the device whose child changed state 291f9f848faSopenharmony_ci * @param _child the child device which changed state 292f9f848faSopenharmony_ci */ 293f9f848faSopenharmony_ci 294f9f848faSopenharmony_cistatic __inline void BUS_CHILD_DETACHED(device_t _dev, device_t _child) 295f9f848faSopenharmony_ci{ 296f9f848faSopenharmony_ci kobjop_t _m; 297f9f848faSopenharmony_ci KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_child_detached); 298f9f848faSopenharmony_ci ((bus_child_detached_t *) _m)(_dev, _child); 299f9f848faSopenharmony_ci} 300f9f848faSopenharmony_ci 301f9f848faSopenharmony_ci/** @brief Unique descriptor for the BUS_DRIVER_ADDED() method */ 302f9f848faSopenharmony_ciextern struct kobjop_desc bus_driver_added_desc; 303f9f848faSopenharmony_ci/** @brief A function implementing the BUS_DRIVER_ADDED() method */ 304f9f848faSopenharmony_citypedef void bus_driver_added_t(device_t _dev, driver_t *_driver); 305f9f848faSopenharmony_ci/** 306f9f848faSopenharmony_ci * @brief Notify a bus that a new driver was added 307f9f848faSopenharmony_ci * 308f9f848faSopenharmony_ci * Called when a new driver is added to the devclass which owns this 309f9f848faSopenharmony_ci * bus. The generic implementation of this method attempts to probe and 310f9f848faSopenharmony_ci * attach any un-matched children of the bus. 311f9f848faSopenharmony_ci * 312f9f848faSopenharmony_ci * @param _dev the device whose devclass had a new driver 313f9f848faSopenharmony_ci * added to it 314f9f848faSopenharmony_ci * @param _driver the new driver which was added 315f9f848faSopenharmony_ci */ 316f9f848faSopenharmony_ci 317f9f848faSopenharmony_cistatic __inline void BUS_DRIVER_ADDED(device_t _dev, driver_t *_driver) 318f9f848faSopenharmony_ci{ 319f9f848faSopenharmony_ci kobjop_t _m; 320f9f848faSopenharmony_ci KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_driver_added); 321f9f848faSopenharmony_ci ((bus_driver_added_t *) _m)(_dev, _driver); 322f9f848faSopenharmony_ci} 323f9f848faSopenharmony_ci 324f9f848faSopenharmony_ci/** @brief Unique descriptor for the BUS_ADD_CHILD() method */ 325f9f848faSopenharmony_ciextern struct kobjop_desc bus_add_child_desc; 326f9f848faSopenharmony_ci/** @brief A function implementing the BUS_ADD_CHILD() method */ 327f9f848faSopenharmony_citypedef device_t bus_add_child_t(device_t _dev, u_int _order, const char *_name, 328f9f848faSopenharmony_ci int _unit); 329f9f848faSopenharmony_ci/** 330f9f848faSopenharmony_ci * @brief Create a new child device 331f9f848faSopenharmony_ci * 332f9f848faSopenharmony_ci * For busses which use use drivers supporting DEVICE_IDENTIFY() to 333f9f848faSopenharmony_ci * enumerate their devices, this method is used to create new 334f9f848faSopenharmony_ci * device instances. The new device will be added after the last 335f9f848faSopenharmony_ci * existing child with the same order. Implementations of bus_add_child 336f9f848faSopenharmony_ci * call device_add_child_ordered to add the child and often add 337f9f848faSopenharmony_ci * a suitable ivar to the device specific to that bus. 338f9f848faSopenharmony_ci * 339f9f848faSopenharmony_ci * @param _dev the bus device which will be the parent of the 340f9f848faSopenharmony_ci * new child device 341f9f848faSopenharmony_ci * @param _order a value which is used to partially sort the 342f9f848faSopenharmony_ci * children of @p _dev - devices created using 343f9f848faSopenharmony_ci * lower values of @p _order appear first in @p 344f9f848faSopenharmony_ci * _dev's list of children 345f9f848faSopenharmony_ci * @param _name devclass name for new device or @c NULL if not 346f9f848faSopenharmony_ci * specified 347f9f848faSopenharmony_ci * @param _unit unit number for new device or @c -1 if not 348f9f848faSopenharmony_ci * specified 349f9f848faSopenharmony_ci */ 350f9f848faSopenharmony_ci 351f9f848faSopenharmony_cistatic __inline device_t BUS_ADD_CHILD(device_t _dev, u_int _order, 352f9f848faSopenharmony_ci const char *_name, int _unit) 353f9f848faSopenharmony_ci{ 354f9f848faSopenharmony_ci kobjop_t _m; 355f9f848faSopenharmony_ci KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_add_child); 356f9f848faSopenharmony_ci return ((bus_add_child_t *) _m)(_dev, _order, _name, _unit); 357f9f848faSopenharmony_ci} 358f9f848faSopenharmony_ci 359f9f848faSopenharmony_ci/** @brief Unique descriptor for the BUS_RESCAN() method */ 360f9f848faSopenharmony_ciextern struct kobjop_desc bus_rescan_desc; 361f9f848faSopenharmony_ci/** @brief A function implementing the BUS_RESCAN() method */ 362f9f848faSopenharmony_citypedef int bus_rescan_t(device_t _dev); 363f9f848faSopenharmony_ci/** 364f9f848faSopenharmony_ci * @brief Rescan the bus 365f9f848faSopenharmony_ci * 366f9f848faSopenharmony_ci * This method is called by a parent bridge or devctl to trigger a bus 367f9f848faSopenharmony_ci * rescan. The rescan should delete devices no longer present and 368f9f848faSopenharmony_ci * enumerate devices that have newly arrived. 369f9f848faSopenharmony_ci * 370f9f848faSopenharmony_ci * @param _dev the bus device 371f9f848faSopenharmony_ci */ 372f9f848faSopenharmony_ci 373f9f848faSopenharmony_cistatic __inline int BUS_RESCAN(device_t _dev) 374f9f848faSopenharmony_ci{ 375f9f848faSopenharmony_ci kobjop_t _m; 376f9f848faSopenharmony_ci KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_rescan); 377f9f848faSopenharmony_ci return ((bus_rescan_t *) _m)(_dev); 378f9f848faSopenharmony_ci} 379f9f848faSopenharmony_ci 380f9f848faSopenharmony_ci/** @brief Unique descriptor for the BUS_CHILD_PRESENT() method */ 381f9f848faSopenharmony_ciextern struct kobjop_desc bus_child_present_desc; 382f9f848faSopenharmony_ci/** @brief A function implementing the BUS_CHILD_PRESENT() method */ 383f9f848faSopenharmony_citypedef int bus_child_present_t(device_t _dev, device_t _child); 384f9f848faSopenharmony_ci/** 385f9f848faSopenharmony_ci * @brief Is the hardware described by @p _child still attached to the 386f9f848faSopenharmony_ci * system? 387f9f848faSopenharmony_ci * 388f9f848faSopenharmony_ci * This method should return 0 if the device is not present. It 389f9f848faSopenharmony_ci * should return -1 if it is present. Any errors in determining 390f9f848faSopenharmony_ci * should be returned as a normal errno value. Client drivers are to 391f9f848faSopenharmony_ci * assume that the device is present, even if there is an error 392f9f848faSopenharmony_ci * determining if it is there. Busses are to try to avoid returning 393f9f848faSopenharmony_ci * errors, but newcard will return an error if the device fails to 394f9f848faSopenharmony_ci * implement this method. 395f9f848faSopenharmony_ci * 396f9f848faSopenharmony_ci * @param _dev the parent device of @p _child 397f9f848faSopenharmony_ci * @param _child the device which is being examined 398f9f848faSopenharmony_ci */ 399f9f848faSopenharmony_ci 400f9f848faSopenharmony_cistatic __inline int BUS_CHILD_PRESENT(device_t _dev, device_t _child) 401f9f848faSopenharmony_ci{ 402f9f848faSopenharmony_ci kobjop_t _m; 403f9f848faSopenharmony_ci KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_child_present); 404f9f848faSopenharmony_ci return ((bus_child_present_t *) _m)(_dev, _child); 405f9f848faSopenharmony_ci} 406f9f848faSopenharmony_ci 407f9f848faSopenharmony_ci// delete resource and interrupt 408f9f848faSopenharmony_ci 409f9f848faSopenharmony_ci/** @brief Unique descriptor for the BUS_HINTED_CHILD() method */ 410f9f848faSopenharmony_ciextern struct kobjop_desc bus_hinted_child_desc; 411f9f848faSopenharmony_ci/** @brief A function implementing the BUS_HINTED_CHILD() method */ 412f9f848faSopenharmony_citypedef void bus_hinted_child_t(device_t _dev, const char *_dname, int _dunit); 413f9f848faSopenharmony_ci/** 414f9f848faSopenharmony_ci * @brief Notify a (bus) driver about a child that the hints mechanism 415f9f848faSopenharmony_ci * believes it has discovered. 416f9f848faSopenharmony_ci * 417f9f848faSopenharmony_ci * The bus is responsible for then adding the child in the right order 418f9f848faSopenharmony_ci * and discovering other things about the child. The bus driver is 419f9f848faSopenharmony_ci * free to ignore this hint, to do special things, etc. It is all up 420f9f848faSopenharmony_ci * to the bus driver to interpret. 421f9f848faSopenharmony_ci * 422f9f848faSopenharmony_ci * This method is only called in response to the parent bus asking for 423f9f848faSopenharmony_ci * hinted devices to be enumerated. 424f9f848faSopenharmony_ci * 425f9f848faSopenharmony_ci * @param _dev the bus device 426f9f848faSopenharmony_ci * @param _dname the name of the device w/o unit numbers 427f9f848faSopenharmony_ci * @param _dunit the unit number of the device 428f9f848faSopenharmony_ci */ 429f9f848faSopenharmony_ci 430f9f848faSopenharmony_cistatic __inline void BUS_HINTED_CHILD(device_t _dev, const char *_dname, 431f9f848faSopenharmony_ci int _dunit) 432f9f848faSopenharmony_ci{ 433f9f848faSopenharmony_ci kobjop_t _m; 434f9f848faSopenharmony_ci KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_hinted_child); 435f9f848faSopenharmony_ci ((bus_hinted_child_t *) _m)(_dev, _dname, _dunit); 436f9f848faSopenharmony_ci} 437f9f848faSopenharmony_ci 438f9f848faSopenharmony_ci// delete dma 439f9f848faSopenharmony_ci 440f9f848faSopenharmony_ci/** @brief Unique descriptor for the BUS_HINT_DEVICE_UNIT() method */ 441f9f848faSopenharmony_ciextern struct kobjop_desc bus_hint_device_unit_desc; 442f9f848faSopenharmony_ci/** @brief A function implementing the BUS_HINT_DEVICE_UNIT() method */ 443f9f848faSopenharmony_citypedef void bus_hint_device_unit_t(device_t _dev, device_t _child, 444f9f848faSopenharmony_ci const char *_name, int *_unitp); 445f9f848faSopenharmony_ci/** 446f9f848faSopenharmony_ci * @brief Allow the bus to determine the unit number of a device. 447f9f848faSopenharmony_ci * 448f9f848faSopenharmony_ci * @param _dev the parent device of @p _child 449f9f848faSopenharmony_ci * @param _child the device whose unit is to be wired 450f9f848faSopenharmony_ci * @param _name the name of the device's new devclass 451f9f848faSopenharmony_ci * @param _unitp a pointer to the device's new unit value 452f9f848faSopenharmony_ci */ 453f9f848faSopenharmony_ci 454f9f848faSopenharmony_cistatic __inline void BUS_HINT_DEVICE_UNIT(device_t _dev, device_t _child, 455f9f848faSopenharmony_ci const char *_name, int *_unitp) 456f9f848faSopenharmony_ci{ 457f9f848faSopenharmony_ci kobjop_t _m; 458f9f848faSopenharmony_ci KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_hint_device_unit); 459f9f848faSopenharmony_ci ((bus_hint_device_unit_t *) _m)(_dev, _child, _name, _unitp); 460f9f848faSopenharmony_ci} 461f9f848faSopenharmony_ci 462f9f848faSopenharmony_ci/** @brief Unique descriptor for the BUS_NEW_PASS() method */ 463f9f848faSopenharmony_ciextern struct kobjop_desc bus_new_pass_desc; 464f9f848faSopenharmony_ci/** @brief A function implementing the BUS_NEW_PASS() method */ 465f9f848faSopenharmony_citypedef void bus_new_pass_t(device_t _dev); 466f9f848faSopenharmony_ci/** 467f9f848faSopenharmony_ci * @brief Notify a bus that the bus pass level has been changed 468f9f848faSopenharmony_ci * 469f9f848faSopenharmony_ci * @param _dev the bus device 470f9f848faSopenharmony_ci */ 471f9f848faSopenharmony_ci 472f9f848faSopenharmony_cistatic __inline void BUS_NEW_PASS(device_t _dev) 473f9f848faSopenharmony_ci{ 474f9f848faSopenharmony_ci kobjop_t _m; 475f9f848faSopenharmony_ci KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_new_pass); 476f9f848faSopenharmony_ci ((bus_new_pass_t *) _m)(_dev); 477f9f848faSopenharmony_ci} 478f9f848faSopenharmony_ci 479f9f848faSopenharmony_ci/** @brief Unique descriptor for the BUS_SUSPEND_CHILD() method */ 480f9f848faSopenharmony_ciextern struct kobjop_desc bus_suspend_child_desc; 481f9f848faSopenharmony_ci/** @brief A function implementing the BUS_SUSPEND_CHILD() method */ 482f9f848faSopenharmony_citypedef int bus_suspend_child_t(device_t _dev, device_t _child); 483f9f848faSopenharmony_ci/** 484f9f848faSopenharmony_ci * @brief Suspend a given child 485f9f848faSopenharmony_ci * 486f9f848faSopenharmony_ci * @param _dev the parent device of @p _child 487f9f848faSopenharmony_ci * @param _child the device to suspend 488f9f848faSopenharmony_ci */ 489f9f848faSopenharmony_ci 490f9f848faSopenharmony_cistatic __inline int BUS_SUSPEND_CHILD(device_t _dev, device_t _child) 491f9f848faSopenharmony_ci{ 492f9f848faSopenharmony_ci kobjop_t _m; 493f9f848faSopenharmony_ci KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_suspend_child); 494f9f848faSopenharmony_ci return ((bus_suspend_child_t *) _m)(_dev, _child); 495f9f848faSopenharmony_ci} 496f9f848faSopenharmony_ci 497f9f848faSopenharmony_ci/** @brief Unique descriptor for the BUS_RESUME_CHILD() method */ 498f9f848faSopenharmony_ciextern struct kobjop_desc bus_resume_child_desc; 499f9f848faSopenharmony_ci/** @brief A function implementing the BUS_RESUME_CHILD() method */ 500f9f848faSopenharmony_citypedef int bus_resume_child_t(device_t _dev, device_t _child); 501f9f848faSopenharmony_ci/** 502f9f848faSopenharmony_ci * @brief Resume a given child 503f9f848faSopenharmony_ci * 504f9f848faSopenharmony_ci * @param _dev the parent device of @p _child 505f9f848faSopenharmony_ci * @param _child the device to resume 506f9f848faSopenharmony_ci */ 507f9f848faSopenharmony_ci 508f9f848faSopenharmony_cistatic __inline int BUS_RESUME_CHILD(device_t _dev, device_t _child) 509f9f848faSopenharmony_ci{ 510f9f848faSopenharmony_ci kobjop_t _m; 511f9f848faSopenharmony_ci KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_resume_child); 512f9f848faSopenharmony_ci return ((bus_resume_child_t *) _m)(_dev, _child); 513f9f848faSopenharmony_ci} 514f9f848faSopenharmony_ci 515f9f848faSopenharmony_ci/** @brief Unique descriptor for the BUS_GET_DOMAIN() method */ 516f9f848faSopenharmony_ciextern struct kobjop_desc bus_get_domain_desc; 517f9f848faSopenharmony_ci/** @brief A function implementing the BUS_GET_DOMAIN() method */ 518f9f848faSopenharmony_citypedef int bus_get_domain_t(device_t _dev, device_t _child, int *_domain); 519f9f848faSopenharmony_ci/** 520f9f848faSopenharmony_ci * @brief Get the VM domain handle for the given bus and child. 521f9f848faSopenharmony_ci * 522f9f848faSopenharmony_ci * @param _dev the bus device 523f9f848faSopenharmony_ci * @param _child the child device 524f9f848faSopenharmony_ci * @param _domain a pointer to the bus's domain handle identifier 525f9f848faSopenharmony_ci */ 526f9f848faSopenharmony_ci 527f9f848faSopenharmony_cistatic __inline int BUS_GET_DOMAIN(device_t _dev, device_t _child, int *_domain) 528f9f848faSopenharmony_ci{ 529f9f848faSopenharmony_ci kobjop_t _m; 530f9f848faSopenharmony_ci KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_get_domain); 531f9f848faSopenharmony_ci return ((bus_get_domain_t *) _m)(_dev, _child, _domain); 532f9f848faSopenharmony_ci} 533f9f848faSopenharmony_ci 534f9f848faSopenharmony_ci 535f9f848faSopenharmony_ci/** @brief Unique descriptor for the BUS_RESET_PREPARE() method */ 536f9f848faSopenharmony_ciextern struct kobjop_desc bus_reset_prepare_desc; 537f9f848faSopenharmony_ci/** @brief A function implementing the BUS_RESET_PREPARE() method */ 538f9f848faSopenharmony_citypedef int bus_reset_prepare_t(device_t _dev, device_t _child); 539f9f848faSopenharmony_ci/** 540f9f848faSopenharmony_ci * @brief Prepares the given child of the bus for reset 541f9f848faSopenharmony_ci * 542f9f848faSopenharmony_ci * Typically bus detaches or suspends children' drivers, and then 543f9f848faSopenharmony_ci * calls this method to save bus-specific information, for instance, 544f9f848faSopenharmony_ci * PCI config space, which is damaged by reset. 545f9f848faSopenharmony_ci * 546f9f848faSopenharmony_ci * The bus_helper_reset_prepare() helper is provided to ease 547f9f848faSopenharmony_ci * implementing bus reset methods. 548f9f848faSopenharmony_ci * 549f9f848faSopenharmony_ci * @param _dev the bus device 550f9f848faSopenharmony_ci * @param _child the child device 551f9f848faSopenharmony_ci */ 552f9f848faSopenharmony_ci 553f9f848faSopenharmony_cistatic __inline int BUS_RESET_PREPARE(device_t _dev, device_t _child) 554f9f848faSopenharmony_ci{ 555f9f848faSopenharmony_ci kobjop_t _m; 556f9f848faSopenharmony_ci KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_reset_prepare); 557f9f848faSopenharmony_ci return ((bus_reset_prepare_t *) _m)(_dev, _child); 558f9f848faSopenharmony_ci} 559f9f848faSopenharmony_ci 560f9f848faSopenharmony_ci/** @brief Unique descriptor for the BUS_RESET_POST() method */ 561f9f848faSopenharmony_ciextern struct kobjop_desc bus_reset_post_desc; 562f9f848faSopenharmony_ci/** @brief A function implementing the BUS_RESET_POST() method */ 563f9f848faSopenharmony_citypedef int bus_reset_post_t(device_t _dev, device_t _child); 564f9f848faSopenharmony_ci/** 565f9f848faSopenharmony_ci * @brief Restores the child operations after the reset 566f9f848faSopenharmony_ci * 567f9f848faSopenharmony_ci * The bus_helper_reset_post() helper is provided to ease 568f9f848faSopenharmony_ci * implementing bus reset methods. 569f9f848faSopenharmony_ci * 570f9f848faSopenharmony_ci * @param _dev the bus device 571f9f848faSopenharmony_ci * @param _child the child device 572f9f848faSopenharmony_ci */ 573f9f848faSopenharmony_ci 574f9f848faSopenharmony_cistatic __inline int BUS_RESET_POST(device_t _dev, device_t _child) 575f9f848faSopenharmony_ci{ 576f9f848faSopenharmony_ci kobjop_t _m; 577f9f848faSopenharmony_ci KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_reset_post); 578f9f848faSopenharmony_ci return ((bus_reset_post_t *) _m)(_dev, _child); 579f9f848faSopenharmony_ci} 580f9f848faSopenharmony_ci 581f9f848faSopenharmony_ci/** @brief Unique descriptor for the BUS_RESET_CHILD() method */ 582f9f848faSopenharmony_ciextern struct kobjop_desc bus_reset_child_desc; 583f9f848faSopenharmony_ci/** @brief A function implementing the BUS_RESET_CHILD() method */ 584f9f848faSopenharmony_citypedef int bus_reset_child_t(device_t _dev, device_t _child, int _flags); 585f9f848faSopenharmony_ci/** 586f9f848faSopenharmony_ci * @brief Performs reset of the child 587f9f848faSopenharmony_ci * 588f9f848faSopenharmony_ci * @param _dev the bus device 589f9f848faSopenharmony_ci * @param _child the child device 590f9f848faSopenharmony_ci * @param _flags DEVF_RESET_ flags 591f9f848faSopenharmony_ci */ 592f9f848faSopenharmony_ci 593f9f848faSopenharmony_cistatic __inline int BUS_RESET_CHILD(device_t _dev, device_t _child, int _flags) 594f9f848faSopenharmony_ci{ 595f9f848faSopenharmony_ci kobjop_t _m; 596f9f848faSopenharmony_ci KOBJOPLOOKUP(((kobj_t)_dev)->ops,bus_reset_child); 597f9f848faSopenharmony_ci return ((bus_reset_child_t *) _m)(_dev, _child, _flags); 598f9f848faSopenharmony_ci} 599f9f848faSopenharmony_ci 600f9f848faSopenharmony_ci#endif /* _bus_if_h_ */ 601