From f662a9105f46affd537c6074bd6a89fcec6b568e Mon Sep 17 00:00:00 2001 From: Ciro Santilli Date: Fri, 16 Jun 2017 16:43:59 +0100 Subject: [PATCH] More random pci tweaking attempts --- kernel_module/pci.c | 30 ++++++++++++++++-------------- runqemu | 1 + 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/kernel_module/pci.c b/kernel_module/pci.c index 423acd9..ad75786 100644 --- a/kernel_module/pci.c +++ b/kernel_module/pci.c @@ -13,7 +13,7 @@ http://nairobi-embedded.org/linux_pci_device_driver.html #define MAX_DEVICE 1 #define DEVICE_NAME "virtual_pci" -#define BAR_IO 2 +#define BAR_IO 0 #define BAR_MEM 3 MODULE_LICENSE("GPL"); @@ -52,12 +52,13 @@ static struct pci_dev *pci_cdev_search_pci_dev(struct pci_cdev pci_cdev[], int s int i; struct pci_dev *pdev = NULL; - for (i=0; idev), "error pci_cdev_add"); goto error; } @@ -192,23 +193,24 @@ static int pci_probe(struct pci_dev *dev, const struct pci_device_id *id) pci_enable_device(dev); /* 'alloc' IO to talk with the card */ - if (pci_request_region(dev, BAR_IO, "IO-pci") == 0) { - dev_err(&(dev->dev), "Can't request BAR2\n"); + if (pci_request_region(dev, BAR_IO, "IO-pci")) { + dev_err(&(dev->dev), "Can't request BAR0\n"); cdev_del(cdev); goto error; } + /* TODO */ /* check that BAR_IO is *really* IO region */ - if ((pci_resource_flags(dev, BAR_IO) & IORESOURCE_IO) != IORESOURCE_IO) { - dev_err(&(dev->dev), "BAR2 isn't an IO region\n"); - cdev_del(cdev); - goto error; - } + /*if ((pci_resource_flags(dev, BAR_IO) & IORESOURCE_IO) != IORESOURCE_IO) {*/ + /*dev_err(&(dev->dev), "BAR2 isn't an IO region\n");*/ + /*cdev_del(cdev);*/ + /*goto error;*/ + /*}*/ - return 1; + return 0; error: - return 0; + return 1; } static void pci_remove(struct pci_dev *dev) @@ -235,7 +237,7 @@ static int __init pci_init_module(void) { int i, first_minor, ret; - ret = alloc_chrdev_region(&devno, 0, MAX_DEVICE, "buffer"); + ret = alloc_chrdev_region(&devno, 0, MAX_DEVICE, "lkmc_pci"); major = MAJOR(devno); first_minor = MINOR(devno); for (i=0; i < MAX_DEVICE; i++) { diff --git a/runqemu b/runqemu index 4d5d932..19b4cb5 100755 --- a/runqemu +++ b/runqemu @@ -49,6 +49,7 @@ case "$arch" in cmd="$debug_qemu ./buildroot/output/host/usr/bin/qemu-system-x86_64 \ -M pc \ -append 'root=/dev/vda $extra_append' \ + -device edu \ -drive file=${images_dir}/rootfs.ext2,if=virtio,format=raw \ -kernel ${images_dir}/bzImage \ -m 128M \