11cf4323eSThomas Huth /*
21cf4323eSThomas Huth * libqos malloc support for PC
31cf4323eSThomas Huth *
41cf4323eSThomas Huth * Copyright IBM, Corp. 2012-2013
51cf4323eSThomas Huth *
61cf4323eSThomas Huth * Authors:
71cf4323eSThomas Huth * Anthony Liguori <aliguori@us.ibm.com>
81cf4323eSThomas Huth *
91cf4323eSThomas Huth * This work is licensed under the terms of the GNU GPL, version 2 or later.
101cf4323eSThomas Huth * See the COPYING file in the top-level directory.
111cf4323eSThomas Huth */
121cf4323eSThomas Huth
131cf4323eSThomas Huth #include "qemu/osdep.h"
14a2ce7dbdSPaolo Bonzini #include "malloc-pc.h"
15a2ce7dbdSPaolo Bonzini #include "fw_cfg.h"
161cf4323eSThomas Huth
171cf4323eSThomas Huth #include "standard-headers/linux/qemu_fw_cfg.h"
181cf4323eSThomas Huth
19*d2c4f384SJiaxun Yang #define ALLOC_PAGE_SIZE (4096)
201cf4323eSThomas Huth
pc_alloc_init(QGuestAllocator * s,QTestState * qts,QAllocOpts flags)211cf4323eSThomas Huth void pc_alloc_init(QGuestAllocator *s, QTestState *qts, QAllocOpts flags)
221cf4323eSThomas Huth {
231cf4323eSThomas Huth uint64_t ram_size;
241cf4323eSThomas Huth QFWCFG *fw_cfg = pc_fw_cfg_init(qts);
251cf4323eSThomas Huth
261cf4323eSThomas Huth ram_size = qfw_cfg_get_u64(fw_cfg, FW_CFG_RAM_SIZE);
27*d2c4f384SJiaxun Yang alloc_init(s, flags, 1 << 20, MIN(ram_size, 0xE0000000), ALLOC_PAGE_SIZE);
281cf4323eSThomas Huth
291cf4323eSThomas Huth /* clean-up */
301cf4323eSThomas Huth pc_fw_cfg_uninit(fw_cfg);
311cf4323eSThomas Huth }
32