summaryrefslogtreecommitdiff
path: root/src/video_out/libdha
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_out/libdha')
-rw-r--r--src/video_out/libdha/Makefile.am2
-rw-r--r--src/video_out/libdha/config.h10
-rw-r--r--src/video_out/libdha/cpu_flush.c23
-rw-r--r--src/video_out/libdha/irq.c62
-rw-r--r--src/video_out/libdha/ports.c219
-rw-r--r--src/video_out/libdha/sysdep/AsmMacros_generic.h56
-rw-r--r--src/video_out/libdha/sysdep/Makefile.am3
-rw-r--r--src/video_out/libdha/sysdep/pci_generic_cpu.c79
-rw-r--r--src/video_out/libdha/sysdep/pci_generic_os.c15
9 files changed, 468 insertions, 1 deletions
diff --git a/src/video_out/libdha/Makefile.am b/src/video_out/libdha/Makefile.am
index cb74a6178..fb59a4f7a 100644
--- a/src/video_out/libdha/Makefile.am
+++ b/src/video_out/libdha/Makefile.am
@@ -19,7 +19,7 @@ EXTRA_PROGRAMS = test
test_SOURCES = test.c
test_LDADD = $(top_builddir)/src/video_out/libdha/libdha.la
-noinst_HEADERS = AsmMacros.h libdha.h pci_ids.h pci_names.h pci_vendors.h
+noinst_HEADERS = AsmMacros.h config.h libdha.h pci_ids.h pci_names.h pci_vendors.h
## for OpenBSD LIBS += -li386
diff --git a/src/video_out/libdha/config.h b/src/video_out/libdha/config.h
new file mode 100644
index 000000000..ede3c13c1
--- /dev/null
+++ b/src/video_out/libdha/config.h
@@ -0,0 +1,10 @@
+#ifndef LIBDHA_CONFIG_H
+#define LIBDHA_CONFIG_H
+
+#include "../config.h"
+
+#ifdef TARGET_LINUX
+//#define CONFIG_DHAHELPER /* doesn't affect virt_to_phys */
+#endif
+
+#endif /* LIBDHA_CONFIG_H */
diff --git a/src/video_out/libdha/cpu_flush.c b/src/video_out/libdha/cpu_flush.c
new file mode 100644
index 000000000..9186f89e8
--- /dev/null
+++ b/src/video_out/libdha/cpu_flush.c
@@ -0,0 +1,23 @@
+/* CPU flush support */
+#include <stdio.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include "libdha.h"
+#include "kernelhelper/dhahelper.h"
+
+void cpu_flush(void *va,unsigned long length)
+{
+ int retval;
+ int libdha_fd=-1;
+ if( libdha_fd == -1) libdha_fd = open("/dev/dhahelper",O_RDWR);
+ if (libdha_fd > 0)
+ {
+ dhahelper_cpu_flush_t _l2;
+ _l2.va = va;
+ _l2.length = length;
+ retval = ioctl(libdha_fd, DHAHELPER_CPU_FLUSH, &_l2);
+ close(libdha_fd);
+ }
+}
diff --git a/src/video_out/libdha/irq.c b/src/video_out/libdha/irq.c
new file mode 100644
index 000000000..6ac852857
--- /dev/null
+++ b/src/video_out/libdha/irq.c
@@ -0,0 +1,62 @@
+/* HW IRQ support */
+#include <stdio.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h> /* mlock */
+#include <pthread.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include "libdha.h"
+#include "kernelhelper/dhahelper.h"
+
+
+static int libdha_fd=-1;
+static int hwirq_locks=0;
+
+int hwirq_install(int bus, int dev, int func,
+ int ar, u_long ao, uint32_t ad)
+{
+ int retval;
+ if( libdha_fd == -1) libdha_fd = open("/dev/dhahelper",O_RDWR);
+ hwirq_locks++;
+ if (libdha_fd > 0)
+ {
+ dhahelper_irq_t _irq;
+ _irq.bus = bus;
+ _irq.dev = dev;
+ _irq.func = func;
+ _irq.ack_region = ar;
+ _irq.ack_offset = ao;
+ _irq.ack_data = ad;
+ retval = ioctl(libdha_fd, DHAHELPER_INSTALL_IRQ, &_irq);
+ return retval;
+ }
+ return errno;
+}
+
+int hwirq_wait(unsigned irqnum)
+{
+ int retval;
+ if (libdha_fd > 0)
+ {
+ dhahelper_irq_t _irq;
+ _irq.num = irqnum;
+ retval = ioctl(libdha_fd, DHAHELPER_ACK_IRQ, &_irq);
+ return retval;
+ }
+ return EINVAL;
+}
+
+int hwirq_uninstall(int bus, int dev, int func)
+{
+ if (libdha_fd > 0)
+ {
+ dhahelper_irq_t _irq;
+ _irq.bus = bus;
+ _irq.dev = dev;
+ _irq.func = func;
+ ioctl(libdha_fd, DHAHELPER_FREE_IRQ, &_irq);
+ }
+ if(!hwirq_locks) { close(libdha_fd); libdha_fd=-1; }
+ return 0;
+}
diff --git a/src/video_out/libdha/ports.c b/src/video_out/libdha/ports.c
new file mode 100644
index 000000000..73ad671d1
--- /dev/null
+++ b/src/video_out/libdha/ports.c
@@ -0,0 +1,219 @@
+/*
+ (C) 2002 - library implementation by Nick Kyrshev
+ XFree86 3.3.3 scanpci.c, modified for GATOS/win/gfxdump by Øyvind Aabling.
+ */
+/* $XConsortium: scanpci.c /main/25 1996/10/27 11:48:40 kaleb $ */
+/*
+ * name: scanpci.c
+ *
+ * purpose: This program will scan for and print details of
+ * devices on the PCI bus.
+
+ * author: Robin Cutshaw (robin@xfree86.org)
+ *
+ * supported O/S's: SVR4, UnixWare, SCO, Solaris,
+ * FreeBSD, NetBSD, 386BSD, BSDI BSD/386,
+ * Linux, Mach/386, ISC
+ * DOS (WATCOM 9.5 compiler)
+ *
+ * compiling: [g]cc scanpci.c -o scanpci
+ * for SVR4 (not Solaris), UnixWare use:
+ * [g]cc -DSVR4 scanpci.c -o scanpci
+ * for DOS, watcom 9.5:
+ * wcc386p -zq -omaxet -7 -4s -s -w3 -d2 name.c
+ * and link with PharLap or other dos extender for exe
+ *
+ */
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/etc/scanpci.c,v 3.34.2.17 1998/11/10 11:55:40 dawes Exp $ */
+
+/*
+ * Copyright 1995 by Robin Cutshaw <robin@XFree86.Org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of the above listed copyright holder(s)
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. The above listed
+ * copyright holder(s) make(s) no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+ * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#ifdef ARCH_ALPHA
+#include <sys/io.h>
+#endif
+#include <unistd.h>
+
+#include "libdha.h"
+#include "AsmMacros.h"
+#include "kernelhelper/dhahelper.h"
+
+/* OS depended stuff */
+#if defined (linux)
+#include "sysdep/pci_linux.c"
+#elif defined (__FreeBSD__)
+#include "sysdep/pci_freebsd.c"
+#elif defined (__386BSD__)
+#include "sysdep/pci_386bsd.c"
+#elif defined (__NetBSD__)
+#include "sysdep/pci_netbsd.c"
+#elif defined (__OpenBSD__)
+#include "sysdep/pci_openbsd.c"
+#elif defined (__bsdi__)
+#include "sysdep/pci_bsdi.c"
+#elif defined (Lynx)
+#include "sysdep/pci_lynx.c"
+#elif defined (MACH386)
+#include "sysdep/pci_mach386.c"
+#elif defined (__SVR4)
+#if !defined(SVR4)
+#define SVR4
+#endif
+#include "sysdep/pci_svr4.c"
+#elif defined (SCO)
+#include "sysdep/pci_sco.c"
+#elif defined (ISC)
+#include "sysdep/pci_isc.c"
+#elif defined (__EMX__)
+#include "sysdep/pci_os2.c"
+#elif defined (_WIN32) || defined(__CYGWIN__)
+#include "sysdep/pci_win32.c"
+#else
+#include "sysdep/pci_generic_os.c"
+#endif
+
+static int dhahelper_fd=-1;
+static unsigned dhahelper_counter=0;
+int enable_app_io( void )
+{
+ if((dhahelper_fd=open("/dev/dhahelper",O_RDWR)) < 0) return enable_os_io();
+ dhahelper_counter++;
+ return 0;
+}
+
+int disable_app_io( void )
+{
+ dhahelper_counter--;
+ if(dhahelper_fd > 0)
+ {
+ if(!dhahelper_counter)
+ {
+ close(dhahelper_fd);
+ dhahelper_fd = -1;
+ }
+ }
+ else return disable_os_io();
+ return 0;
+}
+
+unsigned char INPORT8(unsigned idx)
+{
+ if (dhahelper_fd > 0)
+ {
+ dhahelper_port_t _port;
+
+ _port.operation = PORT_OP_READ;
+ _port.addr = idx;
+ _port.size = 1;
+ if (ioctl(dhahelper_fd, DHAHELPER_PORT, &_port) == 0)
+ return _port.value;
+ }
+ return inb(idx);
+}
+
+unsigned short INPORT16(unsigned idx)
+{
+ if (dhahelper_fd > 0)
+ {
+ dhahelper_port_t _port;
+
+ _port.operation = PORT_OP_READ;
+ _port.addr = idx;
+ _port.size = 2;
+ if (ioctl(dhahelper_fd, DHAHELPER_PORT, &_port) == 0)
+ return _port.value;
+ }
+ return inw(idx);
+}
+
+unsigned INPORT32(unsigned idx)
+{
+ if (dhahelper_fd > 0)
+ {
+ dhahelper_port_t _port;
+
+ _port.operation = PORT_OP_READ;
+ _port.addr = idx;
+ _port.size = 4;
+ if (ioctl(dhahelper_fd, DHAHELPER_PORT, &_port) == 0)
+ return _port.value;
+ }
+ return inl(idx);
+}
+
+void OUTPORT8(unsigned idx,unsigned char val)
+{
+ if (dhahelper_fd > 0)
+ {
+ dhahelper_port_t _port;
+
+ _port.operation = PORT_OP_WRITE;
+ _port.addr = idx;
+ _port.size = 1;
+ _port.value = val;
+ if (ioctl(dhahelper_fd, DHAHELPER_PORT, &_port) == 0)
+ return;
+ }
+ else outb(idx,val);
+}
+
+void OUTPORT16(unsigned idx,unsigned short val)
+{
+ if (dhahelper_fd > 0)
+ {
+ dhahelper_port_t _port;
+
+ _port.operation = PORT_OP_WRITE;
+ _port.addr = idx;
+ _port.size = 2;
+ _port.value = val;
+ if (ioctl(dhahelper_fd, DHAHELPER_PORT, &_port) == 0)
+ return;
+ }
+ else outw(idx,val);
+}
+
+void OUTPORT32(unsigned idx,unsigned val)
+{
+ if (dhahelper_fd > 0)
+ {
+ dhahelper_port_t _port;
+
+ _port.operation = PORT_OP_WRITE;
+ _port.addr = idx;
+ _port.size = 4;
+ _port.value = val;
+ if (ioctl(dhahelper_fd, DHAHELPER_PORT, &_port) == 0)
+ return;
+ }
+ else outl(idx,val);
+}
+
diff --git a/src/video_out/libdha/sysdep/AsmMacros_generic.h b/src/video_out/libdha/sysdep/AsmMacros_generic.h
new file mode 100644
index 000000000..f3844c5ed
--- /dev/null
+++ b/src/video_out/libdha/sysdep/AsmMacros_generic.h
@@ -0,0 +1,56 @@
+/*
+ Generic stuff to compile VIDIX only on any system (SCRATCH)
+*/
+
+#ifndef __ASM_MACROS_GENERIC_H
+#define __ASM_MACROS_GENERIC_H
+
+#warn This stuff is not ported on yur system
+
+static __inline__ void outb(short port,char val)
+{
+ printf("outb: generic function call\n");
+ return;
+}
+
+static __inline__ void outw(short port,short val)
+{
+ printf("outw: generic function call\n");
+ return;
+}
+
+static __inline__ void outl(short port,unsigned int val)
+{
+ printf("outl: generic function call\n");
+ return;
+}
+
+static __inline__ unsigned int inb(short port)
+{
+ printf("inb: generic function call\n");
+ return 0;
+}
+
+static __inline__ unsigned int inw(short port)
+{
+ printf("inw: generic function call\n");
+ return 0;
+}
+
+static __inline__ unsigned int inl(short port)
+{
+ printf("inl: generic function call\n");
+ return 0;
+}
+
+static __inline__ void intr_disable()
+{
+ printf("intr_disable: generic function call\n");
+}
+
+static __inline__ void intr_enable()
+{
+ printf("intr_enable: generic function call\n");
+}
+
+#endif
diff --git a/src/video_out/libdha/sysdep/Makefile.am b/src/video_out/libdha/sysdep/Makefile.am
index 5dc3ef70f..014ef0cf0 100644
--- a/src/video_out/libdha/sysdep/Makefile.am
+++ b/src/video_out/libdha/sysdep/Makefile.am
@@ -6,6 +6,8 @@ EXTRA_DIST = \
pci_arm32.c \
pci_bsdi.c \
pci_freebsd.c \
+ pci_generic_cpu.c \
+ pci_generic_os.c \
pci_ia64.c \
pci_isc.c \
pci_linux.c \
@@ -24,6 +26,7 @@ EXTRA_DIST = \
noinst_HEADERS = \
AsmMacros_alpha.h \
AsmMacros_arm32.h \
+ AsmMacros_generic.h \
AsmMacros_ia64.h \
AsmMacros_powerpc.h \
AsmMacros_sparc.h \
diff --git a/src/video_out/libdha/sysdep/pci_generic_cpu.c b/src/video_out/libdha/sysdep/pci_generic_cpu.c
new file mode 100644
index 000000000..3a37890eb
--- /dev/null
+++ b/src/video_out/libdha/sysdep/pci_generic_cpu.c
@@ -0,0 +1,79 @@
+/*
+ Generic stuff to compile VIDIX only on any system (SCRATCH)
+*/
+#warn This stuff is not ported on yur system
+
+static int pci_config_type( void )
+{
+ printf("pci_config_type: generic function call\n");
+ return 0xFFFF;
+}
+
+static int pci_get_vendor(
+ unsigned char bus,
+ unsigned char dev,
+ int func)
+{
+ printf("pci_get_vendor: generic function call\n");
+ return 0;
+}
+
+static long pci_config_read_long(
+ unsigned char bus,
+ unsigned char dev,
+ int func,
+ unsigned cmd)
+{
+ printf("pci_config_read_long: generic function call\n");
+ return 0;
+}
+
+static long pci_config_read_word(
+ unsigned char bus,
+ unsigned char dev,
+ int func,
+ unsigned cmd)
+{
+ printf("pci_config_read_word: generic function call\n");
+ return 0;
+}
+
+static long pci_config_read_byte(
+ unsigned char bus,
+ unsigned char dev,
+ int func,
+ unsigned cmd)
+{
+ printf("pci_config_read_byte: generic function call\n");
+ return 0;
+}
+
+static void pci_config_write_long(
+ unsigned char bus,
+ unsigned char dev,
+ int func,
+ unsigned cmd,
+ long val)
+{
+ printf("pci_config_write_long: generic function call\n");
+}
+
+static void pci_config_write_word(
+ unsigned char bus,
+ unsigned char dev,
+ int func,
+ unsigned cmd,
+ long val)
+{
+ printf("pci_config_write_word: generic function call\n");
+}
+
+static void pci_config_write_byte(
+ unsigned char bus,
+ unsigned char dev,
+ int func,
+ unsigned cmd,
+ long val)
+{
+ printf("pci_config_write_byte: generic function call\n");
+}
diff --git a/src/video_out/libdha/sysdep/pci_generic_os.c b/src/video_out/libdha/sysdep/pci_generic_os.c
new file mode 100644
index 000000000..8855bb4ba
--- /dev/null
+++ b/src/video_out/libdha/sysdep/pci_generic_os.c
@@ -0,0 +1,15 @@
+/*
+ Generic stuff to compile VIDIX only on any system (SCRATCH)
+*/
+#warn This stuff is not ported on yur system
+static __inline__ int enable_os_io(void)
+{
+ printf("enable_os_io: generic function call\n");
+ return 0;
+}
+
+static __inline__ int disable_os_io(void)
+{
+ printf("disable_os_io: generic function call\n");
+ return 0;
+}