summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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, 823 insertions, 411 deletions
diff --git a/sys/arch/i386/i386/bus_space.c b/sys/arch/i386/i386/bus_space.c
index 83454b80c95..6573180a6a0 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.5 2014/03/29 18:09:29 guenther Exp $ */
+/* $OpenBSD: bus_space.c,v 1.6 2014/10/17 01:46:26 dlg Exp $ */
/*-
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -68,486 +68,849 @@
#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
-bus_space_read_1(bus_space_tag_t t, bus_space_handle_t h,
- bus_size_t o)
+i386_bus_space_io_read_1(bus_space_handle_t h, bus_size_t o)
{
- return ((t) == I386_BUS_SPACE_IO ? (inb((h) + (o))) :
- (*(volatile u_int8_t *)((h) + (o))));
+ return (inb(h + o));
}
u_int16_t
-bus_space_read_2(bus_space_tag_t t, bus_space_handle_t h,
- bus_size_t o)
+i386_bus_space_io_read_2(bus_space_handle_t h, bus_size_t o)
{
- return ((t) == I386_BUS_SPACE_IO ? (inw((h) + (o))) :
- (*(volatile u_int16_t *)((h) + (o))));
+ return (inw(h + o));
}
u_int32_t
-bus_space_read_4(bus_space_tag_t t, bus_space_handle_t h,
- bus_size_t o)
+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)
{
- return ((t) == I386_BUS_SPACE_IO ? (inl((h) + (o))) :
- (*(volatile u_int32_t *)((h) + (o))));
+ return (NULL);
}
+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
-bus_space_read_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
+i386_bus_space_mem_read_multi_1(bus_space_handle_t h, bus_size_t o,
u_int8_t *a, bus_size_t cnt)
{
- 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 *_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
-bus_space_read_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
+i386_bus_space_mem_read_multi_2(bus_space_handle_t h, bus_size_t o,
u_int16_t *a, bus_size_t cnt)
{
- 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,
+ 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,
u_int32_t *a, bus_size_t cnt)
{
- 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 *_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
-bus_space_read_region_1(bus_space_tag_t t, bus_space_handle_t h,
+i386_bus_space_mem_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;
- 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);
+ i386_space_copy(_port, _addr, 1, _cnt);
}
void
-bus_space_read_region_2(bus_space_tag_t t, bus_space_handle_t h,
+i386_bus_space_mem_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;
- 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);
+ i386_space_copy(_port, _addr, 2, _cnt);
}
void
-bus_space_read_region_4(bus_space_tag_t t, bus_space_handle_t h,
+i386_bus_space_mem_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;
- 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);
+ i386_space_copy(_port, _addr, 4, _cnt);
}
void
-bus_space_write_1(bus_space_tag_t t, bus_space_handle_t h,
- bus_size_t o, u_int8_t v)
+i386_bus_space_mem_write_1(bus_space_handle_t h, bus_size_t o, u_int8_t v)
{
- if (t == I386_BUS_SPACE_IO)
- outb(h + o, v);
- else
- ((void)(*(volatile u_int8_t *)(h + o) = v));
+ ((void)(*(volatile u_int8_t *)(h + o) = v));
}
void
-bus_space_write_2(bus_space_tag_t t, bus_space_handle_t h,
- bus_size_t o, u_int16_t v)
+i386_bus_space_mem_write_2(bus_space_handle_t h, bus_size_t o, u_int16_t v)
{
- if ((t) == I386_BUS_SPACE_IO)
- outw(h + o, v);
- else
- ((void)(*(volatile u_int16_t *)(h + o) = v));
+ ((void)(*(volatile u_int16_t *)(h + o) = v));
}
void
-bus_space_write_4(bus_space_tag_t t, bus_space_handle_t h,
- bus_size_t o, u_int32_t v)
+i386_bus_space_mem_write_4(bus_space_handle_t h, bus_size_t o, u_int32_t v)
{
- if ((t) == I386_BUS_SPACE_IO)
- outl(h + o, v);
- else
- ((void)(*(volatile u_int32_t *)(h + o) = v));
+ ((void)(*(volatile u_int32_t *)(h + o) = v));
}
void
-bus_space_write_multi_1(bus_space_tag_t t, bus_space_handle_t h,
+i386_bus_space_mem_write_multi_1(bus_space_handle_t h,
bus_size_t o, const u_int8_t *a, bus_size_t cnt)
{
- if (t == I386_BUS_SPACE_IO) {
- outsb(h + o, a, cnt);
- } else {
- const void *_addr=a;
- int _cnt=cnt;
+ 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
-bus_space_write_multi_2(bus_space_tag_t t, bus_space_handle_t h,
+i386_bus_space_mem_write_multi_2(bus_space_handle_t h,
bus_size_t o, const u_int16_t *a, bus_size_t cnt)
{
- if (t == I386_BUS_SPACE_IO) {
- outsw(h + o, a, cnt);
- } else {
- const void *_addr = a;
- int _cnt = cnt;
+ 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
-bus_space_write_multi_4(bus_space_tag_t t, bus_space_handle_t h,
+i386_bus_space_mem_write_multi_4(bus_space_handle_t h,
bus_size_t o, const u_int32_t *a, bus_size_t cnt)
{
- if (t == I386_BUS_SPACE_IO) {
- outsl(h + o, a, cnt);
- } else {
- const void *_addr=a;
- int _cnt=cnt;
+ 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
-bus_space_write_region_1(bus_space_tag_t t, bus_space_handle_t h,
+i386_bus_space_mem_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;
- 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);
+ i386_space_copy(_addr, _port, 1, _cnt);
}
void
-bus_space_write_region_2(bus_space_tag_t t, bus_space_handle_t h,
+i386_bus_space_mem_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;
- 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);
+ i386_space_copy(_addr, _port, 2, _cnt);
}
void
-bus_space_write_region_4(bus_space_tag_t t, bus_space_handle_t h,
+i386_bus_space_mem_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;
- 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);
+ i386_space_copy(_addr, _port, 4, _cnt);
}
void
-bus_space_set_multi_1(bus_space_tag_t t, bus_space_handle_t h,
+i386_bus_space_mem_set_multi_1(bus_space_handle_t h,
bus_size_t o, u_int8_t v, size_t cnt)
{
int _cnt = cnt;
- 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");
- }
+ __asm volatile("cld ;"
+ "1: movb %b2, (%1) ;"
+ " loop 1b" :
+ "+c" (_cnt) : "D" (h + o), "a" (v) :
+ "cc", "memory");
}
void
-bus_space_set_multi_2(bus_space_tag_t t, bus_space_handle_t h,
+i386_bus_space_mem_set_multi_2(bus_space_handle_t h,
bus_size_t o, u_int16_t v, size_t cnt)
{
int _cnt = cnt;
- 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");
- }
+ __asm volatile("cld ;"
+ "1: movw %w2, (%1) ;"
+ " loop 1b" :
+ "+c" (_cnt) : "D" (h + o), "a" (v) :
+ "cc", "memory");
}
void
-bus_space_set_multi_4(bus_space_tag_t t, bus_space_handle_t h,
+i386_bus_space_mem_set_multi_4(bus_space_handle_t h,
bus_size_t o, u_int32_t v, size_t cnt)
{
int _cnt = cnt;
- 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");
- }
+ __asm volatile("cld ;"
+ "1: movl %2,(%1) ;"
+ " loop 1b" :
+ "+c" (_cnt) : "D" (h + o), "a" (v) :
+ "cc", "memory");
}
void
-bus_space_set_region_1(bus_space_tag_t t, bus_space_handle_t h,
+i386_bus_space_mem_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;
- 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");
- }
+ __asm volatile("cld ;"
+ " repne ;"
+ " stosb" :
+ "+D" (_port), "+c" (_cnt) : "a" (v) :
+ "memory", "cc");
}
void
-bus_space_set_region_2(bus_space_tag_t t, bus_space_handle_t h,
+i386_bus_space_mem_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;
- 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");
- }
+ __asm volatile("cld ;"
+ " repne ;"
+ " stosw" :
+ "+D" (_port), "+c" (_cnt) : "a" (v) :
+ "memory", "cc");
}
void
-bus_space_set_region_4(bus_space_tag_t t, bus_space_handle_t h,
+i386_bus_space_mem_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;
- 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");
- }
+ __asm volatile("cld ;"
+ " repne ;"
+ " stosl" :
+ "+D" (_port), "+c" (_cnt) : "a" (v) :
+ "memory", "cc");
}
void
-bus_space_copy_1(bus_space_tag_t t, bus_space_handle_t h1, bus_size_t o1,
+i386_bus_space_mem_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;
- 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);
+ i386_space_copy(_port1, _port2, 1, _cnt);
}
void
-bus_space_copy_2(bus_space_tag_t t, bus_space_handle_t h1, bus_size_t o1,
+i386_bus_space_mem_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;
- 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,
+
+ i386_space_copy(_port1, _port2, 2, _cnt);
+}
+
+void
+i386_bus_space_mem_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;
- 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);
+ 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);
}
diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c
index 739614f811c..4c3c9faf28b 100644
--- a/sys/arch/i386/i386/machdep.c
+++ b/sys/arch/i386/i386/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.551 2014/09/19 20:02:25 kettenis Exp $ */
+/* $OpenBSD: machdep.c,v 1.552 2014/10/17 01:46:26 dlg Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*-
@@ -3574,18 +3574,13 @@ bus_space_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, int flags,
/*
* Pick the appropriate extent map.
*/
- switch (t) {
- case I386_BUS_SPACE_IO:
+ if (t == I386_BUS_SPACE_IO) {
ex = ioport_ex;
if (flags & BUS_SPACE_MAP_LINEAR)
return (EINVAL);
- break;
-
- case I386_BUS_SPACE_MEM:
+ } else if (t == I386_BUS_SPACE_MEM) {
ex = iomem_ex;
- break;
-
- default:
+ } else {
panic("bus_space_map: bad bus space tag");
}
@@ -3659,16 +3654,11 @@ bus_space_alloc(bus_space_tag_t t, bus_addr_t rstart, bus_addr_t rend,
/*
* Pick the appropriate extent map.
*/
- switch (t) {
- case I386_BUS_SPACE_IO:
+ if (t == I386_BUS_SPACE_IO) {
ex = ioport_ex;
- break;
-
- case I386_BUS_SPACE_MEM:
+ } else if (t == I386_BUS_SPACE_MEM) {
ex = iomem_ex;
- break;
-
- default:
+ } else {
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 891a2c23a77..9e0ba199e98 100644
--- a/sys/arch/i386/include/bus.h
+++ b/sys/arch/i386/include/bus.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bus.h,v 1.61 2014/03/29 18:09:29 guenther Exp $ */
+/* $OpenBSD: bus.h,v 1.62 2014/10/17 01:46:26 dlg Exp $ */
/* $NetBSD: bus.h,v 1.6 1996/11/10 03:19:25 thorpej Exp $ */
/*-
@@ -72,12 +72,6 @@
#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;
@@ -86,7 +80,8 @@ typedef u_long bus_size_t;
/*
* Access methods for bus resources and address space.
*/
-typedef int bus_space_tag_t;
+struct i386_bus_space_ops;
+typedef const struct i386_bus_space_ops *bus_space_tag_t;
typedef u_long bus_space_handle_t;
int bus_space_map(bus_space_tag_t t, bus_addr_t addr,
@@ -110,6 +105,8 @@ 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);
@@ -117,14 +114,13 @@ void bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh,
* Read a 1, 2, 4, or 8 byte quantity from bus space
* described by tag/handle/offset.
*/
-u_int8_t bus_space_read_1(bus_space_tag_t, bus_space_handle_t,
- bus_size_t);
+ 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_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_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)))
#define bus_space_read_raw_2(t, h, o) \
bus_space_read_2((t), (h), (o))
@@ -146,17 +142,19 @@ u_int32_t bus_space_read_4(bus_space_tag_t, bus_space_handle_t,
* described by tag/handle/offset and copy into buffer provided.
*/
-#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)
+ 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);
-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);
+#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)))
#if 0 /* Cause a link error for bus_space_read_multi_8 */
#define bus_space_read_multi_8 !!! bus_space_read_multi_8 unimplemented !!!
@@ -193,12 +191,19 @@ void bus_space_read_multi_4(bus_space_tag_t, bus_space_handle_t, bus_size_t,
* buffer provided.
*/
-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);
+ 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)))
#if 0 /* Cause a link error for bus_space_read_region_8 */
#define bus_space_read_region_8 !!! bus_space_read_region_8 unimplemented !!!
@@ -216,10 +221,10 @@ void bus_space_read_region_4(bus_space_tag_t, bus_space_handle_t,
* these functions.
*/
-#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)
+#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))
#if 0 /* Cause a link error for bus_space_read_raw_region_8 */
#define bus_space_read_raw_region_8 \
@@ -235,12 +240,16 @@ void bus_space_read_region_4(bus_space_tag_t, bus_space_handle_t,
* described by tag/handle/offset.
*/
-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);
+ 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)))
#define bus_space_write_raw_2(t, h, o, v) \
bus_space_write_2((t), (h), (o), (v))
@@ -262,12 +271,19 @@ void bus_space_write_4(bus_space_tag_t, bus_space_handle_t,
* provided to bus space described by tag/handle/offset.
*/
-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);
+ 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)))
#if 0 /* Cause a link error for bus_space_write_multi_8 */
#define bus_space_write_multi_8(t, h, o, a, c) \
@@ -285,10 +301,10 @@ void bus_space_write_multi_4(bus_space_tag_t, bus_space_handle_t,
* possible byte-swapping should be done by these functions.
*/
-#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)
+#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))
#if 0 /* Cause a link error for bus_space_write_raw_multi_8 */
#define bus_space_write_raw_multi_8 \
@@ -304,12 +320,19 @@ void bus_space_write_multi_4(bus_space_tag_t, bus_space_handle_t,
* to bus space described by tag/handle starting at `offset'.
*/
-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);
+ 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)))
#if 0 /* Cause a link error for bus_space_write_region_8 */
#define bus_space_write_region_8 \
@@ -328,10 +351,10 @@ void bus_space_write_region_4(bus_space_tag_t, bus_space_handle_t,
* these functions.
*/
-#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)
+#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))
#if 0 /* Cause a link error for bus_space_write_raw_region_8 */
#define bus_space_write_raw_region_8 \
@@ -347,12 +370,19 @@ void bus_space_write_region_4(bus_space_tag_t, bus_space_handle_t,
* by tag/handle/offset `count' times.
*/
-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);
+ 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)))
#if 0 /* Cause a link error for bus_space_set_multi_8 */
#define bus_space_set_multi_8 \
@@ -367,13 +397,20 @@ void bus_space_set_multi_4(bus_space_tag_t, bus_space_handle_t,
* 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 \
@@ -390,12 +427,19 @@ void bus_space_set_region_4(bus_space_tag_t, bus_space_handle_t,
* at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
*/
-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);
+ 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)))
#if 0 /* Cause a link error for bus_space_copy_8 */
#define bus_space_copy_8 \
@@ -423,6 +467,18 @@ void bus_space_copy_4(bus_space_tag_t, bus_space_handle_t, bus_size_t,
} 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,
@@ -444,13 +500,16 @@ void bus_space_copy_4(bus_space_tag_t, bus_space_handle_t, bus_size_t,
#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.
+ * Values for the i386 bus space tag, not to be used directly by MI code.
*/
-#define bus_space_vaddr(t, h) \
- ((t) == I386_BUS_SPACE_IO ? (void *)(NULL) : (void *)(h))
+
+/* 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)
/*
* Flags used in various bus DMA methods.