blob: ae9dac8f6126ab44daf1664d2c8bdbc9b2e5b356 [file] [log] [blame]
Anthony Liguori8a0743c2013-04-16 09:45:18 -05001/*
2 * libqos malloc support
3 *
4 * Copyright IBM, Corp. 2012-2013
5 *
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
8 *
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
11 */
12
13#ifndef LIBQOS_MALLOC_H
14#define LIBQOS_MALLOC_H
15
Marc Marí292be092014-10-23 10:12:42 +020016#include "qemu/queue.h"
Anthony Liguori8a0743c2013-04-16 09:45:18 -050017
Marc Marí292be092014-10-23 10:12:42 +020018typedef enum {
19 ALLOC_NO_FLAGS = 0x00,
20 ALLOC_LEAK_WARN = 0x01,
21 ALLOC_LEAK_ASSERT = 0x02,
22 ALLOC_PARANOID = 0x04
23} QAllocOpts;
24
John Snowf6f363c2015-01-19 15:15:54 -050025typedef struct QGuestAllocator QGuestAllocator;
Marc Marí292be092014-10-23 10:12:42 +020026
Marc Marí292be092014-10-23 10:12:42 +020027void alloc_uninit(QGuestAllocator *allocator);
Anthony Liguori8a0743c2013-04-16 09:45:18 -050028
29/* Always returns page aligned values */
Marc Marí292be092014-10-23 10:12:42 +020030uint64_t guest_alloc(QGuestAllocator *allocator, size_t size);
31void guest_free(QGuestAllocator *allocator, uint64_t addr);
John Snow085248a2015-05-22 14:13:43 -040032void migrate_allocator(QGuestAllocator *src, QGuestAllocator *dst);
Anthony Liguori8a0743c2013-04-16 09:45:18 -050033
John Snowaf77f2c2015-01-19 15:15:49 -050034QGuestAllocator *alloc_init(uint64_t start, uint64_t end);
John Snowfa02e602015-01-19 15:15:53 -050035QGuestAllocator *alloc_init_flags(QAllocOpts flags,
36 uint64_t start, uint64_t end);
John Snowf6f363c2015-01-19 15:15:54 -050037void alloc_set_page_size(QGuestAllocator *allocator, size_t page_size);
John Snow259342d2015-02-05 12:41:28 -050038void alloc_set_flags(QGuestAllocator *allocator, QAllocOpts opts);
John Snowf6f363c2015-01-19 15:15:54 -050039
Anthony Liguori8a0743c2013-04-16 09:45:18 -050040#endif