xref: /qemu/tests/qtest/libqos/malloc-pc.c (revision 0f9668e0c197ab6de95f61a906703a1d127c11f8)
18a0743cfSAnthony Liguori /*
28a0743cfSAnthony Liguori  * libqos malloc support for PC
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 
13681c28a3SPeter Maydell #include "qemu/osdep.h"
14a2ce7dbdSPaolo Bonzini #include "malloc-pc.h"
15a2ce7dbdSPaolo Bonzini #include "fw_cfg.h"
168a0743cfSAnthony Liguori 
175be5df72SMarc-André Lureau #include "standard-headers/linux/qemu_fw_cfg.h"
188a0743cfSAnthony Liguori 
19*d2c4f384SJiaxun Yang #define ALLOC_PAGE_SIZE (4096)
208a0743cfSAnthony Liguori 
pc_alloc_init(QGuestAllocator * s,QTestState * qts,QAllocOpts flags)21eb5937baSPaolo Bonzini void pc_alloc_init(QGuestAllocator *s, QTestState *qts, QAllocOpts flags)
22ec2f1605SJohn Snow {
238a0743cfSAnthony Liguori     uint64_t ram_size;
2405e520f1SEric Blake     QFWCFG *fw_cfg = pc_fw_cfg_init(qts);
25af77f2cdSJohn Snow 
26af77f2cdSJohn Snow     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);
288a0743cfSAnthony Liguori 
29f3cdcbaeSJohn Snow     /* clean-up */
3065461d12SPhilippe Mathieu-Daudé     pc_fw_cfg_uninit(fw_cfg);
31ec2f1605SJohn Snow }
32