commit 1cefe2bbda34606fb4fb05e5a9ce1aae661b1e20
parent 67fcc9adfb406133b1514b159959eb966e6cc643
Author: Matsuda Kenji <info@mtkn.jp>
Date: Wed, 10 Apr 2024 15:18:32 +0900
read pci config header
Diffstat:
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/sys/src/kernel/amd64/pci.c b/sys/src/kernel/amd64/pci.c
@@ -11,7 +11,7 @@ pci_config_read16(uint8 bus, uint8 dev, uint8 func, uint8 offset)
(uint32) (func&3) << 8 |
(offset&0xfc); // the least 2 bits should be 0.
io_out32(pci_config_address, addr);
- return io_in32(pci_config_data) >> ((offset & 2) * 8);
+ return (io_in32(pci_config_data) >> ((offset&2)*8)) & 0xffff;
}
uint16
diff --git a/sys/src/kernel/main.c b/sys/src/kernel/main.c
@@ -47,7 +47,23 @@ kernel_main(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop)
draw_mouse(&root_window, &m);
cons_printf(&con0, "hello world!\n");
cons_printf(&con0, "pixel at {%d, %d}: %x\n", p.x, p.y, get_pixel(&root_window, p));
- cons_printf(&con0, "bus 0 vendor id: %x\n", pci_config_read_vendor_id(0, 0, 0));
+ cons_printf(&con0, "pci bus 0\n");
+ cons_printf(&con0, "%x\t%x\n",
+ (uint16) pci_config_read16(0, 0, 0, 2),
+ (uint16) pci_config_read16(0, 0, 0, 0));
+ cons_printf(&con0, "%x\t%x\n",
+ (uint16) pci_config_read16(0, 0, 0, 6),
+ (uint16) pci_config_read16(0, 0, 0, 4));
+ cons_printf(&con0, "%x\t%x\t%x\t%x\n",
+ (uint8) pci_config_read16(0, 0, 0, 11),
+ (uint8) pci_config_read16(0, 0, 0, 10),
+ (uint8) pci_config_read16(0, 0, 0, 9),
+ (uint8) pci_config_read16(0, 0, 0, 8));
+ cons_printf(&con0, "%x\t%x\t%x\t%x\n",
+ (uint8) pci_config_read16(0, 0, 0, 15),
+ (uint8) pci_config_read16(0, 0, 0, 14),
+ (uint8) pci_config_read16(0, 0, 0, 13),
+ (uint8) pci_config_read16(0, 0, 0, 12));
halt:
for(;;) { __asm__("hlt"); }