commit 6d09ab244cad53a4bd3744cb3221cd40de270a6d
parent d0eb9a06a05e664306f6d150c733e4538823b743
Author: Matsuda Kenji <info@mtkn.jp>
Date: Wed, 10 Apr 2024 13:09:46 +0900
delete functiona
Diffstat:
2 files changed, 9 insertions(+), 31 deletions(-)
diff --git a/sys/src/kernel/amd64/pci.c b/sys/src/kernel/amd64/pci.c
@@ -1,40 +1,21 @@
#include <libc.h>
#include "pci.h"
-uint32
-pci_config_make_address(uint8 bus, uint8 dev, uint8 func, uint8 reg_off)
+uint16
+pci_config_read16(uint8 bus, uint8 dev, uint8 func, uint8 offset)
{
- return 1 << 31 | // enable bit.
+ uint32 addr;
+ addr = 1 << 31 | // enable bit.
(uint32) bus << 16 |
(uint32) (dev&0x1f) << 11 |
(uint32) (func&3) << 8 |
- (reg_off&0xfc); // the least 2 bits should be 0.
-}
-
-void
-pci_config_write_address(uint32 addr)
-{
+ (offset&0xfc); // the least 2 bits should be 0.
io_out32(pci_config_address, addr);
+ return io_in32(pci_config_data) >> ((offset & 2) * 8);
}
-void
-pci_config_write_data(uint32 value)
-{
- io_out32(pci_config_data, value);
-}
-
-uint32
-pci_config_read_data()
-{
- return io_in32(pci_config_data);
-}
-
-uint16
-pci_config_read16(){}
-
uint16
-pci_config_read_vendor_id(uint8 bus, uint8 device, uint8 func)
+pci_config_read_vendor_id(uint8 bus, uint8 dev, uint8 func)
{
- pci_config_write_address(pci_config_make_address(bus, device, func, 0x00));
- return pci_config_read_data() & 0xffff;
+ return pci_config_read16(bus, dev, func, 0x0);
}
diff --git a/sys/src/kernel/amd64/pci.h b/sys/src/kernel/amd64/pci.h
@@ -3,11 +3,8 @@
const uint16 pci_config_address = 0xcf8;
const uint16 pci_config_data = 0xcfc;
-uint32 pci_config_make_address(uint8 bus, uint8 device, uint8 function, uint8 reg_addr);
void io_out32(uint16 addr, uint32 data);
uint32 io_in32(uint16 addr);
-void pci_config_write_address(uint32 addr);
-void pci_config_write_data(uint32 value);
-uint32 pci_config_read_data();
+uint16 pci_config_read16(uint8 bus, uint8 device, uint8 func, uint8 offset);
uint16 pci_config_read_vendor_id(uint8 bus, uint8 device, uint8 func);
\ No newline at end of file