/*Read PCI configuration space by I/O port*/
u32 read_pci_cfg_u32(u8 bus, u8 dev, u8 fun, u8 regs)
{
u32 reg_offset, value = 0;
reg_offset = (u32)(0x80000000L | (u32)bus << 16 | (u32)dev << 11 | (u32)fun << 8 | (u32)regs);
__asm{
pushad
mov eax, reg_offset
mov dx, 0CF8h
out dx, eax
mov dx, 0CFCh
in eax, dx
mov value, eax
popad
}
return value;
}
/*Write PCI configuration space by I/O port*/
void write_pci_cfg_u32(u8 bus, u8 dev, u8 fun, u8 regs, u32 value)
{
u32 reg_offset;
reg_offset = (u32)(0x80000000L | (u32)bus << 16 | (u32)dev << 11 | (u32)fun << 8 | (u32)regs);
__asm{
pushad
mov eax, reg_offset
mov dx, 0CF8h
out dx, eax
mov eax, value
mov dx, 0CFCh
out dx, eax
popad
}
}
{
u32 reg_offset;
reg_offset = (u32)(0x80000000L | (u32)bus << 16 | (u32)dev << 11 | (u32)fun << 8 | (u32)regs);
__asm{
pushad
mov eax, reg_offset
mov dx, 0CF8h
out dx, eax
mov eax, value
mov dx, 0CFCh
out dx, eax
popad
}
}
沒有留言:
張貼留言