summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--etc/mtree/4.4BSD.dist6
-rw-r--r--lib/libarch/alpha/Makefile30
-rw-r--r--lib/libarch/alpha/bwx.c263
-rw-r--r--lib/libarch/alpha/io.c187
-rw-r--r--lib/libarch/alpha/io.h49
-rw-r--r--lib/libarch/alpha/libalpha.2133
6 files changed, 667 insertions, 1 deletions
diff --git a/etc/mtree/4.4BSD.dist b/etc/mtree/4.4BSD.dist
index 41586ac51ca..c9502d1cc87 100644
--- a/etc/mtree/4.4BSD.dist
+++ b/etc/mtree/4.4BSD.dist
@@ -1,4 +1,4 @@
-# $OpenBSD: 4.4BSD.dist,v 1.130 2002/06/11 17:15:13 beck Exp $
+# $OpenBSD: 4.4BSD.dist,v 1.131 2002/07/07 14:24:04 matthieu Exp $
/set type=dir uname=root gname=wheel mode=0755
# .
@@ -1094,6 +1094,10 @@ vax
# ./usr/share/man/cat2
cat2
+# ./usr/share/man/cat2/alpha
+alpha
+..
+
# ./usr/share/man/cat2/i386
i386
diff --git a/lib/libarch/alpha/Makefile b/lib/libarch/alpha/Makefile
new file mode 100644
index 00000000000..1e6585314f6
--- /dev/null
+++ b/lib/libarch/alpha/Makefile
@@ -0,0 +1,30 @@
+# $FreeBSD: src/lib/libio/Makefile,v 1.2 1999/08/28 00:04:42 peter Exp $
+# $OpenBSD: Makefile,v 1.5 2002/07/07 14:24:04 matthieu Exp $
+
+NOPIC=
+SRCS= io.c bwx.c
+
+CFLAGS+= -Wall -Wno-uninitialized -Wa,-mev56
+
+MAN= libalpha.2
+
+MLINKS+= libalpha.2 dense_base.2 \
+ libalpha.2 inb.2 \
+ libalpha.2 inl.2 \
+ libalpha.2 inw.2 \
+ libalpha.2 ioperm.2 \
+ libalpha.2 map_memory.2 \
+ libalpha.2 outb.2 \
+ libalpha.2 outl.2 \
+ libalpha.2 outw.2 \
+ libalpha.2 readb.2 \
+ libalpha.2 readl.2 \
+ libalpha.2 readw.2 \
+ libalpha.2 unmap_memory.2 \
+ libalpha.2 writeb.2 \
+ libalpha.2 writel.2 \
+ libalpha.2 writew.2
+
+MANSUBDIR=alpha
+
+.include <bsd.lib.mk>
diff --git a/lib/libarch/alpha/bwx.c b/lib/libarch/alpha/bwx.c
new file mode 100644
index 00000000000..1eaa67f8359
--- /dev/null
+++ b/lib/libarch/alpha/bwx.c
@@ -0,0 +1,263 @@
+/* $OpenBSD: bwx.c,v 1.1 2002/07/07 14:24:04 matthieu Exp $ */
+/*-
+ * Copyright (c) 1998 Doug Rabson
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+
+#define vm_page_size (sysconf(_SC_PAGESIZE)) /* XXX */
+#include <sys/param.h>
+#include <sys/mman.h>
+#include <sys/fcntl.h>
+#include <sys/sysctl.h>
+#include <err.h>
+#include <paths.h>
+#include <machine/bwx.h>
+#include <machine/sysarch.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "io.h"
+
+#define mb() __asm__ __volatile__("mb" : : : "memory")
+#define wmb() __asm__ __volatile__("wmb" : : : "memory")
+
+static int mem_fd; /* file descriptor to /dev/mem */
+static void *bwx_int1_ports; /* mapped int1 io ports */
+static void *bwx_int2_ports; /* mapped int2 io ports */
+static void *bwx_int4_ports; /* mapped int4 io ports */
+static u_int64_t bwx_io_base; /* physical address of ports */
+static u_int64_t bwx_mem_base; /* physical address of bwx mem */
+
+static void
+bwx_init(void)
+{
+ size_t len = sizeof(u_int64_t);
+ int error;
+ int mib[3];
+
+ mem_fd = open(_PATH_MEM, O_RDWR);
+ if (mem_fd < 0)
+ err(1, _PATH_MEM);
+
+ mib[0] = CTL_MACHDEP;
+ mib[1] = CPU_CHIPSET;
+ mib[2] = CPU_CHIPSET_PORTS;
+ if ((error = sysctl(mib, 3, &bwx_io_base, &len, NULL, 0)) < 0)
+ err(1, "machdep.chipset.ports_base");
+ mib[2] = CPU_CHIPSET_MEM;
+ if ((error = sysctl(mib, 3, &bwx_mem_base, &len, 0, 0)) < 0)
+ err(1, "machdep.chipset.memory");
+}
+
+static int
+bwx_ioperm(u_int32_t from, u_int32_t num, int on)
+{
+ u_int32_t start, end;
+
+ if (!bwx_int1_ports)
+ bwx_init();
+
+ if (!on)
+ return -1; /* XXX can't unmap yet */
+
+ start = trunc_page(from);
+ end = round_page(from + num);
+ if ((bwx_int1_ports = mmap(0, end-start,
+ PROT_READ|PROT_WRITE, MAP_SHARED, mem_fd,
+ bwx_io_base + BWX_EV56_INT1 + start))
+ == MAP_FAILED)
+ err(1, "mmap int1");
+ if ((bwx_int2_ports = mmap(0, end-start,
+ PROT_READ|PROT_WRITE, MAP_SHARED, mem_fd,
+ bwx_io_base + BWX_EV56_INT2 + start))
+ == MAP_FAILED)
+ err(1, "mmap int2");
+ if ((bwx_int4_ports = mmap(0, end-start,
+ PROT_READ|PROT_WRITE, MAP_SHARED, mem_fd,
+ bwx_io_base + BWX_EV56_INT4 + start))
+ == MAP_FAILED)
+ err(1, "mmap int4");
+ return 0;
+}
+
+static u_int8_t
+bwx_inb(u_int32_t port)
+{
+ mb();
+ return alpha_ldbu(bwx_int1_ports + port);
+}
+
+static u_int16_t
+bwx_inw(u_int32_t port)
+{
+ mb();
+ return alpha_ldwu(bwx_int2_ports + port);
+}
+
+static u_int32_t
+bwx_inl(u_int32_t port)
+{
+ mb();
+ return alpha_ldlu(bwx_int4_ports + port);
+}
+
+static void
+bwx_outb(u_int32_t port, u_int8_t val)
+{
+ alpha_stb(bwx_int1_ports + port, val);
+ mb();
+ wmb();
+}
+
+static void
+bwx_outw(u_int32_t port, u_int16_t val)
+{
+ alpha_stw(bwx_int2_ports + port, val);
+ mb();
+ wmb();
+}
+
+static void
+bwx_outl(u_int32_t port, u_int32_t val)
+{
+ alpha_stl(bwx_int4_ports + port, val);
+ mb();
+ wmb();
+}
+
+struct bwx_mem_handle {
+ void *virt1; /* int1 address in user address-space */
+ void *virt2; /* int2 address in user address-space */
+ void *virt4; /* int4 address in user address-space */
+};
+
+static void *
+bwx_map_memory(u_int32_t address, u_int32_t size)
+{
+ struct bwx_mem_handle *h;
+
+ h = malloc(sizeof(struct bwx_mem_handle));
+ if (!h) return 0;
+ h->virt1 = mmap(0, size << 5, PROT_READ|PROT_WRITE, MAP_SHARED,
+ mem_fd, bwx_mem_base + BWX_EV56_INT1 + address);
+ if ((long) h->virt1 == -1) {
+ free(h);
+ return 0;
+ }
+ h->virt2 = mmap(0, size << 5, PROT_READ|PROT_WRITE, MAP_SHARED,
+ mem_fd, bwx_mem_base + BWX_EV56_INT2 + address);
+ if ((long) h->virt2 == -1) {
+ munmap(h->virt1, size);
+ free(h);
+ return 0;
+ }
+ h->virt4 = mmap(0, size << 5, PROT_READ|PROT_WRITE, MAP_SHARED,
+ mem_fd, bwx_mem_base + BWX_EV56_INT4 + address);
+ if ((long) h->virt4 == -1) {
+ munmap(h->virt1, size);
+ munmap(h->virt2, size);
+ free(h);
+ return 0;
+ }
+ return h;
+}
+
+static void
+bwx_unmap_memory(void *handle, u_int32_t size)
+{
+ struct bwx_mem_handle *h = handle;
+
+ munmap(h->virt1, size);
+ munmap(h->virt2, size);
+ munmap(h->virt4, size);
+ free(h);
+}
+
+static u_int8_t
+bwx_readb(void *handle, u_int32_t offset)
+{
+ struct bwx_mem_handle *h = handle;
+
+ return alpha_ldbu(h->virt1 + offset);
+}
+
+static u_int16_t
+bwx_readw(void *handle, u_int32_t offset)
+{
+ struct bwx_mem_handle *h = handle;
+
+ return alpha_ldwu(h->virt2 + offset);
+}
+
+static u_int32_t
+bwx_readl(void *handle, u_int32_t offset)
+{
+ struct bwx_mem_handle *h = handle;
+
+ return alpha_ldlu(h->virt4 + offset);
+}
+
+static void
+bwx_writeb(void *handle, u_int32_t offset, u_int8_t val)
+{
+ struct bwx_mem_handle *h = handle;
+
+ alpha_stb(h->virt1 + offset, val);
+}
+
+static void
+bwx_writew(void *handle, u_int32_t offset, u_int16_t val)
+{
+ struct bwx_mem_handle *h = handle;
+
+ alpha_stw(h->virt2 + offset, val);
+}
+
+static void
+bwx_writel(void *handle, u_int32_t offset, u_int32_t val)
+{
+ struct bwx_mem_handle *h = handle;
+
+ alpha_stl(h->virt4 + offset, val);
+}
+
+struct io_ops bwx_io_ops = {
+ bwx_ioperm,
+ bwx_inb,
+ bwx_inw,
+ bwx_inl,
+ bwx_outb,
+ bwx_outw,
+ bwx_outl,
+ bwx_map_memory,
+ bwx_unmap_memory,
+ bwx_readb,
+ bwx_readw,
+ bwx_readl,
+ bwx_writeb,
+ bwx_writew,
+ bwx_writel,
+};
diff --git a/lib/libarch/alpha/io.c b/lib/libarch/alpha/io.c
new file mode 100644
index 00000000000..89c648a2064
--- /dev/null
+++ b/lib/libarch/alpha/io.c
@@ -0,0 +1,187 @@
+/* $OpenBSD: io.c,v 1.1 2002/07/07 14:24:04 matthieu Exp $ */
+/*-
+ * Copyright (c) 1998 Doug Rabson
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#include <err.h>
+
+#include "io.h"
+
+static struct io_ops *ops;
+
+int
+ioperm(unsigned long from, unsigned long num, int on)
+{
+ int error;
+ int bwx;
+ size_t len = sizeof(bwx);
+ int mib[3];
+
+ mib[0] = CTL_MACHDEP;
+ mib[1] = CPU_CHIPSET;
+ mib[2] = CPU_CHIPSET_BWX;
+ if ((error = sysctl(mib, 3, &bwx, &len, NULL, 0)) < 0)
+ return error;
+ if (bwx)
+ ops = &bwx_io_ops;
+ else
+#ifdef notyet
+ ops = &swiz_io_ops;
+#else
+ errx(1, "libio is only available on bwx capable machines");
+#endif
+
+ return ops->ioperm(from, num, on);
+}
+
+u_int8_t
+inb(u_int32_t port)
+{
+ return ops->inb(port);
+}
+
+u_int16_t
+inw(u_int32_t port)
+{
+ return ops->inw(port);
+}
+
+u_int32_t
+inl(u_int32_t port)
+{
+ return ops->inl(port);
+}
+
+void
+outb(u_int32_t port, u_int8_t val)
+{
+ ops->outb(port, val);
+}
+
+void
+outw(u_int32_t port, u_int16_t val)
+{
+ ops->outw(port, val);
+}
+
+void
+outl(u_int32_t port, u_int32_t val)
+{
+ ops->outl(port, val);
+}
+
+void *
+map_memory(u_int32_t address, u_int32_t size)
+{
+ return ops->map_memory(address, size);
+}
+
+void
+unmap_memory(void *handle, u_int32_t size)
+{
+ ops->unmap_memory(handle, size);
+}
+
+u_int8_t
+readb(void *handle, u_int32_t offset)
+{
+ return ops->readb(handle, offset);
+}
+
+u_int16_t
+readw(void *handle, u_int32_t offset)
+{
+ return ops->readw(handle, offset);
+}
+
+u_int32_t
+readl(void *handle, u_int32_t offset)
+{
+ return ops->readl(handle, offset);
+}
+
+void
+writeb(void *handle, u_int32_t offset, u_int8_t val)
+{
+ ops->writeb(handle, offset, val);
+ __asm__ __volatile__ ("mb");
+}
+
+void
+writew(void *handle, u_int32_t offset, u_int16_t val)
+{
+ ops->writew(handle, offset, val);
+ __asm__ __volatile__ ("mb");
+}
+
+void
+writel(void *handle, u_int32_t offset, u_int32_t val)
+{
+ ops->writel(handle, offset, val);
+ __asm__ __volatile__ ("mb");
+}
+
+void
+writeb_nb(void *handle, u_int32_t offset, u_int8_t val)
+{
+ return ops->writeb(handle, offset, val);
+}
+
+void
+writew_nb(void *handle, u_int32_t offset, u_int16_t val)
+{
+ return ops->writew(handle, offset, val);
+}
+
+void
+writel_nb(void *handle, u_int32_t offset, u_int32_t val)
+{
+ return ops->writel(handle, offset, val);
+}
+
+u_int64_t
+dense_base(void)
+{
+ static u_int64_t base = 0;
+
+ if (base == 0) {
+ size_t len = sizeof(base);
+ int error;
+ int mib[3];
+
+ mib[0] = CTL_MACHDEP;
+ mib[1] = CPU_CHIPSET;
+ mib[2] = CPU_CHIPSET_DENSE;
+
+ if ((error = sysctl(mib, 3, &base, &len, NULL, 0)) < 0)
+ err(1, "machdep.chipset.dense_base");
+ }
+
+ return base;
+}
diff --git a/lib/libarch/alpha/io.h b/lib/libarch/alpha/io.h
new file mode 100644
index 00000000000..6d7a45f5f50
--- /dev/null
+++ b/lib/libarch/alpha/io.h
@@ -0,0 +1,49 @@
+/* $OpenBSD: io.h,v 1.1 2002/07/07 14:24:04 matthieu Exp $ */
+/*-
+ * Copyright (c) 1998 Doug Rabson
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: src/lib/libio/io.h,v 1.2 1999/08/28 00:04:44 peter Exp $
+ */
+
+struct io_ops {
+ int (*ioperm)(u_int32_t, u_int32_t, int);
+ u_int8_t (*inb)(u_int32_t);
+ u_int16_t (*inw)(u_int32_t);
+ u_int32_t (*inl)(u_int32_t);
+ void (*outb)(u_int32_t, u_int8_t);
+ void (*outw)(u_int32_t, u_int16_t);
+ void (*outl)(u_int32_t, u_int32_t);
+ void *(*map_memory)(u_int32_t, u_int32_t);
+ void (*unmap_memory)(void *, u_int32_t);
+ u_int8_t (*readb)(void *, u_int32_t);
+ u_int16_t (*readw)(void *, u_int32_t);
+ u_int32_t (*readl)(void *, u_int32_t);
+ void (*writeb)(void *, u_int32_t, u_int8_t);
+ void (*writew)(void *, u_int32_t, u_int16_t);
+ void (*writel)(void *, u_int32_t, u_int32_t);
+};
+
+extern struct io_ops swiz_io_ops;
+extern struct io_ops bwx_io_ops;
diff --git a/lib/libarch/alpha/libalpha.2 b/lib/libarch/alpha/libalpha.2
new file mode 100644
index 00000000000..f8006e19293
--- /dev/null
+++ b/lib/libarch/alpha/libalpha.2
@@ -0,0 +1,133 @@
+.\" $OpenBSD: libalpha.2,v 1.1 2002/07/07 14:24:04 matthieu Exp $
+.\"
+.\" Copyright (c) 2002 Matthieu Herrb
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\"
+.\" - Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" - Redistributions in binary form must reproduce the above
+.\" copyright notice, this list of conditions and the following
+.\" disclaimer in the documentation and/or other materials provided
+.\" with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+.\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+.\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+.\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd Jul 6, 2002
+.Dt LIBALPHA 2
+.Os
+.Sh NAME
+.Nm dense_base ,
+.Nm inb ,
+.Nm inl ,
+.Nm inw ,
+.Nm ioperm ,
+.Nm map_memory ,
+.Nm outb ,
+.Nm outl ,
+.Nm outw ,
+.Nm readb ,
+.Nm readl ,
+.Nm readw ,
+.Nm unmap_memory ,
+.Nm writeb ,
+.Nm writel ,
+.Nm writew
+.Nd Alpha devices I/O ports and memory access functions
+.Sh SYNOPSIS
+.Ft u_int64_t
+.Fn dense_base "void"
+.Ft u_int8_t
+.Fn inb "u_int32_t port"
+.Ft u_int32_t
+.Fn inl "u_int32_t port"
+.Ft u_int16_t
+.Fn inw "u_int32_t port"
+.Ft int
+.Fn ioperm "unsigned long from" "unsigned long num" "int on"
+.Ft void *
+.Fn map_memory "u_int32_t address" "u_int32_t size"
+.Ft void
+.Fn outb "u_int32_t port" "u_int8_t val"
+.Ft void
+.Fn outl "u_int32_t port" "u_int32_t val"
+.Ft void
+.Fn outw "u_int32_t port" "u_int16_t val"
+.Ft u_int8_t
+.Fn readb "void *handle" "u_int32_t offset"
+.Ft u_int32_t
+.Fn readl "void *handle" "u_int32_t offset"
+.Ft u_int16_t
+.Fn readw "void *handle" "u_int32_t offset"
+.Ft void
+.Fn unmap_memory "void *handle" "u_int32_t size"
+.Ft void
+.Fn writeb "void *handle" "u_int32_t offset" "u_int8_t val"
+.Ft void
+.Fn writel "void *handle" "u_int32_t offset" "u_int32_t val"
+.Ft void
+.Fn writew "void *handle" "u_int32_t offset" "u_int16_t val"
+.Sh DESCRIPTION
+The functions in libalpha give userland programs access to the I/O
+ports on the OpenBSD/alpha platform.
+.Pp
+The
+.Fn in*
+functions return data read from the specified I/O port.
+.Pp
+The
+.Fn out*
+functions write data to the specified I/O port.
+.Pp
+.Fn ioperm
+enables the access to to the specified port numbers if
+.Fa on
+is
+.Dv TRUE
+and disables access if
+.Fa on
+is
+.Dv FALSE .
+.Pp
+The
+.Fn map_memory
+function allows a user program to map part of a device memory.
+.Pp
+The
+.Fn unmap_memory
+function unmaps memory that was previously mapped by
+.Fn map_memory .
+.Pp
+The
+.Fn read*
+functions read data from device memory previously mapped by
+.Fn map_memory .
+.Pp
+The
+.Fn write*
+functions write datz to the device memory previously mapped by
+.Fn map_memory .
+.\" .Sh EXAMPLES
+.\" TBW
+.Sh HISTORY
+These functions originally appeared in
+.Fx .
+.Sh CAVEATS
+Only BWX bus access method is supported for now. Machines requiring
+swiz type access are not supported.
+.Pp
+Root credentials are needed to use these functions.