From: Jan Kiszka <jan.kiszka@xxxxxxxxxxx>
The map cache is a Xen thing, so its API should make this clear.
Signed-off-by: Jan Kiszka <jan.kiszka@xxxxxxxxxxx>
---
exec.c | 10 +++++-----
trace-events | 6 +++---
xen-all.c | 4 ++--
xen-mapcache-stub.c | 13 +++++++------
xen-mapcache.c | 43 ++++++++++++++++++++++++-------------------
xen-mapcache.h | 16 +++++++---------
6 files changed, 48 insertions(+), 44 deletions(-)
diff --git a/exec.c b/exec.c
index 41ba883..91751c5 100644
--- a/exec.c
+++ b/exec.c
@@ -2990,7 +2990,7 @@ void qemu_ram_free(ram_addr_t addr)
munmap(block->host, block->length);
#else
if (xen_mapcache_enabled()) {
- qemu_invalidate_entry(block->host);
+ xen_invalidate_map_cache_entry(block->host);
} else {
qemu_vfree(block->host);
}
@@ -3087,7 +3087,7 @@ void *qemu_get_ram_ptr(ram_addr_t addr)
* because we don't want to map the entire memory in QEMU.
*/
if (block->offset == 0) {
- return qemu_map_cache(addr, 0, 1);
+ return xen_map_cache(addr, 0, 1);
} else if (block->host == NULL) {
block->host = xen_map_block(block->offset, block->length);
}
@@ -3116,7 +3116,7 @@ void *qemu_safe_ram_ptr(ram_addr_t addr)
* because we don't want to map the entire memory in QEMU.
*/
if (block->offset == 0) {
- return qemu_map_cache(addr, 0, 1);
+ return xen_map_cache(addr, 0, 1);
} else if (block->host == NULL) {
block->host = xen_map_block(block->offset, block->length);
}
@@ -3147,7 +3147,7 @@ void qemu_put_ram_ptr(void *addr)
xen_unmap_block(block->host, block->length);
block->host = NULL;
} else {
- qemu_map_cache_unlock(addr);
+ xen_map_cache_unlock(addr);
}
}
}
@@ -3169,7 +3169,7 @@ int qemu_ram_addr_from_host(void *ptr, ram_addr_t
*ram_addr)
}
if (xen_mapcache_enabled()) {
- *ram_addr = qemu_ram_addr_from_mapcache(ptr);
+ *ram_addr = xen_ram_addr_from_mapcache(ptr);
return 0;
}
diff --git a/trace-events b/trace-events
index f1230f1..a2839dd 100644
--- a/trace-events
+++ b/trace-events
@@ -398,9 +398,9 @@ disable milkymist_vgafb_memory_write(uint32_t addr,
uint32_t value) "addr %08x v
disable xen_ram_alloc(unsigned long ram_addr, unsigned long size) "requested:
%#lx, size %#lx"
# xen-mapcache.c
-disable qemu_map_cache(uint64_t phys_addr) "want %#"PRIx64""
-disable qemu_remap_bucket(uint64_t index) "index %#"PRIx64""
-disable qemu_map_cache_return(void* ptr) "%p"
+disable xen_map_cache(uint64_t phys_addr) "want %#"PRIx64""
+disable xen_remap_bucket(uint64_t index) "index %#"PRIx64""
+disable xen_map_cache_return(void* ptr) "%p"
disable xen_map_block(uint64_t phys_addr, uint64_t size) "%#"PRIx64", size
%#"PRIx64""
disable xen_unmap_block(void* addr, unsigned long size) "%p, size %#lx"
diff --git a/xen-all.c b/xen-all.c
index 0eac202..7346751 100644
--- a/xen-all.c
+++ b/xen-all.c
@@ -368,7 +368,7 @@ static void handle_ioreq(ioreq_t *req)
case IOREQ_TYPE_TIMEOFFSET:
break;
case IOREQ_TYPE_INVALIDATE:
- qemu_invalidate_map_cache();
+ xen_invalidate_map_cache();
break;
default:
hw_error("Invalid ioreq type 0x%x\n", req->type);
@@ -576,7 +576,7 @@ int xen_hvm_init(void)
}
/* Init RAM management */
- qemu_map_cache_init();
+ xen_map_cache_init();
xen_ram_init(ram_size);
qemu_add_vm_change_state_handler(xen_vm_change_state_handler, state);
diff --git a/xen-mapcache-stub.c b/xen-mapcache-stub.c
index dfecbdd..6ee0dc8 100644
--- a/xen-mapcache-stub.c
+++ b/xen-mapcache-stub.c
@@ -13,29 +13,30 @@
#include "cpu-common.h"
#include "xen-mapcache.h"
-void qemu_map_cache_init(void)
+void xen_map_cache_init(void)
{
}
-uint8_t *qemu_map_cache(target_phys_addr_t phys_addr, target_phys_addr_t size,
uint8_t lock)
+uint8_t *xen_map_cache(target_phys_addr_t phys_addr, target_phys_addr_t size,
+ uint8_t lock)
{
return qemu_get_ram_ptr(phys_addr);
}
-void qemu_map_cache_unlock(void *buffer)
+void xen_map_cache_unlock(void *buffer)
{
}
-ram_addr_t qemu_ram_addr_from_mapcache(void *ptr)
+ram_addr_t xen_ram_addr_from_mapcache(void *ptr)
{
return -1;
}
-void qemu_invalidate_map_cache(void)
+void xen_invalidate_map_cache(void)
{
}
-void qemu_invalidate_entry(uint8_t *buffer)
+void xen_invalidate_map_cache_entry(uint8_t *buffer)
{
}
uint8_t *xen_map_block(target_phys_addr_t phys_addr, target_phys_addr_t size)
diff --git a/xen-mapcache.c b/xen-mapcache.c
index 4c663e6..e823246 100644
--- a/xen-mapcache.c
+++ b/xen-mapcache.c
@@ -40,6 +40,9 @@
#endif
#define MCACHE_BUCKET_SIZE (1UL << MCACHE_BUCKET_SHIFT)
+#define mapcache_lock() ((void)0)
+#define mapcache_unlock() ((void)0)
+
typedef struct MapCacheEntry {
target_phys_addr_t paddr_index;
uint8_t *vaddr_base;
@@ -68,7 +71,7 @@ typedef struct MapCache {
static MapCache *mapcache;
-void qemu_map_cache_init(void)
+void xen_map_cache_init(void)
{
unsigned long size;
struct rlimit rlimit_as;
@@ -95,13 +98,14 @@ void qemu_map_cache_init(void)
size = mapcache->nr_buckets * sizeof (MapCacheEntry);
size = (size + XC_PAGE_SIZE - 1) & ~(XC_PAGE_SIZE - 1);
- DPRINTF("qemu_map_cache_init, nr_buckets = %lx size %lu\n",
mapcache->nr_buckets, size);
+ DPRINTF("%s, nr_buckets = %lx size %lu\n", __func__,
+ mapcache->nr_buckets, size);
mapcache->entry = qemu_mallocz(size);
}
-static void qemu_remap_bucket(MapCacheEntry *entry,
- target_phys_addr_t size,
- target_phys_addr_t address_index)
+static void xen_remap_bucket(MapCacheEntry *entry,
+ target_phys_addr_t size,
+ target_phys_addr_t address_index)
{
uint8_t *vaddr_base;
xen_pfn_t *pfns;
@@ -109,7 +113,7 @@ static void qemu_remap_bucket(MapCacheEntry *entry,
unsigned int i;
target_phys_addr_t nb_pfn = size >> XC_PAGE_SHIFT;
- trace_qemu_remap_bucket(address_index);
+ trace_xen_remap_bucket(address_index);
pfns = qemu_mallocz(nb_pfn * sizeof (xen_pfn_t));
err = qemu_mallocz(nb_pfn * sizeof (int));
@@ -146,16 +150,17 @@ static void qemu_remap_bucket(MapCacheEntry *entry,
qemu_free(err);
}
-uint8_t *qemu_map_cache(target_phys_addr_t phys_addr, target_phys_addr_t size,
uint8_t lock)
+uint8_t *xen_map_cache(target_phys_addr_t phys_addr, target_phys_addr_t size,
+ uint8_t lock)
{
MapCacheEntry *entry, *pentry = NULL;
target_phys_addr_t address_index = phys_addr >> MCACHE_BUCKET_SHIFT;
target_phys_addr_t address_offset = phys_addr & (MCACHE_BUCKET_SIZE - 1);
- trace_qemu_map_cache(phys_addr);
+ trace_xen_map_cache(phys_addr);
if (address_index == mapcache->last_address_index && !lock) {
- trace_qemu_map_cache_return(mapcache->last_address_vaddr +
address_offset);
+ trace_xen_map_cache_return(mapcache->last_address_vaddr +
address_offset);
return mapcache->last_address_vaddr + address_offset;
}
@@ -168,17 +173,17 @@ uint8_t *qemu_map_cache(target_phys_addr_t phys_addr,
target_phys_addr_t size, u
if (!entry) {
entry = qemu_mallocz(sizeof (MapCacheEntry));
pentry->next = entry;
- qemu_remap_bucket(entry, size ? : MCACHE_BUCKET_SIZE, address_index);
+ xen_remap_bucket(entry, size ? : MCACHE_BUCKET_SIZE, address_index);
} else if (!entry->lock) {
if (!entry->vaddr_base || entry->paddr_index != address_index ||
!test_bit(address_offset >> XC_PAGE_SHIFT, entry->valid_mapping)) {
- qemu_remap_bucket(entry, size ? : MCACHE_BUCKET_SIZE,
address_index);
+ xen_remap_bucket(entry, size ? : MCACHE_BUCKET_SIZE,
address_index);
}
}
if (!test_bit(address_offset >> XC_PAGE_SHIFT, entry->valid_mapping)) {
mapcache->last_address_index = -1;
- trace_qemu_map_cache_return(NULL);
+ trace_xen_map_cache_return(NULL);
return NULL;
}
@@ -192,11 +197,11 @@ uint8_t *qemu_map_cache(target_phys_addr_t phys_addr,
target_phys_addr_t size, u
QTAILQ_INSERT_HEAD(&mapcache->locked_entries, reventry, next);
}
- trace_qemu_map_cache_return(mapcache->last_address_vaddr + address_offset);
+ trace_xen_map_cache_return(mapcache->last_address_vaddr + address_offset);
return mapcache->last_address_vaddr + address_offset;
}
-void qemu_map_cache_unlock(void *buffer)
+void xen_map_cache_unlock(void *buffer)
{
MapCacheEntry *entry = NULL, *pentry = NULL;
MapCacheRev *reventry;
@@ -229,7 +234,7 @@ void qemu_map_cache_unlock(void *buffer)
}
}
-ram_addr_t qemu_ram_addr_from_mapcache(void *ptr)
+ram_addr_t xen_ram_addr_from_mapcache(void *ptr)
{
MapCacheRev *reventry;
target_phys_addr_t paddr_index;
@@ -243,7 +248,7 @@ ram_addr_t qemu_ram_addr_from_mapcache(void *ptr)
}
}
if (!found) {
- fprintf(stderr, "qemu_ram_addr_from_mapcache, could not find %p\n",
ptr);
+ fprintf(stderr, "%s, could not find %p\n", __func__, ptr);
QTAILQ_FOREACH(reventry, &mapcache->locked_entries, next) {
DPRINTF(" "TARGET_FMT_plx" -> %p is present\n",
reventry->paddr_index,
reventry->vaddr_req);
@@ -255,7 +260,7 @@ ram_addr_t qemu_ram_addr_from_mapcache(void *ptr)
return paddr_index << MCACHE_BUCKET_SHIFT;
}
-void qemu_invalidate_entry(uint8_t *buffer)
+void xen_invalidate_map_cache_entry(uint8_t *buffer)
{
MapCacheEntry *entry = NULL, *pentry = NULL;
MapCacheRev *reventry;
@@ -274,7 +279,7 @@ void qemu_invalidate_entry(uint8_t *buffer)
}
}
if (!found) {
- DPRINTF("qemu_invalidate_entry, could not find %p\n", buffer);
+ DPRINTF("%s, could not find %p\n", __func__, buffer);
QTAILQ_FOREACH(reventry, &mapcache->locked_entries, next) {
DPRINTF(" "TARGET_FMT_plx" -> %p is present\n",
reventry->paddr_index, reventry->vaddr_req);
}
@@ -305,7 +310,7 @@ void qemu_invalidate_entry(uint8_t *buffer)
qemu_free(entry);
}
-void qemu_invalidate_map_cache(void)
+void xen_invalidate_map_cache(void)
{
unsigned long i;
MapCacheRev *reventry;
diff --git a/xen-mapcache.h b/xen-mapcache.h
index f7b4c04..b46c971 100644
--- a/xen-mapcache.h
+++ b/xen-mapcache.h
@@ -9,17 +9,15 @@
#ifndef XEN_MAPCACHE_H
#define XEN_MAPCACHE_H
-void qemu_map_cache_init(void);
-uint8_t *qemu_map_cache(target_phys_addr_t phys_addr, target_phys_addr_t
size, uint8_t lock);
-void qemu_map_cache_unlock(void *phys_addr);
-ram_addr_t qemu_ram_addr_from_mapcache(void *ptr);
-void qemu_invalidate_entry(uint8_t *buffer);
-void qemu_invalidate_map_cache(void);
+void xen_map_cache_init(void);
+uint8_t *xen_map_cache(target_phys_addr_t phys_addr, target_phys_addr_t size,
+ uint8_t lock);
+void xen_map_cache_unlock(void *phys_addr);
+ram_addr_t xen_ram_addr_from_mapcache(void *ptr);
+void xen_invalidate_map_cache_entry(uint8_t *buffer);
+void xen_invalidate_map_cache(void);
uint8_t *xen_map_block(target_phys_addr_t phys_addr, target_phys_addr_t size);
void xen_unmap_block(void *addr, ram_addr_t size);
-#define mapcache_lock() ((void)0)
-#define mapcache_unlock() ((void)0)
-
#endif /* !XEN_MAPCACHE_H */
--
1.7.1
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|