Beispiel #1
0
UINT32
ReadPCICfg(
  UINT8 bus,
  UINT8 dev,
  UINT8 fun,
  UINT8 off,
  UINT8 len // 1, 2, 4 bytes
  )
{
  unsigned int result = 0;
  unsigned int pci_addr = (0x80000000 | (bus << 16) | (dev << 11) | (fun << 8) | (off & ~3));
  unsigned short cfg_data_port = (UINT16)(0xCFC + ( off & 0x3 ));
  if     ( 1 == len ) result = (ReadPCIByte ( pci_addr, cfg_data_port ) & 0xFF);
  else if( 2 == len ) result = (ReadPCIWord ( pci_addr, cfg_data_port ) & 0xFFFF);
  else if( 4 == len ) result =  ReadPCIDword( pci_addr, cfg_data_port );
  return result;
}
Beispiel #2
0
uint32_t ReadPCICfg(uint8_t bus, uint8_t dev, uint8_t fun, uint8_t off,
                    uint8_t len)
{
    unsigned int result = 0;
    unsigned int pci_addr = (0x80000000 | (bus << 16) | (dev << 11) |
                             (fun << 8) | (off & ~3));
    unsigned short cfg_data_port = (uint16_t)(0xCFC + (off & 0x3));
    switch(len) {
        case 1:
            result = (ReadPCIByte (pci_addr, cfg_data_port) & 0xFF);
            break;
        case 2:
            result = (ReadPCIWord (pci_addr, cfg_data_port) & 0xFFFF);
            break;
        case 4:
            result = ReadPCIDword(pci_addr, cfg_data_port);
            break;
    }
    return result;
}