Пример #1
0
static int
extpci_read_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
{
	uint32 addr, *reg = NULL, val;
	int ret = 0;

	if (pci_disabled ||
	    !(addr = config_cmd(sbh, bus, dev, func, off)) ||
	    !(reg = (uint32 *) REG_MAP(addr, len)) ||
	    BUSPROBE(val, reg))
		val = 0xffffffff;

	val >>= 8 * (off & 3);
	if (len == 4)
		*((uint32 *) buf) = val;
	else if (len == 2)
		*((uint16 *) buf) = (uint16) val;
	else if (len == 1)
		*((uint8 *) buf) = (uint8) val;
	else
		ret = -1;

	if (reg)
		REG_UNMAP(reg);

	return ret;
}
Пример #2
0
static int
extpci_write_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
{
	uint32 addr, *reg = NULL, val;
	int ret = 0;

	if (pci_disabled ||
	    !(addr = config_cmd(sbh, bus, dev, func, off)) ||
	    !(reg = (uint32 *) REG_MAP(addr, len)) ||
	    BUSPROBE(val, reg))
		goto done;

	if (len == 4)
		val = *((uint32 *) buf);
	else if (len == 2) {
		val &= ~(0xffff << (8 * (off & 3)));
		val |= *((uint16 *) buf) << (8 * (off & 3));
	} else if (len == 1) {
		val &= ~(0xff << (8 * (off & 3)));
		val |= *((uint8 *) buf) << (8 * (off & 3));
	} else
		ret = -1;

	W_REG(reg, val);

 done:
	if (reg)
		REG_UNMAP(reg);

	return ret;
}
Пример #3
0
static void pcibios_write_config_dword(
    unsigned char bus, unsigned devfn, unsigned where, unsigned int value)
{
    outl(config_cmd(bus, devfn, where), 0xCF8);
    outl(value, 0xCFC);
}
Пример #4
0
static void pcibios_write_config_word(
    unsigned char bus, unsigned devfn, unsigned where, unsigned short value)
{
    outl(config_cmd(bus, devfn, where), 0xCF8);
    outw(value, 0xCFC + (where & 2));
}
Пример #5
0
static void pcibios_write_config_byte(
    unsigned char bus, unsigned devfn, unsigned where, unsigned char value)
{
    outl(config_cmd(bus, devfn, where), 0xCF8);
    outb(value, 0xCFC + (where & 3));
}
Пример #6
0
static unsigned int pcibios_read_config_dword(
    unsigned char bus, unsigned devfn, unsigned where)
{
    outl(config_cmd(bus, devfn, where), 0xCF8);
    return inl(0xCFC);
}
Пример #7
0
static unsigned short pcibios_read_config_word(
    unsigned char bus, unsigned devfn, unsigned where)
{
    outl(config_cmd(bus, devfn, where), 0xCF8);
    return inw(0xCFC + (where & 2));
}
Пример #8
0
static unsigned char pcibios_read_config_byte(
    unsigned char bus, unsigned devfn, unsigned where)
{
    outl(config_cmd(bus, devfn, where), 0xCF8);
    return inb(0xCFC + (where & 3));
}