X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fdevices%2Fpci_passthrough.c;h=4ccbba3f11ea05fb0996a7095cdb2da20f9c4b83;hb=2af24dee6386a5fc694d74fa4281dff8b8e2f148;hp=89b4e8487c48a6e158833df3e83aab28d95e5b8f;hpb=3cab540e9e47ce3562dae4c03b20d84b24d8f1f7;p=palacios.releases.git diff --git a/palacios/src/devices/pci_passthrough.c b/palacios/src/devices/pci_passthrough.c index 89b4e84..4ccbba3 100644 --- a/palacios/src/devices/pci_passthrough.c +++ b/palacios/src/devices/pci_passthrough.c @@ -187,9 +187,12 @@ static int pci_bar_init(int bar_num, uint32_t * dst,void * private_data) { //v3_irq_restore(irq_state); - pbar->size = ~PCI_IO_BASE(max_val) + 1; + V3_Print("max_val = %x\n", max_val); + + pbar->size = (uint16_t)~PCI_IO_BASE(max_val) + 1; + V3_Print("IO Bar with %d (%x) ports %x->%x\n", pbar->size, pbar->size, pbar->addr, pbar->addr + pbar->size); // setup a set of null io hooks // This allows the guest to do passthrough IO to these ports // While still reserving them in the IO map @@ -258,8 +261,6 @@ static int pci_bar_init(int bar_num, uint32_t * dst,void * private_data) { } } - - // Initially the virtual bars match the physical ones @@ -275,8 +276,6 @@ static int pci_bar_init(int bar_num, uint32_t * dst,void * private_data) { state->virt_bars[bar_num].type, state->virt_bars[bar_num].addr, state->virt_bars[bar_num].size); - - // Update the pci subsystem versions *dst = bar_val; @@ -332,7 +331,11 @@ static int pci_bar_write(int bar_num, uint32_t * src, void * private_data) { struct pt_bar * pbar = &(state->phys_bars[bar_num]); struct pt_bar * vbar = &(state->virt_bars[bar_num]); - PrintDebug("Bar update src=0x%x\n", *src); + PrintDebug("Bar update: bar_num=%d, src=0x%x\n", bar_num,*src); + PrintDebug("vbar is size=%u, type=%d, addr=0x%x, val=0x%x\n",vbar->size, vbar->type, vbar->addr, vbar->val); + PrintDebug("pbar is size=%u, type=%d, addr=0x%x, val=0x%x\n",pbar->size, pbar->type, pbar->addr, pbar->val); + + if (vbar->type == PT_BAR_NONE) { return 0; @@ -545,10 +548,10 @@ static int irq_handler(struct guest_info * info, struct v3_interrupt * intr, voi -static int passthrough_init(struct guest_info * info, v3_cfg_tree_t * cfg) { +static int passthrough_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct pt_dev_state * state = V3_Malloc(sizeof(struct pt_dev_state)); struct vm_device * dev = NULL; - struct vm_device * pci = v3_find_dev(info, v3_cfg_val(cfg, "bus")); + struct vm_device * pci = v3_find_dev(vm, v3_cfg_val(cfg, "bus")); char * name = v3_cfg_val(cfg, "name"); memset(state, 0, sizeof(struct pt_dev_state)); @@ -564,7 +567,7 @@ static int passthrough_init(struct guest_info * info, v3_cfg_tree_t * cfg) { dev = v3_allocate_device(name, &dev_ops, state); - if (v3_attach_device(info, dev) == -1) { + if (v3_attach_device(vm, dev) == -1) { PrintError("Could not attach device %s\n", name); return -1; } @@ -579,9 +582,9 @@ static int passthrough_init(struct guest_info * info, v3_cfg_tree_t * cfg) { return 0; } - setup_virt_pci_dev(info, dev); + setup_virt_pci_dev(vm, dev); - v3_hook_irq(info, atoi(v3_cfg_val(cfg, "irq")), irq_handler, dev); + v3_hook_irq(vm, atoi(v3_cfg_val(cfg, "irq")), irq_handler, dev); // v3_hook_irq(info, 64, irq_handler, dev); return 0;