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