Index: head/share/man/man9/BUS_ADD_CHILD.9 =================================================================== --- head/share/man/man9/BUS_ADD_CHILD.9 (revision 355329) +++ head/share/man/man9/BUS_ADD_CHILD.9 (revision 355330) @@ -1,89 +1,85 @@ .\" -*- nroff -*- .\" -.\" Copyright (c) 2004 M. Warner Losh. -.\" -.\" All rights reserved. -.\" -.\" This program is free software. +.\" Copyright (c) 2004 M. Warner Losh .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .\" $FreeBSD$ .\" .Dd April 8, 2018 .Dt BUS_ADD_CHILD 9 .Os .Sh NAME .Nm BUS_ADD_CHILD .Nd "add a device node to the tree with a given priority" .Sh SYNOPSIS .In sys/param.h .In sys/bus.h .Ft device_t .Fn BUS_ADD_CHILD "device_t dev" "int order" "const char *name" "int unit" .Sh DESCRIPTION The .Fn BUS_ADD_CHILD method is used by the driver identify routine to add devices to the tree. It can also be used to add children to buses that implement this routine in other contexts, although the behavior is bus specific. Please see .Xr device_add_child 9 for more details. The interface is the same as .Xr device_add_child 9 however, the bus' .Fn BUS_ADD_CHILD is called. .Pp Buses implementing .Fn BUS_ADD_CHILD should insert the device into the tree using .Xr device_add_child 9 before adding things such as their own ivars and resource lists to the device. .Fn BUS_ADD_CHILD is not called by .Xr device_add_child 9 . .Fn BUS_ADD_CHILD instead calls .Xr device_add_child 9 . .Pp A panic will result when called for a bus that does not implement .Fn BUS_ADD_CHILD . Some buses require a special bus-specific routine to be called instead of .Fn BUS_ADD_CHILD . .Sh RETURN VALUES The .Fn BUS_ADD_CHILD method returns .Vt device_t added to the tree, or .Dv NULL to indicate failure. .Sh SEE ALSO .Xr device 9 , .Xr device_add_child 9 , .Xr driver 9 .Sh AUTHORS This manual page was written by .An M. Warner Losh . Index: head/share/man/man9/bus_activate_resource.9 =================================================================== --- head/share/man/man9/bus_activate_resource.9 (revision 355329) +++ head/share/man/man9/bus_activate_resource.9 (revision 355330) @@ -1,150 +1,146 @@ .\" -*- nroff -*- .\" -.\" Copyright (c) 2003 M. Warner Losh -.\" -.\" All rights reserved. -.\" -.\" This program is free software. +.\" Copyright (c) 2004 M. Warner Losh .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .\" $FreeBSD$ .\" .Dd May 20, 2016 .Dt BUS_ACTIVATE_RESOURCE 9 .Os .Sh NAME .Nm bus_activate_resource , bus_deactivate_resource .Nd activate or deactivate a resource .Sh SYNOPSIS .In sys/param.h .In sys/bus.h .Pp .In machine/bus.h .In sys/rman.h .In machine/resource.h .Ft int .Fo bus_activate_resource .Fa "device_t dev" "int type" "int rid" "struct resource *r" .Fc .Ft int .Fo bus_deactivate_resource .Fa "device_t dev" "int type" "int rid" "struct resource *r" .Fc .Sh DESCRIPTION These functions activate or deactivate a previously allocated resource. In general, resources must be activated before they can be accessed by the driver. Bus drivers may perform additional actions to ensure that the resource is ready to be accessed. For example, the PCI bus driver enables memory decoding in a PCI device's command register when activating a memory resource. .Pp The arguments are as follows: .Bl -tag -width indent .It Fa dev The device that requests ownership of the resource. Before allocation, the resource is owned by the parent bus. .It Fa type The type of resource you want to allocate. It is one of: .Pp .Bl -tag -width ".Dv SYS_RES_MEMORY" -compact .It Dv PCI_RES_BUS for PCI bus numbers .It Dv SYS_RES_IRQ for IRQs .It Dv SYS_RES_DRQ for ISA DMA lines .It Dv SYS_RES_IOPORT for I/O ports .It Dv SYS_RES_MEMORY for I/O memory .El .It Fa rid A pointer to a bus specific handle that identifies the resource being allocated. .It Fa r A pointer to the .Vt "struct resource" returned by .Xr bus_alloc_resource 9 . .El .Ss Resource Mapping Resources which can be mapped for CPU access by a .Xr bus_space 9 tag and handle will create a mapping of the entire resource when activated. The tag and handle for this mapping are stored in .Fa r and can be retrieved via .Xr rman_get_bustag 9 and .Xr rman_get_bushandle 9 . These can be used with the .Xr bus_space 9 API to access device registers or memory described by .Fa r . If the mapping is associated with a virtual address, the virtual address can be retrieved via .Xr rman_get_virtual 9 . .Pp This implicit mapping can be disabled by passing the .Dv RF_UNMAPPED flag to .Xr bus_alloc_resource 9 . A driver may use this if it wishes to allocate its own mappings of a resource using .Xr bus_map_resource 9 . .Pp A wrapper API for .Xr bus_space 9 is also provided that accepts the associated resource as the first argument in place of the .Xr bus_space 9 tag and handle. The functions in this wrapper API are named similarly to the .Xr bus_space 9 API except that .Dq _space is removed from their name. For example, .Fn bus_read_4 can be used in place of .Fn bus_space_read_4 . The wrapper API is preferred in new drivers. .Pp These two statements both read a 32-bit register at the start of a resource: .Bd -literal bus_space_read_4(rman_get_bustag(res), rman_get_bushandle(res), 0); bus_read_4(res, 0); .Ed .Sh RETURN VALUES Zero is returned on success, otherwise an error is returned. .Sh SEE ALSO .Xr bus_alloc_resource 9 , .Xr bus_map_resource 9 , .Xr bus_space 9 , .Xr device 9 , .Xr driver 9 .Sh AUTHORS This manual page was written by .An Warner Losh Aq Mt imp@FreeBSD.org . Index: head/share/man/man9/bus_child_present.9 =================================================================== --- head/share/man/man9/bus_child_present.9 (revision 355329) +++ head/share/man/man9/bus_child_present.9 (revision 355330) @@ -1,87 +1,83 @@ .\" -*- nroff -*- .\" -.\" Copyright (c) 2003 M. Warner Losh -.\" -.\" All rights reserved. -.\" -.\" This program is free software. +.\" Copyright (c) 2003 M. Warner Losh .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .\" $FreeBSD$ .\" .Dd March 27, 2003 .Dt BUS_CHILD_PRESENT 9 .Os .Sh NAME .Nm bus_child_present .Nd "ask the bus driver to see if this device is still really present" .Sh SYNOPSIS .In sys/param.h .In sys/bus.h .Pp .In machine/bus.h .In sys/rman.h .In machine/resource.h .Ft int .Fn bus_child_present "device_t dev" .Sh DESCRIPTION The .Fn bus_child_present function requests that the parent device driver of .Fa dev check to see if the hardware represented by .Fa dev is still physically accessible at this time. While the notion of accessible varies from bus to bus, generally hardware that is not accessible cannot be accessed via the .Fn bus_space* methods that would otherwise be used to access the device. .Pp This does not ask the question .Dq does this device have children? which can better be answered by .Xr device_get_children 9 . .Sh RETURN VALUES A zero return value indicates that the device is not present in the system. A non-zero return value indicates that the device is present in the system, or that the state of the device cannot be determined. .Sh EXAMPLES This is some example code. It only calls stop when the .Xr dc 4 device is actually present. .Bd -literal -offset indent device_t dev; dc_softc *sc; sc = device_get_softc(dev); if (bus_child_present(dev)) dc_stop(sc); .Ed .Sh SEE ALSO .Xr device 9 , .Xr driver 9 .Sh AUTHORS This manual page was written by .An Warner Losh Aq Mt imp@FreeBSD.org . Index: head/share/man/man9/bus_set_resource.9 =================================================================== --- head/share/man/man9/bus_set_resource.9 (revision 355329) +++ head/share/man/man9/bus_set_resource.9 (revision 355330) @@ -1,96 +1,92 @@ .\" -*- nroff -*- .\" -.\" Copyright (c) 2003 M. Warner Losh -.\" -.\" All rights reserved. -.\" -.\" This program is free software. +.\" Copyright (c) 2003 M. Warner Losh .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .\" $FreeBSD$ .\" .Dd March 29, 2003 .Dt BUS_SET_RESOURCE 9 .Os .Sh NAME .Nm bus_set_resource .Nd "associate a definite resource with a given resource ID" .Sh SYNOPSIS .In sys/param.h .In sys/bus.h .Pp .In machine/bus.h .In sys/rman.h .In machine/resource.h .Ft int .Fo bus_set_resource .Fa "device_t dev" "int type" "int rid" "rman_res_t start" "rman_res_t count" .Fc .Sh DESCRIPTION The .Fn bus_set_resource function sets the start address of the resource .Fa type , rid pair to be .Fa count long. Typically, client drivers do not use this interface. Bus drivers, however, often use it to set up the resources a client driver uses. .Pp The arguments are as follows: .Bl -tag -width indent .It Fa dev The device to set the resource on. .It Fa type The type of resource you want to allocate. It is one of: .Pp .Bl -tag -width ".Dv SYS_RES_MEMORY" -compact .It Dv SYS_RES_IRQ for IRQs .It Dv SYS_RES_DRQ for ISA DMA lines .It Dv SYS_RES_IOPORT for I/O ports .It Dv SYS_RES_MEMORY for I/O memory .El .It Fa rid A bus-specific handle that identifies the resource being allocated. .It Fa start The start address of this resource. .It Fa count The length of the resource. For example, the size of the memory in bytes. .El .Sh RETURN VALUES Zero is returned on success, otherwise an error is returned. .Sh SEE ALSO .Xr bus_alloc_resource 9 , .Xr bus_get_resource 9 , .Xr device 9 , .Xr driver 9 .Sh AUTHORS This manual page was written by .An Warner Losh Aq Mt imp@FreeBSD.org . Index: head/share/man/man9/bus_space.9 =================================================================== --- head/share/man/man9/bus_space.9 (revision 355329) +++ head/share/man/man9/bus_space.9 (revision 355330) @@ -1,1716 +1,1716 @@ .\" $NetBSD: bus_space.9,v 1.9 1999/03/06 22:09:29 mycroft Exp $ .\" -.\" Copyright (c) 2005 M. Warner Losh. +.\" Copyright (c) 2005 M. Warner Losh .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" .\" .\" Copyright (c) 1997 The NetBSD Foundation, Inc. .\" All rights reserved. .\" .\" This code is derived from software contributed to The NetBSD Foundation .\" by Christopher G. Demetriou. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" .\" $FreeBSD$ .\" .Dd January 15, 2017 .Dt BUS_SPACE 9 .Os .Sh NAME .Nm bus_space , .Nm bus_space_barrier , .Nm bus_space_copy_region_1 , .Nm bus_space_copy_region_2 , .Nm bus_space_copy_region_4 , .Nm bus_space_copy_region_8 , .Nm bus_space_copy_region_stream_1 , .Nm bus_space_copy_region_stream_2 , .Nm bus_space_copy_region_stream_4 , .Nm bus_space_copy_region_stream_8 , .Nm bus_space_free , .Nm bus_space_map , .Nm bus_space_read_1 , .Nm bus_space_read_2 , .Nm bus_space_read_4 , .Nm bus_space_read_8 , .Nm bus_space_read_multi_1 , .Nm bus_space_read_multi_2 , .Nm bus_space_read_multi_4 , .Nm bus_space_read_multi_8 , .Nm bus_space_read_multi_stream_1 , .Nm bus_space_read_multi_stream_2 , .Nm bus_space_read_multi_stream_4 , .Nm bus_space_read_multi_stream_8 , .Nm bus_space_read_region_1 , .Nm bus_space_read_region_2 , .Nm bus_space_read_region_4 , .Nm bus_space_read_region_8 , .Nm bus_space_read_region_stream_1 , .Nm bus_space_read_region_stream_2 , .Nm bus_space_read_region_stream_4 , .Nm bus_space_read_region_stream_8 , .Nm bus_space_read_stream_1 , .Nm bus_space_read_stream_2 , .Nm bus_space_read_stream_4 , .Nm bus_space_read_stream_8 , .Nm bus_space_set_multi_1 , .Nm bus_space_set_multi_2 , .Nm bus_space_set_multi_4 , .Nm bus_space_set_multi_8 , .Nm bus_space_set_multi_stream_1 , .Nm bus_space_set_multi_stream_2 , .Nm bus_space_set_multi_stream_4 , .Nm bus_space_set_multi_stream_8 , .Nm bus_space_set_region_1 , .Nm bus_space_set_region_2 , .Nm bus_space_set_region_4 , .Nm bus_space_set_region_8 , .Nm bus_space_set_region_stream_1 , .Nm bus_space_set_region_stream_2 , .Nm bus_space_set_region_stream_4 , .Nm bus_space_set_region_stream_8 , .Nm bus_space_subregion , .Nm bus_space_unmap , .Nm bus_space_write_1 , .Nm bus_space_write_2 , .Nm bus_space_write_4 , .Nm bus_space_write_8 , .Nm bus_space_write_multi_1 , .Nm bus_space_write_multi_2 , .Nm bus_space_write_multi_4 , .Nm bus_space_write_multi_8 , .Nm bus_space_write_multi_stream_1 , .Nm bus_space_write_multi_stream_2 , .Nm bus_space_write_multi_stream_4 , .Nm bus_space_write_multi_stream_8 , .Nm bus_space_write_region_1 , .Nm bus_space_write_region_2 , .Nm bus_space_write_region_4 , .Nm bus_space_write_region_8 , .Nm bus_space_write_region_stream_1 , .Nm bus_space_write_region_stream_2 , .Nm bus_space_write_region_stream_4 , .Nm bus_space_write_region_stream_8 , .Nm bus_space_write_stream_1 , .Nm bus_space_write_stream_2 , .Nm bus_space_write_stream_4 , .Nm bus_space_write_stream_8 .Nd "bus space manipulation functions" .Sh SYNOPSIS .In machine/bus.h .Ft int .Fo bus_space_map .Fa "bus_space_tag_t space" "bus_addr_t address" .Fa "bus_size_t size" "int flags" "bus_space_handle_t *handlep" .Fc .Ft void .Fo bus_space_unmap .Fa "bus_space_tag_t space" "bus_space_handle_t handle" "bus_size_t size" .Fc .Ft int .Fo bus_space_subregion .Fa "bus_space_tag_t space" "bus_space_handle_t handle" .Fa "bus_size_t offset" "bus_size_t size" "bus_space_handle_t *nhandlep" .Fc .Ft int .Fo bus_space_alloc .Fa "bus_space_tag_t space" "bus_addr_t reg_start" "bus_addr_t reg_end" .Fa "bus_size_t size" "bus_size_t alignment" "bus_size_t boundary" .Fa "int flags" "bus_addr_t *addrp" "bus_space_handle_t *handlep" .Fc .Ft void .Fo bus_space_free .Fa "bus_space_tag_t space" "bus_space_handle_t handle" "bus_size_t size" .Fc .Ft uint8_t .Fo bus_space_read_1 .Fa "bus_space_tag_t space" "bus_space_handle_t handle" "bus_size_t offset" .Fc .Ft uint16_t .Fo bus_space_read_2 .Fa "bus_space_tag_t space" "bus_space_handle_t handle" "bus_size_t offset" .Fc .Ft uint32_t .Fo bus_space_read_4 .Fa "bus_space_tag_t space" "bus_space_handle_t handle" "bus_size_t offset" .Fc .Ft uint64_t .Fo bus_space_read_8 .Fa "bus_space_tag_t space" "bus_space_handle_t handle" "bus_size_t offset" .Fc .Ft uint8_t .Fo bus_space_read_stream_1 .Fa "bus_space_tag_t space" "bus_space_handle_t handle" "bus_size_t offset" .Fc .Ft uint16_t .Fo bus_space_read_stream_2 .Fa "bus_space_tag_t space" "bus_space_handle_t handle" "bus_size_t offset" .Fc .Ft uint32_t .Fo bus_space_read_stream_4 .Fa "bus_space_tag_t space" "bus_space_handle_t handle" "bus_size_t offset" .Fc .Ft uint64_t .Fo bus_space_read_stream_8 .Fa "bus_space_tag_t space" "bus_space_handle_t handle" "bus_size_t offset" .Fc .Ft void .Fo bus_space_write_1 .Fa "bus_space_tag_t space" "bus_space_handle_t handle" .Fa "bus_size_t offset" "uint8_t value" .Fc .Ft void .Fo bus_space_write_2 .Fa "bus_space_tag_t space" "bus_space_handle_t handle" .Fa "bus_size_t offset" "uint16_t value" .Fc .Ft void .Fo bus_space_write_4 .Fa "bus_space_tag_t space" "bus_space_handle_t handle" .Fa "bus_size_t offset" "uint32_t value" .Fc .Ft void .Fo bus_space_write_8 .Fa "bus_space_tag_t space" "bus_space_handle_t handle" .Fa "bus_size_t offset" "uint64_t value" .Fc .Ft void .Fo bus_space_write_stream_1 .Fa "bus_space_tag_t space" "bus_space_handle_t handle" .Fa "bus_size_t offset" "uint8_t value" .Fc .Ft void .Fo bus_space_write_stream_2 .Fa "bus_space_tag_t space" "bus_space_handle_t handle" .Fa "bus_size_t offset" "uint16_t value" .Fc .Ft void .Fo bus_space_write_stream_4 .Fa "bus_space_tag_t space" "bus_space_handle_t handle" .Fa "bus_size_t offset" "uint32_t value" .Fc .Ft void .Fo bus_space_write_stream_8 .Fa "bus_space_tag_t space" "bus_space_handle_t handle" .Fa "bus_size_t offset" "uint64_t value" .Fc .Ft void .Fo bus_space_barrier .Fa "bus_space_tag_t space" "bus_space_handle_t handle" .Fa "bus_size_t offset" "bus_size_t length" "int flags" .Fc .Ft void .Fo bus_space_read_region_1 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint8_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_read_region_2 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint16_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_read_region_4 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint32_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_read_region_8 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint64_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_read_region_stream_1 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint8_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_read_region_stream_2 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint16_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_read_region_stream_4 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint32_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_read_region_stream_8 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint64_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_write_region_1 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint8_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_write_region_2 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint16_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_write_region_4 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint32_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_write_region_8 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint64_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_write_region_stream_1 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint8_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_write_region_stream_2 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint16_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_write_region_stream_4 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint32_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_write_region_stream_8 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint64_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_copy_region_1 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t srchandle" "bus_size_t srcoffset" .Fa "bus_space_handle_t dsthandle" "bus_size_t dstoffset" "bus_size_t count" .Fc .Ft void .Fo bus_space_copy_region_2 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t srchandle" "bus_size_t srcoffset" .Fa "bus_space_handle_t dsthandle" "bus_size_t dstoffset" "bus_size_t count" .Fc .Ft void .Fo bus_space_copy_region_4 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t srchandle" "bus_size_t srcoffset" .Fa "bus_space_handle_t dsthandle" "bus_size_t dstoffset" "bus_size_t count" .Fc .Ft void .Fo bus_space_copy_region_8 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t srchandle" "bus_size_t srcoffset" .Fa "bus_space_handle_t dsthandle" "bus_size_t dstoffset" "bus_size_t count" .Fc .Ft void .Fo bus_space_copy_region_stream_1 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t srchandle" "bus_size_t srcoffset" .Fa "bus_space_handle_t dsthandle" "bus_size_t dstoffset" "bus_size_t count" .Fc .Ft void .Fo bus_space_copy_region_stream_2 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t srchandle" "bus_size_t srcoffset" .Fa "bus_space_handle_t dsthandle" "bus_size_t dstoffset" "bus_size_t count" .Fc .Ft void .Fo bus_space_copy_region_stream_4 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t srchandle" "bus_size_t srcoffset" .Fa "bus_space_handle_t dsthandle" "bus_size_t dstoffset" "bus_size_t count" .Fc .Ft void .Fo bus_space_copy_region_stream_8 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t srchandle" "bus_size_t srcoffset" .Fa "bus_space_handle_t dsthandle" "bus_size_t dstoffset" "bus_size_t count" .Fc .Ft void .Fo bus_space_set_region_1 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint8_t value" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_set_region_2 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint16_t value" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_set_region_4 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint32_t value" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_set_region_8 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint64_t value" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_set_region_stream_1 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint8_t value" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_set_region_stream_2 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint16_t value" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_set_region_stream_4 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint32_t value" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_set_region_stream_8 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint64_t value" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_read_multi_1 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint8_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_read_multi_2 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint16_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_read_multi_4 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint32_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_read_multi_8 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint64_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_read_multi_stream_1 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint8_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_read_multi_stream_2 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint16_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_read_multi_stream_4 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint32_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_read_multi_stream_8 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint64_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_write_multi_1 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint8_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_write_multi_2 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint16_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_write_multi_4 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint32_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_write_multi_8 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint64_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_write_multi_stream_1 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint8_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_write_multi_stream_2 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint16_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_write_multi_stream_4 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint32_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_write_multi_stream_8 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint64_t *datap" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_set_multi_1 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint8_t value" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_set_multi_2 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint16_t value" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_set_multi_4 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint32_t value" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_set_multi_8 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint64_t value" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_set_multi_stream_1 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint8_t value" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_set_multi_stream_2 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint16_t value" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_set_multi_stream_4 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint32_t value" .Fa "bus_size_t count" .Fc .Ft void .Fo bus_space_set_multi_stream_8 .Fa "bus_space_tag_t space" .Fa "bus_space_handle_t handle" "bus_size_t offset" "uint64_t value" .Fa "bus_size_t count" .Fc .Sh DESCRIPTION The .Nm functions exist to allow device drivers machine-independent access to bus memory and register areas. All of the functions and types described in this document can be used by including the .In machine/bus.h header file. .Pp Many common devices are used on multiple architectures, but are accessed differently on each because of architectural constraints. For instance, a device which is mapped in one system's I/O space may be mapped in memory space on a second system. On a third system, architectural limitations might change the way registers need to be accessed (e.g.\& creating a non-linear register space). In some cases, a single driver may need to access the same type of device in multiple ways in a single system or architecture. The goal of the .Nm functions is to allow a single driver source file to manipulate a set of devices on different system architectures, and to allow a single driver object file to manipulate a set of devices on multiple bus types on a single architecture. .Pp Not all buses have to implement all functions described in this document, though that is encouraged if the operations are logically supported by the bus. Unimplemented functions should cause compile-time errors if possible. .Pp All of the interface definitions described in this document are shown as function prototypes and discussed as if they were required to be functions. Implementations are encouraged to implement prototyped (type-checked) versions of these interfaces, but may implement them as macros if appropriate. Machine-dependent types, variables, and functions should be marked clearly in .In machine/bus.h to avoid confusion with the machine-independent types and functions, and, if possible, should be given names which make the machine-dependence clear. .Sh CONCEPTS AND GUIDELINES Bus spaces are described by bus space tags, which can be created only by machine-dependent code. A given machine may have several different types of bus space (e.g.\& memory space and I/O space), and thus may provide multiple different bus space tags. Individual buses or devices on a machine may use more than one bus space tag. For instance, ISA devices are given an ISA memory space tag and an ISA I/O space tag. Architectures may have several different tags which represent the same type of space, for instance because of multiple different host bus interface chipsets. .Pp A range in bus space is described by a bus address and a bus size. The bus address describes the start of the range in bus space. The bus size describes the size of the range in bytes. Buses which are not byte addressable may require use of bus space ranges with appropriately aligned addresses and properly rounded sizes. .Pp Access to regions of bus space is facilitated by use of bus space handles, which are usually created by mapping a specific range of a bus space. Handles may also be created by allocating and mapping a range of bus space, the actual location of which is picked by the implementation within bounds specified by the caller of the allocation function. .Pp All of the bus space access functions require one bus space tag argument, at least one handle argument, and at least one offset argument (a bus size). The bus space tag specifies the space, each handle specifies a region in the space, and each offset specifies the offset into the region of the actual location(s) to be accessed. Offsets are given in bytes, though buses may impose alignment constraints. The offset used to access data relative to a given handle must be such that all of the data being accessed is in the mapped region that the handle describes. Trying to access data outside that region is an error. .Pp Because some architectures' memory systems use buffering to improve memory and device access performance, there is a mechanism which can be used to create .Dq barriers in the bus space read and write stream. There are three types of barriers: read, write, and read/write. All reads started to the region before a read barrier must complete before any reads after the read barrier are started. (The analogous requirement is true for write barriers.) Read/write barriers force all reads and writes started before the barrier to complete before any reads or writes after the barrier are started. Correctly-written drivers will include all appropriate barriers, and assume only the read/write ordering imposed by the barrier operations. .Pp People trying to write portable drivers with the .Nm functions should try to make minimal assumptions about what the system allows. In particular, they should expect that the system requires bus space addresses being accessed to be naturally aligned (i.e., base address of handle added to offset is a multiple of the access size), and that the system does alignment checking on pointers (i.e., pointer to objects being read and written must point to properly-aligned data). .Pp The descriptions of the .Nm functions given below all assume that they are called with proper arguments. If called with invalid arguments or arguments that are out of range (e.g.\& trying to access data outside of the region mapped when a given handle was created), undefined behaviour results. In that case, they may cause the system to halt, either intentionally (via panic) or unintentionally (by causing a fatal trap of by some other means) or may cause improper operation which is not immediately fatal. Functions which return .Ft void or which return data read from bus space (i.e., functions which do not obviously return an error code) do not fail. They could only fail if given invalid arguments, and in that case their behaviour is undefined. Functions which take a count of bytes have undefined results if the specified .Fa count is zero. .Sh TYPES Several types are defined in .In machine/bus.h to facilitate use of the .Nm functions by drivers. .Ss Vt bus_addr_t The .Vt bus_addr_t type is used to describe bus addresses. It must be an unsigned integral type capable of holding the largest bus address usable by the architecture. This type is primarily used when mapping and unmapping bus space. .Ss Vt bus_size_t The .Vt bus_size_t type is used to describe sizes of ranges in bus space. It must be an unsigned integral type capable of holding the size of the largest bus address range usable on the architecture. This type is used by virtually all of the .Nm functions, describing sizes when mapping regions and offsets into regions when performing space access operations. .Ss Vt bus_space_tag_t The .Vt bus_space_tag_t type is used to describe a particular bus space on a machine. Its contents are machine-dependent and should be considered opaque by machine-independent code. This type is used by all .Nm functions to name the space on which they are operating. .Ss Vt bus_space_handle_t The .Vt bus_space_handle_t type is used to describe a mapping of a range of bus space. Its contents are machine-dependent and should be considered opaque by machine-independent code. This type is used when performing bus space access operations. .Sh MAPPING AND UNMAPPING BUS SPACE This section is specific to the .Nx version of these functions and may or may not apply to the .Fx version. .Pp Bus space must be mapped before it can be used, and should be unmapped when it is no longer needed. The .Fn bus_space_map and .Fn bus_space_unmap functions provide these capabilities. .Pp Some drivers need to be able to pass a subregion of already-mapped bus space to another driver or module within a driver. The .Fn bus_space_subregion function allows such subregions to be created. .Ss Fn bus_space_map space address size flags handlep The .Fn bus_space_map function maps the region of bus space named by the .Fa space , address , and .Fa size arguments. If successful, it returns zero and fills in the bus space handle pointed to by .Fa handlep with the handle that can be used to access the mapped region. If unsuccessful, it will return non-zero and leave the bus space handle pointed to by .Fa handlep in an undefined state. .Pp The .Fa flags argument controls how the space is to be mapped. Supported flags include: .Bl -tag -width ".Dv BUS_SPACE_MAP_CACHEABLE" .It Dv BUS_SPACE_MAP_CACHEABLE Try to map the space so that accesses can be cached and/or prefetched by the system. If this flag is not specified, the implementation should map the space so that it will not be cached or prefetched. .Pp This flag must have a value of 1 on all implementations for backward compatibility. .It Dv BUS_SPACE_MAP_LINEAR Try to map the space so that its contents can be accessed linearly via normal memory access methods (e.g.\& pointer dereferencing and structure accesses). This is useful when software wants to do direct access to a memory device, e.g.\& a frame buffer. If this flag is specified and linear mapping is not possible, the .Fn bus_space_map call should fail. If this flag is not specified, the system may map the space in whatever way is most convenient. .El .Pp Not all combinations of flags make sense or are supported with all spaces. For instance, .Dv BUS_SPACE_MAP_CACHEABLE may be meaningless when used on many systems' I/O port spaces, and on some systems .Dv BUS_SPACE_MAP_LINEAR without .Dv BUS_SPACE_MAP_CACHEABLE may never work. When the system hardware or firmware provides hints as to how spaces should be mapped (e.g.\& the PCI memory mapping registers' .Dq prefetchable bit), those hints should be followed for maximum compatibility. On some systems, requesting a mapping that cannot be satisfied (e.g.\& requesting a non-cacheable mapping when the system can only provide a cacheable one) will cause the request to fail. .Pp Some implementations may keep track of use of bus space for some or all bus spaces and refuse to allow duplicate allocations. This is encouraged for bus spaces which have no notion of slot-specific space addressing, such as ISA, and for spaces which coexist with those spaces (e.g.\& PCI memory and I/O spaces co-existing with ISA memory and I/O spaces). .Pp Mapped regions may contain areas for which there is no device on the bus. If space in those areas is accessed, the results are bus-dependent. .Ss Fn bus_space_unmap space handle size The .Fn bus_space_unmap function unmaps a region of bus space mapped with .Fn bus_space_map . When unmapping a region, the .Fa size specified should be the same as the size given to .Fn bus_space_map when mapping that region. .Pp After .Fn bus_space_unmap is called on a handle, that handle is no longer valid. (If copies were made of the handle they are no longer valid, either.) .Pp This function will never fail. If it would fail (e.g.\& because of an argument error), that indicates a software bug which should cause a panic. In that case, .Fn bus_space_unmap will never return. .Ss Fn bus_space_subregion space handle offset size nhandlep The .Fn bus_space_subregion function is a convenience function which makes a new handle to some subregion of an already-mapped region of bus space. The subregion described by the new handle starts at byte offset .Fa offset into the region described by .Fa handle , with the size give by .Fa size , and must be wholly contained within the original region. .Pp If successful, .Fn bus_space_subregion returns zero and fills in the bus space handle pointed to by .Fa nhandlep . If unsuccessful, it returns non-zero and leaves the bus space handle pointed to by .Fa nhandlep in an undefined state. In either case, the handle described by .Fa handle remains valid and is unmodified. .Pp When done with a handle created by .Fn bus_space_subregion , the handle should be thrown away. Under no circumstances should .Fn bus_space_unmap be used on the handle. Doing so may confuse any resource management being done on the space, and will result in undefined behaviour. When .Fn bus_space_unmap or .Fn bus_space_free is called on a handle, all subregions of that handle become invalid. .Sh ALLOCATING AND FREEING BUS SPACE This section is specific to the .Nx version of these functions and may or may not apply to the .Fx version. .Pp Some devices require or allow bus space to be allocated by the operating system for device use. When the devices no longer need the space, the operating system should free it for use by other devices. The .Fn bus_space_alloc and .Fn bus_space_free functions provide these capabilities. .Ss Fn bus_space_alloc space reg_start reg_end size alignment boundary \ flags addrp handlep The .Fn bus_space_alloc function allocates and maps a region of bus space with the size given by .Fa size , corresponding to the given constraints. If successful, it returns zero, fills in the bus address pointed to by .Fa addrp with the bus space address of the allocated region, and fills in the bus space handle pointed to by .Fa handlep with the handle that can be used to access that region. If unsuccessful, it returns non-zero and leaves the bus address pointed to by .Fa addrp and the bus space handle pointed to by .Fa handlep in an undefined state. .Pp Constraints on the allocation are given by the .Fa reg_start , reg_end , alignment , and .Fa boundary parameters. The allocated region will start at or after .Fa reg_start and end before or at .Fa reg_end . The .Fa alignment constraint must be a power of two, and the allocated region will start at an address that is an even multiple of that power of two. The .Fa boundary constraint, if non-zero, ensures that the region is allocated so that .Fa "first address in region" / .Fa boundary has the same value as .Fa "last address in region" / .Fa boundary . If the constraints cannot be met, .Fn bus_space_alloc will fail. It is an error to specify a set of constraints that can never be met (for example, .Fa size greater than .Fa boundary ) . .Pp The .Fa flags parameter is the same as the like-named parameter to .Fn bus_space_map , the same flag values should be used, and they have the same meanings. .Pp Handles created by .Fn bus_space_alloc should only be freed with .Fn bus_space_free . Trying to use .Fn bus_space_unmap on them causes undefined behaviour. The .Fn bus_space_subregion function can be used on handles created by .Fn bus_space_alloc . .Ss Fn bus_space_free space handle size The .Fn bus_space_free function unmaps and frees a region of bus space mapped and allocated with .Fn bus_space_alloc . When unmapping a region, the .Fa size specified should be the same as the size given to .Fn bus_space_alloc when allocating the region. .Pp After .Fn bus_space_free is called on a handle, that handle is no longer valid. (If copies were made of the handle, they are no longer valid, either.) .Pp This function will never fail. If it would fail (e.g.\& because of an argument error), that indicates a software bug which should cause a panic. In that case, .Fn bus_space_free will never return. .Sh READING AND WRITING SINGLE DATA ITEMS The simplest way to access bus space is to read or write a single data item. The .Fn bus_space_read_N and .Fn bus_space_write_N families of functions provide the ability to read and write 1, 2, 4, and 8 byte data items on buses which support those access sizes. .Ss Fn bus_space_read_1 space handle offset .Ss Fn bus_space_read_2 space handle offset .Ss Fn bus_space_read_4 space handle offset .Ss Fn bus_space_read_8 space handle offset The .Fn bus_space_read_N family of functions reads a 1, 2, 4, or 8 byte data item from the offset specified by .Fa offset into the region specified by .Fa handle of the bus space specified by .Fa space . The location being read must lie within the bus space region specified by .Fa handle . .Pp For portability, the starting address of the region specified by .Fa handle plus the offset should be a multiple of the size of data item being read. On some systems, not obeying this requirement may cause incorrect data to be read, on others it may cause a system crash. .Pp Read operations done by the .Fn bus_space_read_N functions may be executed out of order with respect to other pending read and write operations unless order is enforced by use of the .Fn bus_space_barrier function. .Pp These functions will never fail. If they would fail (e.g.\& because of an argument error), that indicates a software bug which should cause a panic. In that case, they will never return. .Ss Fn bus_space_write_1 space handle offset value .Ss Fn bus_space_write_2 space handle offset value .Ss Fn bus_space_write_4 space handle offset value .Ss Fn bus_space_write_8 space handle offset value The .Fn bus_space_write_N family of functions writes a 1, 2, 4, or 8 byte data item to the offset specified by .Fa offset into the region specified by .Fa handle of the bus space specified by .Fa space . The location being written must lie within the bus space region specified by .Fa handle . .Pp For portability, the starting address of the region specified by .Fa handle plus the offset should be a multiple of the size of data item being written. On some systems, not obeying this requirement may cause incorrect data to be written, on others it may cause a system crash. .Pp Write operations done by the .Fn bus_space_write_N functions may be executed out of order with respect to other pending read and write operations unless order is enforced by use of the .Fn bus_space_barrier function. .Pp These functions will never fail. If they would fail (e.g.\& because of an argument error), that indicates a software bug which should cause a panic. In that case, they will never return. .Sh BARRIERS In order to allow high-performance buffering implementations to avoid bus activity on every operation, read and write ordering should be specified explicitly by drivers when necessary. The .Fn bus_space_barrier function provides that ability. .Ss Fn bus_space_barrier space handle offset length flags The .Fn bus_space_barrier function enforces ordering of bus space read and write operations for the specified subregion (described by the .Fa offset and .Fa length parameters) of the region named by .Fa handle in the space named by .Fa space . .Pp The .Fa flags argument controls what types of operations are to be ordered. Supported flags are: .Bl -tag -width ".Dv BUS_SPACE_BARRIER_WRITE" .It Dv BUS_SPACE_BARRIER_READ Synchronize read operations. .It Dv BUS_SPACE_BARRIER_WRITE Synchronize write operations. .El .Pp Those flags can be combined (or-ed together) to enforce ordering on both read and write operations. .Pp All of the specified type(s) of operation which are done to the region before the barrier operation are guaranteed to complete before any of the specified type(s) of operation done after the barrier. .Pp Example: Consider a hypothetical device with two single-byte ports, one write-only input port (at offset 0) and a read-only output port (at offset 1). Operation of the device is as follows: data bytes are written to the input port, and are placed by the device on a stack, the top of which is read by reading from the output port. The sequence to correctly write two data bytes to the device then read those two data bytes back would be: .Bd -literal /* * t and h are the tag and handle for the mapped device's * space. */ bus_space_write_1(t, h, 0, data0); bus_space_barrier(t, h, 0, 1, BUS_SPACE_BARRIER_WRITE); /* 1 */ bus_space_write_1(t, h, 0, data1); bus_space_barrier(t, h, 0, 2, BUS_SPACE_BARRIER_READ|BUS_SPACE_BARRIER_WRITE); /* 2 */ ndata1 = bus_space_read_1(t, h, 1); bus_space_barrier(t, h, 1, 1, BUS_SPACE_BARRIER_READ); /* 3 */ ndata0 = bus_space_read_1(t, h, 1); /* data0 == ndata0, data1 == ndata1 */ .Ed .Pp The first barrier makes sure that the first write finishes before the second write is issued, so that two writes to the input port are done in order and are not collapsed into a single write. This ensures that the data bytes are written to the device correctly and in order. .Pp The second barrier makes sure that the writes to the output port finish before any of the reads to the input port are issued, thereby making sure that all of the writes are finished before data is read. This ensures that the first byte read from the device really is the last one that was written. .Pp The third barrier makes sure that the first read finishes before the second read is issued, ensuring that data is read correctly and in order. .Pp The barriers in the example above are specified to cover the absolute minimum number of bus space locations. It is correct (and often easier) to make barrier operations cover the device's whole range of bus space, that is, to specify an offset of zero and the size of the whole region. .Sh REGION OPERATIONS Some devices use buffers which are mapped as regions in bus space. Often, drivers want to copy the contents of those buffers to or from memory, e.g.\& into mbufs which can be passed to higher levels of the system or from mbufs to be output to a network. In order to allow drivers to do this as efficiently as possible, the .Fn bus_space_read_region_N and .Fn bus_space_write_region_N families of functions are provided. .Pp Drivers occasionally need to copy one region of a bus space to another, or to set all locations in a region of bus space to contain a single value. The .Fn bus_space_copy_region_N family of functions and the .Fn bus_space_set_region_N family of functions allow drivers to perform these operations. .Ss Fn bus_space_read_region_1 space handle offset datap count .Ss Fn bus_space_read_region_2 space handle offset datap count .Ss Fn bus_space_read_region_4 space handle offset datap count .Ss Fn bus_space_read_region_8 space handle offset datap count The .Fn bus_space_read_region_N family of functions reads .Fa count 1, 2, 4, or 8 byte data items from bus space starting at byte offset .Fa offset in the region specified by .Fa handle of the bus space specified by .Fa space and writes them into the array specified by .Fa datap . Each successive data item is read from an offset 1, 2, 4, or 8 bytes after the previous data item (depending on which function is used). All locations being read must lie within the bus space region specified by .Fa handle . .Pp For portability, the starting address of the region specified by .Fa handle plus the offset should be a multiple of the size of data items being read and the data array pointer should be properly aligned. On some systems, not obeying these requirements may cause incorrect data to be read, on others it may cause a system crash. .Pp Read operations done by the .Fn bus_space_read_region_N functions may be executed in any order. They may also be executed out of order with respect to other pending read and write operations unless order is enforced by use of the .Fn bus_space_barrier function. There is no way to insert barriers between reads of individual bus space locations executed by the .Fn bus_space_read_region_N functions. .Pp These functions will never fail. If they would fail (e.g.\& because of an argument error), that indicates a software bug which should cause a panic. In that case, they will never return. .Ss Fn bus_space_write_region_1 space handle offset datap count .Ss Fn bus_space_write_region_2 space handle offset datap count .Ss Fn bus_space_write_region_4 space handle offset datap count .Ss Fn bus_space_write_region_8 space handle offset datap count The .Fn bus_space_write_region_N family of functions reads .Fa count 1, 2, 4, or 8 byte data items from the array specified by .Fa datap and writes them to bus space starting at byte offset .Fa offset in the region specified by .Fa handle of the bus space specified by .Fa space . Each successive data item is written to an offset 1, 2, 4, or 8 bytes after the previous data item (depending on which function is used). All locations being written must lie within the bus space region specified by .Fa handle . .Pp For portability, the starting address of the region specified by .Fa handle plus the offset should be a multiple of the size of data items being written and the data array pointer should be properly aligned. On some systems, not obeying these requirements may cause incorrect data to be written, on others it may cause a system crash. .Pp Write operations done by the .Fn bus_space_write_region_N functions may be executed in any order. They may also be executed out of order with respect to other pending read and write operations unless order is enforced by use of the .Fn bus_space_barrier function. There is no way to insert barriers between writes of individual bus space locations executed by the .Fn bus_space_write_region_N functions. .Pp These functions will never fail. If they would fail (e.g.\& because of an argument error), that indicates a software bug which should cause a panic. In that case, they will never return. .Ss Fn bus_space_copy_region_1 space srchandle srcoffset dsthandle \ dstoffset count .Ss Fn bus_space_copy_region_2 space srchandle srcoffset dsthandle \ dstoffset count .Ss Fn bus_space_copy_region_4 space srchandle srcoffset dsthandle \ dstoffset count .Ss Fn bus_space_copy_region_8 space srchandle srcoffset dsthandle \ dstoffset count The .Fn bus_space_copy_region_N family of functions copies .Fa count 1, 2, 4, or 8 byte data items in bus space from the area starting at byte offset .Fa srcoffset in the region specified by .Fa srchandle of the bus space specified by .Fa space to the area starting at byte offset .Fa dstoffset in the region specified by .Fa dsthandle in the same bus space. Each successive data item read or written has an offset 1, 2, 4, or 8 bytes after the previous data item (depending on which function is used). All locations being read and written must lie within the bus space region specified by their respective handles. .Pp For portability, the starting addresses of the regions specified by the each handle plus its respective offset should be a multiple of the size of data items being copied. On some systems, not obeying this requirement may cause incorrect data to be copied, on others it may cause a system crash. .Pp Read and write operations done by the .Fn bus_space_copy_region_N functions may be executed in any order. They may also be executed out of order with respect to other pending read and write operations unless order is enforced by use of the .Fn bus_space_barrier function. There is no way to insert barriers between reads or writes of individual bus space locations executed by the .Fn bus_space_copy_region_N functions. .Pp Overlapping copies between different subregions of a single region of bus space are handled correctly by the .Fn bus_space_copy_region_N functions. .Pp These functions will never fail. If they would fail (e.g.\& because of an argument error), that indicates a software bug which should cause a panic. In that case, they will never return. .Ss Fn bus_space_set_region_1 space handle offset value count .Ss Fn bus_space_set_region_2 space handle offset value count .Ss Fn bus_space_set_region_4 space handle offset value count .Ss Fn bus_space_set_region_8 space handle offset value count The .Fn bus_space_set_region_N family of functions writes the given .Fa value to .Fa count 1, 2, 4, or 8 byte data items in bus space starting at byte offset .Fa offset in the region specified by .Fa handle of the bus space specified by .Fa space . Each successive data item has an offset 1, 2, 4, or 8 bytes after the previous data item (depending on which function is used). All locations being written must lie within the bus space region specified by .Fa handle . .Pp For portability, the starting address of the region specified by .Fa handle plus the offset should be a multiple of the size of data items being written. On some systems, not obeying this requirement may cause incorrect data to be written, on others it may cause a system crash. .Pp Write operations done by the .Fn bus_space_set_region_N functions may be executed in any order. They may also be executed out of order with respect to other pending read and write operations unless order is enforced by use of the .Fn bus_space_barrier function. There is no way to insert barriers between writes of individual bus space locations executed by the .Fn bus_space_set_region_N functions. .Pp These functions will never fail. If they would fail (e.g.\& because of an argument error), that indicates a software bug which should cause a panic. In that case, they will never return. .Sh READING AND WRITING A SINGLE LOCATION MULTIPLE TIMES Some devices implement single locations in bus space which are to be read or written multiple times to communicate data, e.g.\& some ethernet devices' packet buffer FIFOs. In order to allow drivers to manipulate these types of devices as efficiently as possible, the .Fn bus_space_read_multi_N , .Fn bus_space_set_multi_N , and .Fn bus_space_write_multi_N families of functions are provided. .Ss Fn bus_space_read_multi_1 space handle offset datap count .Ss Fn bus_space_read_multi_2 space handle offset datap count .Ss Fn bus_space_read_multi_4 space handle offset datap count .Ss Fn bus_space_read_multi_8 space handle offset datap count The .Fn bus_space_read_multi_N family of functions reads .Fa count 1, 2, 4, or 8 byte data items from bus space at byte offset .Fa offset in the region specified by .Fa handle of the bus space specified by .Fa space and writes them into the array specified by .Fa datap . Each successive data item is read from the same location in bus space. The location being read must lie within the bus space region specified by .Fa handle . .Pp For portability, the starting address of the region specified by .Fa handle plus the offset should be a multiple of the size of data items being read and the data array pointer should be properly aligned. On some systems, not obeying these requirements may cause incorrect data to be read, on others it may cause a system crash. .Pp Read operations done by the .Fn bus_space_read_multi_N functions may be executed out of order with respect to other pending read and write operations unless order is enforced by use of the .Fn bus_space_barrier function. Because the .Fn bus_space_read_multi_N functions read the same bus space location multiple times, they place an implicit read barrier between each successive read of that bus space location. .Pp These functions will never fail. If they would fail (e.g.\& because of an argument error), that indicates a software bug which should cause a panic. In that case, they will never return. .Ss Fn bus_space_write_multi_1 space handle offset datap count .Ss Fn bus_space_write_multi_2 space handle offset datap count .Ss Fn bus_space_write_multi_4 space handle offset datap count .Ss Fn bus_space_write_multi_8 space handle offset datap count The .Fn bus_space_write_multi_N family of functions reads .Fa count 1, 2, 4, or 8 byte data items from the array specified by .Fa datap and writes them into bus space at byte offset .Fa offset in the region specified by .Fa handle of the bus space specified by .Fa space . Each successive data item is written to the same location in bus space. The location being written must lie within the bus space region specified by .Fa handle . .Pp For portability, the starting address of the region specified by .Fa handle plus the offset should be a multiple of the size of data items being written and the data array pointer should be properly aligned. On some systems, not obeying these requirements may cause incorrect data to be written, on others it may cause a system crash. .Pp Write operations done by the .Fn bus_space_write_multi_N functions may be executed out of order with respect to other pending read and write operations unless order is enforced by use of the .Fn bus_space_barrier function. Because the .Fn bus_space_write_multi_N functions write the same bus space location multiple times, they place an implicit write barrier between each successive write of that bus space location. .Pp These functions will never fail. If they would fail (e.g.\& because of an argument error), that indicates a software bug which should cause a panic. In that case, they will never return. .Ss Fn bus_space_set_multi_1 space handle offset value count .Ss Fn bus_space_set_multi_2 space handle offset value count .Ss Fn bus_space_set_multi_4 space handle offset value count .Ss Fn bus_space_set_multi_8 space handle offset value count The .Fn bus_space_set_multi_N writes .Fa value into bus space at byte offset .Fa offset in the region specified by .Fa handle of the bus space specified by .Fa space , .Fa count times. The location being written must lie within the bus space region specified by .Fa handle . .Pp For portability, the starting address of the region specified by .Fa handle plus the offset should be a multiple of the size of data items being written and the data array pointer should be properly aligned. On some systems, not obeying these requirements may cause incorrect data to be written, on others it may cause a system crash. .Pp Write operations done by the .Fn bus_space_set_multi_N functions may be executed out of order with respect to other pending read and write operations unless order is enforced by use of the .Fn bus_space_barrier function. Because the .Fn bus_space_set_multi_N functions write the same bus space location multiple times, they place an implicit write barrier between each successive write of that bus space location. .Pp These functions will never fail. If they would fail (e.g.\& because of an argument error), that indicates a software bug which should cause a panic. In that case, they will never return. .Sh STREAM FUNCTIONS Most of the .Nm functions imply a host byte-order and a bus byte-order and take care of any translation for the caller. In some cases, however, hardware may map a FIFO or some other memory region for which the caller may want to use multi-word, yet untranslated access. Access to these types of memory regions should be with the .Fn bus_space_*_stream_N functions. .Pp .Bl -tag -compact -width Fn .It Fn bus_space_read_stream_1 .It Fn bus_space_read_stream_2 .It Fn bus_space_read_stream_4 .It Fn bus_space_read_stream_8 .It Fn bus_space_read_multi_stream_1 .It Fn bus_space_read_multi_stream_2 .It Fn bus_space_read_multi_stream_4 .It Fn bus_space_read_multi_stream_8 .It Fn bus_space_read_region_stream_1 .It Fn bus_space_read_region_stream_2 .It Fn bus_space_read_region_stream_4 .It Fn bus_space_read_region_stream_8 .It Fn bus_space_write_stream_1 .It Fn bus_space_write_stream_2 .It Fn bus_space_write_stream_4 .It Fn bus_space_write_stream_8 .It Fn bus_space_write_multi_stream_1 .It Fn bus_space_write_multi_stream_2 .It Fn bus_space_write_multi_stream_4 .It Fn bus_space_write_multi_stream_8 .It Fn bus_space_write_region_stream_1 .It Fn bus_space_write_region_stream_2 .It Fn bus_space_write_region_stream_4 .It Fn bus_space_write_region_stream_8 .It Fn bus_space_copy_region_stream_1 .It Fn bus_space_copy_region_stream_2 .It Fn bus_space_copy_region_stream_4 .It Fn bus_space_copy_region_stream_8 .It Fn bus_space_set_multi_stream_1 .It Fn bus_space_set_multi_stream_2 .It Fn bus_space_set_multi_stream_4 .It Fn bus_space_set_multi_stream_8 .It Fn bus_space_set_region_stream_1 .It Fn bus_space_set_region_stream_2 .It Fn bus_space_set_region_stream_4 .It Fn bus_space_set_region_stream_8 .El .Pp These functions are defined just as their non-stream counterparts, except that they provide no byte-order translation. .Sh COMPATIBILITY The current .Nx version of the .Nm interface specification differs slightly from the original specification that came into wide use and .Fx adopted. A few of the function names and arguments have changed for consistency and increased functionality. .Sh SEE ALSO .Xr bus_dma 9 .Sh HISTORY The .Nm functions were introduced in a different form (memory and I/O spaces were accessed via different sets of functions) in .Nx 1.2 . The functions were merged to work on generic .Dq spaces early in the .Nx 1.3 development cycle, and many drivers were converted to use them. This document was written later during the .Nx 1.3 development cycle, and the specification was updated to fix some consistency problems and to add some missing functionality. .Pp The manual page was then adapted to the version of the interface that .Fx imported for the CAM SCSI drivers, plus subsequent evolution. The .Fx .Nm version was imported in .Fx 3.0 . .Sh AUTHORS .An -nosplit The .Nm interfaces were designed and implemented by the .Nx developer community. Primary contributors and implementors were .An Chris Demetriou , .An Jason Thorpe , and .An Charles Hannum , but the rest of the .Nx developers and the user community played a significant role in development. .Pp .An Justin Gibbs ported these interfaces to .Fx . .Pp .An Chris Demetriou wrote this manual page. .Pp .An Warner Losh modified it for the .Fx implementation. .Sh BUGS This manual may not completely and accurately document the interface, and many parts of the interface are unspecified. Index: head/share/man/man9/config_intrhook.9 =================================================================== --- head/share/man/man9/config_intrhook.9 (revision 355329) +++ head/share/man/man9/config_intrhook.9 (revision 355330) @@ -1,120 +1,120 @@ .\" -.\" Copyright (C) 2006 M. Warner Losh . +.\" Copyright (C) 2006 M. Warner Losh .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice(s), this list of conditions and the following disclaimer as .\" the first lines of this file unmodified other than the possible .\" addition of one or more copyright notices. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice(s), this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY .\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE .\" DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR .\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER .\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH .\" DAMAGE. .\" .\" $FreeBSD$ .\" .Dd August 10, 2017 .Dt CONFIG_INTRHOOK 9 .Os .Sh NAME .Nm config_intrhook .Nd schedule a function to be run after interrupts have been enabled, but before root is mounted .Sh SYNOPSIS .In sys/kernel.h .Vt typedef void (*ich_func_t)(void *arg); .Ft int .Fn config_intrhook_establish "struct intr_config_hook *hook" .Ft void .Fn config_intrhook_disestablish "struct intr_config_hook *hook" .Ft void .Fn config_intrhook_oneshot "ich_func_t func" "void *arg" .Sh DESCRIPTION The .Fn config_intrhook_establish function schedules a function to be run after interrupts have been enabled, but before root is mounted. If the system has already passed this point in its initialization, the function is called immediately. .Pp The .Fn config_intrhook_disestablish function removes the entry from the hook queue. .Pp The .Fn config_intrhook_oneshot function schedules a function to be run as described for .Fn config_intrhook_establish ; the entry is automatically removed from the hook queue after that function runs. This is appropriate when additional device configuration must be done after interrupts are enabled, but there is no need to stall the boot process after that. This function allocates memory using M_WAITOK; do not call this while holding any non-sleepable locks. .Pp Before root is mounted, all the previously established hooks are run. The boot process is then stalled until all handlers remove their hook from the hook queue with .Fn config_intrhook_disestablish . The boot process then proceeds to attempt to mount the root file system. Any driver that can potentially provide devices they wish to be mounted as root must use either this hook, or probe all these devices in the initial probe. Since interrupts are disabled during the probe process, many drivers need a method to probe for devices with interrupts enabled. .Pp The requests are made with the .Vt intr_config_hook structure. This structure is defined as follows: .Bd -literal struct intr_config_hook { TAILQ_ENTRY(intr_config_hook) ich_links;/* Private */ ich_func_t ich_func; /* function to call */ void *ich_arg; /* Argument to call */ }; .Ed .Pp Storage for the .Vt intr_config_hook structure must be provided by the driver. It must be stable from just before the hook is established until after the hook is disestablished. .Pp Specifically, hooks are run at .Fn SI_SUB_INT_CONFIG_HOOKS , which is immediately after the scheduler is started, and just before the root file system device is discovered. .Sh RETURN VALUES A zero return value means the hook was successfully added to the queue (with either deferred or immediate execution). A non-zero return value means the hook could not be added to the queue because it was already on the queue. .Sh SEE ALSO .Xr DEVICE_ATTACH 9 .Sh HISTORY These functions were introduced in .Fx 3.0 with the CAM subsystem, but are available for any driver to use. .Sh AUTHORS .An -nosplit The functions were written by .An Justin Gibbs Aq Mt gibbs@FreeBSD.org . This manual page was written by .An M. Warner Losh Aq Mt imp@FreeBSD.org . Index: head/share/man/man9/device_get_name.9 =================================================================== --- head/share/man/man9/device_get_name.9 (revision 355329) +++ head/share/man/man9/device_get_name.9 (revision 355330) @@ -1,56 +1,52 @@ .\" -*- nroff -*- .\" -.\" Copyright (c) 2003 M. Warner Losh -.\" -.\" All rights reserved. -.\" -.\" This program is free software. +.\" Copyright (c) 2003 M. Warner Losh .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .\" $FreeBSD$ .\" .Dd April 21, 2003 .Dt DEVICE_GET_NAME 9 .Os .Sh NAME .Nm device_get_name , device_get_nameunit .Nd access the name of a device's device class or instance .Sh SYNOPSIS .In sys/param.h .In sys/bus.h .Ft const char * .Fn device_get_name "device_t dev" .Ft const char * .Fn device_get_nameunit "device_t dev" .Sh DESCRIPTION The .Fn device_get_name function returns the name of the device's device class. .Pp The .Fn device_get_nameunit function returns the name of the device's instance. .Sh SEE ALSO .Xr device 9 .Sh AUTHORS This manual page was written by .An Warner Losh . Index: head/share/man/man9/device_get_parent.9 =================================================================== --- head/share/man/man9/device_get_parent.9 (revision 355329) +++ head/share/man/man9/device_get_parent.9 (revision 355330) @@ -1,50 +1,46 @@ .\" -*- nroff -*- .\" -.\" Copyright (c) 2003 M. Warner Losh -.\" -.\" All rights reserved. -.\" -.\" This program is free software. +.\" Copyright (c) 2003 M. Warner Losh .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .\" $FreeBSD$ .\" .Dd April 21, 2003 .Dt DEVICE_GET_PARENT 9 .Os .Sh NAME .Nm device_get_parent .Nd return the device's parent .Sh SYNOPSIS .In sys/param.h .In sys/bus.h .Ft device_t .Fn device_get_parent "device_t dev" .Sh DESCRIPTION The .Fn device_get_parent function returns the name of the device's parent device. .Sh SEE ALSO .Xr device 9 .Sh AUTHORS This manual page was written by .An Warner Losh . Index: head/share/man/man9/device_get_sysctl.9 =================================================================== --- head/share/man/man9/device_get_sysctl.9 (revision 355329) +++ head/share/man/man9/device_get_sysctl.9 (revision 355330) @@ -1,58 +1,54 @@ .\" -*- nroff -*- .\" -.\" Copyright (c) 2006 M. Warner Losh -.\" -.\" All rights reserved. -.\" -.\" This program is free software. +.\" Copyright (c) 2006 M. Warner Losh .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .\" $FreeBSD$ .\" .Dd June 18, 2011 .Dt DEVICE_GET_SYSCTL 9 .Os .Sh NAME .Nm device_get_sysctl_ctx , .Nm device_get_sysctl_tree .Nd manipulate the sysctl oid tree for driver specific sysctl nodes .Sh SYNOPSIS .In sys/param.h .In sys/bus.h .Ft "struct sysctl_ctx_list *" .Fn device_get_sysctl_ctx "device_t dev" .Ft "struct sysctl_oid *" .Fn device_get_sysctl_tree "device_t dev" .Sh DESCRIPTION The newbus system automatically adds a sysctl node for each device in the system. This node can be accessed with the .Fn device_get_sysctl_tree function. The context for the node can be obtained with the .Fn device_get_sysctl_ctx function. .Sh SEE ALSO .Xr device 9 .Sh AUTHORS This manual page was written by .An Warner Losh . Index: head/share/man/man9/device_printf.9 =================================================================== --- head/share/man/man9/device_printf.9 (revision 355329) +++ head/share/man/man9/device_printf.9 (revision 355330) @@ -1,58 +1,57 @@ .\" -.\" Copyright (c) 2003 M. Warner Losh -.\" All rights reserved. +.\" Copyright (c) 2003 M. Warner Losh .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, .\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED .\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" $FreeBSD$ .\" .Dd April 21, 2003 .Dt DEVICE_PRINTF 9 .Os .Sh NAME .Nm device_printf .Nd formatted output conversion .Sh SYNOPSIS .In sys/param.h .In sys/bus.h .Ft int .Fn device_printf "device_t dev" "const char *fmt" ... .Sh DESCRIPTION The .Fn device_printf function is a convenience interface to the .Xr printf 9 function. It outputs the name of the .Fa dev device, followed by a colon and a space, and then what .Xr printf 9 would print if you passed .Fa fmt and the remaining arguments to it. .Sh RETURN VALUES The .Fn device_printf function returns the number of characters displayed. .Sh SEE ALSO .Xr printf 3 , .Xr printf 9 Index: head/share/man/man9/device_set_driver.9 =================================================================== --- head/share/man/man9/device_set_driver.9 (revision 355329) +++ head/share/man/man9/device_set_driver.9 (revision 355330) @@ -1,53 +1,49 @@ .\" -*- nroff -*- .\" -.\" Copyright (c) 2003 M. Warner Losh -.\" -.\" All rights reserved. -.\" -.\" This program is free software. +.\" Copyright (c) 2003 M. Warner Losh .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .\" $FreeBSD$ .\" .Dd April 21, 2003 .Dt DEVICE_SET_DRIVER 9 .Os .Sh NAME .Nm device_set_driver .Nd "associate a specific driver with a device node in the tree" .Sh SYNOPSIS .In sys/param.h .In sys/bus.h .Ft void .Fn device_set_driver "device_t dev" "driver_t *driver" .Sh DESCRIPTION This function associates a specific driver with a given device node in the tree. It is typically used in .Xr DEVICE_IDENTIFY 9 functions to add devices to a bus that does not support doing so automatically, such as the ISA bus. .Sh SEE ALSO .Xr device 9 .Sh AUTHORS This manual page was written by .An M. Warner Losh . Index: head/share/man/man9/owll.9 =================================================================== --- head/share/man/man9/owll.9 (revision 355329) +++ head/share/man/man9/owll.9 (revision 355330) @@ -1,93 +1,92 @@ .\" -.\" Copyright (c) 2015 M. Warner Losh -.\" All rights reserved. +.\" Copyright (c) 2015 M. Warner Losh .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. The name of the author may not be used to endorse or promote products .\" derived from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" $FreeBSD$ .\" .Dd September 22, 2016 .Dt OWLL 9 .Os .Sh NAME .Nm owll .Nm OWLL_WRITE_ONE , .Nm OWLL_WRITE_ZERO , .Nm OWLL_READ_DATA , .Nm OWLL_REASET_AND_PRESENCE .Nd Dallas Semiconductor 1-Wire Link Layer Interface .Sh SYNOPSIS .Ft int .Fn OWLL_WRITE_ONE "device_t lldev" "struct ow_timing *timing" .Ft int .Fn OWLL_WRITE_ZERO "device_t lldev" "struct ow_timing *timing" .Ft int .Fn OWLL_READ_DATA "device_t lldev" "struct ow_timing *timing" "int *bit" .Ft int .Fn OWLL_RESET_AND_PRESENCE "device_t lldev" "struct ow_timing *timing" "int *bit" .Sh DESCRIPTION The .Nm interface provides access to the link layer of the Dallas Semiconductor 1-Wire from upper layers of the protocol. .Pp .Fn OWLL_WRITE_ONE and .Fn OWLL_WRITE_ZERO writes a one bit or a zero bit respectively on the 1-Wire bus. .Pp .Fn OWLL_READ_DATA reads one bit from the 1-Wire bus. This is often referred to as a .Dq Read Time Slot in the 1-Wire device data sheets. .Pp The .Fn OWLL_RESET_AND_PRESENCE function starts a reset sequence and detects if any device(s) are present on the bus. This is the beginning of all 1-Wire transactions. .Sh NOTES This interface is intended to be used only by the .Xr ow 4 device to talk to the low-level bus. By convention, the device that implements this interface is called .Xr owc 4 . Only devices that implement .Xr own 9 should call these interfaces. .Sh SEE ALSO .Xr ow 4 , .Xr owc 4 , .Xr own 9 .Sh LEGAL .Tn 1-Wire is a registered trademark of Maxim Integrated Products, Inc. .Sh HISTORY The .Nm driver first appeared in .Fx 11.0 . .Sh AUTHORS The .Nm device driver and this manual page were written by .An Warner Losh . Index: head/share/man/man9/own.9 =================================================================== --- head/share/man/man9/own.9 (revision 355329) +++ head/share/man/man9/own.9 (revision 355330) @@ -1,230 +1,229 @@ .\" -.\" Copyright (c) 2015 M. Warner Losh -.\" All rights reserved. +.\" Copyright (c) 2015 M. Warner Losh .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. The name of the author may not be used to endorse or promote products .\" derived from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" $FreeBSD$ .\" .Dd July 20, 2015 .Dt OWN 9 .Os .Sh NAME .Nm own , .Nm own_send_command , .Nm own_commmand_wait , .Nm own_self_command , .Nm own_acquire_bus , .Nm own crc , .Nm own_release_bus , .Nm OWN_ACQUIRE_BUS , .Nm OWN_CRC , .Nm OWN_RELEASE_BUS , .Nm OWN_SEND_COMMAND .Nd Dallas Semiconductor 1-Wire Network and Transport Interface .Sh SYNOPSIS .In sys/bus.h .In dev/ow/own.h .Ft int .Fn own_send_command "device_t pdev" "struct ow_cmd *cmd" .Ft int .Fn own_command_wait "device_t pdev" "struct ow_cmd *cmd" .Ft int .Fn own_self_command "device_t pdev" "struct ow_cmd *cmd" "uint8_t xpt_cmd" .Ft int .Fn own_acquire_bus "device_t pdev" "int how" .Ft int .Fn own_release_bus "device_t pdev" .Ft int .Fn own_crc "device_t pdev" "uint8_t *buffer" "size_t len" .Ft int .Fn OWN_SEND_COMMAND "device_t ndev" "device_t pdev" "struct ow_cmd *cmd" .Ft int .Fn OWN_ACQUIRE_BUS "device_t ndev" "device_t pdev" "int how" .Ft void .Fn OWN_RELEASE_BUS "device_t ndev" "device_t pdev" .Ft uint8_t .Fn OWN_CRC "device_t ndev" "device_t pdev" "uint8_t *buffer" "size_t len" .Sh DESCRIPTION The .Nm interface defines three sets of functions for interacting with 1-Wire devices: sending commands, reserving the bus, and ensuring data integrity. Wrappers are provided for the raw .Nm OWN .Xr kobj 9 interfaces and should be used for improved safety over the .Xr kobj 9 ones. .Ss Bus Commands The 1-Wire bus defines different layers of access to the devices on the bus. The .Nm functions provide access to the network and transport layers. The network layer designates the next command as being either for all devices on the bus, or for a specific device. The network layer also specifies the speed used by the link layer. .Pp .Vt "struct ow_cmd" encapsulates network access, speed, and timing information. It specifies the commands to send and whether or not to read data. Its members are: .Bl -tag -width ".Va xxxx" .It Va flags Flags controlling the interpretation of the structure. These flags are defined in .In dev/ow/ow.h : .Bl -tag -width indent .It OW_FLAG_OVERDRIVE Send .Va xpt_cmd bytes and read .Va xpt_read bytes at overdrive speed. .It OW_FLAG_READ_BIT Interpret .Va xpt_read_len to be in bits to be read after .Va xpt_cmd rather than bytes. .El .It Va rom_cmd ROM command bytes to send. .It Va rom_len Number of ROM command bytes to send. .It Va rom_read_len Number of bytes to read after sending the ROM command. .It Va rom_read Buffer for bytes read after the ROM command. .It Va xpt_cmd Transport command to send. .It Va xpt_len Length of the transport command bytes to send. Specify 0 for no transport command. .It Va xpt_read_len Number of bytes to read after .Va xpt_cmd bytes are sent. If the .Dv OW_FLAG_READ_BIT bit is set in .Va flags , then it is the number of bits to read. Bits read are packed into bytes. .It Va xpt_read Buffer for data read. .El .Pp .Fn own_command_wait acquires the 1-Wire bus, waiting if necessary, sends the command, and then releases the bus. .Fn own_send_command sends the command without bus reservation. .Fa pdev is the client device (the presentation layer device) sending the command. The .Fa cmd argument describes the transaction to send to the 1-Wire bus. .Pp .Fn own_self_command fills in .Fa cmd with a MATCH_ROM ROM command, the ROM address of .Fa pdev and the .Fa xpt_cmd as a convenient way to create directed commands. .Ss Bus Reservation The 1-Wire system includes an advisory lock for the bus that presentation layer devices can use to coordinate access. Locking is purely advisory at this time. .Pp .Fn own_acquire_bus reserves the bus. It waits indefinitely if the .Fa how argument is .Dv OWN_WAIT and returns the error .Dv EWOULDBLOCK if passed .Dv OWN_DONTWAIT when the bus is owned by another client. .Pp .Fn own_release_bus releases the bus. .Ss Data Integrity .Fn own_crc computes the 1-Wire standard CRC function over the data passed in .Fa buffer and .Fa len and returns the result. .Ss Notes The 1-Wire standard (Maxim AN937) defines layers that are akin to ISO networking layers. The lowest relevant layer, the link layer, defines the polling windows and the timing of the signaling of different modes. The network layer is built on top of the link layer and is used to address devices in a unicast or multicast manner. The transport layer defines commands and responses from the devices. The presentation layer is composed of the device specific commands and actions used to control the specific 1-Wire devices on bus. .Pp These interfaces are implemented by the .Xr ow 4 device. Presentation layer devices (children of the newbus .Xr ow 4 device) should only call the functions described here. The functionality provided by the .Xr owc 4 device (specifically the .Xr owll 9 interface) should only be called by the .Xr ow 4 driver. .Sh SEE ALSO .Xr ow 4 , .Xr owc 4 , .Xr owll 9 .Pa https://pdfserv.maximintegrated.com/en/an/AN937.pdf .Sh LEGAL .Tn 1-Wire is a registered trademark of Maxim Integrated Products, Inc. .Sh HISTORY The .Nm driver first appeared in .Fx 11.0 . .Sh AUTHORS The .Nm device driver and this manual page were written by .An Warner Losh . Index: head/share/man/man9/resource_int_value.9 =================================================================== --- head/share/man/man9/resource_int_value.9 (revision 355329) +++ head/share/man/man9/resource_int_value.9 (revision 355330) @@ -1,79 +1,75 @@ .\" -*- nroff -*- .\" -.\" Copyright (c) 2001 M. Warner Losh -.\" -.\" All rights reserved. -.\" -.\" This program is free software. +.\" Copyright (c) 2001 M. Warner Losh .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .\" $FreeBSD$ .\" .Dd March 1, 2001 .Dt RESOURCE_INT_VALUE 9 .Os .Sh NAME .Nm resource_int_value , resource_long_value , resource_string_value .Nd get a value from the hints mechanism .Sh SYNOPSIS .In sys/param.h .In sys/bus.h .Ft int .Fn resource_int_value "const char *name" "int unit" "const char *resname" "int *result" .Ft int .Fn resource_long_value "const char *name" "int unit" "const char *resname" "long *result" .Ft int .Fn resource_string_value "const char *name" "int unit" "const char *resname" "const char **result" .Sh DESCRIPTION These functions fetch a value from the .Dq hints mechanism. .Pp The functions take the following arguments: .Bl -tag -width "resname" .It Fa name The name of the device to get the resource value from. .It Fa unit The unit number of the device. \-1 is special and is used for wildcard entries. .It Fa resname The resource name. .It Fa result A pointer to memory in which to store the resource value. .El .Sh RETURN VALUES If successful, the functions return 0. Otherwise, a non\-zero error code is returned. .Sh ERRORS The functions will fail if: .Bl -tag -width Er .It Bq Er ENOENT The resource could not be found. .It Bq Er EFTYPE Inappropriate resource type. .El .Sh SEE ALSO .Xr device 9 , .Xr driver 9 .Sh AUTHORS This manual page was written by .An Warner Losh Aq Mt imp@FreeBSD.org .