summaryrefslogtreecommitdiffstats
path: root/pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'pci.c')
-rw-r--r--pci.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/pci.c b/pci.c
index c57d6c8..f51f025 100644
--- a/pci.c
+++ b/pci.c
@@ -49,6 +49,37 @@ char* get_pci_description(int vendor_id, int device_id) {
return buf;
}
+// fake two PCI controllers for xen
+static detect_xen(struct pciusb_entries *r) {
+ struct stat sb;
+ if (stat("/sys/bus/xen", &sb) != 0)
+ return;
+
+ struct pciusb_entry *e = &r->entries[r->nb++];
+ pciusb_initialize(e);
+ asprintf(&e->text, "%s|%s", "XenSource, Inc.", "Block Frontend");
+ e->class_id = 0x0106; // STORAGE_SATA
+
+ e->vendor = 0x1a71; // XenSource
+ e->device = 0xfffa; // fake
+ e->subvendor = 0;
+ e->subdevice = 0;
+ e->class_id = 0x0106;
+ e->module = strdup("xen_blkfront");
+
+ e = &r->entries[r->nb++];
+ pciusb_initialize(e);
+ asprintf(&e->text, "%s|%s", "XenSource, Inc.", "Network Frontend");
+ e->class_id = 0x0200; // NETWORK_ETHERNET
+
+ e->vendor = 0x1a71; // XenSource
+ e->device = 0xfffa; // fake
+ e->subvendor = 0;
+ e->subdevice = 0;
+ e->class_id = 0x0200;
+ e->module = strdup("xen_netfront");
+}
+
extern struct pciusb_entries pci_probe(void) {
u8 buf[CONFIG_SPACE_SIZE];
struct pciusb_entries r;
@@ -77,6 +108,8 @@ extern struct pciusb_entries pci_probe(void) {
r.nb = 0;
r.entries = malloc(sizeof(struct pciusb_entry) * MAX_DEVICES);
+ detect_xen(&r);
+
for (dev = pacc->devices; dev; dev = dev->next, r.nb++) {
if (r.nb >= allocated) {
allocated = r.nb*2;