2005-06-14 03:40:01 +00:00
|
|
|
.\" $NetBSD: bus_space.9,v 1.9 1999/03/06 22:09:29 mycroft Exp $
|
2005-06-25 08:59:05 +00:00
|
|
|
.\"
|
2005-06-14 03:40:01 +00:00
|
|
|
.\" Copyright (c) 2005 M. Warner Losh. All Rights Reserved.
|
|
|
|
.\" 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.
|
2005-06-25 08:59:05 +00:00
|
|
|
.\"
|
2005-06-14 03:40:01 +00:00
|
|
|
.\" This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
.\" by Christopher G. Demetriou.
|
2005-06-25 08:59:05 +00:00
|
|
|
.\"
|
2005-06-14 03:40:01 +00:00
|
|
|
.\" 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.
|
|
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
|
|
|
.\" must display the following acknowledgment:
|
|
|
|
.\" This product includes software developed by the NetBSD
|
|
|
|
.\" Foundation, Inc. and its contributors.
|
|
|
|
.\" 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
.\" contributors may be used to endorse or promote products derived
|
|
|
|
.\" from this software without specific prior written permission.
|
2005-06-25 08:59:05 +00:00
|
|
|
.\"
|
2005-06-14 03:40:01 +00:00
|
|
|
.\" 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.
|
|
|
|
.\"
|
2005-06-25 08:59:05 +00:00
|
|
|
.\" $FreeBSD$
|
|
|
|
.\"
|
2005-06-14 03:40:01 +00:00
|
|
|
.Dd June 13, 2005
|
|
|
|
.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 ,
|
2006-04-22 03:58:41 +00:00
|
|
|
.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 ,
|
2005-06-14 03:40:01 +00:00
|
|
|
.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 ,
|
2006-04-22 03:58:41 +00:00
|
|
|
.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 ,
|
2005-06-14 03:40:01 +00:00
|
|
|
.Nm bus_space_read_region_1 ,
|
|
|
|
.Nm bus_space_read_region_2 ,
|
|
|
|
.Nm bus_space_read_region_4 ,
|
|
|
|
.Nm bus_space_read_region_8 ,
|
2006-04-22 03:58:41 +00:00
|
|
|
.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 ,
|
2005-06-14 03:40:01 +00:00
|
|
|
.Nm bus_space_set_region_1 ,
|
|
|
|
.Nm bus_space_set_region_2 ,
|
|
|
|
.Nm bus_space_set_region_4 ,
|
|
|
|
.Nm bus_space_set_region_8 ,
|
2006-04-22 03:58:41 +00:00
|
|
|
.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 ,
|
2005-06-14 03:40:01 +00:00
|
|
|
.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 ,
|
2006-04-22 03:58:41 +00:00
|
|
|
.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 ,
|
2005-06-14 03:40:01 +00:00
|
|
|
.Nm bus_space_write_region_1 ,
|
|
|
|
.Nm bus_space_write_region_2 ,
|
|
|
|
.Nm bus_space_write_region_4 ,
|
2006-04-22 03:58:41 +00:00
|
|
|
.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
|
2005-06-25 08:59:05 +00:00
|
|
|
.Nd "bus space manipulation functions"
|
2005-06-14 03:40:01 +00:00
|
|
|
.Sh SYNOPSIS
|
2005-06-25 08:59:05 +00:00
|
|
|
.In machine/bus.h
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft int
|
2005-06-25 08:59:05 +00:00
|
|
|
.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
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_unmap
|
|
|
|
.Fa "bus_space_tag_t space" "bus_space_handle_t handle" "bus_size_t size"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft int
|
2005-06-25 08:59:05 +00:00
|
|
|
.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
|
2005-06-14 03:40:01 +00:00
|
|
|
.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
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_free
|
|
|
|
.Fa "bus_space_tag_t space" "bus_space_handle_t handle" "bus_size_t size"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft u_int8_t
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_read_1
|
|
|
|
.Fa "bus_space_tag_t space" "bus_space_handle_t handle" "bus_size_t offset"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft u_int16_t
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_read_2
|
|
|
|
.Fa "bus_space_tag_t space" "bus_space_handle_t handle" "bus_size_t offset"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft u_int32_t
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_read_4
|
|
|
|
.Fa "bus_space_tag_t space" "bus_space_handle_t handle" "bus_size_t offset"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft u_int64_t
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_read_8
|
|
|
|
.Fa "bus_space_tag_t space" "bus_space_handle_t handle" "bus_size_t offset"
|
|
|
|
.Fc
|
2006-04-22 03:58:41 +00:00
|
|
|
.Ft u_int8_t
|
|
|
|
.Fo bus_space_read_stream_1
|
|
|
|
.Fa "bus_space_tag_t space" "bus_space_handle_t handle" "bus_size_t offset"
|
|
|
|
.Fc
|
|
|
|
.Ft u_int16_t
|
|
|
|
.Fo bus_space_read_stream_2
|
|
|
|
.Fa "bus_space_tag_t space" "bus_space_handle_t handle" "bus_size_t offset"
|
|
|
|
.Fc
|
|
|
|
.Ft u_int32_t
|
|
|
|
.Fo bus_space_read_stream_4
|
|
|
|
.Fa "bus_space_tag_t space" "bus_space_handle_t handle" "bus_size_t offset"
|
|
|
|
.Fc
|
|
|
|
.Ft u_int64_t
|
|
|
|
.Fo bus_space_read_stream_8
|
|
|
|
.Fa "bus_space_tag_t space" "bus_space_handle_t handle" "bus_size_t offset"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_write_1
|
|
|
|
.Fa "bus_space_tag_t space" "bus_space_handle_t handle"
|
|
|
|
.Fa "bus_size_t offset" "u_int8_t value"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_write_2
|
|
|
|
.Fa "bus_space_tag_t space" "bus_space_handle_t handle"
|
|
|
|
.Fa "bus_size_t offset" "u_int16_t value"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_write_4
|
|
|
|
.Fa "bus_space_tag_t space" "bus_space_handle_t handle"
|
|
|
|
.Fa "bus_size_t offset" "u_int32_t value"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_write_8
|
|
|
|
.Fa "bus_space_tag_t space" "bus_space_handle_t handle"
|
|
|
|
.Fa "bus_size_t offset" "u_int64_t value"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2006-04-22 03:58:41 +00:00
|
|
|
.Fo bus_space_write_stream_1
|
|
|
|
.Fa "bus_space_tag_t space" "bus_space_handle_t handle"
|
|
|
|
.Fa "bus_size_t offset" "u_int8_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" "u_int16_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" "u_int32_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" "u_int64_t value"
|
|
|
|
.Fc
|
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.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
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_read_region_1
|
|
|
|
.Fa "bus_space_tag_t space"
|
|
|
|
.Fa "bus_space_handle_t handle" "bus_size_t offset" "u_int8_t *datap"
|
|
|
|
.Fa "bus_size_t count"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_read_region_2
|
|
|
|
.Fa "bus_space_tag_t space"
|
|
|
|
.Fa "bus_space_handle_t handle" "bus_size_t offset" "u_int16_t *datap"
|
|
|
|
.Fa "bus_size_t count"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_read_region_4
|
|
|
|
.Fa "bus_space_tag_t space"
|
|
|
|
.Fa "bus_space_handle_t handle" "bus_size_t offset" "u_int32_t *datap"
|
|
|
|
.Fa "bus_size_t count"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_read_region_8
|
|
|
|
.Fa "bus_space_tag_t space"
|
|
|
|
.Fa "bus_space_handle_t handle" "bus_size_t offset" "u_int64_t *datap"
|
|
|
|
.Fa "bus_size_t count"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2006-04-22 03:58:41 +00:00
|
|
|
.Fo bus_space_read_region_stream_1
|
|
|
|
.Fa "bus_space_tag_t space"
|
|
|
|
.Fa "bus_space_handle_t handle" "bus_size_t offset" "u_int8_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" "u_int16_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" "u_int32_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" "u_int64_t *datap"
|
|
|
|
.Fa "bus_size_t count"
|
|
|
|
.Fc
|
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_write_region_1
|
|
|
|
.Fa "bus_space_tag_t space"
|
|
|
|
.Fa "bus_space_handle_t handle" "bus_size_t offset" "u_int8_t *datap"
|
|
|
|
.Fa "bus_size_t count"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_write_region_2
|
|
|
|
.Fa "bus_space_tag_t space"
|
|
|
|
.Fa "bus_space_handle_t handle" "bus_size_t offset" "u_int16_t *datap"
|
|
|
|
.Fa "bus_size_t count"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_write_region_4
|
|
|
|
.Fa "bus_space_tag_t space"
|
|
|
|
.Fa "bus_space_handle_t handle" "bus_size_t offset" "u_int32_t *datap"
|
|
|
|
.Fa "bus_size_t count"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_write_region_8
|
|
|
|
.Fa "bus_space_tag_t space"
|
|
|
|
.Fa "bus_space_handle_t handle" "bus_size_t offset" "u_int64_t *datap"
|
|
|
|
.Fa "bus_size_t count"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2006-04-22 03:58:41 +00:00
|
|
|
.Fo bus_space_write_region_stream_1
|
|
|
|
.Fa "bus_space_tag_t space"
|
|
|
|
.Fa "bus_space_handle_t handle" "bus_size_t offset" "u_int8_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" "u_int16_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" "u_int32_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" "u_int64_t *datap"
|
|
|
|
.Fa "bus_size_t count"
|
|
|
|
.Fc
|
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.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
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.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
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.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
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.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
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2006-04-22 03:58:41 +00:00
|
|
|
.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
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_set_region_1
|
|
|
|
.Fa "bus_space_tag_t space"
|
|
|
|
.Fa "bus_space_handle_t handle" "bus_size_t offset" "u_int8_t value"
|
|
|
|
.Fa "bus_size_t count"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_set_region_2
|
|
|
|
.Fa "bus_space_tag_t space"
|
|
|
|
.Fa "bus_space_handle_t handle" "bus_size_t offset" "u_int16_t value"
|
|
|
|
.Fa "bus_size_t count"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_set_region_4
|
|
|
|
.Fa "bus_space_tag_t space"
|
|
|
|
.Fa "bus_space_handle_t handle" "bus_size_t offset" "u_int32_t value"
|
|
|
|
.Fa "bus_size_t count"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_set_region_8
|
|
|
|
.Fa "bus_space_tag_t space"
|
|
|
|
.Fa "bus_space_handle_t handle" "bus_size_t offset" "u_int64_t value"
|
|
|
|
.Fa "bus_size_t count"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2006-04-22 03:58:41 +00:00
|
|
|
.Fo bus_space_set_region_stream_1
|
|
|
|
.Fa "bus_space_tag_t space"
|
|
|
|
.Fa "bus_space_handle_t handle" "bus_size_t offset" "u_int8_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" "u_int16_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" "u_int32_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" "u_int64_t value"
|
|
|
|
.Fa "bus_size_t count"
|
|
|
|
.Fc
|
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_read_multi_1
|
|
|
|
.Fa "bus_space_tag_t space"
|
|
|
|
.Fa "bus_space_handle_t handle" "bus_size_t offset" "u_int8_t *datap"
|
|
|
|
.Fa "bus_size_t count"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_read_multi_2
|
|
|
|
.Fa "bus_space_tag_t space"
|
|
|
|
.Fa "bus_space_handle_t handle" "bus_size_t offset" "u_int16_t *datap"
|
|
|
|
.Fa "bus_size_t count"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_read_multi_4
|
|
|
|
.Fa "bus_space_tag_t space"
|
|
|
|
.Fa "bus_space_handle_t handle" "bus_size_t offset" "u_int32_t *datap"
|
|
|
|
.Fa "bus_size_t count"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_read_multi_8
|
|
|
|
.Fa "bus_space_tag_t space"
|
|
|
|
.Fa "bus_space_handle_t handle" "bus_size_t offset" "u_int64_t *datap"
|
|
|
|
.Fa "bus_size_t count"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2006-04-22 03:58:41 +00:00
|
|
|
.Fo bus_space_read_multi_stream_1
|
|
|
|
.Fa "bus_space_tag_t space"
|
|
|
|
.Fa "bus_space_handle_t handle" "bus_size_t offset" "u_int8_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" "u_int16_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" "u_int32_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" "u_int64_t *datap"
|
|
|
|
.Fa "bus_size_t count"
|
|
|
|
.Fc
|
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_write_multi_1
|
|
|
|
.Fa "bus_space_tag_t space"
|
|
|
|
.Fa "bus_space_handle_t handle" "bus_size_t offset" "u_int8_t *datap"
|
|
|
|
.Fa "bus_size_t count"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_write_multi_2
|
|
|
|
.Fa "bus_space_tag_t space"
|
|
|
|
.Fa "bus_space_handle_t handle" "bus_size_t offset" "u_int16_t *datap"
|
|
|
|
.Fa "bus_size_t count"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_write_multi_4
|
|
|
|
.Fa "bus_space_tag_t space"
|
|
|
|
.Fa "bus_space_handle_t handle" "bus_size_t offset" "u_int32_t *datap"
|
|
|
|
.Fa "bus_size_t count"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_write_multi_8
|
|
|
|
.Fa "bus_space_tag_t space"
|
|
|
|
.Fa "bus_space_handle_t handle" "bus_size_t offset" "u_int64_t *datap"
|
|
|
|
.Fa "bus_size_t count"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2006-04-22 03:58:41 +00:00
|
|
|
.Fo bus_space_write_multi_stream_1
|
|
|
|
.Fa "bus_space_tag_t space"
|
|
|
|
.Fa "bus_space_handle_t handle" "bus_size_t offset" "u_int8_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" "u_int16_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" "u_int32_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" "u_int64_t *datap"
|
|
|
|
.Fa "bus_size_t count"
|
|
|
|
.Fc
|
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_set_multi_1
|
|
|
|
.Fa "bus_space_tag_t space"
|
|
|
|
.Fa "bus_space_handle_t handle" "bus_size_t offset" "u_int8_t value"
|
|
|
|
.Fa "bus_size_t count"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_set_multi_2
|
|
|
|
.Fa "bus_space_tag_t space"
|
|
|
|
.Fa "bus_space_handle_t handle" "bus_size_t offset" "u_int16_t value"
|
|
|
|
.Fa "bus_size_t count"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_set_multi_4
|
|
|
|
.Fa "bus_space_tag_t space"
|
|
|
|
.Fa "bus_space_handle_t handle" "bus_size_t offset" "u_int32_t value"
|
|
|
|
.Fa "bus_size_t count"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Ft void
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fo bus_space_set_multi_8
|
|
|
|
.Fa "bus_space_tag_t space"
|
|
|
|
.Fa "bus_space_handle_t handle" "bus_size_t offset" "u_int64_t value"
|
|
|
|
.Fa "bus_size_t count"
|
|
|
|
.Fc
|
2006-04-22 03:58:41 +00:00
|
|
|
.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" "u_int8_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" "u_int16_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" "u_int32_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" "u_int64_t value"
|
|
|
|
.Fa "bus_size_t count"
|
|
|
|
.Fc
|
2005-06-14 03:40:01 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
functions exist to allow device drivers
|
2005-06-25 08:59:05 +00:00
|
|
|
machine-independent access to bus memory and register areas.
|
|
|
|
All of the
|
2005-06-14 03:40:01 +00:00
|
|
|
functions and types described in this document can be used by including
|
2005-06-25 08:59:05 +00:00
|
|
|
the
|
|
|
|
.In machine/bus.h
|
2005-06-14 03:40:01 +00:00
|
|
|
header file.
|
|
|
|
.Pp
|
|
|
|
Many common devices are used on multiple architectures, but are accessed
|
|
|
|
differently on each because of architectural constraints.
|
2005-06-25 08:59:05 +00:00
|
|
|
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.\&
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
single system or architecture.
|
|
|
|
The goal of the
|
2005-06-14 03:40:01 +00:00
|
|
|
.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 busses have to implement all functions described in this
|
|
|
|
document, though that is encouraged if the operations are logically
|
2005-06-25 08:59:05 +00:00
|
|
|
supported by the bus.
|
|
|
|
Unimplemented functions should cause
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
functions.
|
|
|
|
Implementations are encouraged to implement prototyped
|
2005-06-14 03:40:01 +00:00
|
|
|
(type-checked) versions of these interfaces, but may implement them as
|
2005-06-25 08:59:05 +00:00
|
|
|
macros if appropriate.
|
|
|
|
Machine-dependent types, variables, and functions
|
2005-06-14 03:40:01 +00:00
|
|
|
should be marked clearly in
|
2005-06-25 08:59:05 +00:00
|
|
|
.In machine/bus.h
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
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
|
2005-06-14 03:40:01 +00:00
|
|
|
multiple different bus space tags.
|
|
|
|
Individual busses or devices on a machine may use more than one bus space
|
2005-06-25 08:59:05 +00:00
|
|
|
tag.
|
|
|
|
For instance, ISA devices are
|
|
|
|
given an ISA memory space tag and an ISA I/O space tag.
|
|
|
|
Architectures
|
2005-06-14 03:40:01 +00:00
|
|
|
may have several different tags which represent the same type of
|
|
|
|
space, for instance because of multiple different host bus interface
|
|
|
|
chipsets.
|
|
|
|
.Pp
|
2005-06-25 08:59:05 +00:00
|
|
|
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.
|
|
|
|
Busses which are not byte
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
actual location(s) to be accessed.
|
|
|
|
Offsets are given in bytes, though busses
|
|
|
|
may impose alignment constraints.
|
|
|
|
The offset used to access data
|
2005-06-14 03:40:01 +00:00
|
|
|
relative to a given handle must be such that all of the data being
|
2005-06-25 08:59:05 +00:00
|
|
|
accessed is in the mapped region that the handle describes.
|
|
|
|
Trying to
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
in the bus space read and write stream.
|
|
|
|
There
|
|
|
|
are three types of barriers: read, write, and read/write.
|
|
|
|
All reads
|
2005-06-14 03:40:01 +00:00
|
|
|
started to the region before a read barrier must complete before any reads
|
2005-06-25 08:59:05 +00:00
|
|
|
after the read barrier are started.
|
|
|
|
(The analogous requirement is true for
|
|
|
|
write barriers.)
|
|
|
|
Read/write barriers force all reads and writes started
|
2005-06-14 03:40:01 +00:00
|
|
|
before the barrier to complete before any reads or writes after the
|
2005-06-25 08:59:05 +00:00
|
|
|
barrier are started.
|
|
|
|
Correctly-written drivers will include all
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
try to make minimal assumptions about what the system allows.
|
|
|
|
In particular,
|
2005-06-14 03:40:01 +00:00
|
|
|
they should expect that the system requires bus space addresses being
|
2005-06-25 08:59:05 +00:00
|
|
|
accessed to be naturally aligned (i.e., base address of handle added to
|
2005-06-14 03:40:01 +00:00
|
|
|
offset is a multiple of the access size), and that the system does
|
2005-06-25 08:59:05 +00:00
|
|
|
alignment checking on pointers (i.e., pointer to objects being read and
|
2005-06-14 03:40:01 +00:00
|
|
|
written must point to properly-aligned data).
|
|
|
|
.Pp
|
|
|
|
The descriptions of the
|
|
|
|
.Nm
|
|
|
|
functions given below all assume that
|
2005-06-25 08:59:05 +00:00
|
|
|
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
|
2005-06-14 03:40:01 +00:00
|
|
|
the region mapped when a given handle was created), undefined behaviour
|
2005-06-25 08:59:05 +00:00
|
|
|
results.
|
|
|
|
In that case, they may cause the
|
2005-06-14 03:40:01 +00:00
|
|
|
system to halt, either intentionally (via panic) or unintentionally (by
|
|
|
|
causing a fatal trap of by some other means) or may cause improper
|
2005-06-25 08:59:05 +00:00
|
|
|
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
|
2005-06-14 03:40:01 +00:00
|
|
|
if given invalid arguments, and in that case their behaviour is undefined.
|
2010-12-03 18:30:55 +00:00
|
|
|
Functions which take a count of bytes have undefined results if the specified
|
|
|
|
.Fa count
|
|
|
|
is zero.
|
2005-06-14 03:40:01 +00:00
|
|
|
.Sh TYPES
|
|
|
|
Several types are defined in
|
2005-06-25 08:59:05 +00:00
|
|
|
.In machine/bus.h
|
2005-06-14 03:40:01 +00:00
|
|
|
to facilitate use of the
|
|
|
|
.Nm
|
|
|
|
functions by drivers.
|
2005-06-25 08:59:05 +00:00
|
|
|
.Ss Vt bus_addr_t
|
2005-06-14 03:40:01 +00:00
|
|
|
The
|
2005-06-25 08:59:05 +00:00
|
|
|
.Vt bus_addr_t
|
|
|
|
type is used to describe bus addresses.
|
|
|
|
It must be an
|
2005-06-14 03:40:01 +00:00
|
|
|
unsigned integral type
|
2005-06-25 08:59:05 +00:00
|
|
|
capable of holding the largest bus address usable by the architecture.
|
|
|
|
This
|
2005-06-14 03:40:01 +00:00
|
|
|
type is primarily used when mapping and unmapping bus space.
|
2005-06-25 08:59:05 +00:00
|
|
|
.Ss Vt bus_size_t
|
2005-06-14 03:40:01 +00:00
|
|
|
The
|
2005-06-25 08:59:05 +00:00
|
|
|
.Vt bus_size_t
|
|
|
|
type is used to describe sizes of ranges in bus space.
|
|
|
|
It must be an
|
2005-06-14 03:40:01 +00:00
|
|
|
unsigned integral type capable of holding the size of the largest bus
|
2005-06-25 08:59:05 +00:00
|
|
|
address range usable on the architecture.
|
|
|
|
This type is used by virtually all
|
2005-06-14 03:40:01 +00:00
|
|
|
of the
|
|
|
|
.Nm
|
|
|
|
functions, describing sizes when mapping regions and
|
|
|
|
offsets into regions when performing space access operations.
|
2005-06-25 08:59:05 +00:00
|
|
|
.Ss Vt bus_space_tag_t
|
2005-06-14 03:40:01 +00:00
|
|
|
The
|
2005-06-25 08:59:05 +00:00
|
|
|
.Vt bus_space_tag_t
|
|
|
|
type is used to describe a particular bus space on a machine.
|
|
|
|
Its
|
2005-06-14 03:40:01 +00:00
|
|
|
contents are machine-dependent and should be considered opaque by
|
2005-06-25 08:59:05 +00:00
|
|
|
machine-independent code.
|
|
|
|
This type is used by all
|
2005-06-14 03:40:01 +00:00
|
|
|
.Nm
|
2005-06-25 08:59:05 +00:00
|
|
|
functions to name the space on which they are operating.
|
|
|
|
.Ss Vt bus_space_handle_t
|
2005-06-14 03:40:01 +00:00
|
|
|
The
|
2005-06-25 08:59:05 +00:00
|
|
|
.Vt bus_space_handle_t
|
|
|
|
type is used to describe a mapping of a range of bus space.
|
|
|
|
Its
|
2005-06-14 03:40:01 +00:00
|
|
|
contents are machine-dependent and should be considered opaque by
|
2005-06-25 08:59:05 +00:00
|
|
|
machine-independent code.
|
|
|
|
This type is used when performing bus space
|
2005-06-14 03:40:01 +00:00
|
|
|
access operations.
|
|
|
|
.Sh MAPPING AND UNMAPPING BUS SPACE
|
|
|
|
This section is specific to the
|
2005-06-25 08:59:05 +00:00
|
|
|
.Nx
|
2005-06-14 03:40:01 +00:00
|
|
|
version of these functions and may or may not apply to the
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fx
|
2005-06-14 03:40:01 +00:00
|
|
|
version.
|
|
|
|
.Pp
|
|
|
|
Bus space must be mapped before it can be used, and should be
|
2005-06-25 08:59:05 +00:00
|
|
|
unmapped when it is no longer needed.
|
|
|
|
The
|
2005-06-14 03:40:01 +00:00
|
|
|
.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
|
2005-06-25 08:59:05 +00:00
|
|
|
space to another driver or module within a driver.
|
|
|
|
The
|
2005-06-14 03:40:01 +00:00
|
|
|
.Fn bus_space_subregion
|
|
|
|
function allows such subregions to be created.
|
2005-06-25 08:59:05 +00:00
|
|
|
.Ss Fn bus_space_map space address size flags handlep
|
2005-06-14 03:40:01 +00:00
|
|
|
The
|
|
|
|
.Fn bus_space_map
|
|
|
|
function maps the region of bus space named by the
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fa space , address ,
|
2005-06-14 03:40:01 +00:00
|
|
|
and
|
|
|
|
.Fa size
|
2005-06-25 08:59:05 +00:00
|
|
|
arguments.
|
|
|
|
If successful, it returns zero
|
|
|
|
and fills in the bus space handle pointed to by
|
2005-06-14 03:40:01 +00:00
|
|
|
.Fa handlep
|
|
|
|
with the handle
|
2005-06-25 08:59:05 +00:00
|
|
|
that can be used to access the mapped region.
|
|
|
|
If unsuccessful,
|
2005-06-14 03:40:01 +00:00
|
|
|
it will return non-zero and leave the bus space handle pointed
|
2005-06-25 08:59:05 +00:00
|
|
|
to by
|
2005-06-14 03:40:01 +00:00
|
|
|
.Fa handlep
|
|
|
|
in an undefined state.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fa flags
|
2005-06-25 08:59:05 +00:00
|
|
|
argument controls how the space is to be mapped.
|
|
|
|
Supported flags include:
|
|
|
|
.Bl -tag -width ".Dv BUS_SPACE_MAP_CACHEABLE"
|
2005-06-14 03:40:01 +00:00
|
|
|
.It Dv BUS_SPACE_MAP_CACHEABLE
|
|
|
|
Try to map the space so that accesses can be cached and/or
|
2005-06-25 08:59:05 +00:00
|
|
|
prefetched by the system.
|
|
|
|
If this flag is not specified, the
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
normal memory access methods (e.g.\& pointer dereferencing and structure
|
2005-06-14 03:40:01 +00:00
|
|
|
accesses).
|
|
|
|
This is useful when software wants to do direct access to a memory
|
2005-06-25 08:59:05 +00:00
|
|
|
device, e.g.\& a frame buffer.
|
|
|
|
If this flag is specified and linear
|
2005-06-14 03:40:01 +00:00
|
|
|
mapping is not possible, the
|
|
|
|
.Fn bus_space_map
|
2005-06-25 08:59:05 +00:00
|
|
|
call should fail.
|
|
|
|
If this
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
spaces.
|
|
|
|
For instance,
|
2005-06-14 03:40:01 +00:00
|
|
|
.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
|
2005-06-25 08:59:05 +00:00
|
|
|
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
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
bus spaces and refuse to allow duplicate allocations.
|
|
|
|
This is encouraged
|
2005-06-14 03:40:01 +00:00
|
|
|
for bus spaces which have no notion of slot-specific space addressing,
|
|
|
|
such as ISA and VME, and for spaces which coexist with those spaces
|
2005-06-25 08:59:05 +00:00
|
|
|
(e.g.\& EISA and PCI memory and I/O spaces co-existing with ISA memory and
|
2005-06-14 03:40:01 +00:00
|
|
|
I/O spaces).
|
|
|
|
.Pp
|
2008-03-07 17:02:34 +00:00
|
|
|
Mapped regions may contain areas for which there is no device on the
|
2005-06-25 08:59:05 +00:00
|
|
|
bus.
|
|
|
|
If space in those areas is accessed, the results are
|
2005-06-14 03:40:01 +00:00
|
|
|
bus-dependent.
|
2005-06-25 08:59:05 +00:00
|
|
|
.Ss Fn bus_space_unmap space handle size
|
2005-06-14 03:40:01 +00:00
|
|
|
The
|
|
|
|
.Fn bus_space_unmap
|
|
|
|
function unmaps a region of bus space mapped with
|
|
|
|
.Fn bus_space_map .
|
2005-06-25 08:59:05 +00:00
|
|
|
When unmapping a region, the
|
2005-06-14 03:40:01 +00:00
|
|
|
.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
|
2005-06-25 08:59:05 +00:00
|
|
|
valid.
|
|
|
|
(If copies were made of the handle they are no longer valid,
|
2005-06-14 03:40:01 +00:00
|
|
|
either.)
|
|
|
|
.Pp
|
2005-06-25 08:59:05 +00:00
|
|
|
This function will never fail.
|
|
|
|
If it would fail (e.g.\& because of an
|
2005-06-14 03:40:01 +00:00
|
|
|
argument error), that indicates a software bug which should cause a
|
2005-06-25 08:59:05 +00:00
|
|
|
panic.
|
|
|
|
In that case,
|
2005-06-14 03:40:01 +00:00
|
|
|
.Fn bus_space_unmap
|
|
|
|
will never return.
|
2005-06-25 08:59:05 +00:00
|
|
|
.Ss Fn bus_space_subregion space handle offset size nhandlep
|
2005-06-14 03:40:01 +00:00
|
|
|
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.
|
2005-06-25 08:59:05 +00:00
|
|
|
The subregion described by the new handle starts at byte offset
|
2005-06-14 03:40:01 +00:00
|
|
|
.Fa offset
|
2005-06-25 08:59:05 +00:00
|
|
|
into the region described by
|
2005-06-14 03:40:01 +00:00
|
|
|
.Fa handle ,
|
2005-06-25 08:59:05 +00:00
|
|
|
with the size give by
|
2005-06-14 03:40:01 +00:00
|
|
|
.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
|
2005-06-25 08:59:05 +00:00
|
|
|
undefined state.
|
|
|
|
In either case, the handle described by
|
2005-06-14 03:40:01 +00:00
|
|
|
.Fa handle
|
|
|
|
remains valid and is unmodified.
|
|
|
|
.Pp
|
2005-06-25 08:59:05 +00:00
|
|
|
When done with a handle created by
|
2005-06-14 03:40:01 +00:00
|
|
|
.Fn bus_space_subregion ,
|
|
|
|
the handle should
|
2005-06-25 08:59:05 +00:00
|
|
|
be thrown away.
|
|
|
|
Under no circumstances should
|
2005-06-14 03:40:01 +00:00
|
|
|
.Fn bus_space_unmap
|
2005-06-25 08:59:05 +00:00
|
|
|
be used on the handle.
|
|
|
|
Doing so may confuse any resource management
|
|
|
|
being done on the space, and will result in undefined behaviour.
|
|
|
|
When
|
2005-06-14 03:40:01 +00:00
|
|
|
.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
|
2005-06-25 08:59:05 +00:00
|
|
|
.Nx
|
2005-06-14 03:40:01 +00:00
|
|
|
version of these functions and may or may not apply to the
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fx
|
2005-06-14 03:40:01 +00:00
|
|
|
version.
|
|
|
|
.Pp
|
|
|
|
Some devices require or allow bus space to be allocated by the operating
|
2005-06-25 08:59:05 +00:00
|
|
|
system for device use.
|
|
|
|
When the devices no longer need the space, the
|
|
|
|
operating system should free it for use by other devices.
|
|
|
|
The
|
2005-06-14 03:40:01 +00:00
|
|
|
.Fn bus_space_alloc
|
|
|
|
and
|
|
|
|
.Fn bus_space_free
|
|
|
|
functions provide these capabilities.
|
2005-06-25 08:59:05 +00:00
|
|
|
.Ss Fn bus_space_alloc space reg_start reg_end size alignment boundary \
|
|
|
|
flags addrp handlep
|
2005-06-14 03:40:01 +00:00
|
|
|
The
|
|
|
|
.Fn bus_space_alloc
|
|
|
|
function allocates and maps a region of bus space with the size given by
|
|
|
|
.Fa size ,
|
2005-06-25 08:59:05 +00:00
|
|
|
corresponding to the given constraints.
|
|
|
|
If successful, it returns
|
2005-06-14 03:40:01 +00:00
|
|
|
zero, fills in the bus address pointed to by
|
|
|
|
.Fa addrp
|
|
|
|
with the bus space address of the allocated region, and fills in
|
2005-06-25 08:59:05 +00:00
|
|
|
the bus space handle pointed to by
|
2005-06-14 03:40:01 +00:00
|
|
|
.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
|
2005-06-25 08:59:05 +00:00
|
|
|
and the bus space handle pointed to by
|
2005-06-14 03:40:01 +00:00
|
|
|
.Fa handlep
|
|
|
|
in an undefined state.
|
|
|
|
.Pp
|
2005-06-25 08:59:05 +00:00
|
|
|
Constraints on the allocation are given by the
|
|
|
|
.Fa reg_start , reg_end , alignment ,
|
2005-06-14 03:40:01 +00:00
|
|
|
and
|
|
|
|
.Fa boundary
|
2005-06-25 08:59:05 +00:00
|
|
|
parameters.
|
|
|
|
The allocated region will start at or after
|
2005-06-14 03:40:01 +00:00
|
|
|
.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
|
2005-06-25 08:59:05 +00:00
|
|
|
an address that is an even multiple of that power of two.
|
|
|
|
The
|
2005-06-14 03:40:01 +00:00
|
|
|
.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
|
2005-06-25 08:59:05 +00:00
|
|
|
will fail.
|
|
|
|
It is an error to specify a set of
|
2005-06-14 03:40:01 +00:00
|
|
|
constraints that can never be met
|
2005-06-25 08:59:05 +00:00
|
|
|
(for example,
|
2005-06-14 03:40:01 +00:00
|
|
|
.Fa size
|
|
|
|
greater than
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fa boundary ) .
|
2005-06-14 03:40:01 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fa flags
|
|
|
|
parameter is the same as the like-named parameter to
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fn bus_space_map ,
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
on them causes undefined behaviour.
|
|
|
|
The
|
2005-06-14 03:40:01 +00:00
|
|
|
.Fn bus_space_subregion
|
|
|
|
function can be used on
|
|
|
|
handles created by
|
|
|
|
.Fn bus_space_alloc .
|
2005-06-25 08:59:05 +00:00
|
|
|
.Ss Fn bus_space_free space handle size
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
is called on a handle, that handle is no longer valid.
|
|
|
|
(If copies were
|
2005-06-14 03:40:01 +00:00
|
|
|
made of the handle, they are no longer valid, either.)
|
|
|
|
.Pp
|
2005-06-25 08:59:05 +00:00
|
|
|
This function will never fail.
|
|
|
|
If it would fail (e.g.\& because of an
|
2005-06-14 03:40:01 +00:00
|
|
|
argument error), that indicates a software bug which should cause a
|
2005-06-25 08:59:05 +00:00
|
|
|
panic.
|
|
|
|
In that case,
|
2005-06-14 03:40:01 +00:00
|
|
|
.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
|
2005-06-25 08:59:05 +00:00
|
|
|
item.
|
|
|
|
The
|
2005-06-14 03:40:01 +00:00
|
|
|
.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 busses
|
|
|
|
which support those access sizes.
|
2005-06-25 08:59:05 +00:00
|
|
|
.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
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
into the region specified by
|
2005-06-14 03:40:01 +00:00
|
|
|
.Fa handle
|
2005-06-25 08:59:05 +00:00
|
|
|
of the bus space specified by
|
2005-06-14 03:40:01 +00:00
|
|
|
.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
|
2005-06-25 08:59:05 +00:00
|
|
|
Read operations done by the
|
2005-06-14 03:40:01 +00:00
|
|
|
.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
|
2005-06-25 08:59:05 +00:00
|
|
|
These functions will never fail.
|
|
|
|
If they would fail (e.g.\& because of an
|
2005-06-14 03:40:01 +00:00
|
|
|
argument error), that indicates a software bug which should cause a
|
2005-06-25 08:59:05 +00:00
|
|
|
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
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
of the bus space specified by
|
2005-06-14 03:40:01 +00:00
|
|
|
.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
|
2005-06-25 08:59:05 +00:00
|
|
|
written.
|
|
|
|
On some systems, not obeying this requirement may cause
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
These functions will never fail.
|
|
|
|
If they would fail (e.g.\& because of an
|
2005-06-14 03:40:01 +00:00
|
|
|
argument error), that indicates a software bug which should cause a
|
2005-06-25 08:59:05 +00:00
|
|
|
panic.
|
|
|
|
In that case, they will never return.
|
2005-06-14 03:40:01 +00:00
|
|
|
.Sh BARRIERS
|
|
|
|
In order to allow high-performance buffering implementations to avoid bus
|
|
|
|
activity on every operation, read and write ordering should be specified
|
2005-06-25 08:59:05 +00:00
|
|
|
explicitly by drivers when necessary.
|
|
|
|
The
|
2005-06-14 03:40:01 +00:00
|
|
|
.Fn bus_space_barrier
|
|
|
|
function provides that ability.
|
2005-06-25 08:59:05 +00:00
|
|
|
.Ss Fn bus_space_barrier space handle offset length flags
|
2005-06-14 03:40:01 +00:00
|
|
|
The
|
|
|
|
.Fn bus_space_barrier
|
|
|
|
function enforces ordering of bus space read and write operations
|
|
|
|
for the specified subregion (described by the
|
|
|
|
.Fa offset
|
2005-06-25 08:59:05 +00:00
|
|
|
and
|
2005-06-14 03:40:01 +00:00
|
|
|
.Fa length
|
|
|
|
parameters) of the region named by
|
|
|
|
.Fa handle
|
|
|
|
in the space named by
|
|
|
|
.Fa space .
|
|
|
|
.Pp
|
2005-06-25 08:59:05 +00:00
|
|
|
The
|
2005-06-14 03:40:01 +00:00
|
|
|
.Fa flags
|
|
|
|
argument controls what types of operations are to be ordered.
|
|
|
|
Supported flags are:
|
2005-06-25 08:59:05 +00:00
|
|
|
.Bl -tag -width ".Dv BUS_SPACE_BARRIER_WRITE"
|
2005-06-14 03:40:01 +00:00
|
|
|
.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
|
2005-06-25 08:59:05 +00:00
|
|
|
offset 1).
|
|
|
|
Operation of the device is as follows: data bytes are written
|
2005-06-14 03:40:01 +00:00
|
|
|
to the input port, and are placed by the device on a stack, the top of
|
2005-06-25 08:59:05 +00:00
|
|
|
which is read by reading from the output port.
|
|
|
|
The sequence to correctly
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
in order and are not collapsed into a single write.
|
|
|
|
This ensures that
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
that all of the writes are finished before data is read.
|
|
|
|
This ensures
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
minimum number of bus space locations.
|
|
|
|
It is correct (and often
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
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
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
value.
|
|
|
|
The
|
2005-06-14 03:40:01 +00:00
|
|
|
.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.
|
2005-06-25 08:59:05 +00:00
|
|
|
.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
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
function is used).
|
|
|
|
All locations being read must lie within the bus
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
read and the data array pointer should be properly aligned.
|
|
|
|
On some
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
functions may be executed in any order.
|
|
|
|
They may also be executed out
|
2005-06-14 03:40:01 +00:00
|
|
|
of order with respect to other pending read and write operations unless
|
|
|
|
order is enforced by use of the
|
|
|
|
.Fn bus_space_barrier
|
2005-06-25 08:59:05 +00:00
|
|
|
function.
|
|
|
|
There is no way to insert barriers between reads of
|
2005-06-14 03:40:01 +00:00
|
|
|
individual bus space locations executed by the
|
|
|
|
.Fn bus_space_read_region_N
|
|
|
|
functions.
|
|
|
|
.Pp
|
2005-06-25 08:59:05 +00:00
|
|
|
These functions will never fail.
|
|
|
|
If they would fail (e.g.\& because of an
|
2005-06-14 03:40:01 +00:00
|
|
|
argument error), that indicates a software bug which should cause a
|
2005-06-25 08:59:05 +00:00
|
|
|
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
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fa space .
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
used).
|
|
|
|
All locations being written must lie within the bus space region
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
written and the data array pointer should be properly aligned.
|
|
|
|
On some
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
executed in any order.
|
|
|
|
They may also be executed out of order with
|
2005-06-14 03:40:01 +00:00
|
|
|
respect to other pending read and write operations unless order is
|
|
|
|
enforced by use of the
|
|
|
|
.Fn bus_space_barrier
|
2005-06-25 08:59:05 +00:00
|
|
|
function.
|
|
|
|
There is no way to insert barriers between writes of
|
2005-06-14 03:40:01 +00:00
|
|
|
individual bus space locations executed by the
|
|
|
|
.Fn bus_space_write_region_N
|
|
|
|
functions.
|
|
|
|
.Pp
|
2005-06-25 08:59:05 +00:00
|
|
|
These functions will never fail.
|
|
|
|
If they would fail (e.g.\& because of an
|
2005-06-14 03:40:01 +00:00
|
|
|
argument error), that indicates a software bug which should cause a
|
2005-06-25 08:59:05 +00:00
|
|
|
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
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
in the same bus space.
|
|
|
|
Each successive data item read or written has
|
2005-06-14 03:40:01 +00:00
|
|
|
an offset 1, 2, 4, or 8 bytes after the previous data item (depending
|
2005-06-25 08:59:05 +00:00
|
|
|
on which function is used).
|
|
|
|
All locations being read and written must
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
of data items being copied.
|
|
|
|
On some systems, not obeying this
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
functions may be executed in any order.
|
|
|
|
They may also be executed out
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
These functions will never fail.
|
|
|
|
If they would fail (e.g.\& because of an
|
2005-06-14 03:40:01 +00:00
|
|
|
argument error), that indicates a software bug which should cause a
|
2005-06-25 08:59:05 +00:00
|
|
|
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
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
of the bus space specified by
|
|
|
|
.Fa space .
|
2005-06-14 03:40:01 +00:00
|
|
|
Each successive data item has an offset 1, 2, 4, or 8 bytes after the
|
2005-06-25 08:59:05 +00:00
|
|
|
previous data item (depending on which function is used).
|
|
|
|
All
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
written.
|
|
|
|
On some systems, not obeying this requirement may cause
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
executed in any order.
|
|
|
|
They may also be executed out of order with
|
2005-06-14 03:40:01 +00:00
|
|
|
respect to other pending read and write operations unless order is
|
|
|
|
enforced by use of the
|
|
|
|
.Fn bus_space_barrier
|
2005-06-25 08:59:05 +00:00
|
|
|
function.
|
|
|
|
There is no way to insert barriers between writes of
|
2005-06-14 03:40:01 +00:00
|
|
|
individual bus space locations executed by the
|
|
|
|
.Fn bus_space_set_region_N
|
|
|
|
functions.
|
|
|
|
.Pp
|
2005-06-25 08:59:05 +00:00
|
|
|
These functions will never fail.
|
|
|
|
If they would fail (e.g.\& because of an
|
2005-06-14 03:40:01 +00:00
|
|
|
argument error), that indicates a software bug which should cause a
|
2005-06-25 08:59:05 +00:00
|
|
|
panic.
|
|
|
|
In that case, they will never return.
|
2005-06-14 03:40:01 +00:00
|
|
|
.Sh READING AND WRITING A SINGLE LOCATION MULTIPLE TIMES
|
|
|
|
Some devices implement single locations in bus space which are to be read
|
2005-06-25 08:59:05 +00:00
|
|
|
or written multiple times to communicate data, e.g.\& some ethernet
|
|
|
|
devices' packet buffer FIFOs.
|
|
|
|
In order to allow drivers to manipulate
|
2005-06-14 03:40:01 +00:00
|
|
|
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.
|
2005-06-25 08:59:05 +00:00
|
|
|
.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
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
space.
|
|
|
|
The location being read must lie within the bus space region
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
read and the data array pointer should be properly aligned.
|
|
|
|
On some
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
function.
|
|
|
|
Because the
|
2005-06-14 03:40:01 +00:00
|
|
|
.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
|
2005-06-25 08:59:05 +00:00
|
|
|
These functions will never fail.
|
|
|
|
If they would fail (e.g.\& because of an
|
2005-06-14 03:40:01 +00:00
|
|
|
argument error), that indicates a software bug which should cause a
|
2005-06-25 08:59:05 +00:00
|
|
|
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
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
bus space.
|
|
|
|
The location being written must lie within the bus space
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
written and the data array pointer should be properly aligned.
|
|
|
|
On some
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
function.
|
|
|
|
Because the
|
2005-06-14 03:40:01 +00:00
|
|
|
.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
|
2005-06-25 08:59:05 +00:00
|
|
|
These functions will never fail.
|
|
|
|
If they would fail (e.g.\& because of an
|
2005-06-14 03:40:01 +00:00
|
|
|
argument error), that indicates a software bug which should cause a
|
2005-06-25 08:59:05 +00:00
|
|
|
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
|
2005-06-14 03:40:01 +00:00
|
|
|
The
|
|
|
|
.Fn bus_space_set_multi_N
|
|
|
|
writes
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fa value
|
2005-06-14 03:40:01 +00:00
|
|
|
into bus space at byte offset
|
|
|
|
.Fa offset
|
|
|
|
in the region specified by
|
|
|
|
.Fa handle
|
|
|
|
of the bus space specified by
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fa space ,
|
|
|
|
.Fa count
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
written and the data array pointer should be properly aligned.
|
|
|
|
On some
|
2005-06-14 03:40:01 +00:00
|
|
|
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
|
2005-06-25 08:59:05 +00:00
|
|
|
function.
|
|
|
|
Because the
|
2005-06-14 03:40:01 +00:00
|
|
|
.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
|
2005-06-25 08:59:05 +00:00
|
|
|
These functions will never fail.
|
|
|
|
If they would fail (e.g.\& because of an
|
2005-06-14 03:40:01 +00:00
|
|
|
argument error), that indicates a software bug which should cause a
|
2005-06-25 08:59:05 +00:00
|
|
|
panic.
|
|
|
|
In that case, they will never return.
|
2006-04-22 03:58:41 +00:00
|
|
|
.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
|
2006-09-18 14:31:03 +00:00
|
|
|
.Bl -tag -compact
|
|
|
|
.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
|
2006-04-22 03:58:41 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
These functions are defined just as their non-stream counterparts,
|
|
|
|
except that they provide no byte-order translation.
|
2005-06-14 03:40:01 +00:00
|
|
|
.Sh COMPATIBILITY
|
2005-06-25 08:59:05 +00:00
|
|
|
The current
|
|
|
|
.Nx
|
2005-06-14 03:40:01 +00:00
|
|
|
version of the
|
|
|
|
.Nm
|
|
|
|
interface specification differs slightly from the original
|
2005-06-25 08:59:05 +00:00
|
|
|
specification that came into wide use and
|
|
|
|
.Fx
|
2005-06-14 03:40:01 +00:00
|
|
|
adopted.
|
|
|
|
A few of the function names and arguments have changed
|
|
|
|
for consistency and increased functionality.
|
2005-06-25 08:59:05 +00:00
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr bus_dma 9
|
2005-06-14 03:40:01 +00:00
|
|
|
.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
|
2005-06-25 08:59:05 +00:00
|
|
|
development cycle, and the specification was updated to fix some
|
2005-06-14 03:40:01 +00:00
|
|
|
consistency problems and to add some missing functionality.
|
|
|
|
.Pp
|
2008-03-07 17:02:34 +00:00
|
|
|
The manual page was then adapted to the version of the interface that
|
2005-06-25 08:59:05 +00:00
|
|
|
.Fx
|
2005-06-14 03:40:01 +00:00
|
|
|
imported for the CAM SCSI drivers, plus subsequent evolution.
|
2005-06-25 08:59:05 +00:00
|
|
|
The
|
|
|
|
.Fx
|
2005-06-14 03:40:01 +00:00
|
|
|
.Nm
|
|
|
|
version was imported in
|
|
|
|
.Fx 3.0 .
|
|
|
|
.Sh AUTHORS
|
2005-06-25 08:59:05 +00:00
|
|
|
.An -nosplit
|
2005-06-14 03:40:01 +00:00
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
interfaces were designed and implemented by the
|
|
|
|
.Nx
|
|
|
|
developer
|
2005-06-25 08:59:05 +00:00
|
|
|
community.
|
|
|
|
Primary contributors and implementors were
|
|
|
|
.An Chris Demetriou ,
|
|
|
|
.An Jason Thorpe ,
|
|
|
|
and
|
|
|
|
.An Charles Hannum ,
|
|
|
|
but the rest of the
|
2005-06-14 03:40:01 +00:00
|
|
|
.Nx
|
|
|
|
developers and the user community played a significant role in development.
|
|
|
|
.Pp
|
2005-06-25 08:59:05 +00:00
|
|
|
.An Justin Gibbs
|
|
|
|
ported these interfaces to
|
2005-06-14 03:40:01 +00:00
|
|
|
.Fx .
|
|
|
|
.Pp
|
2005-06-25 08:59:05 +00:00
|
|
|
.An Chris Demetriou
|
|
|
|
wrote this manual page.
|
2005-06-14 03:40:01 +00:00
|
|
|
.Pp
|
2005-06-25 08:59:05 +00:00
|
|
|
.An Warner Losh
|
|
|
|
modified it for the
|
|
|
|
.Fx
|
2005-06-14 03:40:01 +00:00
|
|
|
implementation.
|
|
|
|
.Sh BUGS
|
2005-06-25 08:59:05 +00:00
|
|
|
This manual may not completely and accurately document the interface,
|
2005-06-14 03:40:01 +00:00
|
|
|
and many parts of the interface are unspecified.
|