Update of /cvsroot/xine/xine-lib/src/video_out/libdha/sysdep In directory usw-pr-cvs1:/tmp/cvs-serv6216/src/video_out/libdha/sysdep Added Files: AsmMacros_alpha.h AsmMacros_arm32.h AsmMacros_ia64.h AsmMacros_powerpc.h AsmMacros_sparc.h AsmMacros_x86.h Makefile.am libdha_os2.c libdha_win32.c pci_386bsd.c pci_alpha.c pci_arm32.c pci_bsdi.c pci_freebsd.c pci_ia64.c pci_isc.c pci_linux.c pci_lynx.c pci_mach386.c pci_netbsd.c pci_openbsd.c pci_os2.c pci_powerpc.c pci_sco.c pci_sparc.c pci_svr4.c pci_win32.c pci_x86.c Log Message: Add vidix/libdha from mplayerxp and Miguel's video ouput vidix. --- NEW FILE: AsmMacros_alpha.h --- /* This file is based on: $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/util/AsmMacros.h,v 1.1 2001/11/16 21:13:34 tsi Exp $ Modified for readability by Nick Kurshev */ #ifndef __ASM_MACROS_ALPHA_H #define __ASM_MACROS_ALPHA_H #if defined (linux) #include <sys/io.h> #elif defined (__FreeBSD__) #include <sys/types.h> extern void outb(u_int32_t port, u_int8_t val); extern void outw(u_int32_t port, u_int16_t val); extern void outl(u_int32_t port, u_int32_t val); 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 #endif #define intr_disable() #define intr_enable() #endif --- NEW FILE: AsmMacros_arm32.h --- /* This file is based on: $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/util/AsmMacros.h,v 1.1 2001/11/16 21:13:34 tsi Exp $ Modified for readability by Nick Kurshev */ #ifndef __ASM_MACROS_ARM32_H #define __ASM_MACROS_ARM32_H unsigned int IOPortBase; /* Memory mapped I/O port area */ static __inline__ void outb(short port,char val) { if ((unsigned short)port >= 0x400) return; *(volatile unsigned char*)(((unsigned short)(port))+IOPortBase) = val; } static __inline__ void outw(short port,short val) { if ((unsigned short)port >= 0x400) return; *(volatile unsigned short*)(((unsigned short)(port))+IOPortBase) = val; } static __inline__ void outl(short port,int val) { if ((unsigned short)port >= 0x400) return; *(volatile unsigned long*)(((unsigned short)(port))+IOPortBase) = val; } static __inline__ unsigned int inb(short port) { if ((unsigned short)port >= 0x400) return((unsigned int)-1); return(*(volatile unsigned char*)(((unsigned short)(port))+IOPortBase)); } static __inline__ unsigned int inw(short port) { if ((unsigned short)port >= 0x400) return((unsigned int)-1); return(*(volatile unsigned short*)(((unsigned short)(port))+IOPortBase)); } static __inline__ unsigned int inl(short port) { if ((unsigned short)port >= 0x400) return((unsigned int)-1); return(*(volatile unsigned long*)(((unsigned short)(port))+IOPortBase)); } #define intr_disable() #define intr_enable() #endif --- NEW FILE: AsmMacros_ia64.h --- /* This file is based on: $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/util/AsmMacros.h,v 1.1 2001/11/16 21:13:34 tsi Exp $ Modified for readability by Nick Kurshev */ #ifndef __ASM_MACROS_IA64_H #define __ASM_MACROS_IA64_H #if defined(linux) #include <sys/io.h> #else #error This stuff is not ported on your system #endif #endif --- NEW FILE: AsmMacros_powerpc.h --- /* This file is based on: $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/util/AsmMacros.h,v 1.1 2001/11/16 21:13:34 tsi Exp $ Modified for readability by Nick Kurshev */ #ifndef __ASM_MACROS_POWERPC_H #define __ASM_MACROS_POWERPC_H #if defined(Lynx) extern unsigned char *ioBase; static __inline__ volatile void eieio() { __asm__ __volatile__ ("eieio"); } static __inline__ void outb(short port, unsigned char value) { *(uchar *)(ioBase + port) = value; eieio(); } static __inline__ void outw(short port, unsigned short value) { *(unsigned short *)(ioBase + port) = value; eieio(); } static __inline__ void outl(short port, unsigned short value) { *(unsigned long *)(ioBase + port) = value; eieio(); } static __inline__ unsigned char inb(short port) { unsigned char val; val = *((unsigned char *)(ioBase + port)); eieio(); return(val); } static __inline__ unsigned short inw(short port) { unsigned short val; val = *((unsigned short *)(ioBase + port)); eieio(); return(val); } static __inline__ unsigned long inl(short port) { unsigned long val; val = *((unsigned long *)(ioBase + port)); eieio(); return(val); } #define intr_disable() #define intr_enable() #else #error This stuff is not ported on your system #endif #endif --- NEW FILE: AsmMacros_sparc.h --- /* This file is based on: $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/util/AsmMacros.h,v 1.1 2001/11/16 21:13:34 tsi Exp $ Modified for readability by Nick Kurshev */ #ifndef __ASM_MACROS_SPARC_H #define __ASM_MACROS_SPARC_H #ifndef ASI_PL #define ASI_PL 0x88 #endif static __inline__ void outb(unsigned long port, char val) { __asm__ __volatile__("stba %0, [%1] %2" : : "r" (val), "r" (port), "i" (ASI_PL)); } static __inline__ void outw(unsigned long port, char val) { __asm__ __volatile__("stha %0, [%1] %2" : : "r" (val), "r" (port), "i" (ASI_PL)); } static __inline__ void outl(unsigned long port, char val) { __asm__ __volatile__("sta %0, [%1] %2" : : "r" (val), "r" (port), "i" (ASI_PL)); } static __inline__ unsigned int inb(unsigned long port) { unsigned char ret; __asm__ __volatile__("lduba [%1] %2, %0" : "=r" (ret) : "r" (port), "i" (ASI_PL)); return ret; } static __inline__ unsigned int inw(unsigned long port) { unsigned char ret; __asm__ __volatile__("lduha [%1] %2, %0" : "=r" (ret) : "r" (port), "i" (ASI_PL)); return ret; } static __inline__ unsigned int inl(unsigned long port) { unsigned char ret; __asm__ __volatile__("lda [%1] %2, %0" : "=r" (ret) : "r" (port), "i" (ASI_PL)); return ret; } #define intr_disable() #define intr_enable() #endif --- NEW FILE: AsmMacros_x86.h --- /* This file is based on: $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/util/AsmMacros.h,v 1.1 2001/11/16 21:13:34 tsi Exp $ Modified for readability by Nick Kurshev */ #ifndef __ASM_MACROS_X86_H #define __ASM_MACROS_X86_H #if defined (WINNT) #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)); return ret; } 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)); return ret; } 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)); return ret; } static __inline__ void intr_disable() { __asm__ __volatile__("cli"); } static __inline__ void intr_enable() { __asm__ __volatile__("sti"); } #endif #endif --- NEW FILE: Makefile.am --- EXTRA_DIST = libdha_os2.c pci_arm32.c pci_isc.c pci_netbsd.c pci_sco.c pci_x86.c \ libdha_win32.c pci_bsdi.c pci_linux.c pci_openbsd.c pci_sparc.c pci_386bsd.c \ pci_freebsd.c pci_lynx.c pci_os2.c pci_svr4.c pci_alpha.c pci_ia64.c pci_mach386.c \ pci_powerpc.c pci_win32.c noinst_HEADERS = AsmMacros_alpha.h AsmMacros_ia64.h AsmMacros_sparc.h AsmMacros_arm32.h \ AsmMacros_powerpc.h AsmMacros_x86.h debug: install-debug: mostlyclean-generic: -rm -f *~ \#* .*~ .\#* maintainer-clean-generic: -@echo "This command is intended for maintainers to use;" -@echo "it deletes files that may require special tools to rebuild." -rm -f Makefile.in --- NEW FILE: libdha_os2.c --- /* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_video.c,v 3.14 2000/10/28 01:42:28 mvojkovi Exp $ */ /* Modified for libdha by Nick Kurshev. */ /* * (c) Copyright 1994,1999 by Holger Veit * <Hol...@gm...> * Modified 1996 by Sebastien Marineau <mar...@ge...> * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * HOLGER VEIT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * Except as contained in this notice, the name of Holger Veit shall not be * used in advertising or otherwise to promote the sale, use or other dealings * in this Software without prior written authorization from Holger Veit. * */ /* $XConsortium: os2_video.c /main/8 1996/10/27 11:49:02 kaleb $ */ #define INCL_DOSFILEMGR #include "os2.h" /***************************************************************************/ /* Video Memory Mapping helper functions */ /***************************************************************************/ /* This section uses the xf86sup.sys driver developed for xfree86. * The driver allows mapping of physical memory * You must install it with a line DEVICE=path\xf86sup.sys in config.sys. */ static HFILE mapdev = -1; static ULONG stored_virt_addr; static char* mappath = "\\DEV\\PMAP$"; static HFILE open_mmap() { APIRET rc; ULONG action; if (mapdev != -1) return mapdev; rc = DosOpen((PSZ)mappath, (PHFILE)&mapdev, (PULONG)&action, (ULONG)0, FILE_SYSTEM, FILE_OPEN, OPEN_SHARE_DENYNONE|OPEN_FLAGS_NOINHERIT|OPEN_ACCESS_READONLY, (ULONG)0); if (rc!=0) mapdev = -1; return mapdev; } static void close_mmap() { if (mapdev != -1) DosClose(mapdev); mapdev = -1; } /* this structure is used as a parameter packet for the direct access * ioctl of pmap$ */ /* Changed here for structure of driver PMAP$ */ typedef struct{ ULONG addr; ULONG size; } DIOParPkt; /* This is the data packet for the mapping function */ typedef struct { ULONG addr; USHORT sel; } DIODtaPkt; /***************************************************************************/ /* Video Memory Mapping section */ /***************************************************************************/ static long callcount = 0L; /* ARGSUSED */ void * map_phys_mem(unsigned long base, unsigned long size) { DIOParPkt par; ULONG plen; DIODtaPkt dta; ULONG dlen; static BOOL ErrRedir = FALSE; APIRET rc; par.addr = (ULONG)base; par.size = (ULONG)size; plen = sizeof(par); dlen = sizeof(dta); open_mmap(); if (mapdev == -1) { perror("libdha: device xf86sup.sys is not installed"); exit(1); } if ((rc=DosDevIOCtl(mapdev, (ULONG)0x76, (ULONG)0x44, (PVOID)&par, (ULONG)plen, (PULONG)&plen, (PVOID)&dta, (ULONG)dlen, (PULONG)&dlen)) == 0) { if (dlen==sizeof(dta)) { callcount++; return (void *)dta.addr; } /*else fail*/ } return (void *)-1; } /* ARGSUSED */ void unmap_phys_mem(void * base, unsigned long size) { DIOParPkt par; ULONG plen,vmaddr; /* We need here the VIRTADDR for unmapping, not the physical address */ /* This should be taken care of either here by keeping track of allocated */ /* pointers, but this is also already done in the driver... Thus it would */ /* be a waste to do this tracking twice. Can this be changed when the fn. */ /* is called? This would require tracking this function in all servers, */ /* and changing it appropriately to call this with the virtual adress */ /* If the above mapping function is only called once, then we can store */ /* the virtual adress and use it here.... */ par.addr = (ULONG)base; par.size = 0xffffffff; /* This is the virtual address parameter. Set this to ignore */ plen = sizeof(par); if (mapdev != -1) { DosDevIOCtl(mapdev, (ULONG)0x76, (ULONG)0x46, (PVOID)&par, (ULONG)plen, (PULONG)&plen, &vmaddr, sizeof(ULONG), &plen); callcount--; } /* Now if more than one region has been allocated and we close the driver, * the other pointers will immediately become invalid. We avoid closing * driver for now, but this should be fixed for server exit */ if(!callcount) close_mmap(); } --- NEW FILE: libdha_win32.c --- /* MAPDEV.h - include file for VxD MAPDEV Copyright (c) 1996 Vireo Software, Inc. Modified for libdha by Nick Kurshev. */ #include <windows.h> /* This is the request structure that applications use to request services from the MAPDEV VxD. */ typedef struct _MapDevRequest { DWORD mdr_ServiceID; /* supplied by caller */ LPVOID mdr_PhysicalAddress; /* supplied by caller */ DWORD mdr_SizeInBytes; /* supplied by caller */ LPVOID mdr_LinearAddress; /* returned by VxD */ WORD mdr_Selector; /* returned if 16-bit caller */ WORD mdr_Status; /* MDR_xxxx code below */ } MAPDEVREQUEST, *PMAPDEVREQUEST; #define MDR_SERVICE_MAP CTL_CODE(FILE_DEVICE_UNKNOWN, 1, METHOD_NEITHER, FILE_ANY_ACCESS) #define MDR_SERVICE_UNMAP CTL_CODE(FILE_DEVICE_UNKNOWN, 2, METHOD_NEITHER, FILE_ANY_ACCESS) #define MDR_STATUS_SUCCESS 1 #define MDR_STATUS_ERROR 0 /*#include "winioctl.h"*/ #define FILE_DEVICE_UNKNOWN 0x00000022 #define METHOD_NEITHER 3 #define FILE_ANY_ACCESS 0 #define CTL_CODE( DeviceType, Function, Method, Access ) ( \ ((DeviceType)<<16) | ((Access)<<14) | ((Function)<<2) | (Method) ) /* Memory Map a piece of Real Memory */ void *map_phys_mem(unsigned base, unsigned size) { HANDLE hDevice ; PVOID inBuf[1] ; /* buffer for struct pointer to VxD */ DWORD RetInfo[2] ; /* buffer to receive data from VxD */ DWORD cbBytesReturned ; /* count of bytes returned from VxD */ MAPDEVREQUEST req ; /* map device request structure */ DWORD *pNicstar, Status, Time ; int i ; char *endptr ; const PCHAR VxDName = "\\\\.\\MAPDEV.VXD" ; const PCHAR VxDNameAlreadyLoaded = "\\\\.\\MAPDEV" ; hDevice = CreateFile(VxDName, 0,0,0, CREATE_NEW, FILE_FLAG_DELETE_ON_CLOSE, 0) ; if (hDevice == INVALID_HANDLE_VALUE) hDevice = CreateFile(VxDNameAlreadyLoaded, 0,0,0, CREATE_NEW, FILE_FLAG_DELETE_ON_CLOSE, 0) ; if (hDevice == INVALID_HANDLE_VALUE) { fprintf(stderr, "Cannot open driver, error=%08lx\n", GetLastError()) ; exit(1) ; } req.mdr_ServiceID = MDR_SERVICE_MAP ; req.mdr_PhysicalAddress = (PVOID)base ; req.mdr_SizeInBytes = size ; inBuf[0] = &req ; if ( ! DeviceIoControl(hDevice, MDR_SERVICE_MAP, inBuf, sizeof(PVOID), NULL, 0, &cbBytesReturned, NULL) ) { fprintf(stderr, "Failed to map device\n") ; exit(1) ; } return (void*)req.mdr_LinearAddress ; } void unmap_phys_mem(void *ptr, unsigned size) { } --- NEW FILE: pci_386bsd.c --- /* This file is based on: $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 #define GCCUSESGAS #endif static int io_fd; static __inline__ int enable_os_io(void) { io_fd = -1 ; if ((io_fd = open("/dev/console", O_RDWR, 0)) < 0) { perror("/dev/console"); return(errno); } if (ioctl(io_fd, KDENABIO, 0) < 0) { perror("ioctl(KDENABIO)"); return(errno); } return(0); } static __inline__ int disable_os_io(void) { if (ioctl(io_fd, KDDISABIO, 0) < 0) { perror("ioctl(KDDISABIO)"); close(io_fd); return(errno); } close(io_fd); return(0); } --- NEW FILE: pci_alpha.c --- /* This file is based on: $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 */ static int pci_config_type( void ) { return 1; } static int pci_get_vendor( unsigned char bus, unsigned char dev, int func) { unsigned long retval; pciconfig_read(bus, dev<<3, PCI_ID_REG, 4, &retval); return retval; } static long pci_config_read_long( unsigned char bus, unsigned char dev, int func, unsigned cmd) { unsigned long retval; pciconfig_read(bus, dev<<3, cmd, 4, &retval); return retval; } --- NEW FILE: pci_arm32.c --- /* This file is based on: $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 */ static int pci_config_type( void ) { unsigned long tmplong1, tmplong2; unsigned char tmp1, tmp2; 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); 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); if (tmplong2 == PCI_EN) { retval = 1; /*printf("PCI says configuration type 1\n");*/ } else { /*printf("No PCI !\n");*/ disable_os_io(); /*exit(1);*/ retval = 0xFFFF; } } return retval; } static int pci_get_vendor( unsigned char bus, unsigned char dev, int func) { 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); } static long pci_config_read_long( unsigned char bus, unsigned char dev, int func, unsigned cmd) { 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); } --- NEW FILE: pci_bsdi.c --- /* This file is based on: $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> #ifndef GCCUSESGAS #define GCCUSESGAS #endif static int io_fd; static __inline__ int enable_os_io(void) { io_fd = -1 ; if ((io_fd = open("/dev/console", O_RDWR, 0)) < 0) { perror("/dev/console"); return(errno); } if (ioctl(io_fd, PCCONENABIOPL, 0) < 0) { perror("ioctl(PCCONENABIOPL)"); return(errno); } return(0); } static __inline__ int disable_os_io(void) { if (ioctl(io_fd, PCCONDISABIOPL, 0) < 0) { perror("ioctl(PCCONDISABIOPL)"); close(io_fd); return(errno); } close(io_fd); return(0); } --- NEW FILE: pci_freebsd.c --- /* This file is based on: $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> /* machine/console.h seems to be outdated by recent FreeBSD * * however pcvt_ioctl.h seems to exist for very long time */ /* #include <machine/console.h>*/ #include <machine/pcvt_ioctl.h> #ifndef GCCUSESGAS #define GCCUSESGAS #endif static int io_fd; static __inline__ int enable_os_io(void) { io_fd = -1 ; if ((io_fd = open("/dev/console", O_RDWR, 0)) < 0) { perror("/dev/console"); return(errno); } if (ioctl(io_fd, KDENABIO, 0) < 0) { perror("ioctl(KDENABIO)"); return(errno); } return(0); } static __inline__ int disable_os_io(void) { if (ioctl(io_fd, KDDISABIO, 0) < 0) { perror("ioctl(KDDISABIO)"); close(io_fd); return(errno); } close(io_fd); return(0); } --- NEW FILE: pci_ia64.c --- /* This file is based on: $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 */ static int pci_config_type( void ) { unsigned long tmplong1, tmplong2; unsigned char tmp1, tmp2; 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); 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); if (tmplong2 == PCI_EN) { retval = 1; /*printf("PCI says configuration type 1\n");*/ } else { /*printf("No PCI !\n");*/ disable_os_io(); /*exit(1);*/ retval = 0xFFFF; } } return retval; } static int pci_get_vendor( unsigned char bus, unsigned char dev, int func) { 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); } static long pci_config_read_long( unsigned char bus, unsigned char dev, int func, unsigned cmd) { 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); } --- NEW FILE: pci_isc.c --- /* This file is based on: $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 <sys/param.h> #include <sys/immu.h> #include <sys/region.h> #include <sys/proc.h> #include <sys/tss.h> #include <sys/sysi86.h> #include <sys/v86.h> 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__ int disable_os_io(void) { #if defined(SI86IOPL) sysi86(SI86IOPL, 0); #else sysi86(SI86V86, V86SC_IOPL, 0); #endif return(0); } --- NEW FILE: pci_linux.c --- /* This file is based on: $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 #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); } 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); } --- NEW FILE: pci_lynx.c --- /* This file is based on: $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 */ #if defined(Lynx_22) #ifndef GCCUSESGAS #define GCCUSESGAS #endif /* let's mimick the Linux Alpha stuff for LynxOS so we don't have * to change too much code */ #include <smem.h> static unsigned char *pciConfBase; static __inline__ void enable_os_io(void) { pciConfBase = (unsigned char *) smem_create("PCI-CONF", (char *)0x80800000, 64*1024, SM_READ|SM_WRITE); if (pciConfBase == (void *) -1) exit(1); } static __inline__ void disable_os_io(void) { smem_create(NULL, (char *) pciConfBase, 0, SM_DETACH); smem_remove("PCI-CONF"); pciConfBase = NULL; } #include <smem.h> static unsigned char *pciConfBase; static __inline__ unsigned long static swapl(unsigned long val) { unsigned char *p = (unsigned char *)&val; return ((p[3] << 24) | (p[2] << 16) | (p[1] << 8) | (p[0] << 0)); } #define BUS(tag) (((tag)>>16)&0xff) #define DFN(tag) (((tag)>>8)&0xff) #define PCIBIOS_DEVICE_NOT_FOUND 0x86 #define PCIBIOS_SUCCESSFUL 0x00 static int pciconfig_read( unsigned char bus, unsigned char dev, unsigned char offset, int len, /* unused, alway 4 */ unsigned long *val) { unsigned long _val; unsigned long *ptr; dev >>= 3; if (bus || dev >= 16) { *val = 0xFFFFFFFF; return PCIBIOS_DEVICE_NOT_FOUND; } else { ptr = (unsigned long *)(pciConfBase + ((1<<dev) | offset)); _val = swapl(*ptr); } *val = _val; return PCIBIOS_SUCCESSFUL; } static int pciconfig_write( unsigned char bus, unsigned char dev, unsigned char offset, int len, /* unused, alway 4 */ unsigned long val) { unsigned long _val; unsigned long *ptr; dev >>= 3; _val = swapl(val); if (bus || dev >= 16) { return PCIBIOS_DEVICE_NOT_FOUND; } else { ptr = (unsigned long *)(pciConfBase + ((1<<dev) | offset)); *ptr = _val; } return PCIBIOS_SUCCESSFUL; } --- NEW FILE: pci_mach386.c --- /* This file is based on: $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> static int io_fd; static __inline__ int enable_os_io(void) { io_fd = -1 ; if ((io_fd = open("/dev/iopl", O_RDWR, 0)) < 0) { perror("/dev/iopl"); return(errno); } return(0); } static __inline__ int disable_os_io(void) { close(io_fd); return(0); } --- NEW FILE: pci_netbsd.c --- /* This file is based on: $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> #ifndef GCCUSESGAS #define GCCUSESGAS #endif static int io_fd; 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"); return(errno); } #else if (i386_iopl(1) < 0) { perror("i386_iopl"); return(errno); } #endif /* USE_I386_IOPL */ return(0); } static __inline__ int disable_os_io(void) { #if !defined(USE_I386_IOPL) close(io_fd); #else if (i386_iopl(0) < 0) { perror("i386_iopl"); return(errno); } #endif /* NetBSD1_1 */ return(0); } --- NEW FILE: pci_openbsd.c --- /* This file is based on: $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/types.h> #include <machine/sysarch.h> static __inline__ int enable_os_io(void) { if (i386_iopl(1) < 0) { perror("i386_iopl"); return(errno); } return(0); } static __inline__ int disable_os_io(void) { /* Nothing to do */ return(0); } --- NEW FILE: pci_os2.c --- /* This file is based on: $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 */ #define INCL_DOSFILEMGR #include <os2.h> static USHORT callgate[3] = {0,0,0}; static __inline__ int enable_os_io(void) { HFILE hfd; ULONG dlen,action; APIRET rc; static char *ioDrvPath = "/dev/fastio$"; if (DosOpen((PSZ)ioDrvPath, (PHFILE)&hfd, (PULONG)&action, (ULONG)0, FILE_SYSTEM, FILE_OPEN, OPEN_SHARE_DENYNONE|OPEN_FLAGS_NOINHERIT|OPEN_ACCESS_READONLY, (ULONG)0) != 0) { fprintf(stderr,"Error opening fastio$ driver...\n"); fprintf(stderr,"Please install xf86sup.sys in config.sys!\n"); return(42); } callgate[0] = callgate[1] = 0; /* Get callgate from driver for fast io to ports and other stuff */ rc = DosDevIOCtl(hfd, (ULONG)0x76, (ULONG)0x64, NULL, 0, NULL, (ULONG*)&callgate[2], sizeof(USHORT), &dlen); if (rc) { fprintf(stderr,"xf86-OS/2: EnableIOPorts failed, rc=%d, dlen=%d; emergency exit\n", rc,dlen); DosClose(hfd); return(42); } /* Calling callgate with function 13 sets IOPL for the program */ asm volatile ("movl $13,%%ebx;.byte 0xff,0x1d;.long _callgate" : /*no outputs */ : /*no inputs */ : "eax","ebx","ecx","edx","cc"); DosClose(hfd); return(0); } static __inline__ int disable_os_io(void) { /* Nothing to do */ return(0); } --- NEW FILE: pci_powerpc.c --- /* This file is based on: $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 */ static int pci_config_type( void ) { return 1; } static int pci_get_vendor( unsigned char bus, unsigned char dev, int func) { int retval; pciconfig_read(bus, dev<<3, PCI_ID_REG, 4, &retval); return retval; } static long pci_config_read_long( unsigned char bus, unsigned char dev, int func, unsigned cmd) { long retval; pciconfig_read(bus, dev<<3, cmd, 4, &retval); return retval; } --- NEW FILE: pci_sco.c --- /* This file is based on: $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 <sys/console.h> #include <sys/param.h> #include <sys/immu.h> #include <sys/region.h> #include <sys/proc.h> #include <sys/tss.h> #include <sys/sysi86.h> #include <sys/v86.h> 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__ int disable_os_io(void) { #if defined(SI86IOPL) sysi86(SI86IOPL, 0); #else sysi86(SI86V86, V86SC_IOPL, 0); #endif return(0); } --- NEW FILE: pci_sparc.c --- /* This file is based on: $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 */ static int pci_config_type( void ) { unsigned long tmplong1, tmplong2; unsigned char tmp1, tmp2; 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); 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); if (tmplong2 == PCI_EN) { retval = 1; /*printf("PCI says configuration type 1\n");*/ } else { /*printf("No PCI !\n");*/ disable_os_io(); /*exit(1);*/ retval = 0xFFFF; } } return retval; } static int pci_get_vendor( unsigned char bus, unsigned char dev, int func) { 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); } static long pci_config_read_long( unsigned char bus, unsigned char dev, int func, unsigned cmd) { 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); } --- NEW FILE: pci_svr4.c --- /* This file is based on: $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 <sys/types.h> #include <sys/proc.h> #include <sys/tss.h> #if defined(NCR) #define __STDC #include <sys/sysi86.h> #undef __STDC #else #include <sys/sysi86.h> #endif #if defined(sun) # ifndef __EXTENSIONS__ # define __EXTENSIONS__ # endif # include <sys/psw.h> #endif 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__ int disable_os_io(void) { #if defined(SI86IOPL) sysi86(SI86IOPL, 0); #else sysi86(SI86V86, V86SC_IOPL, 0); #endif return(0); } --- NEW FILE: pci_win32.c --- /* This file is based on: $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 <windows.h> /* Nothing to do for Win9x. For WinNT I have no solution */ static __inline__ int enable_os_io(void) { return(0); } static __inline__ int disable_os_io(void) { return(0); } --- NEW FILE: pci_x86.c --- /* This file is based on: $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 */ static int pci_config_type( void ) { unsigned long tmplong1, tmplong2; unsigned char tmp1, tmp2; 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); 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); if (tmplong2 == PCI_EN) { retval = 1; /*printf("PCI says configuration type 1\n");*/ } else { /*printf("No PCI !\n");*/ disable_os_io(); /*exit(1);*/ retval = 0xFFFF; } } return retval; } static int pci_get_vendor( unsigned char bus, unsigned char dev, int func) { 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); } static long pci_config_read_long( unsigned char bus, unsigned char dev, int func, unsigned cmd) { 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); } |