diff options
Diffstat (limited to 'xc/programs/Xserver/hw/kdrive/linux/linux.c')
-rw-r--r-- | xc/programs/Xserver/hw/kdrive/linux/linux.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/xc/programs/Xserver/hw/kdrive/linux/linux.c b/xc/programs/Xserver/hw/kdrive/linux/linux.c index cd89aa266..2c5e0d0be 100644 --- a/xc/programs/Xserver/hw/kdrive/linux/linux.c +++ b/xc/programs/Xserver/hw/kdrive/linux/linux.c @@ -1,5 +1,5 @@ /* - * $XFree86: xc/programs/Xserver/hw/kdrive/linux/linux.c,v 1.4 2000/08/28 02:43:14 tsi Exp $ + * $XFree86: xc/programs/Xserver/hw/kdrive/linux/linux.c,v 1.5 2001/03/30 02:15:20 keithp Exp $ * * Copyright © 1999 Keith Packard * @@ -28,6 +28,7 @@ #include <linux/vt.h> #include <linux/kd.h> #include <sys/stat.h> +#include <sys/ioctl.h> #include <keysym.h> static int vtno; @@ -174,6 +175,7 @@ LinuxFindPci (CARD16 vendor, CARD16 device, CARD32 count, KdCardAttr *attr) n--; } attr->naddr = n; + attr->bus = bus; ret = TRUE; break; } @@ -181,6 +183,37 @@ LinuxFindPci (CARD16 vendor, CARD16 device, CARD32 count, KdCardAttr *attr) return ret; } +unsigned char * +LinuxGetPciCfg(KdCardAttr *attr) { + char filename[256]; + FILE *f; + unsigned char *cfg; + int r; + + snprintf(filename, 255, "/proc/bus/pci/%02x/%02x.%x", + attr->bus >> 8, (attr->bus & 0xff) >> 3, attr->bus & 7); +/* fprintf(stderr,"Find card on path %s\n",filename); */ + + if (!(f=fopen(filename,"r"))) + return NULL; + + if (!(cfg=xalloc(256))) + { + fclose(f); + return NULL; + } + + if (256 != (r=fread(cfg, 1, 256, f))) + { + fprintf(stderr,"LinuxGetPciCfg: read %d, expected 256\n",r); + free(cfg); + cfg=NULL; + } + fclose(f); +/* fprintf(stderr,"LinuxGetPciCfg: success, returning %p\n",cfg); */ + return cfg; +} + void LinuxSetSwitchMode (int mode) { |