blob: 828fddabdba1a79db1836798f96b3778cf2180f0 [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"
Eric Blake05e520f2017-09-11 12:19:57 -050017#include "libqtest.h"
Anthony Liguori8a0743c2013-04-16 09:45:18 -050018
Marc Marí292be092014-10-23 10:12:42 +020019typedef enum {
20 ALLOC_NO_FLAGS = 0x00,
21 ALLOC_LEAK_WARN = 0x01,
22 ALLOC_LEAK_ASSERT = 0x02,
23 ALLOC_PARANOID = 0x04
24} QAllocOpts;
25
John Snowf6f363c2015-01-19 15:15:54 -050026typedef struct QGuestAllocator QGuestAllocator;
Marc Marí292be092014-10-23 10:12:42 +020027
Marc Marí292be092014-10-23 10:12:42 +020028void alloc_uninit(QGuestAllocator *allocator);
Anthony Liguori8a0743c2013-04-16 09:45:18 -050029
30/* Always returns page aligned values */
Marc Marí292be092014-10-23 10:12:42 +020031uint64_t guest_alloc(QGuestAllocator *allocator, size_t size);
32void guest_free(QGuestAllocator *allocator, uint64_t addr);
John Snow085248a2015-05-22 14:13:43 -040033void migrate_allocator(QGuestAllocator *src, QGuestAllocator *dst);
Anthony Liguori8a0743c2013-04-16 09:45:18 -050034
John Snowaf77f2c2015-01-19 15:15:49 -050035QGuestAllocator *alloc_init(uint64_t start, uint64_t end);
John Snowfa02e602015-01-19 15:15:53 -050036QGuestAllocator *alloc_init_flags(QAllocOpts flags,
37 uint64_t start, uint64_t end);
John Snowf6f363c2015-01-19 15:15:54 -050038void alloc_set_page_size(QGuestAllocator *allocator, size_t page_size);
John Snow259342d2015-02-05 12:41:28 -050039void alloc_set_flags(QGuestAllocator *allocator, QAllocOpts opts);
John Snowf6f363c2015-01-19 15:15:54 -050040
Anthony Liguori8a0743c2013-04-16 09:45:18 -050041#endif