18a0743cfSAnthony Liguori /* 28a0743cfSAnthony Liguori * libqos malloc support 38a0743cfSAnthony Liguori * 48a0743cfSAnthony Liguori * Copyright IBM, Corp. 2012-2013 58a0743cfSAnthony Liguori * 68a0743cfSAnthony Liguori * Authors: 78a0743cfSAnthony Liguori * Anthony Liguori <aliguori@us.ibm.com> 88a0743cfSAnthony Liguori * 98a0743cfSAnthony Liguori * This work is licensed under the terms of the GNU GPL, version 2 or later. 108a0743cfSAnthony Liguori * See the COPYING file in the top-level directory. 118a0743cfSAnthony Liguori */ 128a0743cfSAnthony Liguori 138a0743cfSAnthony Liguori #ifndef LIBQOS_MALLOC_H 148a0743cfSAnthony Liguori #define LIBQOS_MALLOC_H 158a0743cfSAnthony Liguori 168a0743cfSAnthony Liguori #include <stdint.h> 178a0743cfSAnthony Liguori #include <sys/types.h> 18292be092SMarc Marí #include "qemu/queue.h" 198a0743cfSAnthony Liguori 20292be092SMarc Marí typedef enum { 21292be092SMarc Marí ALLOC_NO_FLAGS = 0x00, 22292be092SMarc Marí ALLOC_LEAK_WARN = 0x01, 23292be092SMarc Marí ALLOC_LEAK_ASSERT = 0x02, 24292be092SMarc Marí ALLOC_PARANOID = 0x04 25292be092SMarc Marí } QAllocOpts; 26292be092SMarc Marí 27f6f363c1SJohn Snow typedef struct QGuestAllocator QGuestAllocator; 28292be092SMarc Marí 29292be092SMarc Marí void alloc_uninit(QGuestAllocator *allocator); 308a0743cfSAnthony Liguori 318a0743cfSAnthony Liguori /* Always returns page aligned values */ 32292be092SMarc Marí uint64_t guest_alloc(QGuestAllocator *allocator, size_t size); 33292be092SMarc Marí void guest_free(QGuestAllocator *allocator, uint64_t addr); 348a0743cfSAnthony Liguori 35af77f2cdSJohn Snow QGuestAllocator *alloc_init(uint64_t start, uint64_t end); 36fa02e608SJohn Snow QGuestAllocator *alloc_init_flags(QAllocOpts flags, 37fa02e608SJohn Snow uint64_t start, uint64_t end); 38f6f363c1SJohn Snow void alloc_set_page_size(QGuestAllocator *allocator, size_t page_size); 39*259342d3SJohn Snow void alloc_set_flags(QGuestAllocator *allocator, QAllocOpts opts); 40f6f363c1SJohn Snow 418a0743cfSAnthony Liguori #endif 42