mirror of https://github.com/mpv-player/mpv
added support for dhahelper
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4475 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
127e0ba191
commit
7129693a26
|
@ -7,7 +7,7 @@
|
|||
Modified for GATOS/win/gfxdump.
|
||||
|
||||
2002 - library implementation by Nick Kurshev
|
||||
- some changes by Alex Beregszaszi
|
||||
- dhahelper and some changes by Alex Beregszaszi
|
||||
|
||||
supported O/S's: SVR4, UnixWare, SCO, Solaris,
|
||||
FreeBSD, NetBSD, 386BSD, BSDI BSD/386,
|
||||
|
@ -17,6 +17,8 @@
|
|||
Original location: www.linuxvideo.org/gatos
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "libdha.h"
|
||||
#include "AsmMacros.h"
|
||||
#include <stdio.h>
|
||||
|
@ -60,14 +62,44 @@ void libdha_exit(const char *message, int level)
|
|||
#define DEV_MEM "/dev/mem"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DHAHELPER
|
||||
static int mem=-1;
|
||||
void *map_phys_mem(unsigned base, unsigned size)
|
||||
{
|
||||
if ( (mem = open("/dev/dhahelper",O_RDWR)) < 0)
|
||||
{
|
||||
if ( (mem = open(DEV_MEM,O_RDWR)) == -1) {
|
||||
perror("libdha: open(/dev/mem) failed") ; exit(1) ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dhahelper_memory_t mem_req;
|
||||
|
||||
mem_req.operation = MEMORY_OP_MAP;
|
||||
mem_req.start = base;
|
||||
mem_req.offset = 0;
|
||||
mem_req.size = size;
|
||||
|
||||
if (ioctl(mem, DHAHELPER_MEMORY, &mem_req) < 0)
|
||||
{
|
||||
perror("libdha: failed mapping throught kernel helper");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return mmap(0,size,PROT_READ|PROT_WRITE,MAP_SHARED,mem,base) ;
|
||||
}
|
||||
#else
|
||||
|
||||
static int mem=-1;
|
||||
void *map_phys_mem(unsigned base, unsigned size)
|
||||
{
|
||||
if ( (mem = open(DEV_MEM,O_RDWR)) == -1) {
|
||||
perror("libdha: open(/dev/mem) failed") ; exit(1) ;
|
||||
}
|
||||
return mmap(0,size,PROT_READ|PROT_WRITE,MAP_SHARED,mem,base) ;
|
||||
}
|
||||
#endif /* CONFIG_DHAHELPER */
|
||||
|
||||
void unmap_phys_mem(void *ptr, unsigned size)
|
||||
{
|
||||
|
|
|
@ -11,24 +11,92 @@
|
|||
#error This stuff is not ported on your system
|
||||
#else
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef CONFIG_DHAHELPER
|
||||
#include <sys/ioctl.h>
|
||||
#include "../kernelhelper/dhahelper.h"
|
||||
|
||||
extern int dhahelper_fd;
|
||||
extern int dhahelper_initialized;
|
||||
#endif
|
||||
|
||||
static __inline__ void outb(short port,char val)
|
||||
{
|
||||
#ifdef CONFIG_DHAHELPER
|
||||
if (dhahelper_initialized == 1)
|
||||
{
|
||||
dhahelper_port_t _port;
|
||||
|
||||
_port.operation = PORT_OP_WRITE;
|
||||
_port.addr = port;
|
||||
_port.size = 1;
|
||||
_port.value = val;
|
||||
if (ioctl(dhahelper_fd, DHAHELPER_PORT, &_port) == 0)
|
||||
return;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
__asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
|
||||
return;
|
||||
}
|
||||
|
||||
static __inline__ void outw(short port,short val)
|
||||
{
|
||||
#ifdef CONFIG_DHAHELPER
|
||||
if (dhahelper_initialized == 1)
|
||||
{
|
||||
dhahelper_port_t _port;
|
||||
|
||||
_port.operation = PORT_OP_WRITE;
|
||||
_port.addr = port;
|
||||
_port.size = 2;
|
||||
_port.value = val;
|
||||
if (ioctl(dhahelper_fd, DHAHELPER_PORT, &_port) == 0)
|
||||
return;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
__asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));
|
||||
return;
|
||||
}
|
||||
|
||||
static __inline__ void outl(short port,unsigned int val)
|
||||
{
|
||||
#ifdef CONFIG_DHAHELPER
|
||||
if (dhahelper_initialized == 1)
|
||||
{
|
||||
dhahelper_port_t _port;
|
||||
|
||||
_port.operation = PORT_OP_WRITE;
|
||||
_port.addr = port;
|
||||
_port.size = 4;
|
||||
_port.value = val;
|
||||
if (ioctl(dhahelper_fd, DHAHELPER_PORT, &_port) == 0)
|
||||
return;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
__asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
|
||||
return;
|
||||
}
|
||||
|
||||
static __inline__ unsigned int inb(short port)
|
||||
{
|
||||
unsigned char ret;
|
||||
#ifdef CONFIG_DHAHELPER
|
||||
if (dhahelper_initialized == 1)
|
||||
{
|
||||
dhahelper_port_t _port;
|
||||
|
||||
_port.operation = PORT_OP_READ;
|
||||
_port.addr = port;
|
||||
_port.size = 1;
|
||||
if (ioctl(dhahelper_fd, DHAHELPER_PORT, &_port) == 0)
|
||||
return _port.value;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
__asm__ __volatile__("inb %1,%0" :
|
||||
"=a" (ret) :
|
||||
"d" (port));
|
||||
|
@ -38,6 +106,19 @@ static __inline__ unsigned int inb(short port)
|
|||
static __inline__ unsigned int inw(short port)
|
||||
{
|
||||
unsigned short ret;
|
||||
#ifdef CONFIG_DHAHELPER
|
||||
if (dhahelper_initialized == 1)
|
||||
{
|
||||
dhahelper_port_t _port;
|
||||
|
||||
_port.operation = PORT_OP_READ;
|
||||
_port.addr = port;
|
||||
_port.size = 2;
|
||||
if (ioctl(dhahelper_fd, DHAHELPER_PORT, &_port) == 0)
|
||||
return _port.value;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
__asm__ __volatile__("inw %1,%0" :
|
||||
"=a" (ret) :
|
||||
"d" (port));
|
||||
|
@ -47,6 +128,19 @@ static __inline__ unsigned int inw(short port)
|
|||
static __inline__ unsigned int inl(short port)
|
||||
{
|
||||
unsigned int ret;
|
||||
#ifdef CONFIG_DHAHELPER
|
||||
if (dhahelper_initialized == 1)
|
||||
{
|
||||
dhahelper_port_t _port;
|
||||
|
||||
_port.operation = PORT_OP_READ;
|
||||
_port.addr = port;
|
||||
_port.size = 4;
|
||||
if (ioctl(dhahelper_fd, DHAHELPER_PORT, &_port) == 0)
|
||||
return _port.value;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
__asm__ __volatile__("inl %1,%0" :
|
||||
"=a" (ret) :
|
||||
"d" (port));
|
||||
|
|
|
@ -10,8 +10,26 @@
|
|||
#include <sys/io.h>
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef CONFIG_DHAHELPER
|
||||
#include <fcntl.h>
|
||||
int dhahelper_initialized = 0;
|
||||
int dhahelper_fd = 0;
|
||||
#endif
|
||||
|
||||
static __inline__ int enable_os_io(void)
|
||||
{
|
||||
#ifdef CONFIG_DHAHELPER
|
||||
dhahelper_fd = open("/dev/dhahelper", O_RDWR);
|
||||
if (dhahelper_fd > 0)
|
||||
{
|
||||
dhahelper_initialized = 1;
|
||||
return(0);
|
||||
}
|
||||
dhahelper_initialized = -1;
|
||||
#endif
|
||||
|
||||
if (iopl(3) != 0)
|
||||
return(errno);
|
||||
return(0);
|
||||
|
@ -19,6 +37,11 @@ static __inline__ int enable_os_io(void)
|
|||
|
||||
static __inline__ int disable_os_io(void)
|
||||
{
|
||||
#ifdef CONFIG_DHAHELPER
|
||||
if (dhahelper_initialized == 1)
|
||||
close(dhahelper_fd);
|
||||
else
|
||||
#endif
|
||||
if (iopl(0) != 0)
|
||||
return(errno);
|
||||
return(0);
|
||||
|
|
Loading…
Reference in New Issue