|
|
@@ -27,7 +27,10 @@
|
|
|
#include <kernel/init.h>
|
|
|
#include <kernel/errno.h>
|
|
|
#include <kernel/types.h>
|
|
|
+
|
|
|
#include <kernel/int.h>
|
|
|
+#include <kernel/pci.h>
|
|
|
+#include <lib/string.h>
|
|
|
|
|
|
#include <arch/x86/int.h>
|
|
|
#include <arch/io.h>
|
|
|
@@ -67,3 +70,45 @@ __uint32_t pci_lspci(void) {
|
|
|
|
|
|
return devs;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+void pci_infodev(__uint8_t bus, __uint8_t slot, __uint8_t func) {
|
|
|
+ __uint32_t buf[256];
|
|
|
+ struct pci_header header;
|
|
|
+ int i;
|
|
|
+
|
|
|
+ for (i = 0; i < 256 / 4; i++)
|
|
|
+ buf[i] = pci_read_config(bus, slot, func, i << 2);
|
|
|
+
|
|
|
+ memcpy((char *) &header, (char *) buf, sizeof(struct pci_header));
|
|
|
+
|
|
|
+ /* put the info of this device on the screen */
|
|
|
+ printk(yellow, "vendor id: %w\n", header.vendor);
|
|
|
+ printk(yellow, "device id: %w\n", header.dev);
|
|
|
+
|
|
|
+ printk(yellow, "revision: %b\n", header.revision);
|
|
|
+ printk(yellow, "sub class id: %b\n", header.subclass);
|
|
|
+ printk(yellow, "class code: %b\n", header.class_code);
|
|
|
+
|
|
|
+ printk(yellow, "cache line size: %b\n", header.cache_size);
|
|
|
+ printk(yellow, "latency: %b\n", header.latency);
|
|
|
+
|
|
|
+ printk(yellow, "header type: %b\n", header.hdr_type);
|
|
|
+
|
|
|
+ if (header.hdr_type == 0) {
|
|
|
+ struct pci_header0 *hdr = (struct pci_header0 *) buf;
|
|
|
+
|
|
|
+ printk(yellow, "bar0: %x ", hdr->bar0);
|
|
|
+ printk(yellow, "bar1: %x\n", hdr->bar1);
|
|
|
+
|
|
|
+ printk(yellow, "bar2: %x ", hdr->bar2);
|
|
|
+ printk(yellow, "bar3: %x\n", hdr->bar3);
|
|
|
+
|
|
|
+ printk(yellow, "bar4: %x ", hdr->bar4);
|
|
|
+ printk(yellow, "bar5: %x\n", hdr->bar5);
|
|
|
+
|
|
|
+ printk(yellow, "irq: %b\n", hdr->irqnr);
|
|
|
+ }
|
|
|
+
|
|
|
+ return;
|
|
|
+}
|