| 1 |
/* |
| 2 |
This file is based on: |
| 3 |
$XFree86: xc/programs/Xserver/hw/xfree86/etc/scanpci.c,v 3.34.2.17 1998/11/10 11:55:40 dawes Exp $ |
| 4 |
Modified for readability by Nick Kurshev |
| 5 |
*/ |
| 6 |
|
| 7 |
static int pci_config_type( void ) { return 1; } |
| 8 |
|
| 9 |
static int pci_get_vendor( |
| 10 |
unsigned char bus, |
| 11 |
unsigned char dev, |
| 12 |
int func) |
| 13 |
{ |
| 14 |
unsigned long retval; |
| 15 |
pciconfig_read(bus, dev<<3, PCI_ID_REG, 4, &retval); |
| 16 |
return retval; |
| 17 |
} |
| 18 |
|
| 19 |
static long pci_config_read_long( |
| 20 |
unsigned char bus, |
| 21 |
unsigned char dev, |
| 22 |
int func, |
| 23 |
unsigned cmd) |
| 24 |
{ |
| 25 |
unsigned long retval; |
| 26 |
pciconfig_read(bus, dev<<3, cmd, 4, &retval); |
| 27 |
return retval; |
| 28 |
} |
| 29 |
|
| 30 |
static long pci_config_read_word( |
| 31 |
unsigned char bus, |
| 32 |
unsigned char dev, |
| 33 |
int func, |
| 34 |
unsigned cmd) |
| 35 |
{ |
| 36 |
unsigned long retval; |
| 37 |
pciconfig_read(bus, dev<<3, cmd, 2, &retval); |
| 38 |
return retval; |
| 39 |
} |
| 40 |
|
| 41 |
static long pci_config_read_byte( |
| 42 |
unsigned char bus, |
| 43 |
unsigned char dev, |
| 44 |
int func, |
| 45 |
unsigned cmd) |
| 46 |
{ |
| 47 |
unsigned long retval; |
| 48 |
pciconfig_read(bus, dev<<3, cmd, 1, &retval); |
| 49 |
return retval; |
| 50 |
} |
| 51 |
|
| 52 |
static void pci_config_write_long( |
| 53 |
unsigned char bus, |
| 54 |
unsigned char dev, |
| 55 |
int func, |
| 56 |
unsigned cmd, |
| 57 |
long val) |
| 58 |
{ |
| 59 |
pciconfig_write(bus, dev<<3, cmd, 4, val); |
| 60 |
} |
| 61 |
|
| 62 |
static void pci_config_write_word( |
| 63 |
unsigned char bus, |
| 64 |
unsigned char dev, |
| 65 |
int func, |
| 66 |
unsigned cmd, |
| 67 |
long val) |
| 68 |
{ |
| 69 |
pciconfig_write(bus, dev<<3, cmd, 2, val); |
| 70 |
} |
| 71 |
|
| 72 |
static void pci_config_write_byte( |
| 73 |
unsigned char bus, |
| 74 |
unsigned char dev, |
| 75 |
int func, |
| 76 |
unsigned cmd, |
| 77 |
long val) |
| 78 |
{ |
| 79 |
pciconfig_write(bus, dev<<3, cmd, 1, val); |
| 80 |
} |