implement bus_space_vaddr()

This commit is contained in:
drochner 2000-04-17 17:24:48 +00:00
parent e29659f7dd
commit 13c9f8d398
9 changed files with 152 additions and 11 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.37 2000/03/15 16:44:48 drochner Exp $ */
/* $NetBSD: bus.h,v 1.38 2000/04/17 17:30:48 drochner Exp $ */
/*-
* Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@ -144,6 +144,9 @@ struct alpha_bus_space {
void (*abs_free) __P((void *, bus_space_handle_t,
bus_size_t));
/* get kernel virtual address */
void * (*abs_vaddr) __P((void *, bus_space_handle_t));
/* barrier */
void (*abs_barrier) __P((void *, bus_space_handle_t,
bus_size_t, bus_size_t, int));
@ -327,6 +330,11 @@ do { \
#define bus_space_free(t, h, s) \
(*(t)->abs_free)((t)->abs_cookie, (h), (s))
/*
* Get kernel virtual address for ranges mapped BUS_SPACE_MAP_LINEAR.
*/
#define bus_space_vaddr(t, h) \
(*(t)->abs_vaddr)((t)->abs_cookie, (h))
/*
* Bus barrier operations.

View File

@ -1,4 +1,4 @@
/* $NetBSD: a12c_bus_mem.c,v 1.4 1999/03/12 22:56:21 perry Exp $ */
/* $NetBSD: a12c_bus_mem.c,v 1.5 2000/04/17 17:30:48 drochner Exp $ */
/* [Notice revision 2.0]
* Copyright (c) 1997 Avalon Computer Systems, Inc.
@ -46,7 +46,7 @@
#define A12C_BUS_MEM() /* Generate ctags(1) key */
__KERNEL_RCSID(0, "$NetBSD: a12c_bus_mem.c,v 1.4 1999/03/12 22:56:21 perry Exp $");
__KERNEL_RCSID(0, "$NetBSD: a12c_bus_mem.c,v 1.5 2000/04/17 17:30:48 drochner Exp $");
/* Memory barrier */
void pci_a12c_mem_barrier __P((void *, bus_space_handle_t,
@ -159,6 +159,9 @@ int pci_a12c_mem_alloc __P((void *, bus_addr_t, bus_addr_t,
void pci_a12c_mem_free __P((void *, bus_space_handle_t,
bus_size_t));
/* get kernel virtual address*/
void *pci_a12c_mem_vaddr __P((void *, bus_space_handle_t));
static struct alpha_bus_space pci_a12c_mem_space = {
/* cookie */
NULL,
@ -172,6 +175,9 @@ static struct alpha_bus_space pci_a12c_mem_space = {
pci_a12c_mem_alloc,
pci_a12c_mem_free,
/* get kernel virtual address */
pci_a12c_mem_vaddr,
/* barrier */
pci_a12c_mem_barrier,
@ -297,6 +303,14 @@ pci_a12c_mem_free(v, bsh, size)
{
}
void *
pci_a12c_mem_vaddr(v, bsh)
void *v;
bus_space_handle_t bsh;
{
/* not supported (could panic() if pci_a12c_mem_map() caught it) */
return (0);
}
void
pci_a12c_mem_barrier(v, h, o, l, f)

View File

@ -1,4 +1,4 @@
/* $NetBSD: pci_bwx_bus_io_chipdep.c,v 1.8 2000/02/26 18:53:13 thorpej Exp $ */
/* $NetBSD: pci_bwx_bus_io_chipdep.c,v 1.9 2000/04/17 17:30:48 drochner Exp $ */
/*-
* Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@ -109,6 +109,9 @@ int __C(CHIP,_io_alloc) __P((void *, bus_addr_t, bus_addr_t,
void __C(CHIP,_io_free) __P((void *, bus_space_handle_t,
bus_size_t));
/* get kernel virtual address */
void * __C(CHIP,_io_vaddr) __P((void *, bus_space_handle_t));
/* barrier */
inline void __C(CHIP,_io_barrier) __P((void *, bus_space_handle_t,
bus_size_t, bus_size_t, int));
@ -236,6 +239,9 @@ __C(CHIP,_bus_io_init)(t, v)
t->abs_alloc = __C(CHIP,_io_alloc);
t->abs_free = __C(CHIP,_io_free);
/* get kernel virtual address */
t->abs_vaddr = __C(CHIP,_io_vaddr);
/* barrier */
t->abs_barrier = __C(CHIP,_io_barrier);
@ -497,6 +503,18 @@ __C(CHIP,_io_free)(v, bsh, size)
__C(CHIP,_io_unmap)(v, bsh, size, 1);
}
void *
__C(CHIP,_io_vaddr)(v, bsh)
void *v;
bus_space_handle_t bsh;
{
/*
* _io_translate() catches BUS_SPACE_MAP_LINEAR,
* so we shouldn't get here
*/
panic("_io_vaddr");
}
inline void
__C(CHIP,_io_barrier)(v, h, o, l, f)
void *v;

View File

@ -1,4 +1,4 @@
/* $NetBSD: pci_bwx_bus_mem_chipdep.c,v 1.9 2000/02/26 18:53:13 thorpej Exp $ */
/* $NetBSD: pci_bwx_bus_mem_chipdep.c,v 1.10 2000/04/17 17:30:48 drochner Exp $ */
/*-
* Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@ -109,6 +109,9 @@ int __C(CHIP,_mem_alloc) __P((void *, bus_addr_t, bus_addr_t,
void __C(CHIP,_mem_free) __P((void *, bus_space_handle_t,
bus_size_t));
/* get kernel virtual address */
void * __C(CHIP,_mem_vaddr) __P((void *, bus_space_handle_t));
/* barrier */
inline void __C(CHIP,_mem_barrier) __P((void *, bus_space_handle_t,
bus_size_t, bus_size_t, int));
@ -236,6 +239,9 @@ __C(CHIP,_bus_mem_init)(t, v)
t->abs_alloc = __C(CHIP,_mem_alloc);
t->abs_free = __C(CHIP,_mem_free);
/* get kernel virtual address */
t->abs_vaddr = __C(CHIP,_mem_vaddr);
/* barrier */
t->abs_barrier = __C(CHIP,_mem_barrier);
@ -481,6 +487,18 @@ __C(CHIP,_mem_free)(v, bsh, size)
__C(CHIP,_mem_unmap)(v, bsh, size, 1);
}
void *
__C(CHIP,_mem_vaddr)(v, bsh)
void *v;
bus_space_handle_t bsh;
{
/*
* We get linear access only with BUS_SPACE_MAP_PREFETCHABLE,
* so it should be OK if the caller doesn't use BWX instructions.
*/
return ((void *)bsh);
}
inline void
__C(CHIP,_mem_barrier)(v, h, o, l, f)
void *v;

View File

@ -1,4 +1,4 @@
/* $NetBSD: pci_swiz_bus_io_chipdep.c,v 1.30 2000/02/26 18:53:13 thorpej Exp $ */
/* $NetBSD: pci_swiz_bus_io_chipdep.c,v 1.31 2000/04/17 17:30:48 drochner Exp $ */
/*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@ -107,6 +107,9 @@ int __C(CHIP,_io_alloc) __P((void *, bus_addr_t, bus_addr_t,
void __C(CHIP,_io_free) __P((void *, bus_space_handle_t,
bus_size_t));
/* get kernel virtual address */
void * __C(CHIP,_io_vaddr) __P((void *, bus_space_handle_t));
/* 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)
t->abs_alloc = __C(CHIP,_io_alloc);
t->abs_free = __C(CHIP,_io_free);
/* get kernel virtual address */
t->abs_vaddr = __C(CHIP,_io_vaddr);
/* barrier */
t->abs_barrier = __C(CHIP,_io_barrier);
@ -598,6 +604,18 @@ __C(CHIP,_io_free)(v, bsh, size)
__C(CHIP,_io_unmap)(v, bsh, size, 1);
}
void *
__C(CHIP,_io_vaddr)(v, bsh)
void *v;
bus_space_handle_t bsh;
{
/*
* _io_translate() catches BUS_SPACE_MAP_LINEAR,
* so we shouldn't get here
*/
panic("_io_vaddr");
}
inline void
__C(CHIP,_io_barrier)(v, h, o, l, f)
void *v;

View File

@ -1,4 +1,4 @@
/* $NetBSD: pci_swiz_bus_mem_chipdep.c,v 1.34 2000/02/26 18:53:13 thorpej Exp $ */
/* $NetBSD: pci_swiz_bus_mem_chipdep.c,v 1.35 2000/04/17 17:30:48 drochner Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -116,6 +116,9 @@ int __C(CHIP,_mem_alloc) __P((void *, bus_addr_t, bus_addr_t,
void __C(CHIP,_mem_free) __P((void *, bus_space_handle_t,
bus_size_t));
/* get kernel virtual address */
void * __C(CHIP,_mem_vaddr) __P((void *, bus_space_handle_t));
/* barrier */
inline void __C(CHIP,_mem_barrier) __P((void *, bus_space_handle_t,
bus_size_t, bus_size_t, int));
@ -263,6 +266,9 @@ __C(CHIP,_bus_mem_init)(t, v)
t->abs_alloc = __C(CHIP,_mem_alloc);
t->abs_free = __C(CHIP,_mem_free);
/* get kernel virtual address */
t->abs_vaddr = __C(CHIP,_mem_vaddr);
/* barrier */
t->abs_barrier = __C(CHIP,_mem_barrier);
@ -897,6 +903,22 @@ __C(CHIP,_mem_free)(v, bsh, size)
panic("%s not implemented", __S(__C(CHIP,_mem_free)));
}
void *
__C(CHIP,_mem_vaddr)(v, bsh)
void *v;
bus_space_handle_t bsh;
{
#ifdef CHIP_D_MEM_W1_SYS_START
/*
* XXX should check that the range was mapped
* with BUS_SPACE_MAP_LINEAR for sanity
*/
if ((bsh >> 63) != 0)
return ((void *)bsh);
#endif
return (0);
}
inline void
__C(CHIP,_mem_barrier)(v, h, o, l, f)
void *v;

View File

@ -1,4 +1,4 @@
/* $NetBSD: tc_bus_mem.c,v 1.21 2000/02/26 18:53:13 thorpej Exp $ */
/* $NetBSD: tc_bus_mem.c,v 1.22 2000/04/17 17:30:48 drochner 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.21 2000/02/26 18:53:13 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: tc_bus_mem.c,v 1.22 2000/04/17 17:30:48 drochner Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -65,6 +65,9 @@ int tc_mem_alloc __P((void *, bus_addr_t, bus_addr_t, bus_size_t,
bus_space_handle_t *));
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));
/* barrier */
inline void tc_mem_barrier __P((void *, bus_space_handle_t,
bus_size_t, bus_size_t, int));
@ -171,6 +174,9 @@ static struct alpha_bus_space tc_mem_space = {
tc_mem_alloc,
tc_mem_free,
/* get kernel virtual address */
tc_mem_vaddr;
/* barrier */
tc_mem_barrier,
@ -344,6 +350,23 @@ tc_mem_free(v, bsh, size)
panic("tc_mem_free unimplemented");
}
void *
tc_mem_vaddr(v, bsh)
void *v;
bus_space_handle_t bsh;
{
#ifdef DIAGNOSTIC
if ((bsh & TC_SPACE_SPARSE) != 0) {
/*
* tc_mem_map() catches linear && !cacheable,
* so we shouldn't come here
*/
panic("tc_mem_vaddr");
}
#endif
return ((void *)bsh);
}
inline void
tc_mem_barrier(v, h, o, l, f)
void *v;

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.27 2000/03/15 16:44:50 drochner Exp $ */
/* $NetBSD: bus.h,v 1.28 2000/04/17 17:24:48 drochner Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@ -194,6 +194,16 @@ void i386_memio_free __P((bus_space_tag_t t, bus_space_handle_t bsh,
#define bus_space_free(t, h, s) \
i386_memio_free((t), (h), (s))
/*
* void *bus_space_vaddr __P((bus_space_tag_t, bus_space_handle_t));
*
* Get the kernel virtual address for the mapped bus space.
* Only allowed for regions mapped with BUS_SPACE_MAP_LINEAR.
* (XXX not enforced)
*/
#define bus_space_vaddr(t, h) \
((t) == I386_BUS_SPACE_MEM ? (void *)(h) : (void *)0)
/*
* u_intN_t bus_space_read_N __P((bus_space_tag_t tag,
* bus_space_handle_t bsh, bus_size_t offset));

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.11 2000/01/25 22:13:23 drochner Exp $ */
/* $NetBSD: bus.h,v 1.12 2000/04/17 17:31:50 drochner Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@ -118,6 +118,16 @@ int bus_space_alloc __P((bus_space_tag_t t, bus_addr_t rstart,
void bus_space_free __P((bus_space_tag_t t, bus_space_handle_t bsh,
bus_size_t size));
/*
* void *bus_space_vaddr __P((bus_space_tag_t, bus_space_handle_t));
*
* Get the kernel virtual address for the mapped bus space.
* Only allowed for regions mapped with BUS_SPACE_MAP_LINEAR.
* (XXX not enforced)
*/
#define bus_space_vaddr(t, h) \
((void *)(h))
/*
* u_intN_t bus_space_read_N __P((bus_space_tag_t tag,
* bus_space_handle_t bsh, bus_size_t offset));