Define the bus_space_mmap() method for mmap'ing bus space into

user programs.
This commit is contained in:
thorpej 2001-09-04 02:10:52 +00:00
parent 1b4cef2087
commit c6fda2584d
1 changed files with 43 additions and 1 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: bus_space.9,v 1.19 2001/06/21 11:59:00 wiz Exp $ .\" $NetBSD: bus_space.9,v 1.20 2001/09/04 02:10:52 thorpej Exp $
.\" .\"
.\" Copyright (c) 1997 The NetBSD Foundation, Inc. .\" Copyright (c) 1997 The NetBSD Foundation, Inc.
.\" All rights reserved. .\" All rights reserved.
@ -85,6 +85,7 @@
.Nm bus_space_subregion , .Nm bus_space_subregion ,
.Nm bus_space_unmap , .Nm bus_space_unmap ,
.Nm bus_space_vaddr , .Nm bus_space_vaddr ,
.Nm bus_space_mmap ,
.Nm bus_space_write_1 , .Nm bus_space_write_1 ,
.Nm bus_space_write_2 , .Nm bus_space_write_2 ,
.Nm bus_space_write_4 , .Nm bus_space_write_4 ,
@ -132,6 +133,9 @@
"bus_size_t size" "bus_size_t size"
.Ft void * .Ft void *
.Fn bus_space_vaddr "bus_space_tag_t space" "bus_space_handle_t handle" .Fn bus_space_vaddr "bus_space_tag_t space" "bus_space_handle_t handle"
.Ft paddr_t
.Fn bus_space_mmap "bus_space_tag_t space" "bus_addr_t addr" "off_t off" \
"int prot" "int flags"
.Ft int .Ft int
.Fn bus_space_peek_1 "bus_space_tag_t space" "bus_space_handle_t handle" \ .Fn bus_space_peek_1 "bus_space_tag_t space" "bus_space_handle_t handle" \
"bus_size_t offset" "u_int8_t *datap" "bus_size_t offset" "u_int8_t *datap"
@ -687,6 +691,44 @@ If mapped with the
flag, the flag, the
.Fn bus_space_barrier .Fn bus_space_barrier
method must be used to force a particular access order. method must be used to force a particular access order.
.Pp
.It Fn bus_space_mmap "tag" "addr" "off" "prot" "flags"
.Pp
This method is used to provide support for memory mapping bus space
into user applications. If an address space is addressable via
volatile pointer dereferences,
.Fn bus_space_mmap
will return the physical address (possibly encoded as a machine-dependent
cookie) of the bus space indicated by
.Fa addr
and
.Fa off .
.Fa addr
is the base address of the device or device region, and
.Fa off
is the offset into that region that is being requested.
If the request is made with
.Dv BUS_SPACE_MAP_LINEAR
as a flag, then a linear region must be returned to the caller.
If the region cannot be mapped (either the address does not exist,
or the constraints can not be met),
.Fn bus_space_mmap
returns
.Dv -1
to indicate failure.
.Pp
Note that it is not necessary that the region being requested by a
.Fn bus_space_mmap
call be mapped into a
.Fa bus_space_handle_t .
.Pp
.Fn bus_space_mmap
is called once per
.Dv PAGE_SIZE
page in the range. The
.Fa prot
argument indicates the memory protection requested by the user application
for the range.
.El .El
.Pp .Pp
.Sh ALLOCATING AND FREEING BUS SPACE .Sh ALLOCATING AND FREEING BUS SPACE