memobj-r0drv-solaris.c revision cca8c8c55206ccd60f1b32843a67ce737447ac60
/* $Id$ */
/** @file
* IPRT - Ring-0 Memory Objects, Solaris.
*/
/*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "the-solaris-kernel.h"
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
/**
* The Solaris version of the memory object structure.
*/
typedef struct RTR0MEMOBJSOLARIS
{
/** The core structure. */
/** Pointer to kernel memory cookie. */
/** Shadow locked pages. */
void *handle;
{
{
case RTR0MEMOBJTYPE_CONT:
break;
case RTR0MEMOBJTYPE_PAGE:
break;
case RTR0MEMOBJTYPE_LOCK:
break;
case RTR0MEMOBJTYPE_MAPPING:
break;
/* unused */
case RTR0MEMOBJTYPE_LOW:
case RTR0MEMOBJTYPE_PHYS:
case RTR0MEMOBJTYPE_RES_VIRT:
default:
return VERR_INTERNAL_ERROR;
}
return VINF_SUCCESS;
}
{
/* Create the object */
PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_PAGE, NULL, cb);
if (!pMemSolaris)
return VERR_NO_MEMORY;
if (!virtAddr)
{
return VERR_NO_PAGE_MEMORY;
}
return VINF_SUCCESS;
}
{
/* Try page alloc first */
if (RT_SUCCESS(rc))
{
while (iPage-- > 0)
{
/* Failed! Fall back to physical contiguous alloc */
RTR0MemObjFree(*ppMem, false);
break;
}
}
return rc;
}
{
/* Create the object */
PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_CONT, NULL, cb);
if (!pMemSolaris)
return VERR_NO_MEMORY;
/* Allocate physically contiguous page-aligned memory. */
{
return VERR_NO_CONT_MEMORY;
}
return VINF_SUCCESS;
}
{
/** @todo rtR0MemObjNativeAllocPhysNC / solaris */
return VERR_NOT_SUPPORTED; /* see the RTR0MemObjAllocPhysNC specs */
}
{
}
{
/* Create the object */
PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_PHYS, NULL, cb);
if (!pMemSolaris)
return VERR_NO_MEMORY;
/* There is no allocation here, it needs to be mapped somewhere first */
return VINF_SUCCESS;
}
int rtR0MemObjNativeLockUser(PPRTR0MEMOBJINTERNAL ppMem, RTR3PTR R3Ptr, size_t cb, RTR0PROCESS R0Process)
{
/* Create the locking object */
PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_LOCK, (void *)R3Ptr, cb);
if (!pMemSolaris)
return VERR_NO_MEMORY;
void *ppl;
/* Lock down user pages */
if (rc != 0)
{
return VERR_LOCK_FAILED;
}
return VINF_SUCCESS;
}
{
PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_LOCK, pv, cb);
if (!pMemSolaris)
return VERR_NO_MEMORY;
void *ppl;
if (rc != 0)
{
return VERR_LOCK_FAILED;
}
return VINF_SUCCESS;
}
int rtR0MemObjNativeReserveKernel(PPRTR0MEMOBJINTERNAL ppMem, void *pvFixed, size_t cb, size_t uAlignment)
{
return VERR_NOT_IMPLEMENTED;
}
int rtR0MemObjNativeReserveUser(PPRTR0MEMOBJINTERNAL ppMem, RTR3PTR R3PtrFixed, size_t cb, size_t uAlignment, RTR0PROCESS R0Process)
{
return VERR_NOT_IMPLEMENTED;
}
int rtR0MemObjNativeMapKernel(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, void *pvFixed, size_t uAlignment, unsigned fProt)
{
/* @todo rtR0MemObjNativeMapKernel / Solaris - Should be fairly simple alloc kernel memory and memload it. */
return VERR_NOT_IMPLEMENTED;
}
int rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, PRTR0MEMOBJINTERNAL pMemToMap, RTR3PTR R3PtrFixed, size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process)
{
AssertMsgReturn(R0Process == RTR0ProcHandleSelf(), ("%p != %p\n", R0Process, RTR0ProcHandleSelf()), VERR_NOT_SUPPORTED);
AssertMsgReturn(uAlignment == 0 || uAlignment == PAGE_SIZE, ("%d\n", uAlignment), VERR_NOT_SUPPORTED);
int rc;
/* Create the mapping object */
PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_MAPPING, pv, size);
if (!pMemSolaris)
return VERR_NO_MEMORY;
{
{
goto done;
}
}
if (rc != 0)
{
goto done;
}
else
rc = VINF_SUCCESS;
done:
return rc;
}
{
{
case RTR0MEMOBJTYPE_PAGE:
case RTR0MEMOBJTYPE_LOW:
case RTR0MEMOBJTYPE_MAPPING:
case RTR0MEMOBJTYPE_LOCK:
{
return vbi_va_to_pa(pb);
}
case RTR0MEMOBJTYPE_CONT:
case RTR0MEMOBJTYPE_PHYS:
case RTR0MEMOBJTYPE_PHYS_NC:
AssertFailed(/* not implemented */);
case RTR0MEMOBJTYPE_RES_VIRT:
default:
return NIL_RTHCPHYS;
}
}