memobj-r0drv-solaris.c revision e7e8a6cb1597db3e0a1a83733e1d90e7a1688647
/* $Id$ */
/** @file
* innotek Portable Runtime - Ring-0 Memory Objects, Solaris.
*/
/*
* Copyright (C) 2006-2007 innotek GmbH
*
* 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 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.
*/
/*******************************************************************************
* 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. */
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
{
{
case RTR0MEMOBJTYPE_CONT:
break;
case RTR0MEMOBJTYPE_PAGE:
#if 0
#endif
break;
case RTR0MEMOBJTYPE_LOCK:
{
else
as_pageunlock(addrSpace, pMemSolaris->ppShadowPages, pMemSolaris->Core.pv, pMemSolaris->Core.cb, S_WRITE);
break;
}
case RTR0MEMOBJTYPE_MAPPING:
{
{
/* Kernel process*/
}
else
{
/* User process */
}
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 1
/* Allocate physically contiguous page-aligned memory. */
if (rc != DDI_SUCCESS)
{
return VERR_NO_MEMORY;
}
cmn_err(CE_NOTE, "xAllocPage success physAddr=%p virt=%p\n", PAGE_SIZE * hat_getpfnum(kas.a_hat, virtAddr), virtAddr);
#endif
#if 0
/* Allocate page-aligned kernel memory */
{
return VERR_NO_MEMORY;
}
#endif
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. */
if (rc != DDI_SUCCESS)
{
return VERR_NO_MEMORY;
}
return VINF_SUCCESS;
}
{
/** @todo rtR0MemObjNativeAllocPhys / solaris */
}
{
}
{
/* Create the object */
PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_PHYS, NULL, cb);
if (!pMemSolaris)
return VERR_NO_MEMORY;
/* @todo validate Phys as a proper physical address */
/* 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 object */
PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_LOCK, (void*)R3Ptr, cb);
if (!pMemSolaris)
return VERR_NO_MEMORY;
if (R0Process != NIL_RTR0PROCESS)
if (rc != 0)
return VERR_NO_MEMORY;
return VINF_SUCCESS;
#if 0
/* Lock down the physical pages of current process' virtual address space */
if (rc != 0)
{
return VERR_NO_MEMORY; /** @todo fix mach -> vbox error conversion for Solaris. */
}
return VINF_SUCCESS;
#endif
}
{
/* Create the object */
PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_LOCK, pv, cb);
if (!pMemSolaris)
return VERR_NO_MEMORY;
if (rc != 0)
return VERR_NO_MEMORY;
pMemSolaris->Core.u.Lock.R0Process = NIL_RTR0PROCESS; /* means kernel, see rtR0MemObjNativeFree() */
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)
{
if (kernVirtAddr == NULL)
return VERR_NO_MEMORY;
hat_devload(kas.a_hat, (caddr_t)kernVirtAddr, size, hat_getpfnum(kas.a_hat, pv), PROT_READ | PROT_WRITE | PROT_EXEC,
/* Create the mapping object */
PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_MAPPING,
if (pMemSolaris == NULL)
{
return VERR_NO_MEMORY;
}
return VINF_SUCCESS;
}
int rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, PRTR0MEMOBJINTERNAL pMemToMap, RTR3PTR R3PtrFixed, size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process)
{
int rc;
if (kernVirtAddr == NULL)
return VERR_NO_MEMORY;
/* Wrong ones to use: as_map() */
/* Create the mapping object */
PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_MAPPING,
if (pMemSolaris == NULL)
{
/* @todo cleanup */
return VERR_NO_MEMORY;
}
return VINF_SUCCESS;
}
{
{
case RTR0MEMOBJTYPE_LOCK:
{
/* @todo figure this one out */
return NIL_RTHCPHYS;
}
case RTR0MEMOBJTYPE_PAGE:
case RTR0MEMOBJTYPE_LOW:
{
}
case RTR0MEMOBJTYPE_CONT:
case RTR0MEMOBJTYPE_PHYS:
case RTR0MEMOBJTYPE_RES_VIRT:
case RTR0MEMOBJTYPE_MAPPING:
default:
return NIL_RTHCPHYS;
}
}