
#ifndef _G_VIRT_MEM_ALLOCATOR_NVOC_H_
#define _G_VIRT_MEM_ALLOCATOR_NVOC_H_

// Version of generated metadata structures
#ifdef NVOC_METADATA_VERSION
#undef NVOC_METADATA_VERSION
#endif
#define NVOC_METADATA_VERSION 2

#include "nvoc/runtime.h"
#include "nvoc/rtti.h"

#ifdef __cplusplus
extern "C" {
#endif

/*
 * SPDX-FileCopyrightText: Copyright (c) 1993-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 * SPDX-License-Identifier: MIT
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */

#pragma once
#include "g_virt_mem_allocator_nvoc.h"

#ifndef VIRT_MEM_ALLOCATOR_H
#define VIRT_MEM_ALLOCATOR_H

/**************** Resource Manager Defines and Structures ******************\
*                                                                          *
*       Defines and structures used for the VirtMemAllocator Object.       *
*                                                                          *
\***************************************************************************/

#include "kernel/core/core.h"
#include "kernel/core/info_block.h"
#include "kernel/gpu/eng_state.h"
#include "kernel/gpu/gpu.h"
#include "kernel/gpu/mem_mgr/virt_mem_allocator_common.h"
#include "kernel/mem_mgr/virtual_mem.h"

#include "ctrl/ctrl0080/ctrl0080dma.h" // NV0080_CTRL_DMA_*_PARAMS
#include "mmu/gmmu_fmt.h" // GMMU_APERTURE

typedef struct DMA_PAGE_ARRAY DMA_PAGE_ARRAY;

struct OBJVASPACE;

#ifndef __nvoc_class_id_OBJVASPACE
#define __nvoc_class_id_OBJVASPACE 0x6c347fu
typedef struct OBJVASPACE OBJVASPACE;
#endif /* __nvoc_class_id_OBJVASPACE */


struct KernelChannel;

#ifndef __nvoc_class_id_KernelChannel
#define __nvoc_class_id_KernelChannel 0x5d8d70u
typedef struct KernelChannel KernelChannel;
#endif /* __nvoc_class_id_KernelChannel */


typedef struct _def_client_dma_mapping_info CLI_DMA_MAPPING_INFO;
typedef struct _def_client_dma_alloc_map_info CLI_DMA_ALLOC_MAP_INFO;

//
// DMA mapping calls can invalidate synchronously which always leaves the TLB in a
// consistent state with the PTEs.  For performance reasons we sometimes defer
// the TLB invalidation when we have multiple mappings to perform before the
// mappings will be used.  Please use deferred invalidates with care.
//
enum
{
    DMA_TLB_INVALIDATE = 0,
    DMA_DEFER_TLB_INVALIDATE = 1
};

//
// aperture capabilities
//
#define DMA_GPU_GART_CAPS_SNOOP                 0x00000001
#define DMA_GPU_GART_CAPS_NOSNOOP               0x00000002

// The parameters for dmaAllocBar1P2PMapping
typedef struct _def_dma_bar1p2p_mapping_params
{
    struct OBJVASPACE *pVas;                       // Virtual address space for request
    struct OBJGPU *pPeerGpu;                       // The target GPU which owns the PeerMemDesc
    MEMORY_DESCRIPTOR *pPeerMemDesc;        // The memdesc of the target GPU vidmem
    MEMORY_DESCRIPTOR *pMemDescOut;         // The new memdesc of the mapped BAR1 region on the target GPU
    NvU32 flags;                            // The flags used for the peer mapping
    NvU32 flagsOut;                         // The new flags for for the new pPeerMemDesc
    NvU64 offset;                           // The offset requested by the client.
    NvU64 offsetOut;                        // The Adjusted offset by the new BAR1 surface mapping
    NvU64 length;                           // The requested length by the client
    CLI_DMA_MAPPING_INFO *pDmaMappingInfo;  // The Dma mapping info structure.
} DMA_BAR1P2P_MAPPING_PRARAMS;



// Private field names are wrapped in PRIVATE_FIELD, which does nothing for
// the matching C source file, but causes diagnostics to be issued if another
// source file references the field.
#ifdef NVOC_VIRT_MEM_ALLOCATOR_H_PRIVATE_ACCESS_ALLOWED
#define PRIVATE_FIELD(x) x
#else
#define PRIVATE_FIELD(x) NVOC_PRIVATE_FIELD(x)
#endif


// Metadata with per-class RTTI and vtable with ancestor(s)
struct NVOC_METADATA__VirtMemAllocator;
struct NVOC_METADATA__OBJENGSTATE;
struct NVOC_VTABLE__VirtMemAllocator;


struct VirtMemAllocator {

    // Metadata starts with RTTI structure.
    union {
         const struct NVOC_METADATA__VirtMemAllocator *__nvoc_metadata_ptr;
         const struct NVOC_RTTI *__nvoc_rtti;
    };

    // Parent (i.e. superclass or base class) objects
    struct OBJENGSTATE __nvoc_base_OBJENGSTATE;

    // Ancestor object pointers for `staticCast` feature
    struct Object *__nvoc_pbase_Object;    // obj super^2
    struct OBJENGSTATE *__nvoc_pbase_OBJENGSTATE;    // engstate super
    struct VirtMemAllocator *__nvoc_pbase_VirtMemAllocator;    // dma

    // Vtable with 10 per-object function pointers
    NV_STATUS (*__dmaAllocMapping__)(struct OBJGPU *, struct VirtMemAllocator * /*this*/, struct OBJVASPACE *, MEMORY_DESCRIPTOR *, NvU64 *, NvU32, NvU32, CLI_DMA_ALLOC_MAP_INFO *, NvU32);  // halified (2 hals) body
    NV_STATUS (*__dmaFreeMapping__)(struct OBJGPU *, struct VirtMemAllocator * /*this*/, struct OBJVASPACE *, NvU64, MEMORY_DESCRIPTOR *, NvU32, CLI_DMA_ALLOC_MAP_INFO *);  // halified (2 hals) body
    NV_STATUS (*__dmaAllocBar1P2PMapping__)(struct OBJGPU *, struct VirtMemAllocator * /*this*/, DMA_BAR1P2P_MAPPING_PRARAMS *);  // halified (2 hals) body
    void (*__dmaFreeBar1P2PMapping__)(struct VirtMemAllocator * /*this*/, CLI_DMA_MAPPING_INFO *);  // halified (2 hals) body
    NvBool (*__dmaIsDefaultGpuUncached__)(struct VirtMemAllocator * /*this*/, MEMORY_DESCRIPTOR *, GMMU_APERTURE, NvBool);  // halified (2 hals) body
    NV_STATUS (*__dmaUpdateVASpace__)(struct OBJGPU *, struct VirtMemAllocator * /*this*/, struct OBJVASPACE *, MEMORY_DESCRIPTOR *, NvU8 *, NvU64, NvU64, NvU32, DMA_PAGE_ARRAY *, COMPR_INFO *, NvU64, NvU32, GMMU_APERTURE, NvBool, NvU32, NvU64, NvU32, NvBool, NvU64);  // halified (2 hals) body
    NV_STATUS (*__dmaXlateVAtoPAforChannel__)(struct OBJGPU *, struct VirtMemAllocator * /*this*/, struct KernelChannel *, NvU64, NvU64 *, NvU32 *);  // halified (2 hals) body
    NvU32 (*__dmaGetPTESize__)(struct OBJGPU *, struct VirtMemAllocator * /*this*/);  // halified (2 hals) body
    NV_STATUS (*__dmaMapBuffer__)(struct OBJGPU *, struct VirtMemAllocator * /*this*/, struct OBJVASPACE *, PMEMORY_DESCRIPTOR, NvU64 *, NvU32, NvU32);  // halified (2 hals) body
    void (*__dmaUnmapBuffer__)(struct OBJGPU *, struct VirtMemAllocator * /*this*/, struct OBJVASPACE *, NvU64);  // halified (2 hals) body

    // 1 PDB property
//  NvBool PDB_PROP_DMA_IS_MISSING inherited from OBJENGSTATE

    // Data members
    NvU32 gpuGartCaps;
    NvU32 increaseRsvdPages;
    NvBool bDmaMemoryMapOverride;
    NvBool bDmaRestrictVaRange;
    NvBool bDmaShaderAccessSupported;
    NvBool bDmaIsSupportedSparseVirtual;
    NvBool bDmaMmuInvalidateDisable;
    NvBool bDmaEnforce32BitPointer;
    NvBool bDmaEnableFullCompTagLine;
    NvBool bDmaMultipleVaspaceSupported;
    struct ENG_INFO_LINK_NODE *infoList;
};


// Vtable with 14 per-class function pointers
struct NVOC_VTABLE__VirtMemAllocator {
    NV_STATUS (*__dmaConstructEngine__)(struct OBJGPU *, struct VirtMemAllocator * /*this*/, ENGDESCRIPTOR);  // virtual override (engstate) base (engstate)
    NV_STATUS (*__dmaStateInitLocked__)(struct OBJGPU *, struct VirtMemAllocator * /*this*/);  // virtual override (engstate) base (engstate)
    NV_STATUS (*__dmaStatePostLoad__)(struct OBJGPU *, struct VirtMemAllocator * /*this*/, NvU32);  // virtual halified (singleton optimized) override (engstate) base (engstate) body
    void (*__dmaInitMissing__)(struct OBJGPU *, struct VirtMemAllocator * /*this*/);  // virtual inherited (engstate) base (engstate)
    NV_STATUS (*__dmaStatePreInitLocked__)(struct OBJGPU *, struct VirtMemAllocator * /*this*/);  // virtual inherited (engstate) base (engstate)
    NV_STATUS (*__dmaStatePreInitUnlocked__)(struct OBJGPU *, struct VirtMemAllocator * /*this*/);  // virtual inherited (engstate) base (engstate)
    NV_STATUS (*__dmaStateInitUnlocked__)(struct OBJGPU *, struct VirtMemAllocator * /*this*/);  // virtual inherited (engstate) base (engstate)
    NV_STATUS (*__dmaStatePreLoad__)(struct OBJGPU *, struct VirtMemAllocator * /*this*/, NvU32);  // virtual inherited (engstate) base (engstate)
    NV_STATUS (*__dmaStateLoad__)(struct OBJGPU *, struct VirtMemAllocator * /*this*/, NvU32);  // virtual inherited (engstate) base (engstate)
    NV_STATUS (*__dmaStatePreUnload__)(struct OBJGPU *, struct VirtMemAllocator * /*this*/, NvU32);  // virtual inherited (engstate) base (engstate)
    NV_STATUS (*__dmaStateUnload__)(struct OBJGPU *, struct VirtMemAllocator * /*this*/, NvU32);  // virtual inherited (engstate) base (engstate)
    NV_STATUS (*__dmaStatePostUnload__)(struct OBJGPU *, struct VirtMemAllocator * /*this*/, NvU32);  // virtual inherited (engstate) base (engstate)
    void (*__dmaStateDestroy__)(struct OBJGPU *, struct VirtMemAllocator * /*this*/);  // virtual inherited (engstate) base (engstate)
    NvBool (*__dmaIsPresent__)(struct OBJGPU *, struct VirtMemAllocator * /*this*/);  // virtual inherited (engstate) base (engstate)
};

// Metadata with per-class RTTI and vtable with ancestor(s)
struct NVOC_METADATA__VirtMemAllocator {
    const struct NVOC_RTTI rtti;
    const struct NVOC_METADATA__OBJENGSTATE metadata__OBJENGSTATE;
    const struct NVOC_VTABLE__VirtMemAllocator vtable;
};

#ifndef __nvoc_class_id_VirtMemAllocator
#define __nvoc_class_id_VirtMemAllocator 0x899e48u
typedef struct VirtMemAllocator VirtMemAllocator;
#endif /* __nvoc_class_id_VirtMemAllocator */

// Casting support
extern const struct NVOC_CLASS_DEF __nvoc_class_def_VirtMemAllocator;

#define __staticCast_VirtMemAllocator(pThis) \
    ((pThis)->__nvoc_pbase_VirtMemAllocator)

#ifdef __nvoc_virt_mem_allocator_h_disabled
#define __dynamicCast_VirtMemAllocator(pThis) ((VirtMemAllocator*) NULL)
#else //__nvoc_virt_mem_allocator_h_disabled
#define __dynamicCast_VirtMemAllocator(pThis) \
    ((VirtMemAllocator*) __nvoc_dynamicCast(staticCast((pThis), Dynamic), classInfo(VirtMemAllocator)))
#endif //__nvoc_virt_mem_allocator_h_disabled

// Property macros
#define PDB_PROP_DMA_IS_MISSING_BASE_CAST __nvoc_base_OBJENGSTATE.
#define PDB_PROP_DMA_IS_MISSING_BASE_NAME PDB_PROP_ENGSTATE_IS_MISSING


NV_STATUS __nvoc_objCreateDynamic_VirtMemAllocator(Dynamic**, Dynamic*, NvU32, va_list);

NV_STATUS __nvoc_objCreate_VirtMemAllocator(VirtMemAllocator**, Dynamic*, NvU32);
#define __objCreate_VirtMemAllocator(__nvoc_ppNewObj, __nvoc_pParent, __nvoc_createFlags) \
    __nvoc_objCreate_VirtMemAllocator((__nvoc_ppNewObj), staticCast((__nvoc_pParent), Dynamic), (__nvoc_createFlags))


// Wrapper macros for implementation functions
NV_STATUS dmaAllocMap_IMPL(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma, struct OBJVASPACE *arg3, struct VirtualMemory *arg4, struct Memory *arg5, CLI_DMA_MAPPING_INFO *arg6);
#ifdef __nvoc_virt_mem_allocator_h_disabled
static inline NV_STATUS dmaAllocMap(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma, struct OBJVASPACE *arg3, struct VirtualMemory *arg4, struct Memory *arg5, CLI_DMA_MAPPING_INFO *arg6) {
    NV_ASSERT_FAILED_PRECOMP("VirtMemAllocator was disabled!");
    return NV_ERR_NOT_SUPPORTED;
}
#else // __nvoc_virt_mem_allocator_h_disabled
#define dmaAllocMap(pGpu, pDma, arg3, arg4, arg5, arg6) dmaAllocMap_IMPL(pGpu, pDma, arg3, arg4, arg5, arg6)
#endif // __nvoc_virt_mem_allocator_h_disabled

NV_STATUS dmaFreeMap_IMPL(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma, struct OBJVASPACE *arg3, struct VirtualMemory *arg4, CLI_DMA_MAPPING_INFO *arg5, NvU32 flags);
#ifdef __nvoc_virt_mem_allocator_h_disabled
static inline NV_STATUS dmaFreeMap(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma, struct OBJVASPACE *arg3, struct VirtualMemory *arg4, CLI_DMA_MAPPING_INFO *arg5, NvU32 flags) {
    NV_ASSERT_FAILED_PRECOMP("VirtMemAllocator was disabled!");
    return NV_ERR_NOT_SUPPORTED;
}
#else // __nvoc_virt_mem_allocator_h_disabled
#define dmaFreeMap(pGpu, pDma, arg3, arg4, arg5, flags) dmaFreeMap_IMPL(pGpu, pDma, arg3, arg4, arg5, flags)
#endif // __nvoc_virt_mem_allocator_h_disabled

#ifdef __nvoc_virt_mem_allocator_h_disabled
static inline NV_STATUS dmaInit(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma) {
    NV_ASSERT_FAILED_PRECOMP("VirtMemAllocator was disabled!");
    return NV_ERR_NOT_SUPPORTED;
}
#else // __nvoc_virt_mem_allocator_h_disabled
#define dmaInit(pGpu, pDma) dmaInit_GM107(pGpu, pDma)
#endif // __nvoc_virt_mem_allocator_h_disabled

#ifdef __nvoc_virt_mem_allocator_h_disabled
static inline NV_STATUS dmaConstructHal(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma) {
    NV_ASSERT_FAILED_PRECOMP("VirtMemAllocator was disabled!");
    return NV_ERR_NOT_SUPPORTED;
}
#else // __nvoc_virt_mem_allocator_h_disabled
#define dmaConstructHal(pGpu, pDma) dmaConstructHal_VF(pGpu, pDma)
#endif // __nvoc_virt_mem_allocator_h_disabled

#define __nvoc_dmaDestruct(pDma) dmaDestruct_GM107(pDma)

#ifdef __nvoc_virt_mem_allocator_h_disabled
static inline NV_STATUS dmaInitGart(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma) {
    NV_ASSERT_FAILED_PRECOMP("VirtMemAllocator was disabled!");
    return NV_ERR_NOT_SUPPORTED;
}
#else // __nvoc_virt_mem_allocator_h_disabled
#define dmaInitGart(pGpu, pDma) dmaInitGart_GM107(pGpu, pDma)
#endif // __nvoc_virt_mem_allocator_h_disabled

#ifdef __nvoc_virt_mem_allocator_h_disabled
static inline struct OBJVASPACE * dmaGetPrivateVAS(struct VirtMemAllocator *pDma) {
    NV_ASSERT_FAILED_PRECOMP("VirtMemAllocator was disabled!");
    return NULL;
}
#else // __nvoc_virt_mem_allocator_h_disabled
#define dmaGetPrivateVAS(pDma) dmaGetPrivateVAS_9e2234(pDma)
#endif // __nvoc_virt_mem_allocator_h_disabled


// Wrapper macros for halified functions
#define dmaConstructEngine_FNPTR(pDma) pDma->__nvoc_metadata_ptr->vtable.__dmaConstructEngine__
#define dmaConstructEngine(pGpu, pDma, arg3) dmaConstructEngine_DISPATCH(pGpu, pDma, arg3)
#define dmaStateInitLocked_FNPTR(pDma) pDma->__nvoc_metadata_ptr->vtable.__dmaStateInitLocked__
#define dmaStateInitLocked(pGpu, pDma) dmaStateInitLocked_DISPATCH(pGpu, pDma)
#define dmaInit_HAL(pGpu, pDma) dmaInit(pGpu, pDma)
#define dmaConstructHal_HAL(pGpu, pDma) dmaConstructHal(pGpu, pDma)
#define dmaInitGart_HAL(pGpu, pDma) dmaInitGart(pGpu, pDma)
#define dmaAllocMapping_FNPTR(pDma) pDma->__dmaAllocMapping__
#define dmaAllocMapping(pGpu, pDma, arg3, arg4, arg5, arg6, arg7, arg8, arg9) dmaAllocMapping_DISPATCH(pGpu, pDma, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
#define dmaAllocMapping_HAL(pGpu, pDma, arg3, arg4, arg5, arg6, arg7, arg8, arg9) dmaAllocMapping_DISPATCH(pGpu, pDma, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
#define dmaFreeMapping_FNPTR(pDma) pDma->__dmaFreeMapping__
#define dmaFreeMapping(pGpu, pDma, arg3, arg4, arg5, arg6, arg7) dmaFreeMapping_DISPATCH(pGpu, pDma, arg3, arg4, arg5, arg6, arg7)
#define dmaFreeMapping_HAL(pGpu, pDma, arg3, arg4, arg5, arg6, arg7) dmaFreeMapping_DISPATCH(pGpu, pDma, arg3, arg4, arg5, arg6, arg7)
#define dmaAllocBar1P2PMapping_FNPTR(pDma) pDma->__dmaAllocBar1P2PMapping__
#define dmaAllocBar1P2PMapping(pGpu, pDma, params) dmaAllocBar1P2PMapping_DISPATCH(pGpu, pDma, params)
#define dmaAllocBar1P2PMapping_HAL(pGpu, pDma, params) dmaAllocBar1P2PMapping_DISPATCH(pGpu, pDma, params)
#define dmaFreeBar1P2PMapping_FNPTR(pDma) pDma->__dmaFreeBar1P2PMapping__
#define dmaFreeBar1P2PMapping(pDma, arg2) dmaFreeBar1P2PMapping_DISPATCH(pDma, arg2)
#define dmaFreeBar1P2PMapping_HAL(pDma, arg2) dmaFreeBar1P2PMapping_DISPATCH(pDma, arg2)
#define dmaIsDefaultGpuUncached_FNPTR(pDma) pDma->__dmaIsDefaultGpuUncached__
#define dmaIsDefaultGpuUncached(pDma, pMemDesc, aperture, bIndirectPeer) dmaIsDefaultGpuUncached_DISPATCH(pDma, pMemDesc, aperture, bIndirectPeer)
#define dmaIsDefaultGpuUncached_HAL(pDma, pMemDesc, aperture, bIndirectPeer) dmaIsDefaultGpuUncached_DISPATCH(pDma, pMemDesc, aperture, bIndirectPeer)
#define dmaUpdateVASpace_FNPTR(pDma) pDma->__dmaUpdateVASpace__
#define dmaUpdateVASpace(pGpu, pDma, pVAS, pMemDesc, tgtPteMem, vAddr, vAddrLimit, flags, pPageArray, pComprInfo, surfaceOffset, valid, aperture, isVolatile, peer, fabricAddr, deferInvalidate, bSparse, pageSize) dmaUpdateVASpace_DISPATCH(pGpu, pDma, pVAS, pMemDesc, tgtPteMem, vAddr, vAddrLimit, flags, pPageArray, pComprInfo, surfaceOffset, valid, aperture, isVolatile, peer, fabricAddr, deferInvalidate, bSparse, pageSize)
#define dmaUpdateVASpace_HAL(pGpu, pDma, pVAS, pMemDesc, tgtPteMem, vAddr, vAddrLimit, flags, pPageArray, pComprInfo, surfaceOffset, valid, aperture, isVolatile, peer, fabricAddr, deferInvalidate, bSparse, pageSize) dmaUpdateVASpace_DISPATCH(pGpu, pDma, pVAS, pMemDesc, tgtPteMem, vAddr, vAddrLimit, flags, pPageArray, pComprInfo, surfaceOffset, valid, aperture, isVolatile, peer, fabricAddr, deferInvalidate, bSparse, pageSize)
#define dmaXlateVAtoPAforChannel_FNPTR(pDma) pDma->__dmaXlateVAtoPAforChannel__
#define dmaXlateVAtoPAforChannel(pGpu, pDma, pKernelChannel, vAddr, pAddr, memType) dmaXlateVAtoPAforChannel_DISPATCH(pGpu, pDma, pKernelChannel, vAddr, pAddr, memType)
#define dmaXlateVAtoPAforChannel_HAL(pGpu, pDma, pKernelChannel, vAddr, pAddr, memType) dmaXlateVAtoPAforChannel_DISPATCH(pGpu, pDma, pKernelChannel, vAddr, pAddr, memType)
#define dmaGetPTESize_FNPTR(pDma) pDma->__dmaGetPTESize__
#define dmaGetPTESize(pGpu, pDma) dmaGetPTESize_DISPATCH(pGpu, pDma)
#define dmaGetPTESize_HAL(pGpu, pDma) dmaGetPTESize_DISPATCH(pGpu, pDma)
#define dmaMapBuffer_FNPTR(pDma) pDma->__dmaMapBuffer__
#define dmaMapBuffer(pGpu, pDma, pVAS, pMemDesc, pVaddr, allocFlags, mapFlags) dmaMapBuffer_DISPATCH(pGpu, pDma, pVAS, pMemDesc, pVaddr, allocFlags, mapFlags)
#define dmaMapBuffer_HAL(pGpu, pDma, pVAS, pMemDesc, pVaddr, allocFlags, mapFlags) dmaMapBuffer_DISPATCH(pGpu, pDma, pVAS, pMemDesc, pVaddr, allocFlags, mapFlags)
#define dmaUnmapBuffer_FNPTR(pDma) pDma->__dmaUnmapBuffer__
#define dmaUnmapBuffer(pGpu, pDma, pVAS, vaddr) dmaUnmapBuffer_DISPATCH(pGpu, pDma, pVAS, vaddr)
#define dmaUnmapBuffer_HAL(pGpu, pDma, pVAS, vaddr) dmaUnmapBuffer_DISPATCH(pGpu, pDma, pVAS, vaddr)
#define dmaStatePostLoad_FNPTR(pDma) pDma->__nvoc_metadata_ptr->vtable.__dmaStatePostLoad__
#define dmaStatePostLoad(pGpu, pDma, arg3) dmaStatePostLoad_DISPATCH(pGpu, pDma, arg3)
#define dmaStatePostLoad_HAL(pGpu, pDma, arg3) dmaStatePostLoad_DISPATCH(pGpu, pDma, arg3)
#define dmaGetPrivateVAS_HAL(pDma) dmaGetPrivateVAS(pDma)
#define dmaInitMissing_FNPTR(pEngstate) pEngstate->__nvoc_base_OBJENGSTATE.__nvoc_metadata_ptr->vtable.__engstateInitMissing__
#define dmaInitMissing(pGpu, pEngstate) dmaInitMissing_DISPATCH(pGpu, pEngstate)
#define dmaStatePreInitLocked_FNPTR(pEngstate) pEngstate->__nvoc_base_OBJENGSTATE.__nvoc_metadata_ptr->vtable.__engstateStatePreInitLocked__
#define dmaStatePreInitLocked(pGpu, pEngstate) dmaStatePreInitLocked_DISPATCH(pGpu, pEngstate)
#define dmaStatePreInitUnlocked_FNPTR(pEngstate) pEngstate->__nvoc_base_OBJENGSTATE.__nvoc_metadata_ptr->vtable.__engstateStatePreInitUnlocked__
#define dmaStatePreInitUnlocked(pGpu, pEngstate) dmaStatePreInitUnlocked_DISPATCH(pGpu, pEngstate)
#define dmaStateInitUnlocked_FNPTR(pEngstate) pEngstate->__nvoc_base_OBJENGSTATE.__nvoc_metadata_ptr->vtable.__engstateStateInitUnlocked__
#define dmaStateInitUnlocked(pGpu, pEngstate) dmaStateInitUnlocked_DISPATCH(pGpu, pEngstate)
#define dmaStatePreLoad_FNPTR(pEngstate) pEngstate->__nvoc_base_OBJENGSTATE.__nvoc_metadata_ptr->vtable.__engstateStatePreLoad__
#define dmaStatePreLoad(pGpu, pEngstate, arg3) dmaStatePreLoad_DISPATCH(pGpu, pEngstate, arg3)
#define dmaStateLoad_FNPTR(pEngstate) pEngstate->__nvoc_base_OBJENGSTATE.__nvoc_metadata_ptr->vtable.__engstateStateLoad__
#define dmaStateLoad(pGpu, pEngstate, arg3) dmaStateLoad_DISPATCH(pGpu, pEngstate, arg3)
#define dmaStatePreUnload_FNPTR(pEngstate) pEngstate->__nvoc_base_OBJENGSTATE.__nvoc_metadata_ptr->vtable.__engstateStatePreUnload__
#define dmaStatePreUnload(pGpu, pEngstate, arg3) dmaStatePreUnload_DISPATCH(pGpu, pEngstate, arg3)
#define dmaStateUnload_FNPTR(pEngstate) pEngstate->__nvoc_base_OBJENGSTATE.__nvoc_metadata_ptr->vtable.__engstateStateUnload__
#define dmaStateUnload(pGpu, pEngstate, arg3) dmaStateUnload_DISPATCH(pGpu, pEngstate, arg3)
#define dmaStatePostUnload_FNPTR(pEngstate) pEngstate->__nvoc_base_OBJENGSTATE.__nvoc_metadata_ptr->vtable.__engstateStatePostUnload__
#define dmaStatePostUnload(pGpu, pEngstate, arg3) dmaStatePostUnload_DISPATCH(pGpu, pEngstate, arg3)
#define dmaStateDestroy_FNPTR(pEngstate) pEngstate->__nvoc_base_OBJENGSTATE.__nvoc_metadata_ptr->vtable.__engstateStateDestroy__
#define dmaStateDestroy(pGpu, pEngstate) dmaStateDestroy_DISPATCH(pGpu, pEngstate)
#define dmaIsPresent_FNPTR(pEngstate) pEngstate->__nvoc_base_OBJENGSTATE.__nvoc_metadata_ptr->vtable.__engstateIsPresent__
#define dmaIsPresent(pGpu, pEngstate) dmaIsPresent_DISPATCH(pGpu, pEngstate)

// Dispatch functions
static inline NV_STATUS dmaConstructEngine_DISPATCH(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma, ENGDESCRIPTOR arg3) {
    return pDma->__nvoc_metadata_ptr->vtable.__dmaConstructEngine__(pGpu, pDma, arg3);
}

static inline NV_STATUS dmaStateInitLocked_DISPATCH(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma) {
    return pDma->__nvoc_metadata_ptr->vtable.__dmaStateInitLocked__(pGpu, pDma);
}

static inline NV_STATUS dmaAllocMapping_DISPATCH(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma, struct OBJVASPACE *arg3, MEMORY_DESCRIPTOR *arg4, NvU64 *arg5, NvU32 arg6, NvU32 arg7, CLI_DMA_ALLOC_MAP_INFO *arg8, NvU32 arg9) {
    return pDma->__dmaAllocMapping__(pGpu, pDma, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
}

static inline NV_STATUS dmaFreeMapping_DISPATCH(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma, struct OBJVASPACE *arg3, NvU64 arg4, MEMORY_DESCRIPTOR *arg5, NvU32 arg6, CLI_DMA_ALLOC_MAP_INFO *arg7) {
    return pDma->__dmaFreeMapping__(pGpu, pDma, arg3, arg4, arg5, arg6, arg7);
}

static inline NV_STATUS dmaAllocBar1P2PMapping_DISPATCH(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma, DMA_BAR1P2P_MAPPING_PRARAMS *params) {
    return pDma->__dmaAllocBar1P2PMapping__(pGpu, pDma, params);
}

static inline void dmaFreeBar1P2PMapping_DISPATCH(struct VirtMemAllocator *pDma, CLI_DMA_MAPPING_INFO *arg2) {
    pDma->__dmaFreeBar1P2PMapping__(pDma, arg2);
}

static inline NvBool dmaIsDefaultGpuUncached_DISPATCH(struct VirtMemAllocator *pDma, MEMORY_DESCRIPTOR *pMemDesc, GMMU_APERTURE aperture, NvBool bIndirectPeer) {
    return pDma->__dmaIsDefaultGpuUncached__(pDma, pMemDesc, aperture, bIndirectPeer);
}

static inline NV_STATUS dmaUpdateVASpace_DISPATCH(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma, struct OBJVASPACE *pVAS, MEMORY_DESCRIPTOR *pMemDesc, NvU8 *tgtPteMem, NvU64 vAddr, NvU64 vAddrLimit, NvU32 flags, DMA_PAGE_ARRAY *pPageArray, COMPR_INFO *pComprInfo, NvU64 surfaceOffset, NvU32 valid, GMMU_APERTURE aperture, NvBool isVolatile, NvU32 peer, NvU64 fabricAddr, NvU32 deferInvalidate, NvBool bSparse, NvU64 pageSize) {
    return pDma->__dmaUpdateVASpace__(pGpu, pDma, pVAS, pMemDesc, tgtPteMem, vAddr, vAddrLimit, flags, pPageArray, pComprInfo, surfaceOffset, valid, aperture, isVolatile, peer, fabricAddr, deferInvalidate, bSparse, pageSize);
}

static inline NV_STATUS dmaXlateVAtoPAforChannel_DISPATCH(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma, struct KernelChannel *pKernelChannel, NvU64 vAddr, NvU64 *pAddr, NvU32 *memType) {
    return pDma->__dmaXlateVAtoPAforChannel__(pGpu, pDma, pKernelChannel, vAddr, pAddr, memType);
}

static inline NvU32 dmaGetPTESize_DISPATCH(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma) {
    return pDma->__dmaGetPTESize__(pGpu, pDma);
}

static inline NV_STATUS dmaMapBuffer_DISPATCH(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma, struct OBJVASPACE *pVAS, PMEMORY_DESCRIPTOR pMemDesc, NvU64 *pVaddr, NvU32 allocFlags, NvU32 mapFlags) {
    return pDma->__dmaMapBuffer__(pGpu, pDma, pVAS, pMemDesc, pVaddr, allocFlags, mapFlags);
}

static inline void dmaUnmapBuffer_DISPATCH(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma, struct OBJVASPACE *pVAS, NvU64 vaddr) {
    pDma->__dmaUnmapBuffer__(pGpu, pDma, pVAS, vaddr);
}

static inline NV_STATUS dmaStatePostLoad_DISPATCH(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma, NvU32 arg3) {
    return pDma->__nvoc_metadata_ptr->vtable.__dmaStatePostLoad__(pGpu, pDma, arg3);
}

static inline void dmaInitMissing_DISPATCH(struct OBJGPU *pGpu, struct VirtMemAllocator *pEngstate) {
    pEngstate->__nvoc_metadata_ptr->vtable.__dmaInitMissing__(pGpu, pEngstate);
}

static inline NV_STATUS dmaStatePreInitLocked_DISPATCH(struct OBJGPU *pGpu, struct VirtMemAllocator *pEngstate) {
    return pEngstate->__nvoc_metadata_ptr->vtable.__dmaStatePreInitLocked__(pGpu, pEngstate);
}

static inline NV_STATUS dmaStatePreInitUnlocked_DISPATCH(struct OBJGPU *pGpu, struct VirtMemAllocator *pEngstate) {
    return pEngstate->__nvoc_metadata_ptr->vtable.__dmaStatePreInitUnlocked__(pGpu, pEngstate);
}

static inline NV_STATUS dmaStateInitUnlocked_DISPATCH(struct OBJGPU *pGpu, struct VirtMemAllocator *pEngstate) {
    return pEngstate->__nvoc_metadata_ptr->vtable.__dmaStateInitUnlocked__(pGpu, pEngstate);
}

static inline NV_STATUS dmaStatePreLoad_DISPATCH(struct OBJGPU *pGpu, struct VirtMemAllocator *pEngstate, NvU32 arg3) {
    return pEngstate->__nvoc_metadata_ptr->vtable.__dmaStatePreLoad__(pGpu, pEngstate, arg3);
}

static inline NV_STATUS dmaStateLoad_DISPATCH(struct OBJGPU *pGpu, struct VirtMemAllocator *pEngstate, NvU32 arg3) {
    return pEngstate->__nvoc_metadata_ptr->vtable.__dmaStateLoad__(pGpu, pEngstate, arg3);
}

static inline NV_STATUS dmaStatePreUnload_DISPATCH(struct OBJGPU *pGpu, struct VirtMemAllocator *pEngstate, NvU32 arg3) {
    return pEngstate->__nvoc_metadata_ptr->vtable.__dmaStatePreUnload__(pGpu, pEngstate, arg3);
}

static inline NV_STATUS dmaStateUnload_DISPATCH(struct OBJGPU *pGpu, struct VirtMemAllocator *pEngstate, NvU32 arg3) {
    return pEngstate->__nvoc_metadata_ptr->vtable.__dmaStateUnload__(pGpu, pEngstate, arg3);
}

static inline NV_STATUS dmaStatePostUnload_DISPATCH(struct OBJGPU *pGpu, struct VirtMemAllocator *pEngstate, NvU32 arg3) {
    return pEngstate->__nvoc_metadata_ptr->vtable.__dmaStatePostUnload__(pGpu, pEngstate, arg3);
}

static inline void dmaStateDestroy_DISPATCH(struct OBJGPU *pGpu, struct VirtMemAllocator *pEngstate) {
    pEngstate->__nvoc_metadata_ptr->vtable.__dmaStateDestroy__(pGpu, pEngstate);
}

static inline NvBool dmaIsPresent_DISPATCH(struct OBJGPU *pGpu, struct VirtMemAllocator *pEngstate) {
    return pEngstate->__nvoc_metadata_ptr->vtable.__dmaIsPresent__(pGpu, pEngstate);
}

// Virtual method declarations and/or inline definitions
NV_STATUS dmaConstructEngine_IMPL(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma, ENGDESCRIPTOR arg3);

NV_STATUS dmaStateInitLocked_IMPL(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma);

// Exported method declarations and/or inline definitions
// HAL method declarations without bodies
NV_STATUS dmaInit_GM107(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma);

NV_STATUS dmaConstructHal_VF(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma);

void dmaDestruct_GM107(struct VirtMemAllocator *pDma);

NV_STATUS dmaInitGart_GM107(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma);

NV_STATUS dmaAllocMapping_GM107(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma, struct OBJVASPACE *arg3, MEMORY_DESCRIPTOR *arg4, NvU64 *arg5, NvU32 arg6, NvU32 arg7, CLI_DMA_ALLOC_MAP_INFO *arg8, NvU32 arg9);

NV_STATUS dmaFreeMapping_GM107(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma, struct OBJVASPACE *arg3, NvU64 arg4, MEMORY_DESCRIPTOR *arg5, NvU32 arg6, CLI_DMA_ALLOC_MAP_INFO *arg7);

NV_STATUS dmaAllocBar1P2PMapping_GH100(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma, DMA_BAR1P2P_MAPPING_PRARAMS *params);

void dmaFreeBar1P2PMapping_GH100(struct VirtMemAllocator *pDma, CLI_DMA_MAPPING_INFO *arg2);

NvBool dmaIsDefaultGpuUncached_GM107(struct VirtMemAllocator *pDma, MEMORY_DESCRIPTOR *pMemDesc, GMMU_APERTURE aperture, NvBool bIndirectPeer);

NV_STATUS dmaUpdateVASpace_GF100(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma, struct OBJVASPACE *pVAS, MEMORY_DESCRIPTOR *pMemDesc, NvU8 *tgtPteMem, NvU64 vAddr, NvU64 vAddrLimit, NvU32 flags, DMA_PAGE_ARRAY *pPageArray, COMPR_INFO *pComprInfo, NvU64 surfaceOffset, NvU32 valid, GMMU_APERTURE aperture, NvBool isVolatile, NvU32 peer, NvU64 fabricAddr, NvU32 deferInvalidate, NvBool bSparse, NvU64 pageSize);

NV_STATUS dmaXlateVAtoPAforChannel_GM107(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma, struct KernelChannel *pKernelChannel, NvU64 vAddr, NvU64 *pAddr, NvU32 *memType);

NvU32 dmaGetPTESize_GM107(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma);

NV_STATUS dmaMapBuffer_GM107(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma, struct OBJVASPACE *pVAS, PMEMORY_DESCRIPTOR pMemDesc, NvU64 *pVaddr, NvU32 allocFlags, NvU32 mapFlags);

void dmaUnmapBuffer_GM107(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma, struct OBJVASPACE *pVAS, NvU64 vaddr);

NV_STATUS dmaStatePostLoad_GM107(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma, NvU32 arg3);

// Inline HAL method definitions
static inline NV_STATUS dmaConstructHal_ac1694(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma){
    return NV_OK;
}

static inline NV_STATUS dmaAllocMapping_395e98(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma, struct OBJVASPACE *arg3, MEMORY_DESCRIPTOR *arg4, NvU64 *arg5, NvU32 arg6, NvU32 arg7, CLI_DMA_ALLOC_MAP_INFO *arg8, NvU32 arg9){
    return NV_ERR_NOT_SUPPORTED;
}

static inline NV_STATUS dmaFreeMapping_395e98(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma, struct OBJVASPACE *arg3, NvU64 arg4, MEMORY_DESCRIPTOR *arg5, NvU32 arg6, CLI_DMA_ALLOC_MAP_INFO *arg7){
    return NV_ERR_NOT_SUPPORTED;
}

static inline NV_STATUS dmaAllocBar1P2PMapping_395e98(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma, DMA_BAR1P2P_MAPPING_PRARAMS *params){
    return NV_ERR_NOT_SUPPORTED;
}

static inline void dmaFreeBar1P2PMapping_d44104(struct VirtMemAllocator *pDma, CLI_DMA_MAPPING_INFO *arg2){
    return;
}

static inline NvBool dmaIsDefaultGpuUncached_d69453(struct VirtMemAllocator *pDma, MEMORY_DESCRIPTOR *pMemDesc, GMMU_APERTURE aperture, NvBool bIndirectPeer){
    return NV_FALSE;
}

static inline NV_STATUS dmaUpdateVASpace_395e98(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma, struct OBJVASPACE *pVAS, MEMORY_DESCRIPTOR *pMemDesc, NvU8 *tgtPteMem, NvU64 vAddr, NvU64 vAddrLimit, NvU32 flags, DMA_PAGE_ARRAY *pPageArray, COMPR_INFO *pComprInfo, NvU64 surfaceOffset, NvU32 valid, GMMU_APERTURE aperture, NvBool isVolatile, NvU32 peer, NvU64 fabricAddr, NvU32 deferInvalidate, NvBool bSparse, NvU64 pageSize){
    return NV_ERR_NOT_SUPPORTED;
}

static inline NV_STATUS dmaXlateVAtoPAforChannel_395e98(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma, struct KernelChannel *pKernelChannel, NvU64 vAddr, NvU64 *pAddr, NvU32 *memType){
    return NV_ERR_NOT_SUPPORTED;
}

static inline NvU32 dmaGetPTESize_474d46(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma){
    NV_ASSERT_OR_RETURN_PRECOMP(0, 0);
}

static inline NV_STATUS dmaMapBuffer_5baef9(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma, struct OBJVASPACE *pVAS, PMEMORY_DESCRIPTOR pMemDesc, NvU64 *pVaddr, NvU32 allocFlags, NvU32 mapFlags){
    NV_ASSERT_OR_RETURN_PRECOMP(0, NV_ERR_NOT_SUPPORTED);
}

static inline void dmaUnmapBuffer_f2d351(struct OBJGPU *pGpu, struct VirtMemAllocator *pDma, struct OBJVASPACE *pVAS, NvU64 vaddr){
    NV_ASSERT_PRECOMP(0);
}

static inline struct OBJVASPACE * dmaGetPrivateVAS_9e2234(struct VirtMemAllocator *pDma){
    return ((void *)0);
}

// Static dispatch method declarations
// Static inline method definitions
#undef PRIVATE_FIELD


//
// Virtual Memory Manager
//

//
// The VA space is the root of an address space.
//
// Currently we support 2 page sizes
//
#define VAS_PAGESIZE_IDX_4K    0
#define VAS_PAGESIZE_IDX_BIG   1
#define VAS_PAGESIZE_IDX_HUGE  2
#define VAS_PAGESIZE_IDX_512M  3
#define VAS_PAGESIZE_IDX_256G  4

/*!
 * Abstracts an array of physical page addresses.
 */
struct DMA_PAGE_ARRAY
{
    void        *pData;       //!< Array of PTE addresses or opaque OS-specific data.
    NvU32        startIndex;  //!< Base index into the pData array.
    NvU32        count;       //!< Number of pages represented by this array.
    NvBool       bOsFormat;   //!< Indicates if pData is an opaque OS-specific data.
    NvBool       bDuplicate;  //!< Indicates to duplicate the address of the first page.
    NvBool       bLocalized;  //!< Indicates if its localized memory or not.
    //
    // If DMA_PAGE_ARRARY_FLAGS_LOCALIZED, OR the physical address against this to
    // get the address to be programmed into HW.
    //
    NvU64        localizedMask;
    NvU32        PteAdjust;   //!< PteAdjust of the memdesc
    OS_GPU_INFO *pOsGpuInfo;  //!< OS-specific GPU info needed for IOMMU on Windows.
};

// page array operations
void dmaPageArrayInit(DMA_PAGE_ARRAY *pPageArray, void *pPageData, NvU32 pageCount);

#define DMA_PAGE_ARRAY_FLAGS_NONE       0ULL

#define DMA_PAGE_ARRARY_FLAGS_LOCALIZED  NVBIT64(0)

void dmaPageArrayInitWithFlags(DMA_PAGE_ARRAY *pPageArray, void *pPageData, NvU32 pageCount,
                               NvU64 flags, NvU64 localizedMask);

void dmaPageArrayInitFromMemDesc(DMA_PAGE_ARRAY *pPageArray,
                                 MEMORY_DESCRIPTOR *pMemDesc,
                                 ADDRESS_TRANSLATION addressTranslation);
RmPhysAddr dmaPageArrayGetPhysAddr(DMA_PAGE_ARRAY *pPageArray, NvU32 pageIndex);

//
// hal.dmaUpdateVASpace() flags
//
#define DMA_UPDATE_VASPACE_FLAGS_NONE               0
#define DMA_UPDATE_VASPACE_FLAGS_UPDATE_PADDR       NVBIT(0)
#define DMA_UPDATE_VASPACE_FLAGS_UPDATE_COMPR       NVBIT(1)
#define DMA_UPDATE_VASPACE_FLAGS_UPDATE_ACCESS      NVBIT(2)
#define DMA_UPDATE_VASPACE_FLAGS_UPDATE_VALID       NVBIT(3)
#define DMA_UPDATE_VASPACE_FLAGS_UPDATE_PRIV        NVBIT(4)
#define DMA_UPDATE_VASPACE_FLAGS_UPDATE_KIND        NVBIT(5)
#define DMA_UPDATE_VASPACE_FLAGS_UPDATE_APERTURE    NVBIT(6)
#define DMA_UPDATE_VASPACE_FLAGS_UPDATE_PEER        NVBIT(7)
#define DMA_UPDATE_VASPACE_FLAGS_UPDATE_ENCRYPTED   NVBIT(8)
#define DMA_UPDATE_VASPACE_FLAGS_UPDATE_TLB_LOCK    NVBIT(9)
#define DMA_UPDATE_VASPACE_FLAGS_UPDATE_CACHE       NVBIT(10)         // VOLATILE of fermi
#define DMA_UPDATE_VASPACE_FLAGS_UPDATE_SHADER_ACCESS NVBIT(11)       // Kepler shader access
#define DMA_UPDATE_VASPACE_FLAGS_UPDATE_ALL         MASK_BITS(11)

#define DMA_UPDATE_VASPACE_FLAGS_SKIP_4K_PTE_CHECK  NVBIT(12)
#define DMA_UPDATE_VASPACE_FLAGS_FORCE_ACD          NVBIT(15)
#define DMA_UPDATE_VASPACE_FLAGS_ALLOW_REMAP        NVBIT(23)
#define DMA_UPDATE_VASPACE_FLAGS_UNALIGNED_COMP     NVBIT(24)
#define DMA_UPDATE_VASPACE_FLAGS_FILL_PTE_MEM       NVBIT(25)
#define DMA_UPDATE_VASPACE_FLAGS_DISABLE_ENCRYPTION NVBIT(26)
#define DMA_UPDATE_VASPACE_FLAGS_READ_ONLY          NVBIT(27)
#define DMA_UPDATE_VASPACE_FLAGS_PRIV               NVBIT(28)
#define DMA_UPDATE_VASPACE_FLAGS_TLB_LOCK           NVBIT(29)
#define DMA_UPDATE_VASPACE_FLAGS_SHADER_WRITE_ONLY  NVBIT(30)         // Kepler shader access
#define DMA_UPDATE_VASPACE_FLAGS_SHADER_READ_ONLY   NVBIT(31)         // Kepler shader access

//
// hal.dmaAllocVASpace() flags
//
#define DMA_ALLOC_VASPACE_NONE                      0
#define DMA_VA_LIMIT_49B                            NVBIT(0)
#define DMA_VA_LIMIT_57B                            NVBIT(1)
#define DMA_ALLOC_VASPACE_SIZE_ALIGNED              NVBIT(9)
//
// Bug 3610538 For unlinked SLI, clients want to restrict internal buffers to
// Internal VA range, so that SLI vaspaces can mirror each other.
//
#define DMA_ALLOC_VASPACE_USE_RM_INTERNAL_VALIMITS  NVBIT(10)

//
// UVM privileged region
//
#define UVM_KERNEL_PRIVILEGED_REGION_START      (0xFFF8000000ULL)
#define UVM_KERNEL_PRIVILEGED_REGION_LENGTH     (0x0008000000ULL)

#endif // VIRT_MEM_ALLOCATOR_H

#ifdef __cplusplus
} // extern "C"
#endif

#endif // _G_VIRT_MEM_ALLOCATOR_NVOC_H_
