* and the University of New Mexico. You can find out more at
* http://www.v3vee.org
*
- * Copyright (c) 2009, Lei Xia <lxia@northwestern.edu>
- * Copyright (c) 2009, Chang Seok Bae <jhuell@gmail.com>
* Copyright (c) 2009, Jack Lange <jarusl@cs.northwestern.edu>
* Copyright (c) 2009, The V3VEE Project <http://www.v3vee.org>
* All rights reserved.
*
- * Author: Lei Xia <lxia@northwestern.edu>
- * Chang Seok Bae <jhuell@gmail.com>
- * Jack Lange <jarusl@cs.northwestern.edu>
+ * Author: Jack Lange <jarusl@cs.northwestern.edu>
*
* This is free software. You are permitted to use,
* redistribute, and modify it as specified in the file "V3VEE_LICENSE".
#include <palacios/vmm.h>
+#include <palacios/vmm_dev_mgr.h>
+#include <palacios/vmm_intr.h>
+
#include <devices/pci.h>
#include <devices/southbridge.h>
+
struct iort_reg {
union {
uint8_t value;
return 0;
}
-static int raise_pci_irq(struct vm_device * dev, uint_t intr_pin) {
+
+//irq is pirq_rc[intr_pin + pci_dev_num - 1] & 0x3
+
+static int raise_pci_irq(struct vm_device * dev, struct pci_device * pci_dev) {
struct v3_southbridge * piix3 = (struct v3_southbridge *)(dev->private_data);
- struct pci_device * pci_dev = piix3->southbridge_pci;
- struct piix3_config_space * piix3_cfg = (struct piix3_config_space *)(pci_dev->config_data);
+ struct pci_device * piix3_pci = piix3->southbridge_pci;
+ struct piix3_config_space * piix3_cfg = (struct piix3_config_space *)(piix3_pci->config_data);
+ int intr_pin = pci_dev->config_header.intr_pin - 1;
+ int irq_index = (intr_pin + pci_dev->dev_num - 1) & 0x3;
+
+ // PrintError("Raising PCI IRQ %d\n", piix3_cfg->pirq_rc[irq_index]);
+
+ v3_raise_irq(dev->vm, piix3_cfg->pirq_rc[irq_index]);
- PrintError("Raising PCI IRQ %d\n", piix3_cfg->pirq_rc[intr_pin]);
+ return 0;
+}
+
+
+
+static int lower_pci_irq(struct vm_device * dev, struct pci_device * pci_dev) {
+ struct v3_southbridge * piix3 = (struct v3_southbridge *)(dev->private_data);
+ struct pci_device * piix3_pci = piix3->southbridge_pci;
+ struct piix3_config_space * piix3_cfg = (struct piix3_config_space *)(piix3_pci->config_data);
+ int intr_pin = pci_dev->config_header.intr_pin - 1;
+ int irq_index = (intr_pin + pci_dev->dev_num - 1) & 0x3;
+
+ // PrintError("Lowering PCI IRQ %d\n", piix3_cfg->pirq_rc[irq_index]);
- v3_raise_irq(dev->vm, piix3_cfg->pirq_rc[intr_pin]);
+ v3_lower_irq(dev->vm, piix3_cfg->pirq_rc[irq_index]);
return 0;
}
piix3->southbridge_pci = pci_dev;
- v3_pci_set_irq_bridge(piix3->pci_bus, bus_num, raise_pci_irq, dev);
+ v3_pci_set_irq_bridge(piix3->pci_bus, bus_num, raise_pci_irq, lower_pci_irq, dev);
reset_piix3(dev);
return 0;
}
-static int piix3_init(struct guest_info * vm, void * cfg_data) {
+static int piix3_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
struct v3_southbridge * piix3 = (struct v3_southbridge *)V3_Malloc(sizeof(struct v3_southbridge));
struct vm_device * dev = NULL;
- struct vm_device * pci = v3_find_dev(vm, (char *)cfg_data);
+ struct vm_device * pci = v3_find_dev(vm, v3_cfg_val(cfg, "bus"));
+ char * dev_id = v3_cfg_val(cfg, "ID");
if (!pci) {
PrintError("Could not find PCI device\n");
piix3->pci_bus = pci;
piix3->type = V3_SB_PIIX3;
- dev = v3_allocate_device("PIIX3", &dev_ops, piix3);
+ dev = v3_allocate_device(dev_id, &dev_ops, piix3);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", "PIIX3");
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}