Implement bus_space_mmap().

This commit is contained in:
thorpej 2001-09-04 06:57:26 +00:00
parent c91e08563f
commit a08af3853a
2 changed files with 36 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus_space.c,v 1.3 2000/11/09 06:05:40 thorpej Exp $ */ /* $NetBSD: bus_space.c,v 1.4 2001/09/04 06:57:26 thorpej Exp $ */
/* NetBSD: bus_machdep.c,v 1.1 2000/01/26 18:48:00 drochner Exp */ /* NetBSD: bus_machdep.c,v 1.1 2000/01/26 18:48:00 drochner Exp */
/*- /*-
@ -68,6 +68,7 @@ arc_bus_space_init(bst, name, paddr, vaddr, start, size)
bst->bs_map = arc_bus_space_map; bst->bs_map = arc_bus_space_map;
bst->bs_unmap = arc_bus_space_unmap; bst->bs_unmap = arc_bus_space_unmap;
bst->bs_subregion = arc_bus_space_subregion; bst->bs_subregion = arc_bus_space_subregion;
bst->bs_mmap = arc_bus_space_mmap;
bst->bs_alloc = arc_bus_space_alloc; bst->bs_alloc = arc_bus_space_alloc;
bst->bs_free = arc_bus_space_free; bst->bs_free = arc_bus_space_free;
bst->bs_aux = NULL; bst->bs_aux = NULL;
@ -252,6 +253,27 @@ arc_bus_space_subregion(bst, bsh, offset, size, nbshp)
return (0); return (0);
} }
paddr_t
arc_bus_space_mmap(bst, addr, off, prot, flags)
bus_space_tag_t bst;
bus_addr_t addr;
off_t off;
int prot;
int flags;
{
/*
* XXX We do not disallow mmap'ing of EISA/PCI I/O space here,
* XXX which we should be doing.
*/
if (addr < bst->bs_start ||
(addr + off) >= (bst->bs_start + bst->bs_size))
return (-1);
return (mips_btop(bst->bs_pbase + (addr - bst->bs_start) + off));
}
int int
arc_bus_space_alloc(bst, start, end, size, align, boundary, flags, addrp, bshp) arc_bus_space_alloc(bst, start, end, size, align, boundary, flags, addrp, bshp)
bus_space_tag_t bst; bus_space_tag_t bst;

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.11 2001/07/19 15:32:11 thorpej Exp $ */ /* $NetBSD: bus.h,v 1.12 2001/09/04 06:57:27 thorpej Exp $ */
/* NetBSD: bus.h,v 1.27 2000/03/15 16:44:50 drochner Exp */ /* NetBSD: bus.h,v 1.27 2000/03/15 16:44:50 drochner Exp */
/* $OpenBSD: bus.h,v 1.15 1999/08/11 23:15:21 niklas Exp $ */ /* $OpenBSD: bus.h,v 1.15 1999/08/11 23:15:21 niklas Exp $ */
@ -158,6 +158,7 @@ struct arc_bus_space {
bus_size_t)); bus_size_t));
int (*bs_subregion) __P((bus_space_tag_t, bus_space_handle_t, int (*bs_subregion) __P((bus_space_tag_t, bus_space_handle_t,
bus_size_t, bus_size_t, bus_space_handle_t *)); bus_size_t, bus_size_t, bus_space_handle_t *));
paddr_t (*bs_mmap) __P((bus_space_tag_t, bus_addr_t, off_t, int, int));
/* allocation/deallocation */ /* allocation/deallocation */
int (*bs_alloc) __P((bus_space_tag_t, bus_addr_t, bus_addr_t, int (*bs_alloc) __P((bus_space_tag_t, bus_addr_t, bus_addr_t,
@ -208,6 +209,7 @@ void arc_bus_space_unmap __P((bus_space_tag_t, bus_space_handle_t,
bus_size_t)); bus_size_t));
int arc_bus_space_subregion __P((bus_space_tag_t, bus_space_handle_t, int arc_bus_space_subregion __P((bus_space_tag_t, bus_space_handle_t,
bus_size_t, bus_size_t, bus_space_handle_t *)); bus_size_t, bus_size_t, bus_space_handle_t *));
paddr_t arc_bus_space_mmap __P((bus_space_tag_t, bus_addr_t, off_t, int, int));
int arc_bus_space_alloc __P((bus_space_tag_t, bus_addr_t, bus_addr_t, int arc_bus_space_alloc __P((bus_space_tag_t, bus_addr_t, bus_addr_t,
bus_size_t, bus_size_t, bus_size_t, int, bus_addr_t *, bus_size_t, bus_size_t, bus_size_t, int, bus_addr_t *,
bus_space_handle_t *)); bus_space_handle_t *));
@ -242,7 +244,7 @@ int arc_bus_space_alloc __P((bus_space_tag_t, bus_addr_t, bus_addr_t,
* MACHINE DEPENDENT, NOT PORTABLE INTERFACE: * MACHINE DEPENDENT, NOT PORTABLE INTERFACE:
* (cannot be implemented on e.g. I/O space on i386, non-linear space on alpha) * (cannot be implemented on e.g. I/O space on i386, non-linear space on alpha)
* Return physical address of a region. * Return physical address of a region.
* A helper function for device mmap entry. * A helper function for machine-dependent device mmap entry.
*/ */
#define bus_space_paddr(bst, bsh, pap) \ #define bus_space_paddr(bst, bsh, pap) \
(*(bst)->bs_paddr)(bst, bsh, pap) (*(bst)->bs_paddr)(bst, bsh, pap)
@ -257,6 +259,15 @@ int arc_bus_space_alloc __P((bus_space_tag_t, bus_addr_t, bus_addr_t,
#define bus_space_vaddr(bst, bsh) \ #define bus_space_vaddr(bst, bsh) \
((void *)(bsh)) ((void *)(bsh))
/*
* paddr_t bus_space_mmap __P((bus_space_tag_t, bus_addr_t, off_t,
* int, int));
*
* Mmap bus space on behalf of the user.
*/
#define bus_space_mmap(bst, addr, off, prot, flags) \
(*(bst)->bs_mmap)((bst), (addr), (off), (prot), (flags))
/* /*
* int bus_space_map __P((bus_space_tag_t t, bus_addr_t addr, * int bus_space_map __P((bus_space_tag_t t, bus_addr_t addr,
* bus_size_t size, int flags, bus_space_handle_t *bshp)); * bus_size_t size, int flags, bus_space_handle_t *bshp));