5eda82e218d35ae0691febd531e1bfc0324cc4a6vboxsync/* $Id$ */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/** @file
5b281ba489ca18f0380d7efc7a5108b606cce449vboxsync * IPRT - Ring-0 Memory Objects.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/*
5eda82e218d35ae0691febd531e1bfc0324cc4a6vboxsync * Copyright (C) 2006-2011 Oracle Corporation
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync *
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * available from http://www.virtualbox.org. This file is free software;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * you can redistribute it and/or modify it under the terms of the GNU
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * General Public License (GPL) as published by the Free Software
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync *
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * The contents of this file may alternatively be used under the terms
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * of the Common Development and Distribution License Version 1.0
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * VirtualBox OSE distribution, in which case the provisions of the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * CDDL are applicable instead of those of the GPL.
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync *
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * You may elect to license modified versions of this file under the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * terms and conditions of either the GPL or the CDDL or both.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
cf57145d4697dceca3f0542b370c20f7a2c5c6e8vboxsync#ifndef ___internal_memobj_h
cf57145d4697dceca3f0542b370c20f7a2c5c6e8vboxsync#define ___internal_memobj_h
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync#include <iprt/memobj.h>
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync#include <iprt/assert.h>
881b5ff6bc55e1fb0f4ef42f9782ccec79c0a138vboxsync#include "internal/magics.h"
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
590bfe12ce22cd3716448fbb9f4dc51664bfe5e2vboxsyncRT_C_DECLS_BEGIN
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/** @defgroup grp_rt_memobj_int Internals.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @ingroup grp_rt_memobj
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @internal
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @{
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/**
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * Ring-0 memory object type.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsynctypedef enum RTR0MEMOBJTYPE
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync{
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** The traditional invalid value. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync RTR0MEMOBJTYPE_INVALID = 0,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** @name Primary types (parents)
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @{ */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** RTR0MemObjAllocPage.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * This memory is page aligned and fixed. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync RTR0MEMOBJTYPE_PAGE,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** RTR0MemObjAllocLow.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * This memory is page aligned, fixed and is backed by physical memory below 4GB. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync RTR0MEMOBJTYPE_LOW,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** RTR0MemObjAllocCont.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * This memory is page aligned, fixed and is backed by contiguous physical memory below 4GB. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync RTR0MEMOBJTYPE_CONT,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** RTR0MemObjLockKernel, RTR0MemObjLockUser.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * This memory is page aligned and fixed. It was locked/pinned/wired down by the API call. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync RTR0MEMOBJTYPE_LOCK,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** RTR0MemObjAllocPhys, RTR0MemObjEnterPhys.
c5d2523548cc57504b829f53f1362b848a84542cvboxsync * This memory is physical memory, page aligned, contiguous and doesn't need to have a mapping. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync RTR0MEMOBJTYPE_PHYS,
c5d2523548cc57504b829f53f1362b848a84542cvboxsync /** RTR0MemObjAllocPhysNC.
c5d2523548cc57504b829f53f1362b848a84542cvboxsync * This memory is physical memory, page aligned and doesn't need to have a mapping. */
c5d2523548cc57504b829f53f1362b848a84542cvboxsync RTR0MEMOBJTYPE_PHYS_NC,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** RTR0MemObjReserveKernel, RTR0MemObjReserveUser.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * This memory is page aligned and has no backing. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync RTR0MEMOBJTYPE_RES_VIRT,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** @} */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** @name Secondary types (children)
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @{
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** RTR0MemObjMapUser, RTR0MemObjMapKernel.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * This is a user or kernel context mapping of another ring-0 memory object. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync RTR0MEMOBJTYPE_MAPPING,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** @} */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** The end of the valid types. Used for sanity checking. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync RTR0MEMOBJTYPE_END
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync} RTR0MEMOBJTYPE;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync/** @name RTR0MEMOBJINTERNAL::fFlags
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync * @{ */
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync/** Page level protection was changed. */
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync#define RTR0MEMOBJ_FLAGS_PROT_CHANGED RT_BIT_32(0)
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync/** @} */
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsynctypedef struct RTR0MEMOBJINTERNAL *PRTR0MEMOBJINTERNAL;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsynctypedef struct RTR0MEMOBJINTERNAL **PPRTR0MEMOBJINTERNAL;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/**
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * Ring-0 memory object.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync *
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * When using the PRTR0MEMOBJINTERNAL and PPRTR0MEMOBJINTERNAL types
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * we get pMem and ppMem variable names.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync *
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * When using the RTR0MEMOBJ and PRTR0MEMOBJ types we get MemObj and
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * pMemObj variable names. We never dereference variables of the RTR0MEMOBJ
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * type, we always convert it to a PRTR0MEMOBJECTINTERNAL variable first.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsynctypedef struct RTR0MEMOBJINTERNAL
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync{
8111a14f0afa014e5ec1cf1f010411772e10ebb4vboxsync /** Magic number (RTR0MEMOBJ_MAGIC). */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync uint32_t u32Magic;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** The size of this structure. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync uint32_t cbSelf;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** The type of allocation. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync RTR0MEMOBJTYPE enmType;
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync /** Flags, RTR0MEMOBJ_FLAGS_*. */
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync uint32_t fFlags;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** The size of the memory allocated, pinned down, or mapped. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync size_t cb;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** The memory address.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * What this really is varies with the type.
e5bfc5c34142a7550be3564a8e01a037b1db5b31vboxsync * For PAGE, CONT, LOW, RES_VIRT/R0, LOCK/R0 and MAP/R0 it's the ring-0 mapping.
e5bfc5c34142a7550be3564a8e01a037b1db5b31vboxsync * For LOCK/R3, RES_VIRT/R3 and MAP/R3 it is the ring-3 mapping.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * For PHYS this might actually be NULL if there isn't any mapping.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync void *pv;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** Object relations. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync union
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync {
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** This is for tracking child memory handles mapping the
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * memory described by the primary handle. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync struct
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync {
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** Number of mappings. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync uint32_t cMappingsAllocated;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** Number of mappings in the array. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync uint32_t cMappings;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** Pointers to child handles mapping this memory. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync PPRTR0MEMOBJINTERNAL papMappings;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync } Parent;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** Pointer to the primary handle. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync struct
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync {
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** Pointer to the parent. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync PRTR0MEMOBJINTERNAL pParent;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync } Child;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync } uRel;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** Type specific data for the memory types that requires that. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync union
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync {
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** RTR0MEMTYPE_PAGE. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync struct
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync {
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync unsigned iDummy;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync } Page;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** RTR0MEMTYPE_LOW. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync struct
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync {
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync unsigned iDummy;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync } Low;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** RTR0MEMTYPE_CONT. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync struct
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync {
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** The physical address of the first page. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync RTHCPHYS Phys;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync } Cont;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** RTR0MEMTYPE_LOCK_USER. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync struct
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync {
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** The process that owns the locked memory.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * This is NIL_RTR0PROCESS if it's kernel memory. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync RTR0PROCESS R0Process;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync } Lock;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** RTR0MEMTYPE_PHYS. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync struct
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync {
c5d2523548cc57504b829f53f1362b848a84542cvboxsync /** The base address of the physical memory. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync RTHCPHYS PhysBase;
c5d2523548cc57504b829f53f1362b848a84542cvboxsync /** If set this object was created by RTR0MemPhysAlloc, otherwise it was
c5d2523548cc57504b829f53f1362b848a84542cvboxsync * created by RTR0MemPhysEnter. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync bool fAllocated;
8929a16e87a515b7071399479548158b8c5fbdd2vboxsync /** See RTMEM_CACHE_POLICY_XXX constants */
e4527e0a08e2d635a679ae2947d42195f30a2ce2vboxsync uint32_t uCachePolicy;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync } Phys;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
c5d2523548cc57504b829f53f1362b848a84542cvboxsync /** RTR0MEMTYPE_PHYS_NC. */
c5d2523548cc57504b829f53f1362b848a84542cvboxsync struct
c5d2523548cc57504b829f53f1362b848a84542cvboxsync {
c5d2523548cc57504b829f53f1362b848a84542cvboxsync unsigned iDummy;
c5d2523548cc57504b829f53f1362b848a84542cvboxsync } PhysNC;
c5d2523548cc57504b829f53f1362b848a84542cvboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** RTR0MEMOBJTYPE_RES_VIRT */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync struct
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync {
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** The process that owns the reserved memory.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * This is NIL_RTR0PROCESS if it's kernel memory. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync RTR0PROCESS R0Process;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync } ResVirt;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** RTR0MEMOBJTYPE_MAPPING */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync struct
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync {
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /** The process that owns the reserved memory.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * This is NIL_RTR0PROCESS if it's kernel memory. */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync RTR0PROCESS R0Process;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync } Mapping;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync } u;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync} RTR0MEMOBJINTERNAL;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/**
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * Checks if this is mapping or not.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync *
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @returns true if it's a mapping, otherwise false.
9d80662bfa36cc718a22f982d48148415ca95fb8vboxsync * @param pMem The ring-0 memory object handle.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @see RTR0MemObjIsMapping
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncDECLINLINE(bool) rtR0MemObjIsMapping(PRTR0MEMOBJINTERNAL pMem)
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync{
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync switch (pMem->enmType)
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync {
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync case RTR0MEMOBJTYPE_MAPPING:
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync return true;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync default:
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync return false;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync }
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync}
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync/**
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync * Checks page level protection can be changed on this object.
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync *
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync * @returns true / false.
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync * @param pMem The ring-0 memory object handle.
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync */
31cda52093d58f5c604589fa74949c5fddcbde70vboxsyncDECLINLINE(bool) rtR0MemObjIsProtectable(PRTR0MEMOBJINTERNAL pMem)
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync{
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync switch (pMem->enmType)
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync {
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync case RTR0MEMOBJTYPE_MAPPING:
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync case RTR0MEMOBJTYPE_PAGE:
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync case RTR0MEMOBJTYPE_LOW:
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync case RTR0MEMOBJTYPE_CONT:
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync return true;
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync default:
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync return false;
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync }
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync}
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync/**
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync * Checks if RTR0MEMOBJ::pv is a ring-3 pointer or not.
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync *
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync * @returns true if it's a object with a ring-3 address, otherwise false.
9d80662bfa36cc718a22f982d48148415ca95fb8vboxsync * @param pMem The ring-0 memory object handle.
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync */
fa7c9928985ad8dc74ae6931809083c2af135250vboxsyncDECLINLINE(bool) rtR0MemObjIsRing3(PRTR0MEMOBJINTERNAL pMem)
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync{
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync switch (pMem->enmType)
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync {
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync case RTR0MEMOBJTYPE_RES_VIRT:
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync return pMem->u.ResVirt.R0Process != NIL_RTR0PROCESS;
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync case RTR0MEMOBJTYPE_LOCK:
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync return pMem->u.Lock.R0Process != NIL_RTR0PROCESS;
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync case RTR0MEMOBJTYPE_MAPPING:
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync return pMem->u.Mapping.R0Process != NIL_RTR0PROCESS;
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync default:
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync return false;
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync }
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync}
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/**
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * Frees the memory object (but not the handle).
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * Any OS specific handle resources will be freed by this call.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync *
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @returns IPRT status code. On failure it is assumed that the object remains valid.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param pMem The ring-0 memory object handle to the memory which should be freed.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
5eda82e218d35ae0691febd531e1bfc0324cc4a6vboxsyncDECLHIDDEN(int) rtR0MemObjNativeFree(PRTR0MEMOBJINTERNAL pMem);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/**
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * Allocates page aligned virtual kernel memory.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync *
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * The memory is taken from a non paged (= fixed physical memory backing) pool.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync *
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @returns IPRT status code.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param ppMem Where to store the ring-0 memory object handle.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param cb Number of bytes to allocate, page aligned.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param fExecutable Flag indicating whether it should be permitted to executed code in the memory object.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
5eda82e218d35ae0691febd531e1bfc0324cc4a6vboxsyncDECLHIDDEN(int) rtR0MemObjNativeAllocPage(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/**
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * Allocates page aligned virtual kernel memory with physical backing below 4GB.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync *
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * The physical memory backing the allocation is fixed.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync *
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @returns IPRT status code.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param ppMem Where to store the ring-0 memory object handle.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param cb Number of bytes to allocate, page aligned.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param fExecutable Flag indicating whether it should be permitted to executed code in the memory object.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
5eda82e218d35ae0691febd531e1bfc0324cc4a6vboxsyncDECLHIDDEN(int) rtR0MemObjNativeAllocLow(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/**
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * Allocates page aligned virtual kernel memory with contiguous physical backing below 4GB.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync *
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * The physical memory backing the allocation is fixed.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync *
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @returns IPRT status code.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param ppMem Where to store the ring-0 memory object handle.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param cb Number of bytes to allocate, page aligned.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param fExecutable Flag indicating whether it should be permitted to executed code in the memory object.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
5eda82e218d35ae0691febd531e1bfc0324cc4a6vboxsyncDECLHIDDEN(int) rtR0MemObjNativeAllocCont(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/**
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * Locks a range of user virtual memory.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync *
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @returns IPRT status code.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param ppMem Where to store the ring-0 memory object handle.
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync * @param R3Ptr User virtual address, page aligned.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param cb Number of bytes to lock, page aligned.
db3d025f28c59aececbbda4174fa513496c89b2bvboxsync * @param fAccess The desired access, a combination of RTMEM_PROT_READ
db3d025f28c59aececbbda4174fa513496c89b2bvboxsync * and RTMEM_PROT_WRITE.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param R0Process The process to lock pages in.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
5eda82e218d35ae0691febd531e1bfc0324cc4a6vboxsyncDECLHIDDEN(int) rtR0MemObjNativeLockUser(PPRTR0MEMOBJINTERNAL ppMem, RTR3PTR R3Ptr, size_t cb, uint32_t fAccess, RTR0PROCESS R0Process);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/**
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * Locks a range of kernel virtual memory.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync *
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @returns IPRT status code.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param ppMem Where to store the ring-0 memory object handle.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param pv Kernel virtual address, page aligned.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param cb Number of bytes to lock, page aligned.
db3d025f28c59aececbbda4174fa513496c89b2bvboxsync * @param fAccess The desired access, a combination of RTMEM_PROT_READ
db3d025f28c59aececbbda4174fa513496c89b2bvboxsync * and RTMEM_PROT_WRITE.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
5eda82e218d35ae0691febd531e1bfc0324cc4a6vboxsyncDECLHIDDEN(int) rtR0MemObjNativeLockKernel(PPRTR0MEMOBJINTERNAL ppMem, void *pv, size_t cb, uint32_t fAccess);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/**
88149ac303b4216140c49ef1c0aadad1bbcd2703vboxsync * Allocates contiguous page aligned physical memory without (necessarily) any
88149ac303b4216140c49ef1c0aadad1bbcd2703vboxsync * kernel mapping.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync *
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @returns IPRT status code.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param ppMem Where to store the ring-0 memory object handle.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param cb Number of bytes to allocate, page aligned.
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync * @param PhysHighest The highest permitable address (inclusive).
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * NIL_RTHCPHYS if any address is acceptable.
7783f3d24a8491cfb32a3d0cc193dab7c38150c2vboxsync * @param uAlignment The alignment of the reserved memory.
88149ac303b4216140c49ef1c0aadad1bbcd2703vboxsync * Supported values are PAGE_SIZE, _2M, _4M and _1G.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
5eda82e218d35ae0691febd531e1bfc0324cc4a6vboxsyncDECLHIDDEN(int) rtR0MemObjNativeAllocPhys(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest, size_t uAlignment);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
c5d2523548cc57504b829f53f1362b848a84542cvboxsync/**
c5d2523548cc57504b829f53f1362b848a84542cvboxsync * Allocates non-contiguous page aligned physical memory without (necessarily) any kernel mapping.
c5d2523548cc57504b829f53f1362b848a84542cvboxsync *
c5d2523548cc57504b829f53f1362b848a84542cvboxsync * @returns IPRT status code.
38d78a770c90320c1f6da7ae2f3fa58a28b37189vboxsync * @retval VERR_NOT_SUPPORTED if it's not possible to allocated unmapped
38d78a770c90320c1f6da7ae2f3fa58a28b37189vboxsync * physical memory on this platform.
c5d2523548cc57504b829f53f1362b848a84542cvboxsync * @param ppMem Where to store the ring-0 memory object handle.
c5d2523548cc57504b829f53f1362b848a84542cvboxsync * @param cb Number of bytes to allocate, page aligned.
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync * @param PhysHighest The highest permitable address (inclusive).
c5d2523548cc57504b829f53f1362b848a84542cvboxsync * NIL_RTHCPHYS if any address is acceptable.
c5d2523548cc57504b829f53f1362b848a84542cvboxsync */
5eda82e218d35ae0691febd531e1bfc0324cc4a6vboxsyncDECLHIDDEN(int) rtR0MemObjNativeAllocPhysNC(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest);
c5d2523548cc57504b829f53f1362b848a84542cvboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/**
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * Creates a page aligned, contiguous, physical memory object.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync *
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @returns IPRT status code.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param ppMem Where to store the ring-0 memory object handle.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param Phys The physical address to start at, page aligned.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param cb The size of the object in bytes, page aligned.
e4527e0a08e2d635a679ae2947d42195f30a2ce2vboxsync * @param uCachePolicy One of the RTMEM_CACHE_XXX modes.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
5eda82e218d35ae0691febd531e1bfc0324cc4a6vboxsyncDECLHIDDEN(int) rtR0MemObjNativeEnterPhys(PPRTR0MEMOBJINTERNAL ppMem, RTHCPHYS Phys, size_t cb, uint32_t uCachePolicy);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/**
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * Reserves kernel virtual address space.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync *
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @returns IPRT status code.
38d78a770c90320c1f6da7ae2f3fa58a28b37189vboxsync * Return VERR_NOT_SUPPORTED to indicate that the user should employ fallback strategies.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param ppMem Where to store the ring-0 memory object handle.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param pvFixed Requested address. (void *)-1 means any address. This matches uAlignment if specified.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param cb The number of bytes to reserve, page aligned.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param uAlignment The alignment of the reserved memory; PAGE_SIZE, _2M or _4M.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
5eda82e218d35ae0691febd531e1bfc0324cc4a6vboxsyncDECLHIDDEN(int) rtR0MemObjNativeReserveKernel(PPRTR0MEMOBJINTERNAL ppMem, void *pvFixed, size_t cb, size_t uAlignment);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/**
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * Reserves user virtual address space in the current process.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync *
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @returns IPRT status code.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param ppMem Where to store the ring-0 memory object handle.
c5d2523548cc57504b829f53f1362b848a84542cvboxsync * @param R3PtrFixed Requested address. (RTR3PTR)-1 means any address. This matches uAlignment if specified.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param cb The number of bytes to reserve, page aligned.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param uAlignment The alignment of the reserved memory; PAGE_SIZE, _2M or _4M.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param R0Process The process to reserve the memory in.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
5eda82e218d35ae0691febd531e1bfc0324cc4a6vboxsyncDECLHIDDEN(int) rtR0MemObjNativeReserveUser(PPRTR0MEMOBJINTERNAL ppMem, RTR3PTR R3PtrFixed, size_t cb, size_t uAlignment, RTR0PROCESS R0Process);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/**
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * Maps a memory object into user virtual address space in the current process.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync *
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @returns IPRT status code.
fbb3513a43135c633f7f51544c4bdfce748929bfvboxsync * @retval VERR_NOT_SUPPORTED see RTR0MemObjMapKernelEx.
fbb3513a43135c633f7f51544c4bdfce748929bfvboxsync *
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param ppMem Where to store the ring-0 memory object handle of the mapping object.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param pMemToMap The object to be map.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param pvFixed Requested address. (void *)-1 means any address. This matches uAlignment if specified.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param uAlignment The alignment of the reserved memory; PAGE_SIZE, _2M or _4M.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param fProt Combination of RTMEM_PROT_* flags (except RTMEM_PROT_NONE).
fbb3513a43135c633f7f51544c4bdfce748929bfvboxsync * @param offSub Where in the object to start mapping. If non-zero
fbb3513a43135c633f7f51544c4bdfce748929bfvboxsync * the value must be page aligned and cbSub must be
fbb3513a43135c633f7f51544c4bdfce748929bfvboxsync * non-zero as well.
fbb3513a43135c633f7f51544c4bdfce748929bfvboxsync * @param cbSub The size of the part of the object to be mapped. If
fbb3513a43135c633f7f51544c4bdfce748929bfvboxsync * zero the entire object is mapped. The value must be
fbb3513a43135c633f7f51544c4bdfce748929bfvboxsync * page aligned.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
5eda82e218d35ae0691febd531e1bfc0324cc4a6vboxsyncDECLHIDDEN(int) rtR0MemObjNativeMapKernel(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, void *pvFixed, size_t uAlignment,
5eda82e218d35ae0691febd531e1bfc0324cc4a6vboxsync unsigned fProt, size_t offSub, size_t cbSub);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/**
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * Maps a memory object into user virtual address space in the current process.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync *
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @returns IPRT status code.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param ppMem Where to store the ring-0 memory object handle of the mapping object.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param pMemToMap The object to be map.
c5d2523548cc57504b829f53f1362b848a84542cvboxsync * @param R3PtrFixed Requested address. (RTR3PTR)-1 means any address. This matches uAlignment if specified.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param uAlignment The alignment of the reserved memory; PAGE_SIZE, _2M or _4M.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param fProt Combination of RTMEM_PROT_* flags (except RTMEM_PROT_NONE).
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param R0Process The process to map the memory into.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
5eda82e218d35ae0691febd531e1bfc0324cc4a6vboxsyncDECLHIDDEN(int) rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, PRTR0MEMOBJINTERNAL pMemToMap, RTR3PTR R3PtrFixed, size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync/**
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync * Change the page level protection of one or more pages in a memory object.
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync *
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync * @returns IPRT status code.
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync * @retval VERR_NOT_SUPPORTED see RTR0MemObjProtect.
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync *
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync * @param pMem The memory object.
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync * @param offSub Offset into the memory object. Page aligned.
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync * @param cbSub Number of bytes to change the protection of. Page
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync * aligned.
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync * @param fProt Combination of RTMEM_PROT_* flags.
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync */
5eda82e218d35ae0691febd531e1bfc0324cc4a6vboxsyncDECLHIDDEN(int) rtR0MemObjNativeProtect(PRTR0MEMOBJINTERNAL pMem, size_t offSub, size_t cbSub, uint32_t fProt);
31cda52093d58f5c604589fa74949c5fddcbde70vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/**
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * Get the physical address of an page in the memory object.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync *
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @returns The physical address.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @returns NIL_RTHCPHYS if the object doesn't contain fixed physical pages.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @returns NIL_RTHCPHYS if the iPage is out of range.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @returns NIL_RTHCPHYS if the object handle isn't valid.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param pMem The ring-0 memory object handle.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @param iPage The page number within the object (valid).
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
5eda82e218d35ae0691febd531e1bfc0324cc4a6vboxsyncDECLHIDDEN(RTHCPHYS) rtR0MemObjNativeGetPagePhysAddr(PRTR0MEMOBJINTERNAL pMem, size_t iPage);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
5eda82e218d35ae0691febd531e1bfc0324cc4a6vboxsyncDECLHIDDEN(PRTR0MEMOBJINTERNAL) rtR0MemObjNew(size_t cbSelf, RTR0MEMOBJTYPE enmType, void *pv, size_t cb);
5eda82e218d35ae0691febd531e1bfc0324cc4a6vboxsyncDECLHIDDEN(void) rtR0MemObjDelete(PRTR0MEMOBJINTERNAL pMem);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/** @} */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
590bfe12ce22cd3716448fbb9f4dc51664bfe5e2vboxsyncRT_C_DECLS_END
833f83ce101b6e9168f519decc0dc7a1079d35f7vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync#endif
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync