c107091c0fb9efb797884658dd19dd002358b0e2vboxsync * VBox Host Guest Shared Memory Interface (HGSMI).
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync * Memory allocator.
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync * Copyright (C) 2014 Oracle Corporation
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync * available from http://www.virtualbox.org. This file is free software;
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync * you can redistribute it and/or modify it under the terms of the GNU
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync * General Public License (GPL) as published by the Free Software
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync * The contents of this file may alternatively be used under the terms
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync * of the Common Development and Distribution License Version 1.0
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync * VirtualBox OSE distribution, in which case the provisions of the
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync * CDDL are applicable instead of those of the GPL.
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync * You may elect to license modified versions of this file under the
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync * terms and conditions of either the GPL or the CDDL or both.
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync/* Descriptor. */
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync#define HGSMI_MA_DESC_OFFSET_MASK UINT32_C(0xFFFFFFE0)
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync#define HGSMI_MA_DESC_FREE_MASK UINT32_C(0x00000010)
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync#define HGSMI_MA_DESC_ORDER_MASK UINT32_C(0x0000000F)
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync#define HGSMI_MA_DESC_OFFSET(d) ((d) & HGSMI_MA_DESC_OFFSET_MASK)
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync#define HGSMI_MA_DESC_IS_FREE(d) (((d) & HGSMI_MA_DESC_FREE_MASK) != 0)
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync#define HGSMI_MA_DESC_ORDER(d) ((d) & HGSMI_MA_DESC_ORDER_MASK)
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync#define HGSMI_MA_BLOCK_SIZE_MIN (UINT32_C(1) << (HGSMI_MA_DESC_ORDER_BASE + 0))
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync#define HGSMI_MA_BLOCK_SIZE_MAX (UINT32_C(1) << (HGSMI_MA_DESC_ORDER_BASE + HGSMI_MA_DESC_ORDER_MASK))
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync/* HGSMI_MA_DESC_ORDER_BASE must correspond to HGSMI_MA_DESC_OFFSET_MASK. */
c107091c0fb9efb797884658dd19dd002358b0e2vboxsyncAssertCompile((~HGSMI_MA_DESC_OFFSET_MASK + 1) == HGSMI_MA_BLOCK_SIZE_MIN);
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync uint32_t cBlocks; /* How many blocks in the listBlocks. */
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync RTLISTANCHOR listBlocks; /* All memory blocks, sorted. */
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync RTLISTANCHOR aListFreeBlocks[HGSMI_MA_DESC_ORDER_MASK + 1]; /* For free blocks of each order. */
c107091c0fb9efb797884658dd19dd002358b0e2vboxsyncint HGSMIMAInit(HGSMIMADATA *pMA, const HGSMIAREA *pArea,
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync HGSMIOFFSET *paDescriptors, uint32_t cDescriptors, HGSMISIZE cbMaxBlock,
c107091c0fb9efb797884658dd19dd002358b0e2vboxsyncHGSMIMABLOCK *HGSMIMASearchOffset(HGSMIMADATA *pMA, HGSMIOFFSET off);
c107091c0fb9efb797884658dd19dd002358b0e2vboxsyncDECLINLINE(HGSMISIZE) HGSMIMAOrder2Size(HGSMIOFFSET order)
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync return (UINT32_C(1) << (HGSMI_MA_DESC_ORDER_BASE + order));
c107091c0fb9efb797884658dd19dd002358b0e2vboxsyncDECLINLINE(HGSMIOFFSET) HGSMIMASize2Order(HGSMISIZE cb)
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync HGSMIOFFSET order = HGSMIPopCnt32(cb - 1) - HGSMI_MA_DESC_ORDER_BASE;
c107091c0fb9efb797884658dd19dd002358b0e2vboxsync#endif /* !___VBox_HGSMI_HGSMIMemAlloc_h */