summaryrefslogtreecommitdiff
path: root/xen-mapcache.c
diff options
context:
space:
mode:
authorAnthony PERARD <anthony.perard@citrix.com>2010-09-16 13:57:49 +0100
committerAlexander Graf <agraf@suse.de>2011-05-08 10:10:01 +0200
commit050a0ddf39cf5555ecf9b22a918b2a2b00bdbe34 (patch)
treee8267403b7a59988a32773ec6e9367f791e30f0a /xen-mapcache.c
parentea6c5f8ffe6de12e04e63acbb9937683b30216e2 (diff)
downloadqemu-050a0ddf39cf5555ecf9b22a918b2a2b00bdbe34.tar.gz
qemu-050a0ddf39cf5555ecf9b22a918b2a2b00bdbe34.tar.bz2
qemu-050a0ddf39cf5555ecf9b22a918b2a2b00bdbe34.zip
Introduce qemu_put_ram_ptr
This function allows to unlock a ram_ptr give by qemu_get_ram_ptr. After a call to qemu_put_ram_ptr, the pointer may be unmap from QEMU when used with Xen. Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Acked-by: Alexander Graf <agraf@suse.de> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'xen-mapcache.c')
-rw-r--r--xen-mapcache.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/xen-mapcache.c b/xen-mapcache.c
index 2ca18ce3b5..349cc6221d 100644
--- a/xen-mapcache.c
+++ b/xen-mapcache.c
@@ -196,6 +196,39 @@ uint8_t *qemu_map_cache(target_phys_addr_t phys_addr, target_phys_addr_t size, u
return mapcache->last_address_vaddr + address_offset;
}
+void qemu_map_cache_unlock(void *buffer)
+{
+ MapCacheEntry *entry = NULL, *pentry = NULL;
+ MapCacheRev *reventry;
+ target_phys_addr_t paddr_index;
+ int found = 0;
+
+ QTAILQ_FOREACH(reventry, &mapcache->locked_entries, next) {
+ if (reventry->vaddr_req == buffer) {
+ paddr_index = reventry->paddr_index;
+ found = 1;
+ break;
+ }
+ }
+ if (!found) {
+ return;
+ }
+ QTAILQ_REMOVE(&mapcache->locked_entries, reventry, next);
+ qemu_free(reventry);
+
+ entry = &mapcache->entry[paddr_index % mapcache->nr_buckets];
+ while (entry && entry->paddr_index != paddr_index) {
+ pentry = entry;
+ entry = entry->next;
+ }
+ if (!entry) {
+ return;
+ }
+ if (entry->lock > 0) {
+ entry->lock--;
+ }
+}
+
ram_addr_t qemu_ram_addr_from_mapcache(void *ptr)
{
MapCacheRev *reventry;