83de81b6f22c80532a478e79afaee21a0887302avboxsync/* $Id$ */
83de81b6f22c80532a478e79afaee21a0887302avboxsync/** @file
83de81b6f22c80532a478e79afaee21a0887302avboxsync * IPRT - Memory Allocation, Extended Alloc and Free Functions for Ring-3.
83de81b6f22c80532a478e79afaee21a0887302avboxsync */
83de81b6f22c80532a478e79afaee21a0887302avboxsync
83de81b6f22c80532a478e79afaee21a0887302avboxsync/*
83de81b6f22c80532a478e79afaee21a0887302avboxsync * Copyright (C) 2006-2013 Oracle Corporation
83de81b6f22c80532a478e79afaee21a0887302avboxsync *
83de81b6f22c80532a478e79afaee21a0887302avboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
83de81b6f22c80532a478e79afaee21a0887302avboxsync * available from http://www.virtualbox.org. This file is free software;
83de81b6f22c80532a478e79afaee21a0887302avboxsync * you can redistribute it and/or modify it under the terms of the GNU
83de81b6f22c80532a478e79afaee21a0887302avboxsync * General Public License (GPL) as published by the Free Software
83de81b6f22c80532a478e79afaee21a0887302avboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
83de81b6f22c80532a478e79afaee21a0887302avboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
83de81b6f22c80532a478e79afaee21a0887302avboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
83de81b6f22c80532a478e79afaee21a0887302avboxsync *
83de81b6f22c80532a478e79afaee21a0887302avboxsync * The contents of this file may alternatively be used under the terms
83de81b6f22c80532a478e79afaee21a0887302avboxsync * of the Common Development and Distribution License Version 1.0
83de81b6f22c80532a478e79afaee21a0887302avboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
83de81b6f22c80532a478e79afaee21a0887302avboxsync * VirtualBox OSE distribution, in which case the provisions of the
83de81b6f22c80532a478e79afaee21a0887302avboxsync * CDDL are applicable instead of those of the GPL.
83de81b6f22c80532a478e79afaee21a0887302avboxsync *
83de81b6f22c80532a478e79afaee21a0887302avboxsync * You may elect to license modified versions of this file under the
83de81b6f22c80532a478e79afaee21a0887302avboxsync * terms and conditions of either the GPL or the CDDL or both.
83de81b6f22c80532a478e79afaee21a0887302avboxsync */
83de81b6f22c80532a478e79afaee21a0887302avboxsync
83de81b6f22c80532a478e79afaee21a0887302avboxsync
83de81b6f22c80532a478e79afaee21a0887302avboxsync#ifndef ___r3_allocex_h
83de81b6f22c80532a478e79afaee21a0887302avboxsync#define ___r3_allocex_h
83de81b6f22c80532a478e79afaee21a0887302avboxsync
83de81b6f22c80532a478e79afaee21a0887302avboxsync#include <iprt/types.h>
83de81b6f22c80532a478e79afaee21a0887302avboxsync
83de81b6f22c80532a478e79afaee21a0887302avboxsync/**
83de81b6f22c80532a478e79afaee21a0887302avboxsync * Heading for extended memory allocations in ring-3.
83de81b6f22c80532a478e79afaee21a0887302avboxsync */
83de81b6f22c80532a478e79afaee21a0887302avboxsynctypedef struct RTMEMHDRR3
83de81b6f22c80532a478e79afaee21a0887302avboxsync{
83de81b6f22c80532a478e79afaee21a0887302avboxsync /** Magic (RTMEMHDR_MAGIC). */
83de81b6f22c80532a478e79afaee21a0887302avboxsync uint32_t u32Magic;
83de81b6f22c80532a478e79afaee21a0887302avboxsync /** Block flags (RTMEMALLOCEX_FLAGS_*). */
83de81b6f22c80532a478e79afaee21a0887302avboxsync uint32_t fFlags;
83de81b6f22c80532a478e79afaee21a0887302avboxsync /** The actual size of the block, header not included. */
83de81b6f22c80532a478e79afaee21a0887302avboxsync uint32_t cb;
83de81b6f22c80532a478e79afaee21a0887302avboxsync /** The requested allocation size. */
83de81b6f22c80532a478e79afaee21a0887302avboxsync uint32_t cbReq;
83de81b6f22c80532a478e79afaee21a0887302avboxsync} RTMEMHDRR3;
83de81b6f22c80532a478e79afaee21a0887302avboxsync/** Pointer to a ring-3 extended memory header. */
83de81b6f22c80532a478e79afaee21a0887302avboxsynctypedef RTMEMHDRR3 *PRTMEMHDRR3;
83de81b6f22c80532a478e79afaee21a0887302avboxsync
83de81b6f22c80532a478e79afaee21a0887302avboxsync
83de81b6f22c80532a478e79afaee21a0887302avboxsync/**
83de81b6f22c80532a478e79afaee21a0887302avboxsync * Allocate memory in below 64KB.
83de81b6f22c80532a478e79afaee21a0887302avboxsync *
83de81b6f22c80532a478e79afaee21a0887302avboxsync * @returns IPRT status code.
83de81b6f22c80532a478e79afaee21a0887302avboxsync * @param cbAlloc Number of bytes to allocate (including the
83de81b6f22c80532a478e79afaee21a0887302avboxsync * header if the caller needs one).
83de81b6f22c80532a478e79afaee21a0887302avboxsync * @param fFlags Allocation flags.
83de81b6f22c80532a478e79afaee21a0887302avboxsync * @param ppv Where to return the pointer to the memory.
83de81b6f22c80532a478e79afaee21a0887302avboxsync */
83de81b6f22c80532a478e79afaee21a0887302avboxsyncDECLHIDDEN(int) rtMemAllocEx16BitReach(size_t cbAlloc, uint32_t fFlags, void **ppv);
83de81b6f22c80532a478e79afaee21a0887302avboxsync
83de81b6f22c80532a478e79afaee21a0887302avboxsync/**
83de81b6f22c80532a478e79afaee21a0887302avboxsync * Allocate memory in below 4GB.
83de81b6f22c80532a478e79afaee21a0887302avboxsync *
83de81b6f22c80532a478e79afaee21a0887302avboxsync * @returns IPRT status code.
83de81b6f22c80532a478e79afaee21a0887302avboxsync * @param cbAlloc Number of bytes to allocate (including the
83de81b6f22c80532a478e79afaee21a0887302avboxsync * header if the caller needs one).
83de81b6f22c80532a478e79afaee21a0887302avboxsync * @param fFlags Allocation flags.
83de81b6f22c80532a478e79afaee21a0887302avboxsync * @param ppv Where to return the pointer to the memory.
83de81b6f22c80532a478e79afaee21a0887302avboxsync */
83de81b6f22c80532a478e79afaee21a0887302avboxsyncDECLHIDDEN(int) rtMemAllocEx32BitReach(size_t cbAlloc, uint32_t fFlags, void **ppv);
83de81b6f22c80532a478e79afaee21a0887302avboxsync
83de81b6f22c80532a478e79afaee21a0887302avboxsync
83de81b6f22c80532a478e79afaee21a0887302avboxsync/**
83de81b6f22c80532a478e79afaee21a0887302avboxsync * Frees memory allocated by rtMemAllocEx16BitReach and rtMemAllocEx32BitReach.
83de81b6f22c80532a478e79afaee21a0887302avboxsync *
83de81b6f22c80532a478e79afaee21a0887302avboxsync * @param pv Start of allocation.
83de81b6f22c80532a478e79afaee21a0887302avboxsync * @param cb Allocation size.
83de81b6f22c80532a478e79afaee21a0887302avboxsync * @param fFlags Allocation flags.
83de81b6f22c80532a478e79afaee21a0887302avboxsync */
83de81b6f22c80532a478e79afaee21a0887302avboxsyncDECLHIDDEN(void) rtMemFreeExYyBitReach(void *pv, size_t cb, uint32_t fFlags);
83de81b6f22c80532a478e79afaee21a0887302avboxsync
83de81b6f22c80532a478e79afaee21a0887302avboxsync#endif
83de81b6f22c80532a478e79afaee21a0887302avboxsync