diff options
author | Miguel Freitas <miguelfreitas@users.sourceforge.net> | 2003-01-13 23:36:01 +0000 |
---|---|---|
committer | Miguel Freitas <miguelfreitas@users.sourceforge.net> | 2003-01-13 23:36:01 +0000 |
commit | 9baa6d2f372d3e09280e1103d7bfcf048f6457ec (patch) | |
tree | cf3bfc3fb392fe58ed612a5a09c11d176eb17e99 /src/video_out/libdha/sysdep | |
parent | 989188f25474868841d8a5148873a5995be58c6f (diff) | |
download | xine-lib-9baa6d2f372d3e09280e1103d7bfcf048f6457ec.tar.gz xine-lib-9baa6d2f372d3e09280e1103d7bfcf048f6457ec.tar.bz2 |
big vidix driver update by James Stembridge
CVS patchset: 3907
CVS date: 2003/01/13 23:36:01
Diffstat (limited to 'src/video_out/libdha/sysdep')
-rw-r--r-- | src/video_out/libdha/sysdep/AsmMacros_alpha.h | 2 | ||||
-rw-r--r-- | src/video_out/libdha/sysdep/AsmMacros_ia64.h | 2 | ||||
-rw-r--r-- | src/video_out/libdha/sysdep/AsmMacros_powerpc.h | 6 | ||||
-rw-r--r-- | src/video_out/libdha/sysdep/AsmMacros_x86.h | 92 | ||||
-rw-r--r-- | src/video_out/libdha/sysdep/pci_alpha.c | 51 | ||||
-rw-r--r-- | src/video_out/libdha/sysdep/pci_arm32.c | 89 | ||||
-rw-r--r-- | src/video_out/libdha/sysdep/pci_ia64.c | 89 | ||||
-rw-r--r-- | src/video_out/libdha/sysdep/pci_linux.c | 2 | ||||
-rw-r--r-- | src/video_out/libdha/sysdep/pci_openbsd.c | 3 | ||||
-rw-r--r-- | src/video_out/libdha/sysdep/pci_powerpc.c | 234 | ||||
-rw-r--r-- | src/video_out/libdha/sysdep/pci_sparc.c | 89 | ||||
-rw-r--r-- | src/video_out/libdha/sysdep/pci_x86.c | 89 |
12 files changed, 600 insertions, 148 deletions
diff --git a/src/video_out/libdha/sysdep/AsmMacros_alpha.h b/src/video_out/libdha/sysdep/AsmMacros_alpha.h index 482b59000..59da53891 100644 --- a/src/video_out/libdha/sysdep/AsmMacros_alpha.h +++ b/src/video_out/libdha/sysdep/AsmMacros_alpha.h @@ -17,7 +17,7 @@ extern u_int8_t inb(u_int32_t port); extern u_int16_t inw(u_int32_t port); extern u_int32_t inl(u_int32_t port); #else -#error This stuff is not ported on your system +#include "sysdep/AsmMacros_generic.h" #endif #define intr_disable() diff --git a/src/video_out/libdha/sysdep/AsmMacros_ia64.h b/src/video_out/libdha/sysdep/AsmMacros_ia64.h index e59732fda..7d6123f33 100644 --- a/src/video_out/libdha/sysdep/AsmMacros_ia64.h +++ b/src/video_out/libdha/sysdep/AsmMacros_ia64.h @@ -10,7 +10,7 @@ #if defined(linux) #include <sys/io.h> #else -#error This stuff is not ported on your system +#include "sysdep/AsmMacros_generic.h" #endif #endif diff --git a/src/video_out/libdha/sysdep/AsmMacros_powerpc.h b/src/video_out/libdha/sysdep/AsmMacros_powerpc.h index b17daddbd..cf678c9b8 100644 --- a/src/video_out/libdha/sysdep/AsmMacros_powerpc.h +++ b/src/video_out/libdha/sysdep/AsmMacros_powerpc.h @@ -7,7 +7,7 @@ #ifndef __ASM_MACROS_POWERPC_H #define __ASM_MACROS_POWERPC_H -#if defined(Lynx) +#if defined(Lynx) || defined(__OpenBSD__) extern unsigned char *ioBase; @@ -18,7 +18,7 @@ static __inline__ volatile void eieio() static __inline__ void outb(short port, unsigned char value) { - *(uchar *)(ioBase + port) = value; eieio(); + *(unsigned char *)(ioBase + port) = value; eieio(); } static __inline__ void outw(short port, unsigned short value) @@ -56,7 +56,7 @@ static __inline__ unsigned long inl(short port) #define intr_enable() #else -#error This stuff is not ported on your system +#include "sysdep/AsmMacros_generic.h" #endif #endif diff --git a/src/video_out/libdha/sysdep/AsmMacros_x86.h b/src/video_out/libdha/sysdep/AsmMacros_x86.h index c10f24f2d..97dcaae16 100644 --- a/src/video_out/libdha/sysdep/AsmMacros_x86.h +++ b/src/video_out/libdha/sysdep/AsmMacros_x86.h @@ -8,75 +8,25 @@ #define __ASM_MACROS_X86_H #if defined (WINNT) -#error This stuff is not ported on your system +#include "sysdep/AsmMacros_generic.h" #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; } @@ -84,19 +34,6 @@ static __inline__ void outl(short port,unsigned int val) 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)); @@ -106,19 +43,6 @@ 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)); @@ -128,19 +52,6 @@ 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)); @@ -158,5 +69,4 @@ static __inline__ void intr_enable() } #endif - #endif diff --git a/src/video_out/libdha/sysdep/pci_alpha.c b/src/video_out/libdha/sysdep/pci_alpha.c index e968b3e12..74c3eb687 100644 --- a/src/video_out/libdha/sysdep/pci_alpha.c +++ b/src/video_out/libdha/sysdep/pci_alpha.c @@ -27,3 +27,54 @@ static long pci_config_read_long( return retval; } +static long pci_config_read_word( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd) +{ + unsigned long retval; + pciconfig_read(bus, dev<<3, cmd, 2, &retval); + return retval; +} + +static long pci_config_read_byte( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd) +{ + unsigned long retval; + pciconfig_read(bus, dev<<3, cmd, 1, &retval); + return retval; +} + +static void pci_config_write_long( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd, + long val) +{ + pciconfig_write(bus, dev<<3, cmd, 4, val); +} + +static void pci_config_write_word( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd, + long val) +{ + pciconfig_write(bus, dev<<3, cmd, 2, val); +} + +static void pci_config_write_byte( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd, + long val) +{ + pciconfig_write(bus, dev<<3, cmd, 1, val); +} diff --git a/src/video_out/libdha/sysdep/pci_arm32.c b/src/video_out/libdha/sysdep/pci_arm32.c index a631887da..6920b615e 100644 --- a/src/video_out/libdha/sysdep/pci_arm32.c +++ b/src/video_out/libdha/sysdep/pci_arm32.c @@ -11,24 +11,24 @@ static int pci_config_type( void ) int retval; retval = 0; - outb(PCI_MODE2_ENABLE_REG, 0x00); - outb(PCI_MODE2_FORWARD_REG, 0x00); - tmp1 = inb(PCI_MODE2_ENABLE_REG); - tmp2 = inb(PCI_MODE2_FORWARD_REG); + OUTPORT8(PCI_MODE2_ENABLE_REG, 0x00); + OUTPORT8(PCI_MODE2_FORWARD_REG, 0x00); + tmp1 = INPORT8(PCI_MODE2_ENABLE_REG); + tmp2 = INPORT8(PCI_MODE2_FORWARD_REG); if ((tmp1 == 0x00) && (tmp2 == 0x00)) { retval = 2; /*printf("PCI says configuration type 2\n");*/ } else { - tmplong1 = inl(PCI_MODE1_ADDRESS_REG); - outl(PCI_MODE1_ADDRESS_REG, PCI_EN); - tmplong2 = inl(PCI_MODE1_ADDRESS_REG); - outl(PCI_MODE1_ADDRESS_REG, tmplong1); + tmplong1 = INPORT32(PCI_MODE1_ADDRESS_REG); + OUTPORT32(PCI_MODE1_ADDRESS_REG, PCI_EN); + tmplong2 = INPORT32(PCI_MODE1_ADDRESS_REG); + OUTPORT32(PCI_MODE1_ADDRESS_REG, tmplong1); if (tmplong2 == PCI_EN) { retval = 1; /*printf("PCI says configuration type 1\n");*/ } else { /*printf("No PCI !\n");*/ - disable_os_io(); + disable_app_io(); /*exit(1);*/ retval = 0xFFFF; } @@ -43,8 +43,8 @@ static int pci_get_vendor( { unsigned long config_cmd; config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8); - outl(PCI_MODE1_ADDRESS_REG, config_cmd); - return inl(PCI_MODE1_DATA_REG); + OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd); + return INPORT32(PCI_MODE1_DATA_REG); } static long pci_config_read_long( @@ -55,6 +55,69 @@ static long pci_config_read_long( { unsigned long config_cmd; config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8); - outl(PCI_MODE1_ADDRESS_REG, config_cmd | cmd); - return inl(PCI_MODE1_DATA_REG); + OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd | cmd); + return INPORT32(PCI_MODE1_DATA_REG); +} + +static long pci_config_read_word( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd) +{ + unsigned long config_cmd; + config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8); + OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd | cmd); + return INPORT16(PCI_MODE1_DATA_REG); +} + +static long pci_config_read_byte( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd) +{ + unsigned long config_cmd; + config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8); + OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd | cmd); + return INPORT8(PCI_MODE1_DATA_REG); +} + +static void pci_config_write_long( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd, + long val) +{ + unsigned long config_cmd; + config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8); + OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd | cmd); + OUTPORT32(PCI_MODE1_DATA_REG,val); +} + +static void pci_config_write_word( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd, + unsigned val) +{ + unsigned long config_cmd; + config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8); + OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd | cmd); + OUTPORT16(PCI_MODE1_DATA_REG,val); +} + +static void pci_config_write_byte( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd, + long val) +{ + unsigned long config_cmd; + config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8); + OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd | cmd); + OUTPORT8(PCI_MODE1_DATA_REG,val); } diff --git a/src/video_out/libdha/sysdep/pci_ia64.c b/src/video_out/libdha/sysdep/pci_ia64.c index a631887da..ef2074ab2 100644 --- a/src/video_out/libdha/sysdep/pci_ia64.c +++ b/src/video_out/libdha/sysdep/pci_ia64.c @@ -11,24 +11,24 @@ static int pci_config_type( void ) int retval; retval = 0; - outb(PCI_MODE2_ENABLE_REG, 0x00); - outb(PCI_MODE2_FORWARD_REG, 0x00); - tmp1 = inb(PCI_MODE2_ENABLE_REG); - tmp2 = inb(PCI_MODE2_FORWARD_REG); + OUTPORT8(PCI_MODE2_ENABLE_REG, 0x00); + OUTPORT8(PCI_MODE2_FORWARD_REG, 0x00); + tmp1 = INPORT8(PCI_MODE2_ENABLE_REG); + tmp2 = INPORT8(PCI_MODE2_FORWARD_REG); if ((tmp1 == 0x00) && (tmp2 == 0x00)) { retval = 2; /*printf("PCI says configuration type 2\n");*/ } else { - tmplong1 = inl(PCI_MODE1_ADDRESS_REG); - outl(PCI_MODE1_ADDRESS_REG, PCI_EN); - tmplong2 = inl(PCI_MODE1_ADDRESS_REG); - outl(PCI_MODE1_ADDRESS_REG, tmplong1); + tmplong1 = INPORT32(PCI_MODE1_ADDRESS_REG); + OUTPORT32(PCI_MODE1_ADDRESS_REG, PCI_EN); + tmplong2 = INPORT32(PCI_MODE1_ADDRESS_REG); + OUTPORT32(PCI_MODE1_ADDRESS_REG, tmplong1); if (tmplong2 == PCI_EN) { retval = 1; /*printf("PCI says configuration type 1\n");*/ } else { /*printf("No PCI !\n");*/ - disable_os_io(); + disable_app_io(); /*exit(1);*/ retval = 0xFFFF; } @@ -43,8 +43,8 @@ static int pci_get_vendor( { unsigned long config_cmd; config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8); - outl(PCI_MODE1_ADDRESS_REG, config_cmd); - return inl(PCI_MODE1_DATA_REG); + OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd); + return INPORT32(PCI_MODE1_DATA_REG); } static long pci_config_read_long( @@ -55,6 +55,69 @@ static long pci_config_read_long( { unsigned long config_cmd; config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8); - outl(PCI_MODE1_ADDRESS_REG, config_cmd | cmd); - return inl(PCI_MODE1_DATA_REG); + OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd | cmd); + return INPORT32(PCI_MODE1_DATA_REG); +} + +static long pci_config_read_word( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd) +{ + unsigned long config_cmd; + config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8); + OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd | cmd); + return INPORT16(PCI_MODE1_DATA_REG); +} + +static long pci_config_read_byte( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd) +{ + unsigned long config_cmd; + config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8); + OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd | cmd); + return INPORT8(PCI_MODE1_DATA_REG); +} + +static void pci_config_write_long( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd, + long val) +{ + unsigned long config_cmd; + config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8); + OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd | cmd); + OUTPORT32(PCI_MODE1_DATA_REG,val); +} + +static void pci_config_write_word( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd, + long val) +{ + unsigned long config_cmd; + config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8); + OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd | cmd); + OUTPORT16(PCI_MODE1_DATA_REG,val); +} + +static void pci_config_write_byte( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd, + long val) +{ + unsigned long config_cmd; + config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8); + OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd | cmd); + OUTPORT8(PCI_MODE1_DATA_REG,val); } diff --git a/src/video_out/libdha/sysdep/pci_linux.c b/src/video_out/libdha/sysdep/pci_linux.c index 9382ebf2d..6c0d6b42a 100644 --- a/src/video_out/libdha/sysdep/pci_linux.c +++ b/src/video_out/libdha/sysdep/pci_linux.c @@ -7,8 +7,10 @@ #ifdef __i386__ #include <sys/perm.h> #else +#ifndef __sparc__ #include <sys/io.h> #endif +#endif #include "config.h" diff --git a/src/video_out/libdha/sysdep/pci_openbsd.c b/src/video_out/libdha/sysdep/pci_openbsd.c index 13504db81..89c85eab6 100644 --- a/src/video_out/libdha/sysdep/pci_openbsd.c +++ b/src/video_out/libdha/sysdep/pci_openbsd.c @@ -4,6 +4,8 @@ Modified for readability by Nick Kurshev */ +#ifdef __i386__ + #include <errno.h> #include <sys/types.h> #include <machine/sysarch.h> @@ -22,3 +24,4 @@ static __inline__ int disable_os_io(void) /* Nothing to do */ return(0); } +#endif diff --git a/src/video_out/libdha/sysdep/pci_powerpc.c b/src/video_out/libdha/sysdep/pci_powerpc.c index 9239521ec..b2914d551 100644 --- a/src/video_out/libdha/sysdep/pci_powerpc.c +++ b/src/video_out/libdha/sysdep/pci_powerpc.c @@ -6,6 +6,43 @@ static int pci_config_type( void ) { return 1; } +#ifdef linux +#include <fcntl.h> +#include <sys/io.h> +#include <linux/pci.h> +#include "../../bswap.h" +#endif + +#ifdef linux +static int pci_get_vendor( + unsigned char bus, + unsigned char dev, + int func) +{ + int retval; + char path[100]; + int fd; + short vendor, device; + sprintf(path,"/proc/bus/pci/%02d/%02x.0", bus, dev); + fd = open(path,O_RDONLY|O_SYNC); + if (fd == -1) { + retval=0xFFFF; + } + else if (pread(fd, &vendor, 2, PCI_VENDOR_ID) == 2 && + pread(fd, &device, 2, PCI_DEVICE_ID) == 2) { + vendor = bswap_16(vendor); + device = bswap_16(device); + retval = vendor + (device<<16); /*no worries about byte order, + all ppc are bigendian*/ + } else { + retval = 0xFFFF; + } + if (fd > 0) { + close(fd); + } + return retval; +} +#else static int pci_get_vendor( unsigned char bus, unsigned char dev, @@ -15,7 +52,145 @@ static int pci_get_vendor( pciconfig_read(bus, dev<<3, PCI_ID_REG, 4, &retval); return retval; } +#endif +#ifdef linux +static long pci_config_read_long( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd) +{ + long retval; + char path[100]; + int fd; + sprintf(path,"/proc/bus/pci/%02d/%02x.0", bus, dev); + fd = open(path,O_RDONLY|O_SYNC); + if (fd == -1) { + retval=0; + } + else if (pread(fd, &retval, 4, cmd) == 4) { + retval = bswap_32(retval); + } else { + retval = 0; + } + if (fd > 0) { + close(fd); + } + return retval; +} +static long pci_config_read_word( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd) +{ + long retval; + char path[100]; + int fd; + sprintf(path,"/proc/bus/pci/%02d/%02x.0", bus, dev); + fd = open(path,O_RDONLY|O_SYNC); + if (fd == -1) { + retval=0; + } + else if (pread(fd, &retval, 2, cmd) == 2) { + retval = bswap_16(retval); + } else { + retval = 0; + } + if (fd > 0) { + close(fd); + } + return retval; +} + +static long pci_config_read_byte( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd) +{ + long retval; + char path[100]; + int fd; + sprintf(path,"/proc/bus/pci/%02d/%02x.0", bus, dev); + fd = open(path,O_RDONLY|O_SYNC); + if (fd == -1) { + retval=0; + } + else if (pread(fd, &retval, 1, cmd) != 1) { + retval = 0; + } + if (fd > 0) { + close(fd); + } + return retval; +} + +static void pci_config_write_long( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd, + long val) +{ + char path[100]; + int fd; + val = bswap_32(val); + sprintf(path,"/proc/bus/pci/%02d/%02x.0", bus, dev); + fd = open(path,O_RDONLY|O_SYNC); + if (fd == -1) { + retval=0; + } + else pwrite(fd, &val, 4, cmd); + if (fd > 0) { + close(fd); + } +} + +static void pci_config_write_word( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd, + long val) +{ + char path[100]; + int fd; + val = bswap_16(val); + sprintf(path,"/proc/bus/pci/%02d/%02x.0", bus, dev); + fd = open(path,O_RDONLY|O_SYNC); + if (fd == -1) { + retval=0; + } + else pwrite(fd, &val, 2, cmd); + if (fd > 0) { + close(fd); + } + return retval; +} + +static void pci_config_write_byte( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd, + long val) +{ + char path[100]; + int fd; + sprintf(path,"/proc/bus/pci/%02d/%02x.0", bus, dev); + fd = open(path,O_RDONLY|O_SYNC); + if (fd == -1) { + retval=0; + } + else pwrite(fd, &retval, 1, cmd); + if (fd > 0) { + close(fd); + } + return retval; +} +#else static long pci_config_read_long( unsigned char bus, unsigned char dev, @@ -26,3 +201,62 @@ static long pci_config_read_long( pciconfig_read(bus, dev<<3, cmd, 4, &retval); return retval; } + +static long pci_config_read_word( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd) +{ + long retval; + pciconfig_read(bus, dev<<3, cmd, 2, &retval); + return retval; +} + +static long pci_config_read_byte( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd) +{ + long retval; + pciconfig_read(bus, dev<<3, cmd, 1, &retval); + return retval; +} + +static void pci_config_write_long( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd, + long val) +{ + long retval; + pciconfig_write(bus, dev<<3, cmd, 4, val); + return retval; +} + +static void pci_config_write_word( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd, + long val) +{ + long retval; + pciconfig_write(bus, dev<<3, cmd, 2, val); + return retval; +} + +static void pci_config_write_byte( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd, + long val) +{ + long retval; + pciconfig_write(bus, dev<<3, cmd, 1, val); + return retval; +} +#endif diff --git a/src/video_out/libdha/sysdep/pci_sparc.c b/src/video_out/libdha/sysdep/pci_sparc.c index a631887da..ef2074ab2 100644 --- a/src/video_out/libdha/sysdep/pci_sparc.c +++ b/src/video_out/libdha/sysdep/pci_sparc.c @@ -11,24 +11,24 @@ static int pci_config_type( void ) int retval; retval = 0; - outb(PCI_MODE2_ENABLE_REG, 0x00); - outb(PCI_MODE2_FORWARD_REG, 0x00); - tmp1 = inb(PCI_MODE2_ENABLE_REG); - tmp2 = inb(PCI_MODE2_FORWARD_REG); + OUTPORT8(PCI_MODE2_ENABLE_REG, 0x00); + OUTPORT8(PCI_MODE2_FORWARD_REG, 0x00); + tmp1 = INPORT8(PCI_MODE2_ENABLE_REG); + tmp2 = INPORT8(PCI_MODE2_FORWARD_REG); if ((tmp1 == 0x00) && (tmp2 == 0x00)) { retval = 2; /*printf("PCI says configuration type 2\n");*/ } else { - tmplong1 = inl(PCI_MODE1_ADDRESS_REG); - outl(PCI_MODE1_ADDRESS_REG, PCI_EN); - tmplong2 = inl(PCI_MODE1_ADDRESS_REG); - outl(PCI_MODE1_ADDRESS_REG, tmplong1); + tmplong1 = INPORT32(PCI_MODE1_ADDRESS_REG); + OUTPORT32(PCI_MODE1_ADDRESS_REG, PCI_EN); + tmplong2 = INPORT32(PCI_MODE1_ADDRESS_REG); + OUTPORT32(PCI_MODE1_ADDRESS_REG, tmplong1); if (tmplong2 == PCI_EN) { retval = 1; /*printf("PCI says configuration type 1\n");*/ } else { /*printf("No PCI !\n");*/ - disable_os_io(); + disable_app_io(); /*exit(1);*/ retval = 0xFFFF; } @@ -43,8 +43,8 @@ static int pci_get_vendor( { unsigned long config_cmd; config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8); - outl(PCI_MODE1_ADDRESS_REG, config_cmd); - return inl(PCI_MODE1_DATA_REG); + OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd); + return INPORT32(PCI_MODE1_DATA_REG); } static long pci_config_read_long( @@ -55,6 +55,69 @@ static long pci_config_read_long( { unsigned long config_cmd; config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8); - outl(PCI_MODE1_ADDRESS_REG, config_cmd | cmd); - return inl(PCI_MODE1_DATA_REG); + OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd | cmd); + return INPORT32(PCI_MODE1_DATA_REG); +} + +static long pci_config_read_word( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd) +{ + unsigned long config_cmd; + config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8); + OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd | cmd); + return INPORT16(PCI_MODE1_DATA_REG); +} + +static long pci_config_read_byte( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd) +{ + unsigned long config_cmd; + config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8); + OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd | cmd); + return INPORT8(PCI_MODE1_DATA_REG); +} + +static void pci_config_write_long( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd, + long val) +{ + unsigned long config_cmd; + config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8); + OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd | cmd); + OUTPORT32(PCI_MODE1_DATA_REG,val); +} + +static void pci_config_write_word( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd, + long val) +{ + unsigned long config_cmd; + config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8); + OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd | cmd); + OUTPORT16(PCI_MODE1_DATA_REG,val); +} + +static void pci_config_write_byte( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd, + long val) +{ + unsigned long config_cmd; + config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8); + OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd | cmd); + OUTPORT8(PCI_MODE1_DATA_REG,val); } diff --git a/src/video_out/libdha/sysdep/pci_x86.c b/src/video_out/libdha/sysdep/pci_x86.c index a631887da..ef2074ab2 100644 --- a/src/video_out/libdha/sysdep/pci_x86.c +++ b/src/video_out/libdha/sysdep/pci_x86.c @@ -11,24 +11,24 @@ static int pci_config_type( void ) int retval; retval = 0; - outb(PCI_MODE2_ENABLE_REG, 0x00); - outb(PCI_MODE2_FORWARD_REG, 0x00); - tmp1 = inb(PCI_MODE2_ENABLE_REG); - tmp2 = inb(PCI_MODE2_FORWARD_REG); + OUTPORT8(PCI_MODE2_ENABLE_REG, 0x00); + OUTPORT8(PCI_MODE2_FORWARD_REG, 0x00); + tmp1 = INPORT8(PCI_MODE2_ENABLE_REG); + tmp2 = INPORT8(PCI_MODE2_FORWARD_REG); if ((tmp1 == 0x00) && (tmp2 == 0x00)) { retval = 2; /*printf("PCI says configuration type 2\n");*/ } else { - tmplong1 = inl(PCI_MODE1_ADDRESS_REG); - outl(PCI_MODE1_ADDRESS_REG, PCI_EN); - tmplong2 = inl(PCI_MODE1_ADDRESS_REG); - outl(PCI_MODE1_ADDRESS_REG, tmplong1); + tmplong1 = INPORT32(PCI_MODE1_ADDRESS_REG); + OUTPORT32(PCI_MODE1_ADDRESS_REG, PCI_EN); + tmplong2 = INPORT32(PCI_MODE1_ADDRESS_REG); + OUTPORT32(PCI_MODE1_ADDRESS_REG, tmplong1); if (tmplong2 == PCI_EN) { retval = 1; /*printf("PCI says configuration type 1\n");*/ } else { /*printf("No PCI !\n");*/ - disable_os_io(); + disable_app_io(); /*exit(1);*/ retval = 0xFFFF; } @@ -43,8 +43,8 @@ static int pci_get_vendor( { unsigned long config_cmd; config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8); - outl(PCI_MODE1_ADDRESS_REG, config_cmd); - return inl(PCI_MODE1_DATA_REG); + OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd); + return INPORT32(PCI_MODE1_DATA_REG); } static long pci_config_read_long( @@ -55,6 +55,69 @@ static long pci_config_read_long( { unsigned long config_cmd; config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8); - outl(PCI_MODE1_ADDRESS_REG, config_cmd | cmd); - return inl(PCI_MODE1_DATA_REG); + OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd | cmd); + return INPORT32(PCI_MODE1_DATA_REG); +} + +static long pci_config_read_word( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd) +{ + unsigned long config_cmd; + config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8); + OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd | cmd); + return INPORT16(PCI_MODE1_DATA_REG); +} + +static long pci_config_read_byte( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd) +{ + unsigned long config_cmd; + config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8); + OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd | cmd); + return INPORT8(PCI_MODE1_DATA_REG); +} + +static void pci_config_write_long( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd, + long val) +{ + unsigned long config_cmd; + config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8); + OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd | cmd); + OUTPORT32(PCI_MODE1_DATA_REG,val); +} + +static void pci_config_write_word( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd, + long val) +{ + unsigned long config_cmd; + config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8); + OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd | cmd); + OUTPORT16(PCI_MODE1_DATA_REG,val); +} + +static void pci_config_write_byte( + unsigned char bus, + unsigned char dev, + int func, + unsigned cmd, + long val) +{ + unsigned long config_cmd; + config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8); + OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd | cmd); + OUTPORT8(PCI_MODE1_DATA_REG,val); } |