]> Git Repo - qemu.git/blame - tests/libqos/malloc-pc.c
libqos: drop duplicated virtio_vring.h structs
[qemu.git] / tests / libqos / malloc-pc.c
CommitLineData
8a0743cf
AL
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
681c28a3 13#include "qemu/osdep.h"
8a0743cf 14#include "libqos/malloc-pc.h"
26491a38 15#include "libqos/fw_cfg.h"
8a0743cf 16
6f061ea1 17#include "hw/nvram/fw_cfg_keys.h"
8a0743cf
AL
18
19#include "qemu-common.h"
8a0743cf
AL
20
21#define PAGE_SIZE (4096)
22
ec2f1605
JS
23/*
24 * Mostly for valgrind happiness, but it does offer
25 * a chokepoint for debugging guest memory leaks, too.
26 */
27void pc_alloc_uninit(QGuestAllocator *allocator)
28{
292be092 29 alloc_uninit(allocator);
8a0743cf
AL
30}
31
292be092 32QGuestAllocator *pc_alloc_init_flags(QAllocOpts flags)
8a0743cf 33{
af77f2cd 34 QGuestAllocator *s;
8a0743cf
AL
35 uint64_t ram_size;
36 QFWCFG *fw_cfg = pc_fw_cfg_init();
8a0743cf
AL
37
38 ram_size = qfw_cfg_get_u64(fw_cfg, FW_CFG_RAM_SIZE);
fa02e608 39 s = alloc_init_flags(flags, 1 << 20, MIN(ram_size, 0xE0000000));
f6f363c1 40 alloc_set_page_size(s, PAGE_SIZE);
8a0743cf 41
f3cdcbae
JS
42 /* clean-up */
43 g_free(fw_cfg);
44
292be092 45 return s;
8a0743cf 46}
ec2f1605
JS
47
48inline QGuestAllocator *pc_alloc_init(void)
49{
292be092 50 return pc_alloc_init_flags(ALLOC_NO_FLAGS);
ec2f1605 51}
This page took 0.190441 seconds and 4 git commands to generate.