summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMarco Peereboom <marco@cvs.openbsd.org>2007-08-22 21:28:42 +0000
committerMarco Peereboom <marco@cvs.openbsd.org>2007-08-22 21:28:42 +0000
commita61cd1dd71bf55bfd7fac212de17967f2fd03921 (patch)
treeac003b7240c70c7d7caccdd3a422f07618e45ec4 /sys/arch
parent1b1ce1d4eabef2f290d1d18cb0015f7efc83cfa5 (diff)
Add bus_space_vaddr to i386 arch.
Comments and ok kettenis, art & miod
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/i386/i386/machdep.c20
-rw-r--r--sys/arch/i386/include/bus.h15
2 files changed, 25 insertions, 10 deletions
diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c
index 4b5678ab52f..283f9c428de 100644
--- a/sys/arch/i386/i386/machdep.c
+++ b/sys/arch/i386/i386/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.403 2007/07/20 17:04:14 mk Exp $ */
+/* $OpenBSD: machdep.c,v 1.404 2007/08/22 21:28:41 marco Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*-
@@ -3347,7 +3347,7 @@ cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
}
int
-bus_space_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, int cacheable,
+bus_space_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, int flags,
bus_space_handle_t *bshp)
{
int error;
@@ -3359,6 +3359,8 @@ bus_space_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, int cacheable,
switch (t) {
case I386_BUS_SPACE_IO:
ex = ioport_ex;
+ if (flags & BUS_SPACE_MAP_LINEAR)
+ return (EINVAL);
break;
case I386_BUS_SPACE_MEM:
@@ -3395,7 +3397,7 @@ bus_space_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, int cacheable,
* For memory space, map the bus physical address to
* a kernel virtual address.
*/
- error = bus_mem_add_mapping(bpa, size, cacheable, bshp);
+ error = bus_mem_add_mapping(bpa, size, flags, bshp);
if (error) {
if (extent_free(ex, bpa, size, EX_NOWAIT |
(ioport_malloc_safe ? EX_MALLOCOK : 0))) {
@@ -3410,7 +3412,7 @@ bus_space_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, int cacheable,
int
_bus_space_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size,
- int cacheable, bus_space_handle_t *bshp)
+ int flags, bus_space_handle_t *bshp)
{
/*
* For I/O space, that's all she wrote.
@@ -3424,13 +3426,13 @@ _bus_space_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size,
* For memory space, map the bus physical address to
* a kernel virtual address.
*/
- return (bus_mem_add_mapping(bpa, size, cacheable, bshp));
+ return (bus_mem_add_mapping(bpa, size, flags, bshp));
}
int
bus_space_alloc(bus_space_tag_t t, bus_addr_t rstart, bus_addr_t rend,
bus_size_t size, bus_size_t alignment, bus_size_t boundary,
- int cacheable, bus_addr_t *bpap, bus_space_handle_t *bshp)
+ int flags, bus_addr_t *bpap, bus_space_handle_t *bshp)
{
struct extent *ex;
u_long bpa;
@@ -3480,7 +3482,7 @@ bus_space_alloc(bus_space_tag_t t, bus_addr_t rstart, bus_addr_t rend,
* For memory space, map the bus physical address to
* a kernel virtual address.
*/
- error = bus_mem_add_mapping(bpa, size, cacheable, bshp);
+ error = bus_mem_add_mapping(bpa, size, flags, bshp);
if (error) {
if (extent_free(iomem_ex, bpa, size, EX_NOWAIT |
(ioport_malloc_safe ? EX_MALLOCOK : 0))) {
@@ -3496,7 +3498,7 @@ bus_space_alloc(bus_space_tag_t t, bus_addr_t rstart, bus_addr_t rend,
}
int
-bus_mem_add_mapping(bus_addr_t bpa, bus_size_t size, int cacheable,
+bus_mem_add_mapping(bus_addr_t bpa, bus_size_t size, int flags,
bus_space_handle_t *bshp)
{
u_long pa, endpa;
@@ -3525,7 +3527,7 @@ bus_mem_add_mapping(bus_addr_t bpa, bus_size_t size, int cacheable,
pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE);
pte = kvtopte(va);
- if (cacheable)
+ if (flags & BUS_SPACE_MAP_CACHEABLE)
*pte &= ~PG_N;
else
*pte |= PG_N;
diff --git a/sys/arch/i386/include/bus.h b/sys/arch/i386/include/bus.h
index 5c5caf3e6c7..c07289b953a 100644
--- a/sys/arch/i386/include/bus.h
+++ b/sys/arch/i386/include/bus.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bus.h,v 1.40 2007/02/20 21:15:01 tom Exp $ */
+/* $OpenBSD: bus.h,v 1.41 2007/08/22 21:28:41 marco Exp $ */
/* $NetBSD: bus.h,v 1.6 1996/11/10 03:19:25 thorpej Exp $ */
/*-
@@ -731,6 +731,19 @@ void bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh,
/* Compatibility defines */
#define BUS_BARRIER_READ BUS_SPACE_BARRIER_READ
#define BUS_BARRIER_WRITE BUS_SPACE_BARRIER_WRITE
+#define BUS_SPACE_MAP_CACHEABLE 0x0001
+#define BUS_SPACE_MAP_LINEAR 0x0002
+#define BUS_SPACE_MAP_PREFETCHABLE 0x0008
+
+/*
+ * void *bus_space_vaddr(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_IO ? (void *)(NULL) : (void *)(h))
/*
* Flags used in various bus DMA methods.