target-arm: aarch64: add support for ld lit
[qemu/cris-port.git] / include / migration / page_cache.h
blob87894fea9f11fe73337b9cec7c44995be011fabb
1 /*
2 * Page cache for QEMU
3 * The cache is base on a hash of the page address
5 * Copyright 2012 Red Hat, Inc. and/or its affiliates
7 * Authors:
8 * Orit Wasserman <owasserm@redhat.com>
10 * This work is licensed under the terms of the GNU GPL, version 2 or later.
11 * See the COPYING file in the top-level directory.
15 #ifndef PAGE_CACHE_H
16 #define PAGE_CACHE_H
18 /* Page cache for storing guest pages */
19 typedef struct PageCache PageCache;
21 /**
22 * cache_init: Initialize the page cache
25 * Returns new allocated cache or NULL on error
27 * @cache pointer to the PageCache struct
28 * @num_pages: cache maximal number of cached pages
29 * @page_size: cache page size
31 PageCache *cache_init(int64_t num_pages, unsigned int page_size);
33 /**
34 * cache_fini: free all cache resources
35 * @cache pointer to the PageCache struct
37 void cache_fini(PageCache *cache);
39 /**
40 * cache_is_cached: Checks to see if the page is cached
42 * Returns %true if page is cached
44 * @cache pointer to the PageCache struct
45 * @addr: page addr
47 bool cache_is_cached(const PageCache *cache, uint64_t addr);
49 /**
50 * get_cached_data: Get the data cached for an addr
52 * Returns pointer to the data cached or NULL if not cached
54 * @cache pointer to the PageCache struct
55 * @addr: page addr
57 uint8_t *get_cached_data(const PageCache *cache, uint64_t addr);
59 /**
60 * cache_insert: insert the page into the cache. the page cache
61 * will dup the data on insert. the previous value will be overwritten
63 * @cache pointer to the PageCache struct
64 * @addr: page address
65 * @pdata: pointer to the page
67 void cache_insert(PageCache *cache, uint64_t addr, uint8_t *pdata);
69 /**
70 * cache_resize: resize the page cache. In case of size reduction the extra
71 * pages will be freed
73 * Returns -1 on error new cache size on success
75 * @cache pointer to the PageCache struct
76 * @num_pages: new page cache size (in pages)
78 int64_t cache_resize(PageCache *cache, int64_t num_pages);
80 #endif