Odd bug with PCI enumeration
diff --git a/.gitignore b/.gitignore
index acda9c8..2856816 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,4 +14,5 @@
.gitignore
.idea
.vscode
-**/.#*
\ No newline at end of file
+**/.#*
+src/kernel/dri/pci/vendors.c
\ No newline at end of file
diff --git a/include/kernel/dri/pci/pci.h b/include/kernel/dri/pci/pci.h
index 6ff500a..75262d3 100644
--- a/include/kernel/dri/pci/pci.h
+++ b/include/kernel/dri/pci/pci.h
@@ -9,5 +9,5 @@
PCI_CONFIG_DATA = 0xCFC,
};
-ushort pci_config_readw(uchar bus, uchar slot, uchar func, uchar offset);
-struct pci_vendor *pci_check_vendor(uchar bus, uchar slot, uchar func, ushort *v);
+uint pci_config_readd(uchar bus, uchar slot, uchar func, uchar offset);
+struct pci_vendor *pci_check_vendor(uchar bus, uchar slot, uchar func, uint *v);
diff --git a/src/kernel/dri/pci/pci.c b/src/kernel/dri/pci/pci.c
index 710ce11..39622a5 100644
--- a/src/kernel/dri/pci/pci.c
+++ b/src/kernel/dri/pci/pci.c
@@ -3,7 +3,7 @@
#include <io.h>
#include <log.h>
-ushort pci_config_readw(uchar bus, uchar slot, uchar func, uchar offset)
+uint pci_config_readd(uchar bus, uchar slot, uchar func, uchar offset)
{
uint address = (bus << 16) | (slot << 11) | (func << 8) | (offset << 2) | 0x80000000;
@@ -12,19 +12,18 @@
return inl(PCI_CONFIG_DATA);
}
-struct pci_vendor *pci_check_vendor(uchar bus, uchar slot, uchar func, ushort *v)
+struct pci_vendor *pci_check_vendor(uchar bus, uchar slot, uchar func, uint *v)
{
- ushort vendor;
+ uint vendor;
- if ((vendor = pci_config_readw(bus, slot, func, 0) != 0xffff))
+ if ((vendor = pci_config_readd(bus, slot, func, 0) != ~0))
{
- // TODO: check device and return here as well
+ if (v)
+ *v = vendor;
+
+ return pci_vendor_by_id(vendor);
}
-
- if (v)
- *v = vendor;
-
- return pci_vendor_by_id(vendor);
+ return NULL;
}
struct pci_vendor *pci_vendor_by_id(ushort id)
diff --git a/src/kernel/main.c b/src/kernel/main.c
index 8682681..83aa9a8 100644
--- a/src/kernel/main.c
+++ b/src/kernel/main.c
@@ -77,7 +77,6 @@
kprintf("initializing tasks\n");
init_tasks();
kprintf("\ndone initializing tasks\n");
- asm volatile("sti");
#ifdef TEST_THREADS
spawn_thread(other_thread, NULL);
@@ -95,15 +94,18 @@
{
for (int func = 0; func < 8; func++)
{
- struct pci_vendor *v = pci_check_vendor(bus, slot, func, NULL);
- if (v)
+ uint vendor;
+
+ struct pci_vendor *v = pci_check_vendor(bus, slot, func, &vendor);
+
+ if (vendor != ~0)
{
- kprintf("%s\n", v->name);
+ kprintf("%d %d %d %d\n", bus, slot, func, vendor);
}
}
}
}
-
+
while (true)
asm volatile("hlt");