blob: 0c6c9b7f30750059689945a0fd45db4d00b47924 [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
16#include <stdint.h>
17#include <sys/types.h>
Marc Marí292be092014-10-23 10:12:42 +020018#include "qemu/queue.h"
Anthony Liguori8a0743c2013-04-16 09:45:18 -050019
Marc Marí292be092014-10-23 10:12:42 +020020typedef enum {
21 ALLOC_NO_FLAGS = 0x00,
22 ALLOC_LEAK_WARN = 0x01,
23 ALLOC_LEAK_ASSERT = 0x02,
24 ALLOC_PARANOID = 0x04
25} QAllocOpts;
26
John Snowf6f363c2015-01-19 15:15:54 -050027typedef struct QGuestAllocator QGuestAllocator;
Marc Marí292be092014-10-23 10:12:42 +020028
Marc Marí292be092014-10-23 10:12:42 +020029void alloc_uninit(QGuestAllocator *allocator);
Anthony Liguori8a0743c2013-04-16 09:45:18 -050030
31/* Always returns page aligned values */
Marc Marí292be092014-10-23 10:12:42 +020032uint64_t guest_alloc(QGuestAllocator *allocator, size_t size);
33void guest_free(QGuestAllocator *allocator, uint64_t addr);
John Snow085248a2015-05-22 14:13:43 -040034void migrate_allocator(QGuestAllocator *src, QGuestAllocator *dst);
Anthony Liguori8a0743c2013-04-16 09:45:18 -050035
John Snowaf77f2c2015-01-19 15:15:49 -050036QGuestAllocator *alloc_init(uint64_t start, uint64_t end);
John Snowfa02e602015-01-19 15:15:53 -050037QGuestAllocator *alloc_init_flags(QAllocOpts flags,
38 uint64_t start, uint64_t end);
John Snowf6f363c2015-01-19 15:15:54 -050039void alloc_set_page_size(QGuestAllocator *allocator, size_t page_size);
John Snow259342d2015-02-05 12:41:28 -050040void alloc_set_flags(QGuestAllocator *allocator, QAllocOpts opts);
John Snowf6f363c2015-01-19 15:15:54 -050041
Anthony Liguori8a0743c2013-04-16 09:45:18 -050042#endif