mirror of
https://github.com/mpv-player/mpv
synced 2024-10-22 08:51:57 +02:00
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
This commit is contained in:
parent
2c7c5d325b
commit
3404000366
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
31
libdha/pci.c
31
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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user