alloc-r0drv-solaris.c revision c58f1213e628a545081c70e26c6b67a841cff880
/* $Id$ */
/** @file
* IPRT - Memory Allocation, Ring-0 Driver, Solaris.
*/
/*
* Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "the-solaris-kernel.h"
#include "r0drv/alloc-r0drv.h"
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
static ddi_dma_attr_t s_rtR0SolDmaAttr =
{
DMA_ATTR_V0, /* Version Number */
(uint64_t)0, /* Lower limit */
(uint64_t)0, /* High limit */
1, /* Scatter-gather list length (1 for contiguous) */
1, /* Device granularity */
0 /* Bus-specific flags */
};
/**
* OS specific allocation function.
*/
{
#ifdef RT_ARCH_AMD64
if (fFlags & RTMEMHDR_FLAG_EXEC)
{
}
else
#endif
{
if (fFlags & RTMEMHDR_FLAG_ZEROED)
else
}
if (RT_UNLIKELY(!pHdr))
{
return VERR_NO_MEMORY;
}
return VINF_SUCCESS;
}
/**
* OS specific free function.
*/
{
#ifdef RT_ARCH_AMD64
else
#endif
}
/**
* Allocates physical memory which satisfy the given constraints.
*
* @param uPhysHi The upper physical address limit (inclusive).
* @param puPhys Where to store the physical address of the allocated
* memory. Optional, can be NULL.
* @param cb Size of allocation.
* @param uAlignment Alignment.
* @param fContig Whether the memory must be physically contiguous or
* not.
*
* @returns Virtual address of allocated memory block or NULL if allocation
* failed.
*/
DECLHIDDEN(void *) rtR0SolMemAlloc(uint64_t uPhysHi, uint64_t *puPhys, size_t cb, uint64_t uAlignment, bool fContig)
{
if ((cb & PAGEOFFSET) != 0)
return NULL;
if (!cPages)
return NULL;
if (!fContig)
else
if (!pvMem)
{
LogRel(("rtR0SolMemAlloc failed. cb=%u Align=%u fContig=%d\n", (unsigned)cb, (unsigned)uAlignment, fContig));
return NULL;
}
if (puPhys)
return pvMem;
}
/**
* Frees memory allocated using rtR0SolMemAlloc().
*
* @param pv The memory to free.
* @param cb Size of the memory block
*/
{
}
{
/* Allocate physically contiguous (< 4GB) page-aligned memory. */
if (RT_UNLIKELY(!pvMem))
{
return NULL;
}
return pvMem;
}
{
}