From 502d7b6df7e15d4355315dac8700ff7a703de09c Mon Sep 17 00:00:00 2001 From: acevest Date: Thu, 11 Nov 2021 14:19:25 +0800 Subject: [PATCH] =?utf8?q?fix=20pci=5Fwrite=5Fconfig=5F{byte|word|long}?= =?utf8?q?=E6=B2=A1=E6=9C=89=E5=86=99=E5=BE=80=E6=AD=A3=E7=A1=AE=E5=AF=84?= =?utf8?q?=E5=AD=98=E5=99=A8=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- drivers/pci.c | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/drivers/pci.c b/drivers/pci.c index 5ade796..b19fe9c 100644 --- a/drivers/pci.c +++ b/drivers/pci.c @@ -23,36 +23,35 @@ LIST_HEAD(pci_devs); const char *pci_get_info(unsigned int classcode, unsigned int progif); -int pci_read_config_byte(int cmd) { - outl(PCI_CONFIG_CMD(cmd), PCI_ADDR); - return inb(PCI_DATA + (PCI_GET_CMD_REG(cmd) & 3)); +int pci_read_config_byte(int reg) { + outl(PCI_CONFIG_CMD(reg), PCI_ADDR); + return inb(PCI_DATA + (PCI_GET_CMD_REG(reg) & 3)); } -int pci_read_config_word(int cmd) { - outl(PCI_CONFIG_CMD(cmd), PCI_ADDR); - return inw(PCI_DATA + (PCI_GET_CMD_REG(cmd) & 2)); +int pci_read_config_word(int reg) { + outl(PCI_CONFIG_CMD(reg), PCI_ADDR); + return inw(PCI_DATA + (PCI_GET_CMD_REG(reg) & 2)); } -int pci_read_config_long(int cmd) { - outl(PCI_CONFIG_CMD(cmd), PCI_ADDR); +int pci_read_config_long(int reg) { + outl(PCI_CONFIG_CMD(reg), PCI_ADDR); return inl(PCI_DATA); } -// 可能有BUG -// void pci_write_config_byte(int value, int cmd) { -// outl(PCI_CONFIG_CMD(cmd), PCI_ADDR); -// outb(value & 0xFF, PCI_DATA); -// } - -// void pci_write_config_word(int value, int cmd) { -// outl(PCI_CONFIG_CMD(cmd), PCI_ADDR); -// outw(value & 0xFFFF, PCI_DATA); -// } - -// void pci_write_config_long(int value, int cmd) { -// outl(PCI_CONFIG_CMD(cmd), PCI_ADDR); -// outl(value, PCI_DATA); -// } +void pci_write_config_byte(int value, int reg) { + outl(PCI_CONFIG_CMD(reg), PCI_ADDR); + outb(value & 0xFF, PCI_DATA + (reg & 3)); +} + +void pci_write_config_word(int value, int reg) { + outl(PCI_CONFIG_CMD(reg), PCI_ADDR); + outw(value & 0xFFFF, PCI_DATA + (reg & 2)); +} + +void pci_write_config_long(int value, int reg) { + outl(PCI_CONFIG_CMD(reg), PCI_ADDR); + outl(value, PCI_DATA); +} void scan_pci_bus(int bus) { u8 dev, devfn; -- 2.44.0