static int pt_bar_reg_read(struct pt_dev *ptdev,
struct pt_reg_tbl *cfg_entry,
uint32_t *value, uint32_t valid_mask);
-static int pt_byte_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_byte_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint8_t *value, uint8_t dev_value, uint8_t valid_mask);
-static int pt_word_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_word_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint16_t *value, uint16_t dev_value, uint16_t valid_mask);
-static int pt_long_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_long_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint32_t *value, uint32_t dev_value, uint32_t valid_mask);
-static int pt_cmd_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_cmd_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint16_t *value, uint16_t dev_value, uint16_t valid_mask);
-static int pt_bar_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_bar_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint32_t *value, uint32_t dev_value, uint32_t valid_mask);
-static int pt_exp_rom_bar_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_exp_rom_bar_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint32_t *value, uint32_t dev_value, uint32_t valid_mask);
-static int pt_pmcsr_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_pmcsr_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint16_t *value, uint16_t dev_value, uint16_t valid_mask);
-static int pt_devctrl_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_devctrl_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint16_t *value, uint16_t dev_value, uint16_t valid_mask);
-static int pt_linkctrl_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_linkctrl_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint16_t *value, uint16_t dev_value, uint16_t valid_mask);
-static int pt_devctrl2_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_devctrl2_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint16_t *value, uint16_t dev_value, uint16_t valid_mask);
-static int pt_linkctrl2_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_linkctrl2_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint16_t *value, uint16_t dev_value, uint16_t valid_mask);
-static int pt_msgctrl_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_msgctrl_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint16_t *value, uint16_t dev_value, uint16_t valid_mask);
-static int pt_msgaddr32_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_msgaddr32_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint32_t *value, uint32_t dev_value, uint32_t valid_mask);
-static int pt_msgaddr64_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_msgaddr64_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint32_t *value, uint32_t dev_value, uint32_t valid_mask);
-static int pt_msgdata_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_msgdata_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint16_t *value, uint16_t dev_value, uint16_t valid_mask);
-static int pt_msixctrl_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_msixctrl_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint16_t *value, uint16_t dev_value, uint16_t valid_mask);
-static int pt_byte_reg_restore(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_byte_reg_restore(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint32_t real_offset, uint8_t dev_value, uint8_t *value);
-static int pt_word_reg_restore(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_word_reg_restore(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint32_t real_offset, uint16_t dev_value, uint16_t *value);
-static int pt_long_reg_restore(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_long_reg_restore(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint32_t real_offset, uint32_t dev_value, uint32_t *value);
-static int pt_cmd_reg_restore(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_cmd_reg_restore(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint32_t real_offset, uint16_t dev_value, uint16_t *value);
-static int pt_pmcsr_reg_restore(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_pmcsr_reg_restore(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint32_t real_offset, uint16_t dev_value, uint16_t *value);
-static int pt_bar_reg_restore(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_bar_reg_restore(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint32_t real_offset, uint32_t dev_value, uint32_t *value);
/* pt_reg_info_tbl declaration
* other component), set emu_mask to all 0 and specify r/w func properly.
* - do NOT use ALL F for init_val, otherwise the tbl will not be registered.
*/
-
+
/* Header Type0 reg static infomation table */
static struct pt_reg_info_tbl pt_emu_reg_header0_tbl[] = {
/* Vendor ID reg */
.u.b.restore = NULL,
},
/* Status reg */
- /* use emulated Cap Ptr value to initialize,
- * so need to be declared after Cap Ptr reg
+ /* use emulated Cap Ptr value to initialize,
+ * so need to be declared after Cap Ptr reg
*/
{
.offset = PCI_STATUS,
},
{
.size = 0,
- },
+ },
};
/* Power Management Capability reg static infomation table */
},
{
.size = 0,
- },
+ },
};
/* Vital Product Data Capability Structure reg static infomation table */
},
{
.size = 0,
- },
+ },
};
/* Vendor Specific Capability Structure reg static infomation table */
},
{
.size = 0,
- },
+ },
};
/* PCI Express Capability Structure reg static infomation table */
},
{
.size = 0,
- },
+ },
};
/* MSI Capability Structure reg static infomation table */
},
{
.size = 0,
- },
+ },
};
/* MSI-X Capability Structure reg static infomation table */
},
{
.size = 0,
- },
+ },
};
/* pt_reg_grp_info_tbl declaration
* - only for emulated or zero-hardwired register group.
- * - for register group with dynamic size, just set grp_size to 0xFF and
+ * - for register group with dynamic size, just set grp_size to 0xFF and
* specify size_init func properly.
* - no need to specify emu_reg_tbl for zero-hardwired type.
*/
},
#ifndef __ia64__
/* At present IA64 Xen doesn't support MSI for passthrough, so let's not
- * expose MSI capability to IA64 HVM guest for now.
+ * expose MSI capability to IA64 HVM guest for now.
*/
/* MSI Capability Structure reg group */
{
},
#ifndef __ia64__
/* At present IA64 Xen doesn't support MSI for passthrough, so let's not
- * expose MSI-X capability to IA64 HVM guest for now.
+ * expose MSI-X capability to IA64 HVM guest for now.
*/
/* MSI-X Capability Structure reg group */
{
#endif
{
.grp_size = 0,
- },
+ },
};
static int token_value(char *token)
void pt_iomem_map(PCIDevice *d, int i, uint32_t e_phys, uint32_t e_size,
int type)
{
- struct pt_dev *assigned_device = (struct pt_dev *)d;
+ struct pt_dev *assigned_device = (struct pt_dev *)d;
uint32_t old_ebase = assigned_device->bases[i].e_physbase;
int first_map = ( assigned_device->bases[i].e_size == 0 );
int ret = 0;
assigned_device->bases[i].e_size= e_size;
PT_LOG("e_phys=%08x maddr=%lx type=%d len=%d index=%d first_map=%d\n",
- e_phys, (unsigned long)assigned_device->bases[i].access.maddr,
+ e_phys, (unsigned long)assigned_device->bases[i].access.maddr,
type, e_size, i, first_map);
if ( e_size == 0 )
{
PT_LOG("Error: create new mapping failed!\n");
}
-
+
ret = remove_msix_mapping(assigned_device, i);
if ( ret != 0 )
PT_LOG("Error: remove MSI-X mmio mapping failed!\n");
{
PT_LOG("Guest attempt to set address to unused Base Address Register. "
"[%02x:%02x.%x][Offset:%02xh][Length:%d]\n",
- pci_bus_num(d->bus), ((d->devfn >> 3) & 0x1F),
+ pci_bus_num(d->bus), ((d->devfn >> 3) & 0x1F),
(d->devfn & 0x7), address, len);
}
/* ignore silently */
PT_LOG("Access to 0 Hardwired register. "
"[%02x:%02x.%x][Offset:%02xh][Length:%d]\n",
- pci_bus_num(d->bus), ((d->devfn >> 3) & 0x1F),
+ pci_bus_num(d->bus), ((d->devfn >> 3) & 0x1F),
(d->devfn & 0x7), address, len);
goto exit;
}
pci_bus_num(d->bus), ((d->devfn >> 3) & 0x1F), (d->devfn & 0x7),
address, len);
}
-
+
/* pass directly to libpci for passthrough type register group */
if (reg_grp_entry == NULL)
goto out;
/* emulate write to byte register */
if (reg->u.b.write)
ret = reg->u.b.write(assigned_device, reg_entry,
- (uint8_t *)ptr_val,
+ (uint8_t *)ptr_val,
(uint8_t)(read_val >> ((real_offset & 3) << 3)),
(uint8_t)valid_mask);
break;
/* emulate write to word register */
if (reg->u.w.write)
ret = reg->u.w.write(assigned_device, reg_entry,
- (uint16_t *)ptr_val,
+ (uint16_t *)ptr_val,
(uint16_t)(read_val >> ((real_offset & 3) << 3)),
(uint16_t)valid_mask);
break;
/* emulate write to double word register */
if (reg->u.dw.write)
ret = reg->u.dw.write(assigned_device, reg_entry,
- (uint32_t *)ptr_val,
+ (uint32_t *)ptr_val,
(uint32_t)(read_val >> ((real_offset & 3) << 3)),
(uint32_t)valid_mask);
break;
}
else
{
- /* nothing to do with passthrough type register,
- * continue to find next byte
+ /* nothing to do with passthrough type register,
+ * continue to find next byte
*/
emul_len--;
find_addr++;
}
}
-
+
/* need to shift back before passing them to libpci */
val >>= ((address & 3) << 3);
address, len);
}
- /* just return the I/O device register value for
- * passthrough type register group
+ /* just return the I/O device register value for
+ * passthrough type register group
*/
if (reg_grp_entry == NULL)
goto exit;
/* emulate read to byte register */
if (reg->u.b.read)
ret = reg->u.b.read(assigned_device, reg_entry,
- (uint8_t *)ptr_val,
+ (uint8_t *)ptr_val,
(uint8_t)valid_mask);
break;
case 2:
/* emulate read to word register */
if (reg->u.w.read)
ret = reg->u.w.read(assigned_device, reg_entry,
- (uint16_t *)ptr_val,
+ (uint16_t *)ptr_val,
(uint16_t)valid_mask);
break;
case 4:
/* emulate read to double word register */
if (reg->u.dw.read)
ret = reg->u.dw.read(assigned_device, reg_entry,
- (uint32_t *)ptr_val,
+ (uint32_t *)ptr_val,
(uint32_t)valid_mask);
break;
}
}
else
{
- /* nothing to do with passthrough type register,
- * continue to find next byte
+ /* nothing to do with passthrough type register,
+ * continue to find next byte
*/
emul_len--;
find_addr++;
}
}
-
+
/* need to shift back before returning them to pci bus emulator */
val >>= ((address & 3) << 3);
(uint32_t)pci_dev->size[i], PCI_ADDRESS_SPACE_MEM_PREFETCH,
pt_iomem_map);
else
- pci_register_io_region((PCIDevice *)assigned_device, i,
+ pci_register_io_region((PCIDevice *)assigned_device, i,
(uint32_t)pci_dev->size[i], PCI_ADDRESS_SPACE_MEM,
pt_iomem_map);
}
}
-
+
}
}
base = &ptdev->bases[i];
/* skip unused BAR or upper 64bit BAR */
- if ((base->bar_flag == PT_BAR_FLAG_UNUSED) ||
+ if ((base->bar_flag == PT_BAR_FLAG_UNUSED) ||
(base->bar_flag == PT_BAR_FLAG_UPPER))
continue;
ret = pt_chk_bar_overlap(dev->bus, dev->devfn, r_addr, r_size);
if (ret > 0)
PT_LOG("ptdev[%02x:%02x.%x][Region:%d][Address:%08xh][Size:%08xh] "
- "is overlapped.\n", pci_bus_num(dev->bus),
+ "is overlapped.\n", pci_bus_num(dev->bus),
(dev->devfn >> 3) & 0x1F, (dev->devfn & 0x7),
i, r_addr, r_size);
if (r_addr != ptdev->bases[i].e_physbase)
{
/* mapping BAR */
- r->map_func((PCIDevice *)ptdev, i, r_addr,
+ r->map_func((PCIDevice *)ptdev, i, r_addr,
r_size, r->type);
}
}
if (pm_state->req_state != cur_state)
{
- PT_LOG("Error: Failed to change power state. "
- "[%02x:%02x.%x][requested state:%d][current state:%d]\n",
- pci_bus_num(d->bus), ((d->devfn >> 3) & 0x1F), (d->devfn & 0x7),
+ PT_LOG("Error: Failed to change power state. "
+ "[%02x:%02x.%x][requested state:%d][current state:%d]\n",
+ pci_bus_num(d->bus), ((d->devfn >> 3) & 0x1F), (d->devfn & 0x7),
pm_state->req_state, cur_state);
return -1;
}
config = *(uint32_t*)(d->config + (aer_base + i));
pci_write_long(ptdev->pci_dev, (aer_base + i), config);
break;
- /* other registers should not be reconfigured after reset
+ /* other registers should not be reconfigured after reset
* if there is no reason
*/
default:
if (ret < 0)
{
/* exit I/O emulator */
- PT_LOG("Internal error: Invalid restoring "
+ PT_LOG("Internal error: Invalid restoring "
"return value[%d]. I/O emulator exit.\n", ret);
exit(1);
}
#ifdef PT_DEBUG_PCI_CONFIG_ACCESS
- PT_LOG("[%02x:%02x.%x]: address=%04x val=0x%08x len=%d\n",
- pci_bus_num(d->bus), (d->devfn >> 3) & 0x1F, (d->devfn & 0x7),
+ PT_LOG("[%02x:%02x.%x]: address=%04x val=0x%08x len=%d\n",
+ pci_bus_num(d->bus), (d->devfn >> 3) & 0x1F, (d->devfn & 0x7),
real_offset, val, reg->size);
#endif
if (ret < 0)
goto out;
- PT_LOG("Reinitialize PCI configuration registers "
- "due to power state transition with internal reset. [%02x:%02x.%x]\n",
+ PT_LOG("Reinitialize PCI configuration registers "
+ "due to power state transition with internal reset. [%02x:%02x.%x]\n",
pci_bus_num(d->bus), ((d->devfn >> 3) & 0x1F), (d->devfn & 0x7));
/* restore a part of I/O device register */
{
if (pt_emu_reg_grp_tbl[i].grp_id != 0xFF)
{
- reg_grp_offset = (uint32_t)find_cap_offset(ptdev->pci_dev,
+ reg_grp_offset = (uint32_t)find_cap_offset(ptdev->pci_dev,
pt_emu_reg_grp_tbl[i].grp_id);
- if (!reg_grp_offset)
+ if (!reg_grp_offset)
continue;
}
/* initialize register group entry */
LIST_INIT(®_grp_entry->reg_tbl_head);
- /* need to declare here, to enable searching Cap Ptr reg
- * (which is in the same reg group) when initializing Status reg
+ /* need to declare here, to enable searching Cap Ptr reg
+ * (which is in the same reg group) when initializing Status reg
*/
LIST_INSERT_HEAD(&ptdev->reg_grp_tbl_head, reg_grp_entry, entries);
reg_grp_entry->base_offset = reg_grp_offset;
- reg_grp_entry->reg_grp =
+ reg_grp_entry->reg_grp =
(struct pt_reg_grp_info_tbl*)&pt_emu_reg_grp_tbl[i];
if (pt_emu_reg_grp_tbl[i].size_init)
{
/* get register group size */
reg_grp_entry->size = pt_emu_reg_grp_tbl[i].size_init(ptdev,
- reg_grp_entry->reg_grp,
+ reg_grp_entry->reg_grp,
reg_grp_offset);
}
{
for (i=0; pt_emu_reg_grp_tbl[i].grp_size != 0; i++)
{
- /* check whether the next capability
- * should be exported to guest or not
+ /* check whether the next capability
+ * should be exported to guest or not
*/
if (pt_emu_reg_grp_tbl[i].grp_id == ptdev->dev.config[reg_field])
{
(uint8_t)PCI_EXP_FLAGS_VERS);
dev_type = (ptdev->dev.config[(real_offset - reg->offset) + PCI_EXP_FLAGS] &
(uint8_t)PCI_EXP_FLAGS_TYPE) >> 4;
-
+
/* no need to initialize in case of Root Complex Integrated Endpoint
- * with cap_ver 1.x
+ * with cap_ver 1.x
*/
if ((dev_type == PCI_EXP_TYPE_ROOT_INT_EP) && (cap_ver == 1))
return PT_INVALID_REG;
cap_ver = (ptdev->dev.config[(real_offset - reg->offset) + PCI_EXP_FLAGS] &
(uint8_t)PCI_EXP_FLAGS_VERS);
-
+
/* no need to initialize in case of cap_ver 1.x */
if (cap_ver == 1)
return PT_INVALID_REG;
cap_ver = (ptdev->dev.config[(real_offset - reg->offset) + PCI_EXP_FLAGS] &
(uint8_t)PCI_EXP_FLAGS_VERS);
-
+
/* no need to initialize in case of cap_ver 1.x */
if (cap_ver == 1)
return PT_INVALID_REG;
-
+
/* set Supported Link Speed */
- reg_field |=
- (0x0F &
+ reg_field |=
+ (0x0F &
ptdev->dev.config[(real_offset - reg->offset) + PCI_EXP_LNKCAP]);
return reg_field;
PCIDevice *d = (struct PCIDevice *)ptdev;
struct pci_dev *pdev = ptdev->pci_dev;
uint32_t reg_field = 0;
-
+
/* use I/O device register's value as initial value */
reg_field |= *((uint16_t*)(d->config + real_offset));
-
+
if (reg_field & PCI_MSI_FLAGS_ENABLE)
{
PT_LOG("MSI enabled already, disable first\n");
}
ptdev->msi->flags |= (reg_field | MSI_FLAG_UNINIT);
ptdev->msi->ctrl_offset = real_offset;
-
+
/* All register is 0 after reset, except first 4 byte */
reg_field &= reg->ro_mask;
{
PCIDevice *d = (struct PCIDevice *)ptdev;
uint32_t reg_field = 0;
-
+
/* use I/O device register's value as initial value */
reg_field |= *((uint32_t*)(d->config + real_offset));
-
+
return reg_field;
}
{
PCIDevice *d = (struct PCIDevice *)ptdev;
uint32_t reg_field = 0;
-
+
/* no need to initialize in case of 32 bit type */
if (!(ptdev->msi->flags & PCI_MSI_FLAGS_64BIT))
return PT_INVALID_REG;
-
+
/* use I/O device register's value as initial value */
reg_field |= *((uint32_t*)(d->config + real_offset));
-
+
return reg_field;
}
PCIDevice *d = (struct PCIDevice *)ptdev;
uint32_t flags = ptdev->msi->flags;
uint32_t offset = reg->offset;
-
+
/* check the offset whether matches the type or not */
if (((offset == PCI_MSI_DATA_64) && (flags & PCI_MSI_FLAGS_64BIT)) ||
((offset == PCI_MSI_DATA_32) && !(flags & PCI_MSI_FLAGS_64BIT)))
PCIDevice *d = (struct PCIDevice *)ptdev;
struct pci_dev *pdev = ptdev->pci_dev;
uint16_t reg_field = 0;
-
+
/* use I/O device register's value as initial value */
reg_field |= *((uint16_t*)(d->config + real_offset));
-
+
if (reg_field & PCI_MSIX_ENABLE)
{
PT_LOG("MSIX enabled already, disable first\n");
/* in case of PCI Express Base Specification Rev 1.x */
if (vers == 1)
{
- /* The PCI Express Capabilities, Device Capabilities, and Device
- * Status/Control registers are required for all PCI Express devices.
- * The Link Capabilities and Link Status/Control are required for all
- * Endpoints that are not Root Complex Integrated Endpoints. Endpoints
- * are not required to implement registers other than those listed
+ /* The PCI Express Capabilities, Device Capabilities, and Device
+ * Status/Control registers are required for all PCI Express devices.
+ * The Link Capabilities and Link Status/Control are required for all
+ * Endpoints that are not Root Complex Integrated Endpoints. Endpoints
+ * are not required to implement registers other than those listed
* above and terminate the capability structure.
*/
switch (type) {
case PCI_EXP_TYPE_ENDPOINT:
case PCI_EXP_TYPE_LEG_END:
case PCI_EXP_TYPE_ROOT_INT_EP:
- /* For Functions that do not implement the registers,
+ /* For Functions that do not implement the registers,
* these spaces must be hardwired to 0b.
*/
pcie_size = 0x3C;
/* emulate byte register */
valid_emu_mask = reg->emu_mask & valid_mask;
- *value = ((*value & ~valid_emu_mask) |
+ *value = ((*value & ~valid_emu_mask) |
(cfg_entry->data & valid_emu_mask));
return 0;
/* emulate word register */
valid_emu_mask = reg->emu_mask & valid_mask;
- *value = ((*value & ~valid_emu_mask) |
+ *value = ((*value & ~valid_emu_mask) |
(cfg_entry->data & valid_emu_mask));
return 0;
/* emulate long register */
valid_emu_mask = reg->emu_mask & valid_mask;
- *value = ((*value & ~valid_emu_mask) |
+ *value = ((*value & ~valid_emu_mask) |
(cfg_entry->data & valid_emu_mask));
return 0;
/* emulate BAR */
valid_emu_mask = bar_emu_mask & valid_mask;
- *value = ((*value & ~valid_emu_mask) |
+ *value = ((*value & ~valid_emu_mask) |
(cfg_entry->data & valid_emu_mask));
return 0;
}
/* write byte size emulate register */
-static int pt_byte_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_byte_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint8_t *value, uint8_t dev_value, uint8_t valid_mask)
{
struct pt_reg_info_tbl *reg = cfg_entry->reg;
}
/* write word size emulate register */
-static int pt_word_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_word_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint16_t *value, uint16_t dev_value, uint16_t valid_mask)
{
struct pt_reg_info_tbl *reg = cfg_entry->reg;
}
/* write long size emulate register */
-static int pt_long_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_long_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint32_t *value, uint32_t dev_value, uint32_t valid_mask)
{
struct pt_reg_info_tbl *reg = cfg_entry->reg;
}
/* write Command register */
-static int pt_cmd_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_cmd_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint16_t *value, uint16_t dev_value, uint16_t valid_mask)
{
struct pt_reg_info_tbl *reg = cfg_entry->reg;
*value = ((*value & throughable_mask) | (dev_value & ~throughable_mask));
/* mapping BAR */
- pt_bar_mapping(ptdev, wr_value & PCI_COMMAND_IO,
+ pt_bar_mapping(ptdev, wr_value & PCI_COMMAND_IO,
wr_value & PCI_COMMAND_MEMORY);
return 0;
}
/* write BAR */
-static int pt_bar_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_bar_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint32_t *value, uint32_t dev_value, uint32_t valid_mask)
{
struct pt_reg_info_tbl *reg = cfg_entry->reg;
{
PT_LOG("Guest attempt to set Base Address over the 64KB. "
"[%02x:%02x.%x][Offset:%02xh][Address:%08xh][Size:%08xh]\n",
- pci_bus_num(d->bus),
+ pci_bus_num(d->bus),
((d->devfn >> 3) & 0x1F), (d->devfn & 0x7),
reg->offset, new_addr, r_size);
}
PT_LOG("Guest attempt to set high MMIO Base Address. "
"Ignore mapping. "
"[%02x:%02x.%x][Offset:%02xh][High Address:%08xh]\n",
- pci_bus_num(d->bus),
+ pci_bus_num(d->bus),
((d->devfn >> 3) & 0x1F), (d->devfn & 0x7),
reg->offset, cfg_entry->data);
}
}
/* write Exp ROM BAR */
-static int pt_exp_rom_bar_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_exp_rom_bar_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint32_t *value, uint32_t dev_value, uint32_t valid_mask)
{
struct pt_reg_info_tbl *reg = cfg_entry->reg;
/* update the corresponding virtual region address */
r->addr = cfg_entry->data;
-
+
/* create value for writing to I/O device register */
throughable_mask = ~bar_emu_mask & valid_mask;
*value = ((*value & throughable_mask) |
}
/* write Power Management Control/Status register */
-static int pt_pmcsr_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_pmcsr_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint16_t *value, uint16_t dev_value, uint16_t valid_mask)
{
struct pt_reg_info_tbl *reg = cfg_entry->reg;
PCIDevice *d = &ptdev->dev;
uint16_t writable_mask = 0;
uint16_t throughable_mask = 0;
- uint16_t pmcsr_mask = (PCI_PM_CTRL_PME_ENABLE |
+ uint16_t pmcsr_mask = (PCI_PM_CTRL_PME_ENABLE |
PCI_PM_CTRL_DATA_SEL_MASK |
PCI_PM_CTRL_PME_STATUS);
struct pt_pm_info *pm_state = ptdev->pm_state;
}
/* write Device Control register */
-static int pt_devctrl_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_devctrl_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint16_t *value, uint16_t dev_value, uint16_t valid_mask)
{
struct pt_reg_info_tbl *reg = cfg_entry->reg;
}
/* write Link Control register */
-static int pt_linkctrl_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_linkctrl_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint16_t *value, uint16_t dev_value, uint16_t valid_mask)
{
struct pt_reg_info_tbl *reg = cfg_entry->reg;
uint16_t writable_mask = 0;
uint16_t throughable_mask = 0;
uint16_t linkctrl_mask = (0x04 | PCI_EXP_LNKCTL_DISABLE |
- PCI_EXP_LNKCTL_RETRAIN |
+ PCI_EXP_LNKCTL_RETRAIN |
0x0400 | 0x0800 | 0xF000);
/* modify emulate register */
}
/* write Device Control2 register */
-static int pt_devctrl2_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_devctrl2_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint16_t *value, uint16_t dev_value, uint16_t valid_mask)
{
struct pt_reg_info_tbl *reg = cfg_entry->reg;
}
/* write Link Control2 register */
-static int pt_linkctrl2_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_linkctrl2_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint16_t *value, uint16_t dev_value, uint16_t valid_mask)
{
struct pt_reg_info_tbl *reg = cfg_entry->reg;
uint16_t linkctrl2_mask = (0x0040 | 0xE000);
/* modify emulate register */
- writable_mask = reg->emu_mask & ~reg->ro_mask & valid_mask &
+ writable_mask = reg->emu_mask & ~reg->ro_mask & valid_mask &
~linkctrl2_mask;
cfg_entry->data = ((*value & writable_mask) |
(cfg_entry->data & ~writable_mask));
}
/* write Message Control register */
-static int pt_msgctrl_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_msgctrl_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint16_t *value, uint16_t dev_value, uint16_t valid_mask)
{
struct pt_reg_info_tbl *reg = cfg_entry->reg;
cfg_entry->data = ((*value & writable_mask) |
(cfg_entry->data & ~writable_mask));
/* update the msi_info too */
- ptdev->msi->flags |= cfg_entry->data &
+ ptdev->msi->flags |= cfg_entry->data &
~(MSI_FLAG_UNINIT | PT_MSI_MAPPED | PCI_MSI_FLAGS_ENABLE);
PT_LOG("old_ctrl:%04xh new_ctrl:%04xh\n", old_ctrl, cfg_entry->data);
-
+
/* create value for writing to I/O device register */
val = *value;
throughable_mask = ~reg->emu_mask & valid_mask;
}
/* write Message Address register */
-static int pt_msgaddr32_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_msgaddr32_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint32_t *value, uint32_t dev_value, uint32_t valid_mask)
{
struct pt_reg_info_tbl *reg = cfg_entry->reg;
(cfg_entry->data & ~writable_mask));
/* update the msi_info too */
ptdev->msi->addr_lo = cfg_entry->data;
-
+
PT_LOG("old_addr_lo:%08xh new_addr_lo:%08xh\n", old_addr, cfg_entry->data);
-
+
/* create value for writing to I/O device register */
throughable_mask = ~reg->emu_mask & valid_mask;
*value = ((*value & throughable_mask) | (dev_value & ~throughable_mask));
}
/* write Message Upper Address register */
-static int pt_msgaddr64_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_msgaddr64_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint32_t *value, uint32_t dev_value, uint32_t valid_mask)
{
struct pt_reg_info_tbl *reg = cfg_entry->reg;
(cfg_entry->data & ~writable_mask));
/* update the msi_info too */
ptdev->msi->addr_hi = cfg_entry->data;
-
+
PT_LOG("old_addr_hi:%08xh new_addr_hi:%08xh\n", old_addr, cfg_entry->data);
-
+
/* create value for writing to I/O device register */
throughable_mask = ~reg->emu_mask & valid_mask;
*value = ((*value & throughable_mask) | (dev_value & ~throughable_mask));
/* this function will be called twice (for 32 bit and 64 bit type) */
/* write Message Data register */
-static int pt_msgdata_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_msgdata_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint16_t *value, uint16_t dev_value, uint16_t valid_mask)
{
struct pt_reg_info_tbl *reg = cfg_entry->reg;
}
/* write Message Control register for MSI-X */
-static int pt_msixctrl_reg_write(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_msixctrl_reg_write(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint16_t *value, uint16_t dev_value, uint16_t valid_mask)
{
struct pt_reg_info_tbl *reg = cfg_entry->reg;
(cfg_entry->data & ~writable_mask));
PT_LOG("old_ctrl:%04xh new_ctrl:%04xh\n", old_ctrl, cfg_entry->data);
-
+
/* create value for writing to I/O device register */
throughable_mask = ~reg->emu_mask & valid_mask;
*value = ((*value & throughable_mask) | (dev_value & ~throughable_mask));
}
/* restore byte size emulate register */
-static int pt_byte_reg_restore(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_byte_reg_restore(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint32_t real_offset, uint8_t dev_value, uint8_t *value)
{
struct pt_reg_info_tbl *reg = cfg_entry->reg;
}
/* restore word size emulate register */
-static int pt_word_reg_restore(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_word_reg_restore(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint32_t real_offset, uint16_t dev_value, uint16_t *value)
{
struct pt_reg_info_tbl *reg = cfg_entry->reg;
}
/* restore long size emulate register */
-static int pt_long_reg_restore(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_long_reg_restore(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint32_t real_offset, uint32_t dev_value, uint32_t *value)
{
struct pt_reg_info_tbl *reg = cfg_entry->reg;
}
/* restore Command register */
-static int pt_cmd_reg_restore(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_cmd_reg_restore(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint32_t real_offset, uint16_t dev_value, uint16_t *value)
{
struct pt_reg_info_tbl *reg = cfg_entry->reg;
}
/* restore BAR */
-static int pt_bar_reg_restore(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_bar_reg_restore(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint32_t real_offset, uint32_t dev_value, uint32_t *value)
{
struct pt_reg_info_tbl *reg = cfg_entry->reg;
}
/* restore Power Management Control/Status register */
-static int pt_pmcsr_reg_restore(struct pt_dev *ptdev,
- struct pt_reg_tbl *cfg_entry,
+static int pt_pmcsr_reg_restore(struct pt_dev *ptdev,
+ struct pt_reg_tbl *cfg_entry,
uint32_t real_offset, uint16_t dev_value, uint16_t *value)
{
struct pt_reg_info_tbl *reg = cfg_entry->reg;
/* unregister real device's MMIO/PIO BARs */
pt_unregister_regions(assigned_device);
-
+
/* deassign the dev to dom0 */
bdf |= (pci_dev->bus & 0xff) << 16;
bdf |= (pci_dev->dev & 0x1f) << 11;
struct php_dev *php_dev = &dpci_infos.php_devs[php_slot];
int pci_slot = php_slot + PHP_SLOT_START;
struct pt_dev *pt_dev;
- pt_dev =
+ pt_dev =
register_real_device(dpci_infos.e_bus,
"DIRECT PCI",
pci_slot << 3,