From: "Michael S. Tsirkin" <mst@redhat.com>
To: weil@mail.berlios.de, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 1/2] pci: add API to add capability at a known offset
Date: Wed, 7 Apr 2010 11:04:05 +0300 [thread overview]
Message-ID: <2b600ff5a3d1dd5fc1cb4c35c4403d21674b3377.1270627361.git.mst@redhat.com> (raw)
In-Reply-To: <cover.1270627361.git.mst@redhat.com>
Unlike virtio, device emulations need to add pci capabilities
at known offsets to match real hardware. Make this possible
by adding an appropriate API.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/pci.c | 16 ++++++++++++----
hw/pci.h | 2 ++
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/hw/pci.c b/hw/pci.c
index 0dbca17..df03149 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1789,12 +1789,10 @@ static int pci_add_option_rom(PCIDevice *pdev)
}
/* Reserve space and add capability to the linked list in pci config space */
-int pci_add_capability(PCIDevice *pdev, uint8_t cap_id, uint8_t size)
+int pci_add_capability_at_offset(PCIDevice *pdev, uint8_t cap_id,
+ uint8_t offset, uint8_t size)
{
- uint8_t offset = pci_find_space(pdev, size);
uint8_t *config = pdev->config + offset;
- if (!offset)
- return -ENOSPC;
config[PCI_CAP_LIST_ID] = cap_id;
config[PCI_CAP_LIST_NEXT] = pdev->config[PCI_CAPABILITY_LIST];
pdev->config[PCI_CAPABILITY_LIST] = offset;
@@ -1807,6 +1805,16 @@ int pci_add_capability(PCIDevice *pdev, uint8_t cap_id, uint8_t size)
return offset;
}
+/* Find and reserve space and add capability to the linked list
+ * in pci config space */
+int pci_add_capability(PCIDevice *pdev, uint8_t cap_id, uint8_t size)
+{
+ uint8_t offset = pci_find_space(pdev, size);
+ if (!offset)
+ return -ENOSPC;
+ return pci_add_capability_at_offset(pdev, cap_id, offset, size);
+}
+
/* Unlink capability from the pci config space. */
void pci_del_capability(PCIDevice *pdev, uint8_t cap_id, uint8_t size)
{
diff --git a/hw/pci.h b/hw/pci.h
index 20c670e..625188c 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -190,6 +190,8 @@ void pci_register_bar(PCIDevice *pci_dev, int region_num,
PCIMapIORegionFunc *map_func);
int pci_add_capability(PCIDevice *pci_dev, uint8_t cap_id, uint8_t cap_size);
+int pci_add_capability_at_offset(PCIDevice *pci_dev, uint8_t cap_id,
+ uint8_t cap_offset, uint8_t cap_size);
void pci_del_capability(PCIDevice *pci_dev, uint8_t cap_id, uint8_t cap_size);
--
1.7.0.2.280.gc6f05
next prev parent reply other threads:[~2010-04-07 8:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-07 8:04 [Qemu-devel] [PATCH 0/2] pci_add_capability_at_offset Michael S. Tsirkin
2010-04-07 8:04 ` Michael S. Tsirkin [this message]
2010-04-07 8:36 ` [Qemu-devel] Re: [PATCH 1/2] pci: add API to add capability at a known offset Stefan Weil
2010-04-07 8:04 ` [Qemu-devel] [PATCH 2/2] eepro100: convert to new capability API Michael S. Tsirkin
2010-04-07 8:42 ` [Qemu-devel] " Stefan Weil
2010-04-07 11:04 ` Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2b600ff5a3d1dd5fc1cb4c35c4403d21674b3377.1270627361.git.mst@redhat.com \
--to=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=weil@mail.berlios.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).