|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v1 2/3] xen/vpci: add vpci_read_val helper
Introduce a vPCI read helper function that returns a fixed value. This may be
used for RAZ registers, or registers whose value doesn't change. This helper
will be used in a subsequent patch.
Signed-off-by: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
---
RFC: I'm not a fan of the (uintptr_t) cast, but without it I wasn't sure how to
pass a value without allocating more memory (either with an xalloc function
of sorts, or by adding a new element in struct vpci_register and changing
the interface). Plus, in the current state, to pass a value to
vpci_add_register(), it may be necessary to cast twice:
(void *)(uintptr_t)myval. See next patch. Perhaps a new allocation is worth
it to avoid the casts? Or maybe I'm being overly pedantic and the casts are
okay?
---
xen/drivers/vpci/vpci.c | 6 ++++++
xen/include/xen/vpci.h | 3 +++
2 files changed, 9 insertions(+)
diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c
index acadba1fd6c5..4a96aa50494d 100644
--- a/xen/drivers/vpci/vpci.c
+++ b/xen/drivers/vpci/vpci.c
@@ -133,6 +133,12 @@ static void cf_check vpci_ignored_write(
{
}
+uint32_t cf_check vpci_read_val(
+ const struct pci_dev *pdev, unsigned int reg, void *data)
+{
+ return (uintptr_t)data;
+}
+
uint32_t cf_check vpci_hw_read8(
const struct pci_dev *pdev, unsigned int reg, void *data)
{
diff --git a/xen/include/xen/vpci.h b/xen/include/xen/vpci.h
index ee7a8fcdee83..17fd252746ec 100644
--- a/xen/include/xen/vpci.h
+++ b/xen/include/xen/vpci.h
@@ -45,6 +45,9 @@ uint32_t vpci_read(pci_sbdf_t sbdf, unsigned int reg,
unsigned int size);
void vpci_write(pci_sbdf_t sbdf, unsigned int reg, unsigned int size,
uint32_t data);
+uint32_t cf_check vpci_read_val(
+ const struct pci_dev *pdev, unsigned int reg, void *data);
+
/* Passthrough handlers. */
uint32_t cf_check vpci_hw_read8(
const struct pci_dev *pdev, unsigned int reg, void *data);
--
2.41.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |