]> Git Repo - qemu.git/blob - tests/libqos/malloc-pc.c
tests: Clean up includes
[qemu.git] / tests / libqos / malloc-pc.c
1 /*
2  * libqos malloc support for PC
3  *
4  * Copyright IBM, Corp. 2012-2013
5  *
6  * Authors:
7  *  Anthony Liguori   <[email protected]>
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 #include "qemu/osdep.h"
14 #include "libqos/malloc-pc.h"
15 #include "libqos/fw_cfg.h"
16
17 #define NO_QEMU_PROTOS
18 #include "hw/nvram/fw_cfg.h"
19
20 #include "qemu-common.h"
21 #include <glib.h>
22
23 #define PAGE_SIZE (4096)
24
25 /*
26  * Mostly for valgrind happiness, but it does offer
27  * a chokepoint for debugging guest memory leaks, too.
28  */
29 void pc_alloc_uninit(QGuestAllocator *allocator)
30 {
31     alloc_uninit(allocator);
32 }
33
34 QGuestAllocator *pc_alloc_init_flags(QAllocOpts flags)
35 {
36     QGuestAllocator *s;
37     uint64_t ram_size;
38     QFWCFG *fw_cfg = pc_fw_cfg_init();
39
40     ram_size = qfw_cfg_get_u64(fw_cfg, FW_CFG_RAM_SIZE);
41     s = alloc_init_flags(flags, 1 << 20, MIN(ram_size, 0xE0000000));
42     alloc_set_page_size(s, PAGE_SIZE);
43
44     /* clean-up */
45     g_free(fw_cfg);
46
47     return s;
48 }
49
50 inline QGuestAllocator *pc_alloc_init(void)
51 {
52     return pc_alloc_init_flags(ALLOC_NO_FLAGS);
53 }
This page took 0.025764 seconds and 4 git commands to generate.