Implement bus_space_mmap().
This commit is contained in:
parent
cf412a1220
commit
102190b8fe
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: bus.h,v 1.45 2001/07/19 15:32:11 thorpej Exp $ */
|
||||
/* $NetBSD: bus.h,v 1.46 2001/09/04 05:31:27 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997, 1998, 2000, 2001 The NetBSD Foundation, Inc.
|
||||
@ -147,6 +147,9 @@ struct alpha_bus_space {
|
||||
/* get kernel virtual address */
|
||||
void * (*abs_vaddr)(void *, bus_space_handle_t);
|
||||
|
||||
/* mmap bus space for user */
|
||||
paddr_t (*abs_mmap)(void *, bus_addr_t, off_t, int, int);
|
||||
|
||||
/* barrier */
|
||||
void (*abs_barrier)(void *, bus_space_handle_t,
|
||||
bus_size_t, bus_size_t, int);
|
||||
@ -336,6 +339,12 @@ do { \
|
||||
#define bus_space_vaddr(t, h) \
|
||||
(*(t)->abs_vaddr)((t)->abs_cookie, (h))
|
||||
|
||||
/*
|
||||
* Mmap bus space for a user application.
|
||||
*/
|
||||
#define bus_space_mmap(t, a, o, p, f) \
|
||||
(*(t)->abs_mmap)((t)->abs_cookie, (a), (o), (p), (f))
|
||||
|
||||
/*
|
||||
* Bus barrier operations.
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pci_bwx_bus_io_chipdep.c,v 1.11 2000/06/26 18:19:26 thorpej Exp $ */
|
||||
/* $NetBSD: pci_bwx_bus_io_chipdep.c,v 1.12 2001/09/04 05:31:28 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
|
||||
@ -112,6 +112,9 @@ void __C(CHIP,_io_free) __P((void *, bus_space_handle_t,
|
||||
/* get kernel virtual address */
|
||||
void * __C(CHIP,_io_vaddr) __P((void *, bus_space_handle_t));
|
||||
|
||||
/* mmap for user */
|
||||
paddr_t __C(CHIP,_io_mmap) __P((void *, bus_addr_t, off_t, int, int));
|
||||
|
||||
/* barrier */
|
||||
inline void __C(CHIP,_io_barrier) __P((void *, bus_space_handle_t,
|
||||
bus_size_t, bus_size_t, int));
|
||||
@ -242,6 +245,9 @@ __C(CHIP,_bus_io_init)(t, v)
|
||||
/* get kernel virtual address */
|
||||
t->abs_vaddr = __C(CHIP,_io_vaddr);
|
||||
|
||||
/* mmap for user */
|
||||
t->abs_mmap = __C(CHIP,_io_mmap);
|
||||
|
||||
/* barrier */
|
||||
t->abs_barrier = __C(CHIP,_io_barrier);
|
||||
|
||||
@ -515,6 +521,19 @@ __C(CHIP,_io_vaddr)(v, bsh)
|
||||
panic("_io_vaddr");
|
||||
}
|
||||
|
||||
paddr_t
|
||||
__C(CHIP,_io_vaddr)(v, addr, off, prot, flags)
|
||||
void *v;
|
||||
bus_addr_t addr;
|
||||
off_t off;
|
||||
int prot;
|
||||
int flags;
|
||||
{
|
||||
|
||||
/* Not supported for I/O space. */
|
||||
return (-1);
|
||||
}
|
||||
|
||||
inline void
|
||||
__C(CHIP,_io_barrier)(v, h, o, l, f)
|
||||
void *v;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pci_bwx_bus_mem_chipdep.c,v 1.14 2000/11/29 06:21:12 thorpej Exp $ */
|
||||
/* $NetBSD: pci_bwx_bus_mem_chipdep.c,v 1.15 2001/09/04 05:31:28 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
|
||||
@ -112,6 +112,9 @@ void __C(CHIP,_mem_free) __P((void *, bus_space_handle_t,
|
||||
/* get kernel virtual address */
|
||||
void * __C(CHIP,_mem_vaddr) __P((void *, bus_space_handle_t));
|
||||
|
||||
/* mmap for user */
|
||||
paddr_t __C(CHIP,_mem_mmap) __P((void *, bus_addr_t, off_t, int, int));
|
||||
|
||||
/* barrier */
|
||||
inline void __C(CHIP,_mem_barrier) __P((void *, bus_space_handle_t,
|
||||
bus_size_t, bus_size_t, int));
|
||||
@ -242,6 +245,9 @@ __C(CHIP,_bus_mem_init)(t, v)
|
||||
/* get kernel virtual address */
|
||||
t->abs_vaddr = __C(CHIP,_mem_vaddr);
|
||||
|
||||
/* mmap for user */
|
||||
t->abs_mmap = __C(CHIP,_mem_mmap);
|
||||
|
||||
/* barrier */
|
||||
t->abs_barrier = __C(CHIP,_mem_barrier);
|
||||
|
||||
@ -499,6 +505,18 @@ __C(CHIP,_mem_vaddr)(v, bsh)
|
||||
return ((void *)bsh);
|
||||
}
|
||||
|
||||
void *
|
||||
__C(CHIP,_mem_mmap)(v, addr, off, prot, flags)
|
||||
void *v;
|
||||
bus_addr_t addr;
|
||||
off_t off;
|
||||
int prot;
|
||||
int flags;
|
||||
{
|
||||
|
||||
return (alpha_atop(CHIP_MEM_SYS_START(v) + addr + off));
|
||||
}
|
||||
|
||||
inline void
|
||||
__C(CHIP,_mem_barrier)(v, h, o, l, f)
|
||||
void *v;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pci_swiz_bus_io_chipdep.c,v 1.31 2000/04/17 17:30:48 drochner Exp $ */
|
||||
/* $NetBSD: pci_swiz_bus_io_chipdep.c,v 1.32 2001/09/04 05:31:28 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
|
||||
@ -110,6 +110,9 @@ void __C(CHIP,_io_free) __P((void *, bus_space_handle_t,
|
||||
/* get kernel virtual address */
|
||||
void * __C(CHIP,_io_vaddr) __P((void *, bus_space_handle_t));
|
||||
|
||||
/* mmap for user */
|
||||
paddr_t __C(CHIP,_io_mmap) __P((void *, bus_addr_t, off_t, int, int));
|
||||
|
||||
/* barrier */
|
||||
inline void __C(CHIP,_io_barrier) __P((void *, bus_space_handle_t,
|
||||
bus_size_t, bus_size_t, int));
|
||||
@ -248,6 +251,9 @@ __C(CHIP,_bus_io_init)(t, v)
|
||||
/* get kernel virtual address */
|
||||
t->abs_vaddr = __C(CHIP,_io_vaddr);
|
||||
|
||||
/* mmap for user */
|
||||
t->abs_mmap = __C(CHIP,_io_mmap);
|
||||
|
||||
/* barrier */
|
||||
t->abs_barrier = __C(CHIP,_io_barrier);
|
||||
|
||||
@ -616,6 +622,19 @@ __C(CHIP,_io_vaddr)(v, bsh)
|
||||
panic("_io_vaddr");
|
||||
}
|
||||
|
||||
paddr_t
|
||||
__C(CHIP,_io_mmap)(v, addr, off, prot, flags)
|
||||
void *v;
|
||||
bus_addr_t addr;
|
||||
off_t off;
|
||||
int prot;
|
||||
int flags;
|
||||
{
|
||||
|
||||
/* Not supported for I/O space. */
|
||||
return (-1);
|
||||
}
|
||||
|
||||
inline void
|
||||
__C(CHIP,_io_barrier)(v, h, o, l, f)
|
||||
void *v;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pci_swiz_bus_mem_chipdep.c,v 1.35 2000/04/17 17:30:48 drochner Exp $ */
|
||||
/* $NetBSD: pci_swiz_bus_mem_chipdep.c,v 1.36 2001/09/04 05:31:28 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
@ -119,6 +119,9 @@ void __C(CHIP,_mem_free) __P((void *, bus_space_handle_t,
|
||||
/* get kernel virtual address */
|
||||
void * __C(CHIP,_mem_vaddr) __P((void *, bus_space_handle_t));
|
||||
|
||||
/* mmap for user */
|
||||
paddr_t __C(CHIP,_mem_mmap) __P((void *, bus_addr_t, off_t, int, int));
|
||||
|
||||
/* barrier */
|
||||
inline void __C(CHIP,_mem_barrier) __P((void *, bus_space_handle_t,
|
||||
bus_size_t, bus_size_t, int));
|
||||
@ -269,6 +272,9 @@ __C(CHIP,_bus_mem_init)(t, v)
|
||||
/* get kernel virtual address */
|
||||
t->abs_vaddr = __C(CHIP,_mem_vaddr);
|
||||
|
||||
/* mmap for user */
|
||||
t->abs_mmap = __C(CHIP,_mem_mmap);
|
||||
|
||||
/* barrier */
|
||||
t->abs_barrier = __C(CHIP,_mem_barrier);
|
||||
|
||||
@ -919,6 +925,40 @@ __C(CHIP,_mem_vaddr)(v, bsh)
|
||||
return (0);
|
||||
}
|
||||
|
||||
paddr_t
|
||||
__C(CHIP,_mem_mmap)(v, addr, off, prot, flags)
|
||||
void *v;
|
||||
bus_addr_t addr;
|
||||
off_t off;
|
||||
int prot;
|
||||
int flags;
|
||||
{
|
||||
bus_space_handle_t dh = 0, sh = 0; /* XXX -Wuninitialized */
|
||||
int linear = flags & BUS_SPACE_MAP_LINEAR;
|
||||
int haved = 0, haves = 0;
|
||||
|
||||
#ifdef CHIP_D_MEM_W1_SYS_START
|
||||
if (__C(CHIP,_xlate_addr_to_dense_handle)(v, addr + off, &dh)) {
|
||||
haved = 1;
|
||||
dh = ALPHA_K0SEG_TO_PHYS(dh);
|
||||
}
|
||||
#endif
|
||||
if (__C(CHIP,_xlate_addr_to_sparse_handle)(v, addr + off, &sh)) {
|
||||
haves = 1;
|
||||
sh = ALPHA_K0SEG_TO_PHYS(sh);
|
||||
}
|
||||
|
||||
if (linear) {
|
||||
if (haved == 0)
|
||||
return (-1);
|
||||
return (alpha_btop(dh));
|
||||
}
|
||||
|
||||
if (haves == 0)
|
||||
return (-1);
|
||||
return (alpha_btop(sh));
|
||||
}
|
||||
|
||||
inline void
|
||||
__C(CHIP,_mem_barrier)(v, h, o, l, f)
|
||||
void *v;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: tc_bus_mem.c,v 1.24 2000/06/29 09:02:58 mrg Exp $ */
|
||||
/* $NetBSD: tc_bus_mem.c,v 1.25 2001/09/04 05:31:28 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Carnegie-Mellon University.
|
||||
@ -33,7 +33,7 @@
|
||||
|
||||
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
||||
|
||||
__KERNEL_RCSID(0, "$NetBSD: tc_bus_mem.c,v 1.24 2000/06/29 09:02:58 mrg Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: tc_bus_mem.c,v 1.25 2001/09/04 05:31:28 thorpej Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -69,6 +69,9 @@ void tc_mem_free __P((void *, bus_space_handle_t, bus_size_t));
|
||||
/* get kernel virtual address */
|
||||
void * tc_mem_vaddr __P((void *, bus_space_handle_t));
|
||||
|
||||
/* mmap for user */
|
||||
paddr_t tc_mem_mmap __P((void *, bus_addr_t, off_t, int, int));
|
||||
|
||||
/* barrier */
|
||||
inline void tc_mem_barrier __P((void *, bus_space_handle_t,
|
||||
bus_size_t, bus_size_t, int));
|
||||
@ -178,6 +181,9 @@ static struct alpha_bus_space tc_mem_space = {
|
||||
/* get kernel virtual address */
|
||||
tc_mem_vaddr,
|
||||
|
||||
/* mmap for user */
|
||||
tc_mem_mmap,
|
||||
|
||||
/* barrier */
|
||||
tc_mem_barrier,
|
||||
|
||||
@ -368,6 +374,25 @@ tc_mem_vaddr(v, bsh)
|
||||
return ((void *)bsh);
|
||||
}
|
||||
|
||||
paddr_t
|
||||
tc_mem_mmap(v, addr, off, prot, flags)
|
||||
void *v;
|
||||
bus_addr_t addr;
|
||||
off_t off;
|
||||
int prot;
|
||||
int flags;
|
||||
{
|
||||
int linear = flags & BUS_SPACE_MAP_LINEAR;
|
||||
bus_addr_t rv;
|
||||
|
||||
if (linear)
|
||||
rv = addr + off;
|
||||
else
|
||||
rv = TC_DENSE_TO_SPARSE(addr + off);
|
||||
|
||||
return (alpha_btop(rv));
|
||||
}
|
||||
|
||||
inline void
|
||||
tc_mem_barrier(v, h, o, l, f)
|
||||
void *v;
|
||||
|
Loading…
Reference in New Issue
Block a user