summaryrefslogtreecommitdiffstats
path: root/libdha
diff options
context:
space:
mode:
authoralex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-01-15 15:59:53 +0000
committeralex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-01-15 15:59:53 +0000
commit340400036662ae41b230653e07a3aa4466010e3b (patch)
tree1088d724d0e60bc0dd2ccd637c585f43edacad0d /libdha
parent2c7c5d325bcf50863f91a8c80aaa709d13ddb944 (diff)
downloadmpv-340400036662ae41b230653e07a3aa4466010e3b.tar.bz2
mpv-340400036662ae41b230653e07a3aa4466010e3b.tar.xz
api changed: enable/disable_os_io returns error-code (or zero if ok) and pciconfig_read exported for mga_vid
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4175 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libdha')
-rw-r--r--libdha/libdha.c10
-rw-r--r--libdha/libdha.h3
-rw-r--r--libdha/pci.c31
-rw-r--r--libdha/sysdep/pci_386bsd.c13
-rw-r--r--libdha/sysdep/pci_bsdi.c13
-rw-r--r--libdha/sysdep/pci_freebsd.c13
-rw-r--r--libdha/sysdep/pci_isc.c6
-rw-r--r--libdha/sysdep/pci_linux.c13
-rw-r--r--libdha/sysdep/pci_mach386.c10
-rw-r--r--libdha/sysdep/pci_netbsd.c13
-rw-r--r--libdha/sysdep/pci_openbsd.c10
-rw-r--r--libdha/sysdep/pci_os2.c10
-rw-r--r--libdha/sysdep/pci_sco.c6
-rw-r--r--libdha/sysdep/pci_svr4.c6
-rw-r--r--libdha/sysdep/pci_win32.c6
15 files changed, 118 insertions, 45 deletions
diff --git a/libdha/libdha.c b/libdha/libdha.c
index ddd27aca5e..ccc6fc12f4 100644
--- a/libdha/libdha.c
+++ b/libdha/libdha.c
@@ -7,6 +7,7 @@
Modified for GATOS/win/gfxdump.
2002 - library implementation by Nick Kurshev
+ - some changes by Alex Beregszaszi
supported O/S's: SVR4, UnixWare, SCO, Solaris,
FreeBSD, NetBSD, 386BSD, BSDI BSD/386,
@@ -26,6 +27,14 @@
#include <sys/types.h>
#include <unistd.h>
+/* instead exit() use libdha_exit, and do the 'mother-application' deinit
+ only in this code */
+void libdha_exit(const char *message, int level)
+{
+ printf("libdha: FATAL: %s\n", message);
+ exit(level); /* FIXME */
+}
+
#if defined(_WIN32)
#include "sysdep/libdha_win32.c"
#elif defined (__EMX__)
@@ -97,3 +106,4 @@ void OUTPORT32(unsigned idx,unsigned val)
{
outl(idx,val);
}
+
diff --git a/libdha/libdha.h b/libdha/libdha.h
index 02b872d777..b418d7da2f 100644
--- a/libdha/libdha.h
+++ b/libdha/libdha.h
@@ -32,6 +32,9 @@ typedef struct pciinfo_s
unsigned base0,base1,base2,baserom ; /* Memory and I/O base addresses */
}pciinfo_t;
+/* needed for mga_vid */
+extern int pci_config_read(unsigned char bus, unsigned char dev, unsigned char offset,
+ int len, unsigned long *val);
/* Fill array pci_list which must have size MAX_PCI_DEVICES
and return 0 if sucessful */
extern int pci_scan(pciinfo_t *pci_list,unsigned *num_card);
diff --git a/libdha/pci.c b/libdha/pci.c
index e026ac5b87..bb40fe14e5 100644
--- a/libdha/pci.c
+++ b/libdha/pci.c
@@ -122,7 +122,7 @@ static swapl(unsigned long val)
#define PCIBIOS_DEVICE_NOT_FOUND 0x86
#define PCIBIOS_SUCCESSFUL 0x00
-static int pciconfig_read(
+int pciconfig_read(
unsigned char bus,
unsigned char dev,
unsigned char offset,
@@ -144,7 +144,7 @@ static int pciconfig_read(
return PCIBIOS_SUCCESSFUL;
}
-static int pciconfig_write(
+int pciconfig_write(
unsigned char bus,
unsigned char dev,
unsigned char offset,
@@ -528,10 +528,13 @@ int pci_scan(pciinfo_t *pci_list,unsigned *num_pci)
struct pci_config_reg pcr;
int do_mode1_scan = 0, do_mode2_scan = 0;
int func, hostbridges=0;
+ int ret = -1;
pci_lst = pci_list;
- enable_os_io();
+ ret = enable_os_io();
+ if (ret != 0)
+ return(ret);
if((pcr._configtype = pci_config_type()) == 0xFFFF) return ENODEV;
@@ -695,3 +698,25 @@ int pci_scan(pciinfo_t *pci_list,unsigned *num_pci)
return 0 ;
}
+
+#if !defined(ENOTSUP)
+#if defined(EOPNOTSUPP)
+#define ENOTSUP EOPNOTSUPP
+#else
+#warning "ENOTSUP nor EOPNOTSUPP defined!"
+#endif
+#endif
+
+int pci_config_read(unsigned char bus, unsigned char dev,
+ unsigned char offset, int len, unsigned long *val)
+{
+ if (len != 4)
+ {
+ printf("pci_config_read: reading non-dword not supported!\n");
+ return(ENOTSUP);
+ }
+
+ *val = pci_config_read_long(bus, dev, offset, 0);
+
+ return(0);
+}
diff --git a/libdha/sysdep/pci_386bsd.c b/libdha/sysdep/pci_386bsd.c
index a8040d60ad..d00ecb0785 100644
--- a/libdha/sysdep/pci_386bsd.c
+++ b/libdha/sysdep/pci_386bsd.c
@@ -3,6 +3,7 @@
$XFree86: xc/programs/Xserver/hw/xfree86/etc/scanpci.c,v 3.34.2.17 1998/11/10 11:55:40 dawes Exp $
Modified for readability by Nick Kurshev
*/
+#include <errno.h>
#include <sys/file.h>
#include <machine/console.h>
#ifndef GCCUSESGAS
@@ -11,25 +12,27 @@
static int io_fd;
-static __inline__ void enable_os_io(void)
+static __inline__ int enable_os_io(void)
{
io_fd = -1 ;
if ((io_fd = open("/dev/console", O_RDWR, 0)) < 0) {
perror("/dev/console");
- exit(1);
+ return(errno);
}
if (ioctl(io_fd, KDENABIO, 0) < 0) {
perror("ioctl(KDENABIO)");
- exit(1);
+ return(errno);
}
+ return(0);
}
-static __inline__ void disable_os_io(void)
+static __inline__ int disable_os_io(void)
{
if (ioctl(io_fd, KDDISABIO, 0) < 0) {
perror("ioctl(KDDISABIO)");
close(io_fd);
- exit(1);
+ return(errno);
}
close(io_fd);
+ return(0);
}
diff --git a/libdha/sysdep/pci_bsdi.c b/libdha/sysdep/pci_bsdi.c
index 1e7b877a3b..b6b142054d 100644
--- a/libdha/sysdep/pci_bsdi.c
+++ b/libdha/sysdep/pci_bsdi.c
@@ -3,6 +3,7 @@
$XFree86: xc/programs/Xserver/hw/xfree86/etc/scanpci.c,v 3.34.2.17 1998/11/10 11:55:40 dawes Exp $
Modified for readability by Nick Kurshev
*/
+#include <errno.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <i386/isa/pcconsioctl.h>
@@ -12,25 +13,27 @@
static int io_fd;
-static __inline__ void enable_os_io(void)
+static __inline__ int enable_os_io(void)
{
io_fd = -1 ;
if ((io_fd = open("/dev/console", O_RDWR, 0)) < 0) {
perror("/dev/console");
- exit(1);
+ return(errno);
}
if (ioctl(io_fd, PCCONENABIOPL, 0) < 0) {
perror("ioctl(PCCONENABIOPL)");
- exit(1);
+ return(errno);
}
+ return(0);
}
-static __inline__ void disable_os_io(void)
+static __inline__ int disable_os_io(void)
{
if (ioctl(io_fd, PCCONDISABIOPL, 0) < 0) {
perror("ioctl(PCCONDISABIOPL)");
close(io_fd);
- exit(1);
+ return(errno);
}
close(io_fd);
+ return(0);
}
diff --git a/libdha/sysdep/pci_freebsd.c b/libdha/sysdep/pci_freebsd.c
index a8040d60ad..dd93d90d68 100644
--- a/libdha/sysdep/pci_freebsd.c
+++ b/libdha/sysdep/pci_freebsd.c
@@ -3,6 +3,7 @@
$XFree86: xc/programs/Xserver/hw/xfree86/etc/scanpci.c,v 3.34.2.17 1998/11/10 11:55:40 dawes Exp $
Modified for readability by Nick Kurshev
*/
+#include <errno.h>
#include <sys/file.h>
#include <machine/console.h>
#ifndef GCCUSESGAS
@@ -11,25 +12,27 @@
static int io_fd;
-static __inline__ void enable_os_io(void)
+static __inline__ int enable_os_io(void)
{
io_fd = -1 ;
if ((io_fd = open("/dev/console", O_RDWR, 0)) < 0) {
perror("/dev/console");
- exit(1);
+ return(errno);
}
if (ioctl(io_fd, KDENABIO, 0) < 0) {
perror("ioctl(KDENABIO)");
- exit(1);
+ return(errno);
}
+ return(0);
}
-static __inline__ void disable_os_io(void)
+static __inline__ int disable_os_io(void)
{
if (ioctl(io_fd, KDDISABIO, 0) < 0) {
perror("ioctl(KDDISABIO)");
close(io_fd);
- exit(1);
+ return(errno);
}
close(io_fd);
+ return(0);
}
diff --git a/libdha/sysdep/pci_isc.c b/libdha/sysdep/pci_isc.c
index 0fabba5972..5b5a591824 100644
--- a/libdha/sysdep/pci_isc.c
+++ b/libdha/sysdep/pci_isc.c
@@ -11,20 +11,22 @@
#include <sys/sysi86.h>
#include <sys/v86.h>
-static __inline__ void enable_os_io(void)
+static __inline__ int enable_os_io(void)
{
#if defined(SI86IOPL)
sysi86(SI86IOPL, 3);
#else
sysi86(SI86V86, V86SC_IOPL, PS_IOPL);
#endif
+ return(0);
}
-static __inline__ void disable_os_io(void)
+static __inline__ int disable_os_io(void)
{
#if defined(SI86IOPL)
sysi86(SI86IOPL, 0);
#else
sysi86(SI86V86, V86SC_IOPL, 0);
#endif
+ return(0);
}
diff --git a/libdha/sysdep/pci_linux.c b/libdha/sysdep/pci_linux.c
index 96a520b65d..f4b46990a4 100644
--- a/libdha/sysdep/pci_linux.c
+++ b/libdha/sysdep/pci_linux.c
@@ -3,18 +3,23 @@
$XFree86: xc/programs/Xserver/hw/xfree86/etc/scanpci.c,v 3.34.2.17 1998/11/10 11:55:40 dawes Exp $
Modified for readability by Nick Kurshev
*/
+#include <errno.h>
#ifdef __i386__
#include <sys/perm.h>
#else
#include <sys/io.h>
#endif
-static __inline__ void enable_os_io(void)
+static __inline__ int enable_os_io(void)
{
- iopl(3);
+ if (iopl(3) != 0)
+ return(errno);
+ return(0);
}
-static __inline__ void disable_os_io(void)
+static __inline__ int disable_os_io(void)
{
- iopl(0);
+ if (iopl(0) != 0)
+ return(errno);
+ return(0);
}
diff --git a/libdha/sysdep/pci_mach386.c b/libdha/sysdep/pci_mach386.c
index 32e2a657ff..31621862b8 100644
--- a/libdha/sysdep/pci_mach386.c
+++ b/libdha/sysdep/pci_mach386.c
@@ -4,18 +4,22 @@
Modified for readability by Nick Kurshev
*/
+#include <errno.h>
+
static int io_fd;
-static __inline__ void enable_os_io(void)
+static __inline__ int enable_os_io(void)
{
io_fd = -1 ;
if ((io_fd = open("/dev/iopl", O_RDWR, 0)) < 0) {
perror("/dev/iopl");
- exit(1);
+ return(errno);
}
+ return(0);
}
-static __inline__ void disable_os_io(void)
+static __inline__ int disable_os_io(void)
{
close(io_fd);
+ return(0);
}
diff --git a/libdha/sysdep/pci_netbsd.c b/libdha/sysdep/pci_netbsd.c
index 19fa771fbd..793944beba 100644
--- a/libdha/sysdep/pci_netbsd.c
+++ b/libdha/sysdep/pci_netbsd.c
@@ -3,6 +3,7 @@
$XFree86: xc/programs/Xserver/hw/xfree86/etc/scanpci.c,v 3.34.2.17 1998/11/10 11:55:40 dawes Exp $
Modified for readability by Nick Kurshev
*/
+#include <errno.h>
#include <sys/param.h>
#include <sys/file.h>
#include <machine/sysarch.h>
@@ -12,30 +13,32 @@
static int io_fd;
-static __inline__ void enable_os_io(void)
+static __inline__ int enable_os_io(void)
{
io_fd = -1 ;
#if !defined(USE_I386_IOPL)
if ((io_fd = open("/dev/io", O_RDWR, 0)) < 0) {
perror("/dev/io");
- exit(1);
+ return(errno);
}
#else
if (i386_iopl(1) < 0) {
perror("i386_iopl");
- exit(1);
+ return(errno);
}
#endif /* USE_I386_IOPL */
+ return(0);
}
-static __inline__ void disable_os_io(void)
+static __inline__ int disable_os_io(void)
{
#if !defined(USE_I386_IOPL)
close(io_fd);
#else
if (i386_iopl(0) < 0) {
perror("i386_iopl");
- exit(1);
+ return(errno);
}
#endif /* NetBSD1_1 */
+ return(0);
}
diff --git a/libdha/sysdep/pci_openbsd.c b/libdha/sysdep/pci_openbsd.c
index ef835b405f..387335c236 100644
--- a/libdha/sysdep/pci_openbsd.c
+++ b/libdha/sysdep/pci_openbsd.c
@@ -4,15 +4,19 @@
Modified for readability by Nick Kurshev
*/
-static __inline__ void enable_os_io(void)
+#include <errno.h>
+
+static __inline__ int enable_os_io(void)
{
if (i386_iopl(1) < 0) {
perror("i386_iopl");
- exit(1);
+ return(errno);
}
+ return(0);
}
-static __inline__ void disable_os_io(void)
+static __inline__ int disable_os_io(void)
{
/* Nothing to do */
+ return(0);
}
diff --git a/libdha/sysdep/pci_os2.c b/libdha/sysdep/pci_os2.c
index 4f0df53b30..ddfc0c0ea6 100644
--- a/libdha/sysdep/pci_os2.c
+++ b/libdha/sysdep/pci_os2.c
@@ -8,7 +8,7 @@
static USHORT callgate[3] = {0,0,0};
-static __inline__ void enable_os_io(void)
+static __inline__ int enable_os_io(void)
{
HFILE hfd;
ULONG dlen,action;
@@ -21,7 +21,7 @@ static __inline__ void enable_os_io(void)
(ULONG)0) != 0) {
fprintf(stderr,"Error opening fastio$ driver...\n");
fprintf(stderr,"Please install xf86sup.sys in config.sys!\n");
- exit(42);
+ return(42);
}
callgate[0] = callgate[1] = 0;
@@ -34,7 +34,7 @@ static __inline__ void enable_os_io(void)
fprintf(stderr,"xf86-OS/2: EnableIOPorts failed, rc=%d, dlen=%d; emergency exit\n",
rc,dlen);
DosClose(hfd);
- exit(42);
+ return(42);
}
/* Calling callgate with function 13 sets IOPL for the program */
@@ -45,9 +45,11 @@ static __inline__ void enable_os_io(void)
: "eax","ebx","ecx","edx","cc");
DosClose(hfd);
+ return(0);
}
-static __inline__ void disable_os_io(void)
+static __inline__ int disable_os_io(void)
{
/* Nothing to do */
+ return(0);
}
diff --git a/libdha/sysdep/pci_sco.c b/libdha/sysdep/pci_sco.c
index 1d5c355989..9cb2282ada 100644
--- a/libdha/sysdep/pci_sco.c
+++ b/libdha/sysdep/pci_sco.c
@@ -12,20 +12,22 @@
#include <sys/sysi86.h>
#include <sys/v86.h>
-static __inline__ void enable_os_io(void)
+static __inline__ int enable_os_io(void)
{
#if defined(SI86IOPL)
sysi86(SI86IOPL, 3);
#else
sysi86(SI86V86, V86SC_IOPL, PS_IOPL);
#endif
+ return(0);
}
-static __inline__ void disable_os_io(void)
+static __inline__ int disable_os_io(void)
{
#if defined(SI86IOPL)
sysi86(SI86IOPL, 0);
#else
sysi86(SI86V86, V86SC_IOPL, 0);
#endif
+ return(0);
}
diff --git a/libdha/sysdep/pci_svr4.c b/libdha/sysdep/pci_svr4.c
index 7acdd9f3e4..fd8b9cbfec 100644
--- a/libdha/sysdep/pci_svr4.c
+++ b/libdha/sysdep/pci_svr4.c
@@ -19,20 +19,22 @@
#define __EXTENSIONS__
#endif
-static __inline__ void enable_os_io(void)
+static __inline__ int enable_os_io(void)
{
#if defined(SI86IOPL)
sysi86(SI86IOPL, 3);
#else
sysi86(SI86V86, V86SC_IOPL, PS_IOPL);
#endif
+ return(0);
}
-static __inline__ void disable_os_io(void)
+static __inline__ int disable_os_io(void)
{
#if defined(SI86IOPL)
sysi86(SI86IOPL, 0);
#else
sysi86(SI86V86, V86SC_IOPL, 0);
#endif
+ return(0);
}
diff --git a/libdha/sysdep/pci_win32.c b/libdha/sysdep/pci_win32.c
index 363fa23485..1c88cb13e8 100644
--- a/libdha/sysdep/pci_win32.c
+++ b/libdha/sysdep/pci_win32.c
@@ -7,10 +7,12 @@
/* Nothing to do for Win9x. For WinNT I have no solution */
-static __inline__ void enable_os_io(void)
+static __inline__ int enable_os_io(void)
{
+ return(0);
}
-static __inline__ void disable_os_io(void)
+static __inline__ int disable_os_io(void)
{
+ return(0);
}