Anthony Liguori | 8a0743c | 2013-04-16 09:45:18 -0500 | [diff] [blame] | 1 | /* |
| 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í | 292be09 | 2014-10-23 10:12:42 +0200 | [diff] [blame] | 18 | #include "qemu/queue.h" |
Anthony Liguori | 8a0743c | 2013-04-16 09:45:18 -0500 | [diff] [blame] | 19 | |
Marc Marí | 292be09 | 2014-10-23 10:12:42 +0200 | [diff] [blame] | 20 | typedef enum { |
| 21 | ALLOC_NO_FLAGS = 0x00, |
| 22 | ALLOC_LEAK_WARN = 0x01, |
| 23 | ALLOC_LEAK_ASSERT = 0x02, |
| 24 | ALLOC_PARANOID = 0x04 |
| 25 | } QAllocOpts; |
| 26 | |
John Snow | f6f363c | 2015-01-19 15:15:54 -0500 | [diff] [blame] | 27 | typedef struct QGuestAllocator QGuestAllocator; |
Marc Marí | 292be09 | 2014-10-23 10:12:42 +0200 | [diff] [blame] | 28 | |
Marc Marí | 292be09 | 2014-10-23 10:12:42 +0200 | [diff] [blame] | 29 | void alloc_uninit(QGuestAllocator *allocator); |
Anthony Liguori | 8a0743c | 2013-04-16 09:45:18 -0500 | [diff] [blame] | 30 | |
| 31 | /* Always returns page aligned values */ |
Marc Marí | 292be09 | 2014-10-23 10:12:42 +0200 | [diff] [blame] | 32 | uint64_t guest_alloc(QGuestAllocator *allocator, size_t size); |
| 33 | void guest_free(QGuestAllocator *allocator, uint64_t addr); |
John Snow | 085248a | 2015-05-22 14:13:43 -0400 | [diff] [blame] | 34 | void migrate_allocator(QGuestAllocator *src, QGuestAllocator *dst); |
Anthony Liguori | 8a0743c | 2013-04-16 09:45:18 -0500 | [diff] [blame] | 35 | |
John Snow | af77f2c | 2015-01-19 15:15:49 -0500 | [diff] [blame] | 36 | QGuestAllocator *alloc_init(uint64_t start, uint64_t end); |
John Snow | fa02e60 | 2015-01-19 15:15:53 -0500 | [diff] [blame] | 37 | QGuestAllocator *alloc_init_flags(QAllocOpts flags, |
| 38 | uint64_t start, uint64_t end); |
John Snow | f6f363c | 2015-01-19 15:15:54 -0500 | [diff] [blame] | 39 | void alloc_set_page_size(QGuestAllocator *allocator, size_t page_size); |
John Snow | 259342d | 2015-02-05 12:41:28 -0500 | [diff] [blame] | 40 | void alloc_set_flags(QGuestAllocator *allocator, QAllocOpts opts); |
John Snow | f6f363c | 2015-01-19 15:15:54 -0500 | [diff] [blame] | 41 | |
Anthony Liguori | 8a0743c | 2013-04-16 09:45:18 -0500 | [diff] [blame] | 42 | #endif |