summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Henderson <sthen@cvs.openbsd.org>2014-10-17 19:35:33 +0000
committerStuart Henderson <sthen@cvs.openbsd.org>2014-10-17 19:35:33 +0000
commitfd203e6f78619f4d6702a6f56356450ed4f5075f (patch)
treeacdd104e82cd87ac532c7e3d10ca8971c09d7741
parent98b613962c1a4a56bce22baa1f335339e8c4890d (diff)
backout i386/bus_space diff for now, req'd by deraadt@ - problems at boot
| i386/bus_space.c:1.5->1.6 | i386/machdep.c:1.551->1.552 | include/bus.h:1.61->1.62
-rw-r--r--sys/arch/i386/i386/bus_space.c981
-rw-r--r--sys/arch/i386/i386/machdep.c24
-rw-r--r--sys/arch/i386/include/bus.h229
3 files changed, 411 insertions, 823 deletions
diff --git a/sys/arch/i386/i386/bus_space.c b/sys/arch/i386/i386/bus_space.c
index 6573180a6a0..5041387b679 100644
--- a/sys/arch/i386/i386/bus_space.c
+++ b/sys/arch/i386/i386/bus_space.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bus_space.c,v 1.6 2014/10/17 01:46:26 dlg Exp $ */
+/* $OpenBSD: bus_space.c,v 1.7 2014/10/17 19:35:32 sthen Exp $ */
/*-
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -68,849 +68,486 @@
#include <machine/bus.h>
-u_int8_t i386_bus_space_io_read_1(bus_space_handle_t, bus_size_t);
-u_int16_t i386_bus_space_io_read_2(bus_space_handle_t, bus_size_t);
-u_int32_t i386_bus_space_io_read_4(bus_space_handle_t, bus_size_t);
-
-void i386_bus_space_io_read_multi_1(bus_space_handle_t, bus_size_t,
- u_int8_t *, bus_size_t);
-void i386_bus_space_io_read_multi_2(bus_space_handle_t, bus_size_t,
- u_int16_t *, bus_size_t);
-void i386_bus_space_io_read_multi_4(bus_space_handle_t, bus_size_t,
- u_int32_t *, bus_size_t);
-
-void i386_bus_space_io_read_region_1(bus_space_handle_t, bus_size_t,
- u_int8_t *, bus_size_t);
-void i386_bus_space_io_read_region_2(bus_space_handle_t, bus_size_t,
- u_int16_t *, bus_size_t);
-void i386_bus_space_io_read_region_4(bus_space_handle_t, bus_size_t,
- u_int32_t *, bus_size_t);
-
-void i386_bus_space_io_write_1(bus_space_handle_t, bus_size_t,
- u_int8_t);
-void i386_bus_space_io_write_2(bus_space_handle_t, bus_size_t,
- u_int16_t);
-void i386_bus_space_io_write_4(bus_space_handle_t, bus_size_t,
- u_int32_t);
-
-void i386_bus_space_io_write_multi_1(bus_space_handle_t,
- bus_size_t, const u_int8_t *, bus_size_t);
-void i386_bus_space_io_write_multi_2(bus_space_handle_t,
- bus_size_t, const u_int16_t *, bus_size_t);
-void i386_bus_space_io_write_multi_4(bus_space_handle_t,
- bus_size_t, const u_int32_t *, bus_size_t);
-
-void i386_bus_space_io_write_region_1(bus_space_handle_t,
- bus_size_t, const u_int8_t *, bus_size_t);
-void i386_bus_space_io_write_region_2(bus_space_handle_t,
- bus_size_t, const u_int16_t *, bus_size_t);
-void i386_bus_space_io_write_region_4(bus_space_handle_t,
- bus_size_t, const u_int32_t *, bus_size_t);
-
-void i386_bus_space_io_set_multi_1(bus_space_handle_t, bus_size_t,
- u_int8_t, size_t);
-void i386_bus_space_io_set_multi_2(bus_space_handle_t, bus_size_t,
- u_int16_t, size_t);
-void i386_bus_space_io_set_multi_4(bus_space_handle_t, bus_size_t,
- u_int32_t, size_t);
-
-void i386_bus_space_io_set_region_1(bus_space_handle_t, bus_size_t,
- u_int8_t, size_t);
-void i386_bus_space_io_set_region_2(bus_space_handle_t, bus_size_t,
- u_int16_t, size_t);
-void i386_bus_space_io_set_region_4(bus_space_handle_t, bus_size_t,
- u_int32_t, size_t);
-
-void i386_bus_space_io_copy_1(bus_space_handle_t, bus_size_t,
- bus_space_handle_t, bus_size_t, size_t);
-void i386_bus_space_io_copy_2(bus_space_handle_t, bus_size_t,
- bus_space_handle_t, bus_size_t, size_t);
-void i386_bus_space_io_copy_4(bus_space_handle_t, bus_size_t,
- bus_space_handle_t, bus_size_t, size_t);
-
-void * i386_bus_space_io_vaddr(bus_space_handle_t);
-paddr_t i386_bus_space_io_mmap(bus_addr_t, off_t, int, int);
-
-const struct i386_bus_space_ops i386_bus_space_io_ops = {
- i386_bus_space_io_read_1,
- i386_bus_space_io_read_2,
- i386_bus_space_io_read_4,
- i386_bus_space_io_read_multi_1,
- i386_bus_space_io_read_multi_2,
- i386_bus_space_io_read_multi_4,
- i386_bus_space_io_read_region_1,
- i386_bus_space_io_read_region_2,
- i386_bus_space_io_read_region_4,
- i386_bus_space_io_write_1,
- i386_bus_space_io_write_2,
- i386_bus_space_io_write_4,
- i386_bus_space_io_write_multi_1,
- i386_bus_space_io_write_multi_2,
- i386_bus_space_io_write_multi_4,
- i386_bus_space_io_write_region_1,
- i386_bus_space_io_write_region_2,
- i386_bus_space_io_write_region_4,
- i386_bus_space_io_set_multi_1,
- i386_bus_space_io_set_multi_2,
- i386_bus_space_io_set_multi_4,
- i386_bus_space_io_set_region_1,
- i386_bus_space_io_set_region_2,
- i386_bus_space_io_set_region_4,
- i386_bus_space_io_copy_1,
- i386_bus_space_io_copy_2,
- i386_bus_space_io_copy_4,
- i386_bus_space_io_vaddr,
-};
-
-u_int8_t i386_bus_space_mem_read_1(bus_space_handle_t, bus_size_t);
-u_int16_t i386_bus_space_mem_read_2(bus_space_handle_t, bus_size_t);
-u_int32_t i386_bus_space_mem_read_4(bus_space_handle_t, bus_size_t);
-
-void i386_bus_space_mem_read_multi_1(bus_space_handle_t, bus_size_t,
- u_int8_t *, bus_size_t);
-void i386_bus_space_mem_read_multi_2(bus_space_handle_t, bus_size_t,
- u_int16_t *, bus_size_t);
-void i386_bus_space_mem_read_multi_4(bus_space_handle_t, bus_size_t,
- u_int32_t *, bus_size_t);
-
-void i386_bus_space_mem_read_region_1(bus_space_handle_t, bus_size_t,
- u_int8_t *, bus_size_t);
-void i386_bus_space_mem_read_region_2(bus_space_handle_t, bus_size_t,
- u_int16_t *, bus_size_t);
-void i386_bus_space_mem_read_region_4(bus_space_handle_t, bus_size_t,
- u_int32_t *, bus_size_t);
-
-void i386_bus_space_mem_write_1(bus_space_handle_t, bus_size_t,
- u_int8_t);
-void i386_bus_space_mem_write_2(bus_space_handle_t, bus_size_t,
- u_int16_t);
-void i386_bus_space_mem_write_4(bus_space_handle_t, bus_size_t,
- u_int32_t);
-
-void i386_bus_space_mem_write_multi_1(bus_space_handle_t,
- bus_size_t, const u_int8_t *, bus_size_t);
-void i386_bus_space_mem_write_multi_2(bus_space_handle_t,
- bus_size_t, const u_int16_t *, bus_size_t);
-void i386_bus_space_mem_write_multi_4(bus_space_handle_t,
- bus_size_t, const u_int32_t *, bus_size_t);
-
-void i386_bus_space_mem_write_region_1(bus_space_handle_t,
- bus_size_t, const u_int8_t *, bus_size_t);
-void i386_bus_space_mem_write_region_2(bus_space_handle_t,
- bus_size_t, const u_int16_t *, bus_size_t);
-void i386_bus_space_mem_write_region_4(bus_space_handle_t,
- bus_size_t, const u_int32_t *, bus_size_t);
-
-void i386_bus_space_mem_set_multi_1(bus_space_handle_t, bus_size_t,
- u_int8_t, size_t);
-void i386_bus_space_mem_set_multi_2(bus_space_handle_t, bus_size_t,
- u_int16_t, size_t);
-void i386_bus_space_mem_set_multi_4(bus_space_handle_t, bus_size_t,
- u_int32_t, size_t);
-
-void i386_bus_space_mem_set_region_1(bus_space_handle_t, bus_size_t,
- u_int8_t, size_t);
-void i386_bus_space_mem_set_region_2(bus_space_handle_t, bus_size_t,
- u_int16_t, size_t);
-void i386_bus_space_mem_set_region_4(bus_space_handle_t, bus_size_t,
- u_int32_t, size_t);
-
-void i386_bus_space_mem_copy_1(bus_space_handle_t, bus_size_t,
- bus_space_handle_t, bus_size_t, size_t);
-void i386_bus_space_mem_copy_2(bus_space_handle_t, bus_size_t,
- bus_space_handle_t, bus_size_t, size_t);
-void i386_bus_space_mem_copy_4(bus_space_handle_t, bus_size_t,
- bus_space_handle_t, bus_size_t, size_t);
-
-void * i386_bus_space_mem_vaddr(bus_space_handle_t);
-paddr_t i386_bus_space_mem_mmap(bus_addr_t, off_t, int, int);
-
-const struct i386_bus_space_ops i386_bus_space_mem_ops = {
- i386_bus_space_mem_read_1,
- i386_bus_space_mem_read_2,
- i386_bus_space_mem_read_4,
- i386_bus_space_mem_read_multi_1,
- i386_bus_space_mem_read_multi_2,
- i386_bus_space_mem_read_multi_4,
- i386_bus_space_mem_read_region_1,
- i386_bus_space_mem_read_region_2,
- i386_bus_space_mem_read_region_4,
- i386_bus_space_mem_write_1,
- i386_bus_space_mem_write_2,
- i386_bus_space_mem_write_4,
- i386_bus_space_mem_write_multi_1,
- i386_bus_space_mem_write_multi_2,
- i386_bus_space_mem_write_multi_4,
- i386_bus_space_mem_write_region_1,
- i386_bus_space_mem_write_region_2,
- i386_bus_space_mem_write_region_4,
- i386_bus_space_mem_set_multi_1,
- i386_bus_space_mem_set_multi_2,
- i386_bus_space_mem_set_multi_4,
- i386_bus_space_mem_set_region_1,
- i386_bus_space_mem_set_region_2,
- i386_bus_space_mem_set_region_4,
- i386_bus_space_mem_copy_1,
- i386_bus_space_mem_copy_2,
- i386_bus_space_mem_copy_4,
- i386_bus_space_mem_vaddr,
-};
-
u_int8_t
-i386_bus_space_io_read_1(bus_space_handle_t h, bus_size_t o)
+bus_space_read_1(bus_space_tag_t t, bus_space_handle_t h,
+ bus_size_t o)
{
- return (inb(h + o));
+ return ((t) == I386_BUS_SPACE_IO ? (inb((h) + (o))) :
+ (*(volatile u_int8_t *)((h) + (o))));
}
u_int16_t
-i386_bus_space_io_read_2(bus_space_handle_t h, bus_size_t o)
+bus_space_read_2(bus_space_tag_t t, bus_space_handle_t h,
+ bus_size_t o)
{
- return (inw(h + o));
+ return ((t) == I386_BUS_SPACE_IO ? (inw((h) + (o))) :
+ (*(volatile u_int16_t *)((h) + (o))));
}
u_int32_t
-i386_bus_space_io_read_4(bus_space_handle_t h, bus_size_t o)
-{
- return (inl(h + o));
-}
-
-void
-i386_bus_space_io_read_multi_1(bus_space_handle_t h, bus_size_t o,
- u_int8_t *a, bus_size_t cnt)
-{
- insb(h + o, a, cnt);
-}
-
-void
-i386_bus_space_io_read_multi_2(bus_space_handle_t h, bus_size_t o,
- u_int16_t *a, bus_size_t cnt)
-{
- insw(h + o, a, cnt);
-}
-
-void
-i386_bus_space_io_read_multi_4(bus_space_handle_t h, bus_size_t o,
- u_int32_t *a, bus_size_t cnt)
-{
- insl(h + o, a, cnt);
-}
-
-void
-i386_bus_space_io_read_region_1(bus_space_handle_t h,
- bus_size_t o, u_int8_t *a, bus_size_t cnt)
-{
- int _cnt = cnt;
- void *_addr = a;
- int _port = h + o;
-
- __asm volatile("cld ;"
- "1: inb %w2,%%al ;"
- " stosb ;"
- " incl %2 ;"
- " loop 1b" :
- "+D" (_addr), "+c" (_cnt), "+d" (_port) ::
- "%eax", "memory", "cc");
-}
-
-void
-i386_bus_space_io_read_region_2(bus_space_handle_t h,
- bus_size_t o, u_int16_t *a, bus_size_t cnt)
-{
- int _cnt = cnt;
- void *_addr = a;
- int _port = h + o;
-
- __asm volatile("cld ;"
- "1: inw %w2,%%ax ;"
- " stosw ;"
- " addl $2,%2 ;"
- " loop 1b" :
- "+D" (_addr), "+c" (_cnt), "+d" (_port) ::
- "%eax", "memory", "cc");
-}
-
-void
-i386_bus_space_io_read_region_4(bus_space_handle_t h,
- bus_size_t o, u_int32_t *a, bus_size_t cnt)
-{
- int _cnt = cnt;
- void *_addr = a;
- int _port = h + o;
-
- __asm volatile("cld ;"
- "1: inl %w2,%%eax ;"
- " stosl ;"
- " addl $4,%2 ;"
- " loop 1b" :
- "+D" (_addr), "+c" (_cnt), "+d" (_port) ::
- "%eax", "memory", "cc");
-}
-
-void
-i386_bus_space_io_write_1(bus_space_handle_t h, bus_size_t o, u_int8_t v)
-{
- outb(h + o, v);
-}
-
-void
-i386_bus_space_io_write_2(bus_space_handle_t h, bus_size_t o, u_int16_t v)
-{
- outw(h + o, v);
-}
-
-void
-i386_bus_space_io_write_4(bus_space_handle_t h, bus_size_t o, u_int32_t v)
-{
- outl(h + o, v);
-}
-
-void
-i386_bus_space_io_write_multi_1(bus_space_handle_t h,
- bus_size_t o, const u_int8_t *a, bus_size_t cnt)
-{
- outsb(h + o, a, cnt);
-}
-
-void
-i386_bus_space_io_write_multi_2(bus_space_handle_t h,
- bus_size_t o, const u_int16_t *a, bus_size_t cnt)
-{
- outsw(h + o, a, cnt);
-}
-
-void
-i386_bus_space_io_write_multi_4(bus_space_handle_t h,
- bus_size_t o, const u_int32_t *a, bus_size_t cnt)
-{
- outsl(h + o, a, cnt);
-}
-
-void
-i386_bus_space_io_write_region_1(bus_space_handle_t h,
- bus_size_t o, const u_int8_t *a, bus_size_t cnt)
-{
- int _port = h + o;
- const void *_addr = a;
- int _cnt = cnt;
-
- __asm volatile("cld ;"
- "1: lodsb ;"
- " outb %%al,%w0 ;"
- " incl %0 ;"
- " loop 1b" :
- "+d" (_port), "+S" (_addr), "+c" (_cnt) ::
- "%eax", "memory", "cc");
-}
-
-void
-i386_bus_space_io_write_region_2(bus_space_handle_t h,
- bus_size_t o, const u_int16_t *a, bus_size_t cnt)
-{
- int _port = h + o;
- const void *_addr = a;
- int _cnt = cnt;
-
- __asm volatile("cld ;"
- "1: lodsw ;"
- " outw %%ax,%w0 ;"
- " addl $2,%0 ;"
- " loop 1b" :
- "+d" (_port), "+S" (_addr), "+c" (_cnt) ::
- "%eax", "memory", "cc");
-}
-
-void
-i386_bus_space_io_write_region_4(bus_space_handle_t h,
- bus_size_t o, const u_int32_t *a, bus_size_t cnt)
-{
- int _port = h + o;
- const void *_addr = a;
- int _cnt = cnt;
-
- __asm volatile("cld ;"
- "1: lodsl ;"
- " outl %%eax,%w0 ;"
- " addl $4,%0 ;"
- " loop 1b" :
- "+d" (_port), "+S" (_addr), "+c" (_cnt) ::
- "%eax", "memory", "cc");
-}
-
-void
-i386_bus_space_io_set_multi_1(bus_space_handle_t h,
- bus_size_t o, u_int8_t v, size_t cnt)
-{
- int _cnt = cnt;
-
- __asm volatile("cld ;"
- "1: outb %b2, %w1 ;"
- " loop 1b" :
- "+c" (_cnt) : "d" (h + o), "a" (v) :
- "cc");
-}
-
-void
-i386_bus_space_io_set_multi_2(bus_space_handle_t h,
- bus_size_t o, u_int16_t v, size_t cnt)
-{
- int _cnt = cnt;
-
- __asm volatile("cld ;"
- "1: outw %w2, %w1 ;"
- " loop 1b" :
- "+c" (_cnt) : "d" (h + o), "a" (v) :
- "cc");
-}
-
-void
-i386_bus_space_io_set_multi_4(bus_space_handle_t h,
- bus_size_t o, u_int32_t v, size_t cnt)
-{
- int _cnt = cnt;
-
- __asm volatile("cld ;"
- "1: outl %2,%w1 ;"
- " loop 1b" :
- "+c" (_cnt) : "d" (h + o), "a" (v) :
- "cc");
-}
-
-void
-i386_bus_space_io_set_region_1(bus_space_handle_t h,
- bus_size_t o, u_int8_t v, size_t cnt)
-{
- int _port = h + o;
- int _cnt = cnt;
-
- __asm volatile(
- "1: outb %%al,%w0 ;"
- " incl %0 ;"
- " loop 1b" :
- "+d" (_port), "+c" (_cnt) : "a" (v) :
- "cc");
-}
-
-void
-i386_bus_space_io_set_region_2(bus_space_handle_t h,
- bus_size_t o, u_int16_t v, size_t cnt)
-{
- int _port = h + o;
- int _cnt = cnt;
-
- __asm volatile(
- "1: outw %%ax,%w0 ;"
- " addl $2, %0 ;"
- " loop 1b" :
- "+d" (_port), "+c" (_cnt) : "a" (v) :
- "cc");
-}
-
-void
-i386_bus_space_io_set_region_4(bus_space_handle_t h,
- bus_size_t o, u_int32_t v, size_t cnt)
-{
- int _port = h + o;
- int _cnt = cnt;
-
- __asm volatile(
- "1: outl %%eax,%w0 ;"
- " addl $4, %0 ;"
- " loop 1b" :
- "+d" (_port), "+c" (_cnt) : "a" (v) :
- "cc");
-}
-
-void
-i386_bus_space_io_copy_1(bus_space_handle_t h1, bus_size_t o1,
- bus_space_handle_t h2, bus_size_t o2, bus_size_t cnt)
-{
- int _port1 = h1 + o1;
- int _port2 = h2 + o2;
- int _cnt = cnt;
-
- __asm volatile(
- "1: movl %k1,%%edx ;"
- " inb %%dx,%%al ;"
- " movl %k0,%%edx ;"
- " outb %%al,%%dx ;"
- " incl %0 ;"
- " incl %1 ;"
- " loop 1b" :
- "+D" (_port2), "+S" (_port1), "+c" (_cnt) ::
- "%edx", "%eax", "cc");
-}
-
-void
-i386_bus_space_io_copy_2(bus_space_handle_t h1, bus_size_t o1,
- bus_space_handle_t h2, bus_size_t o2, bus_size_t cnt)
-{
- int _port1 = h1 + o1;
- int _port2 = h2 + o2;
- int _cnt=cnt;
-
- __asm volatile(
- "1: movl %k1,%%edx ;"
- " inw %%dx,%%ax ;"
- " movl %k0,%%edx ;"
- " outw %%ax,%%dx ;"
- " addl $2, %0 ;"
- " addl $2, %1 ;"
- " loop 1b" :
- "+D" (_port2), "+S" (_port1), "+c" (_cnt) ::
- "%edx", "%eax", "cc");
-}
-
-void
-i386_bus_space_io_copy_4(bus_space_handle_t h1, bus_size_t o1,
- bus_space_handle_t h2, bus_size_t o2, bus_size_t cnt)
-{
- int _port1 = h1 + o1;
- int _port2 = h2 + o2;
- int _cnt = cnt;
-
- __asm volatile(
- "1: movl %k1,%%edx ;"
- " inl %%dx,%%eax ;"
- " movl %k0,%%edx ;"
- " outl %%eax,%%dx ;"
- " addl $4, %0 ;"
- " addl $4, %1 ;"
- " loop 1b" :
- "+D" (_port2), "+S" (_port1), "+c" (_cnt) ::
- "%edx", "%eax", "cc");
-}
-
-void *
-i386_bus_space_io_vaddr(bus_space_handle_t h)
+bus_space_read_4(bus_space_tag_t t, bus_space_handle_t h,
+ bus_size_t o)
{
- return (NULL);
+ return ((t) == I386_BUS_SPACE_IO ? (inl((h) + (o))) :
+ (*(volatile u_int32_t *)((h) + (o))));
}
-paddr_t
-i386_bus_space_io_mmap(bus_addr_t addr, off_t off, int prot, int flags)
-{
- /* Can't mmap I/O space. */
- return (-1);
-}
-
-u_int8_t
-i386_bus_space_mem_read_1(bus_space_handle_t h, bus_size_t o)
-{
- return (*(volatile u_int8_t *)((h) + (o)));
-}
-
-u_int16_t
-i386_bus_space_mem_read_2(bus_space_handle_t h, bus_size_t o)
-{
- return (*(volatile u_int16_t *)((h) + (o)));
-}
-
-u_int32_t
-i386_bus_space_mem_read_4(bus_space_handle_t h, bus_size_t o)
-{
- return (*(volatile u_int32_t *)((h) + (o)));
-}
void
-i386_bus_space_mem_read_multi_1(bus_space_handle_t h, bus_size_t o,
+bus_space_read_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
u_int8_t *a, bus_size_t cnt)
{
- void *_addr=a;
- int _cnt=cnt;
- __asm volatile("cld ;"
- "1: movb (%2),%%al ;"
- " stosb ;"
- " loop 1b" :
- "+D" (_addr), "+c" (_cnt) : "r" (h + o) :
- "%eax", "memory", "cc");
+ if (t == I386_BUS_SPACE_IO) {
+ insb(h + o, a, cnt);
+ } else {
+ void *_addr=a;
+ int _cnt=cnt;
+ __asm volatile("cld ;"
+ "1: movb (%2),%%al ;"
+ " stosb ;"
+ " loop 1b" :
+ "+D" (_addr), "+c" (_cnt) : "r" (h + o) :
+ "%eax", "memory", "cc");
+ }
}
void
-i386_bus_space_mem_read_multi_2(bus_space_handle_t h, bus_size_t o,
+bus_space_read_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
u_int16_t *a, bus_size_t cnt)
{
- void *_addr=a;
- int _cnt=cnt;
- __asm volatile("cld ;"
- "1: movw (%2),%%ax ;"
- " stosw ;"
- " loop 1b" :
- "+D" (_addr), "+c" (_cnt) : "r" ((h) + (o)) :
- "%eax", "memory", "cc");
-}
-
-void
-i386_bus_space_mem_read_multi_4(bus_space_handle_t h, bus_size_t o,
+ if (t == I386_BUS_SPACE_IO) {
+ insw(h + o, a, cnt);
+ } else {
+ void *_addr=a;
+ int _cnt=cnt;
+ __asm volatile("cld ;"
+ "1: movw (%2),%%ax ;"
+ " stosw ;"
+ " loop 1b" :
+ "+D" (_addr), "+c" (_cnt) : "r" ((h) + (o)) :
+ "%eax", "memory", "cc");
+ }
+}
+void
+bus_space_read_multi_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
u_int32_t *a, bus_size_t cnt)
{
- void *_addr=a;
- int _cnt=cnt;
- __asm volatile("cld ;"
- "1: movl (%2),%%eax ;"
- " stosl ;"
- " loop 1b" :
- "+D" (_addr), "+c" (_cnt) : "r" (h + o) :
- "%eax", "memory", "cc");
+ if (t == I386_BUS_SPACE_IO) {
+ insl(h + o, a, cnt);
+ } else {
+ void *_addr=a;
+ int _cnt=cnt;
+ __asm volatile("cld ;"
+ "1: movl (%2),%%eax ;"
+ " stosl ;"
+ " loop 1b" :
+ "+D" (_addr), "+c" (_cnt) : "r" (h + o) :
+ "%eax", "memory", "cc");
+ }
}
void
-i386_bus_space_mem_read_region_1(bus_space_handle_t h,
+bus_space_read_region_1(bus_space_tag_t t, bus_space_handle_t h,
bus_size_t o, u_int8_t *a, bus_size_t cnt)
{
int _cnt = cnt;
void *_addr = a;
int _port = h + o;
- i386_space_copy(_port, _addr, 1, _cnt);
+ if (t == I386_BUS_SPACE_IO) {
+ __asm volatile("cld ;"
+ "1: inb %w2,%%al ;"
+ " stosb ;"
+ " incl %2 ;"
+ " loop 1b" :
+ "+D" (_addr), "+c" (_cnt), "+d" (_port) ::
+ "%eax", "memory", "cc");
+ } else
+ i386_space_copy(_port, _addr, 1, _cnt);
}
void
-i386_bus_space_mem_read_region_2(bus_space_handle_t h,
+bus_space_read_region_2(bus_space_tag_t t, bus_space_handle_t h,
bus_size_t o, u_int16_t *a, bus_size_t cnt)
{
int _cnt = cnt;
void *_addr = a;
int _port = h + o;
- i386_space_copy(_port, _addr, 2, _cnt);
+ if (t == I386_BUS_SPACE_IO) {
+ __asm volatile("cld ;"
+ "1: inw %w2,%%ax ;"
+ " stosw ;"
+ " addl $2,%2 ;"
+ " loop 1b" :
+ "+D" (_addr), "+c" (_cnt), "+d" (_port) ::
+ "%eax", "memory", "cc");
+ } else
+ i386_space_copy(_port, _addr, 2, _cnt);
}
void
-i386_bus_space_mem_read_region_4(bus_space_handle_t h,
+bus_space_read_region_4(bus_space_tag_t t, bus_space_handle_t h,
bus_size_t o, u_int32_t *a, bus_size_t cnt)
{
int _cnt = cnt;
void *_addr = a;
int _port = h + o;
- i386_space_copy(_port, _addr, 4, _cnt);
+ if (t == I386_BUS_SPACE_IO) {
+ __asm volatile("cld ;"
+ "1: inl %w2,%%eax ;"
+ " stosl ;"
+ " addl $4,%2 ;"
+ " loop 1b" :
+ "+D" (_addr), "+c" (_cnt), "+d" (_port) ::
+ "%eax", "memory", "cc");
+ } else
+ i386_space_copy(_port, _addr, 4, _cnt);
}
void
-i386_bus_space_mem_write_1(bus_space_handle_t h, bus_size_t o, u_int8_t v)
+bus_space_write_1(bus_space_tag_t t, bus_space_handle_t h,
+ bus_size_t o, u_int8_t v)
{
- ((void)(*(volatile u_int8_t *)(h + o) = v));
+ if (t == I386_BUS_SPACE_IO)
+ outb(h + o, v);
+ else
+ ((void)(*(volatile u_int8_t *)(h + o) = v));
}
void
-i386_bus_space_mem_write_2(bus_space_handle_t h, bus_size_t o, u_int16_t v)
+bus_space_write_2(bus_space_tag_t t, bus_space_handle_t h,
+ bus_size_t o, u_int16_t v)
{
- ((void)(*(volatile u_int16_t *)(h + o) = v));
+ if ((t) == I386_BUS_SPACE_IO)
+ outw(h + o, v);
+ else
+ ((void)(*(volatile u_int16_t *)(h + o) = v));
}
void
-i386_bus_space_mem_write_4(bus_space_handle_t h, bus_size_t o, u_int32_t v)
+bus_space_write_4(bus_space_tag_t t, bus_space_handle_t h,
+ bus_size_t o, u_int32_t v)
{
- ((void)(*(volatile u_int32_t *)(h + o) = v));
+ if ((t) == I386_BUS_SPACE_IO)
+ outl(h + o, v);
+ else
+ ((void)(*(volatile u_int32_t *)(h + o) = v));
}
void
-i386_bus_space_mem_write_multi_1(bus_space_handle_t h,
+bus_space_write_multi_1(bus_space_tag_t t, bus_space_handle_t h,
bus_size_t o, const u_int8_t *a, bus_size_t cnt)
{
- const void *_addr=a;
- int _cnt=cnt;
+ if (t == I386_BUS_SPACE_IO) {
+ outsb(h + o, a, cnt);
+ } else {
+ const void *_addr=a;
+ int _cnt=cnt;
- __asm volatile("cld ;"
- "1: lodsb ;"
- " movb %%al,(%2) ;"
- " loop 1b" :
- "+S" (_addr), "+c" (_cnt) : "r" (h + o) :
- "%eax", "memory", "cc");
+ __asm volatile("cld ;"
+ "1: lodsb ;"
+ " movb %%al,(%2) ;"
+ " loop 1b" :
+ "+S" (_addr), "+c" (_cnt) : "r" (h + o) :
+ "%eax", "memory", "cc");
+ }
}
void
-i386_bus_space_mem_write_multi_2(bus_space_handle_t h,
+bus_space_write_multi_2(bus_space_tag_t t, bus_space_handle_t h,
bus_size_t o, const u_int16_t *a, bus_size_t cnt)
{
- const void *_addr = a;
- int _cnt = cnt;
+ if (t == I386_BUS_SPACE_IO) {
+ outsw(h + o, a, cnt);
+ } else {
+ const void *_addr = a;
+ int _cnt = cnt;
- __asm volatile("cld ;"
- "1: lodsw ;"
- " movw %%ax,(%2) ;"
- " loop 1b" :
- "+S" (_addr), "+c" (_cnt) : "r" (h + o) :
- "%eax", "memory", "cc");
+ __asm volatile("cld ;"
+ "1: lodsw ;"
+ " movw %%ax,(%2) ;"
+ " loop 1b" :
+ "+S" (_addr), "+c" (_cnt) : "r" (h + o) :
+ "%eax", "memory", "cc");
+ }
}
-
void
-i386_bus_space_mem_write_multi_4(bus_space_handle_t h,
+bus_space_write_multi_4(bus_space_tag_t t, bus_space_handle_t h,
bus_size_t o, const u_int32_t *a, bus_size_t cnt)
{
- const void *_addr=a;
- int _cnt=cnt;
+ if (t == I386_BUS_SPACE_IO) {
+ outsl(h + o, a, cnt);
+ } else {
+ const void *_addr=a;
+ int _cnt=cnt;
- __asm volatile("cld ;"
- "1: lodsl ;"
- " movl %%eax,(%2) ;"
- " loop 1b" :
- "+S" (_addr), "+c" (_cnt) : "r" (h + o) :
- "%eax", "memory", "cc");
+ __asm volatile("cld ;"
+ "1: lodsl ;"
+ " movl %%eax,(%2) ;"
+ " loop 1b" :
+ "+S" (_addr), "+c" (_cnt) : "r" (h + o) :
+ "%eax", "memory", "cc");
+ }
}
void
-i386_bus_space_mem_write_region_1(bus_space_handle_t h,
+bus_space_write_region_1(bus_space_tag_t t, bus_space_handle_t h,
bus_size_t o, const u_int8_t *a, bus_size_t cnt)
{
int _port = h + o;
const void *_addr = a;
int _cnt = cnt;
- i386_space_copy(_addr, _port, 1, _cnt);
+ if (t == I386_BUS_SPACE_IO) {
+ __asm volatile("cld ;"
+ "1: lodsb ;"
+ " outb %%al,%w0 ;"
+ " incl %0 ;"
+ " loop 1b" :
+ "+d" (_port), "+S" (_addr), "+c" (_cnt) ::
+ "%eax", "memory", "cc");
+ } else
+ i386_space_copy(_addr, _port, 1, _cnt);
}
void
-i386_bus_space_mem_write_region_2(bus_space_handle_t h,
+bus_space_write_region_2(bus_space_tag_t t, bus_space_handle_t h,
bus_size_t o, const u_int16_t *a, bus_size_t cnt)
{
int _port = h + o;
const void *_addr = a;
int _cnt = cnt;
- i386_space_copy(_addr, _port, 2, _cnt);
+ if (t == I386_BUS_SPACE_IO) {
+ __asm volatile("cld ;"
+ "1: lodsw ;"
+ " outw %%ax,%w0 ;"
+ " addl $2,%0 ;"
+ " loop 1b" :
+ "+d" (_port), "+S" (_addr), "+c" (_cnt) ::
+ "%eax", "memory", "cc");
+ } else
+ i386_space_copy(_addr, _port, 2, _cnt);
}
void
-i386_bus_space_mem_write_region_4(bus_space_handle_t h,
+bus_space_write_region_4(bus_space_tag_t t, bus_space_handle_t h,
bus_size_t o, const u_int32_t *a, bus_size_t cnt)
{
int _port = h + o;
const void *_addr = a;
int _cnt = cnt;
- i386_space_copy(_addr, _port, 4, _cnt);
+ if (t == I386_BUS_SPACE_IO) {
+ __asm volatile("cld ;"
+ "1: lodsl ;"
+ " outl %%eax,%w0 ;"
+ " addl $4,%0 ;"
+ " loop 1b" :
+ "+d" (_port), "+S" (_addr), "+c" (_cnt) ::
+ "%eax", "memory", "cc");
+ } else
+ i386_space_copy(_addr, _port, 4, _cnt);
}
void
-i386_bus_space_mem_set_multi_1(bus_space_handle_t h,
+bus_space_set_multi_1(bus_space_tag_t t, bus_space_handle_t h,
bus_size_t o, u_int8_t v, size_t cnt)
{
int _cnt = cnt;
- __asm volatile("cld ;"
- "1: movb %b2, (%1) ;"
- " loop 1b" :
- "+c" (_cnt) : "D" (h + o), "a" (v) :
- "cc", "memory");
+ if (t == I386_BUS_SPACE_IO) {
+ __asm volatile("cld ;"
+ "1: outb %b2, %w1 ;"
+ " loop 1b" :
+ "+c" (_cnt) : "d" (h + o), "a" (v) :
+ "cc");
+ } else {
+ __asm volatile("cld ;"
+ "1: movb %b2, (%1) ;"
+ " loop 1b" :
+ "+c" (_cnt) : "D" (h + o), "a" (v) :
+ "cc", "memory");
+ }
}
void
-i386_bus_space_mem_set_multi_2(bus_space_handle_t h,
+bus_space_set_multi_2(bus_space_tag_t t, bus_space_handle_t h,
bus_size_t o, u_int16_t v, size_t cnt)
{
int _cnt = cnt;
- __asm volatile("cld ;"
- "1: movw %w2, (%1) ;"
- " loop 1b" :
- "+c" (_cnt) : "D" (h + o), "a" (v) :
- "cc", "memory");
+ if (t == I386_BUS_SPACE_IO) {
+ __asm volatile("cld ;"
+ "1: outw %w2, %w1 ;"
+ " loop 1b" :
+ "+c" (_cnt) : "d" (h + o), "a" (v) :
+ "cc");
+ } else {
+ __asm volatile("cld ;"
+ "1: movw %w2, (%1) ;"
+ " loop 1b" :
+ "+c" (_cnt) : "D" (h + o), "a" (v) :
+ "cc", "memory");
+ }
}
void
-i386_bus_space_mem_set_multi_4(bus_space_handle_t h,
+bus_space_set_multi_4(bus_space_tag_t t, bus_space_handle_t h,
bus_size_t o, u_int32_t v, size_t cnt)
{
int _cnt = cnt;
- __asm volatile("cld ;"
- "1: movl %2,(%1) ;"
- " loop 1b" :
- "+c" (_cnt) : "D" (h + o), "a" (v) :
- "cc", "memory");
+ if (t == I386_BUS_SPACE_IO) {
+ __asm volatile("cld ;"
+ "1: outl %2,%w1 ;"
+ " loop 1b" :
+ "+c" (_cnt) : "d" (h + o), "a" (v) :
+ "cc");
+ } else {
+ __asm volatile("cld ;"
+ "1: movl %2,(%1) ;"
+ " loop 1b" :
+ "+c" (_cnt) : "D" (h + o), "a" (v) :
+ "cc", "memory");
+ }
}
void
-i386_bus_space_mem_set_region_1(bus_space_handle_t h,
+bus_space_set_region_1(bus_space_tag_t t, bus_space_handle_t h,
bus_size_t o, u_int8_t v, size_t cnt)
{
int _port = h + o;
int _cnt = cnt;
- __asm volatile("cld ;"
- " repne ;"
- " stosb" :
- "+D" (_port), "+c" (_cnt) : "a" (v) :
- "memory", "cc");
+ if (t == I386_BUS_SPACE_IO) {
+ __asm volatile(
+ "1: outb %%al,%w0 ;"
+ " incl %0 ;"
+ " loop 1b" :
+ "+d" (_port), "+c" (_cnt) : "a" (v) :
+ "cc");
+ } else {
+ __asm volatile("cld ;"
+ " repne ;"
+ " stosb" :
+ "+D" (_port), "+c" (_cnt) : "a" (v) :
+ "memory", "cc");
+ }
}
void
-i386_bus_space_mem_set_region_2(bus_space_handle_t h,
+bus_space_set_region_2(bus_space_tag_t t, bus_space_handle_t h,
bus_size_t o, u_int16_t v, size_t cnt)
{
int _port = h + o;
int _cnt = cnt;
- __asm volatile("cld ;"
- " repne ;"
- " stosw" :
- "+D" (_port), "+c" (_cnt) : "a" (v) :
- "memory", "cc");
+ if (t == I386_BUS_SPACE_IO) {
+ __asm volatile(
+ "1: outw %%ax,%w0 ;"
+ " addl $2, %0 ;"
+ " loop 1b" :
+ "+d" (_port), "+c" (_cnt) : "a" (v) :
+ "cc");
+ } else {
+ __asm volatile("cld ;"
+ " repne ;"
+ " stosw" :
+ "+D" (_port), "+c" (_cnt) : "a" (v) :
+ "memory", "cc");
+ }
}
void
-i386_bus_space_mem_set_region_4(bus_space_handle_t h,
+bus_space_set_region_4(bus_space_tag_t t, bus_space_handle_t h,
bus_size_t o, u_int32_t v, size_t cnt)
{
int _port = h + o;
int _cnt = cnt;
- __asm volatile("cld ;"
- " repne ;"
- " stosl" :
- "+D" (_port), "+c" (_cnt) : "a" (v) :
- "memory", "cc");
+ if (t == I386_BUS_SPACE_IO) {
+ __asm volatile(
+ "1: outl %%eax,%w0 ;"
+ " addl $4, %0 ;"
+ " loop 1b" :
+ "+d" (_port), "+c" (_cnt) : "a" (v) :
+ "cc");
+ } else {
+ __asm volatile("cld ;"
+ " repne ;"
+ " stosl" :
+ "+D" (_port), "+c" (_cnt) : "a" (v) :
+ "memory", "cc");
+ }
}
void
-i386_bus_space_mem_copy_1( bus_space_handle_t h1, bus_size_t o1,
+bus_space_copy_1(bus_space_tag_t t, bus_space_handle_t h1, bus_size_t o1,
bus_space_handle_t h2, bus_size_t o2, bus_size_t cnt)
{
int _port1 = h1 + o1;
int _port2 = h2 + o2;
int _cnt = cnt;
- i386_space_copy(_port1, _port2, 1, _cnt);
+ if (t == I386_BUS_SPACE_IO) {
+ __asm volatile(
+ "1: movl %k1,%%edx ;"
+ " inb %%dx,%%al ;"
+ " movl %k0,%%edx ;"
+ " outb %%al,%%dx ;"
+ " incl %0 ;"
+ " incl %1 ;"
+ " loop 1b" :
+ "+D" (_port2), "+S" (_port1), "+c" (_cnt) ::
+ "%edx", "%eax", "cc");
+ } else
+ i386_space_copy(_port1, _port2, 1, _cnt);
}
void
-i386_bus_space_mem_copy_2( bus_space_handle_t h1, bus_size_t o1,
+bus_space_copy_2(bus_space_tag_t t, bus_space_handle_t h1, bus_size_t o1,
bus_space_handle_t h2, bus_size_t o2, bus_size_t cnt)
{
int _port1 = h1 + o1;
int _port2 = h2 + o2;
int _cnt=cnt;
-
- i386_space_copy(_port1, _port2, 2, _cnt);
-}
-
-void
-i386_bus_space_mem_copy_4( bus_space_handle_t h1, bus_size_t o1,
+ if (t == I386_BUS_SPACE_IO) {
+ __asm volatile(
+ "1: movl %k1,%%edx ;"
+ " inw %%dx,%%ax ;"
+ " movl %k0,%%edx ;"
+ " outw %%ax,%%dx ;"
+ " addl $2, %0 ;"
+ " addl $2, %1 ;"
+ " loop 1b" :
+ "+D" (_port2), "+S" (_port1), "+c" (_cnt) ::
+ "%edx", "%eax", "cc");
+ } else
+ i386_space_copy(_port1, _port2, 2, _cnt);
+}
+
+void
+bus_space_copy_4(bus_space_tag_t t, bus_space_handle_t h1, bus_size_t o1,
bus_space_handle_t h2, bus_size_t o2, bus_size_t cnt)
{
int _port1 = h1 + o1;
int _port2 = h2 + o2;
int _cnt = cnt;
- i386_space_copy(_port1, _port2, 4, _cnt);
-}
-
-void *
-i386_bus_space_mem_vaddr(bus_space_handle_t h)
-{
- return ((void *)h);
-}
-
-paddr_t
-i386_bus_space_mem_mmap(bus_addr_t addr, off_t off, int prot, int flags)
-{
- /*
- * "addr" is the base address of the device we're mapping.
- * "off" is the offset into that device.
- *
- * Note we are called for each "page" in the device that
- * the upper layers want to map.
- */
- return (addr + off);
+ if (t == I386_BUS_SPACE_IO) {
+ __asm volatile(
+ "1: movl %k1,%%edx ;"
+ " inl %%dx,%%eax ;"
+ " movl %k0,%%edx ;"
+ " outl %%eax,%%dx ;"
+ " addl $4, %0 ;"
+ " addl $4, %1 ;"
+ " loop 1b" :
+ "+D" (_port2), "+S" (_port1), "+c" (_cnt) ::
+ "%edx", "%eax", "cc");
+ } else
+ i386_space_copy(_port1, _port2, 4, _cnt);
}
diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c
index f6f99419ffb..a3ae65a0389 100644
--- a/sys/arch/i386/i386/machdep.c
+++ b/sys/arch/i386/i386/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.553 2014/10/17 18:15:48 kettenis Exp $ */
+/* $OpenBSD: machdep.c,v 1.554 2014/10/17 19:35:32 sthen Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*-
@@ -3576,13 +3576,18 @@ bus_space_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, int flags,
/*
* Pick the appropriate extent map.
*/
- if (t == I386_BUS_SPACE_IO) {
+ switch (t) {
+ case I386_BUS_SPACE_IO:
ex = ioport_ex;
if (flags & BUS_SPACE_MAP_LINEAR)
return (EINVAL);
- } else if (t == I386_BUS_SPACE_MEM) {
+ break;
+
+ case I386_BUS_SPACE_MEM:
ex = iomem_ex;
- } else {
+ break;
+
+ default:
panic("bus_space_map: bad bus space tag");
}
@@ -3656,11 +3661,16 @@ bus_space_alloc(bus_space_tag_t t, bus_addr_t rstart, bus_addr_t rend,
/*
* Pick the appropriate extent map.
*/
- if (t == I386_BUS_SPACE_IO) {
+ switch (t) {
+ case I386_BUS_SPACE_IO:
ex = ioport_ex;
- } else if (t == I386_BUS_SPACE_MEM) {
+ break;
+
+ case I386_BUS_SPACE_MEM:
ex = iomem_ex;
- } else {
+ break;
+
+ default:
panic("bus_space_alloc: bad bus space tag");
}
diff --git a/sys/arch/i386/include/bus.h b/sys/arch/i386/include/bus.h
index 9e0ba199e98..2d92ce760d5 100644
--- a/sys/arch/i386/include/bus.h
+++ b/sys/arch/i386/include/bus.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bus.h,v 1.62 2014/10/17 01:46:26 dlg Exp $ */
+/* $OpenBSD: bus.h,v 1.63 2014/10/17 19:35:32 sthen Exp $ */
/* $NetBSD: bus.h,v 1.6 1996/11/10 03:19:25 thorpej Exp $ */
/*-
@@ -72,6 +72,12 @@
#include <machine/pio.h>
/*
+ * Values for the i386 bus space tag, not to be used directly by MI code.
+ */
+#define I386_BUS_SPACE_IO 0 /* space is i/o space */
+#define I386_BUS_SPACE_MEM 1 /* space is mem space */
+
+/*
* Bus address and size types
*/
typedef u_long bus_addr_t;
@@ -80,8 +86,7 @@ typedef u_long bus_size_t;
/*
* Access methods for bus resources and address space.
*/
-struct i386_bus_space_ops;
-typedef const struct i386_bus_space_ops *bus_space_tag_t;
+typedef int bus_space_tag_t;
typedef u_long bus_space_handle_t;
int bus_space_map(bus_space_tag_t t, bus_addr_t addr,
@@ -105,8 +110,6 @@ int bus_space_alloc(bus_space_tag_t t, bus_addr_t rstart,
void bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh,
bus_size_t size);
-struct i386_bus_space_ops {
-
/*
* u_intN_t bus_space_read_N(bus_space_tag_t tag,
* bus_space_handle_t bsh, bus_size_t offset);
@@ -114,13 +117,14 @@ struct i386_bus_space_ops {
* Read a 1, 2, 4, or 8 byte quantity from bus space
* described by tag/handle/offset.
*/
- u_int8_t (*read_1)(bus_space_handle_t, bus_size_t);
- u_int16_t (*read_2)(bus_space_handle_t, bus_size_t);
- u_int32_t (*read_4)(bus_space_handle_t, bus_size_t);
+u_int8_t bus_space_read_1(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t);
-#define bus_space_read_1(_t, _h, _o) ((_t)->read_1((_h), (_o)))
-#define bus_space_read_2(_t, _h, _o) ((_t)->read_2((_h), (_o)))
-#define bus_space_read_4(_t, _h, _o) ((_t)->read_4((_h), (_o)))
+u_int16_t bus_space_read_2(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t);
+
+u_int32_t bus_space_read_4(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t);
#define bus_space_read_raw_2(t, h, o) \
bus_space_read_2((t), (h), (o))
@@ -142,19 +146,17 @@ struct i386_bus_space_ops {
* described by tag/handle/offset and copy into buffer provided.
*/
- void (*read_multi_1)(bus_space_handle_t, bus_size_t,
- u_int8_t *, bus_size_t);
- void (*read_multi_2)(bus_space_handle_t, bus_size_t,
- u_int16_t *, bus_size_t);
- void (*read_multi_4)(bus_space_handle_t, bus_size_t,
- u_int32_t *, bus_size_t);
+#define bus_space_read_raw_multi_2(t, h, o, a, c) \
+ bus_space_read_multi_2((t), (h), (o), (u_int16_t *)(a), (c) >> 1)
+#define bus_space_read_raw_multi_4(t, h, o, a, c) \
+ bus_space_read_multi_4((t), (h), (o), (u_int32_t *)(a), (c) >> 2)
-#define bus_space_read_multi_1(_t, _h, _o, _a, _c) \
- ((_t)->read_multi_1((_h), (_o), (_a), (_c)))
-#define bus_space_read_multi_2(_t, _h, _o, _a, _c) \
- ((_t)->read_multi_2((_h), (_o), (_a), (_c)))
-#define bus_space_read_multi_4(_t, _h, _o, _a, _c) \
- ((_t)->read_multi_4((_h), (_o), (_a), (_c)))
+void bus_space_read_multi_1(bus_space_tag_t, bus_space_handle_t, bus_size_t,
+ u_int8_t *, bus_size_t);
+void bus_space_read_multi_2(bus_space_tag_t, bus_space_handle_t, bus_size_t,
+ u_int16_t *, bus_size_t);
+void bus_space_read_multi_4(bus_space_tag_t, bus_space_handle_t, bus_size_t,
+ u_int32_t *, bus_size_t);
#if 0 /* Cause a link error for bus_space_read_multi_8 */
#define bus_space_read_multi_8 !!! bus_space_read_multi_8 unimplemented !!!
@@ -191,19 +193,12 @@ struct i386_bus_space_ops {
* buffer provided.
*/
- void (*read_region_1)(bus_space_handle_t,
- bus_size_t, u_int8_t *, bus_size_t);
- void (*read_region_2)(bus_space_handle_t,
- bus_size_t, u_int16_t *, bus_size_t);
- void (*read_region_4)(bus_space_handle_t,
- bus_size_t, u_int32_t *, bus_size_t);
-
-#define bus_space_read_region_1(_t, _h, _o, _a, _c) \
- ((_t)->read_region_1((_h), (_o), (_a), (_c)))
-#define bus_space_read_region_2(_t, _h, _o, _a, _c) \
- ((_t)->read_region_2((_h), (_o), (_a), (_c)))
-#define bus_space_read_region_4(_t, _h, _o, _a, _c) \
- ((_t)->read_region_4((_h), (_o), (_a), (_c)))
+void bus_space_read_region_1(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int8_t *, bus_size_t);
+void bus_space_read_region_2(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int16_t *, bus_size_t);
+void bus_space_read_region_4(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int32_t *, bus_size_t);
#if 0 /* Cause a link error for bus_space_read_region_8 */
#define bus_space_read_region_8 !!! bus_space_read_region_8 unimplemented !!!
@@ -221,10 +216,10 @@ struct i386_bus_space_ops {
* these functions.
*/
-#define bus_space_read_raw_region_2(_t, _h, _o, _a, _c) \
- ((_t)->read_region_2((_h), (_o), (u_int16_t *)(_a), (_c) >> 1))
-#define bus_space_read_raw_region_4(_t, _h, _o, _a, _c) \
- ((_t)->read_region_4((_h), (_o), (u_int32_t *)(_a), (_c) >> 2))
+#define bus_space_read_raw_region_2(t, h, o, a, c) \
+ bus_space_read_region_2((t), (h), (o), (u_int16_t *)(a), (c) >> 1)
+#define bus_space_read_raw_region_4(t, h, o, a, c) \
+ bus_space_read_region_4((t), (h), (o), (u_int32_t *)(a), (c) >> 2)
#if 0 /* Cause a link error for bus_space_read_raw_region_8 */
#define bus_space_read_raw_region_8 \
@@ -240,16 +235,12 @@ struct i386_bus_space_ops {
* described by tag/handle/offset.
*/
- void (*write_1)(bus_space_handle_t, bus_size_t, u_int8_t);
- void (*write_2)(bus_space_handle_t, bus_size_t, u_int16_t);
- void (*write_4)(bus_space_handle_t, bus_size_t, u_int32_t);
-
-#define bus_space_write_1(_t, _h, _o, _v) \
- ((_t)->write_1((_h), (_o), (_v)))
-#define bus_space_write_2(_t, _h, _o, _v) \
- ((_t)->write_2((_h), (_o), (_v)))
-#define bus_space_write_4(_t, _h, _o, _v) \
- ((_t)->write_4((_h), (_o), (_v)))
+void bus_space_write_1(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int8_t);
+void bus_space_write_2(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int16_t);
+void bus_space_write_4(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int32_t);
#define bus_space_write_raw_2(t, h, o, v) \
bus_space_write_2((t), (h), (o), (v))
@@ -271,19 +262,12 @@ struct i386_bus_space_ops {
* provided to bus space described by tag/handle/offset.
*/
- void (*write_multi_1)(bus_space_handle_t,
- bus_size_t, const u_int8_t *, bus_size_t);
- void (*write_multi_2)(bus_space_handle_t,
- bus_size_t, const u_int16_t *, bus_size_t);
- void (*write_multi_4)(bus_space_handle_t,
- bus_size_t, const u_int32_t *, bus_size_t);
-
-#define bus_space_write_multi_1(_t, _h, _o, _a, _c) \
- ((_t)->write_multi_1((_h), (_o), (_a), (_c)))
-#define bus_space_write_multi_2(_t, _h, _o, _a, _c) \
- ((_t)->write_multi_2((_h), (_o), (_a), (_c)))
-#define bus_space_write_multi_4(_t, _h, _o, _a, _c) \
- ((_t)->write_multi_4((_h), (_o), (_a), (_c)))
+void bus_space_write_multi_1(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, const u_int8_t *, bus_size_t);
+void bus_space_write_multi_2(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, const u_int16_t *, bus_size_t);
+void bus_space_write_multi_4(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, const u_int32_t *, bus_size_t);
#if 0 /* Cause a link error for bus_space_write_multi_8 */
#define bus_space_write_multi_8(t, h, o, a, c) \
@@ -301,10 +285,10 @@ struct i386_bus_space_ops {
* possible byte-swapping should be done by these functions.
*/
-#define bus_space_write_raw_multi_2(_t, _h, _o, _a, _c) \
- ((_t)->write_multi_2((_h), (_o), (const u_int16_t *)(_a), (_c) >> 1))
-#define bus_space_write_raw_multi_4(_t, _h, _o, _a, _c) \
- ((_t)->write_multi_4((_h), (_o), (const u_int32_t *)(_a), (_c) >> 2))
+#define bus_space_write_raw_multi_2(t, h, o, a, c) \
+ bus_space_write_multi_2((t), (h), (o), (const u_int16_t *)(a), (c) >> 1)
+#define bus_space_write_raw_multi_4(t, h, o, a, c) \
+ bus_space_write_multi_4((t), (h), (o), (const u_int32_t *)(a), (c) >> 2)
#if 0 /* Cause a link error for bus_space_write_raw_multi_8 */
#define bus_space_write_raw_multi_8 \
@@ -320,19 +304,12 @@ struct i386_bus_space_ops {
* to bus space described by tag/handle starting at `offset'.
*/
- void (*write_region_1)(bus_space_handle_t,
- bus_size_t, const u_int8_t *, bus_size_t);
- void (*write_region_2)(bus_space_handle_t,
- bus_size_t, const u_int16_t *, bus_size_t);
- void (*write_region_4)(bus_space_handle_t,
- bus_size_t, const u_int32_t *, bus_size_t);
-
-#define bus_space_write_region_1(_t, _h, _o, _a, _c) \
- ((_t)->write_region_1((_h), (_o), (_a), (_c)))
-#define bus_space_write_region_2(_t, _h, _o, _a, _c) \
- ((_t)->write_region_2((_h), (_o), (_a), (_c)))
-#define bus_space_write_region_4(_t, _h, _o, _a, _c) \
- ((_t)->write_region_4((_h), (_o), (_a), (_c)))
+void bus_space_write_region_1(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, const u_int8_t *, bus_size_t);
+void bus_space_write_region_2(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, const u_int16_t *, bus_size_t);
+void bus_space_write_region_4(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, const u_int32_t *, bus_size_t);
#if 0 /* Cause a link error for bus_space_write_region_8 */
#define bus_space_write_region_8 \
@@ -351,10 +328,10 @@ struct i386_bus_space_ops {
* these functions.
*/
-#define bus_space_write_raw_region_2(_t, _h, _o, _a, _c) \
- ((_t)->write_region_2((_h), (_o), (const u_int16_t *)(_a), (_c) >> 1))
-#define bus_space_write_raw_region_4(_t, _h, _o, _a, _c) \
- ((_t)->write_region_4((_h), (_o), (const u_int32_t *)(_a), (_c) >> 2))
+#define bus_space_write_raw_region_2(t, h, o, a, c) \
+ bus_space_write_region_2((t), (h), (o), (const u_int16_t *)(a), (c) >> 1)
+#define bus_space_write_raw_region_4(t, h, o, a, c) \
+ bus_space_write_region_4((t), (h), (o), (const u_int32_t *)(a), (c) >> 2)
#if 0 /* Cause a link error for bus_space_write_raw_region_8 */
#define bus_space_write_raw_region_8 \
@@ -370,19 +347,12 @@ struct i386_bus_space_ops {
* by tag/handle/offset `count' times.
*/
- void (*set_multi_1)(bus_space_handle_t,
- bus_size_t, u_int8_t, size_t);
- void (*set_multi_2)(bus_space_handle_t,
- bus_size_t, u_int16_t, size_t);
- void (*set_multi_4)(bus_space_handle_t,
- bus_size_t, u_int32_t, size_t);
-
-#define bus_space_set_multi_1(_t, _h, _o, _a, _c) \
- ((_t)->set_multi_1((_h), (_o), (_a), (_c)))
-#define bus_space_set_multi_2(_t, _h, _o, _a, _c) \
- ((_t)->set_multi_2((_h), (_o), (_a), (_c)))
-#define bus_space_set_multi_4(_t, _h, _o, _a, _c) \
- ((_t)->set_multi_4((_h), (_o), (_a), (_c)))
+void bus_space_set_multi_1(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int8_t, size_t);
+void bus_space_set_multi_2(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int16_t, size_t);
+void bus_space_set_multi_4(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int32_t, size_t);
#if 0 /* Cause a link error for bus_space_set_multi_8 */
#define bus_space_set_multi_8 \
@@ -397,20 +367,13 @@ struct i386_bus_space_ops {
* Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
* by tag/handle starting at `offset'.
*/
+void bus_space_set_region_1(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int8_t, size_t);
+void bus_space_set_region_2(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int16_t, size_t);
+void bus_space_set_region_4(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int32_t, size_t);
- void (*set_region_1)(bus_space_handle_t,
- bus_size_t, u_int8_t, size_t);
- void (*set_region_2)(bus_space_handle_t,
- bus_size_t, u_int16_t, size_t);
- void (*set_region_4)(bus_space_handle_t,
- bus_size_t, u_int32_t, size_t);
-
-#define bus_space_set_region_1(_t, _h, _o, _a, _c) \
- ((_t)->set_region_1((_h), (_o), (_a), (_c)))
-#define bus_space_set_region_2(_t, _h, _o, _a, _c) \
- ((_t)->set_region_2((_h), (_o), (_a), (_c)))
-#define bus_space_set_region_4(_t, _h, _o, _a, _c) \
- ((_t)->set_region_4((_h), (_o), (_a), (_c)))
#if 0 /* Cause a link error for bus_space_set_region_8 */
#define bus_space_set_region_8 \
@@ -427,19 +390,12 @@ struct i386_bus_space_ops {
* at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
*/
- void (*copy_1)(bus_space_handle_t,
- bus_size_t, bus_space_handle_t, bus_size_t, size_t);
- void (*copy_2)(bus_space_handle_t,
- bus_size_t, bus_space_handle_t, bus_size_t, size_t);
- void (*copy_4)(bus_space_handle_t,
- bus_size_t, bus_space_handle_t, bus_size_t, size_t);
-
-#define bus_space_copy_1(_t, _h1, _o1, _h2, _o2, _c) \
- ((_t)->copy_1((_h1), (_o1), (_h2), (_o2), (_c)))
-#define bus_space_copy_2(_t, _h1, _o1, _h2, _o2, _c) \
- ((_t)->copy_2((_h1), (_o1), (_h2), (_o2), (_c)))
-#define bus_space_copy_4(_t, _h1, _o1, _h2, _o2, _c) \
- ((_t)->copy_4((_h1), (_o1), (_h2), (_o2), (_c)))
+void bus_space_copy_1(bus_space_tag_t, bus_space_handle_t, bus_size_t,
+ bus_space_handle_t, bus_size_t, bus_size_t);
+void bus_space_copy_2(bus_space_tag_t, bus_space_handle_t, bus_size_t,
+ bus_space_handle_t, bus_size_t, bus_size_t);
+void bus_space_copy_4(bus_space_tag_t, bus_space_handle_t, bus_size_t,
+ bus_space_handle_t, bus_size_t, bus_size_t);
#if 0 /* Cause a link error for bus_space_copy_8 */
#define bus_space_copy_8 \
@@ -467,18 +423,6 @@ struct i386_bus_space_ops {
} while (0)
/*
- * 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.
- */
- void * (*vaddr)(bus_space_handle_t);
-
-#define bus_space_vaddr(_t, _h) \
- ((_t)->vaddr((_h)))
-};
-
-/*
* Bus read/write barrier methods.
*
* void bus_space_barrier(bus_space_tag_t tag,
@@ -500,16 +444,13 @@ struct i386_bus_space_ops {
#define BUS_SPACE_MAP_PREFETCHABLE 0x0008
/*
- * Values for the i386 bus space tag, not to be used directly by MI code.
+ * 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.
*/
-
-/* space is i/o space */
-extern const struct i386_bus_space_ops i386_bus_space_io_ops;
-#define I386_BUS_SPACE_IO (&i386_bus_space_io_ops)
-
-/* space is mem space */
-extern const struct i386_bus_space_ops i386_bus_space_mem_ops;
-#define I386_BUS_SPACE_MEM (&i386_bus_space_mem_ops)
+#define bus_space_vaddr(t, h) \
+ ((t) == I386_BUS_SPACE_IO ? (void *)(NULL) : (void *)(h))
/*
* Flags used in various bus DMA methods.