Exemplo n.º 1
0
int pci_config_write(unsigned char bus, unsigned char dev, unsigned char func,
		    unsigned char cmd, int len, unsigned long val)
{
    int ret;
    
    ret = enable_app_io();
    if (ret != 0)
	return ret;
    switch(len)
    {
	case 4:
	    pci_config_write_long(bus, dev, func, cmd, val);
	    break;
	case 2:
	    pci_config_write_word(bus, dev, func, cmd, val);
	    break;
	case 1:
	    pci_config_write_byte(bus, dev, func, cmd, val);
	    break;
	default:
	    printf("libdha_pci: wrong length to read: %u\n",len);
    }
    disable_app_io();

    return 0;
}
Exemplo n.º 2
0
int pci_config_write(unsigned char bus, unsigned char dev, unsigned char func,
		    unsigned char cmd, int len, unsigned long val)
{
    int ret;
    
    int dhahelper_fd;
    if ( (dhahelper_fd = open("/dev/dhahelper",O_RDWR)) > 0)
    {
	int retval;
	dhahelper_pci_config_t pcic;
	pcic.operation = PCI_OP_WRITE;
	pcic.bus = bus;
	pcic.dev = dev;
	pcic.func = func;
	pcic.cmd = cmd;
	pcic.size = len;
	pcic.ret = val;
	retval = ioctl(dhahelper_fd, DHAHELPER_PCI_CONFIG, &pcic);
	close(dhahelper_fd);
	return retval;
    }
    ret = enable_app_io();
    if (ret != 0)
	return ret;
    switch(len)
    {
	case 4:
	    pci_config_write_long(bus, dev, func, cmd, val);
	    break;
	case 2:
	    pci_config_write_word(bus, dev, func, cmd, val);
	    break;
	case 1:
	    pci_config_write_byte(bus, dev, func, cmd, val);
	    break;
	default:
	    printf("libdha_pci: wrong length to read: %u\n",len);
    }
    disable_app_io();

    return 0;
}